summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2019-01-31 19:24:04 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2019-02-02 23:48:53 +0000
commit45ad4f041bcf69f7988d87ae390977c10203b1a8 (patch)
treebd1bbbe248edebece93d3d3c05ed07cd6aa41e30
parentf88208e0acbcb771fdbf5ef851eb6aec12ccc188 (diff)
downloadcoreboot-45ad4f041bcf69f7988d87ae390977c10203b1a8.tar.xz
usbdebug: Use fixed size field
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 <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/31182 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
-rw-r--r--src/arch/x86/car.ld2
-rw-r--r--src/drivers/usb/ehci_debug.c31
-rw-r--r--src/drivers/usb/ehci_debug.h4
3 files changed, 21 insertions, 16 deletions
diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld
index 1b0d996b8a..0d0d5852d0 100644
--- a/src/arch/x86/car.ld
+++ b/src/arch/x86/car.ld
@@ -68,7 +68,7 @@
#endif
_car_ehci_dbg_info_start = .;
/* Reserve sizeof(struct ehci_dbg_info). */
- . += 88;
+ . += 80;
_car_ehci_dbg_info_end = .;
/* _car_global_start and _car_global_end provide symbols to per-stage
* variables that are not shared like the timestamp and the pre-ram
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; i<DBGP_MAX_ENDPOINTS; i++)
if (dbg_info->ep_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);