git-svn-id: https://spexeah.com:8443/svn/Asuro@1441 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
kieron 2020-07-21 22:06:41 +00:00
parent 50b77b9ce9
commit 99fc00450e
24 changed files with 1154 additions and 274 deletions

View File

@ -172,6 +172,7 @@ var
elm : pchar; elm : pchar;
begin begin
tracer.push_trace('vfs.evaluatePath.enter');
List:= STRLL_FromString(Path, '/'); List:= STRLL_FromString(Path, '/');
if STRLL_Size(List) > 0 then begin if STRLL_Size(List) > 0 then begin
for i:=STRLL_Size(List)-1 downto 0 do begin for i:=STRLL_Size(List)-1 downto 0 do begin
@ -186,6 +187,7 @@ begin
end; end;
evaluatePath:= CombineToAbsolutePath(List, STRLL_Size(List)); evaluatePath:= CombineToAbsolutePath(List, STRLL_Size(List));
STRLL_Free(List); STRLL_Free(List);
tracer.push_trace('vfs.evaluatePath.exit');
end; end;
function getAbsolutePath(Obj : PVFSObject) : pchar; function getAbsolutePath(Obj : PVFSObject) : pchar;
@ -225,6 +227,7 @@ var
TempPath : pchar; TempPath : pchar;
begin begin
tracer.push_trace('vfs.MakeAbsolutePath.enter');
if Path[0] = '/' then AbsPath:= stringCopy(Path) else begin if Path[0] = '/' then AbsPath:= stringCopy(Path) else begin
if CurrentDirectory[StringSize(CurrentDirectory)-1] <> '/' then if CurrentDirectory[StringSize(CurrentDirectory)-1] <> '/' then
TempPath:= StringConcat(CurrentDirectory, '/') TempPath:= StringConcat(CurrentDirectory, '/')
@ -234,6 +237,7 @@ begin
kfree(void(TempPath)); kfree(void(TempPath));
end; end;
MakeAbsolutePath:= AbsPath; MakeAbsolutePath:= AbsPath;
tracer.push_trace('vfs.MakeAbsolutePath.exit');
end; end;
function GetObjectFromPath(path : pchar) : PVFSObject; function GetObjectFromPath(path : pchar) : PVFSObject;
@ -367,8 +371,13 @@ var
Obj : PVFSObject; Obj : PVFSObject;
ObjPath : pchar; ObjPath : pchar;
RelPath : pchar; RelPath : pchar;
AbsPath : pchar;
CopyPath : pchar;
MntPath : pchar;
ValidCallback : TPathValid;
begin begin
tracer.push_trace('vfs.PathValid.enter');
PathValid:= pvInvalid; PathValid:= pvInvalid;
Obj:= GetObjectFromPath(Path); Obj:= GetObjectFromPath(Path);
if Obj <> nil then begin if Obj <> nil then begin
@ -379,14 +388,22 @@ begin
otDRIVE:begin otDRIVE:begin
ObjPath:= getAbsolutePath(Obj); ObjPath:= getAbsolutePath(Obj);
RelPath:= makeRelative(Path, ObjPath); RelPath:= makeRelative(Path, ObjPath);
PathValid:= PVFSDrive(Obj^.Reference)^.PathValid(PVFSDrive(Obj^.Reference)^.DriveHandle, RelPath); //Fix this to be relative path!!! ValidCallback:= PVFSDrive(Obj^.Reference)^.PathValid;
if ValidCallback <> nil then
PathValid:= ValidCallback(PVFSDrive(Obj^.Reference)^.DriveHandle, RelPath)
else
PathValid:= pvInvalid;
kfree(void(ObjPath)); kfree(void(ObjPath));
kfree(void(RelPath)); kfree(void(RelPath));
end; end;
otDEVICE:begin otDEVICE:begin
ObjPath:= getAbsolutePath(Obj); ObjPath:= getAbsolutePath(Obj);
RelPath:= makeRelative(Path, ObjPath); RelPath:= makeRelative(Path, ObjPath);
PathValid:= PVFSDevice(Obj^.Reference)^.PathValid(PVFSDevice(Obj^.Reference)^.DeviceHandle, RelPath); //Fix this to be the relative path ValidCallback:= PVFSDevice(Obj^.Reference)^.PathValid;
if ValidCallback <> nil then
PathValid:= ValidCallback(PVFSDevice(Obj^.Reference)^.DeviceHandle, RelPath)
else
PathValid:= pvInvalid;
kfree(void(ObjPath)); kfree(void(ObjPath));
kfree(void(RelPath)); kfree(void(RelPath));
end; end;
@ -394,10 +411,30 @@ begin
PathValid:= pvFile; PathValid:= pvFile;
end; end;
otMOUNT:begin otMOUNT:begin
PathValid:= PathValid(PVFSMount(Obj^.Reference)^.Path); { Get the absolute path of this object, i.e. /mnt/mount1 }
ObjPath:= getAbsolutePath(Obj);
{ Make our path relative, i.e. /mnt/mount1/myfile becomes /myfile }
RelPath:= makeRelative(Path, ObjPath);
{ Grab the Redirect Path i.e. /disk/disk1 }
MntPath:= PVFSMount(Obj^.Reference)^.Path;
{ Ensure that if there isn't a '/' between the RelPath & MntPath we add one }
If (MntPath[StringSize(MntPath)-1] <> '/') AND (RelPath[0] <> '/') then
CopyPath:= StringConcat(MntPath, '/')
else
CopyPath:= StringCopy(MntPath);
{ Concat MntPath + RelPath, i.e. above examples would become /disk/disk1/myfile }
AbsPath:= StringConcat(MntPath, RelPath);
{ Recursively call PathValid on our new path }
PathValid:= PathValid(AbsPath);
{ Free everything we allocated }
kfree(void(AbsPath));
kfree(void(RelPath));
kfree(void(CopyPath));
kfree(void(ObjPath));
end; end;
end; end;
end; end;
tracer.push_trace('vfs.PathValid.exit');
end; end;
function changeDirectory(Path : pchar) : TIsPathValid; function changeDirectory(Path : pchar) : TIsPathValid;
@ -407,6 +444,7 @@ var
Validity : TIsPathValid; Validity : TIsPathValid;
begin begin
tracer.push_trace('vfs.changeDirectory.enter');
TempPath:= MakeAbsolutePath(Path); TempPath:= MakeAbsolutePath(Path);
AbsPath:= evaluatePath(TempPath); AbsPath:= evaluatePath(TempPath);
kfree(void(TempPath)); kfree(void(TempPath));
@ -416,6 +454,7 @@ begin
end; end;
changeDirectory:= Validity; changeDirectory:= Validity;
kfree(void(AbsPath)); kfree(void(AbsPath));
tracer.push_trace('vfs.changeDirectory.exit');
end; end;
{ VFS Functions } { VFS Functions }
@ -470,7 +509,9 @@ end;
function getWorkingDirectory : pchar; function getWorkingDirectory : pchar;
begin begin
tracer.push_trace('vfs.getWorkingDirectory.enter');
getWorkingDirectory:= CurrentDirectory; getWorkingDirectory:= CurrentDirectory;
tracer.push_trace('vfs.getWorkingDirectory.exit');
end; end;
{ Terminal Commands } { Terminal Commands }
@ -520,6 +561,7 @@ var
i : uint32; i : uint32;
begin begin
tracer.push_trace('vfs.VFS_COMMAND_CD.enter');
if ParamCount(Params) > 0 then begin if ParamCount(Params) > 0 then begin
for i:=0 to ParamCount(Params)-1 do begin for i:=0 to ParamCount(Params)-1 do begin
if i = 0 then begin if i = 0 then begin
@ -549,6 +591,7 @@ begin
end; end;
kfree(void(Path)); kfree(void(Path));
end; end;
tracer.push_trace('vfs.VFS_COMMAND_CD.exit');
end; end;
{ Init } { Init }
@ -573,10 +616,12 @@ begin
newVirtualDirectory('/disk'); newVirtualDirectory('/disk');
newVirtualDirectory('/disk/test'); newVirtualDirectory('/disk/test');
newVirtualDirectory('/disk/test/myfolder'); newVirtualDirectory('/disk/test/myfolder');
newVirtualDirectory('/disk/test/mytest');
// rel:= makeRelative('/disk/SDA/mydirectory/myfile', '/disk/SDA'); // rel:= makeRelative('/disk/SDA/mydirectory/myfile', '/disk/SDA');
// if rel <> nil then outputln('VFS', rel) else outputln('VFS', 'REL IS NULL!'); // if rel <> nil then outputln('VFS', rel) else outputln('VFS', 'REL IS NULL!');
//outputln('VFS', makeRelative('/test/mydisk/mything', '/test/mydisk'));
//while true do begin end; //while true do begin end;
terminal.registerCommand('LS', @VFS_COMMAND_LS, 'List directory contents.'); terminal.registerCommand('LS', @VFS_COMMAND_LS, 'List directory contents.');

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(true);
BSOD('AC', 'Alignment Check Exception.'); BSOD('AC', 'Alignment Check Exception.');
console.writestringln('Alignment Check Exception.'); console.writestringln('Alignment Check Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('BE', 'Breakpoint Exception.'); BSOD('BE', 'Breakpoint Exception.');
console.writestringln('Breakpoint Exception'); console.writestringln('Breakpoint Exception');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(true);
BSOD('TSS', 'Bad TSS Exception.'); BSOD('TSS', 'Bad TSS Exception.');
console.writestringln('Bad TSS Exception.'); console.writestringln('Bad TSS Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('CF', 'Coprocessor Fault Exception.'); BSOD('CF', 'Coprocessor Fault Exception.');
console.writestringln('Coprocessor Fault Exception.'); console.writestringln('Coprocessor Fault Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('CSO', 'Coprocessor Seg Overrun Exception.'); BSOD('CSO', 'Coprocessor Seg Overrun Exception.');
console.writestringln('Coprocessor Seg Overrun Exception.'); console.writestringln('Coprocessor Seg Overrun Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('DE', 'Debug Exception'); BSOD('DE', 'Debug Exception');
console.writestringln('Debug Exception.'); console.writestringln('Debug Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('DBZ', 'Divide By Zero Exception.'); BSOD('DBZ', 'Divide By Zero Exception.');
console.writestringln('Divide by Zero Exception.'); console.writestringln('Divide by Zero Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(true);
BSOD('DF', 'Double Fault.'); BSOD('DF', 'Double Fault.');
console.writestringln('Double Fault.'); console.writestringln('Double Fault.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -25,20 +25,9 @@ var
begin begin
CLI; CLI;
asm correctInterruptRegisters(true);
MOV EAX, EBP
MOV Regs, EAX
end;
BSOD('GPF', 'General Protection Fault.'); BSOD('GPF', 'General Protection Fault.');
console.writestringln('General Protection Fault.'); console.writestringln('General Protection Fault.');
console.writestring('Flags: ');
console.writehexln(Regs^.EFlags);
console.writestring('EIP: ');
console.writehexln(Regs^.EIP);
console.writestring('CS: ');
console.writehexln(Regs^.CS);
console.writestring('Error Code: ');
console.writehexln(Regs^.ErrorCode);
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('IDO', 'Into Detected Overflow Exception.'); BSOD('IDO', 'Into Detected Overflow Exception.');
console.writestringln('IDO Exception.'); console.writestringln('IDO Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('IO', 'Invalid OPCode Exception.'); BSOD('IO', 'Invalid OPCode Exception.');
console.writestringln('Invalid OPCode Exception.'); console.writestringln('Invalid OPCode Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('MC', 'Machine Check Exception.'); BSOD('MC', 'Machine Check Exception.');
console.writestringln('Machine Check Exception.'); console.writestringln('Machine Check Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('NC', 'No Coprocessor Exception.'); BSOD('NC', 'No Coprocessor Exception.');
console.writestringln('No Coprocessor Exception.'); console.writestringln('No Coprocessor Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('NMI', 'Non-Maskable Interrupt Exception.'); BSOD('NMI', 'Non-Maskable Interrupt Exception.');
console.writestringln('NMI Exception.'); console.writestringln('NMI Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('OOB', 'Out of Bouunds Exception.'); BSOD('OOB', 'Out of Bouunds Exception.');
console.writestringln('OOB Exception.'); console.writestringln('OOB Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(true);
BSOD('PF', 'Page Fault.'); BSOD('PF', 'Page Fault.');
console.writestringln('Page Fault.'); console.writestringln('Page Fault.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(true);
BSOD('SF', 'Stack Fault Exception.'); BSOD('SF', 'Stack Fault Exception.');
console.writestringln('Stack Fault Exception.'); console.writestringln('Stack Fault Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(true);
BSOD('SNS', 'Segment Not Present Exception.'); BSOD('SNS', 'Segment Not Present Exception.');
console.writestringln('Segment Not Present Exception.'); console.writestringln('Segment Not Present Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -24,6 +24,7 @@ var
begin begin
CLI; CLI;
correctInterruptRegisters(false);
BSOD('UI', 'Unknown Interrupt Exception.'); BSOD('UI', 'Unknown Interrupt Exception.');
console.writestringln('Unknown Interrupt Exception.'); console.writestringln('Unknown Interrupt Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -73,7 +73,7 @@ var
implementation implementation
uses uses
console, RTC, cpu, serial, strings; console, RTC, cpu, serial, strings, isr_types;
function MsSinceSystemBoot : uint64; function MsSinceSystemBoot : uint64;
begin begin
@ -580,12 +580,21 @@ begin
console.writestring(' Fault Info: '); console.writestring(' Fault Info: ');
console.writestringln(info); console.writestringln(info);
console.writestringln(' '); console.writestringln(' ');
if IntReg <> nil then begin
console.writestringln(' Processor Info: ');
console.writestring(' EBP: '); console.writehex(IntReg^.EBP); console.writestring(' EAX: '); console.writehex(IntReg^.EAX); console.writestring(' EBX: '); console.writehexln(IntReg^.EBX);
console.writestring(' ECX: '); console.writehex(IntReg^.ECX); console.writestring(' EDX: '); console.writehex(IntReg^.EDX); console.writestring(' ESI: '); console.writehexln(IntReg^.ESI);
console.writestring(' EDI: '); console.writehex(IntReg^.EDI); console.writestring(' DS: '); console.writehex(IntReg^.DS); console.writestring(' ES: '); console.writehexln(IntReg^.ES);
console.writestring(' FS: '); console.writehex(IntReg^.FS); console.writestring(' GS: '); console.writehex(IntReg^.GS); console.writestring(' ERROR: '); console.writehexln(IntErr^.Error);
console.writestring(' EIP: '); console.writehex(IntSpec^.EIP); console.writestring(' CS: '); console.writehex(IntSpec^.CS); console.writestring(' EFLAGS: '); console.writehexln(IntSpec^.EFLAGS);
console.writestringln(' ');
end;
console.writestring(' Call Stack: '); console.writestring(' Call Stack: ');
trace:= tracer.get_last_trace; trace:= tracer.get_last_trace;
if trace <> nil then begin if trace <> nil then begin
console.writestring('[-0] '); console.writestring('[-0] ');
console.writestringln(trace); console.writestringln(trace);
for i:=1 to tracer.get_trace_count-1 do begin for i:=1 to tracer.get_trace_count-7 do begin
trace:= tracer.get_trace_N(i); trace:= tracer.get_trace_N(i);
if trace <> nil then begin if trace <> nil then begin
console.writestring(' ['); console.writestring(' [');

View File

@ -12,6 +12,33 @@ const
MAX_HOOKS = 16; MAX_HOOKS = 16;
type type
TInterruptRegisters = packed record
EBP : uint32;
EAX : uint32;
EBX : uint32;
ECX : uint32;
EDX : uint32;
ESI : uint32;
EDI : uint32;
DS : uint32;
ES : uint32;
FS : uint32;
GS : uint32;
end;
PInterruptRegisters = ^TInterruptRegisters;
TError = packed record
Error : uint32;
end;
PError = ^TError;
TInterruptSpecialRegisters = packed record
EIP : uint32;
CS : uint32;
EFLAGS : uint32;
end;
PInterruptSpecialRegisters = ^TInterruptSpecialRegisters;
PRegisters = ^TRegisters; PRegisters = ^TRegisters;
TRegisters = record TRegisters = record
edi,esi,ebp,esp,ebx,edx,ecx,eax: uint32; edi,esi,ebp,esp,ebx,edx,ecx,eax: uint32;
@ -22,6 +49,27 @@ type
pp_hook_method = procedure(data : void); pp_hook_method = procedure(data : void);
pp_void = pp_hook_method; pp_void = pp_hook_method;
var
IntReg : PInterruptRegisters = nil;
IntSpec : PInterruptSpecialRegisters = nil;
IntErr : PError = nil;
ZeroError : uint32 = 0;
procedure correctInterruptRegisters(Errorcode : boolean);
implementation implementation
procedure correctInterruptRegisters(Errorcode : boolean);
begin
if IntReg <> nil then begin
If errorcode then begin
IntSpec:= PInterruptSpecialRegisters(uint32(IntReg) + uint32(SizeOf(TInterruptRegisters)) + uint32(Sizeof(TError)));
IntErr:= PError(uint32(IntReg) + uint32(sizeof(TInterruptRegisters)));
end else begin
IntSpec:= PInterruptSpecialRegisters(uint32(IntReg) + uint32(SizeOf(TInterruptRegisters)));
IntErr:= PError(@ZeroError);
end;
end;
end;
end. end.

File diff suppressed because it is too large Load Diff

View File

@ -202,6 +202,9 @@ begin
{ Filsystems } { Filsystems }
fat32.init(); fat32.init();
i:= 0;
i:= i div i;
{ Device Drivers } { Device Drivers }
tracer.push_trace('kmain.DEVDRV'); tracer.push_trace('kmain.DEVDRV');
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.'); console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.');
@ -304,6 +307,7 @@ begin
// iret; // iret;
// end; // end;
while true do begin while true do begin
tracer.push_trace('kmain.RedrawWindows'); tracer.push_trace('kmain.RedrawWindows');
console.redrawWindows; console.redrawWindows;