Terminal command registration.

git-svn-id: https://spexeah.com:8443/svn/Asuro@221 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron
2017-10-23 09:58:14 +00:00
parent 30877e5d94
commit 9daebbf49b
13 changed files with 82 additions and 38 deletions

View File

@ -97,13 +97,13 @@ procedure force_alloc_block(block : uint16; caller : uint32);
begin
PhysicalMemory[block].Allocated:= True;
PhysicalMemory[block].MappedTo:= caller;
console.writestring('PMM: 4MiB Block Force Allocated @ ');
console.writeword(block);
console.writestring(' [');
console.writehex(block SHL 22);
console.writestring(' - ');
console.writehex(((block+1) SHL 22));
console.writestringln(']');
// console.writestring('PMM: 4MiB Block Force Allocated @ ');
// console.writeword(block);
// console.writestring(' [');
// console.writehex(block SHL 22);
// console.writestring(' - ');
// console.writehex(((block+1) SHL 22));
// console.writestringln(']');
end;
procedure init;
@ -128,13 +128,13 @@ begin
end else begin
PhysicalMemory[block].Allocated:= True;
PhysicalMemory[block].MappedTo:= caller;
console.writestring('PMM: 4MiB Block Allocated @ ');
console.writeword(block);
console.writestring(' [');
console.writehex(block SHL 22);
console.writestring(' - ');
console.writehex(((block+1) SHL 22));
console.writestringln(']');
// console.writestring('PMM: 4MiB Block Allocated @ ');
// console.writeword(block);
// console.writestring(' [');
// console.writehex(block SHL 22);
// console.writestring(' - ');
// console.writehex(((block+1) SHL 22));
// console.writestringln(']');
alloc_block:= true;
end;
end else begin

View File

@ -7,14 +7,55 @@ uses
keyboard,
util;
type
TCommandBuffer = array[0..1023] of byte;
TCommandMethod = procedure(buf : TCommandBuffer);
TCommand = record
registered : boolean;
command : pchar;
method : TCommandMethod;
end;
var
buffer : array[0..1023] of byte;
bIndex : uint32 = 0;
buffer : TCommandBuffer;
bIndex : uint32 = 0;
Commands : array[0..65534] of TCommand;
procedure run;
procedure registerCommand(command : pchar; method : TCommandMethod);
implementation
procedure version(buffer : TCommandBuffer);
begin
writestringln('Asuro v1.0');
end;
procedure registerCommand(command : pchar; method : TCommandMethod);
var
index : uint32;
begin
index:= 0;
while Commands[index].registered = true do inc(index);
Commands[index].registered:= true;
Commands[index].Command:= command;
Commands[index].method:= method;
end;
procedure upper;
var
i : uint32;
begin
for i:=0 to bIndex do begin
if char(buffer[i]) = ' ' then exit;
if (buffer[i] >= 97) and (buffer[i] <= 122) then begin
buffer[i]:= buffer[i] - 32;
end;
end;
end;
function isCommand(command : pchar) : boolean;
var
i : uint32;
@ -33,18 +74,19 @@ end;
procedure process_command;
var
fallthrough : boolean;
i : uint32;
begin
console.writecharln(' ');
//Process Here
fallthrough:= true;
if isCommand('version') then begin
console.writestringln('Asuro v1.0');
fallthrough:= false;
end;
if isCommand('clear') then begin
console.clear();
fallthrough:= false;
upper;
for i:=0 to 65534 do begin
if Commands[i].registered then begin
if isCommand(Commands[i].command) then begin
Commands[i].method(buffer);
fallthrough:= false;
end;
end;
end;
if fallthrough then begin
console.writestringln('Unknown Command.');
@ -77,7 +119,9 @@ end;
procedure run;
begin
memset(uint32(@Commands[0]), 0, 65535*sizeof(TCommand));
memset(uint32(@buffer[0]), 0, 1024);
registerCommand('VERSION', @version);
keyboard.hook(@key_event);
console.clear();
console.writestring('Asuro#> ');

View File

@ -112,22 +112,22 @@ begin
PD^[page_number].PageSize:= true;
PD^[page_number].Writable:= true;
console.writestringln('VMM: New Page Added:');
//console.writestringln('VMM: New Page Added:');
console.writestring('VMM: - P:');
console.writehex(page_number);
console.writestring('-->B:');
console.writehexln(block);
//console.writestring('VMM: - P:');
//console.writehex(page_number);
// console.writestring('-->B:');
// console.writehexln(block);
console.writestring('VMM: - P:[');
console.writehex(page_number SHL 22);
console.writestring(' - ');
console.writehex(((page_number+1) SHL 22));
console.writestring(']-->B:[');
console.writehex(block SHL 22);
console.writestring(' - ');
console.writehex(((block+1) SHL 22));
console.writestringln(']');
// console.writestring('VMM: - P:[');
// console.writehex(page_number SHL 22);
// console.writestring(' - ');
// console.writehex(((page_number+1) SHL 22));
// console.writestring(']-->B:[');
// console.writehex(block SHL 22);
// console.writestring(' - ');
// console.writehex(((block+1) SHL 22));
// console.writestringln(']');
map_page_ex:= true;
end;