Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/utils/malloc32.h

    r5d5f971 r17ceb72  
    4343#define UHCI_REQUIRED_PAGE_SIZE 4096
    4444
     45/** Get physical address translation
     46 *
     47 * @param[in] addr Virtual address to translate
     48 * @return Physical address if exists, NULL otherwise.
     49 */
    4550static inline uintptr_t addr_to_phys(void *addr)
    4651{
     
    4853        int ret = as_get_physical_mapping(addr, &result);
    4954
    50         assert(ret == 0);
     55        if (ret != EOK)
     56                return 0;
    5157        return (result | ((uintptr_t)addr & 0xfff));
    5258}
    53 
     59/*----------------------------------------------------------------------------*/
     60/** Physical mallocator simulator
     61 *
     62 * @param[in] size Size of the required memory space
     63 * @return Address of the alligned and big enough memory place, NULL on failure.
     64 */
    5465static inline void * malloc32(size_t size)
    5566        { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); }
    56 
    57 static inline void * get_page()
     67/*----------------------------------------------------------------------------*/
     68/** Physical mallocator simulator
     69 *
     70 * @param[in] addr Address of the place allocated by malloc32
     71 */
     72static inline void free32(void *addr)
     73        { if (addr) free(addr); }
     74/*----------------------------------------------------------------------------*/
     75/** Create 4KB page mapping
     76 *
     77 * @return Address of the mapped page, NULL on failure.
     78 */
     79static inline void * get_page(void)
    5880{
    5981        void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    6082        assert(free_address);
    6183        if (free_address == 0)
    62                 return 0;
     84                return NULL;
    6385        void* ret =
    6486          as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    6587                  AS_AREA_READ | AS_AREA_WRITE);
    6688        if (ret != free_address)
    67                 return 0;
     89                return NULL;
    6890        return ret;
    6991}
    70 
    71 static inline void free32(void *addr)
    72         { if (addr) free(addr); }
    7392
    7493#endif
Note: See TracChangeset for help on using the changeset viewer.