Changeset 77 for trunk/src/os2ahci/libc.c
- Timestamp:
- Feb 22, 2011, 2:25:44 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/libc.c
r71 r77 60 60 61 61 static char hex_digits[] = "0123456789abcdef"; 62 static ULONG mem_lock; 62 63 static ULONG com_lock; 63 64 … … 94 95 95 96 /****************************************************************************** 96 * Initialize COM1 to 115200,n,8,1 97 * Initialize libc components 98 */ 99 void init_libc(void) 100 { 101 DevHelp_CreateSpinLock(&mem_lock); 102 DevHelp_CreateSpinLock(&com_lock); 103 } 104 105 /****************************************************************************** 106 * Initialize COM port to 115200,n,8,1 97 107 * 98 108 * NOTE: Something is wrong with this code, or the init sequence, but we never 99 109 * got around to fixing it because it works fine on Virtualbox, and on 100 110 * physical machines we tend to have the kernel debugger running on the 101 * same port simply because serial ports are not that plenty on PCs 102 * these days, thus KDB will set port parameters for us. This is going 111 * same port, thus KDB will set port parameters for us. This is going 103 112 * to be fixed eventually... 104 113 */ 105 void init_com 1(void)114 void init_com(void) 106 115 { 107 116 int i; … … 462 471 * sense buffers, etc. and should be freed as soon as possible, otherwise 463 472 * we'll quickly run out of memory. 464 *465 * NOTE: This function is not reentrant, thus must be called with the driver-466 * level spinlock held. The main reason for this design is that most467 * functions that need dynamic memory are already holding the spinlock.468 473 */ 469 474 void *malloc(size_t len) … … 472 477 u16 i; 473 478 u16 n; 479 480 spin_lock(mem_lock); 474 481 475 482 /* find a sequence of free heap units big enough for the requested length */ … … 486 493 heap_units[i] = (u8) (n - i); 487 494 } 495 spin_unlock(mem_lock); 488 496 return(heap_buf + (n - units) * HEAP_UNIT); 489 497 } … … 498 506 499 507 /* out of memory */ 508 spin_unlock(mem_lock); 500 509 dprintf("malloc(%d): out of memory\n", len); 501 510 return(NULL); … … 524 533 525 534 /* clear unit allocation counters in heap_units[] */ 535 spin_lock(mem_lock); 536 526 537 first_unit = (u16) (p - heap_buf) / HEAP_UNIT; 527 538 units = heap_units[first_unit]; … … 529 540 heap_units[i] = 0; 530 541 } 542 543 spin_unlock(mem_lock); 531 544 } 532 545
Note:
See TracChangeset
for help on using the changeset viewer.