git-svn-id: https://spexeah.com:8443/svn/Asuro@423 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,51 @@
|
||||
unit eth2;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
net, nettypes, console;
|
||||
|
||||
procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
Registered : Boolean = false;
|
||||
EthTypes : Array[0..65535] of TRecvCallback;
|
||||
MAC : puint8;
|
||||
|
||||
procedure registerType(eType : uint16; RecvCB : TRecvCallback);
|
||||
begin
|
||||
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
||||
end;
|
||||
|
||||
procedure recv(p_data : void; p_len : uint16);
|
||||
var
|
||||
src, dst : puint8;
|
||||
proto_type : uint16;
|
||||
|
||||
begin
|
||||
dst:= puint8(p_data);
|
||||
src:= puint8(p_data + 6);
|
||||
console.output('net.eth2', 'DEST: ');
|
||||
writeMACAddress(dst);
|
||||
console.output('net.eth2', 'SRC: ');
|
||||
writeMACAddress(src);
|
||||
end;
|
||||
|
||||
procedure register;
|
||||
var
|
||||
i : uint16;
|
||||
|
||||
begin
|
||||
if not Registered then begin
|
||||
for i:=0 to 65535 do begin
|
||||
EthTypes[i]:= nil;
|
||||
end;
|
||||
net.registerNextLayer(@recv);
|
||||
MAC:= net.getMAC;
|
||||
Registered:= true;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -2,6 +2,50 @@ unit net;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
nettypes;
|
||||
|
||||
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
|
||||
procedure registerNextLayer(RecvCallback : TRecvCallback);
|
||||
procedure send(p_data : void; p_len : uint16);
|
||||
procedure recv(p_data : void; p_len : uint16);
|
||||
function getMAC : puint8;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
CBSend : TNetSendCallback = nil;
|
||||
CBNext : TRecvCallback = nil;
|
||||
MAC : puint8 = nil;
|
||||
|
||||
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
|
||||
begin
|
||||
if CBSend = nil then begin
|
||||
CBSend:= SendCallback;
|
||||
MAC:= _MAC;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure registerNextLayer(RecvCallback : TRecvCallback);
|
||||
begin
|
||||
if CBNext = nil then begin
|
||||
CBNext:= RecvCallback;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure send(p_data : void; p_len : uint16);
|
||||
begin
|
||||
CBSend(p_data, p_len);
|
||||
end;
|
||||
|
||||
procedure recv(p_data : void; p_len : uint16);
|
||||
begin
|
||||
CBNext(p_data, p_len);
|
||||
end;
|
||||
|
||||
function getMAC : puint8;
|
||||
begin
|
||||
getMAC:= MAC;
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
|
||||
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.
|
||||
+10
-17
@@ -12,7 +12,9 @@ uses
|
||||
util,
|
||||
IDT,
|
||||
PCI,
|
||||
terminal;
|
||||
terminal,
|
||||
net,
|
||||
nettypes;
|
||||
|
||||
const
|
||||
INTEL_VEND = $8086;
|
||||
@@ -355,6 +357,8 @@ begin
|
||||
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;
|
||||
old_cur:= rx_curr;
|
||||
@@ -374,19 +378,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure writeMACAddress();
|
||||
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;
|
||||
|
||||
procedure fire(); interrupt;
|
||||
var
|
||||
status : uint32;
|
||||
@@ -419,7 +410,7 @@ end;
|
||||
|
||||
procedure console_command_mac(params : PParamList);
|
||||
begin
|
||||
writeMACAddress();
|
||||
writeMACAddress(@mac[0]);
|
||||
end;
|
||||
|
||||
procedure console_command_sendtest(params : PParamList);
|
||||
@@ -490,7 +481,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
console.output('E1000 Driver', 'MAC Address: ');
|
||||
writeMACAddress();
|
||||
writeMACAddress(@mac[0]);
|
||||
|
||||
startLink();
|
||||
|
||||
@@ -498,9 +489,11 @@ begin
|
||||
writeCommand($5200 + i*4, 0);
|
||||
end;
|
||||
|
||||
IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
|
||||
net.registerNetworkCard(@sendPacket, getMACAddress());
|
||||
|
||||
IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
|
||||
enableInturrupt();
|
||||
|
||||
rxinit();
|
||||
txinit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user