git-svn-id: https://spexeah.com:8443/svn/Asuro@484 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
3bed07c80a
commit
c8b3b14893
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/eth2.ppu
BIN
lib/eth2.ppu
Binary file not shown.
BIN
lib/ipv4.ppu
BIN
lib/ipv4.ppu
Binary file not shown.
BIN
lib/kernel.ppu
BIN
lib/kernel.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/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.
BIN
lib/util.ppu
BIN
lib/util.ppu
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ unit netutils;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
util, nettypes, console, lmemorymanager;
|
tracer, util, nettypes, console, lmemorymanager;
|
||||||
|
|
||||||
procedure copyMAC(src : puint8; dst : puint8);
|
procedure copyMAC(src : puint8; dst : puint8);
|
||||||
procedure copyIPv4(src : puint8; dst : puint8);
|
procedure copyIPv4(src : puint8; dst : puint8);
|
||||||
@ -21,13 +21,15 @@ var
|
|||||||
i : uint8;
|
i : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.IPEqual');
|
||||||
IPEqual:= true;
|
IPEqual:= true;
|
||||||
for i:=0 to 3 do begin
|
for i:=0 to 3 do begin
|
||||||
if ip1[i] <> ip2[i] then begin
|
if ip1[i] <> ip2[i] then begin
|
||||||
IPEqual:= false;
|
IPEqual:= false;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
||||||
@ -35,13 +37,15 @@ var
|
|||||||
i : uint8;
|
i : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.MACEqual');
|
||||||
MACEqual:= true;
|
MACEqual:= true;
|
||||||
for i:=0 to 5 do begin
|
for i:=0 to 5 do begin
|
||||||
if mac1[i] <> mac2[i] then begin
|
if mac1[i] <> mac2[i] then begin
|
||||||
MACEqual:= false;
|
MACEqual:= false;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure writeIPv4Address(ip : puint8);
|
procedure writeIPv4Address(ip : puint8);
|
||||||
@ -49,12 +53,14 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.writeIPv4Address');
|
||||||
console.writeint(ip[0]);
|
console.writeint(ip[0]);
|
||||||
for i:=1 to 3 do begin
|
for i:=1 to 3 do begin
|
||||||
console.writestring('.');
|
console.writestring('.');
|
||||||
console.writeint(ip[i]);
|
console.writeint(ip[i]);
|
||||||
end;
|
end;
|
||||||
console.writestringln(' ');
|
console.writestringln(' ');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure writeMACAddress(mac : puint8);
|
procedure writeMACAddress(mac : puint8);
|
||||||
@ -62,23 +68,29 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.writeMACAddress');
|
||||||
console.writehexpair(mac[0]);
|
console.writehexpair(mac[0]);
|
||||||
for i:=1 to 5 do begin
|
for i:=1 to 5 do begin
|
||||||
console.writestring(':');
|
console.writestring(':');
|
||||||
console.writehexpair(mac[i]);
|
console.writehexpair(mac[i]);
|
||||||
end;
|
end;
|
||||||
console.writestringln(' ');
|
console.writestringln(' ');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function newPacketContext : PPacketContext;
|
function newPacketContext : PPacketContext;
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.newPacketContext');
|
||||||
newPacketContext:= PPacketContext(kalloc(sizeof(TPacketContext)));
|
newPacketContext:= PPacketContext(kalloc(sizeof(TPacketContext)));
|
||||||
memset(uint32(newPacketContext), 0, sizeof(TPacketContext));
|
memset(uint32(newPacketContext), 0, sizeof(TPacketContext));
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure freePacketContext(p_context : PPacketContext);
|
procedure freePacketContext(p_context : PPacketContext);
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.freePacketContext');
|
||||||
kfree(void(p_context));
|
kfree(void(p_context));
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure copyMAC(src : puint8; dst : puint8);
|
procedure copyMAC(src : puint8; dst : puint8);
|
||||||
@ -86,9 +98,11 @@ var
|
|||||||
i : uint8;
|
i : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.copyMAC');
|
||||||
for i:=0 to 5 do begin
|
for i:=0 to 5 do begin
|
||||||
dst[i]:= src[i];
|
dst[i]:= src[i];
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure copyIPv4(src : puint8; dst : puint8);
|
procedure copyIPv4(src : puint8; dst : puint8);
|
||||||
@ -96,9 +110,11 @@ var
|
|||||||
i : uint8;
|
i : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('netutils.copyIPv4');
|
||||||
for i:=0 to 3 do begin
|
for i:=0 to 3 do begin
|
||||||
dst[i]:= src[i];
|
dst[i]:= src[i];
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -3,6 +3,7 @@ unit net;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
tracer,
|
||||||
console,
|
console,
|
||||||
nettypes, netutils;
|
nettypes, netutils;
|
||||||
|
|
||||||
@ -25,22 +26,28 @@ var
|
|||||||
|
|
||||||
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
|
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
|
||||||
begin
|
begin
|
||||||
|
push_trace('net.registerNetworkCard');
|
||||||
if CBSend = nil then begin
|
if CBSend = nil then begin
|
||||||
CBSend:= SendCallback;
|
CBSend:= SendCallback;
|
||||||
MAC:= _MAC;
|
MAC:= _MAC;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure registerNextLayer(RecvCallback : TRecvCallback);
|
procedure registerNextLayer(RecvCallback : TRecvCallback);
|
||||||
begin
|
begin
|
||||||
|
push_trace('net.registerNextLayer');
|
||||||
if CBNext = nil then begin
|
if CBNext = nil then begin
|
||||||
CBNext:= RecvCallback;
|
CBNext:= RecvCallback;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure send(p_data : void; p_len : uint16);
|
procedure send(p_data : void; p_len : uint16);
|
||||||
begin
|
begin
|
||||||
|
push_trace('net.send');
|
||||||
if CBSend <> nil then CBSend(p_data, p_len);
|
if CBSend <> nil then CBSend(p_data, p_len);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure recv(p_data : void; p_len : uint16);
|
procedure recv(p_data : void; p_len : uint16);
|
||||||
@ -48,22 +55,28 @@ var
|
|||||||
context : PPacketContext;
|
context : PPacketContext;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('net.recv');
|
||||||
//console.outputln('net', 'RECV.');
|
//console.outputln('net', 'RECV.');
|
||||||
context:= newPacketContext;
|
context:= newPacketContext;
|
||||||
if CBNext <> nil then CBNext(p_data, p_len, context);
|
if CBNext <> nil then CBNext(p_data, p_len, context);
|
||||||
freePacketContext(context);
|
freePacketContext(context);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getMAC : puint8;
|
function getMAC : puint8;
|
||||||
begin
|
begin
|
||||||
|
push_trace('net.getMAC');
|
||||||
getMAC:= MAC;
|
getMAC:= MAC;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
begin
|
begin
|
||||||
|
push_trace('net.init');
|
||||||
eth2.register;
|
eth2.register;
|
||||||
arp.register;
|
arp.register;
|
||||||
ipv4.register;
|
ipv4.register;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -3,6 +3,7 @@ unit eth2;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
tracer,
|
||||||
nettypes, netutils,
|
nettypes, netutils,
|
||||||
net,
|
net,
|
||||||
console;
|
console;
|
||||||
@ -19,8 +20,10 @@ var
|
|||||||
|
|
||||||
procedure registerType(eType : uint16; RecvCB : TRecvCallback);
|
procedure registerType(eType : uint16; RecvCB : TRecvCallback);
|
||||||
begin
|
begin
|
||||||
|
push_trace('eth2.registerType');
|
||||||
register;
|
register;
|
||||||
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||||
@ -30,6 +33,7 @@ var
|
|||||||
buf : puint8;
|
buf : puint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('eth2.recv');
|
||||||
//console.outputln('net.eth2', 'RECV.');
|
//console.outputln('net.eth2', 'RECV.');
|
||||||
buf:= puint8(p_data);
|
buf:= puint8(p_data);
|
||||||
|
|
||||||
@ -56,6 +60,7 @@ begin
|
|||||||
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register;
|
procedure register;
|
||||||
@ -63,6 +68,7 @@ var
|
|||||||
i : uint16;
|
i : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('eth2.register');
|
||||||
if not Registered then begin
|
if not Registered then begin
|
||||||
for i:=0 to 65535 do begin
|
for i:=0 to 65535 do begin
|
||||||
EthTypes[i]:= nil;
|
EthTypes[i]:= nil;
|
||||||
@ -71,6 +77,7 @@ begin
|
|||||||
MAC:= net.getMAC;
|
MAC:= net.getMAC;
|
||||||
Registered:= true;
|
Registered:= true;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -3,6 +3,7 @@ unit arp;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
tracer,
|
||||||
util, lists, console,
|
util, lists, console,
|
||||||
nettypes, netutils,
|
nettypes, netutils,
|
||||||
eth2;
|
eth2;
|
||||||
@ -30,14 +31,16 @@ var
|
|||||||
r : PARPCacheRecord;
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('arp.findCacheRecordByMAC');
|
||||||
findCacheRecordByMAC:= nil;
|
findCacheRecordByMAC:= nil;
|
||||||
for i:=0 to LL_Size(Cache)-1 do begin
|
for i:=0 to LL_Size(Cache)-1 do begin
|
||||||
r:= PARPCacheRecord(LL_Get(Cache, i));
|
r:= PARPCacheRecord(LL_Get(Cache, i));
|
||||||
if MACEqual(mac, @r^.MAC[0]) then begin
|
if MACEqual(mac, @r^.MAC[0]) then begin
|
||||||
findCacheRecordByMAC:= r;
|
findCacheRecordByMAC:= r;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function findCacheRecordByIP(ip : puint8) : PARPCacheRecord;
|
function findCacheRecordByIP(ip : puint8) : PARPCacheRecord;
|
||||||
@ -46,14 +49,16 @@ var
|
|||||||
r : PARPCacheRecord;
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('arp.findCacheRecordByIP');
|
||||||
findCacheRecordByIP:= nil;
|
findCacheRecordByIP:= nil;
|
||||||
for i:=0 to LL_Size(Cache)-1 do begin
|
for i:=0 to LL_Size(Cache)-1 do begin
|
||||||
r:= PARPCacheRecord(LL_Get(Cache, i));
|
r:= PARPCacheRecord(LL_Get(Cache, i));
|
||||||
if IPEqual(ip, @r^.IP[0]) then begin
|
if IPEqual(ip, @r^.IP[0]) then begin
|
||||||
findCacheRecordByIP:= r;
|
findCacheRecordByIP:= r;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||||
@ -63,6 +68,7 @@ var
|
|||||||
CacheElement : PARPCacheRecord;
|
CacheElement : PARPCacheRecord;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('arp.recv');
|
||||||
{ Get our converted Header }
|
{ Get our converted Header }
|
||||||
Header:= PARPHeader(p_data);
|
Header:= PARPHeader(p_data);
|
||||||
AHeader.Hardware_Type:= (Header^.Hardware_Type_Hi SHL 8) + Header^.Hardware_Type_Lo;
|
AHeader.Hardware_Type:= (Header^.Hardware_Type_Hi SHL 8) + Header^.Hardware_Type_Lo;
|
||||||
@ -104,15 +110,18 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register;
|
procedure register;
|
||||||
begin
|
begin
|
||||||
|
push_trace('arp.register');
|
||||||
if not Registered then begin
|
if not Registered then begin
|
||||||
Cache:= LL_New(sizeof(TARPCacheRecord));
|
Cache:= LL_New(sizeof(TARPCacheRecord));
|
||||||
eth2.registerType($0806, @recv);
|
eth2.registerType($0806, @recv);
|
||||||
Registered:= true;
|
Registered:= true;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IPv4ToMAC(ip : puint8) : puint8;
|
function IPv4ToMAC(ip : puint8) : puint8;
|
||||||
@ -120,12 +129,14 @@ var
|
|||||||
r : PARPCacheRecord;
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('arp.IPv4ToMAC');
|
||||||
register;
|
register;
|
||||||
IPv4ToMAC:= nil;
|
IPv4ToMAC:= nil;
|
||||||
r:= findCacheRecordByIP(ip);
|
r:= findCacheRecordByIP(ip);
|
||||||
if r <> nil then begin
|
if r <> nil then begin
|
||||||
IPv4ToMAC:= @r^.MAC[0];
|
IPv4ToMAC:= @r^.MAC[0];
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function MACToIIPv4(mac : puint8) : puint8;
|
function MACToIIPv4(mac : puint8) : puint8;
|
||||||
@ -133,12 +144,14 @@ var
|
|||||||
r : PARPCacheRecord;
|
r : PARPCacheRecord;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('arp.MACToIPv4');
|
||||||
register;
|
register;
|
||||||
MACToIIPv4:= nil;
|
MACToIIPv4:= nil;
|
||||||
r:= findCacheRecordByMAC(mac);
|
r:= findCacheRecordByMAC(mac);
|
||||||
if r <> nil then begin
|
if r <> nil then begin
|
||||||
MACToIIPv4:= @r^.IP[0];
|
MACToIIPv4:= @r^.IP[0];
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -3,6 +3,7 @@ unit ipv4;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
tracer,
|
||||||
util, console, terminal,
|
util, console, terminal,
|
||||||
net, nettypes, netutils,
|
net, nettypes, netutils,
|
||||||
eth2;
|
eth2;
|
||||||
@ -26,6 +27,7 @@ var
|
|||||||
len : uint16;
|
len : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('ipv4.recv');
|
||||||
//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;
|
||||||
@ -61,12 +63,13 @@ begin
|
|||||||
if (IPEqual(@Config.Address[0], @AHeader.Dst[0])) OR (AHeader.Dst[3] = 255) then begin
|
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);
|
if Protocols[AHeader.Protocol] <> nil then Protocols[AHeader.Protocol](void(buf), len, p_context);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure terminal_command_ifconfig(params : PParamList);
|
procedure terminal_command_ifconfig(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('ipv4.terminal_command_ifconfig');
|
||||||
if paramCount(params) > 2 then begin
|
if paramCount(params) > 2 then begin
|
||||||
|
|
||||||
end else begin
|
end else begin
|
||||||
writestring(' MAC: ');
|
writestring(' MAC: ');
|
||||||
writeMACAddress(net.GetMAC);
|
writeMACAddress(net.GetMAC);
|
||||||
@ -81,6 +84,7 @@ begin
|
|||||||
else
|
else
|
||||||
writestringln(' NetUP: false');
|
writestringln(' NetUP: false');
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register;
|
procedure register;
|
||||||
@ -88,6 +92,7 @@ var
|
|||||||
i : uint8;
|
i : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('ipv4.register');
|
||||||
if not Registered then begin
|
if not Registered then begin
|
||||||
for i:=0 to 255 do begin
|
for i:=0 to 255 do begin
|
||||||
Protocols[i]:= nil;
|
Protocols[i]:= nil;
|
||||||
@ -102,12 +107,15 @@ begin
|
|||||||
terminal.registerCommand('IFCONFIG', @terminal_command_ifconfig, 'Configure Network Settings.');
|
terminal.registerCommand('IFCONFIG', @terminal_command_ifconfig, 'Configure Network Settings.');
|
||||||
Registered:= true;
|
Registered:= true;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
||||||
begin
|
begin
|
||||||
|
push_trace('ipv4.registerProtocol');
|
||||||
register;
|
register;
|
||||||
if Protocols[Protocol_ID] = nil then Protocols[Protocol_ID]:= recv_callback;
|
if Protocols[Protocol_ID] = nil then Protocols[Protocol_ID]:= recv_callback;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -3,6 +3,7 @@ unit E1000;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
tracer,
|
||||||
console,
|
console,
|
||||||
strings,
|
strings,
|
||||||
vmemorymanager,
|
vmemorymanager,
|
||||||
@ -157,6 +158,7 @@ var
|
|||||||
mem : puint32;
|
mem : puint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.writeCommand');
|
||||||
if (bar_type = 0) then begin
|
if (bar_type = 0) then begin
|
||||||
mem:= puint32(mem_base + p_address);
|
mem:= puint32(mem_base + p_address);
|
||||||
mem^:= p_value;
|
mem^:= p_value;
|
||||||
@ -164,6 +166,7 @@ begin
|
|||||||
outl(io_base + 0, p_address);
|
outl(io_base + 0, p_address);
|
||||||
outl(io_base + 4, p_address)
|
outl(io_base + 4, p_address)
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function readCommand(p_address : uint16) : uint32;
|
function readCommand(p_address : uint16) : uint32;
|
||||||
@ -171,13 +174,15 @@ var
|
|||||||
mem : puint32;
|
mem : puint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.readCommand');
|
||||||
if (bar_type = 0) then begin
|
if (bar_type = 0) then begin
|
||||||
mem:= puint32(mem_base + p_address);
|
mem:= puint32(mem_base + p_address);
|
||||||
readCommand:= mem^;
|
readCommand:= mem^;
|
||||||
end else begin
|
end else begin
|
||||||
outl(io_base, p_address);
|
outl(io_base, p_address);
|
||||||
readCommand:= inl(io_base + 4);
|
readCommand:= inl(io_base + 4);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function detectEEPROM() : boolean;
|
function detectEEPROM() : boolean;
|
||||||
@ -185,6 +190,7 @@ var
|
|||||||
val, i : uint32;
|
val, i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.detectEEPROM');
|
||||||
val:= 0;
|
val:= 0;
|
||||||
writeCommand(REG_EEPROM, $1);
|
writeCommand(REG_EEPROM, $1);
|
||||||
for i:=0 to 1000 do begin
|
for i:=0 to 1000 do begin
|
||||||
@ -193,6 +199,7 @@ begin
|
|||||||
if (val and $10) > 0 then eeprom_exists:= true else eeprom_exists:= false;
|
if (val and $10) > 0 then eeprom_exists:= true else eeprom_exists:= false;
|
||||||
end;
|
end;
|
||||||
detectEEPROM:= eeprom_exists;
|
detectEEPROM:= eeprom_exists;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function EEPROMRead( address : uint8 ) : uint32;
|
function EEPROMRead( address : uint8 ) : uint32;
|
||||||
@ -201,6 +208,7 @@ var
|
|||||||
tmp : uint32;
|
tmp : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.EEPROMRead');
|
||||||
tmp:= 0;
|
tmp:= 0;
|
||||||
if (eeprom_exists) then begin
|
if (eeprom_exists) then begin
|
||||||
writeCommand( REG_EEPROM, 1 OR (uint32(address) SHL 8) );
|
writeCommand( REG_EEPROM, 1 OR (uint32(address) SHL 8) );
|
||||||
@ -215,6 +223,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
data:= uint16( (tmp SHR 16) AND ($FFFF) );
|
data:= uint16( (tmp SHR 16) AND ($FFFF) );
|
||||||
EEPROMRead:= data;
|
EEPROMRead:= data;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function readMACAddress() : boolean;
|
function readMACAddress() : boolean;
|
||||||
@ -226,6 +235,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.readMACAddress');
|
||||||
res:= true;
|
res:= true;
|
||||||
if (eeprom_exists) then begin
|
if (eeprom_exists) then begin
|
||||||
temp:= EEPROMRead(0);
|
temp:= EEPROMRead(0);
|
||||||
@ -249,6 +259,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
readMACAddress:= res;
|
readMACAddress:= res;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure startLink();
|
procedure startLink();
|
||||||
@ -256,8 +267,10 @@ var
|
|||||||
val : uint32;
|
val : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.startLink');
|
||||||
val:= readCommand(REG_CTRL);
|
val:= readCommand(REG_CTRL);
|
||||||
writeCommand(REG_CTRL, val OR ECTRL_SLU);
|
writeCommand(REG_CTRL, val OR ECTRL_SLU);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure rxinit();
|
procedure rxinit();
|
||||||
@ -268,6 +281,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.rxinit');
|
||||||
ptr:= puint8(kalloc(sizeof(TE1000_rx_desc) * E1000_NUM_RX_DESC + 16));
|
ptr:= puint8(kalloc(sizeof(TE1000_rx_desc) * E1000_NUM_RX_DESC + 16));
|
||||||
descs:= PE1000_rx_desc(ptr);
|
descs:= PE1000_rx_desc(ptr);
|
||||||
for i:=0 to E1000_NUM_RX_DESC do begin
|
for i:=0 to E1000_NUM_RX_DESC do begin
|
||||||
@ -297,6 +311,7 @@ begin
|
|||||||
rx_curr:= 0;
|
rx_curr:= 0;
|
||||||
|
|
||||||
writeCommand(REG_RCTRL, RCTL_EN OR RCTL_SBP OR RCTL_UPE OR RCTL_MPE OR RCTL_LBM_NONE OR RTCL_RDMTS_HALF OR RCTL_BAM OR RCTL_SECRC OR RCTL_BSIZE_2048);
|
writeCommand(REG_RCTRL, RCTL_EN OR RCTL_SBP OR RCTL_UPE OR RCTL_MPE OR RCTL_LBM_NONE OR RTCL_RDMTS_HALF OR RCTL_BAM OR RCTL_SECRC OR RCTL_BSIZE_2048);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure txinit();
|
procedure txinit();
|
||||||
@ -307,6 +322,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.txinit');
|
||||||
ptr:= puint8(kalloc(sizeof(TE1000_tx_desc) * (E1000_NUM_TX_DESC + 16)));
|
ptr:= puint8(kalloc(sizeof(TE1000_tx_desc) * (E1000_NUM_TX_DESC + 16)));
|
||||||
descs:= PE1000_tx_desc(ptr);
|
descs:= PE1000_tx_desc(ptr);
|
||||||
for i:=0 to E1000_NUM_TX_DESC do begin
|
for i:=0 to E1000_NUM_TX_DESC do begin
|
||||||
@ -338,13 +354,16 @@ begin
|
|||||||
writeCommand(REG_TCTRL, $3003F0FA);
|
writeCommand(REG_TCTRL, $3003F0FA);
|
||||||
writeCommand(REG_TIPG, $0060200A);
|
writeCommand(REG_TIPG, $0060200A);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure enableInturrupt();
|
procedure enableInturrupt();
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.enableInterrupt');
|
||||||
writeCommand(REG_IMASK, $1F6DC);
|
writeCommand(REG_IMASK, $1F6DC);
|
||||||
writeCommand(REG_IMASK, $FF AND NOT(4));
|
writeCommand(REG_IMASK, $FF AND NOT(4));
|
||||||
readCommand($C0);
|
readCommand($C0);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure handleReceive();
|
procedure handleReceive();
|
||||||
@ -356,6 +375,7 @@ var
|
|||||||
i : uint16;
|
i : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.handleReceive');
|
||||||
while (rx_descs[rx_curr]^.status AND $1) > 0 do begin
|
while (rx_descs[rx_curr]^.status AND $1) > 0 do begin
|
||||||
got_packet:= true;
|
got_packet:= true;
|
||||||
buf:= rx_buffs[rx_curr];
|
buf:= rx_buffs[rx_curr];
|
||||||
@ -369,6 +389,7 @@ begin
|
|||||||
rx_curr:= (rx_curr + 1) mod E1000_NUM_RX_DESC;
|
rx_curr:= (rx_curr + 1) mod E1000_NUM_RX_DESC;
|
||||||
writeCommand(REG_RXDESCTAIL, old_cur);
|
writeCommand(REG_RXDESCTAIL, old_cur);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure writeCardType();
|
procedure writeCardType();
|
||||||
@ -388,6 +409,7 @@ var
|
|||||||
data : uint32;
|
data : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.fire');
|
||||||
//console.outputln('E1000 Driver', 'FIRED.');
|
//console.outputln('E1000 Driver', 'FIRED.');
|
||||||
|
|
||||||
status:= readCommand($C0);
|
status:= readCommand($C0);
|
||||||
@ -412,11 +434,14 @@ begin
|
|||||||
|
|
||||||
//CLI (Not 100% Nessisary as this is done on IRET)
|
//CLI (Not 100% Nessisary as this is done on IRET)
|
||||||
CLI;
|
CLI;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure console_command_mac(params : PParamList);
|
procedure console_command_mac(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.console_command_mac');
|
||||||
writeMACAddress(@mac[0]);
|
writeMACAddress(@mac[0]);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure console_command_sendtest(params : PParamList);
|
procedure console_command_sendtest(params : PParamList);
|
||||||
@ -436,6 +461,7 @@ var
|
|||||||
);
|
);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.console_command_sendtest');
|
||||||
TestPacket[6]:= mac[0];
|
TestPacket[6]:= mac[0];
|
||||||
TestPacket[7]:= mac[1];
|
TestPacket[7]:= mac[1];
|
||||||
TestPacket[8]:= mac[2];
|
TestPacket[8]:= mac[2];
|
||||||
@ -450,6 +476,7 @@ begin
|
|||||||
TestPacket[26]:= mac[4];
|
TestPacket[26]:= mac[4];
|
||||||
TestPacket[27]:= mac[5];
|
TestPacket[27]:= mac[5];
|
||||||
sendPacket(void(@TestPacket[0]), 42);
|
sendPacket(void(@TestPacket[0]), 42);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function load(ptr : void) : boolean;
|
function load(ptr : void) : boolean;
|
||||||
@ -460,6 +487,8 @@ var
|
|||||||
iline : uint8;
|
iline : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.load');
|
||||||
|
|
||||||
console.outputln('E1000 Driver', 'Load Start.');
|
console.outputln('E1000 Driver', 'Load Start.');
|
||||||
|
|
||||||
writeCardType();
|
writeCardType();
|
||||||
@ -484,58 +513,66 @@ begin
|
|||||||
if not readMACAddress() then begin
|
if not readMACAddress() then begin
|
||||||
console.outputln('E1000 Driver', 'MAC Read Failed.');
|
console.outputln('E1000 Driver', 'MAC Read Failed.');
|
||||||
load:= false;
|
load:= false;
|
||||||
exit;
|
end else begin
|
||||||
|
console.output('E1000 Driver', 'MAC Address: ');
|
||||||
|
writeMACAddress(@mac[0]);
|
||||||
|
|
||||||
|
startLink();
|
||||||
|
|
||||||
|
for i:=0 to $80 do begin
|
||||||
|
writeCommand($5200 + i*4, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
net.registerNetworkCard(@sendPacket, getMACAddress());
|
||||||
|
|
||||||
|
IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
|
||||||
|
enableInturrupt();
|
||||||
|
|
||||||
|
rxinit();
|
||||||
|
txinit();
|
||||||
|
|
||||||
|
load:= true;
|
||||||
|
|
||||||
|
if load then registercommand('E1000', @console_command_sendtest, 'Test sending a ARP Request.');
|
||||||
|
if load then registercommand('MAC', @console_command_mac, 'Print MAC Address.');
|
||||||
end;
|
end;
|
||||||
console.output('E1000 Driver', 'MAC Address: ');
|
|
||||||
writeMACAddress(@mac[0]);
|
|
||||||
|
|
||||||
startLink();
|
|
||||||
|
|
||||||
for i:=0 to $80 do begin
|
|
||||||
writeCommand($5200 + i*4, 0);
|
|
||||||
end;
|
|
||||||
|
|
||||||
net.registerNetworkCard(@sendPacket, getMACAddress());
|
|
||||||
|
|
||||||
IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
|
|
||||||
enableInturrupt();
|
|
||||||
|
|
||||||
rxinit();
|
|
||||||
txinit();
|
|
||||||
|
|
||||||
load:= true;
|
|
||||||
|
|
||||||
if load then registercommand('E1000', @console_command_sendtest, 'Test sending a ARP Request.');
|
|
||||||
if load then registercommand('MAC', @console_command_mac, 'Print MAC Address.');
|
|
||||||
|
|
||||||
console.outputln('E1000 Driver', 'Load Finish.');
|
console.outputln('E1000 Driver', 'Load Finish.');
|
||||||
|
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function loadE1000(ptr : void) : boolean;
|
function loadE1000(ptr : void) : boolean;
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.loadE1000');
|
||||||
loadE1000:= false;
|
loadE1000:= false;
|
||||||
if not Loaded then begin
|
if not Loaded then begin
|
||||||
card_type:= ctE1000;
|
card_type:= ctE1000;
|
||||||
loadE1000:= load(ptr);
|
loadE1000:= load(ptr);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function load82577LM(ptr : void) : boolean;
|
function load82577LM(ptr : void) : boolean;
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.load82577LM');
|
||||||
load82577LM:= false;
|
load82577LM:= false;
|
||||||
if not Loaded then begin
|
if not Loaded then begin
|
||||||
card_type:= ct82577LM;
|
card_type:= ct82577LM;
|
||||||
load82577LM:= load(ptr);
|
load82577LM:= load(ptr);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function loadI217(ptr : void) : boolean;
|
function loadI217(ptr : void) : boolean;
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.loadI217');
|
||||||
loadI217:= false;
|
loadI217:= false;
|
||||||
if not Loaded then begin
|
if not Loaded then begin
|
||||||
card_type:= ctI217;
|
card_type:= ctI217;
|
||||||
loadI217:= load(ptr);
|
loadI217:= load(ptr);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
@ -543,6 +580,7 @@ var
|
|||||||
dev : TDeviceIdentifier;
|
dev : TDeviceIdentifier;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.init');
|
||||||
card_type:= ctUnknown;
|
card_type:= ctUnknown;
|
||||||
dev.Bus:= biPCI;
|
dev.Bus:= biPCI;
|
||||||
dev.id0:= INTEL_VEND;
|
dev.id0:= INTEL_VEND;
|
||||||
@ -556,6 +594,7 @@ begin
|
|||||||
drivermanagement.register_driver('I217 Ethernet Driver', @dev, @loadI217);
|
drivermanagement.register_driver('I217 Ethernet Driver', @dev, @loadI217);
|
||||||
dev.id4:= LM82577_DEV;
|
dev.id4:= LM82577_DEV;
|
||||||
drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load82577LM);
|
drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load82577LM);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getMACAddress : puint8;
|
function getMACAddress : puint8;
|
||||||
@ -568,6 +607,7 @@ var
|
|||||||
old_cur : uint8;
|
old_cur : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('E1000.sendPacket');
|
||||||
tx_descs[tx_curr]^.address:= uint32(vtop(uint32(p_data)));
|
tx_descs[tx_curr]^.address:= uint32(vtop(uint32(p_data)));
|
||||||
tx_descs[tx_curr]^.length:= p_len;
|
tx_descs[tx_curr]^.length:= p_len;
|
||||||
tx_descs[tx_curr]^.cmd:= CMD_EOP OR CMD_IFCS OR CMD_RS OR CMD_RPS;
|
tx_descs[tx_curr]^.cmd:= CMD_EOP OR CMD_IFCS OR CMD_RS OR CMD_RPS;
|
||||||
@ -578,6 +618,7 @@ begin
|
|||||||
while (tx_descs[old_cur]^.status AND $FF) = 0 do begin
|
while (tx_descs[old_cur]^.status AND $FF) = 0 do begin
|
||||||
end;
|
end;
|
||||||
sendPacket:= 0;
|
sendPacket:= 0;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -31,7 +31,7 @@ type
|
|||||||
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32);
|
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32);
|
||||||
PPDetectHook = procedure(disk : PStorage_Device);
|
PPDetectHook = procedure(disk : PStorage_Device);
|
||||||
|
|
||||||
PPHIOHook = procedure(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
|
PPHIOHook_ = procedure(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
|
||||||
|
|
||||||
TFilesystem = record
|
TFilesystem = record
|
||||||
sName : pchar;
|
sName : pchar;
|
||||||
@ -58,7 +58,7 @@ type
|
|||||||
maxSectorCount : uint32;
|
maxSectorCount : uint32;
|
||||||
sectorSize : uint32;
|
sectorSize : uint32;
|
||||||
writable : boolean;
|
writable : boolean;
|
||||||
volumes : array[0..7] of TStorage_Volume
|
volumes : array[0..7] of TStorage_Volume;
|
||||||
writeCallback : PPHIOHook;
|
writeCallback : PPHIOHook;
|
||||||
readCallback : PPHIOHook;
|
readCallback : PPHIOHook;
|
||||||
end;
|
end;
|
||||||
|
@ -88,7 +88,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//push_trace('driver_management.terminal_command_drivers');
|
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
|
||||||
@ -120,7 +120,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
Drv:= Drv^.Next;
|
Drv:= Drv^.Next;
|
||||||
end;
|
end;
|
||||||
//pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure terminal_command_driversex(Params : PParamList);
|
procedure terminal_command_driversex(Params : PParamList);
|
||||||
@ -130,7 +130,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//push_trace('driver_management.terminal_command_driversex');
|
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
|
||||||
@ -161,7 +161,7 @@ begin
|
|||||||
i:= i + 1;
|
i:= i + 1;
|
||||||
Drv:= Drv^.Next;
|
Drv:= Drv^.Next;
|
||||||
end;
|
end;
|
||||||
//pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure terminal_command_devices(Params : PParamList);
|
procedure terminal_command_devices(Params : PParamList);
|
||||||
@ -171,7 +171,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//push_trace('driver_management.terminal_command_devices');
|
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
|
||||||
@ -209,7 +209,7 @@ begin
|
|||||||
i:= i + 1;
|
i:= i + 1;
|
||||||
Dv:= Dv^.Next;
|
Dv:= Dv^.Next;
|
||||||
end;
|
end;
|
||||||
//pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Main Functions }
|
{ Main Functions }
|
||||||
@ -222,6 +222,7 @@ var
|
|||||||
new_ex: PDevEx;
|
new_ex: PDevEx;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('driver_management.copy_identifier');
|
||||||
New_DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
New_DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
||||||
New_DevID^.Bus:= DeviceID^.Bus;
|
New_DevID^.Bus:= DeviceID^.Bus;
|
||||||
New_DevID^.id0:= DeviceID^.id0;
|
New_DevID^.id0:= DeviceID^.id0;
|
||||||
@ -246,6 +247,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
New_DevID^.ex:= root_ex;
|
New_DevID^.ex:= root_ex;
|
||||||
copy_identifier:= New_DevID;
|
copy_identifier:= New_DevID;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function identifiers_match(i1, i2 : PDeviceIdentifier) : boolean;
|
function identifiers_match(i1, i2 : PDeviceIdentifier) : boolean;
|
||||||
@ -254,6 +256,7 @@ var
|
|||||||
b1, b2 : boolean;
|
b1, b2 : boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('driver_management.identifiers_match');
|
||||||
identifiers_match:= true;
|
identifiers_match:= true;
|
||||||
identifiers_match:= identifiers_match and ((i1^.Bus = i2^.Bus) OR (i1^.Bus = biANY) OR (i2^.Bus = biANY));
|
identifiers_match:= identifiers_match and ((i1^.Bus = i2^.Bus) OR (i1^.Bus = biANY) OR (i2^.Bus = biANY));
|
||||||
identifiers_match:= identifiers_match and ((i1^.id0 = i2^.id0) OR (i1^.id0 = $FFFFFFFF) OR (i2^.id0 = $FFFFFFFF));
|
identifiers_match:= identifiers_match and ((i1^.id0 = i2^.id0) OR (i1^.id0 = $FFFFFFFF) OR (i2^.id0 = $FFFFFFFF));
|
||||||
@ -267,28 +270,36 @@ begin
|
|||||||
b1:= ll1 <> nil;
|
b1:= ll1 <> nil;
|
||||||
b2:= ll2 <> nil;
|
b2:= ll2 <> nil;
|
||||||
identifiers_match:= identifiers_match and (b1 = b2);
|
identifiers_match:= identifiers_match and (b1 = b2);
|
||||||
if not (b1 and b2) then exit;
|
if not (b1 and b2) then begin
|
||||||
|
identifiers_match:= false;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
if b1 = b2 then begin
|
if b1 = b2 then begin
|
||||||
identifiers_match:= identifiers_match and ((ll1^.idN = ll2^.idN) OR (ll1^.idN = $FFFFFFFF) OR (ll2^.idN = $FFFFFFFF));
|
identifiers_match:= identifiers_match and ((ll1^.idN = ll2^.idN) OR (ll1^.idN = $FFFFFFFF) OR (ll2^.idN = $FFFFFFFF));
|
||||||
end else begin
|
end else begin
|
||||||
identifiers_match:= false;
|
identifiers_match:= false;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
ll1:= ll1^.ex;
|
ll1:= ll1^.ex;
|
||||||
ll2:= ll2^.ex;
|
ll2:= ll2^.ex;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
begin
|
begin
|
||||||
|
push_trace('driver_management.init');
|
||||||
terminal.registerCommand('DRIVERSEX', @terminal_command_driversex, 'List all available drivers.');
|
terminal.registerCommand('DRIVERSEX', @terminal_command_driversex, 'List all available drivers.');
|
||||||
terminal.registerCommand('DRIVERS', @terminal_command_drivers, 'List loaded drivers.');
|
terminal.registerCommand('DRIVERS', @terminal_command_drivers, 'List loaded drivers.');
|
||||||
terminal.registerCommand('DEVICES', @terminal_command_devices, 'List devices.');
|
terminal.registerCommand('DEVICES', @terminal_command_devices, 'List devices.');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
||||||
begin
|
begin
|
||||||
|
push_trace('driver_management.register_driver');
|
||||||
register_driver_ex(Driver_Name, DeviceID, Load_Callback, false);
|
register_driver_ex(Driver_Name, DeviceID, Load_Callback, false);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_driver_ex(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback; force_load : boolean);
|
procedure register_driver_ex(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback; force_load : boolean);
|
||||||
@ -297,33 +308,34 @@ var
|
|||||||
RegList : PDriverRegistration;
|
RegList : PDriverRegistration;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//push_trace('driver_management.register_driver_ex');
|
push_trace('driver_management.register_driver_ex');
|
||||||
if DeviceID = nil then exit;
|
if DeviceID <> nil then begin;
|
||||||
NewReg:= PDriverRegistration(kalloc(sizeof(TDriverRegistration)));
|
NewReg:= PDriverRegistration(kalloc(sizeof(TDriverRegistration)));
|
||||||
NewReg^.Driver_Name:= stringCopy(Driver_Name);
|
NewReg^.Driver_Name:= stringCopy(Driver_Name);
|
||||||
NewReg^.Identifier:= copy_identifier(DeviceID);
|
NewReg^.Identifier:= copy_identifier(DeviceID);
|
||||||
NewReg^.Loaded:= false;
|
NewReg^.Loaded:= false;
|
||||||
NewReg^.Driver_Load:= Load_Callback;
|
NewReg^.Driver_Load:= Load_Callback;
|
||||||
NewReg^.Next:= nil;
|
NewReg^.Next:= nil;
|
||||||
if Root = nil then begin
|
if Root = nil then begin
|
||||||
Root:= NewReg;
|
Root:= NewReg;
|
||||||
end else begin
|
end else begin
|
||||||
RegList:= Root;
|
RegList:= Root;
|
||||||
While RegList^.Next <> nil do begin
|
While RegList^.Next <> nil do begin
|
||||||
RegList:= RegList^.Next;
|
RegList:= RegList^.Next;
|
||||||
|
end;
|
||||||
|
RegList^.Next:= NewReg;
|
||||||
|
end;
|
||||||
|
console.output('Driver Management', 'New Driver Registered: ');
|
||||||
|
console.writestringln(NewReg^.Driver_Name);
|
||||||
|
if force_load then begin
|
||||||
|
console.output('Driver Management', 'Driver (');
|
||||||
|
console.writestring(NewReg^.Driver_Name);
|
||||||
|
console.writestringln(') forced to load.');
|
||||||
|
NewReg^.Loaded:= True;
|
||||||
|
NewReg^.Driver_Load(nil);
|
||||||
end;
|
end;
|
||||||
RegList^.Next:= NewReg;
|
|
||||||
end;
|
end;
|
||||||
console.output('Driver Management', 'New Driver Registered: ');
|
pop_trace;
|
||||||
console.writestringln(NewReg^.Driver_Name);
|
|
||||||
if force_load then begin
|
|
||||||
console.output('Driver Management', 'Driver (');
|
|
||||||
console.writestring(NewReg^.Driver_Name);
|
|
||||||
console.writestringln(') forced to load.');
|
|
||||||
NewReg^.Loaded:= True;
|
|
||||||
NewReg^.Driver_Load(nil);
|
|
||||||
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);
|
||||||
@ -333,7 +345,7 @@ var
|
|||||||
dev_list : PDeviceRegistration;
|
dev_list : PDeviceRegistration;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//push_trace('driver_management.register_device');
|
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);
|
||||||
@ -365,12 +377,12 @@ begin
|
|||||||
drv^.Loaded:= true;
|
drv^.Loaded:= true;
|
||||||
new_dev^.Driver_Loaded:= true;
|
new_dev^.Driver_Loaded:= true;
|
||||||
new_dev^.Driver:= drv;
|
new_dev^.Driver:= drv;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
drv:= drv^.Next;
|
drv:= drv^.Next;
|
||||||
end;
|
end;
|
||||||
//pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -128,31 +128,42 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
LL_Insert:= nil;
|
LL_Insert:= nil;
|
||||||
if idx >= LinkedList^.Count then exit;
|
if idx > LinkedList^.Count then exit;
|
||||||
Base:= LinkedList^.Head;
|
Base:= LinkedList^.Head;
|
||||||
i:=0;
|
i:=0;
|
||||||
while (i < idx) and (Base <> nil) do begin
|
while (i < idx) and (Base <> nil) do begin
|
||||||
i:= i + 1;
|
i:= i + 1;
|
||||||
Base:= Base^.Next;
|
Base:= Base^.Next;
|
||||||
end;
|
end;
|
||||||
if Base = nil then exit;
|
if i = 0 then begin
|
||||||
Prev:= Base^.Previous;
|
Element:= PLinkedList(kalloc(sizeof(TLinkedList)));
|
||||||
Next:= Base;
|
Element^.Data:= kalloc(LinkedList^.ElementSize);
|
||||||
Element:= PLinkedList(kalloc(sizeof(TLinkedList)));
|
memset(uint32(Element^.Data), 0, LinkedList^.ElementSize);
|
||||||
Element^.Data:= kalloc(LinkedList^.ElementSize);
|
Element^.Next:= LinkedList^.Head;
|
||||||
memset(uint32(Element^.Data), 0, LinkedList^.ElementSize);
|
Element^.Previous:= nil;
|
||||||
Element^.Previous:= Prev;
|
|
||||||
Element^.Next:= Next;
|
|
||||||
if Prev = nil then begin
|
|
||||||
LinkedList^.Head:= Element;
|
LinkedList^.Head:= Element;
|
||||||
|
LinkedList^.Count:= LinkedList^.Count + 1;
|
||||||
|
LL_Insert:= Element^.Data;
|
||||||
end else begin
|
end else begin
|
||||||
Prev^.Next:= Element;
|
if Base = nil then exit;
|
||||||
|
Prev:= Base^.Previous;
|
||||||
|
Next:= Base;
|
||||||
|
Element:= PLinkedList(kalloc(sizeof(TLinkedList)));
|
||||||
|
Element^.Data:= kalloc(LinkedList^.ElementSize);
|
||||||
|
memset(uint32(Element^.Data), 0, LinkedList^.ElementSize);
|
||||||
|
Element^.Previous:= Prev;
|
||||||
|
Element^.Next:= Next;
|
||||||
|
if Prev = nil then begin
|
||||||
|
LinkedList^.Head:= Element;
|
||||||
|
end else begin
|
||||||
|
Prev^.Next:= Element;
|
||||||
|
end;
|
||||||
|
if Next <> nil then begin
|
||||||
|
Next^.Previous:= Element;
|
||||||
|
end;
|
||||||
|
LinkedList^.Count:= LinkedList^.Count + 1;
|
||||||
|
LL_Insert:= Element^.Data;
|
||||||
end;
|
end;
|
||||||
if Next <> nil then begin
|
|
||||||
Next^.Previous:= Element;
|
|
||||||
end;
|
|
||||||
LinkedList^.Count:= LinkedList^.Count + 1;
|
|
||||||
LL_Insert:= Element^.Data;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LL_Get(LinkedList : PLinkedListBase; idx : uint32) : void;
|
function LL_Get(LinkedList : PLinkedListBase; idx : uint32) : void;
|
||||||
|
@ -14,7 +14,7 @@ interface
|
|||||||
const
|
const
|
||||||
KERNEL_VIRTUAL_BASE = $C0000000;
|
KERNEL_VIRTUAL_BASE = $C0000000;
|
||||||
KERNEL_PAGE_NUMBER = KERNEL_VIRTUAL_BASE SHR 22;
|
KERNEL_PAGE_NUMBER = KERNEL_VIRTUAL_BASE SHR 22;
|
||||||
BSOD_ENABLE = false;
|
BSOD_ENABLE = true;
|
||||||
|
|
||||||
type
|
type
|
||||||
//internal types
|
//internal types
|
||||||
|
@ -57,7 +57,8 @@ var
|
|||||||
buf : puint8;
|
buf : puint8;
|
||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('util.printmemory');
|
||||||
buf:= puint8(source);
|
buf:= puint8(source);
|
||||||
for i:=0 to length do begin
|
for i:=0 to length do begin
|
||||||
if offset_row and (i = 0) then begin
|
if offset_row and (i = 0) then begin
|
||||||
@ -76,6 +77,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
console.writestringln(' ');
|
console.writestringln(' ');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function hi(b : uint8) : uint8; [public, alias: 'util_hi'];
|
function hi(b : uint8) : uint8; [public, alias: 'util_hi'];
|
||||||
@ -219,10 +221,12 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('util.memset');
|
||||||
for i:=0 to size-1 do begin
|
for i:=0 to size-1 do begin
|
||||||
loc:= puint8(location + i);
|
loc:= puint8(location + i);
|
||||||
loc^:= value;
|
loc^:= value;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure memcpy(source : uint32; dest : uint32; size : uint32);
|
procedure memcpy(source : uint32; dest : uint32; size : uint32);
|
||||||
@ -231,11 +235,13 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('util.memcpy');
|
||||||
for i:=0 to size-1 do begin
|
for i:=0 to size-1 do begin
|
||||||
src:= puint8(source + i);
|
src:= puint8(source + i);
|
||||||
dst:= puint8(dest + i);
|
dst:= puint8(dest + i);
|
||||||
dst^:= src^;
|
dst^:= src^;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getWord(i : uint32; hi : boolean) : uint16;
|
function getWord(i : uint32; hi : boolean) : uint16;
|
||||||
@ -257,6 +263,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure BSOD(fault : pchar; info : pchar);
|
procedure BSOD(fault : pchar; info : pchar);
|
||||||
|
var
|
||||||
|
trace : pchar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not BSOD_ENABLE then exit;
|
if not BSOD_ENABLE then exit;
|
||||||
console.setdefaultattribute(console.combinecolors(white, Red));
|
console.setdefaultattribute(console.combinecolors(white, Red));
|
||||||
@ -298,7 +307,8 @@ begin
|
|||||||
console.writestring(' Fault Info: ');
|
console.writestring(' Fault Info: ');
|
||||||
console.writestringln(info);
|
console.writestringln(info);
|
||||||
console.writestring(' Faulting Module: ');
|
console.writestring(' Faulting Module: ');
|
||||||
console.writestringln(tracer.get_last_trace);
|
trace:= tracer.get_last_trace;
|
||||||
|
if trace <> nil then console.writestringln(tracer.get_last_trace) else console.writestringln('Unknown');
|
||||||
console.writestringln(' ');
|
console.writestringln(' ');
|
||||||
halt_and_catch_fire();
|
halt_and_catch_fire();
|
||||||
end;
|
end;
|
||||||
|
@ -100,6 +100,8 @@ begin
|
|||||||
multibootinfo:= mbinfo;
|
multibootinfo:= mbinfo;
|
||||||
multibootmagic:= mbmagic;
|
multibootmagic:= mbmagic;
|
||||||
|
|
||||||
|
tracer.freeze();
|
||||||
|
|
||||||
{ Console Init }
|
{ Console Init }
|
||||||
console.init();
|
console.init();
|
||||||
|
|
||||||
@ -177,6 +179,8 @@ begin
|
|||||||
console.writestringln('');
|
console.writestringln('');
|
||||||
console.writestringln('Press any key to boot in to Asuro Terminal...');
|
console.writestringln('Press any key to boot in to Asuro Terminal...');
|
||||||
|
|
||||||
|
GPF;
|
||||||
|
|
||||||
keyboard.hook(@temphook);
|
keyboard.hook(@temphook);
|
||||||
|
|
||||||
util.halt_and_dont_catch_fire;
|
util.halt_and_dont_catch_fire;
|
||||||
|
@ -15,7 +15,8 @@ uses
|
|||||||
util,
|
util,
|
||||||
vmemorymanager,
|
vmemorymanager,
|
||||||
pmemorymanager,
|
pmemorymanager,
|
||||||
console;
|
console,
|
||||||
|
tracer;
|
||||||
|
|
||||||
const
|
const
|
||||||
ALLOC_SPACE = 8; //64-Bit Allocations
|
ALLOC_SPACE = 8; //64-Bit Allocations
|
||||||
@ -56,11 +57,13 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('lmemorymanager.new_lmm_page');
|
||||||
i:= KERNEL_PAGE_NUMBER + 4;
|
i:= KERNEL_PAGE_NUMBER + 4;
|
||||||
while not vmemorymanager.new_page(i) do begin
|
while not vmemorymanager.new_page(i) do begin
|
||||||
i:= i + 1;
|
i:= i + 1;
|
||||||
end;
|
end;
|
||||||
new_lmm_page:= i SHL 22;
|
new_lmm_page:= i SHL 22;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function new_heap_page(CurrentPage : PHeapPage) : PHeapPage;
|
function new_heap_page(CurrentPage : PHeapPage) : PHeapPage;
|
||||||
@ -68,6 +71,7 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('lmemorymanager.new_heap_page');
|
||||||
new_heap_page:= PHeapPage(new_lmm_page);
|
new_heap_page:= PHeapPage(new_lmm_page);
|
||||||
if CurrentPage <> nil then CurrentPage^.Next_Page:= uint32(new_heap_page);
|
if CurrentPage <> nil then CurrentPage^.Next_Page:= uint32(new_heap_page);
|
||||||
new_heap_page^.Next_Page:= 0;
|
new_heap_page^.Next_Page:= 0;
|
||||||
@ -78,7 +82,8 @@ begin
|
|||||||
Root:= False;
|
Root:= False;
|
||||||
Last:= False;
|
Last:= False;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
@ -86,6 +91,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('lmemorymanager.init');
|
||||||
console.outputln('LMM','INIT BEGIN.');
|
console.outputln('LMM','INIT BEGIN.');
|
||||||
Root_Page:= PHeapPage(new_lmm_page);
|
Root_Page:= PHeapPage(new_lmm_page);
|
||||||
Search_Page:= Root_Page;
|
Search_Page:= Root_Page;
|
||||||
@ -97,6 +103,7 @@ begin
|
|||||||
Root_Page^.Entries[i].Last:= False;
|
Root_Page^.Entries[i].Last:= False;
|
||||||
end;
|
end;
|
||||||
console.outputln('LMM','INIT END.');
|
console.outputln('LMM','INIT END.');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function kpalloc(address : uint32) : void;
|
function kpalloc(address : uint32) : void;
|
||||||
@ -104,10 +111,12 @@ var
|
|||||||
block : uint16;
|
block : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('lmemorymanager.kpalloc');
|
||||||
block:= address SHR 22;
|
block:= address SHR 22;
|
||||||
force_alloc_block(block, 0);
|
force_alloc_block(block, 0);
|
||||||
map_page(block, block);
|
map_page(block, block);
|
||||||
kpalloc:= void(block SHL 22);
|
kpalloc:= void(block SHL 22);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function kalloc(size : uint32) : void;
|
function kalloc(size : uint32) : void;
|
||||||
@ -118,6 +127,7 @@ var
|
|||||||
miss : boolean;
|
miss : boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('lmemorymanager.kalloc');
|
||||||
Heap_Entries:= size div 8;
|
Heap_Entries:= size div 8;
|
||||||
If sint32(size-(Heap_Entries*8)) > 0 then Heap_Entries:= Heap_Entries + 1;
|
If sint32(size-(Heap_Entries*8)) > 0 then Heap_Entries:= Heap_Entries + 1;
|
||||||
hp:= Search_Page;
|
hp:= Search_Page;
|
||||||
@ -153,6 +163,7 @@ begin
|
|||||||
Search_Page:= hp;
|
Search_Page:= hp;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure kfree(area : void);
|
procedure kfree(area : void);
|
||||||
@ -161,6 +172,7 @@ var
|
|||||||
entry : uint32;
|
entry : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('lmemorymanager.kfree');
|
||||||
hp:= PHeapPage((uint32(area) SHR 22) SHL 22);
|
hp:= PHeapPage((uint32(area) SHR 22) SHL 22);
|
||||||
entry:= (uint32(area) - DATA_OFFSET - uint32(hp)) div 8;
|
entry:= (uint32(area) - DATA_OFFSET - uint32(hp)) div 8;
|
||||||
if hp^.Entries[entry].Present then begin
|
if hp^.Entries[entry].Present then begin
|
||||||
@ -180,6 +192,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
GPF;
|
GPF;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -14,7 +14,8 @@ interface
|
|||||||
uses
|
uses
|
||||||
util,
|
util,
|
||||||
console,
|
console,
|
||||||
multiboot;
|
multiboot,
|
||||||
|
tracer;
|
||||||
|
|
||||||
type
|
type
|
||||||
TPhysicalMemoryEntry = packed record
|
TPhysicalMemoryEntry = packed record
|
||||||
@ -44,6 +45,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.set_memory_area_present');
|
||||||
FirstBlock:= base SHR 22;
|
FirstBlock:= base SHR 22;
|
||||||
LastBlock:= (base+length) SHR 22;
|
LastBlock:= (base+length) SHR 22;
|
||||||
if (FirstBlock > 1023) then exit;
|
if (FirstBlock > 1023) then exit;
|
||||||
@ -61,6 +63,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure walk_memory_map;
|
procedure walk_memory_map;
|
||||||
@ -71,6 +74,7 @@ var
|
|||||||
i : uint16;
|
i : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.walk_memory_map');
|
||||||
address:= multibootinfo^.mmap_addr + KERNEL_VIRTUAL_BASE;
|
address:= multibootinfo^.mmap_addr + KERNEL_VIRTUAL_BASE;
|
||||||
length:= multibootinfo^.mmap_length;
|
length:= multibootinfo^.mmap_length;
|
||||||
mmap:= Pmemory_map_t(address);
|
mmap:= Pmemory_map_t(address);
|
||||||
@ -92,10 +96,12 @@ begin
|
|||||||
for i:=0 to 1023 do begin
|
for i:=0 to 1023 do begin
|
||||||
if PhysicalMemory[i].Present then nPresent:= nPresent + 1;
|
if PhysicalMemory[i].Present then nPresent:= nPresent + 1;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure force_alloc_block(block : uint16; caller : uint32);
|
procedure force_alloc_block(block : uint16; caller : uint32);
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.force_alloc_block');
|
||||||
PhysicalMemory[block].Allocated:= True;
|
PhysicalMemory[block].Allocated:= True;
|
||||||
PhysicalMemory[block].MappedTo:= caller;
|
PhysicalMemory[block].MappedTo:= caller;
|
||||||
// console.writestring('PMM: 4MiB Block Force Allocated @ ');
|
// console.writestring('PMM: 4MiB Block Force Allocated @ ');
|
||||||
@ -105,10 +111,12 @@ begin
|
|||||||
// console.writestring(' - ');
|
// console.writestring(' - ');
|
||||||
// console.writehex(((block+1) SHL 22));
|
// console.writehex(((block+1) SHL 22));
|
||||||
// console.writestringln(']');
|
// console.writestringln(']');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.init');
|
||||||
console.outputln('PMM','INIT BEGIN.');
|
console.outputln('PMM','INIT BEGIN.');
|
||||||
walk_memory_map;
|
walk_memory_map;
|
||||||
force_alloc_block(0, 0);
|
force_alloc_block(0, 0);
|
||||||
@ -119,10 +127,12 @@ begin
|
|||||||
console.writeword(nPresent);
|
console.writeword(nPresent);
|
||||||
console.writestringln('/1024 Block Available for Allocation.');
|
console.writestringln('/1024 Block Available for Allocation.');
|
||||||
console.outputln('PMM','INIT END.');
|
console.outputln('PMM','INIT END.');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function alloc_block(block : uint16; caller : uint32) : boolean;
|
function alloc_block(block : uint16; caller : uint32) : boolean;
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.alloc_block');
|
||||||
alloc_block:= false;
|
alloc_block:= false;
|
||||||
if (PhysicalMemory[block].Present) then begin
|
if (PhysicalMemory[block].Present) then begin
|
||||||
if PhysicalMemory[block].Allocated then begin
|
if PhysicalMemory[block].Allocated then begin
|
||||||
@ -143,6 +153,7 @@ begin
|
|||||||
GPF;
|
GPF;
|
||||||
alloc_block:= false;
|
alloc_block:= false;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function new_block(caller : uint32) : uint16;
|
function new_block(caller : uint32) : uint16;
|
||||||
@ -150,6 +161,7 @@ var
|
|||||||
i : uint16;
|
i : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.new_block');
|
||||||
new_block:= 0;
|
new_block:= 0;
|
||||||
for i:=2 to 1023 do begin
|
for i:=2 to 1023 do begin
|
||||||
if PhysicalMemory[i].Present then begin
|
if PhysicalMemory[i].Present then begin
|
||||||
@ -161,10 +173,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure free_block(block : uint16; caller : uint32);
|
procedure free_block(block : uint16; caller : uint32);
|
||||||
begin
|
begin
|
||||||
|
push_trace('pmemorymanager.free_block');
|
||||||
if block > 1023 then begin
|
if block > 1023 then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
exit;
|
||||||
@ -182,6 +196,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
PhysicalMemory[block].Allocated:= false;
|
PhysicalMemory[block].Allocated:= false;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -60,6 +60,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.paramCount');
|
||||||
current:= params;
|
current:= params;
|
||||||
i:= 0;
|
i:= 0;
|
||||||
while current^.param <> nil do begin
|
while current^.param <> nil do begin
|
||||||
@ -67,6 +68,7 @@ begin
|
|||||||
current:= current^.next;
|
current:= current^.next;
|
||||||
end;
|
end;
|
||||||
paramCount:= i-1;
|
paramCount:= i-1;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getParams(buf : TCommandBuffer) : PParamList;
|
function getParams(buf : TCommandBuffer) : PParamList;
|
||||||
@ -78,6 +80,7 @@ var
|
|||||||
current : PParamList;
|
current : PParamList;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.getParams');
|
||||||
root:= PParamList(kalloc(sizeof(TParamList)));
|
root:= PParamList(kalloc(sizeof(TParamList)));
|
||||||
current:= root;
|
current:= root;
|
||||||
current^.next:= nil;
|
current^.next:= nil;
|
||||||
@ -103,6 +106,7 @@ begin
|
|||||||
inc(finish);
|
inc(finish);
|
||||||
end;
|
end;
|
||||||
getParams:= root;
|
getParams:= root;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getParam(index : uint32; params : PParamList) : pchar;
|
function getParam(index : uint32; params : PParamList) : pchar;
|
||||||
@ -112,12 +116,14 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.getParam');
|
||||||
result:= nil;
|
result:= nil;
|
||||||
search:= params;
|
search:= params;
|
||||||
for i:=0 to index do begin
|
for i:=0 to index do begin
|
||||||
search:= search^.next;
|
search:= search^.next;
|
||||||
end;
|
end;
|
||||||
result:= search^.param;
|
result:= search^.param;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure freeParams(params : PParamList);
|
procedure freeParams(params : PParamList);
|
||||||
@ -126,6 +132,7 @@ var
|
|||||||
next : PParamList;
|
next : PParamList;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.freeParams');
|
||||||
p:= params;
|
p:= params;
|
||||||
next:= p^.next;
|
next:= p^.next;
|
||||||
while p^.next <> nil do begin
|
while p^.next <> nil do begin
|
||||||
@ -134,14 +141,17 @@ begin
|
|||||||
p:= next;
|
p:= next;
|
||||||
next:= p^.next;
|
next:= p^.next;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure testParams(params : PParamList);
|
procedure testParams(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.testParams');
|
||||||
while params^.Param <> nil do begin
|
while params^.Param <> nil do begin
|
||||||
writestringln(params^.Param);
|
writestringln(params^.Param);
|
||||||
params:= params^.next;
|
params:= params^.next;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure echo(params : PParamList);
|
procedure echo(params : PParamList);
|
||||||
@ -149,6 +159,7 @@ var
|
|||||||
current : PParamList;
|
current : PParamList;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.echo');
|
||||||
current:= params^.next;
|
current:= params^.next;
|
||||||
while current^.param <> nil do begin
|
while current^.param <> nil do begin
|
||||||
console.writestring(current^.param);
|
console.writestring(current^.param);
|
||||||
@ -156,22 +167,28 @@ begin
|
|||||||
current:= current^.next;
|
current:= current^.next;
|
||||||
end;
|
end;
|
||||||
console.writestringln('');
|
console.writestringln('');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure clear(params : PParamList);
|
procedure clear(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.clear');
|
||||||
console.clear();
|
console.clear();
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure version(params : PParamList);
|
procedure version(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.version');
|
||||||
console.writestringln('Asuro v1.0');
|
console.writestringln('Asuro v1.0');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure help(params : PParamList);
|
procedure help(params : PParamList);
|
||||||
var
|
var
|
||||||
i : uint32;
|
i : uint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.help');
|
||||||
console.writestringln('Registered Commands: ');
|
console.writestringln('Registered Commands: ');
|
||||||
for i:=0 to 65534 do begin
|
for i:=0 to 65534 do begin
|
||||||
if Commands[i].Registered then begin
|
if Commands[i].Registered then begin
|
||||||
@ -181,15 +198,18 @@ begin
|
|||||||
console.writestringln(Commands[i].description);
|
console.writestringln(Commands[i].description);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure test(params : PParamList);
|
procedure test(params : PParamList);
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.test');
|
||||||
if paramCount(params) > 0 then begin
|
if paramCount(params) > 0 then begin
|
||||||
console.writeintln(stringToInt(getParam(0, params)));
|
console.writeintln(stringToInt(getParam(0, params)));
|
||||||
end else begin
|
end else begin
|
||||||
console.writestringln('Invalid number of params');
|
console.writestringln('Invalid number of params');
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure registerCommand(command : pchar; method : TCommandMethod; description : pchar);
|
procedure registerCommand(command : pchar; method : TCommandMethod; description : pchar);
|
||||||
@ -197,12 +217,14 @@ var
|
|||||||
index : uint32;
|
index : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.registerCommand');
|
||||||
index:= 0;
|
index:= 0;
|
||||||
while Commands[index].registered = true do inc(index);
|
while Commands[index].registered = true do inc(index);
|
||||||
Commands[index].registered:= true;
|
Commands[index].registered:= true;
|
||||||
Commands[index].Command:= command;
|
Commands[index].Command:= command;
|
||||||
Commands[index].method:= method;
|
Commands[index].method:= method;
|
||||||
Commands[index].description:= description;
|
Commands[index].description:= description;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure process_command;
|
procedure process_command;
|
||||||
@ -214,6 +236,8 @@ var
|
|||||||
uppera, upperb : pchar;
|
uppera, upperb : pchar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.process_command');
|
||||||
|
|
||||||
{ Start a new line. }
|
{ Start a new line. }
|
||||||
console.writecharln(' ');
|
console.writecharln(' ');
|
||||||
|
|
||||||
@ -249,10 +273,13 @@ begin
|
|||||||
console.writestring('Asuro#> ');
|
console.writestring('Asuro#> ');
|
||||||
bIndex:= 0;
|
bIndex:= 0;
|
||||||
memset(uint32(@buffer[0]), 0, 1024);
|
memset(uint32(@buffer[0]), 0, 1024);
|
||||||
|
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure key_event(info : TKeyInfo);
|
procedure key_event(info : TKeyInfo);
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.key_event');
|
||||||
if (info.key_code >= 32) and (info.key_code <= 126) then begin
|
if (info.key_code >= 32) and (info.key_code <= 126) then begin
|
||||||
if bIndex < 1024 then begin
|
if bIndex < 1024 then begin
|
||||||
buffer[bIndex]:= info.key_code;
|
buffer[bIndex]:= info.key_code;
|
||||||
@ -270,10 +297,12 @@ begin
|
|||||||
if info.key_code = 13 then begin //return
|
if info.key_code = 13 then begin //return
|
||||||
process_command;
|
process_command;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.init');
|
||||||
console.writestringln('TERMINAL: INIT BEGIN.');
|
console.writestringln('TERMINAL: INIT BEGIN.');
|
||||||
memset(uint32(@Commands[0]), 0, 65535*sizeof(TCommand));
|
memset(uint32(@Commands[0]), 0, 65535*sizeof(TCommand));
|
||||||
memset(uint32(@buffer[0]), 0, 1024);
|
memset(uint32(@buffer[0]), 0, 1024);
|
||||||
@ -284,13 +313,16 @@ begin
|
|||||||
registerCommand('TESTPARAMS', @testParams, 'Tests param parsing.');
|
registerCommand('TESTPARAMS', @testParams, 'Tests param parsing.');
|
||||||
registerCommand('TEST', @test, 'Command for testing.');
|
registerCommand('TEST', @test, 'Command for testing.');
|
||||||
console.writestringln('TERMINAL: INIT END.');
|
console.writestringln('TERMINAL: INIT END.');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure run;
|
procedure run;
|
||||||
begin
|
begin
|
||||||
|
push_trace('terminal.run');
|
||||||
keyboard.hook(@key_event);
|
keyboard.hook(@key_event);
|
||||||
console.clear();
|
console.clear();
|
||||||
console.writestring('Asuro#> ');
|
console.writestring('Asuro#> ');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -6,6 +6,9 @@ procedure init;
|
|||||||
procedure push_trace(t_name : pchar);
|
procedure push_trace(t_name : pchar);
|
||||||
procedure pop_trace;
|
procedure pop_trace;
|
||||||
function get_last_trace : pchar;
|
function get_last_trace : pchar;
|
||||||
|
procedure freeze;
|
||||||
|
function get_trace_count : uint32;
|
||||||
|
function get_trace_N(idx : uint32) : pchar;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -13,11 +16,11 @@ uses
|
|||||||
console, util, lists, strings;
|
console, util, lists, strings;
|
||||||
|
|
||||||
var
|
var
|
||||||
t_ready : Boolean = false;
|
t_ready : Boolean;
|
||||||
Locked : Boolean = false;
|
Locked : Boolean;
|
||||||
TraceStack : PLinkedListBase;
|
TraceStack : PLinkedListBase;
|
||||||
|
|
||||||
procedure lock;
|
procedure freeze;
|
||||||
begin
|
begin
|
||||||
t_ready:= false;
|
t_ready:= false;
|
||||||
end;
|
end;
|
||||||
@ -27,38 +30,51 @@ var
|
|||||||
mem : void;
|
mem : void;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not Initialized then exit;
|
if t_ready then begin
|
||||||
console.writestringln('WTF?!?!?');
|
if not Locked then begin
|
||||||
if not Locked then begin
|
Locked:= true;
|
||||||
Locked:= true;
|
mem:= LL_Insert(TraceStack, 0);
|
||||||
mem:= LL_Insert(TraceStack, 0);
|
memset(uint32(mem), 0, StringSize(t_name) + 5);
|
||||||
memset(uint32(mem), 0, StringSize(t_name) + 5);
|
memcpy(uint32(t_name), uint32(mem), StringSize(t_name) + 1);
|
||||||
memcpy(uint32(t_name), uint32(mem), StringSize(t_name) + 1);
|
Locked:= false;
|
||||||
Locked:= false;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure pop_trace;
|
procedure pop_trace;
|
||||||
begin
|
begin
|
||||||
if not Initialized then exit;
|
if t_ready then begin
|
||||||
if not Locked then begin
|
if not Locked then begin
|
||||||
Locked:= true;
|
Locked:= true;
|
||||||
LL_Delete(TraceStack, 0);
|
LL_Delete(TraceStack, 0);
|
||||||
Locked:= false;
|
Locked:= false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function get_last_trace : pchar;
|
function get_last_trace : pchar;
|
||||||
begin
|
begin
|
||||||
if not Initialized then exit;
|
get_last_trace:= nil;
|
||||||
get_last_trace:= pchar(LL_Get(TraceStack, 0));
|
if t_ready then begin
|
||||||
|
get_last_trace:= pchar(LL_Get(TraceStack, 0));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
begin
|
begin
|
||||||
TraceStack:= LL_New(255);
|
TraceStack:= LL_New(255);
|
||||||
|
t_ready:= true;
|
||||||
push_trace('kmain');
|
push_trace('kmain');
|
||||||
Initialized:= true;
|
end;
|
||||||
|
|
||||||
|
function get_trace_count : uint32;
|
||||||
|
begin
|
||||||
|
get_trace_count:= LL_Size(TraceStack);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function get_trace_N(idx : uint32) : pchar;
|
||||||
|
begin
|
||||||
|
get_trace_N:= pchar(LL_Get(TraceStack, idx));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -58,7 +58,9 @@ uses
|
|||||||
|
|
||||||
function new_page_directory : uint32;
|
function new_page_directory : uint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.new_page_directory');
|
||||||
new_page_directory:= uint32(kalloc(sizeof(TPageDirectory)));
|
new_page_directory:= uint32(kalloc(sizeof(TPageDirectory)));
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function new_kernel_mapped_page_directory : uint32;
|
function new_kernel_mapped_page_directory : uint32;
|
||||||
@ -67,11 +69,13 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.new_kernel_mapped_page_directory');
|
||||||
PD:= PPageDirectory(new_page_directory);
|
PD:= PPageDirectory(new_page_directory);
|
||||||
for i:=KERNEL_PAGE_NUMBER to 1023 do begin
|
for i:=KERNEL_PAGE_NUMBER to 1023 do begin
|
||||||
PD^[i]:= KERNEL_PAGE_DIRECTORY^[i];
|
PD^[i]:= KERNEL_PAGE_DIRECTORY^[i];
|
||||||
end;
|
end;
|
||||||
new_kernel_mapped_page_directory:= uint32(PD);
|
new_kernel_mapped_page_directory:= uint32(PD);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function load_current_page_directory : PPageDirectory;
|
function load_current_page_directory : PPageDirectory;
|
||||||
@ -79,6 +83,7 @@ var
|
|||||||
Directory : uint32;
|
Directory : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.load_current_page_directory');
|
||||||
asm
|
asm
|
||||||
MOV EAX, CR3
|
MOV EAX, CR3
|
||||||
MOV Directory, EAX
|
MOV Directory, EAX
|
||||||
@ -93,6 +98,7 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.init');
|
||||||
console.outputln('VMM','INIT BEGIN.');
|
console.outputln('VMM','INIT BEGIN.');
|
||||||
PageDirectory:= load_current_page_directory;
|
PageDirectory:= load_current_page_directory;
|
||||||
KERNEL_PAGE_DIRECTORY:= PageDirectory;
|
KERNEL_PAGE_DIRECTORY:= PageDirectory;
|
||||||
@ -101,6 +107,7 @@ begin
|
|||||||
map_page(KERNEL_PAGE_NUMBER + 2, 2);
|
map_page(KERNEL_PAGE_NUMBER + 2, 2);
|
||||||
map_page(KERNEL_PAGE_NUMBER + 3, 3);
|
map_page(KERNEL_PAGE_NUMBER + 3, 3);
|
||||||
console.outputln('VMM','INIT END.');
|
console.outputln('VMM','INIT END.');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean;
|
function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean;
|
||||||
@ -109,6 +116,7 @@ var
|
|||||||
page : uint16;
|
page : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.map_page_ex');
|
||||||
map_page_ex:= false;
|
map_page_ex:= false;
|
||||||
PD^[page_number].Present:= true;
|
PD^[page_number].Present:= true;
|
||||||
addr:= block;
|
addr:= block;
|
||||||
@ -134,6 +142,7 @@ begin
|
|||||||
// console.writestringln(']');
|
// console.writestringln(']');
|
||||||
|
|
||||||
map_page_ex:= true;
|
map_page_ex:= true;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function map_page(page_number : uint16; block : uint16) : boolean;
|
function map_page(page_number : uint16; block : uint16) : boolean;
|
||||||
@ -143,6 +152,7 @@ var
|
|||||||
rldpd : uint32;
|
rldpd : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.map_page');
|
||||||
map_page:= false;
|
map_page:= false;
|
||||||
PageDirectory^[page_number].Present:= true;
|
PageDirectory^[page_number].Present:= true;
|
||||||
addr:= block;
|
addr:= block;
|
||||||
@ -155,6 +165,7 @@ begin
|
|||||||
mov eax, rldpd
|
mov eax, rldpd
|
||||||
mov CR3, eax
|
mov CR3, eax
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function vtop(address : uint32) : uint32;
|
function vtop(address : uint32) : uint32;
|
||||||
@ -164,10 +175,12 @@ var
|
|||||||
loadd : uint32;
|
loadd : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.vtop');
|
||||||
idx:= address SHR 22;
|
idx:= address SHR 22;
|
||||||
paddress:= uint32(KERNEL_PAGE_DIRECTORY^[idx].address) SHL 12;
|
paddress:= uint32(KERNEL_PAGE_DIRECTORY^[idx].address) SHL 12;
|
||||||
loadd:= address AND $FFFFFF;
|
loadd:= address AND $FFFFFF;
|
||||||
vtop:= paddress + loadd;
|
vtop:= paddress + loadd;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function new_page(page_number : uint16) : boolean;
|
function new_page(page_number : uint16) : boolean;
|
||||||
@ -175,6 +188,7 @@ var
|
|||||||
block : uint16;
|
block : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.new_page');
|
||||||
new_page:= false;
|
new_page:= false;
|
||||||
if PageDirectory^[page_number].Present then exit;
|
if PageDirectory^[page_number].Present then exit;
|
||||||
if PageDirectory^[page_number].Reserved then exit;
|
if PageDirectory^[page_number].Reserved then exit;
|
||||||
@ -185,6 +199,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
new_page:= map_page(page_number, block);
|
new_page:= map_page(page_number, block);
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function new_page_at_address(address : uint32) : boolean;
|
function new_page_at_address(address : uint32) : boolean;
|
||||||
@ -192,8 +207,10 @@ var
|
|||||||
page_number : uint16;
|
page_number : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.new_page_at_address');
|
||||||
page_number:= address SHR 22;
|
page_number:= address SHR 22;
|
||||||
new_page_at_address:= new_page(page_number);
|
new_page_at_address:= new_page(page_number);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure free_page(page_number : uint16);
|
procedure free_page(page_number : uint16);
|
||||||
@ -201,6 +218,7 @@ var
|
|||||||
block : uint16;
|
block : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.free_page');
|
||||||
if PageDirectory^[page_number].Present then begin
|
if PageDirectory^[page_number].Present then begin
|
||||||
block:= PageDirectory^[page_number].Address;
|
block:= PageDirectory^[page_number].Address;
|
||||||
asm
|
asm
|
||||||
@ -210,6 +228,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
GPF;
|
GPF;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure free_page_at_address(address : uint32);
|
procedure free_page_at_address(address : uint32);
|
||||||
@ -217,8 +236,10 @@ var
|
|||||||
page_number : uint16;
|
page_number : uint16;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('vmemorymanager.free_page_at_address');
|
||||||
page_number:= address SHR 22;
|
page_number:= address SHR 22;
|
||||||
free_page(page_number);
|
free_page(page_number);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
Loading…
x
Reference in New Issue
Block a user