From c399be3ea2af9438b28ba32ed7549b8b7020b47d Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Wed, 22 Jan 2025 17:46:10 +0800 Subject: [PATCH] feat(common): add usb_phyaddr2ramaddr & usb_ramaddr2phyaddr macro Signed-off-by: sakumisu <1203593632@qq.com> --- cherryusb_config_template.h | 8 ++++++++ common/usb_util.h | 8 ++++++++ port/ehci/usb_hc_ehci.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h index 395f9016..3a38e994 100644 --- a/cherryusb_config_template.h +++ b/cherryusb_config_template.h @@ -292,4 +292,12 @@ // #define usb_dcache_flush(addr, size) #endif +#ifndef usb_phyaddr2ramaddr +#define usb_phyaddr2ramaddr(addr) (addr) +#endif + +#ifndef usb_ramaddr2phyaddr +#define usb_ramaddr2phyaddr(addr) (addr) +#endif + #endif diff --git a/common/usb_util.h b/common/usb_util.h index 624cd9fc..b2223b2b 100644 --- a/common/usb_util.h +++ b/common/usb_util.h @@ -207,4 +207,12 @@ #define USB_ALIGN_UP(size, align) (((size) + (align)-1) & ~((align)-1)) +#ifndef usb_phyaddr2ramaddr +#define usb_phyaddr2ramaddr(addr) (addr) +#endif + +#ifndef usb_ramaddr2phyaddr +#define usb_ramaddr2phyaddr(addr) (addr) +#endif + #endif /* USB_UTIL_H */ diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c index 2269746a..b40d60d5 100644 --- a/port/ehci/usb_hc_ehci.c +++ b/port/ehci/usb_hc_ehci.c @@ -281,7 +281,7 @@ static void ehci_qtd_fill(struct ehci_qtd_hw *qtd, uint32_t bufaddr, size_t bufl qtd->hw.token = token; - ehci_qtd_bpl_fill(qtd, bufaddr, buflen); + ehci_qtd_bpl_fill(qtd, usb_phyaddr2ramaddr(bufaddr), buflen); qtd->dir_in = ((token & QTD_TOKEN_PID_MASK) == QTD_TOKEN_PID_IN) ? true : false; qtd->bufaddr = bufaddr; qtd->length = buflen;