/****************************************************************
* these bits must run in both 16bit and 32bit modes
****************************************************************/
-u8 *ahci_buf_fl VAR16VISIBLE;
// prepare sata command fis
static void sata_prep_simple(struct sata_cmd_fis *fis, u8 command)
// Use a word aligned buffer for AHCI I/O
int rc;
struct disk_op_s localop = *op;
- u8 *alignedbuf_fl = GET_GLOBAL(ahci_buf_fl);
+ u8 *alignedbuf_fl = GET_GLOBAL(bounce_buf_fl);
u8 *position = op->buf_fl;
localop.buf_fl = alignedbuf_fl;
dprintf(1, "%s\n", desc);
// Register with bcv system.
- boot_add_hd(&port->drive, desc, -1);
+ int prio = bootprio_find_ata_device(ctrl->pci_tmp, pnr, 0);
+ boot_add_hd(&port->drive, desc, prio);
} else {
// found cdrom (atapi)
port->drive.blksize = CDROM_SECTOR_SIZE;
dprintf(1, "%s\n", desc);
// fill cdidmap
- if (iscd)
- boot_add_cd(&port->drive, desc, -1);
+ if (iscd) {
+ int prio = bootprio_find_ata_device(ctrl->pci_tmp, pnr, 0);
+ boot_add_cd(&port->drive, desc, prio);
+ }
}
return 0;
}
// Initialize an ata controller and detect its drives.
static void
-ahci_init_controller(int bdf)
+ahci_init_controller(struct pci_device *pci)
{
struct ahci_ctrl_s *ctrl = malloc_fseg(sizeof(*ctrl));
+ u16 bdf = pci->bdf;
u32 val;
if (!ctrl) {
return;
}
- ahci_buf_fl = malloc_low(DISK_SECTOR_SIZE);
- if (!ahci_buf_fl) {
+ if (bounce_buf_init() < 0) {
warn_noalloc();
+ free(ctrl);
return;
}
+ ctrl->pci_tmp = pci;
ctrl->pci_bdf = bdf;
ctrl->iobase = pci_config_readl(bdf, PCI_BASE_ADDRESS_5);
ctrl->irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
continue;
if (pci->prog_if != 1 /* AHCI rev 1 */)
continue;
- ahci_init_controller(pci->bdf);
+ ahci_init_controller(pci);
}
}