Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/utils/malloc32.h

    rfbcdeb8 raf2b806  
    5454        if (addr == NULL)
    5555                return 0;
    56        
     56
    5757        uintptr_t result;
    5858        const int ret = as_get_physical_mapping(addr, &result);
    5959        if (ret != EOK)
    6060                return 0;
    61        
    62         return result;
     61        return (result | ((uintptr_t)addr & 0xfff));
    6362}
    6463/*----------------------------------------------------------------------------*/
    65 /** DMA malloc simulator
     64/** Physical mallocator simulator
    6665 *
    6766 * @param[in] size Size of the required memory space
    68  * @return Address of the aligned and big enough memory place, NULL on failure.
     67 * @return Address of the alligned and big enough memory place, NULL on failure.
    6968 */
    70 static inline void * malloc32(size_t size)
    71 {
     69static inline void * malloc32(size_t size) {
    7270        /* This works only when the host has less than 4GB of memory as
    7371         * physical address needs to fit into 32 bits */
     
    8583}
    8684/*----------------------------------------------------------------------------*/
    87 /** DMA malloc simulator
     85/** Physical mallocator simulator
    8886 *
    8987 * @param[in] addr Address of the place allocated by malloc32
    9088 */
    91 static inline void free32(void *addr)
    92         { free(addr); }
     89static inline void free32(void *addr) {
     90        if (!addr)
     91                return;
     92        free(addr);
     93}
    9394/*----------------------------------------------------------------------------*/
    9495/** Create 4KB page mapping
     
    9899static inline void * get_page(void)
    99100{
    100         void *address = as_area_create((void *) -1, UHCI_REQUIRED_PAGE_SIZE,
    101             AS_AREA_READ | AS_AREA_WRITE);
    102         if (address == (void *) -1)
     101        void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
     102        if (free_address == 0)
    103103                return NULL;
    104        
     104        void *address = as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
     105                  AS_AREA_READ | AS_AREA_WRITE);
     106        if (address != free_address)
     107                return NULL;
    105108        return address;
    106109}
Note: See TracChangeset for help on using the changeset viewer.