usbdebug: Move ehci_debug_info allocation
Move ehci_debug_info allocation from console to lib, as console code was only built for ramstage. Implement dbgp_ehci_info() to return the EHCI context. Alread alias this as dbgp_console_input() and _output() to return the console stream context later on. Change-Id: Id6cc07d62953f0466df61eeb159e22b0e3287d4e Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/3625 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@google.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
committed by
Stefan Reinauer
parent
4d409b5fc2
commit
9e7806a788
@ -48,7 +48,7 @@ void console_tx_byte(unsigned char byte)
|
|||||||
uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
|
uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_USBDEBUG
|
#if CONFIG_USBDEBUG
|
||||||
usbdebug_tx_byte(0, byte);
|
usbdebug_tx_byte(dbgp_console_output(), byte);
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_CONSOLE_NE2K
|
#if CONFIG_CONSOLE_NE2K
|
||||||
ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
|
ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
|
||||||
@ -73,7 +73,7 @@ void console_tx_flush(void)
|
|||||||
ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
|
ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_USBDEBUG
|
#if CONFIG_USBDEBUG
|
||||||
usbdebug_tx_flush(0);
|
usbdebug_tx_flush(dbgp_console_output());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +105,7 @@ void console_init(void)
|
|||||||
!defined(__BOOT_BLOCK__) && CONFIG_EARLY_CONSOLE
|
!defined(__BOOT_BLOCK__) && CONFIG_EARLY_CONSOLE
|
||||||
|
|
||||||
#if CONFIG_USBDEBUG
|
#if CONFIG_USBDEBUG
|
||||||
enable_usbdebug(CONFIG_USBDEBUG_DEFAULT_PORT);
|
usbdebug_init();
|
||||||
early_usbdebug_init();
|
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_CONSOLE_SERIAL
|
#if CONFIG_CONSOLE_SERIAL
|
||||||
uart_init();
|
uart_init();
|
||||||
|
@ -24,27 +24,28 @@
|
|||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <pc80/mc146818rtc.h>
|
#include <pc80/mc146818rtc.h>
|
||||||
|
|
||||||
static struct ehci_debug_info dbg_info;
|
|
||||||
static struct device_operations *ehci_drv_ops;
|
static struct device_operations *ehci_drv_ops;
|
||||||
static struct device_operations ehci_dbg_ops;
|
static struct device_operations ehci_dbg_ops;
|
||||||
|
|
||||||
static void usbdebug_re_enable(unsigned ehci_base)
|
static void usbdebug_re_enable(unsigned ehci_base)
|
||||||
{
|
{
|
||||||
|
struct ehci_debug_info *dbg_info = dbgp_ehci_info();
|
||||||
unsigned diff;
|
unsigned diff;
|
||||||
|
|
||||||
if (!dbg_info.ehci_debug)
|
if (!dbg_info->ehci_debug)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
diff = (unsigned)dbg_info.ehci_caps - ehci_base;
|
diff = (unsigned)dbg_info->ehci_caps - ehci_base;
|
||||||
dbg_info.ehci_regs -= diff;
|
dbg_info->ehci_regs -= diff;
|
||||||
dbg_info.ehci_debug -= diff;
|
dbg_info->ehci_debug -= diff;
|
||||||
dbg_info.ehci_caps = (void*)ehci_base;
|
dbg_info->ehci_caps = (void*)ehci_base;
|
||||||
dbg_info.status |= DBGP_EP_ENABLED;
|
dbg_info->status |= DBGP_EP_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usbdebug_disable(void)
|
static void usbdebug_disable(void)
|
||||||
{
|
{
|
||||||
dbg_info.status &= ~DBGP_EP_ENABLED;
|
struct ehci_debug_info *dbg_info = dbgp_ehci_info();
|
||||||
|
dbg_info->status &= ~DBGP_EP_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_ehci_set_resources(struct device *dev)
|
static void pci_ehci_set_resources(struct device *dev)
|
||||||
@ -82,35 +83,32 @@ void pci_ehci_read_resources(struct device *dev)
|
|||||||
|
|
||||||
static void dbgp_init(void)
|
static void dbgp_init(void)
|
||||||
{
|
{
|
||||||
#if !CONFIG_EARLY_CONSOLE
|
usbdebug_init();
|
||||||
enable_usbdebug(CONFIG_USBDEBUG_DEFAULT_PORT);
|
|
||||||
#endif
|
|
||||||
usbdebug_init(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, &dbg_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dbgp_tx_byte(unsigned char data)
|
static void dbgp_tx_byte(unsigned char data)
|
||||||
{
|
{
|
||||||
usbdebug_tx_byte(&dbg_info, data);
|
usbdebug_tx_byte(dbgp_console_output(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char dbgp_rx_byte(void)
|
static unsigned char dbgp_rx_byte(void)
|
||||||
{
|
{
|
||||||
unsigned char data = 0xff;
|
unsigned char data = 0xff;
|
||||||
|
|
||||||
if (dbgp_ep_is_active(&dbg_info))
|
if (dbgp_ep_is_active(dbgp_console_input()))
|
||||||
dbgp_bulk_read_x(&dbg_info, &data, 1);
|
dbgp_bulk_read_x(dbgp_console_input(), &data, 1);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dbgp_tx_flush(void)
|
static void dbgp_tx_flush(void)
|
||||||
{
|
{
|
||||||
usbdebug_tx_flush(&dbg_info);
|
usbdebug_tx_flush(dbgp_console_output());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dbgp_tst_byte(void)
|
static int dbgp_tst_byte(void)
|
||||||
{
|
{
|
||||||
return dbgp_ep_is_active(&dbgp_info);
|
return dbgp_ep_is_active(dbgp_console_input());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct console_driver usbdebug_direct_console __console = {
|
static const struct console_driver usbdebug_direct_console __console = {
|
||||||
|
@ -60,10 +60,12 @@ void enable_usbdebug(unsigned int port);
|
|||||||
int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size);
|
int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size);
|
||||||
int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size);
|
int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size);
|
||||||
void set_debug_port(unsigned port);
|
void set_debug_port(unsigned port);
|
||||||
int early_usbdebug_init(void);
|
|
||||||
|
|
||||||
|
int usbdebug_init(void);
|
||||||
|
struct ehci_debug_info *dbgp_ehci_info(void);
|
||||||
|
#define dbgp_console_output dbgp_ehci_info
|
||||||
|
#define dbgp_console_input dbgp_ehci_info
|
||||||
int dbgp_ep_is_active(struct ehci_debug_info *dbg_info);
|
int dbgp_ep_is_active(struct ehci_debug_info *dbg_info);
|
||||||
void usbdebug_tx_byte(struct ehci_debug_info *info, unsigned char data);
|
void usbdebug_tx_byte(struct ehci_debug_info *info, unsigned char data);
|
||||||
void usbdebug_tx_flush(struct ehci_debug_info *info);
|
void usbdebug_tx_flush(struct ehci_debug_info *info);
|
||||||
int usbdebug_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info);
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -86,6 +86,10 @@
|
|||||||
#define DBGP_MAX_PACKET 8
|
#define DBGP_MAX_PACKET 8
|
||||||
#define DBGP_LOOPS 1000
|
#define DBGP_LOOPS 1000
|
||||||
|
|
||||||
|
#if !defined(__PRE_RAM__) && !defined(__SMM__)
|
||||||
|
static struct ehci_debug_info glob_dbg_info;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
|
static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
|
||||||
{
|
{
|
||||||
u32 ctrl;
|
u32 ctrl;
|
||||||
@ -361,8 +365,7 @@ static int ehci_wait_for_port(struct ehci_regs *ehci_regs, int port)
|
|||||||
return -1; //-ENOTCONN;
|
return -1; //-ENOTCONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usbdebug_init_(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info)
|
||||||
int usbdebug_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info)
|
|
||||||
{
|
{
|
||||||
struct ehci_caps *ehci_caps;
|
struct ehci_caps *ehci_caps;
|
||||||
struct ehci_regs *ehci_regs;
|
struct ehci_regs *ehci_regs;
|
||||||
@ -574,22 +577,8 @@ next_debug_port:
|
|||||||
return -10;
|
return -10;
|
||||||
}
|
}
|
||||||
|
|
||||||
int early_usbdebug_init(void)
|
|
||||||
{
|
|
||||||
struct ehci_debug_info *dbg_info = (struct ehci_debug_info *)
|
|
||||||
(CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
|
|
||||||
|
|
||||||
return usbdebug_init(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, dbg_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data)
|
void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data)
|
||||||
{
|
{
|
||||||
if (!dbg_info) {
|
|
||||||
/* "Find" dbg_info structure in Cache */
|
|
||||||
dbg_info = (struct ehci_debug_info *)
|
|
||||||
(CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbgp_is_ep_active(dbg_info)) {
|
if (dbgp_is_ep_active(dbg_info)) {
|
||||||
dbg_info->buf[dbg_info->bufidx++] = data;
|
dbg_info->buf[dbg_info->bufidx++] = data;
|
||||||
if (dbg_info->bufidx >= 8) {
|
if (dbg_info->bufidx >= 8) {
|
||||||
@ -601,12 +590,6 @@ void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data)
|
|||||||
|
|
||||||
void usbdebug_tx_flush(struct ehci_debug_info *dbg_info)
|
void usbdebug_tx_flush(struct ehci_debug_info *dbg_info)
|
||||||
{
|
{
|
||||||
if (!dbg_info) {
|
|
||||||
/* "Find" dbg_info structure in Cache */
|
|
||||||
dbg_info = (struct ehci_debug_info *)
|
|
||||||
(CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbgp_is_ep_active(dbg_info) && dbg_info->bufidx > 0) {
|
if (dbgp_is_ep_active(dbg_info) && dbg_info->bufidx > 0) {
|
||||||
dbgp_bulk_write_x(dbg_info, dbg_info->buf, dbg_info->bufidx);
|
dbgp_bulk_write_x(dbg_info, dbg_info->buf, dbg_info->bufidx);
|
||||||
dbg_info->bufidx = 0;
|
dbg_info->bufidx = 0;
|
||||||
@ -617,3 +600,23 @@ int dbgp_ep_is_active(struct ehci_debug_info *dbg_info)
|
|||||||
{
|
{
|
||||||
return (dbg_info->status & DBGP_EP_STATMASK) == (DBGP_EP_VALID | DBGP_EP_ENABLED);
|
return (dbg_info->status & DBGP_EP_STATMASK) == (DBGP_EP_VALID | DBGP_EP_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ehci_debug_info *dbgp_ehci_info(void)
|
||||||
|
{
|
||||||
|
#if __PRE_RAM__
|
||||||
|
/* "Find" dbg_info structure in Cache */
|
||||||
|
return (struct ehci_debug_info *)
|
||||||
|
(CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
|
||||||
|
#else
|
||||||
|
return &glob_dbg_info;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int usbdebug_init(void)
|
||||||
|
{
|
||||||
|
struct ehci_debug_info *dbg_info = dbgp_ehci_info();
|
||||||
|
#if defined(__PRE_RAM__) || !CONFIG_EARLY_CONSOLE
|
||||||
|
enable_usbdebug(CONFIG_USBDEBUG_DEFAULT_PORT);
|
||||||
|
#endif
|
||||||
|
return usbdebug_init_(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, dbg_info);
|
||||||
|
}
|
||||||
|
@ -278,7 +278,7 @@ void sdram_initialize(struct pei_data *pei_data)
|
|||||||
|
|
||||||
#if CONFIG_USBDEBUG
|
#if CONFIG_USBDEBUG
|
||||||
/* mrc.bin reconfigures USB, so reinit it to have debug */
|
/* mrc.bin reconfigures USB, so reinit it to have debug */
|
||||||
early_usbdebug_init();
|
usbdebug_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For reference print the System Agent version
|
/* For reference print the System Agent version
|
||||||
|
Reference in New Issue
Block a user