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

This commit is contained in:
kieron 2018-05-02 17:17:58 +00:00
parent 191f0a8159
commit b42c7641e6
35 changed files with 265 additions and 165 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,8 +7,8 @@ uses
procedure copyMAC(src : puint8; dst : puint8); procedure copyMAC(src : puint8; dst : puint8);
procedure copyIPv4(src : puint8; dst : puint8); procedure copyIPv4(src : puint8; dst : puint8);
procedure writeMACAddress(mac : puint8); procedure writeMACAddress(mac : puint8; WND : HWND);
procedure writeIPv4Address(ip : puint8); procedure writeIPv4Address(ip : puint8; WND : HWND);
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean; function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
function IPEqual(ip1 : puint8; ip2 : puint8) : boolean; function IPEqual(ip1 : puint8; ip2 : puint8) : boolean;
function newPacketContext : PPacketContext; function newPacketContext : PPacketContext;
@ -48,33 +48,33 @@ begin
pop_trace; pop_trace;
end; end;
procedure writeIPv4Address(ip : puint8); procedure writeIPv4Address(ip : puint8; WND : HWND);
var var
i : integer; i : integer;
begin begin
push_trace('netutils.writeIPv4Address'); push_trace('netutils.writeIPv4Address');
console.writeint(ip[0]); console.writeintWND(ip[0], WND);
for i:=1 to 3 do begin for i:=1 to 3 do begin
console.writestring('.'); console.writestringWND('.', WND);
console.writeint(ip[i]); console.writeintWND(ip[i], WND);
end; end;
console.writestringln(' '); console.writestringlnWND(' ', WND);
pop_trace; pop_trace;
end; end;
procedure writeMACAddress(mac : puint8); procedure writeMACAddress(mac : puint8; WND : HWND);
var var
i : integer; i : integer;
begin begin
push_trace('netutils.writeMACAddress'); push_trace('netutils.writeMACAddress');
console.writehexpair(mac[0]); console.writehexpairWND(mac[0], WND);
for i:=1 to 5 do begin for i:=1 to 5 do begin
console.writestring(':'); console.writestringWND(':', WND);
console.writehexpair(mac[i]); console.writehexpairWND(mac[i], WND);
end; end;
console.writestringln(' '); console.writestringlnWND(' ', WND);
pop_trace; pop_trace;
end; end;

View File

@ -71,18 +71,18 @@ begin
push_trace('ipv4.terminal_command_ifconfig'); 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: '); writestringWND(' MAC: ', getTerminalHWND);
writeMACAddress(net.GetMAC); writeMACAddress(net.GetMAC, getTerminalHWND);
writestring(' IPv4: '); writestringWND(' IPv4: ', getTerminalHWND);
writeIPv4Address(@Config.Address[0]); writeIPv4Address(@Config.Address[0], getTerminalHWND);
writestring(' Gateway: '); writestringWND(' Gateway: ', getTerminalHWND);
writeIPv4Address(@Config.Gateway[0]); writeIPv4Address(@Config.Gateway[0], getTerminalHWND);
writestring(' Netmask: '); writestringWND(' Netmask: ', getTerminalHWND);
writeIPv4Address(@Config.Netmask[0]); writeIPv4Address(@Config.Netmask[0], getTerminalHWND);
if Config.UP then if Config.UP then
writestringln(' NetUP: true') writestringlnWND(' NetUP: true', getTerminalHWND)
else else
writestringln(' NetUP: false'); writestringlnWND(' NetUP: false', getTerminalHWND);
end; end;
pop_trace; pop_trace;
end; end;

View File

@ -438,7 +438,7 @@ end;
procedure console_command_mac(params : PParamList); procedure console_command_mac(params : PParamList);
begin begin
push_trace('E1000.console_command_mac'); push_trace('E1000.console_command_mac');
writeMACAddress(@mac[0]); writeMACAddress(@mac[0], getTerminalHWND);
pop_trace; pop_trace;
end; end;
@ -474,6 +474,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);
writeStringlnWND('E1000 ARP Testpacket Sent.', getTerminalHWND);
pop_trace; pop_trace;
end; end;
@ -513,7 +514,7 @@ begin
load:= false; load:= false;
end else begin end else begin
console.output('E1000 Driver', 'MAC Address: '); console.output('E1000 Driver', 'MAC Address: ');
writeMACAddress(@mac[0]); writeMACAddress(@mac[0], 0);
startLink(); startLink();

View File

@ -255,8 +255,8 @@ begin
fileSystems:= ll_New(sizeof(TFilesystem)); fileSystems:= ll_New(sizeof(TFilesystem));
terminal.registerCommand('DISK', @disk_command, 'Disk utility'); terminal.registerCommand('DISK', @disk_command, 'Disk utility');
terminal.registerCommand('VOLUME', @volume_command, 'Volume utility'); terminal.registerCommand('VOLUME', @volume_command, 'Volume utility');
terminal.registerCommand('mkdir', @mkdir_command, 'Volume utility'); terminal.registerCommandEx('mkdir', @mkdir_command, 'Volume utility', true);
terminal.registerCommand('ls', @ls_command, 'Volume utility'); terminal.registerCommandEx('ls', @ls_command, 'Volume utility', true);
pop_trace(); pop_trace();
end; end;

View File

@ -67,15 +67,15 @@ var
implementation implementation
procedure writeBusType(Bus : TBusIdentifier); procedure writeBusType(Bus : TBusIdentifier; WND : HWND);
begin begin
case Bus of case Bus of
biUnknown : console.writestring('Unknown'); biUnknown : console.writestringWND('Unknown', WND);
biANY : console.writestring('ANY'); biANY : console.writestringWND('ANY', WND);
bii2c : console.writestring('i2c'); bii2c : console.writestringWND('i2c', WND);
biPCI : console.writestring('PCI'); biPCI : console.writestringWND('PCI', WND);
biPCIe : console.writestring('PCIe'); biPCIe : console.writestringWND('PCIe', WND);
biUSB : console.writestring('USB'); biUSB : console.writestringWND('USB', WND);
end; end;
end; end;
@ -93,29 +93,29 @@ begin
i:= 1; i:= 1;
while Drv <> nil do begin while Drv <> nil do begin
if Drv^.Loaded then begin if Drv^.Loaded then begin
console.writeint(i); console.writeintWND(i, getTerminalHWND);
console.writestring(') '); console.writestringWND(') ', getTerminalHWND);
console.writestring(Drv^.Driver_Name); console.writestringWND(Drv^.Driver_Name, getTerminalHWND);
console.writestring(' - Bus: '); console.writestringWND(' - Bus: ', getTerminalHWND);
writeBusType(Drv^.Identifier^.Bus); writeBusType(Drv^.Identifier^.Bus, getTerminalHWND);
console.writestringln(' '); console.writestringlnWND(' ', getTerminalHWND);
console.writestring(' ['); console.writestringWND(' [', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id0); console.writeHexWND(Drv^.Identifier^.id0, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id1); console.writeHexWND(Drv^.Identifier^.id1, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id2); console.writeHexWND(Drv^.Identifier^.id2, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id3); console.writeHexWND(Drv^.Identifier^.id3, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id4); console.writeHexWND(Drv^.Identifier^.id4, getTerminalHWND);
ex:= Drv^.Identifier^.ex; ex:= Drv^.Identifier^.ex;
while ex <> nil do begin while ex <> nil do begin
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(ex^.idN); console.writeHexWND(ex^.idN, getTerminalHWND);
ex:= ex^.ex; ex:= ex^.ex;
end; end;
console.writestringln(']'); console.writestringlnWND(']', getTerminalHWND);
i:= i + 1; i:= i + 1;
end; end;
Drv:= Drv^.Next; Drv:= Drv^.Next;
@ -134,30 +134,30 @@ begin
Drv:= Root; Drv:= Root;
i:= 1; i:= 1;
while Drv <> nil do begin while Drv <> nil do begin
console.writeint(i); console.writeintWND(i, getTerminalHWND);
console.writestring(') '); console.writestringWND(') ', getTerminalHWND);
console.writestring(Drv^.Driver_Name); console.writestringWND(Drv^.Driver_Name, getTerminalHWND);
console.writestring(' - Bus: '); console.writestringWND(' - Bus: ', getTerminalHWND);
writeBusType(Drv^.Identifier^.Bus); writeBusType(Drv^.Identifier^.Bus, getTerminalHWND);
console.writestring(' - Loaded: '); console.writestringWND(' - Loaded: ', getTerminalHWND);
if Drv^.Loaded then console.writestringln('true') else console.writestringln('false'); if Drv^.Loaded then console.writestringlnWND('true', getTerminalHWND) else console.writestringlnWND('false', getTerminalHWND);
console.writestring(' ['); console.writestringWND(' [', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id0); console.writeHexWND(Drv^.Identifier^.id0, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id1); console.writeHexWND(Drv^.Identifier^.id1, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id2); console.writeHexWND(Drv^.Identifier^.id2, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id3); console.writeHexWND(Drv^.Identifier^.id3, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Drv^.Identifier^.id4); console.writeHexWND(Drv^.Identifier^.id4, getTerminalHWND);
ex:= Drv^.Identifier^.ex; ex:= Drv^.Identifier^.ex;
while ex <> nil do begin while ex <> nil do begin
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(ex^.idN); console.writeHexWND(ex^.idN, getTerminalHWND);
ex:= ex^.ex; ex:= ex^.ex;
end; end;
console.writestringln(']'); console.writestringlnWND(']', getTerminalHWND);
i:= i + 1; i:= i + 1;
Drv:= Drv^.Next; Drv:= Drv^.Next;
end; end;
@ -175,35 +175,35 @@ begin
Dv:= Dev; Dv:= Dev;
i:= 1; i:= 1;
while Dv <> nil do begin while Dv <> nil do begin
console.writeint(i); console.writeintWND(i, getTerminalHWND);
console.writestring(') '); console.writestringWND(') ', getTerminalHWND);
console.writestring(Dv^.Device_Name); console.writestringWND(Dv^.Device_Name, getTerminalHWND);
console.writestring(' - Bus: '); console.writestringWND(' - Bus: ', getTerminalHWND);
writeBusType(Dv^.Identifier^.Bus); writeBusType(Dv^.Identifier^.Bus, getTerminalHWND);
console.writestringln(' '); console.writestringlnWND(' ', getTerminalHWND);
console.writestring(' ['); console.writestringWND(' [', getTerminalHWND);
console.writeHex(Dv^.Identifier^.id0); console.writeHexWND(Dv^.Identifier^.id0, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Dv^.Identifier^.id1); console.writeHexWND(Dv^.Identifier^.id1, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Dv^.Identifier^.id2); console.writeHexWND(Dv^.Identifier^.id2, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Dv^.Identifier^.id3); console.writeHexWND(Dv^.Identifier^.id3, getTerminalHWND);
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(Dv^.Identifier^.id4); console.writeHexWND(Dv^.Identifier^.id4, getTerminalHWND);
ex:= Dv^.Identifier^.ex; ex:= Dv^.Identifier^.ex;
while ex <> nil do begin while ex <> nil do begin
console.writestring('-'); console.writestringWND('-', getTerminalHWND);
console.writeHex(ex^.idN); console.writeHexWND(ex^.idN, getTerminalHWND);
ex:= ex^.ex; ex:= ex^.ex;
end; end;
console.writestringln(']'); console.writestringlnWND(']', getTerminalHWND);
if Dv^.Driver_Loaded then begin if Dv^.Driver_Loaded then begin
console.writestring(' Driver Loaded: '); console.writestringWND(' Driver Loaded: ', getTerminalHWND);
if Dv^.Driver <> nil then begin if Dv^.Driver <> nil then begin
console.writestringln(Dv^.Driver^.Driver_Name); console.writestringlnWND(Dv^.Driver^.Driver_Name, getTerminalHWND);
end else begin end else begin
console.writestringln('Unknown') console.writestringlnWND('Unknown', getTerminalHWND)
end; end;
end; end;
i:= i + 1; i:= i + 1;
@ -212,6 +212,35 @@ begin
pop_trace; pop_trace;
end; end;
procedure terminal_command_dev(Params : PParamList);
var
p1 : pchar;
begin
if paramCount(Params) > 0 then begin
p1:= getParam(0, Params);
if StringEquals(p1, 'drivers') then begin
terminal_command_drivers(Params);
end;
if StringEquals(p1, 'devices') then begin
terminal_command_devices(Params);
end;
if StringEquals(p1, 'driverex') then begin
terminal_command_driversex(Params);
end;
end else begin
writeStringlnWND('Driver Management Interface', getTerminalHWND);
writeStringlnWND(' ', getTerminalHWND);
writeStringlnWND('An interface to the drivermanagement portion of the kernel.', getTerminalHWND);
writeStringlnWND(' ', getTerminalHWND);
writeStringlnWND('Usage: ', getTerminalHWND);
writeStringlnWND(' dev drivers - Print a list of loaded drivers.', getTerminalHWND);
writeStringlnWND(' dev devices - Print a list of registered devices.', getTerminalHWND);
writeStringlnWND(' dev driverex - Print a list of all available drivers.', getTerminalHWND);
writeStringlnWND(' ', getTerminalHWND)
end;
end;
{ Main Functions } { Main Functions }
function copy_identifier(DeviceID : PDeviceIdentifier) : PDeviceIdentifier; function copy_identifier(DeviceID : PDeviceIdentifier) : PDeviceIdentifier;
@ -288,9 +317,10 @@ end;
procedure init; procedure init;
begin begin
push_trace('driver_management.init'); push_trace('driver_management.init');
terminal.registerCommand('DRIVERSEX', @terminal_command_driversex, 'List all available drivers.'); terminal.registerCommand('DEV', @terminal_command_dev, 'Driver Management Interface.');
terminal.registerCommand('DRIVERS', @terminal_command_drivers, 'List loaded drivers.'); //terminal.registerCommand('DRIVERSEX', @terminal_command_driversex, 'List all available drivers.');
terminal.registerCommand('DEVICES', @terminal_command_devices, 'List devices.'); //terminal.registerCommand('DRIVERS', @terminal_command_drivers, 'List loaded drivers.');
//terminal.registerCommand('DEVICES', @terminal_command_devices, 'List devices.');
pop_trace; pop_trace;
end; end;

View File

@ -3,11 +3,11 @@ unit asuro;
interface interface
const const
VERSION = '1.0.0-645a'; VERSION = '1.0.0-649a';
VERSION_MAJOR = '1'; VERSION_MAJOR = '1';
VERSION_MINOR = '0'; VERSION_MINOR = '0';
VERSION_SUB = '0'; VERSION_SUB = '0';
REVISION = '645'; REVISION = '649';
RELEASE = 'a'; RELEASE = 'a';
implementation implementation

View File

@ -12,23 +12,15 @@ unit kernel;
interface interface
uses uses
multiboot, multiboot, bios_data_area,
util, util,
gdt, gdt, idt, isr, irq, tss,
idt,
isr,
irq,
TMR_0_ISR, TMR_0_ISR,
console, console,
bios_data_area, keyboard, mouse,
keyboard, vmemorymanager, pmemorymanager, lmemorymanager,
mouse,
vmemorymanager,
pmemorymanager,
lmemorymanager,
tracer, tracer,
drivermanagement, drivermanagement,
tss,
scheduler, scheduler,
PCI, PCI,
Terminal, Terminal,
@ -54,24 +46,19 @@ procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
implementation implementation
procedure temphook(ignored : TKeyInfo);
begin
Terminal.run;
end;
procedure terminal_command_meminfo(params : PParamList); procedure terminal_command_meminfo(params : PParamList);
begin begin
push_trace('kernel.terminal_command_meminfo'); push_trace('kernel.terminal_command_meminfo');
console.writestring('Lower Memory = '); console.writestringWND('Lower Memory = ', getTerminalHWND);
console.writeint(multibootinfo^.mem_lower); console.writeintWND(multibootinfo^.mem_lower, getTerminalHWND);
console.writestringln('KB'); console.writestringlnWND('KB', getTerminalHWND);
console.writestring('Higher Memory = '); console.writestringWND('Higher Memory = ', getTerminalHWND);
console.writeint(multibootinfo^.mem_upper); console.writeintWND(multibootinfo^.mem_upper, getTerminalHWND);
console.writestringln('KB'); console.writestringlnWND('KB', getTerminalHWND);
console.writestring('Total Memory = '); console.writestringWND('Total Memory = ', getTerminalHWND);
console.writeint(((multibootinfo^.mem_upper + 1000) div 1024) + 1); console.writeintWND(((multibootinfo^.mem_upper + 1000) div 1024) + 1, getTerminalHWND);
console.writestringln('MB'); console.writestringlnWND('MB', getTerminalHWND);
pop_trace; pop_trace;
end; end;
@ -83,8 +70,8 @@ begin
if ParamCount(params) > 1 then begin if ParamCount(params) > 1 then begin
bsod(getparam(0, params), getparam(1, params)); bsod(getparam(0, params), getparam(1, params));
end else begin end else begin
console.writestringln('Invalid number of params.'); console.writestringlnWND('Invalid number of params.', getTerminalHWND);
console.writestringln('Usage: bsod <error> <info>'); console.writestringlnWND('Usage: bsod <error> <info>', getTerminalHWND);
end; end;
pop_trace; pop_trace;
@ -157,7 +144,8 @@ begin
{ Console Init } { Console Init }
console.init(); console.init();
//serial.init(); { Serial Init }
serial.init();
{ Call Tracer } { Call Tracer }
tracer.init(); tracer.init();
@ -209,9 +197,6 @@ begin
console.setdefaultattribute(console.combinecolors($17E0, $0000)); console.setdefaultattribute(console.combinecolors($17E0, $0000));
console.writestringln('Asuro Booted Correctly!'); console.writestringln('Asuro Booted Correctly!');
console.setdefaultattribute(console.combinecolors($FFFF, $0000)); console.setdefaultattribute(console.combinecolors($FFFF, $0000));
//console.writestringln('');
//console.writestringln('Press any key to boot in to Asuro Terminal...');
//tracer.pop_trace;
{ Init Progs } { Init Progs }
shell.init(); shell.init();
@ -220,11 +205,6 @@ begin
{ Init Splash } { Init Splash }
splash.init(); splash.init();
//console.writehexln(uint32(multibootinfo^.framebuffer_addr));
//tracer.push_trace('kmain.KEYHOOK');
//keyboard.hook(@temphook);
//tracer.pop_trace;
tracer.push_trace('kmain.END'); tracer.push_trace('kmain.END');
while true do begin while true do begin

View File

@ -80,7 +80,14 @@ var
begin begin
tracer.push_trace('memview.run'); tracer.push_trace('memview.run');
if ParamCount(Params) < 1 then begin if ParamCount(Params) < 1 then begin
writestringlnWND('No memory location specified!', getTerminalHWND); writestringlnWND('Memview Utility', getTerminalHWND);
writestringlnWND(' ', getTerminalHWND);
writestringlnWND('A tool to display the bytes stored at a memory location for debugging.', getTerminalHWND);
writestringlnWND('UP/DOWN on the keyboard can be used to decrement/increment the view location by 16-bytes.', getTerminalHWND);
writestringlnWND(' ', getTerminalHWND);
writestringlnWND('Usage: ', getTerminalHWND);
writestringlnWND(' memview <dLocation> - Display 176 bytes @ <dLocation>', getTerminalHWND);
writestringlnWND(' ', getTerminalHWND);
end else begin end else begin
loc:= GetParam(0, Params); loc:= GetParam(0, Params);
if StringEquals(loc, 'close') then begin if StringEquals(loc, 'close') then begin

View File

@ -37,6 +37,7 @@ type
TCommandMethod = procedure(params : PParamList); TCommandMethod = procedure(params : PParamList);
TCommand = record TCommand = record
registered : boolean; registered : boolean;
hidden : boolean;
command : pchar; command : pchar;
method : TCommandMethod; method : TCommandMethod;
description : pchar; description : pchar;
@ -52,6 +53,7 @@ var
procedure run; procedure run;
procedure init; procedure init;
procedure registerCommand(command : pchar; method : TCommandMethod; description : pchar); procedure registerCommand(command : pchar; method : TCommandMethod; description : pchar);
procedure registerCommandEx(command : pchar; method : TCommandMethod; description : pchar; hide : boolean);
function getParams(buf : TCommandBuffer) : PParamList; function getParams(buf : TCommandBuffer) : PParamList;
function paramCount(params : PParamList) : uint32; function paramCount(params : PParamList) : uint32;
function getParam(index : uint32; params : PParamList) : pchar; function getParam(index : uint32; params : PParamList) : pchar;
@ -209,15 +211,27 @@ end;
procedure help(params : PParamList); procedure help(params : PParamList);
var var
i, j : uint32;
longestCommand : uint32;
len : uint32;
i : uint32;
begin begin
longestCommand:= 0;
for i:=0 to 65534 do begin
if (Commands[i].Registered) and not(Commands[i].hidden) then begin
if stringSize(Commands[i].command) > longestCommand then longestCommand:= stringSize(Commands[i].command);
end;
end;
console.writestringlnWND('Registered Commands: ', TERMINAL_HWND); console.writestringlnWND('Registered Commands: ', TERMINAL_HWND);
for i:=0 to 65534 do begin for i:=0 to 65534 do begin
if Commands[i].Registered then begin if (Commands[i].Registered) and not(Commands[i].hidden) then begin
console.writestringWND(' ', TERMINAL_HWND); console.writestringWND(' ', TERMINAL_HWND);
console.writestringWND(Commands[i].command, TERMINAL_HWND); console.writestringWND(Commands[i].command, TERMINAL_HWND);
console.writestringWND(' - ', TERMINAL_HWND); len:= longestCommand - StringSize(Commands[i].command);
for j:=0 to len do begin
writeStringWND(' ', TERMINAL_HWND);
end;
console.writestringWND('- ', TERMINAL_HWND);
console.writestringlnWND(Commands[i].description, TERMINAL_HWND); console.writestringlnWND(Commands[i].description, TERMINAL_HWND);
end; end;
end; end;
@ -282,6 +296,21 @@ begin
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].hidden:= false;
Commands[index].method:= method;
Commands[index].description:= description;
end;
procedure registerCommandEx(command : pchar; method : TCommandMethod; description : pchar; hide : boolean);
var
index : uint32;
begin
index:= 0;
while Commands[index].registered = true do inc(index);
Commands[index].registered:= true;
Commands[index].Command:= command;
Commands[index].hidden:= hide;
Commands[index].method:= method; Commands[index].method:= method;
Commands[index].description:= description; Commands[index].description:= description;
end; end;
@ -408,12 +437,8 @@ begin
registerCommand('CLEAR', @clear, 'Clear the Screen.'); registerCommand('CLEAR', @clear, 'Clear the Screen.');
registerCommand('HELP', @help, 'Lists all registered commands and their description.'); registerCommand('HELP', @help, 'Lists all registered commands and their description.');
registerCommand('ECHO', @echo, 'Echo''s text to the terminal.'); registerCommand('ECHO', @echo, 'Echo''s text to the terminal.');
registerCommand('TESTPARAMS', @testParams, 'Tests param parsing.');
registerCommand('TEST', @test, 'Command for testing.');
registerCommand('CD', @change_dir, 'Change Directory test.');
registerCommand('PATTERN', @cockwomble, 'Print an animated pattern to the screen.');
registerCommand('TIME', @printTime, 'Print the current time.'); registerCommand('TIME', @printTime, 'Print the current time.');
registerCommand('SERIAL', @SendSerial, 'Send ''helloworld'' through COM1.'); registerCommandEx('SERIAL', @SendSerial, 'Send ''helloworld'' through COM1.', true);
registerCommand('REBOOT', @Reboot, 'Reboot the system.'); registerCommand('REBOOT', @Reboot, 'Reboot the system.');
console.writestringln('TERMINAL: INIT END.'); console.writestringln('TERMINAL: INIT END.');
end; end;
@ -426,7 +451,7 @@ end;
procedure run; procedure run;
begin begin
if TERMINAL_HWND = 0 then begin if TERMINAL_HWND = 0 then begin
TERMINAL_HWND:= newWindow(20, 10, 90, 20, 'ASURO TERMINAL'); TERMINAL_HWND:= newWindow(20, 10, 90, 30, 'ASURO TERMINAL');
console.registerEventHandler(TERMINAL_HWND, EVENT_KEY_PRESSED, void(@key_event)); console.registerEventHandler(TERMINAL_HWND, EVENT_KEY_PRESSED, void(@key_event));
console.registerEventHandler(TERMINAL_HWND, EVENT_CLOSE, void(@OnClose)); console.registerEventHandler(TERMINAL_HWND, EVENT_CLOSE, void(@OnClose));
console.clearWND(TERMINAL_HWND); console.clearWND(TERMINAL_HWND);

View File

@ -85,20 +85,20 @@ var
list : PScheduler_Entry; list : PScheduler_Entry;
begin begin
console.writestringln('ThreadID - Priority - Delta'); console.writestringlnWND('ThreadID - Priority - Delta', getTerminalHWND);
list:= Root_Task; list:= Root_Task;
console.writeint(list^.ThreadID); console.writeintWND(list^.ThreadID, getTerminalHWND);
console.writestring(' - '); console.writestringWND(' - ', getTerminalHWND);
console.writeint(list^.Priority); console.writeintWND(list^.Priority, getTerminalHWND);
console.writestring(' - '); console.writestringWND(' - ', getTerminalHWND);
console.writeintln(list^.Delta); console.writeintlnWND(list^.Delta, getTerminalHWND);
list:= PScheduler_Entry(list^.Next); list:= PScheduler_Entry(list^.Next);
while list <> Root_Task do begin while list <> Root_Task do begin
console.writeint(list^.ThreadID); console.writeintWND(list^.ThreadID, getTerminalHWND);
console.writestring(' - '); console.writestringWND(' - ', getTerminalHWND);
console.writeint(list^.Priority); console.writeintWND(list^.Priority, getTerminalHWND);
console.writestring(' - '); console.writestringWND(' - ', getTerminalHWND);
console.writeintln(list^.Delta); console.writeintlnWND(list^.Delta, getTerminalHWND);
list:= PScheduler_Entry(list^.Next); list:= PScheduler_Entry(list^.Next);
end; end;
end; end;
@ -115,7 +115,7 @@ begin
Tick:= 0; Tick:= 0;
Active:= False; Active:= False;
TMR_0_ISR.hook(uint32(@delta)); TMR_0_ISR.hook(uint32(@delta));
terminal.registerCommand('TASKS', @terminal_command_tasks, 'List Active Processes.'); //terminal.registerCommand('TASKS', @terminal_command_tasks, 'List Active Processes.');
console.outputln('SCHEDULER','INIT END.'); console.outputln('SCHEDULER','INIT END.');
end; end;

View File

@ -13,7 +13,7 @@ function get_trace_N(idx : uint32) : pchar;
implementation implementation
uses uses
console, lmemorymanager, util, strings, serial; console, lmemorymanager, util, strings, serial, terminal;
const const
MAX_TRACE = 40; MAX_TRACE = 40;
@ -22,6 +22,60 @@ var
t_ready : Boolean; t_ready : Boolean;
Locked : Boolean; Locked : Boolean;
Traces : Array[0..MAX_TRACE-1] of PChar; Traces : Array[0..MAX_TRACE-1] of PChar;
c_lock : Boolean = false;
procedure terminal_command_tracer(Params : PParamList);
var
p1, p2 : PChar;
count : uint32;
i : uint32;
t : PChar;
begin
if ParamCount(Params) > 0 then begin
p1:= getParam(0, Params);
if StringEquals(p1, 'list') then begin
count:= 5;
if ParamCount(Params) > 1 then begin
count:= stringToInt(getParam(1, Params));
if count > MAX_TRACE-1 then count:= MAX_TRACE-1;
end;
for i:=0 to count do begin
writeStringWND('[-', getTerminalHWND);
writeintWND(i, getTerminalHWND);
writeStringWND('] ', getTerminalHWND);
t:= get_trace_N(i);
if t <> nil then writeStringWND(t, getTerminalHWND);
writeStringLnWND(' ', getTerminalHWND);
end;
end;
if StringEquals(p1, 'disable') then begin
if TRACER_ENABLE then begin
t_ready:= false;
writeStringLnWND('Tracer disabled.', getTerminalHWND);
end else begin
writeStringLnWND('Tracer is disabled by the system and it''s status cannot be changed.', getTerminalHWND);
end;
end;
if StringEquals(p1, 'enable') then begin
if TRACER_ENABLE then begin
t_ready:= true;
writeStringLnWND('Tracer enabled.', getTerminalHWND);
end else begin
writeStringLnWND('Tracer is disabled by the system and it''s status cannot be changed.', getTerminalHWND);
end;
end;
end else begin
writeStringLnWND('System Trace Utility', getTerminalHWND);
writeStringLnWND(' ', getTerminalHWND);
writeStringLnWND('Usage: ', getTerminalHWND);
writeStringLnWND(' tracer list <Count> - Print the last <count> traces.', getTerminalHWND);
writeStringLnWND(' tracer disable - Disable Tracer.', getTerminalHWND);
writeStringLnWND(' tracer enable - Enable Tracer.', getTerminalHWND);
writeStringLnWND(' ', getTerminalHWND);
end;
end;
procedure freeze; procedure freeze;
begin begin
@ -36,13 +90,15 @@ begin
if TRACER_ENABLE then begin if TRACER_ENABLE then begin
if t_ready then begin if t_ready then begin
if not Locked then begin if not Locked then begin
Locked:= true; if not c_lock then begin
if Traces[MAX_TRACE-1] <> nil then kfree(void(Traces[MAX_TRACE-1])); Locked:= true;
for i:=MAX_TRACE-1 downto 1 do begin if Traces[MAX_TRACE-1] <> nil then kfree(void(Traces[MAX_TRACE-1]));
Traces[i]:= Traces[i-1]; for i:=MAX_TRACE-1 downto 1 do begin
Traces[i]:= Traces[i-1];
end;
Traces[0]:= StringCopy(t_name);
Locked:= false;
end; end;
Traces[0]:= StringCopy(t_name);
Locked:= false;
end; end;
end; end;
end; end;
@ -70,6 +126,7 @@ begin
t_ready:= true; t_ready:= true;
push_trace('kmain'); push_trace('kmain');
end; end;
terminal.registerCommand('TRACER', @terminal_command_tracer, 'System.Tracer Interface.');
end; end;
function get_trace_count : uint32; function get_trace_count : uint32;