All pastes #468773 Raw Edit

ata_read_sectors()

public c v1 · immutable
#468773 ·published 2007-05-03 10:46 UTC
rendered paste body
pseudo ata_read_sectors(IF_MV2(int drive,)                     unsigned long start,                     int incount,                     void* inbuf){    // Determine where to start    if (start % 2 != 0)                   // odd starting sector        realstart = start - 1;    else        realstart = start;    // Determine how many sectors to read    if (realstart + incount % 2 != 0)     // odd number of sectors to read        realcount = incount + 1;    else        realcount = incount;    copy_read_sectors(buf, wordcount);        // Return the data actually requested.    // buf now (probably) contains more data than     // we wanted.        if (realstart != start)        memcpy (realbuf, buf + ATA_SECTOR_SIZE , ATA_SECTOR_SIZE * count);    else        memcpy (realbuf, buf, ATA_SECTOR_SIZE * count);}