Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/ipc.h

    rda1bafb r21580dd  
    3636#define KERN_IPC_H_
    3737
    38 /** Length of data being transfered with IPC call
    39  *
    40  * The uspace may not be able to utilize full length
    41  *
    42  */
    43 #define IPC_CALL_LEN  6
     38/* Length of data being transfered with IPC call */
     39/* - the uspace may not be able to utilize full length */
     40#define IPC_CALL_LEN            6       
    4441
    4542/** Maximum active async calls per thread */
    4643#ifdef CONFIG_DEBUG
    47         #define IPC_MAX_ASYNC_CALLS  4
     44#define IPC_MAX_ASYNC_CALLS     4
    4845#else
    49         #define IPC_MAX_ASYNC_CALLS  4000
     46#define IPC_MAX_ASYNC_CALLS     4000
    5047#endif
    5148
     
    5350
    5451/** This is answer to a call */
    55 #define IPC_CALL_ANSWERED  (1 << 0)
    56 
     52#define IPC_CALL_ANSWERED       (1 << 0)
    5753/** Answer will not be passed to userspace, will be discarded */
    58 #define IPC_CALL_DISCARD_ANSWER  (1 << 1)
    59 
     54#define IPC_CALL_DISCARD_ANSWER (1 << 1)
    6055/** Call was forwarded */
    61 #define IPC_CALL_FORWARDED  (1 << 2)
    62 
     56#define IPC_CALL_FORWARDED      (1 << 2)
    6357/** Identify connect_me_to answer */
    64 #define IPC_CALL_CONN_ME_TO  (1 << 3)
    65 
     58#define IPC_CALL_CONN_ME_TO     (1 << 3)
    6659/** Interrupt notification */
    67 #define IPC_CALL_NOTIF  (1 << 4)
    68 
    69 
    70 /** Bits used in call hashes.
    71  *
     60#define IPC_CALL_NOTIF          (1 << 4)
     61
     62/*
     63 * Bits used in call hashes.
    7264 * The addresses are aligned at least to 4 that is why we can use the 2 least
    7365 * significant bits of the call address.
    74  *
    75  */
    76 
     66 */
    7767/** Type of this call is 'answer' */
    78 #define IPC_CALLID_ANSWERED  1
    79 
     68#define IPC_CALLID_ANSWERED     1
    8069/** Type of this call is 'notification' */
    81 #define IPC_CALLID_NOTIFICATION  2
     70#define IPC_CALLID_NOTIFICATION 2
    8271
    8372/* Return values from sys_ipc_call_async(). */
    84 #define IPC_CALLRET_FATAL      -1
    85 #define IPC_CALLRET_TEMPORARY  -2
     73#define IPC_CALLRET_FATAL       -1
     74#define IPC_CALLRET_TEMPORARY   -2
    8675
    8776
    8877/* Macros for manipulating calling data */
    89 #define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (retval))
    90 #define IPC_SET_METHOD(data, val)     ((data).args[0] = (val))
    91 #define IPC_SET_ARG1(data, val)       ((data).args[1] = (val))
    92 #define IPC_SET_ARG2(data, val)       ((data).args[2] = (val))
    93 #define IPC_SET_ARG3(data, val)       ((data).args[3] = (val))
    94 #define IPC_SET_ARG4(data, val)       ((data).args[4] = (val))
    95 #define IPC_SET_ARG5(data, val)       ((data).args[5] = (val))
    96 
    97 #define IPC_GET_METHOD(data)  ((data).args[0])
    98 #define IPC_GET_RETVAL(data)  ((data).args[0])
    99 
    100 #define IPC_GET_ARG1(data)  ((data).args[1])
    101 #define IPC_GET_ARG2(data)  ((data).args[2])
    102 #define IPC_GET_ARG3(data)  ((data).args[3])
    103 #define IPC_GET_ARG4(data)  ((data).args[4])
    104 #define IPC_GET_ARG5(data)  ((data).args[5])
     78#define IPC_SET_RETVAL(data, retval)    ((data).args[0] = (retval))
     79#define IPC_SET_METHOD(data, val)       ((data).args[0] = (val))
     80#define IPC_SET_ARG1(data, val)         ((data).args[1] = (val))
     81#define IPC_SET_ARG2(data, val)         ((data).args[2] = (val))
     82#define IPC_SET_ARG3(data, val)         ((data).args[3] = (val))
     83#define IPC_SET_ARG4(data, val)         ((data).args[4] = (val))
     84#define IPC_SET_ARG5(data, val)         ((data).args[5] = (val))
     85
     86#define IPC_GET_METHOD(data)            ((data).args[0])
     87#define IPC_GET_RETVAL(data)            ((data).args[0])
     88
     89#define IPC_GET_ARG1(data)              ((data).args[1])
     90#define IPC_GET_ARG2(data)              ((data).args[2])
     91#define IPC_GET_ARG3(data)              ((data).args[3])
     92#define IPC_GET_ARG4(data)              ((data).args[4])
     93#define IPC_GET_ARG5(data)              ((data).args[5])
    10594
    10695/* Well known phone descriptors */
    107 #define PHONE_NS  0
     96#define PHONE_NS        0
    10897
    10998/* Forwarding flags. */
    110 #define IPC_FF_NONE  0
    111 
     99#define IPC_FF_NONE             0
    112100/**
    113101 * The call will be routed as though it was initially sent via the phone used to
     
    116104 * calls that were initially sent by the forwarder to the same destination. This
    117105 * flag has no imapct on routing replies.
    118  *
    119  */
    120 #define IPC_FF_ROUTE_FROM_ME  (1 << 0)
    121 
    122 /** System-specific methods - only through special syscalls
     106 */
     107#define IPC_FF_ROUTE_FROM_ME    (1 << 0)
     108
     109/* System-specific methods - only through special syscalls
    123110 * These methods have special behaviour
    124  *
    125  */
    126 
     111 */
    127112/** Clone connection.
    128113 *
     
    130115 *
    131116 * - ARG1 - The caller sets ARG1 to the phone of the cloned connection.
    132  *        - The callee gets the new phone from ARG1.
    133  *
     117 *        - The callee gets the new phone from ARG1.
    134118 * - on answer, the callee acknowledges the new connection by sending EOK back
    135119 *   or the kernel closes it
    136  *
    137  */
    138 #define IPC_M_CONNECTION_CLONE  1
    139 
     120 */
     121#define IPC_M_CONNECTION_CLONE  1
    140122/** Protocol for CONNECT - ME
    141123 *
    142124 * Through this call, the recipient learns about the new cloned connection.
    143  *
     125 * 
    144126 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone
    145127 * - on asnwer, the callee acknowledges the new connection by sending EOK back
    146128 *   or the kernel closes it
    147  *
    148  */
    149 #define IPC_M_CONNECT_ME  2
    150 
    151 /** Protocol for CONNECT - TO - ME
     129 */
     130#define IPC_M_CONNECT_ME        2
     131/** Protocol for CONNECT - TO - ME
    152132 *
    153133 * Calling process asks the callee to create a callback connection,
     
    164144 *                     - the allocated phoneid is passed to userspace
    165145 *                       (on the receiving side) as ARG5 of the call.
    166  *
    167  */
    168 #define IPC_M_CONNECT_TO_ME  3
    169 
     146 */
     147#define IPC_M_CONNECT_TO_ME     3       
    170148/** Protocol for CONNECT - ME - TO
    171149 *
     
    185163 *
    186164 */
    187 #define IPC_M_CONNECT_ME_TO  4
    188 
    189 /** This message is sent to answerbox when the phone is hung up
    190  *
    191  */
    192 #define IPC_M_PHONE_HUNGUP  5
     165#define IPC_M_CONNECT_ME_TO     4       
     166/** This message is sent to answerbox when the phone
     167 * is hung up
     168 */
     169#define IPC_M_PHONE_HUNGUP      5
    193170
    194171/** Send as_area over IPC.
     
    196173 * - ARG2 - size of source as_area (filled automatically by kernel)
    197174 * - ARG3 - flags of the as_area being sent
    198  *
     175 * 
    199176 * on answer, the recipient must set:
    200177 * - ARG1 - dst as_area base adress
    201  *
    202  */
    203 #define IPC_M_SHARE_OUT  6
     178 */
     179#define IPC_M_SHARE_OUT         6       
    204180
    205181/** Receive as_area over IPC.
     
    207183 * - ARG2 - destination as_area size
    208184 * - ARG3 - user defined argument
    209  *
     185 * 
    210186 * on answer, the recipient must set:
    211187 *
    212188 * - ARG1 - source as_area base address
    213189 * - ARG2 - flags that will be used for sharing
    214  *
    215  */
    216 #define IPC_M_SHARE_IN  7
     190 */
     191#define IPC_M_SHARE_IN          7       
    217192
    218193/** Send data to another address space over IPC.
     
    224199 * - ARG1 - final destination address space virtual address
    225200 * - ARG2 - final size of data to be copied
    226  *
    227  */
    228 #define IPC_M_DATA_WRITE  8
     201 */
     202#define IPC_M_DATA_WRITE        8
    229203
    230204/** Receive data from another address space over IPC.
     
    236210 * - ARG1 - source virtual address in the destination address space
    237211 * - ARG2 - final size of data to be copied
    238  *
    239  */
    240 #define IPC_M_DATA_READ  9
     212 */
     213#define IPC_M_DATA_READ         9
    241214
    242215/** Debug the recipient.
    243216 * - ARG1 - specifies the debug method (from udebug_method_t)
    244217 * - other arguments are specific to the debug method
    245  *
    246  */
    247 #define IPC_M_DEBUG_ALL  10
     218 */
     219#define IPC_M_DEBUG_ALL         10
    248220
    249221/* Well-known methods */
    250 #define IPC_M_LAST_SYSTEM  511
    251 #define IPC_M_PING         512
    252 
     222#define IPC_M_LAST_SYSTEM       511
     223#define IPC_M_PING              512
    253224/* User methods */
    254 #define IPC_FIRST_USER_METHOD  1024
     225#define IPC_FIRST_USER_METHOD   1024
    255226
    256227#ifdef KERNEL
     
    288259
    289260typedef struct answerbox {
    290         IRQ_SPINLOCK_DECLARE(lock);
    291        
     261        SPINLOCK_DECLARE(lock);
     262
    292263        struct task *task;
    293        
     264
    294265        waitq_t wq;
    295        
     266
    296267        /** Linkage for the list of task's synchronous answerboxes. */
    297268        link_t sync_box_link;
    298        
     269
    299270        /** Phones connected to this answerbox. */
    300271        link_t connected_phones;
    301272        /** Received calls. */
    302         link_t calls;
    303         link_t dispatched_calls;  /* Should be hash table in the future */
    304        
     273        link_t calls;                   
     274        link_t dispatched_calls;        /* Should be hash table in the future */
     275
    305276        /** Answered calls. */
    306277        link_t answers;
    307        
    308         IRQ_SPINLOCK_DECLARE(irq_lock);
    309        
     278
     279        SPINLOCK_DECLARE(irq_lock);
    310280        /** Notifications from IRQ handlers. */
    311281        link_t irq_notifs;
     
    321291typedef struct {
    322292        link_t link;
    323        
    324         unsigned int flags;
    325        
     293
     294        int flags;
     295
    326296        /** Identification of the caller. */
    327297        struct task *sender;
    328        
    329         /*
    330          * The caller box is different from sender->answerbox
    331          * for synchronous calls.
    332          *
    333          */
     298        /** The caller box is different from sender->answerbox for synchronous
     299         *  calls. */
    334300        answerbox_t *callerbox;
    335        
     301
    336302        /** Private data to internal IPC. */
    337303        unative_t priv;
    338        
     304
    339305        /** Data passed from/to userspace. */
    340306        ipc_data_t data;
    341        
     307
    342308        /** Buffer for IPC_M_DATA_WRITE and IPC_M_DATA_READ. */
    343309        uint8_t *buffer;
    344        
     310
    345311        /*
    346312         * The forward operation can masquerade the caller phone. For those
    347313         * cases, we must keep it aside so that the answer is processed
    348314         * correctly.
    349          *
    350315         */
    351316        phone_t *caller_phone;
    352317} call_t;
    353318
     319
    354320extern answerbox_t *ipc_phone_0;
    355321
     322
    356323extern void ipc_init(void);
    357324
    358 extern call_t *ipc_call_alloc(unsigned int);
     325extern call_t * ipc_call_alloc(int);
    359326extern void ipc_call_free(call_t *);
    360327
    361328extern int ipc_call(phone_t *, call_t *);
    362329extern int ipc_call_sync(phone_t *, call_t *);
    363 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int);
    364 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int);
     330extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, int);
     331extern int ipc_forward(call_t *, phone_t *, answerbox_t *, int);
    365332extern void ipc_answer(answerbox_t *, call_t *);
    366333
     
    378345extern void ipc_print_task(task_id_t);
    379346
    380 #endif /* KERNEL */
    381 
    382347#endif
    383348
     349#endif
     350
    384351/** @}
    385352 */
Note: See TracChangeset for help on using the changeset viewer.