Changeset b4b534ac in mainline for uspace/lib/usbhost/include/usb/host/utils/malloc32.h
- Timestamp:
- 2016-07-22T08:24:47Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f76d2c2
- Parents:
- 5b18137 (diff), 8351f9a4 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/utils/malloc32.h
r5b18137 rb4b534ac 1 1 /* 2 * Copyright (c) 201 0Jan Vesely2 * Copyright (c) 2013 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusb ohci28 /** @addtogroup drvusbehci 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief OHCI driver32 * @brief EHCI driver 33 33 */ 34 #ifndef DRV_ OHCI_UTILS_MALLOC32_H35 #define DRV_ OHCI_UTILS_MALLOC32_H34 #ifndef DRV_EHCI_UTILS_MALLOC32_H 35 #define DRV_EHCI_UTILS_MALLOC32_H 36 36 37 #include <a ssert.h>38 #include < malloc.h>39 #include < unistd.h>37 #include <align.h> 38 #include <as.h> 39 #include <ddi.h> 40 40 #include <errno.h> 41 #include < mem.h>42 #include < as.h>41 #include <stdlib.h> 42 #include <sys/types.h> 43 43 44 44 /* Generic TDs and EDs require 16byte alignment, … … 46 46 * buffers do not have to be aligned. 47 47 */ 48 #define OHCI_ALIGN 32 48 #define EHCI_ALIGN 32 49 50 #define EHCI_REQUIRED_PAGE_SIZE 4096 49 51 50 52 /** Get physical address translation … … 70 72 */ 71 73 static inline void * malloc32(size_t size) 72 { return memalign(OHCI_ALIGN, size); } 74 { 75 uintptr_t phys; 76 void *address = AS_AREA_ANY; 77 size_t real_size = ALIGN_UP(size, PAGE_SIZE); 78 79 const int ret = dmamem_map_anonymous(real_size, 80 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys, 81 &address); 82 83 if (ret == EOK) { 84 /* Poison, accessing it should be enough to make sure 85 * the location is mapped, but poison works better */ 86 memset(address, 0x5, real_size); 87 return address; 88 } 89 return NULL; 90 } 73 91 74 92 /** Physical mallocator simulator … … 77 95 */ 78 96 static inline void free32(void *addr) 79 { free(addr); } 97 { 98 dmamem_unmap_anonymous(addr); 99 } 100 101 /** Create 4KB page mapping 102 * 103 * @return Address of the mapped page, NULL on failure. 104 */ 105 static inline void *get_page() 106 { 107 return malloc32(PAGE_SIZE); 108 } 109 110 static inline void return_page(void *page) 111 { 112 free32(page); 113 } 114 115 80 116 #endif 81 117 /**
Note:
See TracChangeset
for help on using the changeset viewer.