Changeset 72af8da in mainline for uspace/drv/uhci-hcd/utils/malloc32.h


Ignore:
Timestamp:
2011-03-16T18:50:17Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42a3a57
Parents:
3e7b7cd (diff), fcf07e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from usb/development

File:
1 edited

Legend:

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

    r3e7b7cd r72af8da  
    3535#define DRV_UHCI_TRANSLATOR_H
    3636
    37 #include <usb/usbmem.h>
    38 
    3937#include <assert.h>
    4038#include <malloc.h>
     
    4543#define UHCI_REQUIRED_PAGE_SIZE 4096
    4644
     45/** Get physical address translation
     46 *
     47 * @param[in] addr Virtual address to translate
     48 * @return Physical address if exists, NULL otherwise.
     49 */
    4750static inline uintptr_t addr_to_phys(void *addr)
    4851{
     
    5053        int ret = as_get_physical_mapping(addr, &result);
    5154
    52         assert(ret == 0);
     55        if (ret != EOK)
     56                return 0;
    5357        return (result | ((uintptr_t)addr & 0xfff));
    5458}
    55 
     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 */
    5665static inline void * malloc32(size_t size)
    5766        { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); }
    58 
    59 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)
    6080{
    6181        void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    6282        assert(free_address);
    6383        if (free_address == 0)
    64                 return 0;
     84                return NULL;
    6585        void* ret =
    6686          as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    6787                  AS_AREA_READ | AS_AREA_WRITE);
    6888        if (ret != free_address)
    69                 return 0;
     89                return NULL;
    7090        return ret;
    7191}
    72 
    73 static inline void free32(void *addr)
    74         { if (addr) free(addr); }
    7592
    7693#endif
Note: See TracChangeset for help on using the changeset viewer.