Changeset 6b10dab in mainline


Ignore:
Timestamp:
2010-12-14T15:26:36Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dd8d5a7
Parents:
96b02eb9
Message:

ABI split: pass 64-bit task ID as plain 64-bit argument to SYS_IPC_CONNECT_KBOX, SYS_CAP_GRANT, SYS_CAP_REVOKE

Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • contrib/arch/kernel/kernel.adl

    r96b02eb9 r6b10dab  
    166166interface sys_cap {
    167167                /* 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
    169175               
    170176                /* 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
    172184        protocol:
    173185                (
     
    221233interface sys_debug {
    222234                /* 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
    224242        protocol:
    225243                ?sys_ipc_connect_kbox*
  • kernel/generic/include/ipc/sysipc.h

    r96b02eb9 r6b10dab  
    4040#include <typedefs.h>
    4141
    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);
     42extern sysarg_t sys_ipc_call_sync_fast(sysarg_t, sysarg_t, sysarg_t,
     43    sysarg_t, sysarg_t, ipc_data_t *);
     44extern sysarg_t sys_ipc_call_sync_slow(sysarg_t, ipc_data_t *, ipc_data_t *);
     45extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t,
     46    sysarg_t, sysarg_t, sysarg_t);
     47extern sysarg_t sys_ipc_call_async_slow(sysarg_t, ipc_data_t *);
     48extern sysarg_t sys_ipc_answer_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     49    sysarg_t, sysarg_t);
     50extern sysarg_t sys_ipc_answer_slow(sysarg_t, ipc_data_t *);
     51extern sysarg_t sys_ipc_wait_for_call(ipc_data_t *, uint32_t, unsigned int);
    5452extern 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);
     53extern sysarg_t sys_ipc_forward_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     54    sysarg_t, unsigned int);
     55extern sysarg_t sys_ipc_forward_slow(sysarg_t, sysarg_t, ipc_data_t *,
     56    unsigned int);
     57extern sysarg_t sys_ipc_hangup(sysarg_t);
     58extern sysarg_t sys_ipc_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *);
     59extern sysarg_t sys_ipc_unregister_irq(inr_t, devno_t);
     60
     61#ifdef __32_BITS__
     62
     63extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *);
     64
     65#endif  /* __32_BITS__ */
     66
     67#ifdef __64_BITS__
     68
     69extern sysarg_t sys_ipc_connect_kbox(sysarg_t);
     70
     71#endif  /* __64_BITS__ */
    6472
    6573#endif
  • kernel/generic/include/security/cap.h

    r96b02eb9 r6b10dab  
    4848#define __CAP_H__
    4949
    50 #include <syscall/sysarg64.h>
    5150#include <typedefs.h>
    5251
     
    5554 * privilege to/from other tasks.
    5655 */
    57 #define CAP_CAP                 (1<<0)
     56#define CAP_CAP  (1 << 0)
    5857
    5958/**
     
    6160 * to other tasks.
    6261 */
    63 #define CAP_MEM_MANAGER         (1<<1)
     62#define CAP_MEM_MANAGER  (1 << 1)
    6463
    6564/**
     
    6766 * to other tasks.
    6867 */
    69 #define CAP_IO_MANAGER          (1<<2)
     68#define CAP_IO_MANAGER  (1 << 2)
    7069
    7170/**
    7271 * CAP_IRQ_REG entitles its holder to register IRQ handlers.
    7372 */
    74 #define CAP_IRQ_REG             (1<<3)
     73#define CAP_IRQ_REG  (1 << 3)
    7574
    7675typedef uint32_t cap_t;
    7776
    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
     79extern sysarg_t sys_cap_grant(sysarg64_t *, cap_t);
     80extern sysarg_t sys_cap_revoke(sysarg64_t *, cap_t);
     81
     82#endif  /* __32_BITS__ */
     83
     84#ifdef __64_BITS__
     85
     86extern sysarg_t sys_cap_grant(sysarg_t, cap_t);
     87extern sysarg_t sys_cap_revoke(sysarg_t, cap_t);
     88
     89#endif  /* __64_BITS__ */
    8090
    8191#endif
  • kernel/generic/include/syscall/syscall.h

    r96b02eb9 r6b10dab  
    3838typedef enum {
    3939        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) */
    4141       
    4242        SYS_THREAD_CREATE,
     
    7171        SYS_IPC_REGISTER_IRQ,
    7272        SYS_IPC_UNREGISTER_IRQ,
     73        SYS_IPC_CONNECT_KBOX,
    7374       
    7475        SYS_EVENT_SUBSCRIBE,
     
    9091        SYS_DEBUG_DISABLE_CONSOLE,
    9192       
    92         SYS_IPC_CONNECT_KBOX,
    9393        SYSCALL_END
    9494} syscall_t;
  • kernel/generic/include/typedefs.h

    r96b02eb9 r6b10dab  
    7373typedef volatile uint32_t ioport32_t;
    7474
     75#ifdef __32_BITS__
     76
     77/** Explicit 64-bit arguments passed to syscalls. */
     78typedef uint64_t sysarg64_t;
     79
     80#endif /* __32_BITS__ */
     81
    7582#endif
    7683
  • kernel/generic/src/ipc/sysipc.c

    r96b02eb9 r6b10dab  
    4949#include <syscall/copy.h>
    5050#include <security/cap.h>
     51#include <console/console.h>
    5152#include <mm/as.h>
    5253#include <print.h>
     
    11281129}
    11291130
    1130 #include <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)
    11331134 *
    11341135 * @return Phone id on success, or negative error code.
    11351136 *
    11361137 */
    1137 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg)
     1138sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid)
    11381139{
    11391140#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));
    11421143        if (rc != 0)
    11431144                return (sysarg_t) rc;
    11441145       
    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);
    11481147#else
    11491148        return (sysarg_t) ENOTSUP;
     
    11511150}
    11521151
     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 */
     1161sysarg_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
    11531172/** @}
    11541173 */
  • kernel/generic/src/security/cap.c

    r96b02eb9 r6b10dab  
    4141#include <proc/task.h>
    4242#include <synch/spinlock.h>
    43 #include <syscall/sysarg64.h>
    4443#include <syscall/copy.h>
    4544#include <arch.h>
     
    7978 * The calling task must have the CAP_CAP capability.
    8079 *
    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 sysarg_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 */
     86static sysarg_t cap_grant(task_id_t taskid, cap_t caps)
    8887{
    8988        if (!(cap_get(TASK) & CAP_CAP))
    9089                return (sysarg_t) EPERM;
    9190       
    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        
    9791        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);
    9993       
    10094        if ((!task) || (!context_check(CONTEXT, task->context))) {
     
    116110 * attempt to revoke capabilities from itself.
    117111 *
    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 */
     118static sysarg_t cap_revoke(task_id_t taskid, cap_t caps)
     119{
    131120        irq_spinlock_lock(&tasks_lock, true);
    132121       
    133         task_t *task = task_find_by_id((task_id_t) taskid_arg.value);
     122        task_t *task = task_find_by_id(taskid);
    134123        if ((!task) || (!context_check(CONTEXT, task->context))) {
    135124                irq_spinlock_unlock(&tasks_lock, true);
     
    157146}
    158147
     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 */
     160sysarg_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 */
     181sysarg_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 */
     205sysarg_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 */
     221sysarg_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
    159228/** @}
    160229 */
  • kernel/generic/src/syscall/syscall.c

    r96b02eb9 r6b10dab  
    147147        (syshandler_t) sys_ipc_register_irq,
    148148        (syshandler_t) sys_ipc_unregister_irq,
     149        (syshandler_t) sys_ipc_connect_kbox,
    149150       
    150151        /* Event notification syscalls. */
     
    169170        /* Debug calls */
    170171        (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
    174173};
    175174
  • uspace/lib/c/generic/cap.c

    r96b02eb9 r6b10dab  
    3131 */
    3232/**
    33  * @file        cap.c
    34  * @brief       Functions to grant/revoke capabilities to/from a task.
     33 * @file  cap.c
     34 * @brief Functions to grant/revoke capabilities to/from a task.
    3535 */
    3636
     
    3838#include <task.h>
    3939#include <libc.h>
    40 #include <kernel/syscall/sysarg64.h>
    4140
    4241/** Grant capabilities to a task.
    4342 *
    44  * @param id Destination task ID.
     43 * @param id   Destination task ID.
    4544 * @param caps Capabilities to grant.
    4645 *
    4746 * @return Zero on success or a value from @ref errno.h on failure.
     47 *
    4848 */
    4949int cap_grant(task_id_t id, unsigned int caps)
    5050{
    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
    5255       
    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
    5659}
    5760
    5861/** Revoke capabilities from a task.
    5962 *
    60  * @param id Destination task ID.
     63 * @param id   Destination task ID.
    6164 * @param caps Capabilities to revoke.
    6265 *
    6366 * @return Zero on success or a value from @ref errno.h on failure.
     67 *
    6468 */
    6569int cap_revoke(task_id_t id, unsigned int caps)
    6670{
    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
    6875       
    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
    7279}
    7380
  • uspace/lib/c/generic/ipc.c

    r96b02eb9 r6b10dab  
    3838 */
    3939/** @file
    40  */ 
     40 */
    4141
    4242#include <ipc/ipc.h>
     
    845845}
    846846
    847 #include <kernel/syscall/sysarg64.h>
    848847/** Connect to a task specified by id.
     848 *
    849849 */
    850850int ipc_connect_kbox(task_id_t id)
    851851{
    852         sysarg64_t arg;
    853 
    854         arg.value = (unsigned long long) id;
    855 
     852#ifdef __32_BITS__
     853        sysarg64_t arg = (sysarg64_t) id;
    856854        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
    859862/** @}
    860863 */
  • uspace/lib/c/include/libc.h

    r96b02eb9 r6b10dab  
    4040#include <libarch/syscall.h>
    4141
     42#ifdef __32_BITS__
     43
     44/** Explicit 64-bit arguments passed to syscalls. */
     45typedef uint64_t sysarg64_t;
     46
     47#endif /* __32_BITS__ */
     48
    4249#define __SYSCALL0(id) \
    4350        __syscall0(0, 0, 0, 0, 0, 0, id)
     
    5360        __syscall5(p1, p2, p3, p4, p5, 0, id)
    5461#define __SYSCALL6(id, p1, p2, p3, p4, p5, p6) \
    55     __syscall6(p1, p2, p3, p4, p5, p6, id)
     62        __syscall6(p1, p2, p3, p4, p5, p6, id)
    5663
    5764extern void __main(void *pcb_ptr);
Note: See TracChangeset for help on using the changeset viewer.