diff --git a/Asuro.iso b/Asuro.iso index 89d65e7b..9641f8f9 100644 Binary files a/Asuro.iso and b/Asuro.iso differ diff --git a/bin/kernel.bin b/bin/kernel.bin index 426e2f71..34171569 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 426e2f71..34171569 100755 Binary files a/iso/boot/asuro.bin and b/iso/boot/asuro.bin differ diff --git a/lib/AHCI_OLD.ppu b/lib/AHCI_OLD.ppu index 5f9d50e5..43ff6399 100644 Binary files a/lib/AHCI_OLD.ppu and b/lib/AHCI_OLD.ppu differ diff --git a/lib/E1000.ppu b/lib/E1000.ppu index 540b4e73..f92d6bb4 100644 Binary files a/lib/E1000.ppu and b/lib/E1000.ppu differ diff --git a/lib/IDE.ppu b/lib/IDE.ppu index c51ba19f..dd145075 100644 Binary files a/lib/IDE.ppu and b/lib/IDE.ppu differ diff --git a/lib/PCI.ppu b/lib/PCI.ppu index 00c4d4de..110f2591 100644 Binary files a/lib/PCI.ppu and b/lib/PCI.ppu differ diff --git a/lib/USB.ppu b/lib/USB.ppu index 5223d492..c662b263 100644 Binary files a/lib/USB.ppu and b/lib/USB.ppu differ diff --git a/lib/bios_data_area.ppu b/lib/bios_data_area.ppu index cfc331a7..55231f14 100644 Binary files a/lib/bios_data_area.ppu and b/lib/bios_data_area.ppu differ diff --git a/lib/console.ppu b/lib/console.ppu index db6aff03..d5bb8e4d 100644 Binary files a/lib/console.ppu and b/lib/console.ppu differ diff --git a/lib/drivermanagement.ppu b/lib/drivermanagement.ppu index 80c919df..e19dc42a 100644 Binary files a/lib/drivermanagement.ppu and b/lib/drivermanagement.ppu differ diff --git a/lib/drivertypes.ppu b/lib/drivertypes.ppu index d65bea0d..4df11084 100644 Binary files a/lib/drivertypes.ppu and b/lib/drivertypes.ppu differ diff --git a/lib/eth2.ppu b/lib/eth2.ppu index f9bdbc8e..2a81f155 100644 Binary files a/lib/eth2.ppu and b/lib/eth2.ppu differ diff --git a/lib/gdt.ppu b/lib/gdt.ppu index d3679911..9f0ad49b 100644 Binary files a/lib/gdt.ppu and b/lib/gdt.ppu differ diff --git a/lib/idt.ppu b/lib/idt.ppu index 7feb7486..5de6603b 100644 Binary files a/lib/idt.ppu and b/lib/idt.ppu differ diff --git a/lib/ipv4.ppu b/lib/ipv4.ppu new file mode 100644 index 00000000..3e2c34ea Binary files /dev/null and b/lib/ipv4.ppu differ diff --git a/lib/irq.ppu b/lib/irq.ppu index d28554b0..dcb4635b 100644 Binary files a/lib/irq.ppu and b/lib/irq.ppu differ diff --git a/lib/isr.ppu b/lib/isr.ppu index 69646688..9ec22053 100644 Binary files a/lib/isr.ppu and b/lib/isr.ppu differ diff --git a/lib/isr0.ppu b/lib/isr0.ppu index d52a9288..60e5b98b 100644 Binary files a/lib/isr0.ppu and b/lib/isr0.ppu differ diff --git a/lib/isr1.ppu b/lib/isr1.ppu index f9d3b583..d1e73edf 100644 Binary files a/lib/isr1.ppu and b/lib/isr1.ppu differ diff --git a/lib/isr10.ppu b/lib/isr10.ppu index 26aab93f..9379dd89 100644 Binary files a/lib/isr10.ppu and b/lib/isr10.ppu differ diff --git a/lib/isr11.ppu b/lib/isr11.ppu index c0b34fe0..482ffb84 100644 Binary files a/lib/isr11.ppu and b/lib/isr11.ppu differ diff --git a/lib/isr12.ppu b/lib/isr12.ppu index 87208936..dc374988 100644 Binary files a/lib/isr12.ppu and b/lib/isr12.ppu differ diff --git a/lib/isr13.ppu b/lib/isr13.ppu index e09e125c..e24abd86 100644 Binary files a/lib/isr13.ppu and b/lib/isr13.ppu differ diff --git a/lib/isr14.ppu b/lib/isr14.ppu index 896d183c..d7f19467 100644 Binary files a/lib/isr14.ppu and b/lib/isr14.ppu differ diff --git a/lib/isr15.ppu b/lib/isr15.ppu index 8513cee1..244b1290 100644 Binary files a/lib/isr15.ppu and b/lib/isr15.ppu differ diff --git a/lib/isr16.ppu b/lib/isr16.ppu index cf44921f..0f884324 100644 Binary files a/lib/isr16.ppu and b/lib/isr16.ppu differ diff --git a/lib/isr17.ppu b/lib/isr17.ppu index 13bc7771..4a5cb396 100644 Binary files a/lib/isr17.ppu and b/lib/isr17.ppu differ diff --git a/lib/isr18.ppu b/lib/isr18.ppu index 8e762b6f..ec0fde94 100644 Binary files a/lib/isr18.ppu and b/lib/isr18.ppu differ diff --git a/lib/isr2.ppu b/lib/isr2.ppu index 7a4adc00..33b56169 100644 Binary files a/lib/isr2.ppu and b/lib/isr2.ppu differ diff --git a/lib/isr3.ppu b/lib/isr3.ppu index 161daf38..2cc07a54 100644 Binary files a/lib/isr3.ppu and b/lib/isr3.ppu differ diff --git a/lib/isr32.ppu b/lib/isr32.ppu index e54c83c6..346d76ef 100644 Binary files a/lib/isr32.ppu and b/lib/isr32.ppu differ diff --git a/lib/isr33.ppu b/lib/isr33.ppu index 4ff1aa16..0fe5348b 100644 Binary files a/lib/isr33.ppu and b/lib/isr33.ppu differ diff --git a/lib/isr4.ppu b/lib/isr4.ppu index 62edd6aa..d6598973 100644 Binary files a/lib/isr4.ppu and b/lib/isr4.ppu differ diff --git a/lib/isr40.ppu b/lib/isr40.ppu index 8711ba36..0dc97533 100644 Binary files a/lib/isr40.ppu and b/lib/isr40.ppu differ diff --git a/lib/isr44.ppu b/lib/isr44.ppu index 65c0a961..08a0a237 100644 Binary files a/lib/isr44.ppu and b/lib/isr44.ppu differ diff --git a/lib/isr5.ppu b/lib/isr5.ppu index 4c1971d6..12d68a11 100644 Binary files a/lib/isr5.ppu and b/lib/isr5.ppu differ diff --git a/lib/isr6.ppu b/lib/isr6.ppu index 8e659b08..1950c967 100644 Binary files a/lib/isr6.ppu and b/lib/isr6.ppu differ diff --git a/lib/isr7.ppu b/lib/isr7.ppu index 75f78e00..47973135 100644 Binary files a/lib/isr7.ppu and b/lib/isr7.ppu differ diff --git a/lib/isr76.ppu b/lib/isr76.ppu index bb32fd07..6c2dc577 100644 Binary files a/lib/isr76.ppu and b/lib/isr76.ppu differ diff --git a/lib/isr8.ppu b/lib/isr8.ppu index 54e414e6..decd6a2d 100644 Binary files a/lib/isr8.ppu and b/lib/isr8.ppu differ diff --git a/lib/isr9.ppu b/lib/isr9.ppu index 07423423..718c54a8 100644 Binary files a/lib/isr9.ppu and b/lib/isr9.ppu differ diff --git a/lib/isr_types.ppu b/lib/isr_types.ppu index 3be68a80..f27e1d7e 100644 Binary files a/lib/isr_types.ppu and b/lib/isr_types.ppu differ diff --git a/lib/kernel.ppu b/lib/kernel.ppu index d0e32084..63bd0931 100644 Binary files a/lib/kernel.ppu and b/lib/kernel.ppu differ diff --git a/lib/keyboard.ppu b/lib/keyboard.ppu index bd1c5cc3..dd4a22a1 100644 Binary files a/lib/keyboard.ppu and b/lib/keyboard.ppu differ diff --git a/lib/libpconsole.a b/lib/libpconsole.a index 664dd714..3f453001 100644 Binary files a/lib/libpconsole.a and b/lib/libpconsole.a differ diff --git a/lib/libpmultiboot.a b/lib/libpmultiboot.a index 730a662d..406cbf63 100644 Binary files a/lib/libpmultiboot.a and b/lib/libpmultiboot.a differ diff --git a/lib/libpsystem.a b/lib/libpsystem.a index 812c56f9..395495ef 100644 Binary files a/lib/libpsystem.a and b/lib/libpsystem.a differ diff --git a/lib/lmemorymanager.ppu b/lib/lmemorymanager.ppu index 40371b80..46d87a05 100644 Binary files a/lib/lmemorymanager.ppu and b/lib/lmemorymanager.ppu differ diff --git a/lib/mouse.ppu b/lib/mouse.ppu index fe3c65ea..5aad8f2e 100644 Binary files a/lib/mouse.ppu and b/lib/mouse.ppu differ diff --git a/lib/multiboot.ppu b/lib/multiboot.ppu index a43ad22d..864aae53 100644 Binary files a/lib/multiboot.ppu and b/lib/multiboot.ppu differ diff --git a/lib/net.ppu b/lib/net.ppu index a5acd344..941e4a1b 100644 Binary files a/lib/net.ppu and b/lib/net.ppu differ diff --git a/lib/nettypes.ppu b/lib/nettypes.ppu index e2200f0e..2e3f02d0 100644 Binary files a/lib/nettypes.ppu and b/lib/nettypes.ppu differ diff --git a/lib/netutils.ppu b/lib/netutils.ppu new file mode 100644 index 00000000..14a193a3 Binary files /dev/null and b/lib/netutils.ppu differ diff --git a/lib/pmemorymanager.ppu b/lib/pmemorymanager.ppu index bb92378e..cf921aae 100644 Binary files a/lib/pmemorymanager.ppu and b/lib/pmemorymanager.ppu differ diff --git a/lib/scheduler.ppu b/lib/scheduler.ppu index 417ab81a..7ef9add6 100644 Binary files a/lib/scheduler.ppu and b/lib/scheduler.ppu differ diff --git a/lib/storagemanagement.ppu b/lib/storagemanagement.ppu index 2cce6119..888de8d3 100644 Binary files a/lib/storagemanagement.ppu and b/lib/storagemanagement.ppu differ diff --git a/lib/strings.ppu b/lib/strings.ppu index b4a818fd..56a1537b 100644 Binary files a/lib/strings.ppu and b/lib/strings.ppu differ diff --git a/lib/system.o b/lib/system.o index 450f08f1..44b9c110 100644 Binary files a/lib/system.o and b/lib/system.o differ diff --git a/lib/system.ppu b/lib/system.ppu index 51fea349..22e6840f 100644 Binary files a/lib/system.ppu and b/lib/system.ppu differ diff --git a/lib/terminal.ppu b/lib/terminal.ppu index 952ccb1f..50ed3e66 100644 Binary files a/lib/terminal.ppu and b/lib/terminal.ppu differ diff --git a/lib/testdriver.ppu b/lib/testdriver.ppu index f633bfe3..a8f32684 100644 Binary files a/lib/testdriver.ppu and b/lib/testdriver.ppu differ diff --git a/lib/tss.ppu b/lib/tss.ppu index 2f2fae2f..f4622142 100644 Binary files a/lib/tss.ppu and b/lib/tss.ppu differ diff --git a/lib/util.ppu b/lib/util.ppu index 1a2ae267..924bcde8 100644 Binary files a/lib/util.ppu and b/lib/util.ppu differ diff --git a/lib/vmemorymanager.ppu b/lib/vmemorymanager.ppu index 3eaa1c31..791eb9f5 100644 Binary files a/lib/vmemorymanager.ppu and b/lib/vmemorymanager.ppu differ diff --git a/src/driver/net/arp.pas b/src/driver/net/arp.pas new file mode 100644 index 00000000..274f1318 --- /dev/null +++ b/src/driver/net/arp.pas @@ -0,0 +1,11 @@ +unit arp; + +interface + +uses + nettypes, netutils, + eth2; + +implementation + +end. \ No newline at end of file diff --git a/src/driver/net/eth2.pas b/src/driver/net/eth2.pas index 51ffe5f8..92ef9877 100644 --- a/src/driver/net/eth2.pas +++ b/src/driver/net/eth2.pas @@ -3,8 +3,11 @@ unit eth2; interface uses - net, nettypes, console; + nettypes, netutils, + net, + console; +procedure registerType(eType : uint16; RecvCB : TRecvCallback); procedure register; implementation @@ -16,21 +19,40 @@ var procedure registerType(eType : uint16; RecvCB : TRecvCallback); begin + register; if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB; end; procedure recv(p_data : void; p_len : uint16); var - src, dst : puint8; + Header : PEthernetHeader; proto_type : uint16; + buf : puint8; begin - dst:= puint8(p_data); - src:= puint8(p_data + 6); + console.outputln('net.eth2', 'RECV.'); + buf:= puint8(p_data); + + Header:= PEthernetHeader(buf); + console.output('net.eth2', 'DEST: '); - writeMACAddress(dst); + writeMACAddress(@Header^.dst[0]); console.output('net.eth2', 'SRC: '); - writeMACAddress(src); + writeMACAddress(@Header^.src[0]); + + proto_type:= Header^.EthTypeHi SHL 8; + proto_type:= proto_type + Header^.EthTypeLo; + console.output('net.eth2', 'PROTO: '); + console.writehexln(proto_type); + + buf:= buf + 14; + + if MACEqual(@Header^.dst[0], @Header^.src[0]) or MACEqual(@Header^.dst[0], @BROADCAST_MAC[0]) then begin + console.outputln('net.eth2', 'MAC HIT'); + if EthTypes[proto_type] <> nil then begin + EthTypes[proto_type](void(buf), p_len - 14); + end; + end; end; procedure register; diff --git a/src/driver/net/icmp.pas b/src/driver/net/icmp.pas new file mode 100644 index 00000000..3ea972b7 --- /dev/null +++ b/src/driver/net/icmp.pas @@ -0,0 +1,11 @@ +unit icmp; + +interface + +uses + nettypes, netutils, + ipv4; + +implementation + +end. \ No newline at end of file diff --git a/src/driver/net/ipv4.pas b/src/driver/net/ipv4.pas new file mode 100644 index 00000000..341ac449 --- /dev/null +++ b/src/driver/net/ipv4.pas @@ -0,0 +1,81 @@ +unit ipv4; + +interface + +uses + util, console, + nettypes, netutils, + eth2; + +procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback); +procedure register; + +implementation + +var + Registered : Boolean = false; + Protocols : Array[0..255] of TRecvCallback; + +procedure recv(p_data : void; p_len : uint16); +var + Header : PIPV4Header; + AHeader : TIPV4AbstractHeader; + i : Integer; + + buf : puint8; + len : uint16; + +begin + console.outputln('net.ipv4', 'RECV.'); + Header:= PIPV4Header(p_data); + AHeader.version:= Header^.version; + AHeader.header_len:= Header^.header_len; + AHeader.ToS:= Header^.ToS; + AHeader.total_len:= (Header^.total_len_Hi SHL 8) + Header^.total_len_Lo; + AHeader.identifier:= (Header^.identifier_Hi SHL 8) + Header^.identifier_Lo; + AHeader.Flags.RS:= false; + AHeader.Flags.DF:= (Header^.Flags AND $2) > 0; + AHeader.Flags.MF:= (Header^.Flags AND $1) > 0; + AHeader.Fragment_Off:= Header^.Fragment_Off; + AHeader.TTL:= Header^.TTL; + AHeader.Protocol:= Header^.Protocol; + AHeader.HDR_CHK:= (Header^.HDR_CHK_Hi SHL 8) + Header^.HDR_CHK_Lo; + for i:=0 to 3 do begin + AHeader.Src[i]:= Header^.Src[i]; + AHeader.Dst[i]:= Header^.Dst[i]; + end; + AHeader.Options:= Header^.Options; + + console.output('net.ipv4', 'Source: '); + writeIPv4Address(puint8(@AHeader.Src[0])); + console.output('net.ipv4', 'Dest: '); + writeIPv4Address(puint8(@AHeader.Dst[0])); + + buf:= puint8(p_data); + buf:= buf + AHeader.header_len; + len:= p_len - AHeader.header_len; + + if Protocols[AHeader.Protocol] <> nil then Protocols[AHeader.Protocol](void(buf), len); +end; + +procedure register; +var + i : integer; + +begin + if not Registered then begin + for i:=0 to 255 do begin + Protocols[i]:= nil; + end; + eth2.registerType($0800, @recv); + Registered:= true; + end; +end; + +procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback); +begin + register; + if Protocols[Protocol_ID] = nil then Protocols[Protocol_ID]:= recv_callback; +end; + +end. \ No newline at end of file diff --git a/src/driver/net/net.pas b/src/driver/net/net.pas index 7f7bd38a..1b4a5e84 100644 --- a/src/driver/net/net.pas +++ b/src/driver/net/net.pas @@ -3,7 +3,8 @@ unit net; interface uses - nettypes; + console, + nettypes, netutils; procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8); procedure registerNextLayer(RecvCallback : TRecvCallback); @@ -35,12 +36,13 @@ end; procedure send(p_data : void; p_len : uint16); begin - CBSend(p_data, p_len); + if CBSend <> nil then CBSend(p_data, p_len); end; procedure recv(p_data : void; p_len : uint16); begin - CBNext(p_data, p_len); + console.outputln('net', 'RECV.'); + if CBNext <> nil then CBNext(p_data, p_len); end; function getMAC : puint8; diff --git a/src/driver/net/nettypes.pas b/src/driver/net/nettypes.pas index a9549a67..faf20ee4 100644 --- a/src/driver/net/nettypes.pas +++ b/src/driver/net/nettypes.pas @@ -2,28 +2,64 @@ unit nettypes; interface -uses - console; - type TNetSendCallback = function(p_data : void; p_len : uint16) : sint32; TRecvCallback = procedure(p_data : void; p_len : uint16); -procedure writeMACAddress(mac : puint8); + PEthernetHeader = ^TEthernetHeader; + TEthernetHeader = bitpacked record + dst : array[0..5] of uint8; + src : array[0..5] of uint8; + EthTypeHi : uint8; + EthTypeLo : uint8; + end; + + PIPV4Header = ^TIPV4Header; + TIPV4Header = bitpacked record + version : ubit4; + header_len : ubit4; + ToS : uint8; + total_len_Hi : uint8; + total_len_Lo : uint8; + identifier_Hi : uint8; + identifier_Lo : uint8; + Flags : ubit3; + Fragment_Off : ubit13; + TTL : uint8; + Protocol : uint8; + HDR_CHK_Hi : uint8; + HDR_CHK_Lo : uint8; + Src : Array[0..3] of uint8; + Dst : Array[0..3] of uint8; + Options : ubit24; + Padding : uint8; + end; + + TTCPFlags = record + RS : Boolean; + DF : Boolean; + MF : Boolean; + end; + + TIPV4AbstractHeader = record + version : uint8; + header_len : uint8; + ToS : uint8; + total_len : uint16; + identifier : uint16; + Flags : TTCPFlags; + Fragment_Off : uint16; + TTL : uint8; + Protocol : uint8; + HDR_CHK : uint16; + Src : Array[0..3] of uint8; + Dst : Array[0..3] of uint8; + Options : uint32; + end; + +const + BROADCAST_MAC : Array[0..5] of uint8 = ($FF, $FF, $FF, $FF, $FF, $FF); implementation -procedure writeMACAddress(mac : puint8); -var - i : integer; - -begin - console.writehexpair(mac[0]); - for i:=1 to 5 do begin - console.writestring(':'); - console.writehexpair(mac[i]); - end; - console.writestringln(' '); -end; - end. \ No newline at end of file diff --git a/src/driver/net/netutils.pas b/src/driver/net/netutils.pas new file mode 100644 index 00000000..48f0f1f2 --- /dev/null +++ b/src/driver/net/netutils.pas @@ -0,0 +1,54 @@ +unit netutils; + +interface + +uses + nettypes, console; + +procedure writeMACAddress(mac : puint8); +procedure writeIPv4Address(ip : puint8); +function MACEqual(mac1 : puint8; mac2 : puint8) : boolean; + +implementation + +function MACEqual(mac1 : puint8; mac2 : puint8) : boolean; +var + i : uint8; + +begin + MACEqual:= true; + for i:=0 to 5 do begin + if mac1[i] <> mac2[i] then begin + MACEqual:= false; + exit; + end; + end; +end; + +procedure writeIPv4Address(ip : puint8); +var + i : integer; + +begin + console.writeint(ip[0]); + for i:=1 to 3 do begin + console.writestring('.'); + console.writeint(ip[i]); + end; + console.writestringln(' '); +end; + +procedure writeMACAddress(mac : puint8); +var + i : integer; + +begin + console.writehexpair(mac[0]); + for i:=1 to 5 do begin + console.writestring(':'); + console.writehexpair(mac[i]); + end; + console.writestringln(' '); +end; + +end. \ No newline at end of file diff --git a/src/driver/net/tcp.pas b/src/driver/net/tcp.pas new file mode 100644 index 00000000..90392c40 --- /dev/null +++ b/src/driver/net/tcp.pas @@ -0,0 +1,11 @@ +unit tcp; + +interface + +uses + nettypes, netutils, + ipv4; + +implementation + +end. \ No newline at end of file diff --git a/src/driver/net/udp.pas b/src/driver/net/udp.pas new file mode 100644 index 00000000..848138b5 --- /dev/null +++ b/src/driver/net/udp.pas @@ -0,0 +1,11 @@ +unit udp; + +interface + +uses + nettypes, netutils, + ipv4; + +implementation + +end. \ No newline at end of file diff --git a/src/driver/netdev/E1000.pas b/src/driver/netdev/E1000.pas index 89801dd6..d1186b43 100644 --- a/src/driver/netdev/E1000.pas +++ b/src/driver/netdev/E1000.pas @@ -14,7 +14,8 @@ uses PCI, terminal, net, - nettypes; + nettypes, + netutils; const INTEL_VEND = $8086; @@ -146,8 +147,10 @@ var mac : array[0..5] of uint8; rx_descs : array[0..E1000_NUM_RX_DESC-1] of PE1000_rx_desc; tx_descs : array[0..E1000_NUM_TX_DESC-1] of PE1000_tx_desc; + rx_buffs : array[0..E1000_NUM_RX_DESC-1] of puint8; rx_curr : uint16; tx_curr : uint16; + mem_aloc : boolean = false; procedure writeCommand(p_address : uint16; p_value : uint32); var @@ -269,7 +272,8 @@ begin descs:= PE1000_rx_desc(ptr); for i:=0 to E1000_NUM_RX_DESC do begin rx_descs[i]:= @descs[i];//PE1000_rx_desc(uint32(descs) + i*16); - rx_descs[i]^.address:= uint64(kalloc(8192 + 16)); + rx_buffs[i]:= puint8(kalloc(8192 + 16)); + rx_descs[i]^.address:= uint64(vtop(uint32(rx_buffs[i]))); rx_descs[i]^.status:= 0; end; @@ -349,15 +353,15 @@ var got_packet : boolean; buf : puint8; len : uint16; + i : uint16; begin while (rx_descs[rx_curr]^.status AND $1) > 0 do begin got_packet:= true; - buf:= puint8(rx_descs[rx_curr]^.address); + buf:= rx_buffs[rx_curr]; len:= rx_descs[rx_curr]^.length; //Inject Packet into Network Stack - kpalloc(uint32(buf)); net.recv(void(buf), len); rx_descs[rx_curr]^.status:= 0; @@ -384,6 +388,8 @@ var data : uint32; begin + console.outputln('E1000 Driver', 'FIRED.'); + status:= readCommand($C0); //console.output('E1000 Driver', 'Int Status: '); //console.writehexln(status); diff --git a/src/kernel.pas b/src/kernel.pas index 22ccdfa9..92dd4e53 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -37,7 +37,7 @@ uses E1000, AHCI_OLD, IDE, - storagemanagement; + ipv4; procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; @@ -95,7 +95,6 @@ begin terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.'); drivermanagement.init(); - storagemanagement.init(); console.init(); @@ -142,12 +141,14 @@ begin testdriver.init(); E1000.init(); //AHCI_OLD.init(); - IDE.init(); + //IDE.init(); //Nothing beyond here USB.init(); pci.init(); console.outputln('KERNEL', 'DRIVERS: INIT END.'); + ipv4.register(); + console.writestringln(''); console.setdefaultattribute(console.combinecolors(Green, Black)); console.writestringln('Asuro Booted Correctly!'); diff --git a/src/system.pas b/src/system.pas index 66159cbe..2ac03547 100644 --- a/src/system.pas +++ b/src/system.pas @@ -36,7 +36,7 @@ type sInt64 = longint; Float = Single; - + //Pointer Types PuByte = ^Byte; PuInt8 = PuByte; @@ -55,19 +55,35 @@ type Void = ^uInt32; //Alternate Types - UBit2 = 0..(1 shl 2) - 1; - UBit3 = 0..(1 shl 3) - 1; - UBit4 = 0..(1 shl 4) - 1; - UBit5 = 0..(1 shl 5) - 1; - UBit6 = 0..(1 shl 6) - 1; - UBit7 = 0..(1 shl 7) - 1; - UBit9 = 0..(1 shl 9) - 1; + UBit1 = 0..(1 shl 01) - 1; + UBit2 = 0..(1 shl 02) - 1; + UBit3 = 0..(1 shl 03) - 1; + UBit4 = 0..(1 shl 04) - 1; + UBit5 = 0..(1 shl 05) - 1; + UBit6 = 0..(1 shl 06) - 1; + UBit7 = 0..(1 shl 07) - 1; + UBit9 = 0..(1 shl 09) - 1; + UBit10 = 0..(1 shl 10) - 1; + UBit11 = 0..(1 shl 11) - 1; + UBit12 = 0..(1 shl 12) - 1; + UBit13 = 0..(1 shl 13) - 1; + UBit14 = 0..(1 shl 14) - 1; + UBit15 = 0..(1 shl 15) - 1; + UBit16 = 0..(1 shl 16) - 1; UBit17 = 0..(1 shl 17) - 1; + UBit18 = 0..(1 shl 18) - 1; + UBit19 = 0..(1 shl 19) - 1; UBit20 = 0..(1 shl 20) - 1; + UBit21 = 0..(1 shl 21) - 1; UBit22 = 0..(1 shl 22) - 1; + UBit23 = 0..(1 shl 23) - 1; + UBit24 = 0..(1 shl 24) - 1; UBit25 = 0..(1 shl 25) - 1; + UBit26 = 0..(1 shl 26) - 1; + UBit27 = 0..(1 shl 27) - 1; UBit28 = 0..(1 shl 28) - 1; UBit30 = 0..(1 shl 30) - 1; + UBit31 = 0..(1 shl 31) - 1; TBitMask = bitpacked record b0,b1,b2,b3,b4,b5,b6,b7 : Boolean; diff --git a/src/util.pas b/src/util.pas index b0448272..4338c2ad 100644 --- a/src/util.pas +++ b/src/util.pas @@ -36,6 +36,8 @@ function inl(port : uint16) : uint32; procedure memset(location : uint32; value : uint8; size : uint32); procedure memcpy(source : uint32; dest : uint32; size : uint32); +procedure printmemory(source : uint32; length : uint32; col : uint32; delim : PChar; offset_row : boolean); + procedure halt_and_catch_fire(); procedure halt_and_dont_catch_fire(); procedure BSOD(fault : pchar; info : pchar); @@ -50,6 +52,32 @@ implementation uses console; +procedure printmemory(source : uint32; length : uint32; col : uint32; delim : PChar; offset_row : boolean); +var + buf : puint8; + i : uint32; + +begin + buf:= puint8(source); + for i:=0 to length do begin + if offset_row and (i = 0) then begin + console.writehex(source + (i * col)); + console.writestring(': '); + end; + console.writehexpair(buf[i]); + if ((i+1) MOD col) = 0 then begin + console.writestringln(' '); + if offset_row then begin + console.writehex(source + (i * col)); + console.writestring(': '); + end; + end else begin + console.writestring(delim); + end; + end; + console.writestringln(' '); +end; + function hi(b : uint8) : uint8; [public, alias: 'util_hi']; begin hi:= (b AND $F0) SHR 4; diff --git a/src/vmemorymanager.pas b/src/vmemorymanager.pas index 3e70dfdc..90047320 100644 --- a/src/vmemorymanager.pas +++ b/src/vmemorymanager.pas @@ -94,9 +94,9 @@ begin console.outputln('VMM','INIT BEGIN.'); PageDirectory:= load_current_page_directory; KERNEL_PAGE_DIRECTORY:= PageDirectory; + map_page(KERNEL_PAGE_NUMBER + 0, 0); map_page(KERNEL_PAGE_NUMBER + 1, 1); map_page(KERNEL_PAGE_NUMBER + 2, 2); - map_page(KERNEL_PAGE_NUMBER + 3, 3); console.outputln('VMM','INIT END.'); end;