diff --git a/kernel/arch/x86_64/architecture/cpu.d b/kernel/arch/x86_64/architecture/cpu.d index 41badd2..9d90a47 100644 --- a/kernel/arch/x86_64/architecture/cpu.d +++ b/kernel/arch/x86_64/architecture/cpu.d @@ -130,7 +130,8 @@ public: const char[] ioInMixinB = ` asm { naked; - in AL, ` ~ port ~ `; + mov DX, ` ~ port ~ `; + in AL, DX; ret; }`; } diff --git a/kernel/arch/x86_64/architecture/pci.d b/kernel/arch/x86_64/architecture/pci.d index 163fe82..c604092 100644 --- a/kernel/arch/x86_64/architecture/pci.d +++ b/kernel/arch/x86_64/architecture/pci.d @@ -14,25 +14,35 @@ static: // Description: Will read a uint from PCI. uint read32(uint address) { - // write out address - Cpu.ioOut!(uint, "0xcf8")(address); + _setAddress(address); // get offset ushort offset = cast(ushort)(address & 0xff); // read in data - Cpu.ioIn!(uint, "0xcfc")(); - return 0; + return Cpu.ioIn!(uint, "0xcfc")(); } // Description: Will read a ushort from PCI. ushort read16(uint address) { - return 0; + _setAddress(address); + + // get offset + ushort offset = cast(ushort)(address & 0xff); + + // read in data + return Cpu.ioIn!(ushort, "0xcfc")(); } // Description: Will read a ubyte from PCI. ubyte read8(uint address) { - return 0; + _setAddress(address); + + // get offset + ushort offset = cast(ushort)(address & 0xff); + + // read in data + return Cpu.ioIn!(ubyte, "0xcfc")(); } // Description: Will write to PCI. @@ -48,4 +58,8 @@ static: } private: + void _setAddress(uint address) { + // write out address + Cpu.ioOut!(uint, "0xcf8")(address); + } }