Ignore:
Timestamp:
Feb 22, 2011, 2:25:44 AM (14 years ago)
Author:
chris
Message:
  • Further fixes to automatic ATAPI sense handling, now supporting sense buffers larger than 64 bytes if requested by initiator (cdrecord wanted 96 bytes)
  • Separate, and internally handled, spinlock for libc malloc/free calls to reduce chances of memory corruption if somebody forgets to get the driver-level spinlock before calling malloc/free. There was no real problem with that, just some awkward code fragments which look much better now.
  • Link power management implemented
  • More generic support for adapter/port options so all of them can now have a global, adapter or port scope
  • Generic support for inverting driver options (i.e. turn them off with '!')
  • Thorough PCI scan is now the default; the reason it wasn't so far was a delay in Virtualbox but that was never a problem on real hardware
  • SCSI emulation for ATAPI devices; this can be enabled on global, adapter or port scope
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/libc.c

    r71 r77  
    6060
    6161static char  hex_digits[] = "0123456789abcdef";
     62static ULONG mem_lock;
    6263static ULONG com_lock;
    6364
     
    9495
    9596/******************************************************************************
    96  * Initialize COM1 to 115200,n,8,1
     97 * Initialize libc components
     98 */
     99void 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
    97107 *
    98108 * NOTE: Something is wrong with this code, or the init sequence, but we never
    99109 *       got around to fixing it because it works fine on Virtualbox, and on
    100110 *       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
    103112 *       to be fixed eventually...
    104113 */
    105 void init_com1(void)
     114void init_com(void)
    106115{
    107116  int i;
     
    462471 * sense buffers, etc. and should be freed as soon as possible, otherwise
    463472 * 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 most
    467  *       functions that need dynamic memory are already holding the spinlock.
    468473 */
    469474void *malloc(size_t len)
     
    472477  u16 i;
    473478  u16 n;
     479
     480  spin_lock(mem_lock);
    474481
    475482  /* find a sequence of free heap units big enough for the requested length */
     
    486493          heap_units[i] = (u8) (n - i);
    487494        }
     495        spin_unlock(mem_lock);
    488496        return(heap_buf + (n - units) * HEAP_UNIT);
    489497      }
     
    498506
    499507  /* out of memory */
     508  spin_unlock(mem_lock);
    500509  dprintf("malloc(%d): out of memory\n", len);
    501510  return(NULL);
     
    524533
    525534  /* clear unit allocation counters in heap_units[] */
     535  spin_lock(mem_lock);
     536
    526537  first_unit = (u16) (p - heap_buf) / HEAP_UNIT;
    527538  units = heap_units[first_unit];
     
    529540    heap_units[i] = 0;
    530541  }
     542
     543  spin_unlock(mem_lock);
    531544}
    532545
Note: See TracChangeset for help on using the changeset viewer.