Changeset 17ceb72 in mainline for uspace/drv/uhci-hcd/utils/malloc32.h
- Timestamp:
- 2011-03-14T01:39:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6298d80
- Parents:
- 3bd96bb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/utils/malloc32.h
r3bd96bb r17ceb72 43 43 #define UHCI_REQUIRED_PAGE_SIZE 4096 44 44 45 /** Get physical address translation 46 * 47 * @param[in] addr Virtual address to translate 48 * @return Physical address if exists, NULL otherwise. 49 */ 45 50 static inline uintptr_t addr_to_phys(void *addr) 46 51 { … … 48 53 int ret = as_get_physical_mapping(addr, &result); 49 54 50 assert(ret == 0); 55 if (ret != EOK) 56 return 0; 51 57 return (result | ((uintptr_t)addr & 0xfff)); 52 58 } 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 */ 54 65 static inline void * malloc32(size_t size) 55 66 { 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 */ 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) 58 80 { 59 81 void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 60 82 assert(free_address); 61 83 if (free_address == 0) 62 return 0;84 return NULL; 63 85 void* ret = 64 86 as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 65 87 AS_AREA_READ | AS_AREA_WRITE); 66 88 if (ret != free_address) 67 return 0;89 return NULL; 68 90 return ret; 69 91 } 70 71 static inline void free32(void *addr)72 { if (addr) free(addr); }73 92 74 93 #endif
Note:
See TracChangeset
for help on using the changeset viewer.