Changeset 0ea8f83 in mainline for uspace/drv/audio/sb16/dma.h
- Timestamp:
- 2011-11-11T19:44:07Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d98d136
- Parents:
- 751d17a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dma.h
r751d17a2 r0ea8f83 65 65 * @return Address of the aligned and big enough memory place, NULL on failure. 66 66 */ 67 static inline void * malloc24(size_t size)67 static inline void *dma_create_buffer24(size_t size) 68 68 { 69 /* This works only reliably when the host has less than 16MB of memory 70 * as physical address needs to fit into 24 bits */ 71 72 /* If we need more than one page there is no guarantee that the 73 * memory will be continuous */ 74 if (size > PAGE_SIZE) 69 void *free_address = as_get_mappable_page(size); 70 if (free_address == 0) 75 71 return NULL; 76 return memalign(DMA_ALIGNENT, size); 72 void *address = 73 as_area_create(free_address, size, AS_AREA_READ | AS_AREA_WRITE); 74 if (address != free_address) 75 return NULL; 76 bzero(address, size); 77 return address; 77 78 } 78 79 /*----------------------------------------------------------------------------*/ 79 80 /** DMA mallocator simulator 80 81 * 81 * @param[in] addr Address of the place allocated by malloc2482 * @param[in] addr Address of the place allocated by dma_create_buffer24 82 83 */ 83 static inline void free24(void *addr) 84 { free(addr); } 84 static inline void dma_destroy_buffer(void *page) 85 { 86 if (page) 87 as_area_destroy(page); 88 } 89 85 90 86 91 #endif
Note:
See TracChangeset
for help on using the changeset viewer.