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

This commit is contained in:
kieron
2018-05-07 21:47:59 +00:00
parent 956588c920
commit 1615e6781a
21 changed files with 392 additions and 86 deletions

45
src/driver/bus/EHCI.pas Normal file
View File

@ -0,0 +1,45 @@
unit EHCI;
interface
uses
tracer,
Console,
PCI,
drivertypes,
pmemorymanager,
vmemorymanager,
util,
drivermanagement;
function load : boolean;
implementation
function load : boolean;
var
devices : TDeviceArray;
count : uint32;
i : uint32;
begin
devices:= PCI.getDeviceInfo($0C, $03, $20, count);
console.output('USB-EHCI Driver', 'Found ');
console.writeint(count);
console.writestringln(' USB Controller(s).');
if count > 0 then begin
for i:=0 to count-1 do begin
console.output('USB-OHCI Driver', 'Controller[');
console.writeint(i);
console.writestring(']: ');
console.writehex(devices[i].device_id);
console.writestring(' ');
console.writehex(devices[i].vendor_id);
console.writestring(' ');
console.writehexln(devices[i].prog_if);
end;
end;
load:= true;
end;
end.

76
src/driver/bus/OHCI.pas Normal file
View File

@ -0,0 +1,76 @@
unit OHCI;
interface
uses
tracer,
Console,
PCI,
drivertypes,
pmemorymanager,
vmemorymanager,
util,
drivermanagement;
type
POHCI_MMR = ^TOHCI_MMR;
TOHCI_MMR = packed record
HcRevision : uint32;
HcControl : uint32;
HcCommandStatus : uint32;
HcIntStatus : uint32;
HcIntEnable : uint32;
HcIntDisable : uint32;
HcHCCA : uint32;
HcPeriodCurrentED : uint32;
HcControlHeadED : uint32;
HcControlCurrentED : uint32;
HcBulkHeadED : uint32;
HcBulkCurrentED : uint32;
HcDoneHead : uint32;
HcFmRemaining : uint32;
HcFmNumber : uint32;
HcPeriodicStart : uint32;
HcLSThreshold : uint32;
HcRhDescriptorA : uint32;
HcRhDescriptorB : uint32;
HcRhStatus : uint32;
end;
function load : boolean;
implementation
function load : boolean;
var
devices : TDeviceArray;
count : uint32;
i : uint32;
block : uint32;
MMR : POHCI_MMR;
begin
devices:= PCI.getDeviceInfo($0C, $03, $10, count);
console.output('USB-OHCI Driver', 'Found ');
console.writeint(count);
console.writestringln(' USB Controller(s).');
if count > 0 then begin
for i:=0 to count-1 do begin
console.output('USB-OHCI Driver', 'Controller[');
console.writeint(i);
console.writestring(']: ');
console.writehex(devices[i].device_id);
console.writestring(' ');
console.writehex(devices[i].vendor_id);
console.writestring(' ');
console.writehexln(devices[i].prog_if);
block:= devices[i].address0 SHR 22;
force_alloc_block(block, 0);
map_page(block, block);
MMR:= POHCI_MMR(devices[i].address0);
end;
end;
load:= true;
end;
end.

45
src/driver/bus/UHCI.pas Normal file
View File

@ -0,0 +1,45 @@
unit UHCI;
interface
uses
tracer,
Console,
PCI,
drivertypes,
pmemorymanager,
vmemorymanager,
util,
drivermanagement;
function load : boolean;
implementation
function load : boolean;
var
devices : TDeviceArray;
count : uint32;
i : uint32;
begin
devices:= PCI.getDeviceInfo($0C, $03, $00, count);
console.output('USB-UHCI Driver','Found ');
console.writeint(count);
console.writestringln(' USB Controller(s).');
if count > 0 then begin
for i:=0 to count-1 do begin
console.output('USB-UHCI Driver','Controller[');
console.writeint(i);
console.writestring(']: ');
console.writehex(devices[i].device_id);
console.writestring(' ');
console.writehex(devices[i].vendor_id);
console.writestring(' ');
console.writehexln(devices[i].prog_if);
end;
end;
load:= true;
end;
end.

View File

@ -10,102 +10,34 @@ uses
pmemorymanager,
vmemorymanager,
util,
drivermanagement;
type
POHCI_MMR = ^TOHCI_MMR;
TOHCI_MMR = packed record
HcRevision : uint32;
HcControl : uint32;
HcCommandStatus : uint32;
HcIntStatus : uint32;
HcIntEnable : uint32;
HcIntDisable : uint32;
HcHCCA : uint32;
HcPeriodCurrentED : uint32;
HcControlHeadED : uint32;
HcControlCurrentED : uint32;
HcBulkHeadED : uint32;
HcBulkCurrentED : uint32;
HcDoneHead : uint32;
HcFmRemaining : uint32;
HcFmNumber : uint32;
HcPeriodicStart : uint32;
HcLSThreshold : uint32;
HcRhDescriptorA : uint32;
HcRhDescriptorB : uint32;
HcRhStatus : uint32;
end;
drivermanagement,
OHCI, UHCI, EHCI;
procedure init;
implementation
function loadOHCI(ptr : void) : boolean;
var
devices : TDeviceArray;
count : uint32;
i : uint32;
block : uint32;
MMR : POHCI_MMR;
function loadEHCI(ptr : void) : boolean;
begin
push_trace('USB.loadEHCI');
loadEHCI:= EHCI.load;
end;
function loadOHCI(ptr : void) : boolean;
begin
push_trace('USB.loadOHCI');
devices:= PCI.getDeviceInfo($0C, $03, $10, count);
console.output('USB-OHCI Driver', 'Found ');
console.writeint(count);
console.writestringln(' USB Controller(s).');
if count > 0 then begin
for i:=0 to count-1 do begin
console.output('USB-OHCI Driver', 'Controller[');
console.writeint(i);
console.writestring(']: ');
console.writehex(devices[i].device_id);
console.writestring(' ');
console.writehex(devices[i].vendor_id);
console.writestring(' ');
console.writehexln(devices[i].prog_if);
block:= devices[i].address0 SHR 22;
force_alloc_block(block, 0);
map_page(block, block);
MMR:= POHCI_MMR(devices[i].address0);
end;
end;
loadOHCI:= true;
pop_trace;
loadOHCI:= OHCI.load;
end;
function loadUHCI(ptr : void) : boolean;
var
devices : TDeviceArray;
count : uint32;
i : uint32;
begin
push_trace('USB.loadUHCI');
devices:= PCI.getDeviceInfo($0C, $03, $00, count);
console.output('USB-UHCI Driver','Found ');
console.writeint(count);
console.writestringln(' USB Controller(s).');
if count > 0 then begin
for i:=0 to count-1 do begin
console.output('USB-UHCI Driver','Controller[');
console.writeint(i);
console.writestring(']: ');
console.writehex(devices[i].device_id);
console.writestring(' ');
console.writehex(devices[i].vendor_id);
console.writestring(' ');
console.writehexln(devices[i].prog_if);
end;
end;
loadUHCI:= true;
pop_trace;
loadUHCI:= UHCI.load;
end;
procedure init;
var
UHCI_ID, OHCI_ID : TDeviceIdentifier;
UHCI_ID, OHCI_ID, EHCI_ID: TDeviceIdentifier;
begin
push_trace('USB.init');
@ -127,8 +59,17 @@ begin
OHCI_ID.id4:= $FFFFFFFF;
OHCI_ID.ex:= nil;
EHCI_ID.Bus:= biPCI;
EHCI_ID.id0:= idANY;
EHCI_ID.id1:= $0000000C;
EHCI_ID.id2:= $00000003;
EHCI_ID.id3:= $00000020;
EHCI_ID.id4:= $FFFFFFFF;
EHCI_ID.ex:= nil;
drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI);
drivermanagement.register_driver('USB-OHCI Driver', @OHCI_ID, @loadOHCI);
drivermanagement.register_driver('USB-EHCI Driver', @EHCI_ID, @loadEHCI);
console.outputln('USB Driver', 'INIT END.');
pop_trace;

View File

@ -3,20 +3,20 @@ unit asuro;
interface
const
VERSION = '1.0.1-664ia';
VERSION = '1.0.1-668ia';
VERSION_MAJOR = '1';
VERSION_MINOR = '0';
VERSION_SUB = '1';
REVISION = '664';
REVISION = '668';
RELEASE = 'ia';
LINE_COUNT = 27361;
FILE_COUNT = 84;
DRIVER_COUNT = 28;
LINE_COUNT = 27480;
FILE_COUNT = 87;
DRIVER_COUNT = 31;
FPC_VERSION = '2.6.4';
NASM_VERSION = '2.10.09';
MAKE_VERSION = '3.81';
COMPILE_DATE = '06/05/18';
COMPILE_TIME = '06:55:52';
COMPILE_DATE = '07/05/18';
COMPILE_TIME = '22:47:28';
implementation

199
src/prog/themer.pas Normal file
View File

@ -0,0 +1,199 @@
unit themer;
interface
uses
console, terminal, keyboard, shell, strings, tracer;
procedure init();
implementation
type
TThemeThing = record
ThemeName : PChar;
Colors : PRGB565Pair;
end;
var
Handle : HWND = 0;
Colors : uint32;
Themes : Array[0..3] of TThemeThing;
Selected : uint32;
ForeBack : uint32;
Changing : Boolean = false;
procedure OnClose();
begin
Handle:= 0;
end;
procedure Draw();
var
i, j : uint32;
longest, len : uint32;
begin
tracer.push_trace('themer.draw');
if Handle <> 0 then begin
clearWNDEx(Handle, Colors);
writestringlnexWND(' ', Colors, Handle);
writestringlnexWND(' ', Colors, Handle);
writestringlnexWND(' ', Colors, Handle);
writestringlnexWND(' ', Colors, Handle);
longest:= 0;
for i:=0 to 3 do begin
if stringSize(Themes[i].ThemeName) > longest then longest:= stringSize(Themes[i].ThemeName);
end;
for j:=0 to longest do begin
writeStringexWND(' ', Colors, Handle);
end;
writestringexWND(' Foreground ', Colors, Handle);
writestringexWND(#6, Colors, Handle);
writestringlnexWND(' Background', Colors, Handle);
for i:=0 to 3 do begin
len:= longest - StringSize(Themes[i].ThemeName);
for j:=0 to len do begin
writeStringexWND(' ', Colors, Handle);
end;
writestringexWND(' ', Colors, Handle);
writeStringexWND(Themes[i].ThemeName, Colors, Handle);
writeStringexWND(':', Colors, Handle);
if (ForeBack = 0) and (Selected = i) and (Changing) then writeStringexWND(' *R:', Colors, Handle) else if (ForeBack = 0) and (Selected = i) then writeStringexWND(' >R:', Colors, Handle) else writeStringexWND(' R:', Colors, Handle);
if Themes[i].Colors^.Foreground.R < 10 then writeintexWND(0, Colors, Handle);
writeintexWND(Themes[i].Colors^.Foreground.R, Colors, Handle);
if (ForeBack = 1) and (Selected = i) and (Changing) then writeStringexWND(' *G:', Colors, Handle) else if (ForeBack = 1) and (Selected = i) then writeStringexWND(' >G:', Colors, Handle) else writeStringexWND(' G:', Colors, Handle);
if Themes[i].Colors^.Foreground.G < 10 then writeintexWND(0, Colors, Handle);
writeintexWND(Themes[i].Colors^.Foreground.G, Colors, Handle);
if (ForeBack = 2) and (Selected = i) and (Changing) then writeStringexWND(' *B:', Colors, Handle) else if (ForeBack = 2) and (Selected = i) then writeStringexWND(' >B:', Colors, Handle) else writeStringexWND(' B:', Colors, Handle);
if Themes[i].Colors^.Foreground.B < 10 then writeintexWND(0, Colors, Handle);
writeintexWND(Themes[i].Colors^.Foreground.B, Colors, Handle);
writestringexWND(' ', Colors, Handle);
writestringexWND(#6, Colors, Handle);
if (ForeBack = 3) and (Selected = i) and (Changing) then writeStringexWND(' *R:', Colors, Handle) else if (ForeBack = 3) and (Selected = i) then writeStringexWND(' >R:', Colors, Handle) else writeStringexWND(' R:', Colors, Handle);
if Themes[i].Colors^.Background.R < 10 then writeintexWND(0, Colors, Handle);
writeintexWND(Themes[i].Colors^.Background.R, Colors, Handle);
if (ForeBack = 4) and (Selected = i) and (Changing) then writeStringexWND(' *G:', Colors, Handle) else if (ForeBack = 4) and (Selected = i) then writeStringexWND(' >G:', Colors, Handle) else writeStringexWND(' G:', Colors, Handle);
if Themes[i].Colors^.Background.G < 10 then writeintexWND(0, Colors, Handle);
writeintexWND(Themes[i].Colors^.Background.G, Colors, Handle);
if (ForeBack = 5) and (Selected = i) and (Changing) then writeStringexWND(' *B:', Colors, Handle) else if (ForeBack = 5) and (Selected = i) then writeStringexWND(' >B:', Colors, Handle) else writeStringexWND(' B:', Colors, Handle);
if Themes[i].Colors^.Background.B < 10 then writeintexWND(0, Colors, Handle);
writeintexWND(Themes[i].Colors^.Background.B, Colors, Handle);
writestringlnexWND(' ', Colors, Handle);
end;
len:= longest - StringSize('Color16');
for j:=0 to len do begin
writeStringexWND(' ', Colors, Handle);
end;
writestringexWND(' ', Colors, Handle);
writestringexWND('Color16:', Colors, Handle);
writestringexWND(' ', Colors, Handle);
writehexexWND(puint16(@Themes[Selected].Colors^.Foreground)^, Colors, Handle);
writestringexWND(' '+#6, Colors, Handle);
writestringexWND(' ', Colors, Handle);
writehexlnexWND(puint16(@Themes[Selected].Colors^.Background)^, Colors, Handle);
writestringlnexWND(' ', Colors, Handle);
writestringlnexWND(' Press ''d'' to dump color values.', Colors, Handle);
end;
end;
procedure incrementSelected;
begin
case ForeBack of
0:Themes[Selected].Colors^.Foreground.R:= Themes[Selected].Colors^.Foreground.R + 1;
1:Themes[Selected].Colors^.Foreground.G:= Themes[Selected].Colors^.Foreground.G + 1;
2:Themes[Selected].Colors^.Foreground.B:= Themes[Selected].Colors^.Foreground.B + 1;
3:Themes[Selected].Colors^.Background.R:= Themes[Selected].Colors^.Background.R + 1;
4:Themes[Selected].Colors^.Background.G:= Themes[Selected].Colors^.Background.G + 1;
5:Themes[Selected].Colors^.Background.B:= Themes[Selected].Colors^.Background.B + 1;
end;
end;
procedure decrementSelected;
begin
case ForeBack of
0:Themes[Selected].Colors^.Foreground.R:= Themes[Selected].Colors^.Foreground.R - 1;
1:Themes[Selected].Colors^.Foreground.G:= Themes[Selected].Colors^.Foreground.G - 1;
2:Themes[Selected].Colors^.Foreground.B:= Themes[Selected].Colors^.Foreground.B - 1;
3:Themes[Selected].Colors^.Background.R:= Themes[Selected].Colors^.Background.R - 1;
4:Themes[Selected].Colors^.Background.G:= Themes[Selected].Colors^.Background.G - 1;
5:Themes[Selected].Colors^.Background.B:= Themes[Selected].Colors^.Background.B - 1;
end;
end;
procedure OnKeyPressed(info : TKeyInfo);
var
i : uint32;
begin
case info.key_code of
13:begin
Changing:= not Changing;
end;
16:begin //Up
if changing then begin
incrementSelected;
end else begin
if Selected > 0 then dec(Selected);
end;
end;
18:begin //Down
if changing then begin
decrementSelected;
end else begin
if Selected < 3 then inc(Selected);
end;
end;
20:begin //Right
if not changing then begin
if ForeBack < 5 then inc(ForeBack);
end;
end;
19:begin //Left
if not changing then begin
if ForeBack > 0 then dec(ForeBack);
end;
end;
uint8('d'):begin
writestringlnWND(' ', getTerminalHWND);
for i:=0 to 3 do begin
writestringWND(Themes[i].ThemeName, getTerminalHWND);
writestringWND(': Foreground: ', getTerminalHWND);
writehexWND(puint16(@Themes[i].Colors^.Foreground)^, getTerminalHWND);
writestringWND(' Background: ', getTerminalHWND);
writehexlnWND(puint16(@Themes[i].Colors^.Background)^, getTerminalHWND);
end;
end;
end;
end;
procedure run(Params : PParamList);
begin
tracer.push_trace('themer.run');
if Handle = 0 then begin
Handle:= newWindow(20, 40, 65, 14, 'THEMER');
registerEventHandler(Handle, EVENT_DRAW, void(@Draw));
registerEventHandler(Handle, EVENT_CLOSE, void(@OnClose));
registerEventHandler(Handle, EVENT_KEY_PRESSED, void(@OnKeyPressed));
writestringlnWND('Themer Started.', getTerminalHWND);
Themes[0].ThemeName:= 'Windows';
Themes[0].Colors:= PRGB565Pair(getWindowColorPtr);
Themes[1].ThemeName:= 'Background';
Themes[1].Colors:= PRGB565Pair(getDesktopColorsPtr);
Themes[2].ThemeName:= 'Explore Button';
Themes[2].Colors:= PRGB565Pair(getExploreColorsPtr);
Themes[3].ThemeName:= 'Taskbar';
Themes[3].Colors:= PRGB565Pair(getTaskbarColorsPtr);
Selected:= 0;
ForeBack:= 0;
end;
end;
procedure init();
begin
Colors:= combineColors($0000, $FFFF);
tracer.push_trace('themer.init');
terminal.registerCommand('THEMER', @Run, 'Themer, for your themez.');
end;
end.