Changeset fbcdeb8 in mainline for uspace/lib/c/generic/ipc.c


Ignore:
Timestamp:
2011-12-19T17:30:39Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
58f6229
Parents:
24cf31f1
Message:

Remove the two-phase way of creating virtual memory areas (first asking for a mappable address and then mapping it) which was prone to race conditions when two or more calls to as_get_mappable_page() and as_area_create() were interleaved. This for example caused the e1k driver to randomly fail.

The memory area related syscalls and IPC calls have all been altered to accept a special value (void *) -1, representing a demand to atomically search for a mappable address space "hole" and map to it.

Individual changes:

  • IPC_M_SHARE_OUT: the destination address space area is supplied by the kernel, the callee only specifies the lower bound

(the address is returned to the callee via a pointer in an IPC reply argument)

  • IPC_M_SHARE_IN: the destination address space ares is supplied by the kernel, the callee only specifies the lower bound

(the address is returned to the caller as usual via an IPC argument)

  • SYS_AS_GET_UNMAPPED_AREA was removed
  • dummy implementations of SYS_PHYSMEM_UNMAP and SYS_IOSPACE_DISABLE were added for the sake of symmetry (they do nothing yet)
  • SYS_PHYSMEM_MAP and SYS_DMAMEM_MAP were altered to accept (void *) -1 as address space area base and a lower bound
  • kernel as_area_create() and as_area_share() were altered to accept (void *) -1 as address space area base and a lower bound
  • uspace libraries and programs were altered to reflect the new API
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ipc.c

    r24cf31f1 rfbcdeb8  
    4848#include <fibril.h>
    4949#include <macros.h>
     50#include "private/libc.h"
    5051
    5152/**
     
    760761 *
    761762 * @param phoneid Phone that will be used to contact the receiving side.
    762  * @param dst     Destination address space area base.
    763763 * @param size    Size of the destination address space area.
    764764 * @param arg     User defined argument.
    765765 * @param flags   Storage for received flags. Can be NULL.
     766 * @param dst     Destination address space area base. Cannot be NULL.
    766767 *
    767768 * @return Zero on success or a negative error code from errno.h.
    768769 *
    769770 */
    770 int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
    771     unsigned int *flags)
    772 {
    773         sysarg_t tmp_flags = 0;
    774         int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
    775             (sysarg_t) size, arg, NULL, &tmp_flags);
     771int ipc_share_in_start(int phoneid, size_t size, sysarg_t arg,
     772    unsigned int *flags, void **dst)
     773{
     774        sysarg_t _flags = 0;
     775        sysarg_t _dst = (sysarg_t) -1;
     776        int res = ipc_call_sync_2_4(phoneid, IPC_M_SHARE_IN, (sysarg_t) size,
     777            arg, NULL, &_flags, NULL, &_dst);
    776778       
    777779        if (flags)
    778                 *flags = (unsigned int) tmp_flags;
    779        
     780                *flags = (unsigned int) _flags;
     781       
     782        *dst = (void *) _dst;
    780783        return res;
    781784}
     
    783786/** Wrapper for answering the IPC_M_SHARE_IN calls.
    784787 *
    785  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
     788 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_IN
    786789 * calls so that the user doesn't have to remember the meaning of each
    787790 * IPC argument.
     
    796799int ipc_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
    797800{
    798         return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags);
     801        return ipc_answer_3(callid, EOK, (sysarg_t) src, (sysarg_t) flags,
     802            (sysarg_t) __entry);
    799803}
    800804
     
    826830 *
    827831 */
    828 int ipc_share_out_finalize(ipc_callid_t callid, void *dst)
    829 {
    830         return ipc_answer_1(callid, EOK, (sysarg_t) dst);
     832int ipc_share_out_finalize(ipc_callid_t callid, void **dst)
     833{
     834        return ipc_answer_2(callid, EOK, (sysarg_t) __entry, (sysarg_t) dst);
    831835}
    832836
Note: See TracChangeset for help on using the changeset viewer.