3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <gcell/gc_logging.h>
23 #include <gcell/gc_spu_args.h>
24 #include <spu_intrinsics.h>
25 #include <spu_mfcio.h>
27 static gc_eaddr_t log_base_ea; // base address of log entries in EA
28 static uint32_t log_idx_mask; // nentries - 1
29 static uint32_t log_idx; // current log entry index
30 static uint32_t log_seqno;
32 static int log_tags; // two consecutive tags
33 static int tmp_buffer_busy; // bitmask: buffer busy state
34 static int tmp_buffer_idx; // 0 or 1
35 static gc_log_entry_t tmp_buffer[2];
38 _gc_log_init(gc_log_t info)
40 spu_write_decrementer(~0);
42 log_base_ea = info.base;
43 log_idx_mask = info.nentries - 1;
47 log_tags = mfc_multi_tag_reserve(2);
51 gc_log_write0(GCL_SS_SYS, 0);
55 _gc_log_write(gc_log_entry_t entry)
60 entry.seqno = log_seqno++;
61 entry.timestamp = spu_read_decrementer();
63 if (tmp_buffer_busy & (1 << tmp_buffer_idx)){
64 mfc_write_tag_mask(1 << (log_tags + tmp_buffer_idx));
65 mfc_read_tag_status_all();
68 tmp_buffer[tmp_buffer_idx] = entry; // save local copy
70 mfc_put(&tmp_buffer[tmp_buffer_idx],
71 log_base_ea + log_idx * sizeof(entry), sizeof(entry),
72 log_tags + tmp_buffer_idx, 0, 0);
74 tmp_buffer_busy |= (1 << tmp_buffer_idx);
75 tmp_buffer_idx ^= 0x1;
76 log_idx = (log_idx + 1) & log_idx_mask;