dev Utility for working with devices

This commit is contained in:
2025-10-08 19:32:57 +02:00
parent 0ac80c76b0
commit ed704e2cef
5 changed files with 71 additions and 0 deletions

20
user/dev/ls.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdint.h>
#include <stddef.h>
#include <ulib.h>
void dev_ls(void) {
size_t ndevs = devctl(NULL, DEVCTL_DEVLS_SZ, NULL, 0, 0);
uprintf("TOTAL: %zu\n", ndevs);
uprintf("%-20s %-10s\n", "DEVICE", "FUNCTIONS");
for (size_t i = 0; i < 0x100; i++) {
DevStat devstat; ZERO(&devstat);
devctl(NULL, DEVCTL_DEVLS_STAT, (uint8_t *)&devstat, i, 0);
if (!devstat.present)
continue;
uprintf("%-20s %-10zu\n", devstat.name, devstat.nfns);
}
}