Changeset 27d293a in mainline


Ignore:
Timestamp:
2007-12-31T16:46:43Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
215e375
Parents:
3115355
Message:

Rename IPC_M_AS_AREA_SEND to IPC_M_SHARE_OUT. Rename IPC_M_AS_AREA_RECV to
IPC_M_SHARE_IN. Provide user-friendly wrappers for these methods so that even
dummies can get it right. Some applications using simpler protocols still use
these methods directly.

Files:
14 edited

Legend:

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

    r3115355 r27d293a  
    160160 * - ARG1 - dst as_area base adress
    161161 */
    162 #define IPC_M_AS_AREA_SEND      4       
     162#define IPC_M_SHARE_OUT         4       
    163163
    164164/** Receive as_area over IPC.
     
    172172 * - ARG2 - flags that will be used for sharing
    173173 */
    174 #define IPC_M_AS_AREA_RECV      5       
     174#define IPC_M_SHARE_IN          5       
    175175
    176176/** Send data to another address space over IPC.
  • kernel/generic/src/ipc/sysipc.c

    r3115355 r27d293a  
    113113{
    114114        switch (method) {
    115         case IPC_M_AS_AREA_SEND:
    116         case IPC_M_AS_AREA_RECV:
     115        case IPC_M_SHARE_OUT:
     116        case IPC_M_SHARE_IN:
    117117        case IPC_M_DATA_WRITE:
    118118        case IPC_M_DATA_READ:
     
    142142        case IPC_M_CONNECT_TO_ME:
    143143        case IPC_M_CONNECT_ME_TO:
    144         case IPC_M_AS_AREA_SEND:
    145         case IPC_M_AS_AREA_RECV:
     144        case IPC_M_SHARE_OUT:
     145        case IPC_M_SHARE_IN:
    146146        case IPC_M_DATA_WRITE:
    147147        case IPC_M_DATA_READ:
     
    200200                            &TASK->answerbox);
    201201                }
    202         } else if (IPC_GET_METHOD(*olddata) == IPC_M_AS_AREA_SEND) {
     202        } else if (IPC_GET_METHOD(*olddata) == IPC_M_SHARE_OUT) {
    203203                if (!IPC_GET_RETVAL(answer->data)) {
    204204                        /* Accepted, handle as_area receipt */
     
    219219                        return rc;
    220220                }
    221         } else if (IPC_GET_METHOD(*olddata) == IPC_M_AS_AREA_RECV) {
     221        } else if (IPC_GET_METHOD(*olddata) == IPC_M_SHARE_IN) {
    222222                if (!IPC_GET_RETVAL(answer->data)) {
    223223                        ipl_t ipl;
     
    314314                call->priv = newphid;
    315315                break;
    316         case IPC_M_AS_AREA_SEND:
     316        case IPC_M_SHARE_OUT:
    317317                size = as_area_get_size(IPC_GET_ARG1(call->data));
    318318                if (!size)
  • uspace/app/klog/klog.c

    r3115355 r27d293a  
    6464       
    6565        mapping = as_get_mappable_page(PAGE_SIZE);
    66         res = ipc_call_sync_3_0(PHONE_NS, IPC_M_AS_AREA_RECV,
    67             (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG);
     66        res = ipc_share_in_send_1_0(PHONE_NS, mapping, PAGE_SIZE,
     67            SERVICE_MEM_KLOG);
    6868        if (res) {
    6969                printf("Failed to initialize klog memarea\n");
  • uspace/lib/libc/generic/ipc.c

    r3115355 r27d293a  
    667667}
    668668
     669/** Wrapper for making IPC_M_SHARE_IN calls.
     670 *
     671 * @param phoneid       Phone that will be used to contact the receiving side.
     672 * @param dst           Destination address space area base.
     673 * @param size          Size of the destination address space area.
     674 * @param arg           User defined argument.
     675 * @param flags         Storage where the received flags will be stored. Can be
     676 *                      NULL.
     677 *
     678 * @return              Zero on success or a negative error code from errno.h.
     679 */
     680int ipc_share_in_send(int phoneid, void *dst, size_t size, ipcarg_t arg,
     681    int *flags)
     682{
     683        int res;
     684        sysarg_t tmp_flags;
     685        res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
     686            (ipcarg_t) size, arg, NULL, &tmp_flags);
     687        if (flags)
     688                *flags = tmp_flags;
     689        return res;
     690}
     691
     692/** Wrapper for receiving the IPC_M_SHARE_IN calls.
     693 *
     694 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN calls
     695 * so that the user doesn't have to remember the meaning of each IPC argument.
     696 *
     697 * So far, this wrapper is to be used from within a connection fibril.
     698 *
     699 * @param callid        Storage where the hash of the IPC_M_SHARE_IN call will
     700 *                      be stored.
     701 * @param size          Destination address space area size.   
     702 *
     703 * @return              Non-zero on success, zero on failure.
     704 */
     705int ipc_share_in_receive(ipc_callid_t *callid, size_t *size)
     706{
     707        ipc_call_t data;
     708       
     709        assert(callid);
     710        assert(size);
     711
     712        *callid = async_get_call(&data);
     713        if (IPC_GET_METHOD(data) != IPC_M_SHARE_IN)
     714                return 0;
     715        *size = (size_t) IPC_GET_ARG2(data);
     716        return 1;
     717}
     718
     719/** Wrapper for answering the IPC_M_SHARE_IN calls.
     720 *
     721 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
     722 * so that the user doesn't have to remember the meaning of each IPC argument.
     723 *
     724 * @param callid        Hash of the IPC_M_DATA_READ call to answer.
     725 * @param src           Source address space base.
     726 * @param flags         Flags to be used for sharing. Bits can be only cleared.
     727 *
     728 * @return              Zero on success or a value from @ref errno.h on failure.
     729 */
     730int ipc_share_in_deliver(ipc_callid_t callid, void *src, int flags)
     731{
     732        return ipc_answer_2(callid, EOK, (ipcarg_t) src, (ipcarg_t) flags);
     733}
     734
     735/** Wrapper for making IPC_M_SHARE_OUT calls.
     736 *
     737 * @param phoneid       Phone that will be used to contact the receiving side.
     738 * @param src           Source address space area base address.
     739 * @param flags         Flags to be used for sharing. Bits can be only cleared.
     740 *
     741 * @return              Zero on success or a negative error code from errno.h.
     742 */
     743int ipc_share_out_send(int phoneid, void *src, int flags)
     744{
     745        return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0,
     746            (ipcarg_t) flags);
     747}
     748
     749/** Wrapper for receiving the IPC_M_SHARE_OUT calls.
     750 *
     751 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT calls
     752 * so that the user doesn't have to remember the meaning of each IPC argument.
     753 *
     754 * So far, this wrapper is to be used from within a connection fibril.
     755 *
     756 * @param callid        Storage where the hash of the IPC_M_SHARE_OUT call will
     757 *                      be stored.
     758 * @param size          Storage where the source address space area size will be
     759 *                      stored.
     760 * @param flags         Storage where the sharing flags will be stored.
     761 *
     762 * @return              Non-zero on success, zero on failure.
     763 */
     764int ipc_share_out_receive(ipc_callid_t *callid, size_t *size, int *flags)
     765{
     766        ipc_call_t data;
     767       
     768        assert(callid);
     769        assert(size);
     770        assert(flags);
     771
     772        *callid = async_get_call(&data);
     773        if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE)
     774                return 0;
     775        *size = (size_t) IPC_GET_ARG2(data);
     776        *flags = (int) IPC_GET_ARG3(data);
     777        return 1;
     778}
     779
     780/** Wrapper for answering the IPC_M_SHARE_OUT calls.
     781 *
     782 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls
     783 * so that the user doesn't have to remember the meaning of each IPC argument.
     784 *
     785 * @param callid        Hash of the IPC_M_DATA_WRITE call to answer.
     786 * @param dst           Destination address space area base address.   
     787 *
     788 * @return              Zero on success or a value from @ref errno.h on failure.
     789 */
     790int ipc_share_out_deliver(ipc_callid_t callid, void *dst)
     791{
     792        return ipc_answer_1(callid, EOK, (ipcarg_t) dst);
     793}
     794
     795
    669796/** Wrapper for making IPC_M_DATA_READ calls.
    670797 *
  • uspace/lib/libc/generic/time.c

    r3115355 r27d293a  
    136136        void *mapping;
    137137        sysarg_t s1, s2;
    138         sysarg_t rights;
     138        int rights;
    139139        int res;
    140140
     
    142142                mapping = as_get_mappable_page(PAGE_SIZE);
    143143                /* Get the mapping of kernel clock */
    144                 res = ipc_call_sync_3_2(PHONE_NS, IPC_M_AS_AREA_RECV,
    145                     (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL,
    146                     &rights);
     144                res = ipc_share_in_send_1_1(PHONE_NS, mapping, PAGE_SIZE,
     145                    SERVICE_MEM_REALTIME, &rights);
    147146                if (res) {
    148147                        printf("Failed to initialize timeofday memarea\n");
  • uspace/lib/libc/include/ipc/ipc.h

    r3115355 r27d293a  
    263263
    264264
     265/*
     266 * User-friendly wrappers for ipc_share_in_send().
     267 */
     268#define ipc_share_in_send_0_0(phoneid, dst, size) \
     269    ipc_share_in_send((phoneid), (dst), (size), 0, NULL)
     270#define ipc_share_in_send_0_1(phoneid, dst, size, flags) \
     271    ipc_share_in_send((phoneid), (dst), (size), 0, (flags))
     272#define ipc_share_in_send_1_0(phoneid, dst, size, arg) \
     273    ipc_share_in_send((phoneid), (dst), (size), (arg), NULL)
     274#define ipc_share_in_send_1_1(phoneid, dst, size, arg, flags) \
     275    ipc_share_in_send((phoneid), (dst), (size), (arg), (flags))
     276
     277extern int ipc_share_in_send(int phoneid, void *dst, size_t size, ipcarg_t arg,
     278    int *flags);
     279extern int ipc_share_in_receive(ipc_callid_t *callid, size_t *size);
     280extern int ipc_share_in_deliver(ipc_callid_t callid, void *src, int flags);
     281extern int ipc_share_out_send(int phoneid, void *src, int flags);
     282extern int ipc_share_out_receive(ipc_callid_t *callid, size_t *size, int *flags);
     283extern int ipc_share_out_deliver(ipc_callid_t callid, void *dst);
    265284extern int ipc_data_read_send(int phoneid, void *dst, size_t size);
    266285extern int ipc_data_read_receive(ipc_callid_t *callid, size_t *size);
  • uspace/lib/libfs/libfs.c

    r3115355 r27d293a  
    9595         * Request sharing the Path Lookup Buffer with VFS.
    9696         */
    97         rc = ipc_call_sync_2_0(vfs_phone, IPC_M_AS_AREA_RECV,
    98             (ipcarg_t) reg->plb_ro, PLB_SIZE);
     97        rc = ipc_share_in_send_0_0(vfs_phone, reg->plb_ro, PLB_SIZE);
    9998        if (rc) {
    10099                async_wait_for(req, NULL);
  • uspace/srv/console/console.c

    r3115355 r27d293a  
    538538            PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
    539539        if (!interbuffer) {
    540                 if (async_req_3_0(fb_info.phone, IPC_M_AS_AREA_SEND,
    541                     (ipcarg_t) interbuffer, 0, AS_AREA_READ) != 0) {
     540                if (ipc_share_out_send(fb_info.phone, interbuffer,
     541                    AS_AREA_READ) != EOK) {
    542542                        munmap(interbuffer,
    543543                            sizeof(keyfield_t) * fb_info.cols * fb_info.rows);
  • uspace/srv/console/gcons.c

    r3115355 r27d293a  
    326326        if (rc)
    327327                goto exit;
    328         rc = async_req_3_0(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t) shm, 0,
    329             PROTO_READ);
     328        rc = ipc_share_out_send(fbphone, shm, PROTO_READ);
    330329        if (rc)
    331330                goto drop;
     
    388387        if (rc)
    389388                goto exit;
    390         rc = async_req_3_0(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t) shm, 0,
    391             PROTO_READ);
     389        rc = ipc_share_out_send(fbphone, shm, PROTO_READ);
    392390        if (rc)
    393391                goto drop;
  • uspace/srv/fb/ega.c

    r3115355 r27d293a  
    209209                        ipc_answer_0(callid, EOK);
    210210                        return; /* Exit thread */
    211                 case IPC_M_AS_AREA_SEND:
     211                case IPC_M_SHARE_OUT:
    212212                        /* We accept one area for data interchange */
    213213                        intersize = IPC_GET_ARG2(call);
  • uspace/srv/fb/fb.c

    r3115355 r27d293a  
    748748
    749749        switch (IPC_GET_METHOD(*call)) {
    750         case IPC_M_AS_AREA_SEND:
     750        case IPC_M_SHARE_OUT:
    751751                /* We accept one area for data interchange */
    752752                if (IPC_GET_ARG1(*call) == shm_id) {
  • uspace/srv/ns/ns.c

    r3115355 r27d293a  
    118118                callid = ipc_wait_for_call(&call);
    119119                switch (IPC_GET_METHOD(call)) {
    120                 case IPC_M_AS_AREA_RECV:
     120                case IPC_M_SHARE_IN:
    121121                        switch (IPC_GET_ARG3(call)) {
    122122                        case SERVICE_MEM_REALTIME:
  • uspace/srv/rd/rd.c

    r3115355 r27d293a  
    104104         * Now we wait for the client to send us its communication as_area.
    105105         */
    106         callid = async_get_call(&call);
    107         if (IPC_GET_METHOD(call) == IPC_M_AS_AREA_SEND) {
    108                 if (IPC_GET_ARG1(call) >= (ipcarg_t) BLOCK_SIZE) {
     106        size_t size;
     107        if (ipc_share_out_receive(&callid, &size, NULL)) {
     108                if (size >= BLOCK_SIZE) {
    109109                        /*
    110110                         * The client sends an as_area that can absorb the whole
    111111                         * block.
    112112                         */
    113                         ipc_answer_1(callid, EOK, (uintptr_t) fs_va);
     113                        (void) ipc_share_out_deliver(callid, fs_va);
    114114                } else {
    115115                        /*
  • uspace/srv/vfs/vfs_register.c

    r3115355 r27d293a  
    271271         * The client will want us to send him the address space area with PLB.
    272272         */
    273         callid = async_get_call(&call);
    274         if (IPC_GET_METHOD(call) != IPC_M_AS_AREA_RECV) {
     273
     274        if (!ipc_share_in_receive(&callid, &size)) {
    275275                dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
    276276                list_remove(&fs_info->fs_link);
     
    286286         * We can only send the client address space area PLB_SIZE bytes long.
    287287         */
    288         size = IPC_GET_ARG2(call);
    289288        if (size != PLB_SIZE) {
    290289                dprintf("Client suggests wrong size of PFB, size = %d\n", size);
     
    301300         * Commit to read-only sharing the PLB with the client.
    302301         */
    303         ipc_answer_2(callid, EOK, (ipcarg_t) plb,
    304             (ipcarg_t) (AS_AREA_READ | AS_AREA_CACHEABLE));     
     302        (void) ipc_share_in_deliver(callid, plb,
     303            AS_AREA_READ | AS_AREA_CACHEABLE);
    305304
    306305        dprintf("Sharing PLB.\n");
Note: See TracChangeset for help on using the changeset viewer.