Enable native USB core, OHCI, mass storage and HID drivers

This commit is contained in:
Aaron committed 2026-11-08 09:02:33 +00:00
1 parent f8911ccdec
commit 465cf1deca
7 files changed
+350 -311

No files matched your search

File diff suppressed because it is too large. Load diff
+5 -17
View File
@@ -15,7 +15,7 @@ interface
uses uses
debug.tracer, debug.tracer,
io.syslog, io.syslog,
core.util, arch.x86.util, core.util, arch.platform.cpu, arch.platform.diagnostics,
memory.heap, memory.heap,
driver.types, driver.types,
driver.mgr, driver.mgr,
@@ -315,7 +315,7 @@ begin
io.syslog.writeintln(depth); io.syslog.writeintln(depth);
{ Step 1: Get hub descriptor } { Step 1: Get hub descriptor }
memset(uint32(@hubDesc), 0, sizeof(TUSBHubDescriptor)); memset(PtrUInt(@hubDesc), 0, sizeof(TUSBHubDescriptor));
if not hub_get_descriptor(dev, @hubDesc, sizeof(TUSBHubDescriptor)) then begin if not hub_get_descriptor(dev, @hubDesc, sizeof(TUSBHubDescriptor)) then begin
io.syslog.logln('USBHub', 'Failed to get hub descriptor.'); io.syslog.logln('USBHub', 'Failed to get hub descriptor.');
pop_trace; pop_trace;
@@ -344,7 +344,7 @@ begin
pop_trace; pop_trace;
exit; exit;
end; end;
memset(uint32(hub), 0, sizeof(TUSBHubData)); memset(PtrUInt(hub), 0, sizeof(TUSBHubData));
hub^.Device := dev; hub^.Device := dev;
hub^.NumPorts := hubDesc.bNbrPorts; hub^.NumPorts := hubDesc.bNbrPorts;
hub^.PwrOn2PwrGood := hubDesc.bPwrOn2PwrGood; hub^.PwrOn2PwrGood := hubDesc.bPwrOn2PwrGood;
@@ -378,7 +378,7 @@ begin
if HubList <> nil then begin if HubList <> nil then begin
hubEntry := PUSBHubData(LL_Add(HubList)); hubEntry := PUSBHubData(LL_Add(HubList));
if hubEntry <> nil then if hubEntry <> nil then
memcpy(uint32(hub), uint32(hubEntry), sizeof(TUSBHubData)); memcpy(PtrUInt(hub), PtrUInt(hubEntry), sizeof(TUSBHubData));
end; end;
{ Step 6: Scan ports for connected devices } { Step 6: Scan ports for connected devices }
@@ -649,20 +649,8 @@ var
end; end;
procedure PrintSummary; procedure PrintSummary;
var
pStr, fStr, msg, tmp : pchar;
begin begin
pStr := intToString(passed); testSummary('USBHub', 'USBHUB_TESTS_PASSED', 'USBHUB_TESTS_FAILED', passed, failed);
fStr := intToString(failed);
msg := stringConcat(pStr, ' passed, ');
tmp := stringConcat(msg, fStr);
kfree(void(msg));
msg := stringConcat(tmp, ' failed.');
kfree(void(tmp));
io.syslog.logln('USBHub', msg);
kfree(void(msg));
kfree(void(pStr));
kfree(void(fStr));
end; end;
begin begin
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+7 -21
View File
@@ -12,18 +12,19 @@ unit driver.hid.usb.keyboard;
interface interface
uses uses
boot.mgr,
driver.bus.usb.types, driver.bus.usb.types,
driver.bus.usb.core, driver.bus.usb.core,
driver.hid.keyboard, driver.hid.keyboard,
driver.hid.ps2.keyboard,
driver.mgr, driver.mgr,
memory.heap, memory.heap,
core.ds.lists, core.ds.lists,
debug.tracer, debug.tracer,
io.syslog, io.syslog,
core.strings, core.strings,
core.util, arch.x86.util; core.util, arch.platform.cpu, arch.platform.diagnostics;
{ Target startup may disable a legacy keyboard when USB becomes active. }
var onAttach: procedure = nil;
procedure init; procedure init;
procedure poll_keyboards; procedure poll_keyboards;
@@ -400,7 +401,7 @@ begin
end; end;
{ Save current report as previous for next comparison } { Save current report as previous for next comparison }
memcpy(uint32(@kb^.ReportBuf[0]), uint32(@kb^.PrevReport[0]), KB_REPORT_SIZE); memcpy(PtrUInt(@kb^.ReportBuf[0]), PtrUInt(@kb^.PrevReport[0]), KB_REPORT_SIZE);
end; end;
{ ========================= Disconnect Handler ========================= } { ========================= Disconnect Handler ========================= }
@@ -573,7 +574,7 @@ begin
io.syslog.writestringln(').'); io.syslog.writestringln(').');
{ Disable PS/2 driver.hid.keyboard to prevent duplicate input from driver.bus.usb legacy emulation } { Disable PS/2 driver.hid.keyboard to prevent duplicate input from driver.bus.usb legacy emulation }
driver.hid.ps2.keyboard.disable; if onAttach <> nil then onAttach;
load := true; load := true;
pop_trace; pop_trace;
@@ -632,20 +633,8 @@ var
end; end;
procedure PrintSummary; procedure PrintSummary;
var
pStr, fStr, msg, tmp : pchar;
begin begin
pStr := intToString(passed); testSummary('USBKeyboard', 'USBKEYBOARD_TESTS_PASSED', 'USBKEYBOARD_TESTS_FAILED', passed, failed);
fStr := intToString(failed);
msg := stringConcat(pStr, ' passed, ');
tmp := stringConcat(msg, fStr);
kfree(void(msg));
msg := stringConcat(tmp, ' failed.');
kfree(void(tmp));
io.syslog.logln('USBKeyboard', msg);
kfree(void(msg));
kfree(void(pStr));
kfree(void(fStr));
end; end;
var var
@@ -754,7 +743,4 @@ begin
PrintSummary; PrintSummary;
end; end;
initialization
boot.mgr.registerBoot('driver.hid.usb.keyboard', @init, 'USB Keyboard Driver', BOOT_MGR_BARRIER_DEVICE);
end. end.
+5 -21
View File
@@ -13,7 +13,6 @@ unit driver.hid.usb.mouse;
interface interface
uses uses
boot.mgr,
driver.bus.usb.types, driver.bus.usb.types,
driver.bus.usb.core, driver.bus.usb.core,
driver.hid.mouse, driver.hid.mouse,
@@ -23,7 +22,7 @@ uses
debug.tracer, debug.tracer,
io.syslog, io.syslog,
core.strings, core.strings,
core.util, arch.x86.util; core.util, arch.platform.cpu, arch.platform.diagnostics;
procedure init; procedure init;
procedure poll_mice; procedure poll_mice;
@@ -82,7 +81,7 @@ function mouse_delta_x(report : Pointer) : sint32;
var var
raw : uint8; raw : uint8;
begin begin
raw := PUint8(uint32(report) + 1)^; raw := PUint8(PtrUInt(report) + 1)^;
if raw < 128 then if raw < 128 then
mouse_delta_x := sint32(raw) mouse_delta_x := sint32(raw)
else else
@@ -94,7 +93,7 @@ function mouse_delta_y(report : Pointer) : sint32;
var var
raw : uint8; raw : uint8;
begin begin
raw := PUint8(uint32(report) + 2)^; raw := PUint8(PtrUInt(report) + 2)^;
if raw < 128 then if raw < 128 then
mouse_delta_y := sint32(raw) mouse_delta_y := sint32(raw)
else else
@@ -108,7 +107,7 @@ var
begin begin
mouse_scroll := 0; mouse_scroll := 0;
if reportLen < 4 then exit; if reportLen < 4 then exit;
raw := PUint8(uint32(report) + 3)^; raw := PUint8(PtrUInt(report) + 3)^;
if raw < 128 then if raw < 128 then
mouse_scroll := sint32(raw) mouse_scroll := sint32(raw)
else else
@@ -417,20 +416,8 @@ var
end; end;
procedure PrintSummary; procedure PrintSummary;
var
pStr, fStr, msg, tmp : pchar;
begin begin
pStr := intToString(passed); testSummary('USBMouse', 'USBMOUSE_TESTS_PASSED', 'USBMOUSE_TESTS_FAILED', passed, failed);
fStr := intToString(failed);
msg := stringConcat(pStr, ' passed, ');
tmp := stringConcat(msg, fStr);
kfree(void(msg));
msg := stringConcat(tmp, ' failed.');
kfree(void(tmp));
io.syslog.logln('USBMouse', msg);
kfree(void(msg));
kfree(void(pStr));
kfree(void(fStr));
end; end;
var var
@@ -555,7 +542,4 @@ begin
PrintSummary; PrintSummary;
end; end;
initialization
boot.mgr.registerBoot('driver.hid.usb.mouse', @Init, 'USB Mouse Driver', BOOT_MGR_BARRIER_DEVICE);
end. end.
File diff suppressed because it is too large. Load diff