splitting generic ata from pata.
This commit is contained in:
parent
7e8b77c033
commit
c7336d912c
10 changed files with 1095 additions and 843 deletions
|
@ -97,21 +97,64 @@ enum grub_ata_timeout_milliseconds
|
|||
GRUB_ATA_TOUT_DATA = 10000 /* 10s DATA I/O timeout. */
|
||||
};
|
||||
|
||||
struct grub_ata_device
|
||||
typedef union
|
||||
{
|
||||
/* IDE port to use. */
|
||||
int port;
|
||||
grub_uint8_t raw[11];
|
||||
struct
|
||||
{
|
||||
union
|
||||
{
|
||||
grub_uint8_t features;
|
||||
grub_uint8_t error;
|
||||
};
|
||||
union
|
||||
{
|
||||
grub_uint8_t sectors;
|
||||
grub_uint8_t atapi_ireason;
|
||||
};
|
||||
union
|
||||
{
|
||||
grub_uint8_t lba_low;
|
||||
grub_uint8_t sectnum;
|
||||
};
|
||||
union
|
||||
{
|
||||
grub_uint8_t lba_mid;
|
||||
grub_uint8_t cyllsb;
|
||||
grub_uint8_t atapi_cntlow;
|
||||
};
|
||||
union
|
||||
{
|
||||
grub_uint8_t lba_high;
|
||||
grub_uint8_t cylmsb;
|
||||
grub_uint8_t atapi_cnthigh;
|
||||
};
|
||||
grub_uint8_t disk;
|
||||
union
|
||||
{
|
||||
grub_uint8_t cmd;
|
||||
grub_uint8_t status;
|
||||
};
|
||||
grub_uint8_t sectors48;
|
||||
grub_uint8_t lba48_low;
|
||||
grub_uint8_t lba48_mid;
|
||||
grub_uint8_t lba48_high;
|
||||
};
|
||||
} grub_ata_regs_t;
|
||||
|
||||
/* IO addresses on which the registers for this device can be
|
||||
found. */
|
||||
grub_port_t ioaddress;
|
||||
grub_port_t ioaddress2;
|
||||
|
||||
/* Two devices can be connected to a single cable. Use this field
|
||||
to select device 0 (commonly known as "master") or device 1
|
||||
(commonly known as "slave"). */
|
||||
int device;
|
||||
/* ATA pass through parameters and function. */
|
||||
struct grub_disk_ata_pass_through_parms
|
||||
{
|
||||
grub_ata_regs_t taskfile;
|
||||
void * buffer;
|
||||
grub_size_t size;
|
||||
int write;
|
||||
void *cmd;
|
||||
int cmdsize;
|
||||
};
|
||||
|
||||
struct grub_ata
|
||||
{
|
||||
/* Addressing methods available for accessing this device. If CHS
|
||||
is only available, use that. Otherwise use LBA, except for the
|
||||
high sectors. In that case use LBA48. */
|
||||
|
@ -128,47 +171,36 @@ struct grub_ata_device
|
|||
/* Set to 0 for ATA, set to 1 for ATAPI. */
|
||||
int atapi;
|
||||
|
||||
struct grub_ata_device *next;
|
||||
void *data;
|
||||
|
||||
struct grub_ata_dev *dev;
|
||||
};
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_ata_wait_not_busy) (struct grub_ata_device *dev,
|
||||
int milliseconds);
|
||||
grub_err_t EXPORT_FUNC(grub_ata_wait_drq) (struct grub_ata_device *dev,
|
||||
int rw, int milliseconds);
|
||||
void EXPORT_FUNC(grub_ata_pio_read) (struct grub_ata_device *dev,
|
||||
char *buf, grub_size_t size);
|
||||
typedef struct grub_ata *grub_ata_t;
|
||||
|
||||
static inline void
|
||||
grub_ata_regset (struct grub_ata_device *dev, int reg, int val)
|
||||
struct grub_ata_dev
|
||||
{
|
||||
grub_outb (val, dev->ioaddress + reg);
|
||||
}
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int (*hook) (int id, int bus));
|
||||
|
||||
static inline grub_uint8_t
|
||||
grub_ata_regget (struct grub_ata_device *dev, int reg)
|
||||
{
|
||||
return grub_inb (dev->ioaddress + reg);
|
||||
}
|
||||
/* Open the device named NAME, and set up SCSI. */
|
||||
grub_err_t (*open) (int id, int bus, struct grub_ata *scsi);
|
||||
|
||||
static inline void
|
||||
grub_ata_regset2 (struct grub_ata_device *dev, int reg, int val)
|
||||
{
|
||||
grub_outb (val, dev->ioaddress2 + reg);
|
||||
}
|
||||
/* Close the scsi device SCSI. */
|
||||
void (*close) (struct grub_ata *ata);
|
||||
|
||||
static inline grub_uint8_t
|
||||
grub_ata_regget2 (struct grub_ata_device *dev, int reg)
|
||||
{
|
||||
return grub_inb (dev->ioaddress2 + reg);
|
||||
}
|
||||
/* Read SIZE bytes from the device SCSI into BUF after sending the
|
||||
command CMD of size CMDSIZE. */
|
||||
grub_err_t (*readwrite) (struct grub_ata *ata,
|
||||
struct grub_disk_ata_pass_through_parms *parms);
|
||||
|
||||
static inline grub_err_t
|
||||
grub_ata_check_ready (struct grub_ata_device *dev)
|
||||
{
|
||||
if (grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
|
||||
return grub_ata_wait_not_busy (dev, GRUB_ATA_TOUT_STD);
|
||||
/* The next scsi device. */
|
||||
struct grub_ata_dev *next;
|
||||
};
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
typedef struct grub_ata_dev *grub_ata_dev_t;
|
||||
|
||||
void grub_ata_dev_register (grub_ata_dev_t dev);
|
||||
void grub_ata_dev_unregister (grub_ata_dev_t dev);
|
||||
|
||||
#endif /* ! GRUB_ATA_HEADER */
|
||||
|
|
|
@ -165,16 +165,5 @@ grub_uint64_t EXPORT_FUNC(grub_disk_get_size) (grub_disk_t disk);
|
|||
|
||||
extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
|
||||
extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
|
||||
|
||||
/* ATA pass through parameters and function. */
|
||||
struct grub_disk_ata_pass_through_parms
|
||||
{
|
||||
grub_uint8_t taskfile[8];
|
||||
void * buffer;
|
||||
int size;
|
||||
};
|
||||
|
||||
extern grub_err_t (* EXPORT_VAR(grub_disk_ata_pass_through)) (grub_disk_t,
|
||||
struct grub_disk_ata_pass_through_parms *);
|
||||
|
||||
|
||||
#endif /* ! GRUB_DISK_HEADER */
|
||||
|
|
|
@ -29,10 +29,13 @@ struct grub_scsi;
|
|||
enum
|
||||
{
|
||||
GRUB_SCSI_SUBSYSTEM_USBMS,
|
||||
GRUB_SCSI_SUBSYSTEM_ATAPI,
|
||||
GRUB_SCSI_SUBSYSTEM_AHCI
|
||||
GRUB_SCSI_SUBSYSTEM_PATA,
|
||||
GRUB_SCSI_SUBSYSTEM_AHCI,
|
||||
GRUB_SCSI_NUM_SUBSYSTEMS
|
||||
};
|
||||
|
||||
extern char grub_scsi_names[GRUB_SCSI_NUM_SUBSYSTEMS][5];
|
||||
|
||||
#define GRUB_SCSI_ID_SUBSYSTEM_SHIFT 24
|
||||
#define GRUB_SCSI_ID_BUS_SHIFT 8
|
||||
#define GRUB_SCSI_ID_LUN_SHIFT 0
|
||||
|
@ -46,16 +49,11 @@ grub_make_scsi_id (int subsystem, int bus, int lun)
|
|||
|
||||
struct grub_scsi_dev
|
||||
{
|
||||
/* The device name. */
|
||||
const char *name;
|
||||
|
||||
grub_uint8_t id;
|
||||
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int (*hook) (int bus, int luns));
|
||||
int (*iterate) (int (*hook) (int id, int bus, int luns));
|
||||
|
||||
/* Open the device named NAME, and set up SCSI. */
|
||||
grub_err_t (*open) (int bus, struct grub_scsi *scsi);
|
||||
grub_err_t (*open) (int id, int bus, struct grub_scsi *scsi);
|
||||
|
||||
/* Close the scsi device SCSI. */
|
||||
void (*close) (struct grub_scsi *scsi);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue