Skip to content

Commit

Permalink
Adding PCI device scan.
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 5513338 commit 7cf44f8
Show file tree
Hide file tree
Showing 4 changed files with 452 additions and 18 deletions.
9 changes: 8 additions & 1 deletion kernel/arch/x86_64/architecture/cpu.d
Expand Up @@ -183,8 +183,10 @@ public:
}

T ioIn(T)(uint port) {
// The argument is passed as RDI
asm {
mov EDX, port;
naked;
mov EDX, EDI;
}

static if (is(T == ubyte) || is(T == byte)) {
Expand All @@ -205,6 +207,11 @@ public:
else {
static assert (false, "Cannot determine data type.");
}

// EAX is the return value, so this is correct
asm {
ret;
}
}

T ioIn(T, char[] port)() {
Expand Down
8 changes: 6 additions & 2 deletions kernel/arch/x86_64/architecture/pci.d
Expand Up @@ -9,8 +9,11 @@ module architecture.pci;

import architecture.cpu;

class PCIImplementation {
import kernel.core.kprintf;

class PCIConfiguration {
static:
protected:

T read(T)(uint address) {
synchronized {
Expand All @@ -19,6 +22,7 @@ static:
// get offset
ushort offset = cast(ushort)(address & 0x3);

// return cast(T)(Cpu.ioIn!(uint)(0xcfc) >> (cast(uint)offset * 8));
return Cpu.ioIn!(T)(0xcfc + offset);
}
}
Expand All @@ -38,6 +42,6 @@ private:

void _setAddress(uint address) {
// write out address
Cpu.ioOut!(uint, "0xcf8")(address);
Cpu.ioOut!(uint, "0xcf8")(address & ~0x3);
}
}
3 changes: 3 additions & 0 deletions kernel/core/kmain.d
Expand Up @@ -131,6 +131,9 @@ extern(C) void kmain(int bootLoaderID, void *data) {
Log.print("Keyboard: initialize()");
Log.result(Keyboard.initialize());

Log.print("PCI: initialize()");
Log.result(PCI.initialize());

// 7. Schedule
Scheduler.initialize();

Expand Down

0 comments on commit 7cf44f8

Please sign in to comment.