diff --git a/Asuro.iso b/Asuro.iso index 059e2579..05a34df4 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 574a0562..d94c4172 100755 Binary files a/bin/kernel.bin and b/bin/kernel.bin differ diff --git a/iso/boot/asuro.bin b/iso/boot/asuro.bin index 574a0562..d94c4172 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/E1000.ppu b/lib/E1000.ppu index 49b96d04..5d1ca6e6 100644 Binary files a/lib/E1000.ppu and b/lib/E1000.ppu differ diff --git a/lib/PCI.ppu b/lib/PCI.ppu index 81d67c5b..334c2dff 100644 Binary files a/lib/PCI.ppu and b/lib/PCI.ppu differ diff --git a/lib/USB.ppu b/lib/USB.ppu index 0687e14a..af5ca494 100644 Binary files a/lib/USB.ppu and b/lib/USB.ppu differ diff --git a/lib/drivertypes.ppu b/lib/drivertypes.ppu index cd0fccab..d65bea0d 100644 Binary files a/lib/drivertypes.ppu and b/lib/drivertypes.ppu differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index 411ac5f9..6a18edfc 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index bb1bb018..9c7227d4 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 84cd9397..bf91992b 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 2a7cae3e..e1e83065 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/src/driver/PCI.pas b/src/driver/PCI.pas index e68a3add..1c308e9d 100644 --- a/src/driver/PCI.pas +++ b/src/driver/PCI.pas @@ -19,6 +19,10 @@ uses vmemorymanager, drivermanagement; +const + PCI_PORT_CONF_ADDR = $CF8; + PCI_PORT_CONF_DATA = $CFC; + type TPCI_Device_Bridge = bitpacked record @@ -72,6 +76,8 @@ procedure init(); procedure scanBus(bus : uint8); function loadDeviceConfig(bus : uint8; slot : uint8; func : uint8) : boolean; function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint8; var count : uint32) : TdeviceArray; //(Will in future)returns TPCI_DEVICE.vendor_id := 0xFFFF if no device found. +procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8); +procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32); implementation @@ -131,18 +137,47 @@ begin end; end; +{ + void pci_config_write_dword(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, uint32_t val) + + uint32_t addr; + uint32_t lbus = (uint32_t)bus; + uint32_t lslot = (uint32_t)slot; + uint32_t lfunc = (uint32_t)func; + + addr = (uint32_t)((lbus<<16) | (lslot << 11) | (lfunc << 8) | + (offset & 0xfc) | ((uint32_t)0x80000000)); + outl(PCI_PORT_CONF_ADDR, addr); + io_wait(); + outl(PCI_PORT_CONF_DATA, val); + io_wait(); +} + +procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32); +var + addr : uint32; + +begin + addr := ($1 shl 31); + addr := addr or (bus shl 16); + addr := addr or ((slot) shl 11); + addr := addr or ((func) shl 8); + addr := addr or ((row) shl 2); + outl(PCI_PORT_CONF_ADDR, addr); + outl(PCI_PORT_CONF_DATA, val); +end; + procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8); var - packet : uint32; + addr : uint32; begin - packet := ($1 shl 31); - packet := packet or (bus shl 16); - packet := packet or ((slot) shl 11); - packet := packet or ((func) shl 8); - packet := packet or ((row) shl 2); - - outl($CF8, uint32(packet)); + addr := ($1 shl 31); + addr := addr or (bus shl 16); + addr := addr or ((slot) shl 11); + addr := addr or ((func) shl 8); + addr := addr or ((row) shl 2); + outl(PCI_PORT_CONF_ADDR, addr); end; procedure loadBusConfig(bus : uint8; slot : uint8; func : uint8; device : TPCI_Device); @@ -233,6 +268,10 @@ begin loadDeviceConfig := false; + device.bus:= bus; + device.slot:= slot; + device.func:= func; + requestConfig(bus, slot, func, 0); data := inl($CFC); device.device_id := getword(data, false); diff --git a/src/driver/drivertypes.pas b/src/driver/drivertypes.pas index 72d1e6e8..7e68ba28 100644 --- a/src/driver/drivertypes.pas +++ b/src/driver/drivertypes.pas @@ -14,6 +14,9 @@ type PPCI_Device = ^TPCI_Device; TPCI_Device = bitpacked record + bus : uint8; + slot : uint8; + func : uint8; device_id : uint16; vendor_id : uint16; status : uint16; diff --git a/src/driver/network/E1000.pas b/src/driver/network/E1000.pas index 10fb6eeb..67adf76f 100644 --- a/src/driver/network/E1000.pas +++ b/src/driver/network/E1000.pas @@ -9,7 +9,9 @@ uses lmemorymanager, drivermanagement, drivertypes, - util; + util, + IDT, + PCI; const INTEL_VEND = $8086; @@ -125,7 +127,6 @@ type TCardType = (ctUnknown, ctE1000, ctI217, ct82577LM); procedure init(); -procedure fire(); function getMACAddress : puint8; function sendPacket(p_data : void; p_len : uint16) : sint32; @@ -323,7 +324,9 @@ end; procedure enableInturrupt(); begin - + writeCommand(REG_IMASK, $1F6DC); + writeCommand(REG_IMASK, $FF AND NOT(4)); + readCommand($C0); end; procedure handleReceive(); @@ -355,9 +358,33 @@ begin console.writestringln(' '); end; +procedure fire(); interrupt; +var + status : uint32; +begin + status:= readCommand($0C); + console.writehexln(status); + case status of + $04:begin + + end; + $10:begin + + end; + $80:begin + + end; + end; + console.writestringln('Fired.'); +end; + function load(ptr : void) : boolean; var PCI_Info : PPCI_Device; + i : uint32; + data : uint32; + iline : uint8; + begin console.outputln('E1000 Driver', 'Load Start.'); @@ -384,6 +411,16 @@ begin writeMACAddress(); startLink(); + + for i:=0 to $80 do begin + writeCommand($5200 + i*4, 0); + end; + + IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0); + enableInturrupt(); + rxinit(); + txinit(); + load:= true; console.outputln('E1000 Driver', 'Load Finish.'); end; @@ -435,11 +472,6 @@ begin drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load82577LM); end; -procedure fire(); -begin - -end; - function getMACAddress : puint8; begin getMACAddress:= puint8(@mac[0]);