Mercurial > nand-ecoscentric
annotate packages/kernel/current/src/instrmnt/meminst.cxx @ 6:d376b777e2ce ecos-sw-1999-05-14
Merge from eCos master repository on 1999-05-14-19:27:43-BST
| author | jlarmour |
|---|---|
| date | Fri, 14 May 1999 12:20:00 +0000 |
| parents | 443894e2e912 |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 2 | 3 // instrmnt/meminst.cxx |
| 0 | 4 // |
| 2 | 5 // Memory buffer instrumentation functions |
| 0 | 6 // |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 2 | 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 0 | 26 // ------------------------------------------- |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //========================================================================== | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 2 | 32 // Author(s): nickg |
| 33 // Contributors: nickg | |
| 34 // Date: 1997-10-27 | |
| 35 // Purpose: Instrumentation functions | |
| 36 // Description: The functions in this file are implementations of the | |
| 0 | 37 // standard instrumentation functions that place records |
| 38 // into a memory buffer. | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 // | |
| 42 //========================================================================== | |
| 43 | |
| 44 #include <pkgconf/kernel.h> | |
| 45 | |
| 46 #include <cyg/kernel/ktypes.h> // base kernel types | |
| 47 #include <cyg/infra/cyg_trac.h> // tracing macros | |
| 48 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 49 #include <cyg/kernel/instrmnt.h> // instrumentation | |
| 50 | |
| 51 #include <cyg/kernel/intr.hxx> // interrupt control | |
| 52 #include <cyg/kernel/sched.hxx> // scheduler defines | |
| 53 | |
| 54 #include <cyg/kernel/sched.inl> // scheduler inlines | |
| 55 #include <cyg/kernel/clock.inl> // clock inlines | |
| 56 | |
| 57 #ifdef CYGPKG_KERNEL_INSTRUMENT | |
| 58 | |
| 59 // ------------------------------------------------------------------------- | |
| 60 // Instrumentation record. | |
| 61 | |
| 62 struct Instrument_Record | |
| 63 { | |
| 64 CYG_WORD16 type; // record type | |
| 65 CYG_WORD16 thread; // current thread id | |
| 66 CYG_WORD timestamp; // 32 bit timestamp | |
| 67 CYG_WORD arg1; // first arg | |
| 68 CYG_WORD arg2; // second arg | |
| 69 }; | |
| 70 | |
| 71 // ------------------------------------------------------------------------- | |
| 72 // Buffer base and end. This buffer must be a whole number of | |
| 73 | |
| 74 #ifdef CYGVAR_KERNEL_INSTRUMENT_EXTERNAL_BUFFER | |
| 75 | |
| 76 externC Instrument_Record instrument_buffer[]; | |
| 77 externC cyg_uint32 instrument_buffer_size; | |
| 78 | |
| 79 #else | |
| 80 | |
| 81 extern "C" | |
| 82 { | |
| 83 | |
| 84 Instrument_Record instrument_buffer[CYGNUM_KERNEL_INSTRUMENT_BUFFER_SIZE]; | |
| 85 | |
| 86 cyg_uint32 instrument_buffer_size = CYGNUM_KERNEL_INSTRUMENT_BUFFER_SIZE; | |
| 87 | |
| 88 }; | |
| 89 | |
| 90 #endif | |
| 91 | |
| 92 extern "C" | |
| 93 { | |
| 94 | |
| 95 #define instrument_buffer_start instrument_buffer[0] | |
| 96 #define instrument_buffer_end instrument_buffer[instrument_buffer_size] | |
| 97 | |
| 98 extern "C" | |
| 99 { | |
| 100 Instrument_Record *instrument_buffer_pointer = &instrument_buffer_start; | |
| 101 }; | |
| 102 | |
| 103 #ifdef CYGDBG_KERNEL_INSTRUMENT_FLAGS | |
| 104 | |
| 105 // This array contains a 32 bit word for each event class. The | |
| 106 // bits in the word correspond to events. By setting or clearing | |
| 107 // the appropriate bit, the selected instrumentation event may | |
| 108 // be enabled or disabled dynamically. | |
| 109 | |
| 110 cyg_uint32 instrument_flags[(CYG_INSTRUMENT_CLASS_MAX>>8)+1]; | |
| 111 | |
| 112 #endif | |
| 113 | |
| 114 }; | |
| 115 | |
| 116 // ------------------------------------------------------------------------- | |
| 117 | |
| 118 void cyg_instrument( cyg_uint32 type, CYG_ADDRWORD arg1, CYG_ADDRWORD arg2 ) | |
| 119 { | |
| 120 | |
| 121 cyg_uint32 old_ints; | |
| 122 | |
| 123 #ifdef CYGDBG_KERNEL_INSTRUMENT_FLAGS | |
| 124 | |
| 125 cyg_ucount8 cl = (type>>8)&0xff; | |
| 126 cyg_ucount8 event = type&0xff; | |
| 127 | |
| 128 if( instrument_flags[cl] & (1<<event) ) | |
| 129 #endif | |
| 130 { | |
| 131 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 132 | |
| 133 Instrument_Record *p = instrument_buffer_pointer; | |
| 134 Cyg_Thread *t = Cyg_Scheduler::get_current_thread(); | |
| 135 p->type = type; | |
| 136 p->thread = (t==0)?0xFFFF:t->get_unique_id(); | |
| 137 #ifdef CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 138 // p->timestamp = Cyg_Clock::real_time_clock->current_value_lo(); | |
| 139 HAL_CLOCK_READ( &p->timestamp ); | |
| 140 #else | |
| 141 p->timestamp = 0; | |
| 142 #endif | |
| 143 p->arg1 = arg1; | |
| 144 p->arg2 = arg2; | |
| 145 | |
| 146 p++; | |
|
6
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
147 #ifdef CYGDBG_KERNEL_INSTRUMENT_BUFFER_WRAP |
| 0 | 148 if( p == &instrument_buffer_end ) |
| 149 instrument_buffer_pointer = &instrument_buffer_start; | |
| 150 else instrument_buffer_pointer = p; | |
|
6
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
151 #else |
|
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
152 // when not wrapping, just continue to put further entries |
|
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
153 // in the last slot. |
|
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
154 if( p != &instrument_buffer_end ) |
|
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
155 instrument_buffer_pointer = p; |
|
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
156 #endif |
| 0 | 157 HAL_RESTORE_INTERRUPTS(old_ints); |
| 158 } | |
| 159 | |
| 160 return; | |
| 161 } | |
| 162 | |
| 163 // ------------------------------------------------------------------------- | |
| 164 // Functions to enable and disable selected instrumentation events | |
| 165 // when the flags are enabled. | |
| 166 | |
| 167 #ifdef CYGDBG_KERNEL_INSTRUMENT_FLAGS | |
| 168 | |
| 169 externC void cyg_instrument_enable( cyg_uint32 cl, cyg_uint32 event) | |
| 170 { | |
| 171 if( 0 != event ) | |
| 172 instrument_flags[cl>>8] |= 1<<event; | |
| 173 else | |
| 174 instrument_flags[cl>>8] = ~0; | |
| 175 } | |
| 176 | |
| 177 externC void cyg_instrument_disable( cyg_uint32 cl, cyg_uint32 event) | |
| 178 { | |
| 179 if( 0 != event ) | |
| 180 instrument_flags[cl>>8] &= ~(1<<event); | |
| 181 else | |
| 182 instrument_flags[cl>>8] = 0; | |
| 183 | |
| 184 } | |
| 185 | |
| 186 #endif | |
| 187 | |
| 188 // ------------------------------------------------------------------------- | |
| 189 | |
| 190 #endif // CYGPKG_KERNEL_INSTRUMENT | |
| 191 | |
| 192 // EOF instrmnt/null.cxx |
