Changeset 1916

Show
Ignore:
Timestamp:
02/25/09 01:21:12 (3 years ago)
Author:
mwhitworth
Message:

Move ind/inw reading code to AtaDataRead function, let ATA disk code use it, check against drive->totalSectors for out of bound I/O, and misc formatting.

Location:
Whitix/trunk/devices/storage/ata
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/devices/storage/ata/ata-cd.c

    r1885 r1916  
    101101/*********************************************************************** 
    102102 * 
    103  * FUNCTION:    AtapiRead 
    104  * 
    105  * DESCRIPTION: Read data from the drive controller. 
    106  * 
    107  * PARAMETERS:  controller - controller of the drive. 
    108  *                              buffer - buffer to transfer data into. 
    109  *                              count - number of bytes available. 
    110  * 
    111  * RETURNS:             Nothing. 
    112  * 
    113  ***********************************************************************/ 
    114  
    115 static void AtapiRead(struct AtaDrive* drive, BYTE* buffer, int count) 
    116 { 
    117         if (!count) 
    118         { 
    119                 KePrint("AtapiRead: no bytes to read.\n"); 
    120                 return; 
    121         } 
    122          
    123         if (drive->ioFlags & ATA_IO_DWORD) 
    124                 insd(CTRL_REG(drive->parent, REG_DATA), buffer, count >> 2); 
    125         else 
    126                 insw(CTRL_REG(drive->parent,REG_DATA), buffer, count >> 1); 
    127 } 
    128  
    129 /*********************************************************************** 
    130  * 
    131103 * FUNCTION:    AtapiError 
    132104 * 
     
    205177                count=AtapiTransferCount(drive->parent); 
    206178                 
    207                 AtapiRead(drive, (BYTE*)request->data, count); 
     179                AtaDataRead(drive, (BYTE*)request->data, count); 
    208180                 
    209181                request->data+=ATAPI_SECTOR_SIZE; 
  • Whitix/trunk/devices/storage/ata/ata-disk.c

    r1885 r1916  
    2828{ 
    2929        struct Request* request=StorageGetCurrRequest(drive->sDev); 
    30         WORD* p=(WORD*)request->data; 
     30        BYTE* p=(WORD*)request->data; 
    3131        int i; 
    3232 
    3333        if (!request) 
    34         { 
    35                 KePrint("AtaRwInterrupt: request is null?\n"); 
    3634                return; 
    37         } 
    3835 
    39         if (status & STATE_ERR || status & STATE_DF) 
     36        if ( (status & STATE_ERR) || (status & STATE_DF)) 
    4037        { 
    4138                KePrint("AtaRwInterrupt: failure reading sector %u\n",request->sector); 
     
    5350                        return; 
    5451                } 
    55  
    56                 for (i=0; i<256; i++) 
    57                         p[i]=inw(CTRL_REG(drive->parent,REG_DATA)); 
     52                 
     53                AtaDataRead(drive, p, 512); 
    5854        } 
    5955 
     
    7773        /* If the request is out of bounds, notify the request code and process 
    7874         * another request. */ 
    79         if (request->sector > (drive->cyls*drive->heads*drive->sectors)) 
     75        if (request->sector > drive->totalSectors) 
    8076                return AtaFinishRequest(drive, -EIO); 
    8177         
     
    8682        command.count=1; /* For now */ 
    8783 
    88         drive->interrupt=AtaRwInterrupt; 
     84        drive->interrupt = AtaRwInterrupt; 
    8985        err=AtaSendCommand(drive,&command); 
    9086 
  • Whitix/trunk/devices/storage/ata/ata-identify.c

    r1872 r1916  
    8383        }else{ 
    8484                KePrint("CHS: TODO\n"); 
    85         } 
     85        }        
    8686} 
    8787 
  • Whitix/trunk/devices/storage/ata/ata.c

    r1885 r1916  
    5353 
    5454KE_OBJECT_TYPE_SIMPLE(ataType, NULL); 
     55 
     56/*********************************************************************** 
     57 * 
     58 * FUNCTION:    AtaDataRead 
     59 * 
     60 * DESCRIPTION: Read data from the drive controller. 
     61 * 
     62 * PARAMETERS:  controller - controller of the drive. 
     63 *                              buffer - buffer to transfer data into. 
     64 *                              count - number of bytes available. 
     65 * 
     66 * RETURNS:             Nothing. 
     67 * 
     68 ***********************************************************************/ 
     69 
     70void AtaDataRead(struct AtaDrive* drive, BYTE* buffer, int count) 
     71{ 
     72        if (!count) 
     73        { 
     74                KePrint(KERN_ERROR "AtaDataRead: no bytes to read.\n"); 
     75                return; 
     76        } 
     77         
     78        if (drive->ioFlags & ATA_IO_DWORD) 
     79                insd(CTRL_REG(drive->parent, REG_DATA), buffer, count >> 2); 
     80        else 
     81                insw(CTRL_REG(drive->parent,REG_DATA), buffer, count >> 1); 
     82} 
    5583 
    5684/*********************************************************************** 
  • Whitix/trunk/devices/storage/ata/ata.h

    r1885 r1916  
    199199int AtaFinishRequest(struct AtaDrive* drive, int status); 
    200200 
     201void AtaDataRead(struct AtaDrive* drive, BYTE* buffer, int count); 
     202 
    201203/* Drive-specific functions */ 
    202204int AtaReadWrite(struct Request* request, struct AtaDrive* drive);