diff --git a/Asuro.iso b/Asuro.iso index 6dcb14e6..843556d6 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 0dd4f329..d33748d3 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 0dd4f329..d33748d3 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/AHCI.ppu b/lib/AHCI.ppu new file mode 100644 index 00000000..d9fdcc37 Binary files /dev/null and b/lib/AHCI.ppu differ diff --git a/lib/ATA.ppu b/lib/ATA.ppu new file mode 100644 index 00000000..23c8e505 Binary files /dev/null and b/lib/ATA.ppu differ diff --git a/lib/E1000.ppu b/lib/E1000.ppu new file mode 100644 index 00000000..741f33e2 Binary files /dev/null and b/lib/E1000.ppu differ diff --git a/lib/PCI.ppu b/lib/PCI.ppu index ad21f4d3..5ce5c4e2 100644 Binary files a/lib/PCI.ppu and b/lib/PCI.ppu differ diff --git a/lib/USB.ppu b/lib/USB.ppu new file mode 100644 index 00000000..7953c09f Binary files /dev/null and b/lib/USB.ppu differ diff --git a/lib/drivermanagement.ppu b/lib/drivermanagement.ppu new file mode 100644 index 00000000..be3967ae Binary files /dev/null and b/lib/drivermanagement.ppu differ diff --git a/lib/drivertypes.ppu b/lib/drivertypes.ppu new file mode 100644 index 00000000..cd0fccab Binary files /dev/null and b/lib/drivertypes.ppu differ diff --git a/lib/isr76.ppu b/lib/isr76.ppu new file mode 100644 index 00000000..d5713f2f Binary files /dev/null and b/lib/isr76.ppu differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index 69571a6f..890e906d 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/keyboard.ppu b/lib/keyboard.ppu index 2d311799..e8f5e467 100644 Binary files a/lib/keyboard.ppu and b/lib/keyboard.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index 7b1aeb51..5a13454c 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index bf97a16d..a6813afb 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index fefd4cb5..82000ede 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/mouse.ppu b/lib/mouse.ppu index 3c513204..350263d0 100644 Binary files a/lib/mouse.ppu and b/lib/mouse.ppu differ diff --git a/lib/strings.ppu b/lib/strings.ppu new file mode 100644 index 00000000..06cf691d Binary files /dev/null and b/lib/strings.ppu differ diff --git a/lib/testdriver.ppu b/lib/testdriver.ppu new file mode 100644 index 00000000..ac614f55 Binary files /dev/null and b/lib/testdriver.ppu differ diff --git a/src/driver/E1000.pas b/src/driver/E1000.pas new file mode 100644 index 00000000..81edd8ee --- /dev/null +++ b/src/driver/E1000.pas @@ -0,0 +1,227 @@ +unit E1000; + +interface + +uses + console, + strings, + vmemorymanager, + lmemorymanager, + drivermanagement; + +const + INTEL_VEND = $8086; + E1000_DEV = $100E; + I217_DEV = $153A; + LM82577_DEV = $10EA; + + REG_CTRL = $0000; + REG_STATUS = $0008; + REG_EEPROM = $0014; + REG_CTRL_EXT = $0018; + REG_IMASK = $00D0; + REG_RCTRL = $0100; + REG_RXDESCLO = $2800; + REG_RXDESCHI = $2804; + REG_RXDESCLEN = $2808; + REG_RXDESCHEAD = $2810; + REG_RXDESCTAIL = $2818; + + REG_TCTRL = $0400; + REG_TXDESCLO = $3800; + REG_TXDESCHI = $3804; + REG_TXDESCLEN = $3808; + REG_TXDESCHEAD = $3810; + REG_TXDESCTAIL = $3818; + + REG_RDTR = $2820; // RX Delay Timer Register + REG_RXDCTL = $3828; // RX Descriptor Control + REG_RADV = $282C; // RX Int. Absolute Delay Timer + REG_RSRPD = $2C00; // RX Small Packet Detect Interrupt + + REG_TIPG = $0410; // Transmit Inter Packet Gap + ECTRL_SLU = $40; //set link up + + RCTL_EN = (1 SHL 1); // Receiver Enable + RCTL_SBP = (1 SHL 2); // Store Bad Packets + RCTL_UPE = (1 SHL 3); // Unicast Promiscuous Enabled + RCTL_MPE = (1 SHL 4); // Multicast Promiscuous Enabled + RCTL_LPE = (1 SHL 5); // Long Packet Reception Enable + RCTL_LBM_NONE = (0 SHL 6); // No Loopback + RCTL_LBM_PHY = (3 SHL 6); // PHY or external SerDesc loopback + RTCL_RDMTS_HALF = (0 SHL 8); // Free Buffer Threshold is 1/2 of RDLEN + RTCL_RDMTS_QUARTER = (1 SHL 8); // Free Buffer Threshold is 1/4 of RDLEN + RTCL_RDMTS_EIGHTH = (2 SHL 8); // Free Buffer Threshold is 1/8 of RDLEN + RCTL_MO_36 = (0 SHL 12); // Multicast Offset - bits 47:36 + RCTL_MO_35 = (1 SHL 12); // Multicast Offset - bits 46:35 + RCTL_MO_34 = (2 SHL 12); // Multicast Offset - bits 45:34 + RCTL_MO_32 = (3 SHL 12); // Multicast Offset - bits 43:32 + RCTL_BAM = (1 SHL 15); // Broadcast Accept Mode + RCTL_VFE = (1 SHL 18); // VLAN Filter Enable + RCTL_CFIEN = (1 SHL 19); // Canonical Form Indicator Enable + RCTL_CFI = (1 SHL 20); // Canonical Form Indicator Bit Value + RCTL_DPF = (1 SHL 22); // Discard Pause Frames + RCTL_PMCF = (1 SHL 23); // Pass MAC Control Frames + RCTL_SECRC = (1 SHL 26); // Strip Ethernet CRC + + // Buffer Sizes + RCTL_BSIZE_256 = (3 SHL 16); + RCTL_BSIZE_512 = (2 SHL 16); + RCTL_BSIZE_1024 = (1 SHL 16); + RCTL_BSIZE_2048 = (0 SHL 16); + RCTL_BSIZE_4096 = ((3 SHL 16) OR (1 SHL 25)); + RCTL_BSIZE_8192 = ((2 SHL 16) OR (1 SHL 25)); + RCTL_BSIZE_16384 = ((1 SHL 16) OR (1 SHL 25)); + + // Transmit Command + CMD_EOP = (1 SHL 0); // End of Packet + CMD_IFCS = (1 SHL 1); // Insert FCS + CMD_IC = (1 SHL 2); // Insert Checksum + CMD_RS = (1 SHL 3); // Report Status + CMD_RPS = (1 SHL 4); // Report Packet Sent + CMD_VLE = (1 SHL 6); // VLAN Packet Enable + CMD_IDE = (1 SHL 7); // Interrupt Delay Enable + + // TCTL Register + TCTL_EN = (1 SHL 1); // Transmit Enable + TCTL_PSP = (1 SHL 3); // Pad Short Packets + TCTL_CT_SHIFT = 4; // Collision Threshold + TCTL_COLD_SHIFT = 12; // Collision Distance + TCTL_SWXOFF = (1 SHL 22); // Software XOFF Transmission + TCTL_RTLC = (1 SHL 24); // Re-transmit on Late Collision + + TSTA_DD = (1 SHL 0); // Descriptor Done + TSTA_EC = (1 SHL 1); // Excess Collisions + TSTA_LC = (1 SHL 2); // Late Collision + LSTA_TU = (1 SHL 3); // Transmit Underrun + +type + PE1000_rx_desc = ^TE1000_rx_desc; + TE1000_rx_desc = bitpacked record + address : uint64; + length : uint16; + checksum : uint16; + status : uint8; + errors : uint8; + special : uint16; + end; + + PE1000_tx_desc = ^TE1000_tx_desc; + TE1000_tx_desc = bitpacked record + address : uint64; + length : uint16; + cso : uint8; + cmd : uint8; + status : uint8; + css : uint8; + special : uint16; + end; + +procedure init(); +procedure fire(); +function getMACAddress : uint8; +function sendPacket(p_data : void; p_len : uint16) : sint32; + +implementation + +var + bar_type : uint8; + io_base : uint16; + mem_base : uint64; + eeprom_exists : boolean; + mac : array[0..5] of uint8; + rx_descs : array[0..65535] of TE1000_rx_desc; + tx_descs : array[0..65535] of TE1000_tx_desc; + rx_curr : uint16; + tx_curr : uint16; + +procedure writeCommand(p_address : uint16; p_value : uint32); +begin + +end; + +function readCommand(p_address : uint16) : uint32; +begin + +end; + +function detectEEPROM() : boolean; +begin + +end; + +function EEPROMRead( address : uint8 ) : uint32; +begin + +end; + +function readMACAddress() : boolean; +begin + +end; + +procedure startLink(); +begin + +end; + +procedure rxinit(); +begin + +end; + +procedure txinit(); +begin + +end; + +procedure enableInturrupt(); +begin + +end; + +procedure handleReceive(); +begin + +end; + +function load(ptr : void) : boolean; +begin + load:= true; +end; + +procedure init(); +var + dev : TDeviceIdentifier; + +begin + dev.Bus:= biPCI; + dev.id0:= E1000_DEV; + dev.id1:= idANY; + dev.id2:= idANY; + dev.id3:= idANY; + dev.id4:= INTEL_VEND; + dev.ex:= nil; + drivermanagement.register_driver('E1000 Ethernet Driver', @dev, @load); + dev.id0:= I217_DEV; + drivermanagement.register_driver('I217 Ethernet Driver', @dev, @load); + dev.id0:= LM82577_DEV; + drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load); +end; + +procedure fire(); +begin + +end; + +function getMACAddress : uint8; +begin + +end; + +function sendPacket(p_data : void; p_len : uint16) : sint32; +begin + +end; + +end. \ No newline at end of file diff --git a/src/driver/PCI.pas b/src/driver/PCI.pas index ef812fb4..441ada3c 100644 --- a/src/driver/PCI.pas +++ b/src/driver/PCI.pas @@ -313,6 +313,7 @@ begin DevID^.id1:= device.class_code; DevID^.id2:= device.subclass_class; DevID^.id3:= device.prog_if; + DevID^.id4:= device.vendor_id; DevID^.ex:= nil; console.writestring('PCI: Found Device: '); diff --git a/src/driver/USB.pas b/src/driver/USB.pas index 1a41cb47..66bf4700 100644 --- a/src/driver/USB.pas +++ b/src/driver/USB.pas @@ -110,6 +110,7 @@ begin UHCI_ID.id1:= $0000000C; UHCI_ID.id2:= $00000003; UHCI_ID.id3:= $00000000; + UHCI_ID.id4:= $FFFFFFFF; UHCI_ID.ex:= nil; OHCI_ID.Bus:= biPCI; @@ -117,6 +118,7 @@ begin OHCI_ID.id1:= $0000000C; OHCI_ID.id2:= $00000003; OHCI_ID.id3:= $00000010; + OHCI_ID.id4:= $FFFFFFFF; OHCI_ID.ex:= nil; drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI); diff --git a/src/driver/keyboard.pas b/src/driver/keyboard.pas index 2463d032..c527f65e 100644 --- a/src/driver/keyboard.pas +++ b/src/driver/keyboard.pas @@ -78,6 +78,7 @@ begin devid.id1:= 0; devid.id2:= 0; devid.id3:= 0; + devid.id4:= 0; devid.ex:= nil; drivermanagement.register_driver_ex('PS/2 Keyboard', @devid, @load, true); console.writestringln('PS/2 KEYBOARD: INIT END.'); diff --git a/src/driver/mouse.pas b/src/driver/mouse.pas index fbe1061d..9529c151 100644 --- a/src/driver/mouse.pas +++ b/src/driver/mouse.pas @@ -122,6 +122,7 @@ begin devid.id1:= 0; devid.id2:= 0; devid.id3:= 0; + devid.id4:= 0; devid.ex:= nil; drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true); console.writestringln('PS/2 MOUSE: INIT END.'); diff --git a/src/driver/testdriver.pas b/src/driver/testdriver.pas index 17efff4e..fda02bc6 100644 --- a/src/driver/testdriver.pas +++ b/src/driver/testdriver.pas @@ -24,6 +24,7 @@ begin devID.id1:= $00000006; { CLASS } devID.id2:= $00000000; { SUBCLASS } devID.id3:= $00000000; { PROGIF } + devID.id4:= idANY; devID.ex:= nil; { NO EXTENDED INFO } drivermanagement.register_driver('DUMMY DRIVER', @devID, @load); end; diff --git a/src/drivermanagement.pas b/src/drivermanagement.pas index 9fa88af8..ee66fd45 100644 --- a/src/drivermanagement.pas +++ b/src/drivermanagement.pas @@ -26,12 +26,13 @@ type TBusIdentifier = (biUnknown, biPCI, biUSB, bii2c, biPCIe, biANY); PDeviceIdentifier = ^TDeviceIdentifier; - TDeviceIdentifier = record + TDeviceIdentifier = record Bus : TBusIdentifier; id0 : uInt32; id1 : uInt32; id2 : uInt32; id3 : uint32; + id4 : uint32; ex : PDevEx; end; @@ -93,8 +94,8 @@ begin if Drv^.Loaded then begin console.writeint(i); console.writestring(') '); - console.writestring(Drv^.Driver_Name); - console.writestring(' ['); + console.writestringln(Drv^.Driver_Name); + console.writestring('['); writeBusType(Drv^.Identifier^.Bus); console.writestring(' - ID:'); console.writeHex(Drv^.Identifier^.id0); @@ -104,6 +105,8 @@ begin console.writeHex(Drv^.Identifier^.id2); console.writestring('-'); console.writeHex(Drv^.Identifier^.id3); + console.writestring('-'); + console.writeHex(Drv^.Identifier^.id4); ex:= Drv^.Identifier^.ex; while ex <> nil do begin console.writestring('-'); @@ -130,8 +133,8 @@ begin console.writeint(i); if Drv^.Loaded then console.writestring('L'); console.writestring(') '); - console.writestring(Drv^.Driver_Name); - console.writestring(' ['); + console.writestringln(Drv^.Driver_Name); + console.writestring('['); writeBusType(Drv^.Identifier^.Bus); console.writestring(' - ID:'); console.writeHex(Drv^.Identifier^.id0); @@ -141,6 +144,8 @@ begin console.writeHex(Drv^.Identifier^.id2); console.writestring('-'); console.writeHex(Drv^.Identifier^.id3); + console.writestring('-'); + console.writeHex(Drv^.Identifier^.id4); ex:= Drv^.Identifier^.ex; while ex <> nil do begin console.writestring('-'); @@ -165,8 +170,8 @@ begin while Dv <> nil do begin console.writeint(i); console.writestring(') '); - console.writestring(Dv^.Device_Name); - console.writestring(' ['); + console.writestringln(Dv^.Device_Name); + console.writestring('['); writeBusType(Dv^.Identifier^.Bus); console.writestring(' - ID:'); console.writeHex(Dv^.Identifier^.id0); @@ -176,6 +181,8 @@ begin console.writeHex(Dv^.Identifier^.id2); console.writestring('-'); console.writeHex(Dv^.Identifier^.id3); + console.writestring('-'); + console.writeHex(Dv^.Identifier^.id4); ex:= Dv^.Identifier^.ex; while ex <> nil do begin console.writestring('-'); @@ -212,6 +219,7 @@ begin New_DevID^.id1:= DeviceID^.id1; New_DevID^.id2:= DeviceID^.id2; New_DevID^.id3:= DeviceID^.id3; + New_DevID^.id4:= DeviceID^.id4; root_ex:= nil; if DeviceID^.ex <> nil then begin root_ex:= PDevEx(kalloc(sizeof(TDevEx))); @@ -243,6 +251,7 @@ begin identifiers_match:= identifiers_match and ((i1^.id1 = i2^.id1) OR (i1^.id1 = $FFFFFFFF) OR (i2^.id1 = $FFFFFFFF)); identifiers_match:= identifiers_match and ((i1^.id2 = i2^.id2) OR (i1^.id2 = $FFFFFFFF) OR (i2^.id2 = $FFFFFFFF)); identifiers_match:= identifiers_match and ((i1^.id3 = i2^.id3) OR (i1^.id3 = $FFFFFFFF) OR (i2^.id3 = $FFFFFFFF)); + identifiers_match:= identifiers_match and ((i1^.id4 = i2^.id4) OR (i1^.id4 = $FFFFFFFF) OR (i2^.id4 = $FFFFFFFF)); ll1:= i1^.ex; ll2:= i2^.ex; while true do begin diff --git a/src/kernel.pas b/src/kernel.pas index 8d1000c9..2c85336b 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -34,7 +34,8 @@ uses strings, AHCI, USB, - testdriver; + testdriver, + E1000; procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; @@ -128,7 +129,7 @@ begin pci.init(); console.writestringln('DRIVERS: INIT END.'); - console.writestring('AHCI TEST'); + {console.writestring('AHCI TEST'); console.writestringln('A'); atmp:= puint32(kalloc(sizeof(1024*128))); console.writestringln('B'); @@ -141,7 +142,7 @@ begin AHCI.read(0, $5, $1, 32, atmp); console.writestringln('F'); console.writeint(atmp^); - console.writestringln('G'); + console.writestringln('G');} console.writestringln(''); console.setdefaultattribute(console.combinecolors(Green, Black));