Skip to content

Commit

Permalink
Added implementation of PCI config reads.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkie authored and The XOmB Overlord committed Feb 27, 2010
1 parent 8410c21 commit a8159b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion kernel/arch/x86_64/architecture/cpu.d
Expand Up @@ -130,7 +130,8 @@ public:
const char[] ioInMixinB = `
asm {
naked;
in AL, ` ~ port ~ `;
mov DX, ` ~ port ~ `;
in AL, DX;
ret;
}`;
}
Expand Down
26 changes: 20 additions & 6 deletions kernel/arch/x86_64/architecture/pci.d
Expand Up @@ -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.
Expand All @@ -48,4 +58,8 @@ static:
}

private:
void _setAddress(uint address) {
// write out address
Cpu.ioOut!(uint, "0xcf8")(address);
}
}

0 comments on commit a8159b9

Please sign in to comment.