Changeset fbcdeb8 in mainline for uspace/lib/c/generic/as.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/as.c

    r24cf31f1 rfbcdeb8  
    4545/** Create address space area.
    4646 *
    47  * @param address Virtual address where to place new address space area.
    48  * @param size    Size of the area.
    49  * @param flags   Flags describing type of the area.
     47 * @param base  Starting virtual address of the area.
     48 *              If set to (void *) -1, the kernel finds
     49 *              a mappable area.
     50 * @param size  Size of the area.
     51 * @param flags Flags describing type of the area.
    5052 *
    51  * @return address on success, (void *) -1 otherwise.
     53 * @return Starting virtual address of the created area on success.
     54 * @return (void *) -1 otherwise.
    5255 *
    5356 */
    54 void *as_area_create(void *address, size_t size, unsigned int flags)
     57void *as_area_create(void *base, size_t size, unsigned int flags)
    5558{
    56         return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t) address,
    57             (sysarg_t) size, (sysarg_t) flags);
     59        return (void *) __SYSCALL4(SYS_AS_AREA_CREATE, (sysarg_t) base,
     60            (sysarg_t) size, (sysarg_t) flags, (sysarg_t) __entry);
    5861}
    5962
     
    102105}
    103106
    104 /** Return pointer to unmapped address space area
    105  *
    106  * @param size Requested size of the allocation.
    107  *
    108  * @return Pointer to the beginning of unmapped address space area.
    109  *
    110  */
    111 void *as_get_mappable_page(size_t size)
    112 {
    113         return (void *) __SYSCALL2(SYS_AS_GET_UNMAPPED_AREA,
    114             (sysarg_t) __entry, (sysarg_t) size);
    115 }
    116 
    117107/** Find mapping to physical address.
    118108 *
Note: See TracChangeset for help on using the changeset viewer.