Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/drivers/ata/ata.h need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef _ATA_H_
0019 #define _ATA_H_
0020 #include "types.h"
0021 
0022 #define ATA_TYPE_NONE 0
0023 #define ATA_TYPE_PATA 1
0024 #define ATA_TYPE_PATAPI 2
0025 #define ATA_TYPE_SATA 3
0026 #define ATA_TYPE_SATAPI 4
0027 
0028 typedef struct
0029 {
0030   uint32 ata_type, ata_bus, ata_drive;
0031 } ata_info;
0032 
0033 extern ata_info pata_drives[4];
0034 
0035 #define ATA_BUS_PRIMARY     0x1F0
0036 #define ATA_BUS_SECONDARY   0x170
0037 
0038 #define ATA_IRQ_PRIMARY     0x0E
0039 #define ATA_IRQ_SECONDARY   0x0F
0040 #define ATA_VECTOR_PRIMARY   0x27
0041 #define ATA_VECTOR_SECONDARY 0x28
0042 #define ATA_IRQ(bus)        (bus==ATA_BUS_PRIMARY ? ATA_IRQ_PRIMARY : ATA_IRQ_SECONDARY)
0043 #define ATA_VECTOR(bus)     (bus==ATA_BUS_PRIMARY ? ATA_VECTOR_PRIMARY : ATA_VECTOR_SECONDARY)
0044 
0045 #define ATA_DATA(x)         (x)
0046 #define ATA_FEATURES(x)     (x+1)
0047 #define ATA_SECTOR_COUNT(x) (x+2)
0048 #define ATA_ADDRESS1(x)     (x+3)
0049 #define ATA_ADDRESS2(x)     (x+4)
0050 #define ATA_ADDRESS3(x)     (x+5)
0051 #define ATA_DRIVE_SELECT(x) (x+6)
0052 #define ATA_COMMAND(x)      (x+7)
0053 #define ATA_DCR(x)          (x+0x206)   /* device control register */
0054 
0055 #define ATA_DRIVE_MASTER    0xA0
0056 #define ATA_DRIVE_SLAVE     0xB0
0057 
0058 /* The default and seemingly universal sector size for CD-ROMs. */
0059 #define ATAPI_SECTOR_SIZE 2048
0060 
0061 bool ata_init (void);
0062 int ata_drive_read_sector (uint32 bus, uint32 drive, uint32 lba,
0063                            uint8 * buffer);
0064 int ata_drive_write_sector (uint32 bus, uint32 drive, uint32 lba,
0065                             uint8 * buffer);
0066 int atapi_drive_read_sector (uint32 bus, uint32 drive, uint32 lba,
0067                              uint8 * buffer);
0068 
0069 #endif
0070 
0071 /* 
0072  * Local Variables:
0073  * indent-tabs-mode: nil
0074  * mode: C
0075  * c-file-style: "gnu"
0076  * c-basic-offset: 2
0077  * End: 
0078  */
0079 
0080 /* vi: set et sw=2 sts=2: */