summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-07-31 15:57:59 +0800
committersakumisu <[email protected]>2022-07-31 18:40:45 +0800
commitb835c9ccd206907b77a5462286da147cdc95ab33 (patch)
treedb5e0dff3f28060bcc161d97ce98881b16bd76f0 /common
parent7dd7285e3af2ab7855c2e4b96a1687a65cfad7e8 (diff)
add nocache ram config when enable dcache
Diffstat (limited to 'common')
-rw-r--r--common/usb_mem.h31
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