diff options
| author | sakumisu <[email protected]> | 2022-07-31 15:57:59 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-07-31 18:40:45 +0800 |
| commit | b835c9ccd206907b77a5462286da147cdc95ab33 (patch) | |
| tree | db5e0dff3f28060bcc161d97ce98881b16bd76f0 /common | |
| parent | 7dd7285e3af2ab7855c2e4b96a1687a65cfad7e8 (diff) | |
add nocache ram config when enable dcache
Diffstat (limited to 'common')
| -rw-r--r-- | common/usb_mem.h | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/common/usb_mem.h b/common/usb_mem.h index 0771e552..db2e0369 100644 --- a/common/usb_mem.h +++ b/common/usb_mem.h @@ -23,23 +23,17 @@ #ifndef _USB_MEM_H #define _USB_MEM_H -#ifndef CONFIG_DCACHE_LINE_SIZE -#define CONFIG_DCACHE_LINE_SIZE 32 +#define usb_malloc(size) malloc(size) +#define usb_free(ptr) free(ptr) + +#ifndef CONFIG_USB_ALIGN_SIZE +#define CONFIG_USB_ALIGN_SIZE 4 #endif -#if defined(CONFIG_USB_DCACHE_ENABLE) -#define USB_NOCACHE_RAM_SECTION __attribute__((section(".nocache_ram"))) -#define USB_MEM_ALIGN32 __attribute__((aligned(CONFIG_DCACHE_LINE_SIZE))) -#elif defined(CONFIG_USB_ALIGN32) +#ifndef USB_NOCACHE_RAM_SECTION #define USB_NOCACHE_RAM_SECTION -#define USB_MEM_ALIGN32 __attribute__((aligned(32))) -#else -#define USB_NOCACHE_RAM_SECTION -#define USB_MEM_ALIGN32 #endif - -#define usb_malloc(size) malloc(size) -#define usb_free(ptr) free(ptr) +#define USB_MEM_ALIGNX __attribute__((aligned(CONFIG_USB_ALIGN_SIZE))) #ifdef CONFIG_USB_DCACHE_ENABLE static inline void *usb_iomalloc(size_t size) @@ -48,7 +42,7 @@ static inline void *usb_iomalloc(size_t size) void *align_ptr; int uintptr_size; size_t align_size; - uint32_t align = CONFIG_DCACHE_LINE_SIZE; + uint32_t align = CONFIG_USB_ALIGN_SIZE; /* sizeof pointer */ uintptr_size = sizeof(void *); @@ -85,9 +79,18 @@ static inline void usb_iofree(void *ptr) real_ptr = (void *)*(unsigned long *)((unsigned long)ptr - sizeof(void *)); usb_free(real_ptr); } + +void usb_dcache_clean(uintptr_t addr, uint32_t len); +void usb_dcache_invalidate(uintptr_t addr, uint32_t len); +void usb_dcache_clean_invalidate(uintptr_t addr, uint32_t len); #else #define usb_iomalloc(size) usb_malloc(size) #define usb_iofree(ptr) usb_free(ptr) + +#define usb_dcache_clean(addr, len) +#define usb_dcache_invalidate(addr, len) +#define usb_dcache_clean_invalidate(addr, len) + #endif #endif |
