Changeset 466 for soft/giet_vm/giet_common/tty0.c
- Timestamp:
- Dec 12, 2014, 4:55:06 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/tty0.c
r455 r466 10 10 #include <hard_config.h> 11 11 #include <tty0.h> 12 #include <stdarg.h> 12 13 #include <tty_driver.h> 13 #include <stdarg.h>14 14 #include <utils.h> 15 15 #include <locks.h> … … 114 114 } 115 115 116 ////////////////////////////////// 117 void _printf( char * format, ... ) 118 { 119 va_list ap; 120 va_start(ap, format); 121 unsigned int save_sr; // to save SR value in critical section 122 123 // get TTY lock 124 _it_disable( &save_sr ); 125 _simple_lock_acquire( &_tty_tx_lock[0] ); 116 ////////////////////////////////////////////////////////// 117 static void _kernel_printf( char * format, va_list* args ) 118 { 126 119 127 120 printf_text: … … 143 136 } 144 137 145 // release TTY lock146 _simple_lock_release( &_tty_tx_lock[0] );147 _it_restore( &save_sr );148 149 va_end(ap);150 138 return; 151 139 … … 163 151 case ('c'): /* char conversion */ 164 152 { 165 int val = va_arg( ap, int );153 int val = va_arg( *args , int ); 166 154 len = 1; 167 155 buf[0] = val; … … 171 159 case ('d'): /* 32 bits decimal signed */ 172 160 { 173 int val = va_arg( ap, int );161 int val = va_arg( *args , int ); 174 162 if (val < 0) 175 163 { … … 188 176 case ('u'): /* 32 bits decimal unsigned */ 189 177 { 190 unsigned int val = va_arg( ap, unsigned int );178 unsigned int val = va_arg( *args , unsigned int ); 191 179 for(i = 0; i < 10; i++) 192 180 { … … 200 188 case ('x'): /* 32 bits hexadecimal unsigned */ 201 189 { 202 unsigned int val = va_arg( ap, unsigned int );190 unsigned int val = va_arg( *args , unsigned int ); 203 191 if ( _tty0_write( "0x" , 2 ) ) goto return_error; 204 192 for(i = 0; i < 8; i++) … … 213 201 case ('l'): /* 64 bits hexadecimal unsigned */ 214 202 { 215 unsigned long long val = va_arg( ap, unsigned long long );203 unsigned long long val = va_arg( *args , unsigned long long ); 216 204 if ( _tty0_write( "0x" , 2 ) ) goto return_error; 217 205 for(i = 0; i < 16; i++) … … 226 214 case ('s'): /* string */ 227 215 { 228 char* str = va_arg( ap, char* );216 char* str = va_arg( *args , char* ); 229 217 while (str[len]) 230 218 { … … 246 234 247 235 { 248 // release TTY lock 249 _simple_lock_release( &_tty_tx_lock[0] ); 250 _it_restore( &save_sr ); 251 252 // try to print a non protected error message... 236 // try to print an error message and exit... 253 237 unsigned int procid = _get_procid(); 254 238 unsigned int x = (procid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1); 255 239 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 256 240 unsigned int lpid = procid & ((1<<P_WIDTH)-1); 257 258 241 _puts("\n\n[GIET ERROR] in _printf() for processor["); 259 242 _putd( x ); … … 266 249 _exit(); 267 250 } 268 } // end _printf() 251 } // end _kernel_printf() 252 253 /////////////////////////////////////// 254 void _nolock_printf( char* format, ...) 255 { 256 va_list args; 257 258 va_start( args , format ); 259 _kernel_printf( format , &args ); 260 va_end( args ); 261 } 262 //////////////////////////////// 263 void _printf( char* format, ...) 264 { 265 va_list args; 266 unsigned int save_sr; 267 268 // get TTY0 lock 269 _it_disable( &save_sr ); 270 _sbt_lock_acquire( &_tty_tx_lock[0] ); 271 272 va_start( args , format ); 273 _kernel_printf( format , &args ); 274 va_end( args ); 275 276 // release TTY0 lock 277 _sbt_lock_release( &_tty_tx_lock[0] ); 278 _it_restore( &save_sr ); 279 } 269 280 270 281
Note: See TracChangeset
for help on using the changeset viewer.