diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/kmi/caps.h | 51 | ||||
| -rw-r--r-- | include/kmi/power.h | 14 | ||||
| -rw-r--r-- | include/kmi/syscalls.h | 89 | ||||
| -rw-r--r-- | include/kmi/tcb.h | 2 | ||||
| -rw-r--r-- | include/kmi/types.h | 32 | ||||
| -rw-r--r-- | include/kmi/uapi.h | 18 |
6 files changed, 94 insertions, 112 deletions
diff --git a/include/kmi/caps.h b/include/kmi/caps.h index 02f6b3e..cc54dbe 100644 --- a/include/kmi/caps.h +++ b/include/kmi/caps.h @@ -16,51 +16,13 @@ #include <kmi/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, create/exec/fork/etc. */ - CAP_PROC = (1 << 1), - - /** Thread is allowed to force notification in other thread. */ - CAP_NOTIFY = (1 << 2), - - /** Thread is allowed to shut down system. */ - CAP_POWER = (1 << 3), - - /** Thread is allowed to access configuration parameters. */ - CAP_CONF = (1 << 4), - - /** Thread is allowed to request to handle IRQs. */ - CAP_IRQ = (1 << 5), - - /** Thread is allowed to request notification handler. */ - CAP_SIGNAL = (1 << 6), - - /** Thread is allowed to request shared memory */ - CAP_SHARED = (1 << 7) -}; - -/** - * 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) +#define set_caps(x, c) set_bits(x, c) /** * Clear capabilities. @@ -69,7 +31,7 @@ enum { * @param o Offset. * @param c Capabilities to set. */ -#define clear_caps(x, o, c) clear_bits(x, c) +#define clear_caps(x, c) clear_bits(x, c) /** * Copy capabilities. @@ -80,15 +42,6 @@ enum { #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) - -/** * Check if something has capability. * * @param x Capabilities to check in. diff --git a/include/kmi/power.h b/include/kmi/power.h index db00999..d0ebeca 100644 --- a/include/kmi/power.h +++ b/include/kmi/power.h @@ -10,22 +10,10 @@ * host machines. */ +#include <kmi/syscalls.h> #include <kmi/types.h> #include <kmi/attrs.h> -/** Types of powering off. Still unclear what difference there is between warm - * and cold reboot. */ -enum poweroff_type { - /** Shut down. */ - SHUTDOWN, - - /** Cold or complete reboot. */ - COLD_REBOOT, - - /** Warm or partial reboot. */ - WARM_REBOOT -}; - /** * Power off the system. * diff --git a/include/kmi/syscalls.h b/include/kmi/syscalls.h index 1efd0d4..1ca2113 100644 --- a/include/kmi/syscalls.h +++ b/include/kmi/syscalls.h @@ -130,10 +130,10 @@ enum sys_code { /** @name Kernel management. */ /** @{ */ /** Configure system parameters (stack size etc.). */ - SYS_CONF_SET, + SYS_SET_CONF, /** Get system parameters. */ - SYS_CONF_GET, + SYS_GET_CONF, /** Set capability of thread. */ SYS_SET_CAP, @@ -153,8 +153,11 @@ enum sys_code { /** Request to handle IRQ. */ SYS_IRQ_REQ, + /** Retract IRQ. */ + SYS_FREE_IRQ, + /** Request a notification handler. */ - SYS_REQ_NOTIFICATION, + SYS_SET_HANDLER, /** Request a thread exits. */ SYS_EXIT, @@ -197,6 +200,19 @@ enum notify_flag { NOTIFY_ORPHANED = (1 << 3), }; +/** Types of powering off. Still unclear what difference there is between warm + * and cold reboot. */ +enum poweroff_type { + /** Shut down. */ + SYS_SHUTDOWN, + + /** Cold or complete reboot. */ + SYS_COLD_REBOOT, + + /** Warm or partial reboot. */ + SYS_WARM_REBOOT +}; + /* function declarations should be somewhere else, this file could be used in * userspace applications as well */ @@ -244,6 +260,63 @@ enum conf_param { CONF_PAGE_SIZE, }; +enum sys_cap { + /** Thread is allowed to set capabilities of other threads. */ + CAP_CAPS = (1 << 0), + + /** Thread is allowed to modify process statuses, create/exec/fork/etc. */ + CAP_PROC = (1 << 1), + + /** Thread is allowed to force notification in other thread. */ + CAP_NOTIFY = (1 << 2), + + /** Thread is allowed to shut down system. */ + CAP_POWER = (1 << 3), + + /** Thread is allowed to access configuration parameters. */ + CAP_CONF = (1 << 4), + + /** Thread is allowed to request to handle IRQs. */ + CAP_IRQ = (1 << 5), + + /** Thread is allowed to request notification handler. */ + CAP_SIGNAL = (1 << 6), + + /** Thread is allowed to request shared memory */ + CAP_SHARED = (1 << 7) +}; + +/** + * Status codes. + * Negative error codes are reserved for general usage, positive error codes are + * allowed to be function-specific, although that's sort of difficult to keep + * track of. + */ +enum sys_status { + /** Permission error. */ + ERR_PERM = -10, + /** Internal error, should probably halt */ + ERR_INT = -9, + /** Something went wrong :/ */ + ERR_MISC = -8, + /** Not initialized. */ + ERR_NOINIT = -7, + /** Invalid value. */ + ERR_INVAL = -6, + /** Already exists. */ + ERR_EXT = -5, + /** Out of memory. */ + ERR_OOMEM = -4, + /** Illegal address. */ + ERR_ADDR = -3, + /** Wrong alignment. */ + ERR_ALIGN = -2, + /** Not found. */ + ERR_NF = -1, + /** OK. */ + OK = 0, +}; + /** * Return structure of syscall. * \note Field names are generic, and can be used for whatever, @@ -255,19 +328,19 @@ struct sys_ret { sys_arg_t s; /** First argument. */ - sys_arg_t ar0; + sys_arg_t a0; /** Second argument. */ - sys_arg_t ar1; + sys_arg_t a1; /** Third argument. */ - sys_arg_t ar2; + sys_arg_t a2; /** Fourth argument. */ - sys_arg_t ar3; + sys_arg_t a3; /** Fifth argument. */ - sys_arg_t ar4; + sys_arg_t a4; }; #endif /* KMI_SYSCALLS_H */ diff --git a/include/kmi/tcb.h b/include/kmi/tcb.h index a06d801..a6522f8 100644 --- a/include/kmi/tcb.h +++ b/include/kmi/tcb.h @@ -184,7 +184,7 @@ struct tcb { enum notify_flag notify_flags; /** Capabilities of thread. */ - capflags_t caps; + enum sys_cap caps; /** Queue that connects together threads waiting for an ipi */ struct queue_head ipi_queue; diff --git a/include/kmi/types.h b/include/kmi/types.h index 1da5248..040d3c6 100644 --- a/include/kmi/types.h +++ b/include/kmi/types.h @@ -459,38 +459,6 @@ typedef int_fast32_t id_t; /** Memory region flags. */ typedef uint_fast16_t vmflags_t; -/** - * Status codes. - * Negative error codes are reserved for general usage, positive error codes are - * allowed to be function-specific, although that's sort of difficult to keep - * track of. - */ -/* should this enum be somewhere else? */ -enum status_codes { - /** Permission error. */ - ERR_PERM = -10, - /** Internal error, should probably halt */ - ERR_INT = -9, - /** Something went wrong :/ */ - ERR_MISC = -8, - /** Not initialized. */ - ERR_NOINIT = -7, - /** Invalid value. */ - ERR_INVAL = -6, - /** Already exists. */ - ERR_EXT = -5, - /** Out of memory. */ - ERR_OOMEM = -4, - /** Illegal address. */ - ERR_ADDR = -3, - /** Wrong alignment. */ - ERR_ALIGN = -2, - /** Not found. */ - ERR_NF = -1, - /** OK. */ - OK = 0, -}; - #include <arch/types.h> /* arch-specific type definitions (pm_t/vm_t etc) */ #endif /* KMI_TYPES_H */ diff --git a/include/kmi/uapi.h b/include/kmi/uapi.h index 350285f..3f03879 100644 --- a/include/kmi/uapi.h +++ b/include/kmi/uapi.h @@ -697,7 +697,7 @@ SYSCALL_DECLARE1(swap, tid); * * Returns \ref OK and 0. */ -SYSCALL_DECLARE2(conf_set, param, val); +SYSCALL_DECLARE2(set_conf, param, val); /** * Get configuration syscall. @@ -713,49 +713,49 @@ SYSCALL_DECLARE2(conf_set, param, val); * * Returns \ref OK. */ -SYSCALL_DECLARE2(conf_get, param, d0); +SYSCALL_DECLARE2(get_conf, param, d0); /** * Set capabilities. * * @param t Current tcb. * @param tid Thread ID whose capabilities to set. - * @param off Offset of capability, multiple of \c bits(cap). * @param caps Mask of capabilities to set. + * @param c Unused. * @param d Unused. * @param e Unused. * * Returns \ref OK on success, \ref ERR_INVAL on invalid input. */ -SYSCALL_DECLARE3(set_cap, tid, off, caps); +SYSCALL_DECLARE2(set_cap, tid, caps); /** * Get capabilities. * * @param t Current tcb. * @param tid Thread ID whose capabilities to get. - * @param off Offset of capability, multiple of \c bits(cap). + * @param b Unused. * @param c Unused. * @param d Unused. * @param e Unused. * * Returns \ref OK, capabilities. */ -SYSCALL_DECLARE2(get_cap, tid, off); +SYSCALL_DECLARE1(cap_get, tid); /** * Clear capabilities. * * @param t Current tcb. * @param tid Thread ID whose capabilities to clear. - * @param off Offset of capability, multiple of \c bits(cap). * @param cap Mask of capabilities to clear. + * @param c Unused. * @param d Unused. * @param e Unused. * * Returns \ref OK. */ -SYSCALL_DECLARE3(clear_cap, tid, off, cap); +SYSCALL_DECLARE2(clear_cap, tid, cap); /** * Set which process to move notifications to for thread. @@ -771,7 +771,7 @@ SYSCALL_DECLARE3(clear_cap, tid, off, cap); * * Returns \ref OK. */ -SYSCALL_DECLARE2(req_notification, tid, pid); +SYSCALL_DECLARE2(set_handler, tid, pid); /** * Power off syscall. |
