From 45ad4f041bcf69f7988d87ae390977c10203b1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Thu, 31 Jan 2019 19:24:04 +0200 Subject: usbdebug: Use fixed size field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The structure is placed inside CBMEM, one should use types with fixed size. Seems we prefer to prepare for 64-bit builds even for MMIO pointers. Change-Id: I60382664a53650b225abc1f77c87ed4e121d429e Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/31182 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- src/drivers/usb/ehci_debug.c | 31 ++++++++++++++++++------------- src/drivers/usb/ehci_debug.h | 4 ++-- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c index c5fb984d54..0cb89ceb21 100644 --- a/src/drivers/usb/ehci_debug.c +++ b/src/drivers/usb/ehci_debug.c @@ -28,11 +28,11 @@ #include "ehci.h" struct ehci_debug_info { - void *ehci_base; - void *ehci_debug; + u64 ehci_base; + u64 ehci_debug; struct dbgp_pipe ep_pipe[DBGP_MAX_ENDPOINTS]; -}; +} __packed; #if IS_ENABLED(CONFIG_DEBUG_CONSOLE_INIT) /* When selected, you can debug the connection of usbdebug dongle. @@ -263,7 +263,9 @@ static int dbgp_bulk_write(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *p int dbgp_bulk_write_x(struct dbgp_pipe *pipe, const char *bytes, int size) { struct ehci_debug_info *dbg_info = dbgp_ehci_info(); - return dbgp_bulk_write(dbg_info->ehci_debug, pipe, bytes, size); + struct ehci_dbg_port *port; + port = (void *)(uintptr_t)dbg_info->ehci_debug; + return dbgp_bulk_write(port, pipe, bytes, size); } static int dbgp_bulk_read(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, @@ -297,7 +299,9 @@ static int dbgp_bulk_read(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pi int dbgp_bulk_read_x(struct dbgp_pipe *pipe, void *data, int size) { struct ehci_debug_info *dbg_info = dbgp_ehci_info(); - return dbgp_bulk_read(dbg_info->ehci_debug, pipe, data, size); + struct ehci_dbg_port *port; + port = (void *)(uintptr_t)dbg_info->ehci_debug; + return dbgp_bulk_read(port, pipe, data, size); } void dbgp_mdelay(int ms) @@ -447,8 +451,8 @@ static int usbdebug_init_(unsigned ehci_bar, unsigned offset, struct ehci_debug_ /* Keep all endpoints disabled before any printk() call. */ memset(info, 0, sizeof (*info)); - info->ehci_base = (void *)ehci_bar; - info->ehci_debug = (void *)(ehci_bar + offset); + info->ehci_base = ehci_bar; + info->ehci_debug = ehci_bar + offset; info->ep_pipe[0].status |= DBGP_EP_NOT_PRESENT; dprintk(BIOS_INFO, "ehci_bar: 0x%x debug_offset 0x%x\n", ehci_bar, offset); @@ -457,7 +461,7 @@ static int usbdebug_init_(unsigned ehci_bar, unsigned offset, struct ehci_debug_ ehci_regs = (struct ehci_regs *)(ehci_bar + HC_LENGTH(read32(&ehci_caps->hc_capbase))); - struct ehci_dbg_port *ehci_debug = info->ehci_debug; + struct ehci_dbg_port *ehci_debug = (void *)(uintptr_t)info->ehci_debug; if (CONFIG_USBDEBUG_DEFAULT_PORT > 0) ehci_debug_select_port(CONFIG_USBDEBUG_DEFAULT_PORT); @@ -582,7 +586,8 @@ try_next_port: dbgp_mdelay(100); - ret = dbgp_probe_gadget(info->ehci_debug, &info->ep_pipe[0]); + struct ehci_dbg_port *port = (void *)(uintptr_t)info->ehci_debug; + ret = dbgp_probe_gadget(port, &info->ep_pipe[0]); if (ret < 0) { dprintk(BIOS_INFO, "Could not probe gadget on debug port.\n"); ret = -6; @@ -654,12 +659,12 @@ void dbgp_put(struct dbgp_pipe *pipe) void usbdebug_re_enable(unsigned ehci_base) { struct ehci_debug_info *dbg_info = dbgp_ehci_info(); - unsigned diff; + u64 diff; int i; - diff = (unsigned)dbg_info->ehci_base - ehci_base; + diff = dbg_info->ehci_base - ehci_base; dbg_info->ehci_debug -= diff; - dbg_info->ehci_base = (void *)ehci_base; + dbg_info->ehci_base = ehci_base; for (i=0; iep_pipe[i].status & DBGP_EP_VALID) @@ -679,7 +684,7 @@ void usbdebug_disable(void) int usbdebug_hw_init(bool force) { struct ehci_debug_info *dbg_info = dbgp_ehci_info(); - unsigned int ehci_base, dbg_offset; + u32 ehci_base, dbg_offset; if (dbgp_enabled() && !force) return 0; diff --git a/src/drivers/usb/ehci_debug.h b/src/drivers/usb/ehci_debug.h index efb27666bc..0ac94bfe6f 100644 --- a/src/drivers/usb/ehci_debug.h +++ b/src/drivers/usb/ehci_debug.h @@ -47,12 +47,12 @@ struct dbgp_pipe u8 endpoint; u8 pid; u8 status; - int timeout; + u16 timeout; u8 bufidx; u8 buflen; char buf[8]; -}; +} __packed; void dbgp_put(struct dbgp_pipe *pipe); int dbgp_try_get(struct dbgp_pipe *pipe); -- cgit v1.2.3