Changes in uspace/drv/uhci-hcd/utils/malloc32.h [17ceb72:5d5f971] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/utils/malloc32.h
r17ceb72 r5d5f971 43 43 #define UHCI_REQUIRED_PAGE_SIZE 4096 44 44 45 /** Get physical address translation46 *47 * @param[in] addr Virtual address to translate48 * @return Physical address if exists, NULL otherwise.49 */50 45 static inline uintptr_t addr_to_phys(void *addr) 51 46 { … … 53 48 int ret = as_get_physical_mapping(addr, &result); 54 49 55 if (ret != EOK) 56 return 0; 50 assert(ret == 0); 57 51 return (result | ((uintptr_t)addr & 0xfff)); 58 52 } 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 */ 53 65 54 static inline void * malloc32(size_t size) 66 55 { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); } 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) 56 57 static inline void * get_page() 80 58 { 81 59 void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 82 60 assert(free_address); 83 61 if (free_address == 0) 84 return NULL;62 return 0; 85 63 void* ret = 86 64 as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 87 65 AS_AREA_READ | AS_AREA_WRITE); 88 66 if (ret != free_address) 89 return NULL;67 return 0; 90 68 return ret; 91 69 } 70 71 static inline void free32(void *addr) 72 { if (addr) free(addr); } 92 73 93 74 #endif
Note:
See TracChangeset
for help on using the changeset viewer.