diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-20 15:38:06 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-20 15:38:06 +0300 |
| commit | d2f2714398d415eb9a628aab82b332b92ad5c923 (patch) | |
| tree | ce6844c3f6f446b3acefffbd294dfecd3eb8dc98 /include/apos/caps.h | |
| parent | a717296a2036cede5fccfff544513043a984d614 (diff) | |
| download | kmi-d2f2714398d415eb9a628aab82b332b92ad5c923.tar.gz kmi-d2f2714398d415eb9a628aab82b332b92ad5c923.zip | |
add capability subsystem and syscalls
Diffstat (limited to 'include/apos/caps.h')
| -rw-r--r-- | include/apos/caps.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/include/apos/caps.h b/include/apos/caps.h new file mode 100644 index 0000000..e8ef76b --- /dev/null +++ b/include/apos/caps.h @@ -0,0 +1,70 @@ +#ifndef APOS_CAPS_H +#define APOS_CAPS_H + +/** + * @file caps.h + * Capabilities of threads. + * \todo The list of capabilities should maybe be placed in some other file so + * as to easier extract it into userspace programs. + */ + +#include <apos/bits.h> + +/** Helper typedef for capabilities. */ +typedef unsigned char capflags_t; + +enum { + /** Thread is allowed to set capabilities of other threads. */ + CAP_CAPS = (1 << 0), + + /** Thread is allowed to modify process statuses, exec/fork/etc. */ + CAP_PROC = (1 << 1), + + /** Thread is allowed to force interrupt to callback in other thread. */ + CAP_CALL = (1 << 2), +}; + +/** + * Check that offset is OK. + * + * @param o Offset to check. + * @return \ref true is OK, \ref false otherwise. + */ +#define cap_off_ok(o) (o == 0) + +/** + * Set capabilities. + * + * @param x Capabilities to modify. + * @param o Offset. + * @param c Capabilities to set. + */ +#define set_caps(x, o, c) set_bits(x, c) + +/** + * Clear capabilities. + * + * @param x Capabilities to modify. + * @param o Offset. + * @param c Capabilities to set. + */ +#define clear_caps(x, o, c) clear_bits(x, c) + +/** + * Copy capabilities. + * + * @param x Capabilities to copy to. + * @param y Capabilities to copy from. + */ +#define copy_caps(x, y) (x = y) + +/** + * Get capabilities at offset \p o. + * + * @param x Capabilities to get from. + * @param o Offset to get capabilities from. + * @return Capabilities at offset \p o. + */ +#define get_caps(x, o) (x) + +#endif /* APOS_CAPS_H */ |
