Changeset 72af8da in mainline for uspace/drv/uhci-hcd/utils/malloc32.h
- Timestamp:
- 2011-03-16T18:50:17Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/utils/malloc32.h
r3e7b7cd r72af8da 35 35 #define DRV_UHCI_TRANSLATOR_H 36 36 37 #include <usb/usbmem.h>38 39 37 #include <assert.h> 40 38 #include <malloc.h> … … 45 43 #define UHCI_REQUIRED_PAGE_SIZE 4096 46 44 45 /** Get physical address translation 46 * 47 * @param[in] addr Virtual address to translate 48 * @return Physical address if exists, NULL otherwise. 49 */ 47 50 static inline uintptr_t addr_to_phys(void *addr) 48 51 { … … 50 53 int ret = as_get_physical_mapping(addr, &result); 51 54 52 assert(ret == 0); 55 if (ret != EOK) 56 return 0; 53 57 return (result | ((uintptr_t)addr & 0xfff)); 54 58 } 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 */ 56 65 static inline void * malloc32(size_t size) 57 66 { 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 */ 72 static 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 */ 79 static inline void * get_page(void) 60 80 { 61 81 void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 62 82 assert(free_address); 63 83 if (free_address == 0) 64 return 0;84 return NULL; 65 85 void* ret = 66 86 as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 67 87 AS_AREA_READ | AS_AREA_WRITE); 68 88 if (ret != free_address) 69 return 0;89 return NULL; 70 90 return ret; 71 91 } 72 73 static inline void free32(void *addr)74 { if (addr) free(addr); }75 92 76 93 #endif
Note:
See TracChangeset
for help on using the changeset viewer.