Changeset 623 for trunk/kernel/kern/printk.c
- Timestamp:
- Mar 6, 2019, 4:37:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/printk.c
r583 r623 48 48 49 49 va_list args; // printf arguments 50 uint32_t ps; // writepointer to the string buffer50 uint32_t ps; // pointer to the string buffer 51 51 52 52 ps = 0; … … 57 57 while ( *format != 0 ) 58 58 { 59 60 59 if (*format == '%') // copy argument to string 61 60 { … … 98 97 break; 99 98 } 100 case ('d'): // decimal signed integer 99 case ('b'): // excactly 2 digits hexadecimal integer 100 { 101 int val = va_arg( args, int ); 102 int val_lsb = val & 0xF; 103 int val_msb = (val >> 4) & 0xF; 104 buf[0] = HexaTab[val_msb]; 105 buf[1] = HexaTab[val_lsb]; 106 len = 2; 107 pbuf = buf; 108 break; 109 } 110 case ('d'): // up to 10 digits decimal signed integer 101 111 { 102 112 int val = va_arg( args, int ); … … 108 118 for(i = 0; i < 10; i++) 109 119 { 110 111 120 buf[9 - i] = HexaTab[val % 10]; 112 121 if (!(val /= 10)) break; … … 116 125 break; 117 126 } 118 case ('u'): // decimal unsigned integer127 case ('u'): // up to 10 digits decimal unsigned integer 119 128 { 120 129 uint32_t val = va_arg( args, uint32_t ); … … 128 137 break; 129 138 } 130 case ('x'): // 32 bits hexadecimal131 case ('l'): // 64 bits hexadecimal139 case ('x'): // up to 8 digits hexadecimal 140 case ('l'): // up to 16 digits hexadecimal 132 141 { 133 142 uint32_t imax; … … 157 166 break; 158 167 } 159 case ('X'): // 32 bits hexadecimal on 8 characters168 case ('X'): // exactly 8 digits hexadecimal 160 169 { 161 170 uint32_t val = va_arg( args , uint32_t ); … … 238 247 case ('c'): /* char conversion */ 239 248 { 240 int val = va_arg( *args , int );249 int val = va_arg( *args , int ); 241 250 len = 1; 242 buf[0] = val;251 buf[0] = (char)val; 243 252 pbuf = &buf[0]; 244 253 break; 245 254 } 246 case ('d'): /* 32 bits decimal signed */ 255 case ('b'): // excactly 2 digits hexadecimal 256 { 257 int val = va_arg( *args, int ); 258 int val_lsb = val & 0xF; 259 int val_msb = (val >> 4) & 0xF; 260 buf[0] = HexaTab[val_msb]; 261 buf[1] = HexaTab[val_lsb]; 262 len = 2; 263 pbuf = buf; 264 break; 265 } 266 case ('d'): /* up to 10 digits signed decimal */ 247 267 { 248 268 int val = va_arg( *args , int ); … … 261 281 break; 262 282 } 263 case ('u'): /* 32 bits decimal unsigned*/283 case ('u'): /* up to 10 digits unsigned decimal */ 264 284 { 265 285 uint32_t val = va_arg( *args , uint32_t ); … … 273 293 break; 274 294 } 275 case ('x'): /* 32 bits hexadecimal unsigned*/295 case ('x'): /* up to 8 digits hexadecimal */ 276 296 { 277 297 uint32_t val = va_arg( *args , uint32_t ); … … 286 306 break; 287 307 } 288 case ('X'): /* 32 bits hexadecimal unsigned on 10 char*/308 case ('X'): /* exactly 8 digits hexadecimal */ 289 309 { 290 310 uint32_t val = va_arg( *args , uint32_t ); … … 299 319 break; 300 320 } 301 case ('l'): /* 64 bits hexadecimal unsigned*/302 { 303 u nsigned long long val = va_arg( *args , unsigned long long);321 case ('l'): /* up to 16 digits hexadecimal */ 322 { 323 uint64_t val = va_arg( *args , uint64_t ); 304 324 dev_txt_sync_write( "0x" , 2 ); 305 325 for(i = 0; i < 16; i++) … … 312 332 break; 313 333 } 314 case ('L'): /* 64 bits hexadecimal unsigned on 18 char*/315 { 316 u nsigned long long val = va_arg( *args , unsigned long long);334 case ('L'): /* exactly 16 digits hexadecimal */ 335 { 336 uint64_t val = va_arg( *args , uint64_t ); 317 337 dev_txt_sync_write( "0x" , 2 ); 318 338 for(i = 0; i < 16; i++) … … 525 545 } 526 546 547 ///////////////////////////// 548 void putb( char * string, 549 uint8_t * buffer, 550 uint32_t size ) 551 { 552 uint32_t line; 553 uint32_t byte = 0; 554 555 // get pointers on TXT0 chdev 556 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 557 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 558 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); 559 560 // get extended pointer on remote TXT0 chdev lock 561 xptr_t lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 562 563 // get TXT0 lock 564 remote_busylock_acquire( lock_xp ); 565 566 // display string on TTY0 567 nolock_printk("\n***** %s *****\n", string ); 568 569 for ( line = 0 ; line < (size>>4) ; line++ ) 570 { 571 nolock_printk(" %X | %b %b %b %b | %b %b %b %b | %b %b %b %b | %b %b %b %b \n", 572 byte, 573 buffer[byte+ 0],buffer[byte+ 1],buffer[byte+ 2],buffer[byte+ 3], 574 buffer[byte+ 4],buffer[byte+ 5],buffer[byte+ 6],buffer[byte+ 7], 575 buffer[byte+ 8],buffer[byte+ 9],buffer[byte+10],buffer[byte+11], 576 buffer[byte+12],buffer[byte+13],buffer[byte+14],buffer[byte+15] ); 577 578 byte += 16; 579 } 580 581 // release TXT0 lock 582 remote_busylock_release( lock_xp ); 583 } 584 585 527 586 528 587 // Local Variables:
Note: See TracChangeset
for help on using the changeset viewer.