Changeset 111 for trunk/src/os2ahci/libc.c
- Timestamp:
- Jun 27, 2011, 6:40:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/libc.c
r110 r111 58 58 ULONG parm2); 59 59 static int mdelay_cal_end (void); 60 static int trace_enabled (void); 60 61 61 62 /* ------------------------ global/static variables ------------------------ */ … … 98 99 static ULONG heap_phys_addr; 99 100 101 /* global info segment */ 102 volatile PGINFOSEG gis; 103 104 100 105 /* ----------------------------- start of code ----------------------------- */ 101 106 … … 105 110 void init_libc(void) 106 111 { 112 PSEL p; 113 107 114 DevHelp_CreateSpinLock(&mem_lock); 108 115 DevHelp_CreateSpinLock(&com_lock); 109 116 110 117 DevHelp_VirtToPhys(heap_buf, &heap_phys_addr); 118 119 /* get global info segment */ 120 if (DevHelp_GetDOSVar(DHGETDOSV_SYSINFOSEG, 0, (PPVOID) &p) == 0) { 121 gis = (PGINFOSEG) ((u32) *p << 16); 122 } 123 111 124 } 112 125 … … 263 276 static char buf[1024]; 264 277 char *s; 278 int len; 265 279 266 280 spin_lock(com_lock); 267 281 268 vsprintf(buf, fmt, va); 282 len = vsprintf(buf, fmt, va); 283 284 if (com_base == 0) { 285 /* write debug message to trace buffer, not COM port */ 286 trace(debug, len, buf); 287 spin_unlock(com_lock); 288 return; 289 } 269 290 270 291 /* write debug message to serial port */ … … 329 350 vsprintf(buf, fmt, va); 330 351 331 if (debug ) {352 if (debug && com_base != 0) { 332 353 /* print the same message to COM1 as well */ 333 354 printf("%s", buf); … … 346 367 * Print hex buffer to COM port. 347 368 */ 348 void phex(const void _far *p, int len, const char *fmt, ...)369 void phex(const void _far *p, int len, u16 trace_minor_code, const char *fmt, ...) 349 370 { 350 371 va_list va; … … 353 374 354 375 if (!debug) { 376 return; 377 } 378 379 if (!com_base) { 380 /* dump to kernel trace buffer, not serial port; 381 * just dump the buffer, it is formatted by TRACEFMT 382 * 383 * NOTE: writing the header to the trace buffer causes 384 * the trace facility to hick up and swallow the 385 * binary data that follows... 386 */ 387 trace(trace_minor_code, len, buf); 355 388 return; 356 389 } … … 705 738 void msleep(u32 millies) 706 739 { 707 volatile PGINFOSEG gis;708 740 ULONG start; 709 741 ULONG end; 710 PSEL p; 711 712 if (DevHelp_GetDOSVar(DHGETDOSV_SYSINFOSEG, 0, (PPVOID) &p)) { 742 743 if (gis == NULL) { 713 744 /* no global info segment; use mdelay() */ 714 745 mdelay(millies); 715 746 return; 716 747 } 717 gis = (PGINFOSEG) ((u32) *p << 16); 748 718 749 start = gis->msecs; 719 750 end = start + millies; … … 834 865 return(mdelay_cal_status == MD_CALIBRATION_END); 835 866 } 867 868 /****************************************************************************** 869 * is_trace_enabled - checks if kernel tracing is enabled 870 */ 871 int is_trace_enabled(void) 872 { 873 int ret = 1; /* if global info seg is not present/known, 874 * we enable tracing for now */ 875 876 /* check global info segment's trace enabled bitmap if our 877 * major trace code is enabled 878 */ 879 if (gis) { 880 u8 trace_bitmap = gis->amecRAS[AHCI_TRACE_MAJOR / 8]; 881 if (trace_bitmap & (0x80 >> (AHCI_TRACE_MAJOR % 8))) { 882 ret = 1; 883 } else { 884 ret = 0; 885 } 886 } 887 888 return ret; 889 } 890 891 /****************************************************************************** 892 * trace - write a buffer to the kernel trace buffer 893 */ 894 void trace(u16 minor_code, u16 cb_buf, const char _far *buf) 895 { 896 if (!is_trace_enabled()) { 897 return; 898 } 899 900 DevHelp_RAS(AHCI_TRACE_MAJOR, minor_code, cb_buf, (PBYTE) buf); 901 } 902
Note:
See TracChangeset
for help on using the changeset viewer.