USB driver polling user app, handle only one XHCI controller for now, Implement USB device addressing
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 3m47s
Build documentation / build-and-deploy (push) Successful in 2m38s

This commit is contained in:
2026-03-29 18:59:20 +02:00
parent 69f063198a
commit 482afb47d7
22 changed files with 383 additions and 56 deletions

6
usb/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
*.o
*.json
docs/
.cache/
*.map
usb

10
usb/Makefile Normal file
View File

@@ -0,0 +1,10 @@
include ../make/ufuncs.mk
$(eval $(call add_lib,libstring))
$(eval $(call add_lib,libprocess))
$(eval $(call add_lib,libaux))
$(eval $(call add_lib,libmalloc))
cflags += -DPRINTF_INCLUDE_CONFIG_H=1
include ../make/user.mk

1
usb/app.mk Normal file
View File

@@ -0,0 +1 @@
app := usb

3
usb/src.mk Normal file
View File

@@ -0,0 +1,3 @@
c += usb.c
o += usb.o

57
usb/usb.c Normal file
View File

@@ -0,0 +1,57 @@
#include <device_info.h>
#include <devices.h>
#include <malloc.h>
#include <mprintf.h>
#include <process.h>
#include <process_self.h>
#include <status.h>
#include <string.h>
#include <system.h>
static void usb_poll_driver_proc (void* arg) {
struct device_info* info = arg;
mprintf ("Polling device %s\n", info->key);
for (;;) {
device_do (info->key, XUSBCTRL_POLL_DRIVER, NULL, NULL, NULL, NULL);
sched ();
}
}
void app_main (void) {
libprocess_self_init ();
char commandbuf[32];
memset (commandbuf, 0, sizeof (commandbuf));
if (env_get (process_get_pgid (), "C", (void*)commandbuf, sizeof (commandbuf)) != ST_OK) {
mprintf ("ERROR C=???. No command provided\n");
return;
}
if (strcmp (commandbuf, "poll") == 0) {
struct device_info* infos = malloc (sizeof (struct device_info) * 1024);
memset (infos, 0, sizeof (struct device_info) * 1024);
int device_count = get_device_info (infos, 1024);
for (int dev = 0; dev < device_count; dev++) {
struct device_info* info = &infos[dev];
if (info->type != DEVICE_TYPE_USB_CTRL) {
continue;
}
struct process_data* pdata = process_spawn (&usb_poll_driver_proc, info);
mprintf ("Started USB poller process: PID %d\n", pdata->pid);
}
for (;;)
;
} else {
mprintf ("ERROR unknown command %s\n", commandbuf);
}
}