|
XenevaOS
|
#include <Fs/Dev/devhw.h>#include <Fs/Dev/devfs.h>#include <Fs/vfs.h>#include <Cap/capability.h>#include <Cred/group.h>#include <Hal/AA64/sched.h>#include <Hal/AA64/gic.h>#include <Serv/sysserv.h>#include <Mm/kmalloc.h>#include <Mm/pmmngr.h>#include <Mm/vmmngr.h>#include <Drivers/uart.h>#include <Drivers/virtio.h>#include <Hal/AA64/aa64lowlevel.h>#include <aucomponent.h>#include <Sound/sndproxy.h>#include <Net/netproxy.h>#include <Fs/Dev/devgpu.h>#include <hwdev.h>#include <pcie.h>#include <string.h>#include <_null.h>
Classes | |
| struct | _hw_map_ |
| struct | _hw_dma_ |
| struct | _hw_bar_ |
| struct | _hw_pci_ |
Macros | |
| #define | HW_MAX_CLAIMS 32 |
| #define | HW_MAX_MAPS 16 |
| #define | HW_MAX_DMA_PAGES 256 /* 1 MiB per buffer */ |
| #define | HW_MAX_DMAS 16 |
| #define | PCI_CMD_MEM (1u << 1) |
| #define | PCI_CMD_MASTER (1u << 2) |
| #define | PCI_CMD_INTXOFF (1u << 10) |
| #define | PCI_CMD_IO (1u << 0) |
| #define | HW_MAX_SPI 1024 |
Typedefs | |
| typedef struct _hw_map_ | HwMap |
| typedef struct _hw_dma_ | HwDma |
| typedef struct _hw_bar_ | HwBar |
| typedef struct _hw_pci_ | HwPci |
Functions | |
| bool | AuHwdevClaimsPci (int bus, int dev, int func) |
| True when a live user-space hwdev capability owns this PCI function. | |
| AuProcess * | AuHwdevCurrentProcess (void) |
| AuHwdevCurrentProcess – the process running the current thread. | |
| bool | AuHwdevCallerAllowed (AuProcess *proc) |
| AuHwdevCallerAllowed – true when proc is in the MISC_DAEMONS group. Checked on every privileged operation: a write-mode open skips the VFS permission check, so node permissions alone are not enough. | |
| bool | AuHwdevOwnsDma (AuProcess *proc, uint64_t phys, uint64_t len) |
| AuHwdevOwnsDma – true when [phys, phys+len) lies inside a DMA buffer that proc allocated through one of its own hw handles. Lets other kernel code accept a user-supplied physical address without trusting it. | |
| bool | AuHwdevHandleIsDevice (AuProcess *proc, int fd, uint16_t vendor, uint16_t device) |
| Validate that fd is the caller's PCI function with the requested ID. | |
| void * | AuHwdevHandleObject (AuProcess *proc, int fd) |
| Return the opaque kernel object for one exact caller handle. | |
| bool | AuHwdevHandleOwnsDma (AuProcess *proc, int fd, uint64_t phys, uint64_t len) |
| Validate a DMA range against one exact hwdev capability. | |
| void | AuHwdevCapReleased (void *procptr, AuCapability *cap) |
| void | AuHwdevInitialize (void) |
| AuHwdevInitialize – register /dev/hwdev (hardware access for user-space drivers, see BaseHdr/hwdev.h) | |
| #define HW_MAX_CLAIMS 32 |
devhw.c – /dev/hwdev: capability-gated hardware access for user-space drivers
See BaseHdr/hwdev.h for the contract. Summary: PCI_OPEN on the controller node returns a new fd that is a CAP_OBJ_PCIDEV capability for one PCI function; config access, BAR mapping and DMA buffers are ioctls on that fd, each bounded by the device. The capability table releases everything when the fd is closed or the process exits (AuHwdevCapReleased).
| #define HW_MAX_DMA_PAGES 256 /* 1 MiB per buffer */ |
| #define HW_MAX_DMAS 16 |
| #define HW_MAX_MAPS 16 |
| #define HW_MAX_SPI 1024 |
| #define PCI_CMD_INTXOFF (1u << 10) |
| #define PCI_CMD_IO (1u << 0) |
| #define PCI_CMD_MASTER (1u << 2) |
| #define PCI_CMD_MEM (1u << 1) |
AuHwdevCallerAllowed – true when proc is in the MISC_DAEMONS group. Checked on every privileged operation: a write-mode open skips the VFS permission check, so node permissions alone are not enough.
| void AuHwdevCapReleased | ( | void * | procptr, |
| AuCapability * | cap | ||
| ) |
| bool AuHwdevClaimsPci | ( | int | bus, |
| int | dev, | ||
| int | func | ||
| ) |
True when a live user-space hwdev capability owns this PCI function.
| AuProcess * AuHwdevCurrentProcess | ( | void | ) |
AuHwdevCurrentProcess – the process running the current thread.
Validate that fd is the caller's PCI function with the requested ID.
| void * AuHwdevHandleObject | ( | AuProcess * | proc, |
| int | fd | ||
| ) |
Return the opaque kernel object for one exact caller handle.
Validate a DMA range against one exact hwdev capability.
| void AuHwdevInitialize | ( | void | ) |
AuHwdevInitialize – register /dev/hwdev (hardware access for user-space drivers, see BaseHdr/hwdev.h)
AuHwdevOwnsDma – true when [phys, phys+len) lies inside a DMA buffer that proc allocated through one of its own hw handles. Lets other kernel code accept a user-supplied physical address without trusting it.
| uint16_t vendor |