uint32_t PciBus::Read(uint32_t bus, uint32_t device, uint32_t function, uint32_t offset, uint8_t size) { uint32_t value; io_outd(0xCF8, 0x80000000 | (bus << 16) | (device << 11) | (function << 8) | (offset & ~3)); switch (size) { case 1: value = io_inb(0xCFC + (offset & 3)); break; case 2: value = io_inw(0xCFC + (offset & 2)); break; case 4: value = io_ind(0xCFC); break; default: return 0xFF; } return value; }
static void MouseCallback(regs_t *reg) { switch(Cycle) { case 0: Byte[0] = io_inb(0x60); Cycle++; break; case 1: Byte[1] = io_inw(0x60); Cycle++; break; case 2: Byte[2] = io_inw(0x60); Cycle = 0; //printf("%d %d\n", Byte[1], Byte[2]); break; } }
/* * Performs a PIO read. */ static void ata_do_pio_read(ata_driver_t *drv, void* dest, uint32_t num_words, uint8_t channel) { ata_reg_write(drv, channel, ATA_REG_CONTROL, 0x80 | drv->channels[channel].nIEN); uint16_t *dest_ptr = (uint16_t *) dest; // Read from PIO data port static uint16_t temp; for(int i = 0; i < num_words; i++) { temp = io_inw(drv->channels[channel].base); *dest_ptr++ = temp; } ata_reg_write(drv, channel, ATA_REG_CONTROL, drv->channels[channel].nIEN); }