Changeset fbcfd458 in mainline for generic/include/ipc/ipc.h


Ignore:
Timestamp:
2006-03-18T23:02:08Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b4b45210
Parents:
ba81cab
Message:

Untested better IPC functions.

  • There is some bug in MIPS, unpredicatbly sometimes the thread gets mapped

different frame for stack.

File:
1 edited

Legend:

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

    rba81cab rfbcfd458  
    3838
    3939/* Flags for calls */
    40 #define IPC_CALL_ANSWERED      0x1 /**< This is answer to a call */
    41 #define IPC_CALL_STATIC_ALLOC  0x2 /**< This call will not be freed on error */
    42 #define IPC_CALL_DISPATCHED    0x4 /**< Call is in dispatch queue */
     40#define IPC_CALL_ANSWERED     (1<<0) /**< This is answer to a call */
     41#define IPC_CALL_STATIC_ALLOC (1<<1) /**< This call will not be freed on error */
     42#define IPC_CALL_DISPATCHED   (1<<2) /**< Call is in dispatch queue */
     43#define IPC_CALL_DISCARD_ANSWER (1<<3) /**< Answer will not be passed to
     44                                        * userspace, will be discarded */
    4345
    4446/* Flags for ipc_wait_for_call */
    4547#define IPC_WAIT_NONBLOCKING   1
    4648
    47 /* Flags of callid */
    48 #define IPC_CALLID_ANSWERED  1
     49/* Flags of callid (the addresses are aligned at least to 4,
     50 * that is why we can use bottom 2 bits of the call address
     51 */
     52#define IPC_CALLID_ANSWERED       1 /**< Type of this msg is 'answer' */
     53#define IPC_CALLID_NOTIFICATION   2 /**< Type of this msg is 'notification' */
    4954
    5055/* Return values from IPC_ASYNC */
     
    5459
    5560/* Macros for manipulating calling data */
    56 #define IPC_SET_RETVAL(data, retval)   ((data)[0] = (retval))
    57 #define IPC_SET_METHOD(data, val)   ((data)[0] = (val))
    58 #define IPC_SET_ARG1(data, val)   ((data)[1] = (val))
    59 #define IPC_SET_ARG2(data, val)   ((data)[2] = (val))
    60 #define IPC_SET_ARG3(data, val)   ((data)[3] = (val))
    61 
    62 #define IPC_GET_METHOD(data)           ((data)[0])
    63 #define IPC_GET_RETVAL(data)           ((data)[0])
    64 
    65 #define IPC_GET_ARG1(data)              ((data)[1])
    66 #define IPC_GET_ARG2(data)              ((data)[2])
    67 #define IPC_GET_ARG3(data)              ((data)[3])
     61#define IPC_SET_RETVAL(data, retval)   ((data).args[0] = (retval))
     62#define IPC_SET_METHOD(data, val)   ((data).args[0] = (val))
     63#define IPC_SET_ARG1(data, val)   ((data).args[1] = (val))
     64#define IPC_SET_ARG2(data, val)   ((data).args[2] = (val))
     65#define IPC_SET_ARG3(data, val)   ((data).args[3] = (val))
     66
     67#define IPC_GET_METHOD(data)           ((data).args[0])
     68#define IPC_GET_RETVAL(data)           ((data).args[0])
     69
     70#define IPC_GET_ARG1(data)              ((data).args[1])
     71#define IPC_GET_ARG2(data)              ((data).args[2])
     72#define IPC_GET_ARG3(data)              ((data).args[3])
    6873
    6974/* Well known phone descriptors */
     
    9095 *                     - the caller obtains taskid of the called thread
    9196 */
    92 #define IPC_M_CONNECTTOME     1
     97#define IPC_M_CONNECT_TO_ME     1
    9398/** Protocol for CONNECT - ME - TO
    9499 *
     
    109114 *
    110115 */
    111 #define IPC_M_CONNECTMETO     2
    112 /* Control messages that the server sends to the processes
    113  * about their connections.
    114  */
     116#define IPC_M_CONNECT_ME_TO     2
     117/** This message is sent to answerbox when the phone
     118 * is hung up
     119 */
     120#define IPC_M_PHONE_HUNGUP      3
    115121
    116122
     
    129135#define IPC_MAX_PHONES  16
    130136
    131 typedef struct answerbox answerbox_t;
    132 typedef __native ipc_data_t[IPC_CALL_LEN];
    133 
     137typedef struct answerbox_s answerbox_t;
     138typedef struct phone_s phone_t;
    134139typedef struct {
    135         link_t list;
    136         answerbox_t *callerbox;
    137         int flags;
    138         task_t *sender;
    139         ipc_data_t data;
    140 } call_t;
    141 
    142 struct answerbox {
     140        __native args[IPC_CALL_LEN];
     141        phone_t *phone;
     142}ipc_data_t;
     143
     144struct answerbox_s {
    143145        SPINLOCK_DECLARE(lock);
    144146
     
    154156};
    155157
    156 typedef struct {
     158struct phone_s {
    157159        SPINLOCK_DECLARE(lock);
    158160        link_t list;
    159161        answerbox_t *callee;
    160162        int busy;
    161 } phone_t;
     163        atomic_t active_calls;
     164};
     165
     166typedef struct {
     167        link_t list;
     168
     169        int flags;
     170
     171        /* Identification of the caller */
     172        task_t *sender;
     173        /* The caller box is different from sender->answerbox
     174         * for synchronous calls
     175         */
     176        answerbox_t *callerbox;
     177
     178        ipc_data_t data;
     179}call_t;
    162180
    163181extern void ipc_init(void);
     
    166184extern void ipc_call(phone_t *phone, call_t *request);
    167185extern void ipc_call_sync(phone_t *phone, call_t *request);
    168 extern void ipc_phone_destroy(phone_t *phone);
    169186extern void ipc_phone_init(phone_t *phone);
    170187extern void ipc_phone_connect(phone_t *phone, answerbox_t *box);
     
    178195extern answerbox_t *ipc_phone_0;
    179196extern void ipc_cleanup(task_t *task);
     197extern int ipc_phone_hangup(phone_t *phone);
    180198
    181199#endif
Note: See TracChangeset for help on using the changeset viewer.