PRIVATE int pci_bus_probe() { unsigned long init = 0x80000000; out_long(PCI_CTRL, init); init = in_long(PCI_DATA); if(init == 0xFFFFFFFF) return 0; return 1; }
static void do_read(void *buf) { int i; static struct Message m; do { receive(MSG_HARD_INTR, &m); } while (m.type != IDE_READY); for (i = 0; i < 512 / sizeof(uint_32); i ++) { *(((uint_32*)buf) + i) = in_long(IDE_PORT_BASE); } }
void disk_do_read(void *buf, uint32_t sector) { int i; ide_prepare(sector); issue_read(); waitdisk(); for (i = 0; i < 512 / sizeof(uint32_t); i ++) { *(((uint32_t*)buf) + i) = in_long(IDE_PORT_BASE); } }
/* 读磁盘的一个扇区 */ void readsect(void *dst, int offset) { int i; waitdisk(); out_byte(0x1F2, 1); out_byte(0x1F3, offset); out_byte(0x1F4, offset >> 8); out_byte(0x1F5, offset >> 16); out_byte(0x1F6, (offset >> 24) | 0xE0); out_byte(0x1F7, 0x20); waitdisk(); for (i = 0; i < SECTSIZE / 4; i ++) { ((int *)dst)[i] = in_long(0x1F0); } }
PRIVATE void pci_scan_devices(int bus_nr) { unsigned long conf_reg = 0x80000000; unsigned long tmp = 0L; printl("Scaning PCI device.\n"); tmp = bus_nr; tmp &= 0x000000FF; conf_reg += (tmp << 16); int i = 0; for(i = 0; i < 0x100; i++) { conf_reg &= 0xFFFF0000; conf_reg += (i << 8); out_long(PCI_CTRL, conf_reg); tmp = in_long(PCI_DATA); if(0xFFFFFFFF == tmp) continue; printl("A PCI device found.\n"); } return; }