GNU Radio 3.4.0 C++ API
gc_logging.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  */
00021 #ifndef INCLUDED_GCELL_GC_LOGGING_H
00022 #define INCLUDED_GCELL_GC_LOGGING_H
00023 
00024 #include <gcell/gc_types.h>
00025 #include <string.h>
00026 
00027 __GC_BEGIN_DECLS
00028 
00029 typedef struct gc_log {
00030   gc_eaddr_t    base;           // gc_log_entry_t * (16 byte aligned)
00031   uint32_t      nentries;       // number of entries (power-of-2)
00032 } gc_log_t;
00033 
00034 typedef struct gc_log_entry {
00035   uint32_t      seqno;          // monotonic sequence number
00036   uint32_t      timestamp;      // decrementer value (wraps every 53s on PS3)
00037   uint16_t      subsystem;      // 0 to 255 reserved for system, user gets 256 and up
00038   uint16_t      event;
00039   uint32_t      info[5];
00040 } _AL16 gc_log_entry_t;
00041 
00042 #define GCL_SS_SYS      0       // lowest system reserved subsystem
00043 #define GCL_SS_USER   256       // lowest user reserved subsystem
00044 
00045 
00046 /*
00047  * The resulting log files can be displayed using using:
00048  *
00049  *  $ od -t x4 -w32 spu_log.00 | less
00050  */
00051 
00052 
00053 #if defined(__SPU__)
00054 
00055 /*!
00056  * System fills in seqno and timestamp.  User is responsible for the rest.
00057  */
00058 
00059 void _gc_log_write(gc_log_entry_t entry);
00060 
00061 #ifdef ENABLE_GC_LOGGING
00062 #define gc_log_write(entry) _gc_log_write(entry)
00063 #else
00064 #define gc_log_write(entry) do { } while (0)
00065 #endif
00066 
00067 inline static void
00068 gc_log_write0(int subsystem, int event)
00069 {
00070   gc_log_entry_t e;
00071   e.subsystem = subsystem;
00072   e.event = event;
00073   e.info[0] = 0;
00074   e.info[1] = 0;
00075   e.info[2] = 0;
00076   e.info[3] = 0;
00077   e.info[4] = 0;
00078   gc_log_write(e);
00079 }
00080 
00081 inline static void
00082 gc_log_write1(int subsystem, int event,
00083               uint32_t info0)
00084 {
00085   gc_log_entry_t e;
00086   e.subsystem = subsystem;
00087   e.event = event;
00088   e.info[0] = info0;
00089   e.info[1] = 0;
00090   e.info[2] = 0;
00091   e.info[3] = 0;
00092   e.info[4] = 0;
00093   gc_log_write(e);
00094 }
00095 
00096 inline static void
00097 gc_log_write2(int subsystem, int event,
00098               uint32_t info0, uint32_t info1)
00099 {
00100   gc_log_entry_t e;
00101   e.subsystem = subsystem;
00102   e.event = event;
00103   e.info[0] = info0;
00104   e.info[1] = info1;
00105   e.info[2] = 0;
00106   e.info[3] = 0;
00107   e.info[4] = 0;
00108   gc_log_write(e);
00109 }
00110 
00111 inline static void
00112 gc_log_write3(int subsystem, int event,
00113               uint32_t info0, uint32_t info1, uint32_t info2)
00114 {
00115   gc_log_entry_t e;
00116   e.subsystem = subsystem;
00117   e.event = event;
00118   e.info[0] = info0;
00119   e.info[1] = info1;
00120   e.info[2] = info2;
00121   e.info[3] = 0;
00122   e.info[4] = 0;
00123   gc_log_write(e);
00124 }
00125 
00126 inline static void
00127 gc_log_write4(int subsystem, int event,
00128               uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3)
00129 {
00130   gc_log_entry_t e;
00131   e.subsystem = subsystem;
00132   e.event = event;
00133   e.info[0] = info0;
00134   e.info[1] = info1;
00135   e.info[2] = info2;
00136   e.info[3] = info3;
00137   e.info[4] = 0;
00138   gc_log_write(e);
00139 }
00140 
00141 inline static void
00142 gc_log_write5(int subsystem, int event,
00143               uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3, uint32_t info4)
00144 {
00145   gc_log_entry_t e;
00146   e.subsystem = subsystem;
00147   e.event = event;
00148   e.info[0] = info0;
00149   e.info[1] = info1;
00150   e.info[2] = info2;
00151   e.info[3] = info3;
00152   e.info[4] = info4;
00153   gc_log_write(e);
00154 }
00155 
00156 /*!
00157  * One time initialization called by system runtime
00158  */
00159 void
00160 _gc_log_init(gc_log_t log_info);
00161 
00162 #endif
00163 
00164 __GC_END_DECLS
00165 
00166 #endif /* INCLUDED_GCELL_GC_LOGGING_H */