Big commit thing.

git-svn-id: https://spexeah.com:8443/svn/Asuro@867 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron
2020-07-08 21:42:55 +00:00
parent 6b781c6345
commit 1dcfc4e7eb
19 changed files with 107 additions and 45 deletions

View File

@ -17,12 +17,19 @@ var
Ports : Array[0..65535] of PUDPBindContext;
procedure register();
function bind(bindContext : PUDPBindContext) : TUDPError;
function unbind(bindContext : PUDPBindContext) : TUDPError;
implementation
uses
console, terminal;
function send(p_data : void; p_len : uint16; p_context : PPacketContext; bindContext : PUDPBindContext);
begin
end;
function bind(bindContext : PUDPBindContext) : TUDPError;
var
result : TUDPError;
@ -66,9 +73,10 @@ begin
result:= tuePortNotFound;
end;
end;
unbind:= result;
end;
procedure UDPReceive(p_data : void; p_len : uint16; p_context : PPacketContext);
procedure ProcessPacket(p_data : void; p_len : uint16; p_context : PPacketContext);
var
header : PUDPHeader;
context : PUDPPacketContext;
@ -81,18 +89,6 @@ var
begin
writeToLogLn(' L4: udp.recv');
header:= PUDPHeader(p_data);
//writestringln('UDP Packet: ');
//hex:= puint8(p_data);
//for i:=0 to 7 do begin
// writehexpair(hex^);
// hex:= hex+1;
//end;
//writestringln(' ');
//Writeintln(switchendian16(header^.SrcPort));
//Writeintln(header^.SrcPort);
//Writeintln(switchendian16(header^.DstPort));
//Writeintln(header^.DstPort);
//writestringln('');
if Ports[switchendian16(header^.DstPort)] <> nil then begin
context:= PUDPPacketContext(kalloc(sizeof(TUDPPacketContext)));
context^.PacketContext:= p_context;
@ -105,6 +101,7 @@ begin
size:= context^.Length - sizeof(TUDPHeader);
bind:= Ports[context^.DstPort];
bind^.Callback(void(buf), size, context);
kfree(void(context));
end;
end;
@ -131,19 +128,19 @@ begin
for i:=0 to 65535 do begin
Ports[i]:= nil;
end;
context:= PUDPBindContext(kalloc(sizeof(TUDPBindContext)));
context^.Port:= 22294;
context^.Callback:= @TestRecv;
context^.UID:= 4398724;
r:= bind(context);
writestring('[TestBind] ');
case r of
tueOK:writestringln('22294 bind OK');
tuePortInUse:writestringln('22294 port in use');
tueGenericError:writestringln('22294 generic error');
tuePortRestricted:writestringln('22294 restricted');
end;
ipv4.registerProtocol($11, @UDPReceive);
//context:= PUDPBindContext(kalloc(sizeof(TUDPBindContext)));
//context^.Port:= 22294;
//context^.Callback:= @TestRecv;
//context^.UID:= 4398724;
//r:= bind(context);
//writestring('[TestBind] ');
//case r of
// tueOK:writestringln('22294 bind OK');
// tuePortInUse:writestringln('22294 port in use');
// tueGenericError:writestringln('22294 generic error');
// tuePortRestricted:writestringln('22294 restricted');
//end;
ipv4.registerProtocol($11, @ProcessPacket);
end;
end.

View File

@ -41,6 +41,18 @@ type
info : TIdentResponse;
end;
TIDE_Status = bitpacked record
Busy : Boolean;
Ready : Boolean;
Fault : Boolean;
Seek : Boolean;
DRQ : Boolean;
CORR : Boolean;
IDDEX : Boolean;
ERROR : Boolean;
end;
PIDE_Status = ^TIDE_Status;
const
ATA_SR_BUSY = $80; //BUSY
@ -325,39 +337,62 @@ var
begin
push_trace('ide.writePIO28');
console.writestringln('[IDE] (WRITEPIO28) BEGIN');
console.redrawWindows;
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
console.writestringln('[IDE] (WRITEPIO28) 1');
console.redrawWindows;
noInt(drive);
if IDEDevices[drive].isMaster then begin
//outb($1F6, $A0); //drive select
outb($1F6, $A0); //drive select
outb($1F7, $E0 or ((LBA shr 24) and $0F)); //LBA command primary master
end
else begin
//outb($1F6, $B0); //drive select
outb($1F6, $B0); //drive select
outb($1F7, $F0 or ((LBA shr 24) and $0F)); //LBA command primary slave
end;
console.writestringln('[IDE] (WRITEPIO28) 2');
console.redrawWindows;
outb($1F2, sectorCount);
outb($1F3, LBA);
outb($1F4, LBA shr 8);
outb($1F5, LBA shr 16);
outb($1F7, $30); //write command
for i:=0 to sectorCount do begin
console.writestringln('[IDE] (WRITEPIO28) 3');
console.redrawWindows;
for i:=0 to sectorCount-1 do begin
//poll status
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
while true do if (inb($1f7) and ATA_SR_BUSY) = 0 then break; //Wait until drive not busy
console.writestringln('[IDE] (WRITEPIO28) 4');
console.redrawWindows;
while true do begin
console.writestring('[IDE] (WRITEPIO28) inb($1f7): ');
writehexpair(inb($1f7));
if inb($1f7) = $40 then begin
while true do begin console.redrawWindows; end;
end;
writestringln(' ');
console.redrawWindows;
if (inb($1f7) and (1 shl 3)) <> 0 then break;
if (inb($1F7) and 1) <> 0 then begin
console.writestringln('write error');
console.redrawWindows;
exit;
end; //drive error
end;
console.writestringln('[IDE] (WRITEPIO28) 5');
console.redrawWindows;
for ii:=0 to 127 do begin //write data
outb($1F0, Puint32(buffer + ((i * 512) + (ii * 32) DIV 32) )^);
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
@ -367,10 +402,14 @@ begin
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
outb($1F7, $E7);
end;
end;
console.writestringln('[IDE] (WRITEPIO28) 6');
console.redrawWindows;
end;
console.writestringln('[IDE] (WRITEPIO28) END');
console.redrawWindows;
pop_trace();
end;
@ -402,7 +441,7 @@ begin
outb($1F7, $20); //read command
for i:=0 to sectorCount do begin
for i:=0 to sectorCount-1 do begin
//poll status
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
@ -483,4 +522,5 @@ procedure write(device : PStorage_device; LBA : uint32; sectorCount : uint32; bu
begin
writePIO28(device^.controllerId0, LBA, sectorCount, buffer);
end;
end.

View File

@ -800,8 +800,8 @@ begin //maybe increase buffer size by one?
// memset(uint32(buffer), 0, sizeof(TBootRecord));
// bootRecord:= PBootRecord(buffer);
buffer:= puint32(kalloc(2048));
memset(uint32(buffer), 0, 2048);
buffer:= puint32(kalloc(disk^.sectorSize));
memset(uint32(buffer), 0, disk^.sectorSize);
bootRecord:= PBootRecord(buffer);
@ -831,30 +831,48 @@ begin //maybe increase buffer size by one?
fatStart:= start + 1 + bootRecord^.rsvSectors;
dataStart:= fatStart + bootRecord^.FATSize;
zeroBuffer:= puint32(kalloc( disk^.sectorSize * 4 ));
memset(uint32(zeroBuffer), 0, disk^.sectorSize * 4);
zeroBuffer:= puint32(kalloc( disk^.sectorSize ));
memset(uint32(zeroBuffer), 0, disk^.sectorSize );
while true do begin
if i > FATSize DIV 4 then break;
disk^.writecallback(disk, fatStart + i, 4, zeroBuffer);
{while true do begin
if i > FATSize then break;
writestring('LOOP BEGIN: ');
writeintln(i);
writeintln(bootRecord^.rsvSectors);
writeintln(start);
writeintln(fatStart);
writeintln(FATSize);
console.redrawWindows;
disk^.writecallback(disk, fatStart + i, 1, zeroBuffer);
writestring('LOOP END: ');
writeintln(i);
console.redrawWindows;
i+=1;
end;
end;}
kfree(buffer);
kfree(zeroBuffer);
writestring('Frees');
console.redrawWindows;
buffer:= puint32(kalloc(disk^.sectorSize));
memset(uint32(buffer), 0, disk^.sectorSize);
puint32(buffer)[0]:= $FFFFFFF8; //fsinfo
puint32(buffer)[1]:= $FFFFFFF8; //root cluster
writestring('Buffer Alloc');
console.redrawWindows;
disk^.writecallback(disk, fatStart, 1, buffer);
writestring('WriteCB1');
console.redrawWindows;
kfree(buffer);
buffer:= puint32(kalloc(disk^.sectorsize));
memset(uint32(buffer), 0, disk^.sectorsize);
writestring('Buffer Alloc 2');
console.redrawWindows;
PDirectory(buffer)[0].fileName := thisArray;
PDirectory(buffer)[0].attributes := $08;
@ -865,8 +883,12 @@ begin //maybe increase buffer size by one?
PDirectory(buffer)[1].clusterLow := 1;
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
writestring('WriteCB2');
console.redrawWindows;
kfree(buffer);
writestring('Free');
console.redrawWindows;
end;

View File

@ -44,7 +44,8 @@ uses
vmlog,
vm,
vmstate,
edit;
edit,
udpcat;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
@ -221,6 +222,7 @@ begin
vmstate.init();
tracer.push_trace('kmain.EDIT');
edit.init();
udpcat.init();
terminal.run();
{ Init Splash }