-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
66 lines (48 loc) · 1.89 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
This is a WIP prototype of libuhwi - a C99 library for detecting PCI, USB
devices as well as other hardware components.
It supports the following OSes (at least this was the case at the time of
writing):
- FreeBSD (PCI via <sys/pciio.h>, USB via built-in libusb 2.0)
- macOS (PCI and USB via IOKit)
- Linux (PCI and USB via sysfs)
Use GNU make to build on macOS or Linux, use the provided shell script to
build on FreeBSD:
$ sh build_freebsd.sh clean
$ sh build_freebsd.sh
It is possible to compile an experimental version of libuhwi which is ca-
pable of guessing PCI devices' names using a database file provided by
PCI IDs Project (bundled on every default installation of FreeBSD):
# on FreeBSD
$ ENABLE_PCI_DB=1 sh build_freebsd.sh
# on macOS (for debugging purposes only as PCI device name strings
# are provided by IOKit natively on Mac)
$ make ENABLE_PCI_DB=1 CFLAGS="-DUHWI_PCI_DB_PATH_CONST=\"/valid/DB/path\""
# on Linux
$ make ENABLE_PCI_DB=1
Linking with the library requires you to link with the appropriate depen-
dencies as well since libuhwi is built as a static library:
# on FreeBSD
$ clang ... -L. -luhwi -lusb
# on macOS
$ clang ... -L. -luhwi -framework CoreFoundation -framework IOKit
UniHWI comes with lsuhwi - a command-line tool akin to lspci/usbconfig, but
using libuhwi instead:
# dumps PCI and USB devices available on the system
$ ./lsuhwi
# dumps PCI and USB devices available on the system in JSON form
$ ./lsuhwi -J
# dumps just the PCI devices
$ ./lsuhwi -l
# dumps just the USB devices
$ ./lsuhwi -u
# dumps PCI devices in JSON form
$ ./lsuhwi -l -J
# dumps USB devices in JSON form
$ ./lsuhwi -u -J
# dumps PCI DB contents
$ ./lsuhwi -d
# mediocre built-in usage documentation
$ ./lsuhwi -h
Copyright (c) 2023 Universe-OS
Copyright (c) 2023 Tim K. <timk@xfen.page>
Licensed under MIT License