feat(atapi): add discover for all drives
This commit is contained in:
parent
38bb731587
commit
26bdfc63d6
24
k/atapi.c
24
k/atapi.c
@ -24,7 +24,7 @@ static void wait_device_selection(uint16_t drive)
|
|||||||
inb(drive);
|
inb(drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t is_atapi_driver(uint16_t bus, uint8_t slave)
|
static uint8_t is_atapi_drive(uint16_t bus, uint8_t slave)
|
||||||
{
|
{
|
||||||
static uint8_t atapi_sig[] = { ATAPI_SIG_SC, ATAPI_SIG_LBA_LO,
|
static uint8_t atapi_sig[] = { ATAPI_SIG_SC, ATAPI_SIG_LBA_LO,
|
||||||
ATAPI_SIG_LBA_MI, ATAPI_SIG_LBA_HI };
|
ATAPI_SIG_LBA_MI, ATAPI_SIG_LBA_HI };
|
||||||
@ -61,15 +61,31 @@ static uint8_t is_atapi_driver(uint16_t bus, uint8_t slave)
|
|||||||
|
|
||||||
void discover_atapi_drive(void)
|
void discover_atapi_drive(void)
|
||||||
{
|
{
|
||||||
// primary_reg
|
/* primary_reg */
|
||||||
outb(PRIMARY_DCR, SRST);
|
outb(PRIMARY_DCR, SRST);
|
||||||
outb(PRIMARY_DCR, INTERRUPT_DISABLE);
|
outb(PRIMARY_DCR, INTERRUPT_DISABLE);
|
||||||
|
|
||||||
|
// master_port
|
||||||
select_drive(PRIMARY_REG, ATA_PORT_MASTER);
|
select_drive(PRIMARY_REG, ATA_PORT_MASTER);
|
||||||
wait_device_selection(PRIMARY_REG);
|
wait_device_selection(PRIMARY_REG);
|
||||||
is_atapi_driver(PRIMARY_REG, ATA_PORT_MASTER);
|
is_atapi_drive(PRIMARY_REG, ATA_PORT_MASTER);
|
||||||
|
|
||||||
// secondary_reg
|
// slave port
|
||||||
|
select_drive(PRIMARY_REG, ATA_PORT_SLAVE);
|
||||||
|
wait_device_selection(PRIMARY_REG);
|
||||||
|
is_atapi_drive(PRIMARY_REG, ATA_PORT_SLAVE);
|
||||||
|
|
||||||
|
/* secondary_reg */
|
||||||
outb(SECONDARY_DCR, SRST);
|
outb(SECONDARY_DCR, SRST);
|
||||||
outb(SECONDARY_DCR, INTERRUPT_DISABLE);
|
outb(SECONDARY_DCR, INTERRUPT_DISABLE);
|
||||||
|
|
||||||
|
// master_port
|
||||||
|
select_drive(SECONDARY_REG, ATA_PORT_MASTER);
|
||||||
|
wait_device_selection(SECONDARY_REG);
|
||||||
|
is_atapi_drive(SECONDARY_REG, ATA_PORT_MASTER);
|
||||||
|
|
||||||
|
// slave port
|
||||||
|
select_drive(SECONDARY_REG, ATA_PORT_SLAVE);
|
||||||
|
wait_device_selection(SECONDARY_REG);
|
||||||
|
is_atapi_drive(SECONDARY_REG, ATA_PORT_SLAVE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user