Changeset 407 for trunk/kernel/kern/printk.c
- Timestamp:
- Nov 7, 2017, 3:08:12 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/printk.c
r406 r407 190 190 goto xprintf_text; 191 191 } 192 } // end xprintf() 193 194 /////////////////////////////////////////////////////////////////////////////////// 195 // This static function is called by kernel_printf() to display a string on the 196 // TXT channel defined by the <channel> argument. 197 // The access mode is defined by the <busy> argument: 198 // - if <busy> is true, it uses the dev_txt_sync_write() function, that takes the 199 // TXT lock, and call directly the relevant TXT driver, without descheduling. 200 // - if <busy is false, it uses the dev_txt_write() function, that register the 201 // write buffer in the relevant TXT chdev queue, and uses a descheduling policy. 202 /////////////////////////////////////////////////////////////////////////////////// 203 // @ channel : TXT channel. 204 // @ busy : TXT device acces mode (busy waiting if non zero). 205 // @ buf : buffer containing the characters. 206 // @ nc : number of characters. 207 // return 0 if success / return -1 if TTY0 busy after 10000 retries. 208 /////////////////////////////////////////////////////////////////////////////////// 209 static error_t txt_write( uint32_t channel, 210 uint32_t busy, 211 char * buffer, 212 uint32_t count ) 213 { 214 if( busy ) return dev_txt_sync_write( channel , buffer , count ); 215 else return dev_txt_write( channel , buffer , count ); 216 } 192 } // end snprintf() 217 193 218 194 ////////////////////////////////////////////////////////////////////////////////////// 219 // This static function is called by printk(), assert() and nolock_printk() to build220 // a formated string.195 // This static function is called by printk(), assert() and nolock_printk() 196 // to display a formated string on TXT0, using a busy waiting policy. 221 197 ////////////////////////////////////////////////////////////////////////////////////// 222 // @ channel : channel index.223 // @ busy : TXT device access mode (busy waiting if non zero).224 198 // @ format : printf like format. 225 // @ args : formatarguments.199 // @ args : va_list of arguments. 226 200 ////////////////////////////////////////////////////////////////////////////////////// 227 static void kernel_printf( uint32_t channel, 228 uint32_t busy, 229 char * format, 201 static void kernel_printf( char * format, 230 202 va_list * args ) 231 203 { … … 239 211 if (i) 240 212 { 241 txt_write( channel, busy,format, i );213 dev_txt_sync_write( format, i ); 242 214 format += i; 243 215 } … … 276 248 { 277 249 val = -val; 278 txt_write( channel, busy,"-" , 1 );250 dev_txt_sync_write( "-" , 1 ); 279 251 } 280 252 for(i = 0; i < 10; i++) … … 302 274 { 303 275 uint32_t val = va_arg( *args , uint32_t ); 304 txt_write( channel, busy,"0x" , 2 );276 dev_txt_sync_write( "0x" , 2 ); 305 277 for(i = 0; i < 8; i++) 306 278 { … … 315 287 { 316 288 uint32_t val = va_arg( *args , uint32_t ); 317 txt_write( channel, busy,"0x" , 2 );289 dev_txt_sync_write( "0x" , 2 ); 318 290 for(i = 0; i < 8; i++) 319 291 { … … 328 300 { 329 301 unsigned long long val = va_arg( *args , unsigned long long ); 330 txt_write( channel, busy,"0x" , 2 );302 dev_txt_sync_write( "0x" , 2 ); 331 303 for(i = 0; i < 16; i++) 332 304 { … … 341 313 { 342 314 unsigned long long val = va_arg( *args , unsigned long long ); 343 txt_write( channel, busy,"0x" , 2 );315 dev_txt_sync_write( "0x" , 2 ); 344 316 for(i = 0; i < 16; i++) 345 317 { … … 363 335 default: 364 336 { 365 txt_write( channel , busy, 366 "\n[PANIC] in kernel_printf() : illegal format\n", 45 ); 367 } 368 } 369 370 if( pbuf != NULL ) txt_write( channel, busy, pbuf, len ); 337 dev_txt_sync_write( "\n[PANIC] in kernel_printf() : illegal format\n", 45 ); 338 } 339 } 340 341 if( pbuf != NULL ) dev_txt_sync_write( pbuf, len ); 371 342 372 343 goto printf_text; … … 382 353 383 354 // get pointers on TXT0 chdev 384 xptr_t txt0_xp = chdev_dir.txt [0];355 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 385 356 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 386 357 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); … … 394 365 // call kernel_printf on TXT0, in busy waiting mode 395 366 va_start( args , format ); 396 kernel_printf( 0 , 1 ,format , &args );367 kernel_printf( format , &args ); 397 368 va_end( args ); 398 369 … … 408 379 // call kernel_printf on TXT0, in busy waiting mode 409 380 va_start( args , format ); 410 kernel_printf( 0 , 1 ,format , &args );381 kernel_printf( format , &args ); 411 382 va_end( args ); 412 383 } … … 419 390 420 391 // get pointers on TXT0 chdev 421 xptr_t txt0_xp = chdev_dir.txt [0];392 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 422 393 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 423 394 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); … … 431 402 // call kernel_printf on TXT0, in busy waiting mode 432 403 va_start( args , format ); 433 kernel_printf( 0 , 1 ,format , &args );404 kernel_printf( format , &args ); 434 405 va_end( args ); 435 406 … … 456 427 { 457 428 // get pointers on TXT0 chdev 458 xptr_t txt0_xp = chdev_dir.txt [0];429 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 459 430 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 460 431 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); … … 471 442 // call kernel_printf on TXT0, in busy waiting to print format 472 443 va_start( args , format ); 473 kernel_printf( 0 , 1 ,format , &args );444 kernel_printf( format , &args ); 474 445 va_end( args ); 475 446
Note: See TracChangeset
for help on using the changeset viewer.