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


Ignore:
Timestamp:
2011-12-19T17:30:39Z (13 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/async.c

    r24cf31f1 rfbcdeb8  
    19981998 *
    19991999 * @param exch  Exchange for sending the message.
    2000  * @param dst   Destination address space area base.
    20012000 * @param size  Size of the destination address space area.
    20022001 * @param arg   User defined argument.
    20032002 * @param flags Storage for the received flags. Can be NULL.
     2003 * @param dst   Destination address space area base. Cannot be NULL.
    20042004 *
    20052005 * @return Zero on success or a negative error code from errno.h.
    20062006 *
    20072007 */
    2008 int async_share_in_start(async_exch_t *exch, void *dst, size_t size,
    2009     sysarg_t arg, unsigned int *flags)
     2008int async_share_in_start(async_exch_t *exch, size_t size, sysarg_t arg,
     2009    unsigned int *flags, void **dst)
    20102010{
    20112011        if (exch == NULL)
    20122012                return ENOENT;
    20132013       
    2014         sysarg_t tmp_flags;
    2015         int res = async_req_3_2(exch, IPC_M_SHARE_IN, (sysarg_t) dst,
    2016             (sysarg_t) size, arg, NULL, &tmp_flags);
     2014        sysarg_t _flags = 0;
     2015        sysarg_t _dst = (sysarg_t) -1;
     2016        int res = async_req_2_4(exch, IPC_M_SHARE_IN, (sysarg_t) size,
     2017            arg, NULL, &_flags, NULL, &_dst);
    20172018       
    20182019        if (flags)
    2019                 *flags = (unsigned int) tmp_flags;
    2020        
     2020                *flags = (unsigned int) _flags;
     2021       
     2022        *dst = (void *) _dst;
    20212023        return res;
    20222024}
     
    20472049                return false;
    20482050       
    2049         *size = (size_t) IPC_GET_ARG2(data);
     2051        *size = (size_t) IPC_GET_ARG1(data);
    20502052        return true;
    20512053}
     
    20532055/** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework.
    20542056 *
    2055  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
     2057 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_IN
    20562058 * calls so that the user doesn't have to remember the meaning of each IPC
    20572059 * argument.
     
    21312133 *
    21322134 */
    2133 int async_share_out_finalize(ipc_callid_t callid, void *dst)
     2135int async_share_out_finalize(ipc_callid_t callid, void **dst)
    21342136{
    21352137        return ipc_share_out_finalize(callid, dst);
Note: See TracChangeset for help on using the changeset viewer.