Imported Upstream version 3.2.2
[debian/gnuradio] / gcell / include / gcell / gc_logging.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
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)
10  * any later version.
11  * 
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.
16  * 
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.
20  */
21 #ifndef INCLUDED_GCELL_GC_LOGGING_H
22 #define INCLUDED_GCELL_GC_LOGGING_H
23
24 #include <gcell/gc_types.h>
25 #include <string.h>
26
27 __GC_BEGIN_DECLS
28
29 typedef struct gc_log {
30   gc_eaddr_t    base;           // gc_log_entry_t * (16 byte aligned)
31   uint32_t      nentries;       // number of entries (power-of-2)
32 } gc_log_t;
33
34 typedef struct gc_log_entry {
35   uint32_t      seqno;          // monotonic sequence number
36   uint32_t      timestamp;      // decrementer value (wraps every 53s on PS3)
37   uint16_t      subsystem;      // 0 to 255 reserved for system, user gets 256 and up
38   uint16_t      event;
39   uint32_t      info[5];
40 } _AL16 gc_log_entry_t;
41
42 #define GCL_SS_SYS      0       // lowest system reserved subsystem
43 #define GCL_SS_USER   256       // lowest user reserved subsystem
44
45
46 /*
47  * The resulting log files can be displayed using using:
48  *
49  *  $ od -t x4 -w32 spu_log.00 | less
50  */
51
52
53 #if defined(__SPU__)
54
55 /*!
56  * System fills in seqno and timestamp.  User is responsible for the rest.
57  */
58
59 void _gc_log_write(gc_log_entry_t entry);
60
61 #ifdef ENABLE_GC_LOGGING
62 #define gc_log_write(entry) _gc_log_write(entry)
63 #else
64 #define gc_log_write(entry) do { } while (0)
65 #endif
66
67 inline static void
68 gc_log_write0(int subsystem, int event)
69 {
70   gc_log_entry_t e;
71   e.subsystem = subsystem;
72   e.event = event;
73   e.info[0] = 0;
74   e.info[1] = 0;
75   e.info[2] = 0;
76   e.info[3] = 0;
77   e.info[4] = 0;
78   gc_log_write(e);
79 }
80
81 inline static void
82 gc_log_write1(int subsystem, int event,
83               uint32_t info0)
84 {
85   gc_log_entry_t e;
86   e.subsystem = subsystem;
87   e.event = event;
88   e.info[0] = info0;
89   e.info[1] = 0;
90   e.info[2] = 0;
91   e.info[3] = 0;
92   e.info[4] = 0;
93   gc_log_write(e);
94 }
95
96 inline static void
97 gc_log_write2(int subsystem, int event,
98               uint32_t info0, uint32_t info1)
99 {
100   gc_log_entry_t e;
101   e.subsystem = subsystem;
102   e.event = event;
103   e.info[0] = info0;
104   e.info[1] = info1;
105   e.info[2] = 0;
106   e.info[3] = 0;
107   e.info[4] = 0;
108   gc_log_write(e);
109 }
110
111 inline static void
112 gc_log_write3(int subsystem, int event,
113               uint32_t info0, uint32_t info1, uint32_t info2)
114 {
115   gc_log_entry_t e;
116   e.subsystem = subsystem;
117   e.event = event;
118   e.info[0] = info0;
119   e.info[1] = info1;
120   e.info[2] = info2;
121   e.info[3] = 0;
122   e.info[4] = 0;
123   gc_log_write(e);
124 }
125
126 inline static void
127 gc_log_write4(int subsystem, int event,
128               uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3)
129 {
130   gc_log_entry_t e;
131   e.subsystem = subsystem;
132   e.event = event;
133   e.info[0] = info0;
134   e.info[1] = info1;
135   e.info[2] = info2;
136   e.info[3] = info3;
137   e.info[4] = 0;
138   gc_log_write(e);
139 }
140
141 inline static void
142 gc_log_write5(int subsystem, int event,
143               uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3, uint32_t info4)
144 {
145   gc_log_entry_t e;
146   e.subsystem = subsystem;
147   e.event = event;
148   e.info[0] = info0;
149   e.info[1] = info1;
150   e.info[2] = info2;
151   e.info[3] = info3;
152   e.info[4] = info4;
153   gc_log_write(e);
154 }
155
156 /*!
157  * One time initialization called by system runtime
158  */
159 void
160 _gc_log_init(gc_log_t log_info);
161
162 #endif
163
164 __GC_END_DECLS
165
166 #endif /* INCLUDED_GCELL_GC_LOGGING_H */