Changeset 46b881c in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2011-01-29T11:36:41Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b6931a, 8add9ca5
Parents:
e26a4633 (diff), ffa2c8ef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

IPC/async: strictly isolate the use of low-level IPC methods (ipc_*) and async framework methods (async_*) in user code, do not allow a mixture of both in a single source file

Benefits for future plans

  • The async framework could use different communication style under the hood, but keeping the same high-level API
  • The async framework can be integrated more tightly with sessions without potential problems of intermixing session-aware async methods with session-unaware low-level methods in user code
  • The async_serialize_start()/_end() can be deprecated more easily
Location:
uspace/lib/c/include
Files:
1 added
36 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/async.h

    re26a4633 r46b881c  
    3333 */
    3434
     35#if ((defined(LIBC_IPC_H_)) && (!defined(LIBC_ASYNC_C_)))
     36        #error Do not intermix low-level IPC interface and async framework
     37#endif
     38
    3539#ifndef LIBC_ASYNC_H_
    3640#define LIBC_ASYNC_H_
    3741
    38 #include <ipc/ipc.h>
     42#include <ipc/common.h>
    3943#include <async_sess.h>
    4044#include <fibril.h>
     
    4246#include <atomic.h>
    4347#include <bool.h>
     48#include <task.h>
    4449
    4550typedef ipc_callid_t aid_t;
     
    4954
    5055typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
    51 
    52 extern atomic_t async_futex;
    5356
    5457extern atomic_t threads_in_ipc_wait;
     
    110113extern void async_set_interrupt_received(async_client_conn_t);
    111114
    112 /* Wrappers for simple communication */
    113 #define async_msg_0(phone, method) \
    114         ipc_call_async_0((phone), (method), NULL, NULL, true)
    115 #define async_msg_1(phone, method, arg1) \
    116         ipc_call_async_1((phone), (method), (arg1), NULL, NULL, \
    117             true)
    118 #define async_msg_2(phone, method, arg1, arg2) \
    119         ipc_call_async_2((phone), (method), (arg1), (arg2), NULL, NULL, \
    120             true)
    121 #define async_msg_3(phone, method, arg1, arg2, arg3) \
    122         ipc_call_async_3((phone), (method), (arg1), (arg2), (arg3), NULL, NULL, \
    123             true)
    124 #define async_msg_4(phone, method, arg1, arg2, arg3, arg4) \
    125         ipc_call_async_4((phone), (method), (arg1), (arg2), (arg3), (arg4), NULL, \
    126             NULL, true)
    127 #define async_msg_5(phone, method, arg1, arg2, arg3, arg4, arg5) \
    128         ipc_call_async_5((phone), (method), (arg1), (arg2), (arg3), (arg4), \
    129             (arg5), NULL, NULL, true)
     115/*
     116 * Wrappers for simple communication.
     117 */
     118
     119extern void async_msg_0(int, sysarg_t);
     120extern void async_msg_1(int, sysarg_t, sysarg_t);
     121extern void async_msg_2(int, sysarg_t, sysarg_t, sysarg_t);
     122extern void async_msg_3(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     123extern void async_msg_4(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     124extern void async_msg_5(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     125    sysarg_t);
     126
     127/*
     128 * Wrappers for answer routines.
     129 */
     130
     131extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
     132extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
     133extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
     134extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     135    sysarg_t);
     136extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     137    sysarg_t, sysarg_t);
     138extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     139    sysarg_t, sysarg_t, sysarg_t);
     140
     141/*
     142 * Wrappers for forwarding routines.
     143 */
     144
     145extern int async_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
     146extern int async_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
     147    sysarg_t, sysarg_t, sysarg_t, int);
    130148
    131149/*
     
    135153 * and slow verion based on m.
    136154 */
     155
    137156#define async_req_0_0(phoneid, method) \
    138157        async_req_fast((phoneid), (method), 0, 0, 0, 0, NULL, NULL, NULL, NULL, \
     
    270289extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
    271290extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
     291extern int async_connect_kbox(task_id_t);
     292extern int async_hangup(int);
     293extern void async_poke(void);
    272294
    273295/*
    274296 * User-friendly wrappers for async_share_in_start().
    275297 */
     298
    276299#define async_share_in_start_0_0(phoneid, dst, size) \
    277300        async_share_in_start((phoneid), (dst), (size), 0, NULL)
     
    293316 * User-friendly wrappers for async_data_read_forward_fast().
    294317 */
     318
    295319#define async_data_read_forward_0_0(phoneid, method, answer) \
    296320        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     
    329353 * User-friendly wrappers for async_data_write_forward_fast().
    330354 */
     355
    331356#define async_data_write_forward_0_0(phoneid, method, answer) \
    332357        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
  • uspace/lib/c/include/ddi.h

    re26a4633 r46b881c  
    3636#define LIBC_DDI_H_
    3737
     38#include <sys/types.h>
     39#include <kernel/ddi/irq.h>
    3840#include <task.h>
    3941
     
    4244extern int iospace_enable(task_id_t, void *, unsigned long);
    4345extern int pio_enable(void *, size_t, void **);
     46extern int register_irq(int, int, int, irq_code_t *);
     47extern int unregister_irq(int, int);
    4448
    4549#endif
  • uspace/lib/c/include/devman.h

    re26a4633 r46b881c  
    4141#include <bool.h>
    4242
    43 
    4443extern int devman_get_phone(devman_interface_t, unsigned int);
    4544extern void devman_hangup_phone(devman_interface_t);
  • uspace/lib/c/include/event.h

    re26a4633 r46b881c  
    3737
    3838#include <kernel/ipc/event_types.h>
    39 #include <ipc/ipc.h>
    4039
    4140extern int event_subscribe(event_type_t, sysarg_t);
  • uspace/lib/c/include/io/console.h

    re26a4633 r46b881c  
    3636#define LIBC_IO_CONSOLE_H_
    3737
    38 #include <ipc/ipc.h>
    3938#include <bool.h>
    4039
  • uspace/lib/c/include/io/screenbuffer.h

    re26a4633 r46b881c  
    3838#include <stdint.h>
    3939#include <sys/types.h>
    40 #include <ipc/ipc.h>
    4140#include <bool.h>
    4241
  • uspace/lib/c/include/ipc/adb.h

    re26a4633 r46b881c  
    3232/** @file
    3333 * @brief ADB device interface.
    34  */ 
     34 */
    3535
    3636#ifndef LIBC_IPC_ADB_H_
    3737#define LIBC_IPC_ADB_H_
    3838
    39 #include <ipc/ipc.h>
     39#include <ipc/common.h>
    4040
    4141typedef enum {
    4242        ADB_REG_WRITE = IPC_FIRST_USER_METHOD
    4343} adb_request_t;
    44 
    4544
    4645typedef enum {
  • uspace/lib/c/include/ipc/arp.h

    re26a4633 r46b881c  
    3939#define LIBC_ARP_MESSAGES_
    4040
    41 #include <ipc/ipc.h>
    4241#include <ipc/net.h>
    4342
  • uspace/lib/c/include/ipc/bd.h

    re26a4633 r46b881c  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_IPC_BD_H_
    3636#define LIBC_IPC_BD_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
  • uspace/lib/c/include/ipc/char.h

    re26a4633 r46b881c  
    3232/** @file
    3333 * @brief Character device interface.
    34  */ 
     34 */
    3535
    3636#ifndef LIBC_IPC_CHAR_H_
    3737#define LIBC_IPC_CHAR_H_
    3838
    39 #include <ipc/ipc.h>
     39#include <ipc/common.h>
    4040
    4141typedef enum {
    4242        CHAR_WRITE_BYTE = IPC_FIRST_USER_METHOD
    4343} char_request_t;
    44 
    4544
    4645typedef enum {
  • uspace/lib/c/include/ipc/clipboard.h

    re26a4633 r46b881c  
    3636#define LIBC_IPC_CLIPBOARD_H_
    3737
    38 #include <ipc/ipc.h>
    39 
    4038typedef enum {
    4139        CLIPBOARD_PUT_DATA = IPC_FIRST_USER_METHOD,
  • uspace/lib/c/include/ipc/console.h

    re26a4633 r46b881c  
    3636#define LIBC_IPC_CONSOLE_H_
    3737
    38 #include <ipc/ipc.h>
    3938#include <ipc/vfs.h>
    4039
  • uspace/lib/c/include/ipc/dev_iface.h

    re26a4633 r46b881c  
    3030#define LIBC_IPC_DEV_IFACE_H_
    3131
    32 #include <ipc/ipc.h>
    3332#include <malloc.h>
    3433#include <unistd.h>
  • uspace/lib/c/include/ipc/devman.h

    re26a4633 r46b881c  
    3030 * @{
    3131 */
    32  
     32
    3333#ifndef LIBC_IPC_DEVMAN_H_
    3434#define LIBC_IPC_DEVMAN_H_
    3535
     36#include <ipc/common.h>
    3637#include <adt/list.h>
    37 #include <ipc/ipc.h>
    38 #include <stdlib.h>
    39 #include <stdio.h>
    40 #include <str.h>
     38#include <malloc.h>
     39#include <mem.h>
    4140
    42 #define DEVMAN_NAME_MAXLEN 256
     41#define DEVMAN_NAME_MAXLEN  256
    4342
    4443typedef sysarg_t devman_handle_t;
     
    6766} match_id_list_t;
    6867
    69 
    70 static inline match_id_t * create_match_id()
     68static inline match_id_t *create_match_id(void)
    7169{
    7270        match_id_t *id = malloc(sizeof(match_id_t));
     
    8583}
    8684
    87 static inline void add_match_id(match_id_list_t *ids, match_id_t *id) 
     85static inline void add_match_id(match_id_list_t *ids, match_id_t *id)
    8886{
    8987        match_id_t *mid = NULL;
    90         link_t *link = ids->ids.next;   
     88        link_t *link = ids->ids.next;
    9189       
    9290        while (link != &ids->ids) {
     
    9896        }
    9997       
    100         list_insert_before(&id->link, link);   
     98        list_insert_before(&id->link, link);
    10199}
    102100
  • uspace/lib/c/include/ipc/devmap.h

    re26a4633 r46b881c  
    3434#define DEVMAP_DEVMAP_H_
    3535
    36 #include <atomic.h>
    37 #include <ipc/ipc.h>
    38 #include <adt/list.h>
     36#include <ipc/common.h>
    3937
    4038#define DEVMAP_NAME_MAXLEN  255
  • uspace/lib/c/include/ipc/fb.h

    re26a4633 r46b881c  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_FB_H_
    3636#define LIBC_FB_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
  • uspace/lib/c/include/ipc/icmp.h

    re26a4633 r46b881c  
    3939#define LIBC_ICMP_MESSAGES_
    4040
    41 #include <ipc/ipc.h>
    4241#include <ipc/net.h>
    4342#include <sys/types.h>
    4443#include <sys/time.h>
    45 
    4644#include <net/icmp_codes.h>
    4745
  • uspace/lib/c/include/ipc/il.h

    re26a4633 r46b881c  
    4040#define LIBC_IL_MESSAGES_H_
    4141
    42 #include <ipc/ipc.h>
    4342#include <ipc/net.h>
    4443
  • uspace/lib/c/include/ipc/ip.h

    re26a4633 r46b881c  
    3939#define LIBC_IP_MESSAGES_H_
    4040
    41 #include <ipc/ipc.h>
    4241#include <ipc/net.h>
    43 
    4442#include <net/in.h>
    4543#include <net/ip_codes.h>
  • uspace/lib/c/include/ipc/ipc.h

    re26a4633 r46b881c  
    3333 */
    3434
    35 #ifndef LIBIPC_IPC_H_
    36 #define LIBIPC_IPC_H_
    37 
     35#if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
     36        #error Do not intermix low-level IPC interface and async framework
     37#endif
     38
     39#ifndef LIBC_IPC_H_
     40#define LIBC_IPC_H_
     41
     42#include <sys/types.h>
     43#include <ipc/common.h>
     44#include <kernel/synch/synch.h>
    3845#include <task.h>
    39 #include <kernel/ipc/ipc.h>
    40 #include <kernel/ddi/irq.h>
    41 #include <sys/types.h>
    42 #include <kernel/synch/synch.h>
    43 
    44 #define IPC_FLAG_BLOCKING  0x01
    45 
    46 typedef struct {
    47         sysarg_t args[IPC_CALL_LEN];
    48         sysarg_t in_task_hash;
    49         sysarg_t in_phone_hash;
    50 } ipc_call_t;
    51 
    52 typedef sysarg_t ipc_callid_t;
    53 
    54 typedef void (* ipc_async_callback_t)(void *, int, ipc_call_t *);
     46
     47typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
    5548
    5649/*
     
    263256extern int ipc_connect_me_to_blocking(int, int, int, int);
    264257extern int ipc_hangup(int);
    265 extern int ipc_register_irq(int, int, int, irq_code_t *);
    266 extern int ipc_unregister_irq(int, int);
    267258extern int ipc_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
    268259extern int ipc_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
  • uspace/lib/c/include/ipc/irc.h

    re26a4633 r46b881c  
    3636#define LIBC_IRC_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
  • uspace/lib/c/include/ipc/kbd.h

    re26a4633 r46b881c  
    3838#define LIBC_IPC_KBD_H_
    3939
    40 #include <ipc/ipc.h>
     40#include <ipc/common.h>
    4141
    4242typedef enum {
  • uspace/lib/c/include/ipc/loader.h

    re26a4633 r46b881c  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_IPC_LOADER_H_
    3636#define LIBC_IPC_LOADER_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
  • uspace/lib/c/include/ipc/mouse.h

    re26a4633 r46b881c  
    3737#define LIBC_IPC_MOUSE_H_
    3838
    39 #include <ipc/ipc.h>
     39#include <ipc/common.h>
    4040
    4141typedef enum {
  • uspace/lib/c/include/ipc/net.h

    re26a4633 r46b881c  
    3838#define LIBC_NET_MESSAGES_H_
    3939
    40 #include <ipc/ipc.h>
    4140#include <ipc/services.h>
    42 
    4341#include <net/device.h>
    4442#include <net/packet.h>
  • uspace/lib/c/include/ipc/net_net.h

    re26a4633 r46b881c  
    3939#define LIBC_NET_NET_MESSAGES_H_
    4040
    41 #include <ipc/ipc.h>
    4241#include <ipc/net.h>
    4342
  • uspace/lib/c/include/ipc/netif.h

    re26a4633 r46b881c  
    3838#define LIBC_NETIF_MESSAGES_H_
    3939
    40 #include <ipc/ipc.h>
    4140#include <ipc/net.h>
    4241
  • uspace/lib/c/include/ipc/nil.h

    re26a4633 r46b881c  
    3838#define LIBC_NIL_MESSAGES_H_
    3939
    40 #include <ipc/ipc.h>
    4140#include <ipc/net.h>
    4241
  • uspace/lib/c/include/ipc/ns.h

    re26a4633 r46b881c  
    3333 */
    3434
    35 #ifndef LIBIPC_NS_H_
    36 #define LIBIPC_NS_H_
     35#ifndef LIBC_NS_H_
     36#define LIBC_NS_H_
    3737
    3838#include <sys/types.h>
    39 #include <ipc/ipc.h>
     39#include <ipc/common.h>
    4040
    4141typedef enum {
     
    5151
    5252extern wchar_t *service_klog_share_in(size_t *);
     53extern void *service_realtime_share_in(void);
    5354
    5455#endif
  • uspace/lib/c/include/ipc/packet.h

    re26a4633 r46b881c  
    3838#define LIBC_PACKET_MESSAGES_
    3939
    40 #include <ipc/ipc.h>
    4140#include <ipc/net.h>
    4241
  • uspace/lib/c/include/ipc/services.h

    re26a4633 r46b881c  
    3535 */
    3636
    37 #ifndef LIBIPC_SERVICES_H_
    38 #define LIBIPC_SERVICES_H_
     37#ifndef LIBC_SERVICES_H_
     38#define LIBC_SERVICES_H_
    3939
    4040typedef enum {
     
    6666} services_t;
    6767
    68 /* Memory area to be received from NS */
    69 #define SERVICE_MEM_REALTIME    1
    70 #define SERVICE_MEM_KLOG        2
     68/* Memory areas to be received from NS */
     69typedef enum {
     70        SERVICE_MEM_REALTIME = 1,
     71        SERVICE_MEM_KLOG = 2
     72} mem_services_t;
    7173
    7274#endif
  • uspace/lib/c/include/ipc/socket.h

    re26a4633 r46b881c  
    3838#define LIBC_SOCKET_MESSAGES_H_
    3939
    40 #include <ipc/ipc.h>
    4140#include <ipc/net.h>
    4241
  • uspace/lib/c/include/ipc/tl.h

    re26a4633 r46b881c  
    3939#define LIBC_TL_MESSAGES_H_
    4040
    41 #include <ipc/ipc.h>
    4241#include <ipc/net.h>
    4342
  • uspace/lib/c/include/ipc/vfs.h

    re26a4633 r46b881c  
    3636#define LIBC_IPC_VFS_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939#include <sys/types.h>
    4040#include <bool.h>
  • uspace/lib/c/include/net/modules.h

    re26a4633 r46b881c  
    4343
    4444#include <async.h>
    45 
    46 #include <ipc/ipc.h>
    4745#include <ipc/services.h>
    48 
    4946#include <sys/time.h>
    5047
  • uspace/lib/c/include/udebug.h

    re26a4633 r46b881c  
    3838#include <kernel/udebug/udebug.h>
    3939#include <sys/types.h>
    40 #include <libarch/types.h>
    4140
    4241typedef sysarg_t thash_t;
    4342
    44 int udebug_begin(int phoneid);
    45 int udebug_end(int phoneid);
    46 int udebug_set_evmask(int phoneid, udebug_evmask_t mask);
    47 int udebug_thread_read(int phoneid, void *buffer, size_t n,
    48         size_t *copied, size_t *needed);
    49 int udebug_name_read(int phoneid, void *buffer, size_t n,
    50         size_t *copied, size_t *needed);
    51 int udebug_areas_read(int phoneid, void *buffer, size_t n,
    52         size_t *copied, size_t *needed);
    53 int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n);
    54 int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer);
    55 int udebug_regs_read(int phoneid, thash_t tid, void *buffer);
    56 int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type,
    57         sysarg_t *val0, sysarg_t *val1);
    58 int udebug_stop(int phoneid, thash_t tid);
     43int udebug_begin(int);
     44int udebug_end(int);
     45int udebug_set_evmask(int, udebug_evmask_t);
     46int udebug_thread_read(int, void *, size_t , size_t *, size_t *);
     47int udebug_name_read(int, void *, size_t, size_t *, size_t *);
     48int udebug_areas_read(int, void *, size_t, size_t *, size_t *);
     49int udebug_mem_read(int, void *, uintptr_t, size_t);
     50int udebug_args_read(int, thash_t, sysarg_t *);
     51int udebug_regs_read(int, thash_t, void *);
     52int udebug_go(int, thash_t, udebug_event_t *, sysarg_t *, sysarg_t *);
     53int udebug_stop(int, thash_t);
    5954
    6055#endif
Note: See TracChangeset for help on using the changeset viewer.