XenevaOS
Loading...
Searching...
No Matches
capability.h
Go to the documentation of this file.
1#ifndef CAPABILITY_H
2#define CAPABILITY_H
3
4
5
6#include <aurora.h>
7#include <Cred/user.h>
8#include <stdint.h>
9//#include <stdbool.h>
10
11
12
13#define CAP_READ (1 << 0)
14#define CAP_WRITE (1 << 1)
15
16#define CAP_EXECUTE (1 << 2)
17#define CAP_SEEK (1 << 3)
18#define CAP_IOCTL (1 << 4)
19
20#define CAP_DUP (1 << 5)
21
22#define CAP_TRANSFER (1 << 6)
23/* hardware-handle rights (CAP_OBJ_PCIDEV) */
24#define CAP_HW_CFG (1 << 7) /* PCI config space access */
25#define CAP_HW_MAP (1 << 8) /* map BARs into the process */
26#define CAP_HW_DMA (1 << 9) /* allocate DMA buffers */
27#define CAP_HW_IRQ (1 << 10) /* receive the device's interrupts */
28#define CAP_HW_RIGHTS_MASK (CAP_HW_CFG | CAP_HW_MAP | CAP_HW_DMA | CAP_HW_IRQ)
29
30#define CAP_RIGHTS_NONE 0
31
32#define CAP_FILE_RIGHTS_MASK (CAP_READ | CAP_WRITE | CAP_SEEK | CAP_IOCTL | CAP_DUP | CAP_TRANSFER)
33
34/* Return codes */
35#define CAP_OK 0
36#define CAP_ERR_INVALID -1
37#define CAP_ERR_PERM -2
38
39#define CAP_OBJ_FILE 1
40#define CAP_OBJ_PCIDEV 2 /* a claimed PCI function, see hwdev.h */
41
42#define CAP_FLAG_NONE 0
43
44#define CAP_FLAG_NO_INHERIT (1 << 0)
45
46
47
48/* Capability entry */
49typedef struct _au_capability_ {
50
51 void* object;
52
53
55
56
58
59
61
62
64
65
66 unsigned char valid;
68
69extern int BordoisilaCapCreate(void* proc, int fd, void* object, uint8_t type, CapRights rights);
70extern AuCapability* BordoisilaCapLookup(void* proc, int fd);
71extern bool BordoisilaCapCheckRights(void* proc, int fd, CapRights required);
72extern int BordoisilaCapDup(void* proc, int oldfd, int newfd);
73extern int BordoisilaCapRestrict(void* proc, int fd, CapRights new_rights);
74extern void BordoisilaCapDestroy(void* proc, int fd);
75extern void BordoisilaCapCleanupProcess(void* proc);
76
77/* called by the capability table before a CAP_OBJ_PCIDEV slot is cleared, so
78 * the device can be unmapped, its DMA freed and its claim released */
79extern void AuHwdevCapReleased(void* proc, AuCapability* cap);
80extern void BordoisilaCapInheritTable(void* parent, void* child);
81
82#endif
uint32_t CapRights
Definition aurora.h:57
void BordoisilaCapCleanupProcess(void *proc)
Definition capability.c:189
void BordoisilaCapInheritTable(void *parent, void *child)
Definition capability.c:208
struct _au_capability_ AuCapability
void BordoisilaCapDestroy(void *proc, int fd)
Definition capability.c:172
AuCapability * BordoisilaCapLookup(void *proc, int fd)
Definition capability.c:97
bool BordoisilaCapCheckRights(void *proc, int fd, CapRights required)
Definition capability.c:107
int BordoisilaCapDup(void *proc, int oldfd, int newfd)
Definition capability.c:121
int BordoisilaCapRestrict(void *proc, int fd, CapRights new_rights)
Definition capability.c:159
void AuHwdevCapReleased(void *proc, AuCapability *cap)
Definition devhw.c:539
int BordoisilaCapCreate(void *proc, int fd, void *object, uint8_t type, CapRights rights)
Definition capability.c:70
unsigned char uint8_t
Definition acefiex.h:161
unsigned short int uint16_t
Definition acefiex.h:162
struct kobject * parent
Definition kobject.h:91
Definition capability.h:49
unsigned char valid
Definition capability.h:66
UID_NUM owner
Definition capability.h:60
CapRights rights
Definition capability.h:57
uint8_t object_type
Definition capability.h:54
uint16_t flags
Definition capability.h:63
void * object
Definition capability.h:51
Definition file.h:140
#define UID_NUM
Definition user.h:35