dev Utility for working with devices
This commit is contained in:
20
user/dev/ls.c
Normal file
20
user/dev/ls.c
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user