Changeset 6b10dab in mainline
- Timestamp:
- 2010-12-14T15:26:36Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dd8d5a7
- Parents:
- 96b02eb9
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/kernel/kernel.adl
r96b02eb9 r6b10dab 166 166 interface sys_cap { 167 167 /* Grant capabilities to a task */ 168 sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps); 168 #ifdef __32_BITS__ 169 sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid, cap_t caps); 170 #endif 171 172 #ifdef __64_BITS__ 173 sysarg_t sys_cap_grant(sysarg_t taskid, cap_t caps); 174 #endif 169 175 170 176 /* Revoke capabilities from a task */ 171 sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps); 177 #ifdef __32_BITS__ 178 sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid, cap_t caps); 179 #endif 180 181 #ifdef __64_BITS__ 182 sysarg_t sys_cap_revoke(sysarg_t taskid, cap_t caps); 183 #endif 172 184 protocol: 173 185 ( … … 221 233 interface sys_debug { 222 234 /* Connect to the kernel debugging answerbox of a given task */ 223 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg); 235 #ifdef __32_BITS__ 236 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid); 237 #endif 238 239 #ifdef __64_BITS__ 240 sysarg_t sys_ipc_connect_kbox(sysarg_t taskid); 241 #endif 224 242 protocol: 225 243 ?sys_ipc_connect_kbox* -
kernel/generic/include/ipc/sysipc.h
r96b02eb9 r6b10dab 40 40 #include <typedefs.h> 41 41 42 extern sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t method, 43 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data); 44 extern sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *question, 45 ipc_data_t *reply); 46 extern sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t method, 47 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4); 48 extern sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data); 49 extern sysarg_t sys_ipc_answer_fast(sysarg_t callid, sysarg_t retval, 50 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4); 51 extern sysarg_t sys_ipc_answer_slow(sysarg_t callid, ipc_data_t *data); 52 extern sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 53 unsigned int nonblocking); 42 extern sysarg_t sys_ipc_call_sync_fast(sysarg_t, sysarg_t, sysarg_t, 43 sysarg_t, sysarg_t, ipc_data_t *); 44 extern sysarg_t sys_ipc_call_sync_slow(sysarg_t, ipc_data_t *, ipc_data_t *); 45 extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t, 46 sysarg_t, sysarg_t, sysarg_t); 47 extern sysarg_t sys_ipc_call_async_slow(sysarg_t, ipc_data_t *); 48 extern sysarg_t sys_ipc_answer_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 49 sysarg_t, sysarg_t); 50 extern sysarg_t sys_ipc_answer_slow(sysarg_t, ipc_data_t *); 51 extern sysarg_t sys_ipc_wait_for_call(ipc_data_t *, uint32_t, unsigned int); 54 52 extern sysarg_t sys_ipc_poke(void); 55 extern sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid, 56 sysarg_t method, sysarg_t arg1, sysarg_t arg2, unsigned int mode); 57 extern sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid, 58 ipc_data_t *data, unsigned int mode); 59 extern sysarg_t sys_ipc_hangup(sysarg_t phoneid); 60 extern sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t method, 61 irq_code_t *ucode); 62 extern sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno); 63 extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *task_id); 53 extern sysarg_t sys_ipc_forward_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 54 sysarg_t, unsigned int); 55 extern sysarg_t sys_ipc_forward_slow(sysarg_t, sysarg_t, ipc_data_t *, 56 unsigned int); 57 extern sysarg_t sys_ipc_hangup(sysarg_t); 58 extern sysarg_t sys_ipc_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *); 59 extern sysarg_t sys_ipc_unregister_irq(inr_t, devno_t); 60 61 #ifdef __32_BITS__ 62 63 extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *); 64 65 #endif /* __32_BITS__ */ 66 67 #ifdef __64_BITS__ 68 69 extern sysarg_t sys_ipc_connect_kbox(sysarg_t); 70 71 #endif /* __64_BITS__ */ 64 72 65 73 #endif -
kernel/generic/include/security/cap.h
r96b02eb9 r6b10dab 48 48 #define __CAP_H__ 49 49 50 #include <syscall/sysarg64.h>51 50 #include <typedefs.h> 52 51 … … 55 54 * privilege to/from other tasks. 56 55 */ 57 #define CAP_CAP (1<<0)56 #define CAP_CAP (1 << 0) 58 57 59 58 /** … … 61 60 * to other tasks. 62 61 */ 63 #define CAP_MEM_MANAGER (1<<1)62 #define CAP_MEM_MANAGER (1 << 1) 64 63 65 64 /** … … 67 66 * to other tasks. 68 67 */ 69 #define CAP_IO_MANAGER (1<<2)68 #define CAP_IO_MANAGER (1 << 2) 70 69 71 70 /** 72 71 * CAP_IRQ_REG entitles its holder to register IRQ handlers. 73 72 */ 74 #define CAP_IRQ_REG (1<<3)73 #define CAP_IRQ_REG (1 << 3) 75 74 76 75 typedef uint32_t cap_t; 77 76 78 extern sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps); 79 extern sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps); 77 #ifdef __32_BITS__ 78 79 extern sysarg_t sys_cap_grant(sysarg64_t *, cap_t); 80 extern sysarg_t sys_cap_revoke(sysarg64_t *, cap_t); 81 82 #endif /* __32_BITS__ */ 83 84 #ifdef __64_BITS__ 85 86 extern sysarg_t sys_cap_grant(sysarg_t, cap_t); 87 extern sysarg_t sys_cap_revoke(sysarg_t, cap_t); 88 89 #endif /* __64_BITS__ */ 80 90 81 91 #endif -
kernel/generic/include/syscall/syscall.h
r96b02eb9 r6b10dab 38 38 typedef enum { 39 39 SYS_KLOG = 0, 40 SYS_TLS_SET = 1, /* Hardcoded in AMD64, IA32 uspace - fibril.S*/40 SYS_TLS_SET = 1, /* Hardcoded for AMD64, IA-32 (fibril.S in uspace) */ 41 41 42 42 SYS_THREAD_CREATE, … … 71 71 SYS_IPC_REGISTER_IRQ, 72 72 SYS_IPC_UNREGISTER_IRQ, 73 SYS_IPC_CONNECT_KBOX, 73 74 74 75 SYS_EVENT_SUBSCRIBE, … … 90 91 SYS_DEBUG_DISABLE_CONSOLE, 91 92 92 SYS_IPC_CONNECT_KBOX,93 93 SYSCALL_END 94 94 } syscall_t; -
kernel/generic/include/typedefs.h
r96b02eb9 r6b10dab 73 73 typedef volatile uint32_t ioport32_t; 74 74 75 #ifdef __32_BITS__ 76 77 /** Explicit 64-bit arguments passed to syscalls. */ 78 typedef uint64_t sysarg64_t; 79 80 #endif /* __32_BITS__ */ 81 75 82 #endif 76 83 -
kernel/generic/src/ipc/sysipc.c
r96b02eb9 r6b10dab 49 49 #include <syscall/copy.h> 50 50 #include <security/cap.h> 51 #include <console/console.h> 51 52 #include <mm/as.h> 52 53 #include <print.h> … … 1128 1129 } 1129 1130 1130 #i nclude <console/console.h>1131 1132 /** Syscall connect to a task by id.1131 #ifdef __32_BITS__ 1132 1133 /** Syscall connect to a task by ID (32 bits) 1133 1134 * 1134 1135 * @return Phone id on success, or negative error code. 1135 1136 * 1136 1137 */ 1137 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid _arg)1138 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid) 1138 1139 { 1139 1140 #ifdef CONFIG_UDEBUG 1140 sysarg64_t taskid _arg;1141 int rc = copy_from_uspace(&taskid _arg, uspace_taskid_arg, sizeof(sysarg64_t));1141 sysarg64_t taskid; 1142 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 1142 1143 if (rc != 0) 1143 1144 return (sysarg_t) rc; 1144 1145 1145 LOG("sys_ipc_connect_kbox(%" PRIu64 ")", taskid_arg.value); 1146 1147 return ipc_connect_kbox(taskid_arg.value); 1146 return ipc_connect_kbox((task_id_t) taskid); 1148 1147 #else 1149 1148 return (sysarg_t) ENOTSUP; … … 1151 1150 } 1152 1151 1152 #endif /* __32_BITS__ */ 1153 1154 #ifdef __64_BITS__ 1155 1156 /** Syscall connect to a task by ID (64 bits) 1157 * 1158 * @return Phone id on success, or negative error code. 1159 * 1160 */ 1161 sysarg_t sys_ipc_connect_kbox(sysarg_t taskid) 1162 { 1163 #ifdef CONFIG_UDEBUG 1164 return ipc_connect_kbox((task_id_t) taskid); 1165 #else 1166 return (sysarg_t) ENOTSUP; 1167 #endif 1168 } 1169 1170 #endif /* __64_BITS__ */ 1171 1153 1172 /** @} 1154 1173 */ -
kernel/generic/src/security/cap.c
r96b02eb9 r6b10dab 41 41 #include <proc/task.h> 42 42 #include <synch/spinlock.h> 43 #include <syscall/sysarg64.h>44 43 #include <syscall/copy.h> 45 44 #include <arch.h> … … 79 78 * The calling task must have the CAP_CAP capability. 80 79 * 81 * @param uspace_taskid_arg Userspace structure holding destination task ID.82 * @param caps Capabilities to grant.83 * 84 * @return Zero on success or an error code from @ref errno.h. 85 * 86 */ 87 s ysarg_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps)80 * @param taskid Destination task ID. 81 * @param caps Capabilities to grant. 82 * 83 * @return Zero on success or an error code from @ref errno.h. 84 * 85 */ 86 static sysarg_t cap_grant(task_id_t taskid, cap_t caps) 88 87 { 89 88 if (!(cap_get(TASK) & CAP_CAP)) 90 89 return (sysarg_t) EPERM; 91 90 92 sysarg64_t taskid_arg;93 int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));94 if (rc != 0)95 return (sysarg_t) rc;96 97 91 irq_spinlock_lock(&tasks_lock, true); 98 task_t *task = task_find_by_id( (task_id_t) taskid_arg.value);92 task_t *task = task_find_by_id(taskid); 99 93 100 94 if ((!task) || (!context_check(CONTEXT, task->context))) { … … 116 110 * attempt to revoke capabilities from itself. 117 111 * 118 * @param uspace_taskid_arg Userspace structure holding destination task ID. 119 * @param caps Capabilities to revoke. 120 * 121 * @return Zero on success or an error code from @ref errno.h. 122 * 123 */ 124 sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps) 125 { 126 sysarg64_t taskid_arg; 127 int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); 128 if (rc != 0) 129 return (sysarg_t) rc; 130 112 * @param taskid Destination task ID. 113 * @param caps Capabilities to revoke. 114 * 115 * @return Zero on success or an error code from @ref errno.h. 116 * 117 */ 118 static sysarg_t cap_revoke(task_id_t taskid, cap_t caps) 119 { 131 120 irq_spinlock_lock(&tasks_lock, true); 132 121 133 task_t *task = task_find_by_id( (task_id_t) taskid_arg.value);122 task_t *task = task_find_by_id(taskid); 134 123 if ((!task) || (!context_check(CONTEXT, task->context))) { 135 124 irq_spinlock_unlock(&tasks_lock, true); … … 157 146 } 158 147 148 #ifdef __32_BITS__ 149 150 /** Grant capabilities to a task (32 bits) 151 * 152 * The calling task must have the CAP_CAP capability. 153 * 154 * @param uspace_taskid User-space pointer to destination task ID. 155 * @param caps Capabilities to grant. 156 * 157 * @return Zero on success or an error code from @ref errno.h. 158 * 159 */ 160 sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid, cap_t caps) 161 { 162 sysarg64_t taskid; 163 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 164 if (rc != 0) 165 return (sysarg_t) rc; 166 167 return cap_grant((task_id_t) taskid, caps); 168 } 169 170 /** Revoke capabilities from a task (32 bits) 171 * 172 * The calling task must have the CAP_CAP capability or the caller must 173 * attempt to revoke capabilities from itself. 174 * 175 * @param uspace_taskid User-space pointer to destination task ID. 176 * @param caps Capabilities to revoke. 177 * 178 * @return Zero on success or an error code from @ref errno.h. 179 * 180 */ 181 sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid, cap_t caps) 182 { 183 sysarg64_t taskid; 184 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 185 if (rc != 0) 186 return (sysarg_t) rc; 187 188 return cap_revoke((task_id_t) taskid, caps); 189 } 190 191 #endif /* __32_BITS__ */ 192 193 #ifdef __64_BITS__ 194 195 /** Grant capabilities to a task (64 bits) 196 * 197 * The calling task must have the CAP_CAP capability. 198 * 199 * @param taskid Destination task ID. 200 * @param caps Capabilities to grant. 201 * 202 * @return Zero on success or an error code from @ref errno.h. 203 * 204 */ 205 sysarg_t sys_cap_grant(sysarg_t taskid, cap_t caps) 206 { 207 return cap_grant((task_id_t) taskid, caps); 208 } 209 210 /** Revoke capabilities from a task (64 bits) 211 * 212 * The calling task must have the CAP_CAP capability or the caller must 213 * attempt to revoke capabilities from itself. 214 * 215 * @param taskid Destination task ID. 216 * @param caps Capabilities to revoke. 217 * 218 * @return Zero on success or an error code from @ref errno.h. 219 * 220 */ 221 sysarg_t sys_cap_revoke(sysarg_t taskid, cap_t caps) 222 { 223 return cap_revoke((task_id_t) taskid, caps); 224 } 225 226 #endif /* __64_BITS__ */ 227 159 228 /** @} 160 229 */ -
kernel/generic/src/syscall/syscall.c
r96b02eb9 r6b10dab 147 147 (syshandler_t) sys_ipc_register_irq, 148 148 (syshandler_t) sys_ipc_unregister_irq, 149 (syshandler_t) sys_ipc_connect_kbox, 149 150 150 151 /* Event notification syscalls. */ … … 169 170 /* Debug calls */ 170 171 (syshandler_t) sys_debug_enable_console, 171 (syshandler_t) sys_debug_disable_console, 172 173 (syshandler_t) sys_ipc_connect_kbox 172 (syshandler_t) sys_debug_disable_console 174 173 }; 175 174 -
uspace/lib/c/generic/cap.c
r96b02eb9 r6b10dab 31 31 */ 32 32 /** 33 * @file 34 * @brief 33 * @file cap.c 34 * @brief Functions to grant/revoke capabilities to/from a task. 35 35 */ 36 36 … … 38 38 #include <task.h> 39 39 #include <libc.h> 40 #include <kernel/syscall/sysarg64.h>41 40 42 41 /** Grant capabilities to a task. 43 42 * 44 * @param id Destination task ID.43 * @param id Destination task ID. 45 44 * @param caps Capabilities to grant. 46 45 * 47 46 * @return Zero on success or a value from @ref errno.h on failure. 47 * 48 48 */ 49 49 int cap_grant(task_id_t id, unsigned int caps) 50 50 { 51 sysarg64_t arg; 51 #ifdef __32_BITS__ 52 sysarg64_t arg = (sysarg64_t) id; 53 return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps); 54 #endif 52 55 53 arg.value = (unsigned long long) id; 54 55 return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps); 56 #ifdef __64_BITS__ 57 return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) id, (sysarg_t) caps); 58 #endif 56 59 } 57 60 58 61 /** Revoke capabilities from a task. 59 62 * 60 * @param id Destination task ID.63 * @param id Destination task ID. 61 64 * @param caps Capabilities to revoke. 62 65 * 63 66 * @return Zero on success or a value from @ref errno.h on failure. 67 * 64 68 */ 65 69 int cap_revoke(task_id_t id, unsigned int caps) 66 70 { 67 sysarg64_t arg; 71 #ifdef __32_BITS__ 72 sysarg64_t arg = (sysarg64_t) id; 73 return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps); 74 #endif 68 75 69 arg.value = (unsigned long long) id; 70 71 return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps); 76 #ifdef __64_BITS__ 77 return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) id, (sysarg_t) caps); 78 #endif 72 79 } 73 80 -
uspace/lib/c/generic/ipc.c
r96b02eb9 r6b10dab 38 38 */ 39 39 /** @file 40 */ 40 */ 41 41 42 42 #include <ipc/ipc.h> … … 845 845 } 846 846 847 #include <kernel/syscall/sysarg64.h>848 847 /** Connect to a task specified by id. 848 * 849 849 */ 850 850 int ipc_connect_kbox(task_id_t id) 851 851 { 852 sysarg64_t arg; 853 854 arg.value = (unsigned long long) id; 855 852 #ifdef __32_BITS__ 853 sysarg64_t arg = (sysarg64_t) id; 856 854 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg); 857 } 858 855 #endif 856 857 #ifdef __64_BITS__ 858 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) id); 859 #endif 860 } 861 859 862 /** @} 860 863 */ -
uspace/lib/c/include/libc.h
r96b02eb9 r6b10dab 40 40 #include <libarch/syscall.h> 41 41 42 #ifdef __32_BITS__ 43 44 /** Explicit 64-bit arguments passed to syscalls. */ 45 typedef uint64_t sysarg64_t; 46 47 #endif /* __32_BITS__ */ 48 42 49 #define __SYSCALL0(id) \ 43 50 __syscall0(0, 0, 0, 0, 0, 0, id) … … 53 60 __syscall5(p1, p2, p3, p4, p5, 0, id) 54 61 #define __SYSCALL6(id, p1, p2, p3, p4, p5, p6) \ 55 62 __syscall6(p1, p2, p3, p4, p5, p6, id) 56 63 57 64 extern void __main(void *pcb_ptr);
Note:
See TracChangeset
for help on using the changeset viewer.