IPC


Files

file  ipc.h
file  ipcrsc.h
file  irq.h
file  sysipc.h
file  ipc.c
file  ipcrsc.c
file  irq.c
file  sysipc.c

Data Structures

struct  irq_cmd_t
struct  irq_code_t
struct  ipc_irq_t

Defines

#define IPC_CALL_LEN   4
#define IPC_MAX_ASYNC_CALLS   4000
#define IPC_CALL_ANSWERED   (1<<0)
#define IPC_CALL_STATIC_ALLOC   (1<<1)
#define IPC_CALL_DISCARD_ANSWER   (1<<2)
#define IPC_CALL_FORWARDED   (1<<3)
#define IPC_CALL_CONN_ME_TO   (1<<4)
#define IPC_CALL_NOTIF   (1<<5)
#define IPC_CALLID_ANSWERED   1
#define IPC_CALLID_NOTIFICATION   2
#define IPC_CALLRET_FATAL   -1
#define IPC_CALLRET_TEMPORARY   -2
#define IPC_SET_RETVAL(data, retval)   ((data).args[0] = (retval))
#define IPC_SET_METHOD(data, val)   ((data).args[0] = (val))
#define IPC_SET_ARG1(data, val)   ((data).args[1] = (val))
#define IPC_SET_ARG2(data, val)   ((data).args[2] = (val))
#define IPC_SET_ARG3(data, val)   ((data).args[3] = (val))
#define IPC_GET_METHOD(data)   ((data).args[0])
#define IPC_GET_RETVAL(data)   ((data).args[0])
#define IPC_GET_ARG1(data)   ((data).args[1])
#define IPC_GET_ARG2(data)   ((data).args[2])
#define IPC_GET_ARG3(data)   ((data).args[3])
#define PHONE_NS   0
#define IPC_M_CONNECT_TO_ME   1
#define IPC_M_CONNECT_ME_TO   2
#define IPC_M_PHONE_HUNGUP   3
#define IPC_M_AS_AREA_SEND   5
#define IPC_M_AS_AREA_RECV   6
#define IPC_M_LAST_SYSTEM   511
#define IPC_M_PING   512
#define FIRST_USER_METHOD   1024
#define IRQ_MAX_PROG_SIZE   10
#define IPC_IRQ_RESERVED_VIRTUAL   10
#define IPC_IRQ_KLOG   (-1)
#define IPC_IRQ_KBDRESTART   (-2)
#define GET_CHECK_PHONE(phone, phoneid, err)
#define STRUCT_TO_USPACE(dst, src)   copy_to_uspace(dst,src,sizeof(*(src)))

Enumerations

enum  irq_cmd_type {
  CMD_MEM_READ_1 = 0, CMD_MEM_READ_2, CMD_MEM_READ_4, CMD_MEM_READ_8,
  CMD_MEM_WRITE_1, CMD_MEM_WRITE_2, CMD_MEM_WRITE_4, CMD_MEM_WRITE_8,
  CMD_PORT_READ_1, CMD_PORT_WRITE_1, CMD_IA64_GETCHAR, CMD_PPC32_GETCHAR,
  CMD_LAST
}

Functions

call_t * get_call (__native callid)
int phone_alloc (void)
void phone_connect (int phoneid, answerbox_t *box)
void phone_dealloc (int phoneid)
__native sys_ipc_call_sync_fast (__native phoneid, __native method, __native arg1, ipc_data_t *data)
__native sys_ipc_call_sync (__native phoneid, ipc_data_t *question, ipc_data_t *reply)
__native sys_ipc_call_async_fast (__native phoneid, __native method, __native arg1, __native arg2)
__native sys_ipc_call_async (__native phoneid, ipc_data_t *data)
__native sys_ipc_answer_fast (__native callid, __native retval, __native arg1, __native arg2)
__native sys_ipc_answer (__native callid, ipc_data_t *data)
__native sys_ipc_wait_for_call (ipc_data_t *calldata, __u32 usec, int nonblocking)
__native sys_ipc_forward_fast (__native callid, __native phoneid, __native method, __native arg1)
__native sys_ipc_hangup (int phoneid)
__native sys_ipc_register_irq (int irq, irq_code_t *ucode)
__native sys_ipc_unregister_irq (int irq)
static void _ipc_call_init (call_t *call)
call_t * ipc_call_alloc (int flags)
void ipc_call_static_init (call_t *call)
void ipc_call_free (call_t *call)
void ipc_answerbox_init (answerbox_t *box)
void ipc_phone_connect (phone_t *phone, answerbox_t *box)
void ipc_phone_init (phone_t *phone)
void ipc_call_sync (phone_t *phone, call_t *request)
static void _ipc_answer_free_call (call_t *call)
void ipc_answer (answerbox_t *box, call_t *call)
void ipc_backsend_err (phone_t *phone, call_t *call, __native err)
static void _ipc_call (phone_t *phone, answerbox_t *box, call_t *call)
int ipc_call (phone_t *phone, call_t *call)
int ipc_phone_hangup (phone_t *phone)
int ipc_forward (call_t *call, phone_t *newphone, answerbox_t *oldbox)
call_t * ipc_wait_for_call (answerbox_t *box, __u32 usec, int flags)
static void ipc_cleanup_call_list (link_t *lst)
void ipc_cleanup (void)
void ipc_init (void)
void ipc_print_task (task_id_t taskid)
static void phone_deallocp (phone_t *phone)
static void code_execute (call_t *call, irq_code_t *code)
static void code_free (irq_code_t *code)
static irq_code_tcode_from_uspace (irq_code_t *ucode)
void ipc_irq_unregister (answerbox_t *box, int irq)
int ipc_irq_register (answerbox_t *box, int irq, irq_code_t *ucode)
static void send_call (int mq, call_t *call)
void ipc_irq_send_msg (int irq, __native a1, __native a2, __native a3)
void ipc_irq_send_notif (int irq)
void ipc_irq_make_table (int irqcount)
void ipc_irq_cleanup (answerbox_t *box)
static int is_system_method (__native method)
static int is_forwardable (__native method)
static int answer_need_old (call_t *call)
static int answer_preprocess (call_t *answer, ipc_data_t *olddata)
static int request_preprocess (call_t *call)
static void process_answer (call_t *call)
static int process_request (answerbox_t *box, call_t *call)
static int check_call_limit (void)

Variables

answerbox_t * ipc_phone_0 = NULL
static slab_cache_tipc_call_slab
static ipc_irq_tirq_conns = NULL
static int irq_conns_size

Define Documentation

#define FIRST_USER_METHOD   1024
 

Definition at line 154 of file ipc.h.

#define GET_CHECK_PHONE phone,
phoneid,
err   ) 
 

Value:

{ \
      if (phoneid > IPC_MAX_PHONES) { err; } \
      phone = &TASK->phones[phoneid]; \
}

Definition at line 51 of file sysipc.c.

Referenced by sys_ipc_call_async(), sys_ipc_call_async_fast(), sys_ipc_call_sync(), sys_ipc_call_sync_fast(), sys_ipc_forward_fast(), and sys_ipc_hangup().

#define IPC_CALL_ANSWERED   (1<<0)
 

This is answer to a call

Definition at line 50 of file ipc.h.

Referenced by _ipc_answer_free_call(), and sys_ipc_wait_for_call().

#define IPC_CALL_CONN_ME_TO   (1<<4)
 

Definition at line 55 of file ipc.h.

Referenced by process_answer(), and request_preprocess().

#define IPC_CALL_DISCARD_ANSWER   (1<<2)
 

Answer will not be passed to userspace, will be discarded

Definition at line 52 of file ipc.h.

Referenced by ipc_phone_hangup(), and sys_ipc_wait_for_call().

#define IPC_CALL_FORWARDED   (1<<3)
 

Definition at line 54 of file ipc.h.

Referenced by _ipc_call(), ipc_call(), process_answer(), and sys_ipc_forward_fast().

#define IPC_CALL_LEN   4
 

Definition at line 40 of file ipc.h.

#define IPC_CALL_NOTIF   (1<<5)
 

Definition at line 56 of file ipc.h.

Referenced by ipc_irq_send_msg(), ipc_irq_send_notif(), and sys_ipc_wait_for_call().

#define IPC_CALL_STATIC_ALLOC   (1<<1)
 

This call will not be freed on error

Definition at line 51 of file ipc.h.

Referenced by ipc_call_static_init(), and sys_ipc_wait_for_call().

#define IPC_CALLID_ANSWERED   1
 

Type of this msg is 'answer'

Definition at line 61 of file ipc.h.

Referenced by sys_ipc_wait_for_call().

#define IPC_CALLID_NOTIFICATION   2
 

Type of this msg is 'notification'

Definition at line 62 of file ipc.h.

Referenced by sys_ipc_answer(), sys_ipc_answer_fast(), and sys_ipc_wait_for_call().

#define IPC_CALLRET_FATAL   -1
 

Definition at line 65 of file ipc.h.

Referenced by sys_ipc_call_async(), and sys_ipc_call_async_fast().

#define IPC_CALLRET_TEMPORARY   -2
 

Definition at line 66 of file ipc.h.

Referenced by sys_ipc_call_async(), and sys_ipc_call_async_fast().

#define IPC_GET_ARG1 data   )     ((data).args[1])
 

Definition at line 79 of file ipc.h.

Referenced by answer_preprocess(), and request_preprocess().

#define IPC_GET_ARG2 data   )     ((data).args[2])
 

Definition at line 80 of file ipc.h.

Referenced by answer_preprocess().

#define IPC_GET_ARG3 data   )     ((data).args[3])
 

Definition at line 81 of file ipc.h.

Referenced by answer_preprocess().

#define IPC_GET_METHOD data   )     ((data).args[0])
 

Definition at line 76 of file ipc.h.

Referenced by answer_need_old(), answer_preprocess(), process_request(), and request_preprocess().

#define IPC_GET_RETVAL data   )     ((data).args[0])
 

Definition at line 77 of file ipc.h.

Referenced by answer_preprocess(), and process_answer().

#define IPC_IRQ_KBDRESTART   (-2)
 

Definition at line 45 of file irq.h.

Referenced by cmd_continue().

#define IPC_IRQ_KLOG   (-1)
 

Definition at line 44 of file irq.h.

Referenced by klog_vprintf().

#define IPC_IRQ_RESERVED_VIRTUAL   10
 

Reserved 'virtual' messages for kernel notifications

Definition at line 42 of file irq.h.

Referenced by ipc_irq_make_table(), ipc_irq_register(), ipc_irq_send_msg(), ipc_irq_send_notif(), ipc_irq_unregister(), sys_ipc_register_irq(), and sys_ipc_unregister_irq().

#define IPC_M_AS_AREA_RECV   6
 

Get as_area over IPC

  • ARG1 - Where the area will be mapped
  • ARG2 - Expected size of area
  • ARG3 - User defined argument on answer - the server sets ARG1 as src as address of the as_area to be shared, ARG2 is set to rights that will be used for sharing, which is returned as part of answer back to the receiver

Definition at line 147 of file ipc.h.

Referenced by answer_need_old(), answer_preprocess(), and is_forwardable().

#define IPC_M_AS_AREA_SEND   5
 

Send as_area over IPC

  • ARG1 - src base address
  • ARG2 - size of src as(filled automatically by kernel)
  • ARG3 - flags of the area being sent
  • on answer ARG1 - dst base adress

Definition at line 137 of file ipc.h.

Referenced by answer_need_old(), answer_preprocess(), is_forwardable(), and request_preprocess().

#define IPC_M_CONNECT_ME_TO   2
 

Protocol for CONNECT - ME - TO

Calling process asks the callee to create for him a new connection. E.g. the caller wants a name server to connect him to print server.

The protocol for negotiating is:

  • sys_connect_me_to - send a synchronous message to name server indicating that it wants to be connected to some service
    • arg1/2 are user specified, arg3 contains address of the phone that should be connected (TODO: it leaks to userspace) recipient - if ipc_answer == 0, then accept connection
    • otherwise connection refused
    • recepient may forward message. Forwarding system message

Definition at line 125 of file ipc.h.

Referenced by answer_need_old(), answer_preprocess(), and request_preprocess().

#define IPC_M_CONNECT_TO_ME   1
 

Protocol for CONNECT - TO - ME

Calling process asks the callee to create a callback connection, so that it can start initiating new messages.

The protocol for negotiating is:

  • sys_connect_to_me - sends a message IPC_M_CONNECTTOME
  • sys_wait_for_call - upon receipt tries to allocate new phone
    • if it fails, responds with ELIMIT

passes call to userspace. If userspace responds with error, phone is deallocated and error is sent back to caller. Otherwise the call is accepted and the response is sent back.

  • the allocated phoneid is passed to userspace (on the receiving sid) as ARG3 of the call.
  • the caller obtains taskid of the called thread

Definition at line 106 of file ipc.h.

Referenced by answer_need_old(), answer_preprocess(), and process_request().

#define IPC_M_LAST_SYSTEM   511
 

Definition at line 151 of file ipc.h.

Referenced by is_system_method().

#define IPC_M_PHONE_HUNGUP   3
 

This message is sent to answerbox when the phone is hung up

Definition at line 129 of file ipc.h.

Referenced by ipc_phone_hangup(), and is_forwardable().

#define IPC_M_PING   512
 

Definition at line 152 of file ipc.h.

#define IPC_MAX_ASYNC_CALLS   4000
 

Maximum active async calls per thread

Definition at line 46 of file ipc.h.

Referenced by check_call_limit().

#define IPC_SET_ARG1 data,
val   )     ((data).args[1] = (val))
 

Definition at line 72 of file ipc.h.

Referenced by ipc_irq_send_msg(), sys_ipc_answer_fast(), sys_ipc_call_async_fast(), and sys_ipc_call_sync_fast().

#define IPC_SET_ARG2 data,
val   )     ((data).args[2] = (val))
 

Definition at line 73 of file ipc.h.

Referenced by ipc_irq_send_msg(), request_preprocess(), sys_ipc_answer_fast(), and sys_ipc_call_async_fast().

#define IPC_SET_ARG3 data,
val   )     ((data).args[3] = (val))
 

Definition at line 74 of file ipc.h.

Referenced by answer_preprocess(), ipc_irq_send_msg(), process_answer(), process_request(), request_preprocess(), and sys_ipc_call_async_fast().

#define IPC_SET_METHOD data,
val   )     ((data).args[0] = (val))
 

Definition at line 71 of file ipc.h.

Referenced by ipc_irq_send_msg(), ipc_irq_send_notif(), ipc_phone_hangup(), sys_ipc_call_async_fast(), and sys_ipc_call_sync_fast().

#define IPC_SET_RETVAL data,
retval   )     ((data).args[0] = (retval))
 

Definition at line 70 of file ipc.h.

Referenced by answer_preprocess(), ipc_backsend_err(), ipc_call(), ipc_cleanup_call_list(), process_answer(), process_request(), sys_ipc_answer_fast(), sys_ipc_call_sync(), sys_ipc_call_sync_fast(), and sys_ipc_forward_fast().

#define IRQ_MAX_PROG_SIZE   10
 

Maximum length of IPC IRQ program

Definition at line 39 of file irq.h.

Referenced by code_from_uspace().

#define PHONE_NS   0
 

Definition at line 84 of file ipc.h.

#define STRUCT_TO_USPACE dst,
src   )     copy_to_uspace(dst,src,sizeof(*(src)))
 

Definition at line 56 of file sysipc.c.

Referenced by sys_ipc_call_sync(), sys_ipc_call_sync_fast(), and sys_ipc_wait_for_call().


Enumeration Type Documentation

enum irq_cmd_type
 

Enumerator:
CMD_MEM_READ_1 
CMD_MEM_READ_2 
CMD_MEM_READ_4 
CMD_MEM_READ_8 
CMD_MEM_WRITE_1 
CMD_MEM_WRITE_2 
CMD_MEM_WRITE_4 
CMD_MEM_WRITE_8 
CMD_PORT_READ_1 
CMD_PORT_WRITE_1 
CMD_IA64_GETCHAR 
CMD_PPC32_GETCHAR 
CMD_LAST 

Definition at line 47 of file irq.h.


Function Documentation

static void _ipc_answer_free_call call_t *  call  )  [static]
 

Answer message that was not dispatched and is not entered in any queue

Definition at line 156 of file ipc.c.

References IPC_CALL_ANSWERED, list_append(), spinlock_lock, spinlock_unlock(), and waitq_wakeup().

Referenced by ipc_answer(), ipc_backsend_err(), ipc_call(), and ipc_cleanup_call_list().

Here is the call graph for this function:

static void _ipc_call phone_t *  phone,
answerbox_t *  box,
call_t *  call
[static]
 

Definition at line 197 of file ipc.c.

References atomic_inc(), IPC_CALL_FORWARDED, list_append(), spinlock_lock, spinlock_unlock(), and waitq_wakeup().

Referenced by ipc_call(), and ipc_phone_hangup().

Here is the call graph for this function:

static void _ipc_call_init call_t *  call  )  [static]
 

Definition at line 62 of file ipc.c.

References memsetb(), and TASK.

Referenced by ipc_call_alloc(), and ipc_call_static_init().

Here is the call graph for this function:

static int answer_need_old call_t *  call  )  [static]
 

Return true if the caller (ipc_answer) should save the old call contents for answer_preprocess

Definition at line 87 of file sysipc.c.

References IPC_GET_METHOD, IPC_M_AS_AREA_RECV, IPC_M_AS_AREA_SEND, IPC_M_CONNECT_ME_TO, and IPC_M_CONNECT_TO_ME.

Referenced by sys_ipc_answer(), and sys_ipc_answer_fast().

static int answer_preprocess call_t *  answer,
ipc_data_t *  olddata
[static]
 

Interpret process answer as control information

This function is called directly after sys_ipc_answer

Definition at line 104 of file sysipc.c.

References AS, as_area_share(), EHANGUP, interrupts_disable(), interrupts_restore(), IPC_GET_ARG1, IPC_GET_ARG2, IPC_GET_ARG3, IPC_GET_METHOD, IPC_GET_RETVAL, IPC_M_AS_AREA_RECV, IPC_M_AS_AREA_SEND, IPC_M_CONNECT_ME_TO, IPC_M_CONNECT_TO_ME, ipc_phone_connect(), IPC_SET_ARG3, IPC_SET_RETVAL, list_remove(), phone_connect(), phone_dealloc(), spinlock_lock, spinlock_unlock(), and TASK.

Referenced by sys_ipc_answer(), and sys_ipc_answer_fast().

Here is the call graph for this function:

static int check_call_limit void   )  [static]
 

Check that the task did not exceed allowed limit

Returns:
0 - Limit OK, -1 - limit exceeded

Definition at line 312 of file sysipc.c.

References atomic_dec(), atomic_preinc, IPC_MAX_ASYNC_CALLS, and TASK.

Referenced by sys_ipc_call_async(), and sys_ipc_call_async_fast().

Here is the call graph for this function:

static void code_execute call_t *  call,
irq_code_t code
[static]
 

Definition at line 73 of file irq.c.

References _getc(), irq_cmd_t::addr, irq_cmd_t::cmd, CMD_IA64_GETCHAR, CMD_MEM_READ_1, CMD_MEM_READ_2, CMD_MEM_READ_4, CMD_MEM_READ_8, CMD_MEM_WRITE_1, CMD_MEM_WRITE_2, CMD_MEM_WRITE_4, CMD_MEM_WRITE_8, CMD_PORT_READ_1, CMD_PORT_WRITE_1, CMD_PPC32_GETCHAR, irq_code_t::cmdcount, irq_code_t::cmds, inb(), outb(), and irq_cmd_t::value.

Referenced by ipc_irq_send_notif().

Here is the call graph for this function:

static void code_free irq_code_t code  )  [static]
 

Definition at line 134 of file irq.c.

References irq_code_t::cmds, and free().

Referenced by ipc_irq_register(), and ipc_irq_unregister().

Here is the call graph for this function:

static irq_code_t* code_from_uspace irq_code_t ucode  )  [static]
 

Definition at line 142 of file irq.c.

References copy_from_uspace(), free(), IRQ_MAX_PROG_SIZE, malloc(), and NULL.

Referenced by ipc_irq_register().

Here is the call graph for this function:

call_t * get_call __native  callid  ) 
 

Find call_t * in call table according to callid

TODO: Some speedup (hash table?)

Returns:
NULL on not found, otherwise pointer to call structure

Definition at line 141 of file ipcrsc.c.

References list_get_instance, link::next, NULL, spinlock_lock, spinlock_unlock(), and TASK.

Referenced by sys_ipc_answer(), sys_ipc_answer_fast(), and sys_ipc_forward_fast().

Here is the call graph for this function:

void ipc_answer answerbox_t *  box,
call_t *  call
 

Answer message, that is in callee queue

Parameters:
box Answerbox that is answering the message
call Modified request that is being sent back

Definition at line 173 of file ipc.c.

References _ipc_answer_free_call(), list_remove(), spinlock_lock, and spinlock_unlock().

Referenced by process_request(), sys_ipc_answer(), sys_ipc_answer_fast(), and sys_ipc_forward_fast().

Here is the call graph for this function:

void ipc_answerbox_init answerbox_t *  box  ) 
 

Initialize answerbox structure

Definition at line 101 of file ipc.c.

References list_initialize(), spinlock_initialize(), TASK, and waitq_initialize().

Referenced by ipc_call_sync(), and task_create().

Here is the call graph for this function:

void ipc_backsend_err phone_t *  phone,
call_t *  call,
__native  err
 

Simulate sending back a message

Most errors are better handled by forming a normal backward message and sending it as a normal answer.

Definition at line 188 of file ipc.c.

References _ipc_answer_free_call(), atomic_inc(), and IPC_SET_RETVAL.

Referenced by ipc_call(), sys_ipc_call_async(), and sys_ipc_call_async_fast().

Here is the call graph for this function:

int ipc_call phone_t *  phone,
call_t *  call
 

Send a asynchronous request using phone to answerbox

Parameters:
phone Phone connected to answerbox.
call Structure representing the call.

Definition at line 215 of file ipc.c.

References _ipc_answer_free_call(), _ipc_call(), EFORWARD, EHANGUP, ENOENT, ipc_backsend_err(), IPC_CALL_FORWARDED, IPC_SET_RETVAL, spinlock_lock, and spinlock_unlock().

Referenced by ipc_call_sync(), ipc_forward(), sys_ipc_call_async(), and sys_ipc_call_async_fast().

Here is the call graph for this function:

call_t* ipc_call_alloc int  flags  ) 
 

Allocate & initialize call structure

The call is initialized, so that the reply will be directed to TASK->answerbox

Parameters:
flags Parameters for slab_alloc (ATOMIC, etc.)

Definition at line 76 of file ipc.c.

References _ipc_call_init(), ipc_call_slab, and slab_alloc().

Referenced by ipc_irq_send_msg(), ipc_irq_send_notif(), ipc_phone_hangup(), sys_ipc_call_async(), and sys_ipc_call_async_fast().

Here is the call graph for this function:

void ipc_call_free call_t *  call  ) 
 

Deallocate call stracuture

Definition at line 94 of file ipc.c.

References ipc_call_slab, and slab_free().

Referenced by sys_ipc_call_async(), and sys_ipc_wait_for_call().

Here is the call graph for this function:

void ipc_call_static_init call_t *  call  ) 
 

Initialize allocated call

Definition at line 87 of file ipc.c.

References _ipc_call_init(), and IPC_CALL_STATIC_ALLOC.

Referenced by sys_ipc_call_sync(), and sys_ipc_call_sync_fast().

Here is the call graph for this function:

void ipc_call_sync phone_t *  phone,
call_t *  request
 

Helper function to facilitate synchronous calls

Definition at line 140 of file ipc.c.

References ipc_answerbox_init(), ipc_call(), ipc_wait_for_call(), SYNCH_FLAGS_NONE, and SYNCH_NO_TIMEOUT.

Referenced by sys_ipc_call_sync(), and sys_ipc_call_sync_fast().

Here is the call graph for this function:

void ipc_cleanup void   ) 
 

Cleans up all IPC communication of the current task

Note: ipc_hangup sets returning answerbox to TASK->answerbox, you have to change it as well if you want to cleanup other current then current.

Definition at line 371 of file ipc.c.

References ipc_irq_cleanup(), ipc_phone_hangup(), list_empty(), list_get_instance, spinlock_lock, spinlock_trylock(), spinlock_unlock(), and TASK.

Referenced by ktaskclnp().

Here is the call graph for this function:

static void ipc_cleanup_call_list link_t lst  )  [static]
 

Answer all calls from list with EHANGUP msg

Definition at line 353 of file ipc.c.

References _ipc_answer_free_call(), EHANGUP, IPC_SET_RETVAL, list_empty(), list_get_instance, list_remove(), and link::next.

Here is the call graph for this function:

int ipc_forward call_t *  call,
phone_t *  newphone,
answerbox_t *  oldbox
 

Forwards call from one answerbox to a new one

Parameters:
call Call to be redirected.
newphone Phone to target answerbox.
oldbox Old answerbox
Returns:
0 on forward ok, error code, if there was error
  • the return value serves only as an information for the forwarder, the original caller is notified automatically with EFORWARD

Definition at line 291 of file ipc.c.

References ipc_call(), list_remove(), spinlock_lock, and spinlock_unlock().

Here is the call graph for this function:

void ipc_init void   ) 
 

Initilize ipc subsystem

Definition at line 444 of file ipc.c.

References ipc_call_slab, ipc_irq_make_table(), IRQ_COUNT, NULL, and slab_cache_create().

Referenced by main_bsp_separated_stack().

Here is the call graph for this function:

void ipc_irq_cleanup answerbox_t *  box  ) 
 

Disconnect all irq's notifications

TODO: It may be better to do some linked list, so that we wouldn't need to go through whole array every cleanup

Definition at line 322 of file irq.c.

References ipc_irq_t::box, interrupts_disable(), interrupts_restore(), irq_conns, irq_conns_size, NULL, spinlock_lock, and spinlock_unlock().

Referenced by ipc_cleanup().

Here is the call graph for this function:

void ipc_irq_make_table int  irqcount  ) 
 

Initialize table of interrupt handlers

Parameters:
irqcount Count of required hardware IRQs to be supported

Definition at line 302 of file irq.c.

References IPC_IRQ_RESERVED_VIRTUAL, irq_conns, irq_conns_size, malloc(), NULL, and spinlock_initialize().

Referenced by ipc_init().

Here is the call graph for this function:

int ipc_irq_register answerbox_t *  box,
int  irq,
irq_code_t ucode
 

Register an answerbox as a receiving end of interrupts notifications

Definition at line 190 of file irq.c.

References ASSERT, atomic_set(), ipc_irq_t::box, ipc_irq_t::code, code_free(), code_from_uspace(), EBADMEM, EEXISTS, interrupts_disable(), interrupts_restore(), IPC_IRQ_RESERVED_VIRTUAL, irq_conns, NULL, spinlock_lock, and spinlock_unlock().

Referenced by sys_ipc_register_irq().

Here is the call graph for this function:

void ipc_irq_send_msg int  irq,
__native  a1,
__native  a2,
__native  a3
 

Send notification message

Definition at line 238 of file irq.c.

References atomic_preinc, FRAME_ATOMIC, ipc_call_alloc(), IPC_CALL_NOTIF, IPC_IRQ_RESERVED_VIRTUAL, IPC_SET_ARG1, IPC_SET_ARG2, IPC_SET_ARG3, IPC_SET_METHOD, irq_conns, send_call(), spinlock_lock, and spinlock_unlock().

Referenced by cmd_continue(), and klog_vprintf().

Here is the call graph for this function:

void ipc_irq_send_notif int  irq  ) 
 

Notify task that an irq had occurred.

We expect interrupts to be disabled

Definition at line 268 of file irq.c.

References ASSERT, atomic_preinc, code_execute(), FRAME_ATOMIC, ipc_call_alloc(), IPC_CALL_NOTIF, IPC_IRQ_RESERVED_VIRTUAL, IPC_SET_METHOD, irq_conns, send_call(), spinlock_lock, and spinlock_unlock().

Referenced by ipc_int().

Here is the call graph for this function:

void ipc_irq_unregister answerbox_t *  box,
int  irq
 

Unregister task from irq

Definition at line 172 of file irq.c.

References ipc_irq_t::box, ipc_irq_t::code, code_free(), interrupts_disable(), interrupts_restore(), IPC_IRQ_RESERVED_VIRTUAL, irq_conns, NULL, spinlock_lock, and spinlock_unlock().

Referenced by sys_ipc_unregister_irq().

Here is the call graph for this function:

void ipc_phone_connect phone_t *  phone,
answerbox_t *  box
 

Connect phone to answerbox

Definition at line 115 of file ipc.c.

References list_append(), spinlock_lock, and spinlock_unlock().

Referenced by answer_preprocess(), phone_connect(), and task_create().

Here is the call graph for this function:

int ipc_phone_hangup phone_t *  phone  ) 
 

Disconnect phone from answerbox

This call leaves the phone in HUNGUP state. The change to 'free' is done lazily later.

Parameters:
phone Phone to be hung up
Returns:
0 - phone disconnected, -1 - the phone was already disconnected

Definition at line 249 of file ipc.c.

References _ipc_call(), ipc_call_alloc(), IPC_CALL_DISCARD_ANSWER, IPC_M_PHONE_HUNGUP, IPC_SET_METHOD, list_remove(), spinlock_lock, and spinlock_unlock().

Referenced by ipc_cleanup(), and sys_ipc_hangup().

Here is the call graph for this function:

void ipc_phone_init phone_t *  phone  ) 
 

Initialize phone structure and connect phone to answerbox

Definition at line 131 of file ipc.c.

References atomic_set(), NULL, and spinlock_initialize().

Referenced by task_create().

Here is the call graph for this function:

void ipc_print_task task_id_t  taskid  ) 
 

Kconsole - list answerbox contents

Definition at line 455 of file ipc.c.

References task::phones, printf(), spinlock_lock, spinlock_unlock(), task_find_by_id(), and tasks_lock.

Referenced by cmd_ipc_task().

Here is the call graph for this function:

call_t* ipc_wait_for_call answerbox_t *  box,
__u32  usec,
int  flags
 

Wait for phone call

Parameters:
box Answerbox expecting the call.
usec Timeout in microseconds. See documentation for waitq_sleep_timeout() for decription of its special meaning.
flags Select mode of sleep operation. See documentation for waitq_sleep_timeout()i for description of its special meaning.
Returns:
Recived message address
  • to distinguish between call and answer, look at call->flags

Definition at line 311 of file ipc.c.

References atomic_dec(), interrupts_disable(), interrupts_restore(), list_append(), list_empty(), list_get_instance, list_remove(), NULL, spinlock_lock, spinlock_unlock(), SYNCH_FAILED, and waitq_sleep_timeout().

Referenced by ipc_call_sync(), and sys_ipc_wait_for_call().

Here is the call graph for this function:

static int is_forwardable __native  method  )  [static]
 

Return true if the message with this method is forwardable

  • some system messages may be forwarded, for some of them it is useless

Definition at line 71 of file sysipc.c.

References IPC_M_AS_AREA_RECV, IPC_M_AS_AREA_SEND, and IPC_M_PHONE_HUNGUP.

static int is_system_method __native  method  )  [static]
 

Return true if the method is a system method

Definition at line 59 of file sysipc.c.

References IPC_M_LAST_SYSTEM.

int phone_alloc void   ) 
 

Allocate new phone slot in current TASK structure

Definition at line 160 of file ipcrsc.c.

References atomic_get(), spinlock_lock, and TASK.

Referenced by process_request(), and request_preprocess().

Here is the call graph for this function:

void phone_connect int  phoneid,
answerbox_t *  box
 

Connect phone to a given answerbox

Parameters:
phoneid The slot that will be connected
The procedure _enforces_ that the user first marks the phone busy (e.g. via phone_alloc) and then connects the phone, otherwise race condition may appear.

Definition at line 208 of file ipcrsc.c.

References ASSERT, ipc_phone_connect(), and TASK.

Referenced by answer_preprocess().

Here is the call graph for this function:

void phone_dealloc int  phoneid  ) 
 

Free slot from a disconnected phone

All already sent messages will be correctly processed

Definition at line 195 of file ipcrsc.c.

References phone_deallocp(), and TASK.

Referenced by answer_preprocess(), and process_answer().

Here is the call graph for this function:

static void phone_deallocp phone_t *  phone  )  [static]
 

Definition at line 183 of file ipcrsc.c.

References ASSERT.

Referenced by phone_dealloc().

static void process_answer call_t *  call  )  [static]
 

Do basic kernel processing of received call answer

Definition at line 217 of file sysipc.c.

References EFORWARD, EHANGUP, IPC_CALL_CONN_ME_TO, IPC_CALL_FORWARDED, IPC_GET_RETVAL, IPC_SET_ARG3, IPC_SET_RETVAL, and phone_dealloc().

Referenced by sys_ipc_call_sync(), sys_ipc_call_sync_fast(), and sys_ipc_wait_for_call().

Here is the call graph for this function:

static int process_request answerbox_t *  box,
call_t *  call
[static]
 

Do basic kernel processing of received call request

Returns:
0 - the call should be passed to userspace, 1 - ignore call

Definition at line 235 of file sysipc.c.

References ELIMIT, ipc_answer(), IPC_GET_METHOD, IPC_M_CONNECT_TO_ME, IPC_SET_ARG3, IPC_SET_RETVAL, and phone_alloc().

Referenced by sys_ipc_wait_for_call().

Here is the call graph for this function:

static int request_preprocess call_t *  call  )  [static]
 

Called before the request is sent

Returns:
0 - no error, -1 - report error to user

Definition at line 183 of file sysipc.c.

References as_get_size(), ELIMIT, EPERM, IPC_CALL_CONN_ME_TO, IPC_GET_ARG1, IPC_GET_METHOD, IPC_M_AS_AREA_SEND, IPC_M_CONNECT_ME_TO, IPC_SET_ARG2, IPC_SET_ARG3, phone_alloc(), and TASK.

Referenced by sys_ipc_call_async(), sys_ipc_call_async_fast(), sys_ipc_call_sync(), and sys_ipc_call_sync_fast().

Here is the call graph for this function:

static void send_call int  mq,
call_t *  call
[static]
 

Add call to proper answerbox queue

Assume irq_conns[mq].lock is locked

Definition at line 226 of file irq.c.

References ipc_irq_t::box, irq_conns, list_append(), spinlock_lock, spinlock_unlock(), and waitq_wakeup().

Referenced by ipc_irq_send_msg(), and ipc_irq_send_notif().

Here is the call graph for this function:

__native sys_ipc_answer __native  callid,
ipc_data_t *  data
 

Send IPC answer

Definition at line 462 of file sysipc.c.

References answer_need_old(), answer_preprocess(), copy_from_uspace(), ENOENT, get_call(), ipc_answer(), IPC_CALLID_NOTIFICATION, memcpy(), NULL, and TASK.

Here is the call graph for this function:

__native sys_ipc_answer_fast __native  callid,
__native  retval,
__native  arg1,
__native  arg2
 

Send IPC answer

Definition at line 431 of file sysipc.c.

References answer_need_old(), answer_preprocess(), ENOENT, get_call(), ipc_answer(), IPC_CALLID_NOTIFICATION, IPC_SET_ARG1, IPC_SET_ARG2, IPC_SET_RETVAL, memcpy(), NULL, and TASK.

Here is the call graph for this function:

__native sys_ipc_call_async __native  phoneid,
ipc_data_t *  data
 

Synchronous IPC call allowing to send whole message

Returns:
The same as sys_ipc_call_async

Definition at line 356 of file sysipc.c.

References check_call_limit(), copy_from_uspace(), GET_CHECK_PHONE, ipc_backsend_err(), ipc_call(), ipc_call_alloc(), ipc_call_free(), IPC_CALLRET_FATAL, IPC_CALLRET_TEMPORARY, and request_preprocess().

Here is the call graph for this function:

__native sys_ipc_call_async_fast __native  phoneid,
__native  method,
__native  arg1,
__native  arg2
 

Send an asynchronous call over ipc

Returns:
Call identification, returns -1 on fatal error, -2 on 'Too many async request, handle answers first

Definition at line 326 of file sysipc.c.

References check_call_limit(), GET_CHECK_PHONE, ipc_backsend_err(), ipc_call(), ipc_call_alloc(), IPC_CALLRET_FATAL, IPC_CALLRET_TEMPORARY, IPC_SET_ARG1, IPC_SET_ARG2, IPC_SET_ARG3, IPC_SET_METHOD, and request_preprocess().

Here is the call graph for this function:

__native sys_ipc_call_sync __native  phoneid,
ipc_data_t *  question,
ipc_data_t *  reply
 

Synchronous IPC call allowing to send whole message

Definition at line 280 of file sysipc.c.

References copy_from_uspace(), ENOENT, GET_CHECK_PHONE, ipc_call_static_init(), ipc_call_sync(), IPC_SET_RETVAL, process_answer(), request_preprocess(), and STRUCT_TO_USPACE.

Here is the call graph for this function:

__native sys_ipc_call_sync_fast __native  phoneid,
__native  method,
__native  arg1,
ipc_data_t *  data
 

Send a call over IPC, wait for reply, return to user

Returns:
Call identification, returns -1 on fatal error, -2 on 'Too many async request, handle answers first

Definition at line 256 of file sysipc.c.

References ENOENT, GET_CHECK_PHONE, ipc_call_static_init(), ipc_call_sync(), IPC_SET_ARG1, IPC_SET_METHOD, IPC_SET_RETVAL, process_answer(), request_preprocess(), and STRUCT_TO_USPACE.

Here is the call graph for this function:

__native sys_ipc_forward_fast __native  callid,
__native  phoneid,
__native  method,
__native  arg1
 

Forward received call to another destination

The arg1 and arg2 are changed in the forwarded message

Warning: If implementing non-fast version, make sure that arg3 is not rewritten for certain system IPC

Definition at line 389 of file sysipc.c.

References EFORWARD, ENOENT, get_call(), GET_CHECK_PHONE, ipc_answer(), IPC_CALL_FORWARDED, IPC_SET_RETVAL, and TASK.

Here is the call graph for this function:

__native sys_ipc_hangup int  phoneid  ) 
 

Hang up the phone

Definition at line 496 of file sysipc.c.

References ENOENT, GET_CHECK_PHONE, and ipc_phone_hangup().

Here is the call graph for this function:

__native sys_ipc_register_irq int  irq,
irq_code_t ucode
 

Connect irq handler to task

Definition at line 568 of file sysipc.c.

References cap_get(), CAP_IRQ_REG, ELIMIT, ipc_irq_register(), IPC_IRQ_RESERVED_VIRTUAL, IRQ_COUNT, irq_ipc_bind_arch(), and TASK.

Here is the call graph for this function:

__native sys_ipc_unregister_irq int  irq  ) 
 

Definition at line 582 of file sysipc.c.

References cap_get(), CAP_IRQ_REG, ELIMIT, IPC_IRQ_RESERVED_VIRTUAL, ipc_irq_unregister(), IRQ_COUNT, and TASK.

Here is the call graph for this function:

__native sys_ipc_wait_for_call ipc_data_t *  calldata,
__u32  usec,
int  flags
 

Wait for incoming ipc call or answer

Parameters:
calldata Pointer to buffer where the call/answer data is stored
usec Timeout. See waitq_sleep_timeout() for explanation.
flags Select mode of sleep operation. See waitq_sleep_timeout() for explanation.
Returns:
Callid, if callid & 1, then the call is answer

Definition at line 516 of file sysipc.c.

References ASSERT, atomic_dec(), IPC_CALL_ANSWERED, IPC_CALL_DISCARD_ANSWER, ipc_call_free(), IPC_CALL_NOTIF, IPC_CALL_STATIC_ALLOC, IPC_CALLID_ANSWERED, IPC_CALLID_NOTIFICATION, ipc_wait_for_call(), process_answer(), process_request(), STRUCT_TO_USPACE, SYNCH_FLAGS_INTERRUPTIBLE, and TASK.

Here is the call graph for this function:


Variable Documentation

slab_cache_t* ipc_call_slab [static]
 

Definition at line 59 of file ipc.c.

Referenced by ipc_call_alloc(), ipc_call_free(), and ipc_init().

answerbox_t* ipc_phone_0 = NULL
 

Definition at line 57 of file ipc.c.

Referenced by task_create().

ipc_irq_t* irq_conns = NULL [static]
 

Definition at line 68 of file irq.c.

Referenced by ipc_irq_cleanup(), ipc_irq_make_table(), ipc_irq_register(), ipc_irq_send_msg(), ipc_irq_send_notif(), ipc_irq_unregister(), and send_call().

int irq_conns_size [static]
 

Definition at line 69 of file irq.c.

Referenced by ipc_irq_cleanup(), and ipc_irq_make_table().


Generated on Sun Jun 18 16:36:15 2006 for HelenOS Kernel (amd64) by  doxygen 1.4.6