git-svn-id: https://spexeah.com:8443/svn/Asuro@481 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
aa748b9796
commit
16c0580e58
BIN
bin/kernel.bin
BIN
bin/kernel.bin
Binary file not shown.
Binary file not shown.
BIN
lib/E1000.ppu
BIN
lib/E1000.ppu
Binary file not shown.
BIN
lib/IDE.ppu
BIN
lib/IDE.ppu
Binary file not shown.
BIN
lib/PCI.ppu
BIN
lib/PCI.ppu
Binary file not shown.
BIN
lib/USB.ppu
BIN
lib/USB.ppu
Binary file not shown.
Binary file not shown.
BIN
lib/console.ppu
BIN
lib/console.ppu
Binary file not shown.
Binary file not shown.
BIN
lib/eth2.ppu
BIN
lib/eth2.ppu
Binary file not shown.
BIN
lib/idt.ppu
BIN
lib/idt.ppu
Binary file not shown.
BIN
lib/ipv4.ppu
BIN
lib/ipv4.ppu
Binary file not shown.
BIN
lib/irq.ppu
BIN
lib/irq.ppu
Binary file not shown.
BIN
lib/isr0.ppu
BIN
lib/isr0.ppu
Binary file not shown.
BIN
lib/isr1.ppu
BIN
lib/isr1.ppu
Binary file not shown.
BIN
lib/isr10.ppu
BIN
lib/isr10.ppu
Binary file not shown.
BIN
lib/isr11.ppu
BIN
lib/isr11.ppu
Binary file not shown.
BIN
lib/isr12.ppu
BIN
lib/isr12.ppu
Binary file not shown.
BIN
lib/isr13.ppu
BIN
lib/isr13.ppu
Binary file not shown.
BIN
lib/isr14.ppu
BIN
lib/isr14.ppu
Binary file not shown.
BIN
lib/isr15.ppu
BIN
lib/isr15.ppu
Binary file not shown.
BIN
lib/isr16.ppu
BIN
lib/isr16.ppu
Binary file not shown.
BIN
lib/isr17.ppu
BIN
lib/isr17.ppu
Binary file not shown.
BIN
lib/isr18.ppu
BIN
lib/isr18.ppu
Binary file not shown.
BIN
lib/isr2.ppu
BIN
lib/isr2.ppu
Binary file not shown.
BIN
lib/isr3.ppu
BIN
lib/isr3.ppu
Binary file not shown.
BIN
lib/isr32.ppu
BIN
lib/isr32.ppu
Binary file not shown.
BIN
lib/isr33.ppu
BIN
lib/isr33.ppu
Binary file not shown.
BIN
lib/isr4.ppu
BIN
lib/isr4.ppu
Binary file not shown.
BIN
lib/isr40.ppu
BIN
lib/isr40.ppu
Binary file not shown.
BIN
lib/isr44.ppu
BIN
lib/isr44.ppu
Binary file not shown.
BIN
lib/isr5.ppu
BIN
lib/isr5.ppu
Binary file not shown.
BIN
lib/isr6.ppu
BIN
lib/isr6.ppu
Binary file not shown.
BIN
lib/isr7.ppu
BIN
lib/isr7.ppu
Binary file not shown.
BIN
lib/isr76.ppu
BIN
lib/isr76.ppu
Binary file not shown.
BIN
lib/isr8.ppu
BIN
lib/isr8.ppu
Binary file not shown.
BIN
lib/isr9.ppu
BIN
lib/isr9.ppu
Binary file not shown.
BIN
lib/kernel.ppu
BIN
lib/kernel.ppu
Binary file not shown.
BIN
lib/keyboard.ppu
BIN
lib/keyboard.ppu
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/libpsystem.a
BIN
lib/libpsystem.a
Binary file not shown.
BIN
lib/lists.ppu
BIN
lib/lists.ppu
Binary file not shown.
Binary file not shown.
BIN
lib/mouse.ppu
BIN
lib/mouse.ppu
Binary file not shown.
BIN
lib/net.ppu
BIN
lib/net.ppu
Binary file not shown.
BIN
lib/nettypes.ppu
BIN
lib/nettypes.ppu
Binary file not shown.
BIN
lib/netutils.ppu
BIN
lib/netutils.ppu
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/strings.ppu
BIN
lib/strings.ppu
Binary file not shown.
BIN
lib/system.ppu
BIN
lib/system.ppu
Binary file not shown.
BIN
lib/terminal.ppu
BIN
lib/terminal.ppu
Binary file not shown.
Binary file not shown.
BIN
lib/tss.ppu
BIN
lib/tss.ppu
Binary file not shown.
BIN
lib/util.ppu
BIN
lib/util.ppu
Binary file not shown.
Binary file not shown.
@ -3,8 +3,62 @@ unit nettypes;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
type
|
type
|
||||||
TNetSendCallback = function(p_data : void; p_len : uint16) : sint32;
|
|
||||||
TRecvCallback = procedure(p_data : void; p_len : uint16);
|
|
||||||
|
TMACAddress = Array[0..5] of uint8;
|
||||||
|
TIPv4Address = Array[0..3] of uint8;
|
||||||
|
|
||||||
|
TMACPair = record
|
||||||
|
Source : TMACAddress;
|
||||||
|
Destination : TMACAddress;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TIPv4Pair = record
|
||||||
|
Source : TIPv4Address;
|
||||||
|
Destination : TIPv4Address;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PPacketContext = ^TPacketContext;
|
||||||
|
TPacketContext = record
|
||||||
|
MAC : TMACPair;
|
||||||
|
IP : TIPv4Pair;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PIPv4Configuration = ^TIPv4Configuration;
|
||||||
|
TIPv4Configuration = record
|
||||||
|
Address : array[0..3] of uint8;
|
||||||
|
Gateway : array[0..3] of uint8;
|
||||||
|
Netmask : array[0..3] of uint8;
|
||||||
|
UP : Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TARPAbstractHeader = record
|
||||||
|
Hardware_Type : uint16;
|
||||||
|
Protocol_Type : uint16;
|
||||||
|
Hardware_Address_Length : uint8;
|
||||||
|
Protocol_Address_Length : uint8;
|
||||||
|
Operation : uint16;
|
||||||
|
Source_Hardware : TMACAddress;
|
||||||
|
Source_Protocol : TIPv4Address;
|
||||||
|
Destination_Hardware : TMACAddress;
|
||||||
|
Destination_Protocol : TIPv4Address;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PARPHeader = ^TARPHeader;
|
||||||
|
TARPHeader = bitpacked record
|
||||||
|
Hardware_Type_Hi : uint8;
|
||||||
|
Hardware_Type_Lo : uint8;
|
||||||
|
Protocol_Type_Hi : uint8;
|
||||||
|
Protocol_Type_Lo : uint8;
|
||||||
|
Hardware_Address_Length : uint8;
|
||||||
|
Protocol_Address_Length : uint8;
|
||||||
|
Operation_Hi : uint8;
|
||||||
|
Operation_Lo : uint8;
|
||||||
|
Source_Hardware : TMACAddress;
|
||||||
|
Source_Protocol : TIPv4Address;
|
||||||
|
Destination_Hardware : TMACAddress;
|
||||||
|
Destination_Protocol : TIPv4Address;
|
||||||
|
end;
|
||||||
|
|
||||||
PEthernetHeader = ^TEthernetHeader;
|
PEthernetHeader = ^TEthernetHeader;
|
||||||
TEthernetHeader = bitpacked record
|
TEthernetHeader = bitpacked record
|
||||||
@ -57,6 +111,9 @@ type
|
|||||||
Options : uint32;
|
Options : uint32;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TNetSendCallback = function(p_data : void; p_len : uint16) : sint32;
|
||||||
|
TRecvCallback = procedure(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||||
|
|
||||||
const
|
const
|
||||||
BROADCAST_MAC : Array[0..5] of uint8 = ($FF, $FF, $FF, $FF, $FF, $FF);
|
BROADCAST_MAC : Array[0..5] of uint8 = ($FF, $FF, $FF, $FF, $FF, $FF);
|
||||||
|
|
||||||
|
@ -3,14 +3,33 @@ unit netutils;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
nettypes, console;
|
util, nettypes, console, lmemorymanager;
|
||||||
|
|
||||||
|
procedure copyMAC(src : puint8; dst : puint8);
|
||||||
|
procedure copyIPv4(src : puint8; dst : puint8);
|
||||||
procedure writeMACAddress(mac : puint8);
|
procedure writeMACAddress(mac : puint8);
|
||||||
procedure writeIPv4Address(ip : puint8);
|
procedure writeIPv4Address(ip : puint8);
|
||||||
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
||||||
|
function IPEqual(ip1 : puint8; ip2 : puint8) : boolean;
|
||||||
|
function newPacketContext : PPacketContext;
|
||||||
|
procedure freePacketContext(p_context : PPacketContext);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
function IPEqual(ip1 : puint8; ip2 : puint8) : boolean;
|
||||||
|
var
|
||||||
|
i : uint8;
|
||||||
|
|
||||||
|
begin
|
||||||
|
IPEqual:= true;
|
||||||
|
for i:=0 to 3 do begin
|
||||||
|
if ip1[i] <> ip2[i] then begin
|
||||||
|
IPEqual:= false;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
@ -51,4 +70,35 @@ begin
|
|||||||
console.writestringln(' ');
|
console.writestringln(' ');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function newPacketContext : PPacketContext;
|
||||||
|
begin
|
||||||
|
newPacketContext:= PPacketContext(kalloc(sizeof(TPacketContext)));
|
||||||
|
memset(uint32(newPacketContext), 0, sizeof(TPacketContext));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure freePacketContext(p_context : PPacketContext);
|
||||||
|
begin
|
||||||
|
kfree(void(p_context));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure copyMAC(src : puint8; dst : puint8);
|
||||||
|
var
|
||||||
|
i : uint8;
|
||||||
|
|
||||||
|
begin
|
||||||
|
for i:=0 to 5 do begin
|
||||||
|
dst[i]:= src[i];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure copyIPv4(src : puint8; dst : puint8);
|
||||||
|
var
|
||||||
|
i : uint8;
|
||||||
|
|
||||||
|
begin
|
||||||
|
for i:=0 to 3 do begin
|
||||||
|
dst[i]:= src[i];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -6,6 +6,7 @@ uses
|
|||||||
console,
|
console,
|
||||||
nettypes, netutils;
|
nettypes, netutils;
|
||||||
|
|
||||||
|
procedure init;
|
||||||
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
|
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
|
||||||
procedure registerNextLayer(RecvCallback : TRecvCallback);
|
procedure registerNextLayer(RecvCallback : TRecvCallback);
|
||||||
procedure send(p_data : void; p_len : uint16);
|
procedure send(p_data : void; p_len : uint16);
|
||||||
@ -14,6 +15,9 @@ function getMAC : puint8;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
ipv4, arp, eth2;
|
||||||
|
|
||||||
var
|
var
|
||||||
CBSend : TNetSendCallback = nil;
|
CBSend : TNetSendCallback = nil;
|
||||||
CBNext : TRecvCallback = nil;
|
CBNext : TRecvCallback = nil;
|
||||||
@ -40,9 +44,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure recv(p_data : void; p_len : uint16);
|
procedure recv(p_data : void; p_len : uint16);
|
||||||
|
var
|
||||||
|
context : PPacketContext;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//console.outputln('net', 'RECV.');
|
//console.outputln('net', 'RECV.');
|
||||||
if CBNext <> nil then CBNext(p_data, p_len);
|
context:= newPacketContext;
|
||||||
|
if CBNext <> nil then CBNext(p_data, p_len, context);
|
||||||
|
freePacketContext(context);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getMAC : puint8;
|
function getMAC : puint8;
|
||||||
@ -50,4 +59,11 @@ begin
|
|||||||
getMAC:= MAC;
|
getMAC:= MAC;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure init;
|
||||||
|
begin
|
||||||
|
eth2.register;
|
||||||
|
arp.register;
|
||||||
|
ipv4.register;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -23,34 +23,37 @@ begin
|
|||||||
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure recv(p_data : void; p_len : uint16);
|
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||||
var
|
var
|
||||||
Header : PEthernetHeader;
|
Header : PEthernetHeader;
|
||||||
proto_type : uint16;
|
proto_type : uint16;
|
||||||
buf : puint8;
|
buf : puint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.outputln('net.eth2', 'RECV.');
|
//console.outputln('net.eth2', 'RECV.');
|
||||||
buf:= puint8(p_data);
|
buf:= puint8(p_data);
|
||||||
|
|
||||||
Header:= PEthernetHeader(buf);
|
Header:= PEthernetHeader(buf);
|
||||||
|
|
||||||
console.output('net.eth2', 'DEST: ');
|
//console.output('net.eth2', 'DEST: ');
|
||||||
writeMACAddress(@Header^.dst[0]);
|
//writeMACAddress(@Header^.dst[0]);
|
||||||
console.output('net.eth2', 'SRC: ');
|
//console.output('net.eth2', 'SRC: ');
|
||||||
writeMACAddress(@Header^.src[0]);
|
//writeMACAddress(@Header^.src[0]);
|
||||||
|
|
||||||
proto_type:= Header^.EthTypeHi SHL 8;
|
proto_type:= Header^.EthTypeHi SHL 8;
|
||||||
proto_type:= proto_type + Header^.EthTypeLo;
|
proto_type:= proto_type + Header^.EthTypeLo;
|
||||||
console.output('net.eth2', 'PROTO: ');
|
//console.output('net.eth2', 'PROTO: ');
|
||||||
console.writehexln(proto_type);
|
//console.writehexln(proto_type);
|
||||||
|
|
||||||
buf:= buf + 14;
|
buf:= buf + 14;
|
||||||
|
|
||||||
|
copyMAC(@Header^.src[0], @p_context^.MAC.Source[0]);
|
||||||
|
copyMAC(@Header^.dst[0], @p_context^.MAC.Destination[0]);
|
||||||
|
|
||||||
if MACEqual(@Header^.dst[0], @Header^.src[0]) or MACEqual(@Header^.dst[0], @BROADCAST_MAC[0]) then begin
|
if MACEqual(@Header^.dst[0], @Header^.src[0]) or MACEqual(@Header^.dst[0], @BROADCAST_MAC[0]) then begin
|
||||||
console.outputln('net.eth2', 'MAC HIT');
|
//console.outputln('net.eth2', 'MAC HIT');
|
||||||
if EthTypes[proto_type] <> nil then begin
|
if EthTypes[proto_type] <> nil then begin
|
||||||
EthTypes[proto_type](void(buf), p_len - 14);
|
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -3,9 +3,142 @@ unit arp;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
util, lists, console,
|
||||||
nettypes, netutils,
|
nettypes, netutils,
|
||||||
eth2;
|
eth2;
|
||||||
|
|
||||||
|
type
|
||||||
|
PARPCacheRecord = ^TARPCacheRecord;
|
||||||
|
TARPCacheRecord = record
|
||||||
|
MAC : TMACAddress;
|
||||||
|
IP : TIPv4Address;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure register;
|
||||||
|
function IPv4ToMAC(ip : puint8) : puint8;
|
||||||
|
function MACToIIPv4(mac : puint8) : puint8;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
Registered : Boolean = false;
|
||||||
|
Cache : PLinkedListBase;
|
||||||
|
|
||||||
|
function findCacheRecordByMAC(mac : puint8) : PARPCacheRecord;
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
findCacheRecordByMAC:= nil;
|
||||||
|
for i:=0 to LL_Size(Cache)-1 do begin
|
||||||
|
r:= PARPCacheRecord(LL_Get(Cache, i));
|
||||||
|
if MACEqual(mac, @r^.MAC[0]) then begin
|
||||||
|
findCacheRecordByMAC:= r;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function findCacheRecordByIP(ip : puint8) : PARPCacheRecord;
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
findCacheRecordByIP:= nil;
|
||||||
|
for i:=0 to LL_Size(Cache)-1 do begin
|
||||||
|
r:= PARPCacheRecord(LL_Get(Cache, i));
|
||||||
|
if IPEqual(ip, @r^.IP[0]) then begin
|
||||||
|
findCacheRecordByIP:= r;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||||
|
var
|
||||||
|
Header : PARPHeader;
|
||||||
|
AHeader : TARPAbstractHeader;
|
||||||
|
CacheElement : PARPCacheRecord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{ Get our converted Header }
|
||||||
|
Header:= PARPHeader(p_data);
|
||||||
|
AHeader.Hardware_Type:= (Header^.Hardware_Type_Hi SHL 8) + Header^.Hardware_Type_Lo;
|
||||||
|
AHeader.Protocol_Type:= (Header^.Protocol_Type_Hi SHL 8) + Header^.Protocol_Type_Lo;
|
||||||
|
AHeader.Hardware_Address_Length:= Header^.Hardware_Address_Length;
|
||||||
|
AHeader.Protocol_Address_Length:= Header^.Protocol_Address_Length;
|
||||||
|
AHeader.Operation:= (Header^.Operation_Hi SHL 8) + Header^.Operation_Lo;
|
||||||
|
copyMAC(@Header^.Source_Hardware[0], @AHeader.Source_Hardware[0]);
|
||||||
|
copyIPv4(@Header^.Source_Protocol[0], @AHeader.Source_Protocol[0]);
|
||||||
|
copyMAC(@Header^.Destination_Hardware[0], @AHeader.Destination_Hardware[0]);
|
||||||
|
copyIPv4(@Header^.Destination_Protocol[0], @AHeader.Destination_Protocol[0]);
|
||||||
|
|
||||||
|
case AHeader.Operation of
|
||||||
|
$1:begin { ARP Request }
|
||||||
|
//console.writestringln('ARP Request.');
|
||||||
|
end;
|
||||||
|
$2:begin { ARP Reply }
|
||||||
|
//console.writestringln('ARP Reply.');
|
||||||
|
end;
|
||||||
|
$3:begin { RARP Request }
|
||||||
|
|
||||||
|
end;
|
||||||
|
$4:begin { RARP Reply }
|
||||||
|
|
||||||
|
end;
|
||||||
|
$5:begin { DRARP Request }
|
||||||
|
|
||||||
|
end;
|
||||||
|
$6:begin { DRARP Reply }
|
||||||
|
|
||||||
|
end;
|
||||||
|
$7:begin { DRARP Error }
|
||||||
|
|
||||||
|
end;
|
||||||
|
$8:begin { InARP Request }
|
||||||
|
|
||||||
|
end;
|
||||||
|
$9:begin { InARP Reply }
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure register;
|
||||||
|
begin
|
||||||
|
if not Registered then begin
|
||||||
|
Cache:= LL_New(sizeof(TARPCacheRecord));
|
||||||
|
eth2.registerType($0806, @recv);
|
||||||
|
Registered:= true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IPv4ToMAC(ip : puint8) : puint8;
|
||||||
|
var
|
||||||
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
register;
|
||||||
|
IPv4ToMAC:= nil;
|
||||||
|
r:= findCacheRecordByIP(ip);
|
||||||
|
if r <> nil then begin
|
||||||
|
IPv4ToMAC:= @r^.MAC[0];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MACToIIPv4(mac : puint8) : puint8;
|
||||||
|
var
|
||||||
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
register;
|
||||||
|
MACToIIPv4:= nil;
|
||||||
|
r:= findCacheRecordByMAC(mac);
|
||||||
|
if r <> nil then begin
|
||||||
|
MACToIIPv4:= @r^.IP[0];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -3,8 +3,8 @@ unit ipv4;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
util, console,
|
util, console, terminal,
|
||||||
nettypes, netutils,
|
net, nettypes, netutils,
|
||||||
eth2;
|
eth2;
|
||||||
|
|
||||||
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
||||||
@ -15,8 +15,9 @@ implementation
|
|||||||
var
|
var
|
||||||
Registered : Boolean = false;
|
Registered : Boolean = false;
|
||||||
Protocols : Array[0..255] of TRecvCallback;
|
Protocols : Array[0..255] of TRecvCallback;
|
||||||
|
Config : TIPv4Configuration;
|
||||||
|
|
||||||
procedure recv(p_data : void; p_len : uint16);
|
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||||
var
|
var
|
||||||
Header : PIPV4Header;
|
Header : PIPV4Header;
|
||||||
AHeader : TIPV4AbstractHeader;
|
AHeader : TIPV4AbstractHeader;
|
||||||
@ -25,7 +26,7 @@ var
|
|||||||
len : uint16;
|
len : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.outputln('net.ipv4', 'RECV.');
|
//console.outputln('net.ipv4', 'RECV.');
|
||||||
Header:= PIPV4Header(p_data);
|
Header:= PIPV4Header(p_data);
|
||||||
AHeader.version:= Header^.version;
|
AHeader.version:= Header^.version;
|
||||||
AHeader.header_len:= Header^.header_len;
|
AHeader.header_len:= Header^.header_len;
|
||||||
@ -45,16 +46,41 @@ begin
|
|||||||
end;
|
end;
|
||||||
AHeader.Options:= Header^.Options;
|
AHeader.Options:= Header^.Options;
|
||||||
|
|
||||||
console.output('net.ipv4', 'Source: ');
|
//console.output('net.ipv4', 'Source: ');
|
||||||
writeIPv4Address(puint8(@AHeader.Src[0]));
|
//writeIPv4Address(puint8(@AHeader.Src[0]));
|
||||||
console.output('net.ipv4', 'Dest: ');
|
//console.output('net.ipv4', 'Dest: ');
|
||||||
writeIPv4Address(puint8(@AHeader.Dst[0]));
|
//writeIPv4Address(puint8(@AHeader.Dst[0]));
|
||||||
|
|
||||||
buf:= puint8(p_data);
|
buf:= puint8(p_data);
|
||||||
buf:= buf + AHeader.header_len;
|
buf:= buf + AHeader.header_len;
|
||||||
len:= p_len - AHeader.header_len;
|
len:= p_len - AHeader.header_len;
|
||||||
|
|
||||||
if Protocols[AHeader.Protocol] <> nil then Protocols[AHeader.Protocol](void(buf), len);
|
copyIPv4(@AHeader.Src[0], @p_context^.IP.Source[0]);
|
||||||
|
copyIPv4(@AHeader.Dst[0], @p_context^.IP.Destination[0]);
|
||||||
|
|
||||||
|
if (IPEqual(@Config.Address[0], @AHeader.Dst[0])) OR (AHeader.Dst[3] = 255) then begin
|
||||||
|
if Protocols[AHeader.Protocol] <> nil then Protocols[AHeader.Protocol](void(buf), len, p_context);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure terminal_command_ifconfig(params : PParamList);
|
||||||
|
begin
|
||||||
|
if paramCount(params) > 2 then begin
|
||||||
|
|
||||||
|
end else begin
|
||||||
|
writestring(' MAC: ');
|
||||||
|
writeMACAddress(net.GetMAC);
|
||||||
|
writestring(' IPv4: ');
|
||||||
|
writeIPv4Address(@Config.Address[0]);
|
||||||
|
writestring(' Gateway: ');
|
||||||
|
writeIPv4Address(@Config.Gateway[0]);
|
||||||
|
writestring(' Netmask: ');
|
||||||
|
writeIPv4Address(@Config.Netmask[0]);
|
||||||
|
if Config.UP then
|
||||||
|
writestringln(' NetUP: true')
|
||||||
|
else
|
||||||
|
writestringln(' NetUP: false');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register;
|
procedure register;
|
||||||
@ -66,7 +92,14 @@ begin
|
|||||||
for i:=0 to 255 do begin
|
for i:=0 to 255 do begin
|
||||||
Protocols[i]:= nil;
|
Protocols[i]:= nil;
|
||||||
end;
|
end;
|
||||||
|
for i:=0 to 3 do begin
|
||||||
|
Config.Address[i]:= 0;
|
||||||
|
Config.Gateway[i]:= 0;
|
||||||
|
Config.Netmask[i]:= 0;
|
||||||
|
end;
|
||||||
|
Config.UP:= false;
|
||||||
eth2.registerType($0800, @recv);
|
eth2.registerType($0800, @recv);
|
||||||
|
terminal.registerCommand('IFCONFIG', @terminal_command_ifconfig, 'Configure Network Settings.');
|
||||||
Registered:= true;
|
Registered:= true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -11,7 +11,7 @@ unit drivermanagement;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
console, util, strings, lmemorymanager, terminal;
|
console, util, strings, lmemorymanager, terminal, tracer;
|
||||||
|
|
||||||
const
|
const
|
||||||
idANY = $FFFFFFFF;
|
idANY = $FFFFFFFF;
|
||||||
@ -88,6 +88,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
//push_trace('driver_management.terminal_command_drivers');
|
||||||
Drv:= Root;
|
Drv:= Root;
|
||||||
i:= 1;
|
i:= 1;
|
||||||
while Drv <> nil do begin
|
while Drv <> nil do begin
|
||||||
@ -119,6 +120,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
Drv:= Drv^.Next;
|
Drv:= Drv^.Next;
|
||||||
end;
|
end;
|
||||||
|
//pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure terminal_command_driversex(Params : PParamList);
|
procedure terminal_command_driversex(Params : PParamList);
|
||||||
@ -128,6 +130,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
//push_trace('driver_management.terminal_command_driversex');
|
||||||
Drv:= Root;
|
Drv:= Root;
|
||||||
i:= 1;
|
i:= 1;
|
||||||
while Drv <> nil do begin
|
while Drv <> nil do begin
|
||||||
@ -158,6 +161,7 @@ begin
|
|||||||
i:= i + 1;
|
i:= i + 1;
|
||||||
Drv:= Drv^.Next;
|
Drv:= Drv^.Next;
|
||||||
end;
|
end;
|
||||||
|
//pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure terminal_command_devices(Params : PParamList);
|
procedure terminal_command_devices(Params : PParamList);
|
||||||
@ -167,6 +171,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
//push_trace('driver_management.terminal_command_devices');
|
||||||
Dv:= Dev;
|
Dv:= Dev;
|
||||||
i:= 1;
|
i:= 1;
|
||||||
while Dv <> nil do begin
|
while Dv <> nil do begin
|
||||||
@ -204,6 +209,7 @@ begin
|
|||||||
i:= i + 1;
|
i:= i + 1;
|
||||||
Dv:= Dv^.Next;
|
Dv:= Dv^.Next;
|
||||||
end;
|
end;
|
||||||
|
//pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Main Functions }
|
{ Main Functions }
|
||||||
@ -291,6 +297,7 @@ var
|
|||||||
RegList : PDriverRegistration;
|
RegList : PDriverRegistration;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
//push_trace('driver_management.register_driver_ex');
|
||||||
if DeviceID = nil then exit;
|
if DeviceID = nil then exit;
|
||||||
NewReg:= PDriverRegistration(kalloc(sizeof(TDriverRegistration)));
|
NewReg:= PDriverRegistration(kalloc(sizeof(TDriverRegistration)));
|
||||||
NewReg^.Driver_Name:= stringCopy(Driver_Name);
|
NewReg^.Driver_Name:= stringCopy(Driver_Name);
|
||||||
@ -316,6 +323,7 @@ begin
|
|||||||
NewReg^.Loaded:= True;
|
NewReg^.Loaded:= True;
|
||||||
NewReg^.Driver_Load(nil);
|
NewReg^.Driver_Load(nil);
|
||||||
end;
|
end;
|
||||||
|
//pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
||||||
@ -325,6 +333,7 @@ var
|
|||||||
dev_list : PDeviceRegistration;
|
dev_list : PDeviceRegistration;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
//push_trace('driver_management.register_device');
|
||||||
drv:= Root;
|
drv:= Root;
|
||||||
new_dev:= PDeviceRegistration(kalloc(sizeof(TDeviceRegistration)));
|
new_dev:= PDeviceRegistration(kalloc(sizeof(TDeviceRegistration)));
|
||||||
new_dev^.Device_Name:= stringCopy(Device_Name);
|
new_dev^.Device_Name:= stringCopy(Device_Name);
|
||||||
@ -361,6 +370,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
drv:= drv^.Next;
|
drv:= drv^.Next;
|
||||||
end;
|
end;
|
||||||
|
//pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -14,7 +14,7 @@ unit util;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
bios_data_area;
|
bios_data_area, tracer;
|
||||||
|
|
||||||
procedure CLI();
|
procedure CLI();
|
||||||
procedure STI();
|
procedure STI();
|
||||||
@ -297,7 +297,8 @@ begin
|
|||||||
console.writestringln(fault);
|
console.writestringln(fault);
|
||||||
console.writestring(' Fault Info: ');
|
console.writestring(' Fault Info: ');
|
||||||
console.writestringln(info);
|
console.writestringln(info);
|
||||||
console.writestringln(' ');
|
console.writestring(' Faulting Module: ');
|
||||||
|
console.writestringln(tracer.get_last_trace);
|
||||||
console.writestringln(' ');
|
console.writestringln(' ');
|
||||||
halt_and_catch_fire();
|
halt_and_catch_fire();
|
||||||
end;
|
end;
|
||||||
|
@ -26,6 +26,7 @@ uses
|
|||||||
vmemorymanager,
|
vmemorymanager,
|
||||||
pmemorymanager,
|
pmemorymanager,
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
|
tracer,
|
||||||
drivermanagement,
|
drivermanagement,
|
||||||
tss,
|
tss,
|
||||||
scheduler,
|
scheduler,
|
||||||
@ -37,8 +38,8 @@ uses
|
|||||||
E1000,
|
E1000,
|
||||||
IDE,
|
IDE,
|
||||||
storagemanagement,
|
storagemanagement,
|
||||||
ipv4,
|
lists,
|
||||||
lists;
|
net;
|
||||||
|
|
||||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
|
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
|
||||||
|
|
||||||
@ -51,6 +52,8 @@ end;
|
|||||||
|
|
||||||
procedure terminal_command_meminfo(params : PParamList);
|
procedure terminal_command_meminfo(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('kernel.terminal_command_meminfo');
|
||||||
|
|
||||||
console.writestring('Lower Memory = ');
|
console.writestring('Lower Memory = ');
|
||||||
console.writeint(multibootinfo^.mem_lower);
|
console.writeint(multibootinfo^.mem_lower);
|
||||||
console.writestringln('KB');
|
console.writestringln('KB');
|
||||||
@ -60,16 +63,22 @@ begin
|
|||||||
console.writestring('Total Memory = ');
|
console.writestring('Total Memory = ');
|
||||||
console.writeint(((multibootinfo^.mem_upper + 1000) div 1024) + 1);
|
console.writeint(((multibootinfo^.mem_upper + 1000) div 1024) + 1);
|
||||||
console.writestringln('MB');
|
console.writestringln('MB');
|
||||||
|
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure terminal_command_bsod(params : PParamList);
|
procedure terminal_command_bsod(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('kernel.terminal_command_bsod');
|
||||||
|
|
||||||
if ParamCount(params) > 1 then begin
|
if ParamCount(params) > 1 then begin
|
||||||
bsod(getparam(0, params), getparam(1, params));
|
bsod(getparam(0, params), getparam(1, params));
|
||||||
end else begin
|
end else begin
|
||||||
console.writestringln('Invalid number of params.');
|
console.writestringln('Invalid number of params.');
|
||||||
console.writestringln('Usage: bsod <error> <info>');
|
console.writestringln('Usage: bsod <error> <info>');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
|
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
|
||||||
@ -134,6 +143,7 @@ begin
|
|||||||
scheduler.init();
|
scheduler.init();
|
||||||
|
|
||||||
{ Management Interfaces }
|
{ Management Interfaces }
|
||||||
|
tracer.init();
|
||||||
drivermanagement.init();
|
drivermanagement.init();
|
||||||
storagemanagement.init();
|
storagemanagement.init();
|
||||||
|
|
||||||
@ -157,7 +167,7 @@ begin
|
|||||||
console.outputln('KERNEL', 'BUS DRIVERS: INIT END.');
|
console.outputln('KERNEL', 'BUS DRIVERS: INIT END.');
|
||||||
|
|
||||||
{ Network Stack }
|
{ Network Stack }
|
||||||
ipv4.register();
|
net.init;
|
||||||
|
|
||||||
{ End of Boot }
|
{ End of Boot }
|
||||||
console.writestringln('');
|
console.writestringln('');
|
||||||
|
@ -16,7 +16,8 @@ uses
|
|||||||
keyboard,
|
keyboard,
|
||||||
util,
|
util,
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
strings;
|
strings,
|
||||||
|
tracer;
|
||||||
|
|
||||||
type
|
type
|
||||||
PParamList = ^TParamList;
|
PParamList = ^TParamList;
|
||||||
|
@ -14,7 +14,8 @@ interface
|
|||||||
uses
|
uses
|
||||||
util,
|
util,
|
||||||
pmemorymanager,
|
pmemorymanager,
|
||||||
console;
|
console,
|
||||||
|
tracer;
|
||||||
|
|
||||||
type
|
type
|
||||||
PPageDirEntry = ^TPageDirEntry;
|
PPageDirEntry = ^TPageDirEntry;
|
||||||
@ -84,6 +85,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
Directory:= Directory + KERNEL_VIRTUAL_BASE;
|
Directory:= Directory + KERNEL_VIRTUAL_BASE;
|
||||||
load_current_page_directory:= PPageDirectory(Directory);
|
load_current_page_directory:= PPageDirectory(Directory);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user