Changes in uspace/drv/uhci-hcd/utils/malloc32.h [fb2de0a:23f40280] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/utils/malloc32.h
rfb2de0a r23f40280 41 41 #include <as.h> 42 42 43 #include "slab.h" 44 43 45 #define UHCI_STRCUTURES_ALIGNMENT 16 44 46 #define UHCI_REQUIRED_PAGE_SIZE 4096 … … 57 59 uintptr_t result; 58 60 const int ret = as_get_physical_mapping(addr, &result); 61 assert(ret == EOK); 62 59 63 if (ret != EOK) 60 64 return 0; … … 68 72 */ 69 73 static inline void * malloc32(size_t size) { 70 /* This works only when the host has less than 4GB of memory as 71 * physical address needs to fit into 32 bits */ 72 73 /* If we need more than one page there is no guarantee that the 74 * memory will be continuous */ 75 if (size > PAGE_SIZE) 76 return NULL; 77 /* Calculate alignment to make sure the block won't cross page 78 * boundary */ 79 size_t alignment = UHCI_STRCUTURES_ALIGNMENT; 80 while (alignment < size) 81 alignment *= 2; 82 return memalign(alignment, size); 74 if (size <= SLAB_ELEMENT_SIZE) 75 return slab_malloc_g(); 76 assert(false); 77 return memalign(UHCI_STRCUTURES_ALIGNMENT, size); 83 78 } 84 79 /*----------------------------------------------------------------------------*/ … … 90 85 if (!addr) 91 86 return; 87 if (slab_in_range_g(addr)) 88 return slab_free_g(addr); 92 89 free(addr); 93 90 } … … 100 97 { 101 98 void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 99 assert(free_address); /* TODO: remove this assert */ 102 100 if (free_address == 0) 103 101 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.