coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ehci_debug.c File Reference
#include <stdint.h>
#include <console/console.h>
#include <console/usb.h>
#include <arch/io.h>
#include <device/mmio.h>
#include <arch/symbols.h>
#include <string.h>
#include <cbmem.h>
#include "ehci_debug.h"
#include "usb_ch9.h"
#include "ehci.h"
Include dependency graph for ehci_debug.c:

Go to the source code of this file.

Data Structures

struct  ehci_debug_info
 

Macros

#define dprintk(LEVEL, args...)   do {} while (0)
 
#define DBGP_LEN_UPDATE(x, len)   (((x) & ~0x0f) | ((len) & 0x0f))
 
#define DBGP_CLAIM   (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
 
#define HUB_ROOT_RESET_TIME   50 /* times are in msec */
 
#define HUB_SHORT_RESET_TIME   10
 
#define HUB_LONG_RESET_TIME   200
 
#define HUB_RESET_TIMEOUT   500
 
#define DBGP_MICROFRAME_TIMEOUT_LOOPS   1000
 
#define DBGP_MICROFRAME_RETRIES   10
 
#define DBGP_MAX_PACKET   8
 

Functions

static int dbgp_enabled (void)
 
static void dbgp_print_data (struct ehci_dbg_port *ehci_debug)
 
static struct ehci_debug_infodbgp_ehci_info (void)
 
static int dbgp_wait_until_complete (struct ehci_dbg_port *ehci_debug)
 
static void dbgp_breath (void)
 
static int dbgp_wait_until_done (struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, unsigned int ctrl, const int timeout)
 
static void dbgp_set_data (struct ehci_dbg_port *ehci_debug, const void *buf, int size)
 
static void dbgp_get_data (struct ehci_dbg_port *ehci_debug, void *buf, int size)
 
static int dbgp_bulk_write (struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, const char *bytes, int size)
 
int dbgp_bulk_write_x (struct dbgp_pipe *pipe, const char *bytes, int size)
 
static int dbgp_bulk_read (struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, void *data, int size)
 
int dbgp_bulk_read_x (struct dbgp_pipe *pipe, void *data, int size)
 
void dbgp_mdelay (int ms)
 
int dbgp_control_msg (struct ehci_dbg_port *ehci_debug, unsigned int devnum, int requesttype, int request, int value, int index, void *data, int size)
 
static int ehci_reset_port (struct ehci_regs *ehci_regs, int port)
 
static int ehci_wait_for_port (struct ehci_regs *ehci_regs, int port)
 
static int usbdebug_init_ (uintptr_t ehci_bar, unsigned int offset, struct ehci_debug_info *info)
 
static int dbgp_not_present (void)
 
int dbgp_try_get (struct dbgp_pipe *pipe)
 
void dbgp_put (struct dbgp_pipe *pipe)
 
int usbdebug_hw_init (bool force)
 
static void migrate_ehci_debug (int is_recovery)
 
 ROMSTAGE_CBMEM_INIT_HOOK (migrate_ehci_debug)
 
 POSTCAR_CBMEM_INIT_HOOK (migrate_ehci_debug)
 
 RAMSTAGE_CBMEM_INIT_HOOK (migrate_ehci_debug)
 
int dbgp_ep_is_active (struct dbgp_pipe *pipe)
 
struct dbgp_pipedbgp_console_output (void)
 
struct dbgp_pipedbgp_console_input (void)
 
void usbdebug_init (void)
 

Variables

struct ehci_debug_info __packed
 
static struct ehci_debug_info glob_dbg_info
 
static struct ehci_debug_infoglob_dbg_info_p
 

Macro Definition Documentation

◆ DBGP_CLAIM

#define DBGP_CLAIM   (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)

Definition at line 36 of file ehci_debug.c.

◆ DBGP_LEN_UPDATE

#define DBGP_LEN_UPDATE (   x,
  len 
)    (((x) & ~0x0f) | ((len) & 0x0f))

Definition at line 34 of file ehci_debug.c.

◆ DBGP_MAX_PACKET

#define DBGP_MAX_PACKET   8

Definition at line 45 of file ehci_debug.c.

◆ DBGP_MICROFRAME_RETRIES

#define DBGP_MICROFRAME_RETRIES   10

Definition at line 44 of file ehci_debug.c.

◆ DBGP_MICROFRAME_TIMEOUT_LOOPS

#define DBGP_MICROFRAME_TIMEOUT_LOOPS   1000

Definition at line 43 of file ehci_debug.c.

◆ dprintk

#define dprintk (   LEVEL,
  args... 
)    do {} while (0)

Definition at line 31 of file ehci_debug.c.

◆ HUB_LONG_RESET_TIME

#define HUB_LONG_RESET_TIME   200

Definition at line 40 of file ehci_debug.c.

◆ HUB_RESET_TIMEOUT

#define HUB_RESET_TIMEOUT   500

Definition at line 41 of file ehci_debug.c.

◆ HUB_ROOT_RESET_TIME

#define HUB_ROOT_RESET_TIME   50 /* times are in msec */

Definition at line 38 of file ehci_debug.c.

◆ HUB_SHORT_RESET_TIME

#define HUB_SHORT_RESET_TIME   10

Definition at line 39 of file ehci_debug.c.

Function Documentation

◆ dbgp_breath()

static void dbgp_breath ( void  )
static

Definition at line 94 of file ehci_debug.c.

Referenced by dbgp_wait_until_done().

Here is the caller graph for this function:

◆ dbgp_bulk_read()

static int dbgp_bulk_read ( struct ehci_dbg_port ehci_debug,
struct dbgp_pipe pipe,
void data,
int  size 
)
static

Definition at line 257 of file ehci_debug.c.

References addr, ehci_dbg_port::address, ehci_dbg_port::control, DBGP_EPADDR, dbgp_get_data(), DBGP_LEN_UPDATE, DBGP_MAX_PACKET, DBGP_OUT, DBGP_PID_SET, dbgp_wait_until_done(), ehci_dbg_port::pids, read32(), USB_PID_IN, and write32().

Referenced by dbgp_bulk_read_x(), and dbgp_control_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_bulk_read_x()

int dbgp_bulk_read_x ( struct dbgp_pipe pipe,
void data,
int  size 
)

Definition at line 285 of file ehci_debug.c.

References dbgp_bulk_read(), dbgp_ehci_info(), and ehci_debug_info::ehci_debug.

Referenced by usbdebug_rx_byte().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_bulk_write()

static int dbgp_bulk_write ( struct ehci_dbg_port ehci_debug,
struct dbgp_pipe pipe,
const char *  bytes,
int  size 
)
static

Definition at line 224 of file ehci_debug.c.

References addr, DBGP_EPADDR, DBGP_LEN_UPDATE, DBGP_MAX_PACKET, DBGP_OUT, DBGP_PID_SET, dbgp_set_data(), dbgp_wait_until_done(), ehci_debug_info::ehci_debug, read32(), USB_PID_OUT, and write32().

Referenced by dbgp_bulk_write_x(), and dbgp_control_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_bulk_write_x()

int dbgp_bulk_write_x ( struct dbgp_pipe pipe,
const char *  bytes,
int  size 
)

Definition at line 249 of file ehci_debug.c.

References dbgp_bulk_write(), dbgp_ehci_info(), and ehci_debug_info::ehci_debug.

Referenced by probe_for_debug_descriptor(), probe_for_ftdi(), usbdebug_tx_byte(), and usbdebug_tx_flush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_console_input()

struct dbgp_pipe* dbgp_console_input ( void  )

Definition at line 724 of file ehci_debug.c.

References DBGP_CONSOLE_EPIN, dbgp_ehci_info(), and ehci_debug_info::ep_pipe.

Referenced by usb_can_rx_byte(), and usb_rx_byte().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_console_output()

struct dbgp_pipe* dbgp_console_output ( void  )

Definition at line 719 of file ehci_debug.c.

References DBGP_CONSOLE_EPOUT, dbgp_ehci_info(), and ehci_debug_info::ep_pipe.

Referenced by usb_tx_byte(), and usb_tx_flush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_control_msg()

◆ dbgp_ehci_info()

static struct ehci_debug_info* dbgp_ehci_info ( void  )
inlinestatic

◆ dbgp_enabled()

static int dbgp_enabled ( void  )
static

Definition at line 603 of file ehci_debug.c.

References dbgp_ehci_info(), DBGP_EP_ENABLED, DBGP_SETUP_EP0, ehci_debug_info::ep_pipe, and dbgp_pipe::status.

Referenced by dbgp_print_data(), and usbdebug_hw_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_ep_is_active()

int dbgp_ep_is_active ( struct dbgp_pipe pipe)

Definition at line 714 of file ehci_debug.c.

References DBGP_EP_ENABLED, DBGP_EP_STATMASK, and DBGP_EP_VALID.

Referenced by dbgp_try_get(), and usb_can_rx_byte().

Here is the caller graph for this function:

◆ dbgp_get_data()

static void dbgp_get_data ( struct ehci_dbg_port ehci_debug,
void buf,
int  size 
)
static

Definition at line 186 of file ehci_debug.c.

References buf, ehci_debug_info::ehci_debug, and read32().

Referenced by dbgp_bulk_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_mdelay()

void dbgp_mdelay ( int  ms)

Definition at line 293 of file ehci_debug.c.

References inb().

Referenced by dbgp_hub_enable(), ehci_reset_port(), ehci_wait_for_port(), and usbdebug_init_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_not_present()

static int dbgp_not_present ( void  )
static

Definition at line 609 of file ehci_debug.c.

References dbgp_ehci_info(), DBGP_EP_NOT_PRESENT, DBGP_SETUP_EP0, ehci_debug_info::ep_pipe, and dbgp_pipe::status.

Referenced by usbdebug_hw_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_print_data()

static void dbgp_print_data ( struct ehci_dbg_port ehci_debug)
static

Definition at line 200 of file ehci_debug.c.

References BIOS_SPEW, CONFIG, dbgp_enabled(), DBGP_LEN, dprintk, ehci_debug_info::ehci_debug, and read32().

Referenced by dbgp_wait_until_done().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_put()

void dbgp_put ( struct dbgp_pipe pipe)

Definition at line 625 of file ehci_debug.c.

References dbgp_ehci_info(), DBGP_EP_BUSY, DBGP_SETUP_EP0, ehci_debug_info::ep_pipe, and dbgp_pipe::status.

Referenced by usbdebug_rx_byte(), usbdebug_tx_byte(), and usbdebug_tx_flush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_set_data()

static void dbgp_set_data ( struct ehci_dbg_port ehci_debug,
const void buf,
int  size 
)
static

Definition at line 171 of file ehci_debug.c.

References buf, ehci_debug_info::ehci_debug, and write32().

Referenced by dbgp_bulk_write(), and dbgp_control_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_try_get()

int dbgp_try_get ( struct dbgp_pipe pipe)

Definition at line 615 of file ehci_debug.c.

References dbgp_ehci_info(), DBGP_EP_BUSY, dbgp_ep_is_active(), DBGP_SETUP_EP0, ehci_debug_info::ep_pipe, and dbgp_pipe::status.

Referenced by usbdebug_rx_byte(), usbdebug_tx_byte(), and usbdebug_tx_flush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_wait_until_complete()

static int dbgp_wait_until_complete ( struct ehci_dbg_port ehci_debug)
static

Definition at line 70 of file ehci_debug.c.

References BIOS_ERR, DBGP_DONE, DBGP_ERR_SIGNAL, DBGP_ERRCODE, DBGP_ERROR, DBGP_LEN, DBGP_MICROFRAME_TIMEOUT_LOOPS, dprintk, ehci_debug_info::ehci_debug, read32(), and write32().

Referenced by dbgp_wait_until_done().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbgp_wait_until_done()

static int dbgp_wait_until_done ( struct ehci_dbg_port ehci_debug,
struct dbgp_pipe pipe,
unsigned int  ctrl,
const int  timeout 
)
static

◆ ehci_reset_port()

static int ehci_reset_port ( struct ehci_regs ehci_regs,
int  port 
)
static

Definition at line 369 of file ehci_debug.c.

References dbgp_mdelay(), HUB_ROOT_RESET_TIME, PORT_CONNECT, PORT_CSC, PORT_PE, PORT_RESET, PORT_RWC_BITS, ehci_regs::port_status, read32(), and write32().

Referenced by ehci_wait_for_port().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ehci_wait_for_port()

static int ehci_wait_for_port ( struct ehci_regs ehci_regs,
int  port 
)
static

Definition at line 407 of file ehci_debug.c.

References dbgp_mdelay(), ehci_reset_port(), read32(), ehci_regs::status, and STS_PCD.

Referenced by usbdebug_init_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ migrate_ehci_debug()

static void migrate_ehci_debug ( int  is_recovery)
static

Definition at line 679 of file ehci_debug.c.

References BIOS_DEBUG, cbmem_add(), cbmem_find(), CBMEM_ID_EHCI_DEBUG, CONFIG, dbgp_ehci_info(), ENV_ROMSTAGE, ENV_STRING, glob_dbg_info_p, memcpy(), NULL, printk, and usbdebug_hw_init().

Here is the call graph for this function:

◆ POSTCAR_CBMEM_INIT_HOOK()

POSTCAR_CBMEM_INIT_HOOK ( migrate_ehci_debug  )

◆ RAMSTAGE_CBMEM_INIT_HOOK()

RAMSTAGE_CBMEM_INIT_HOOK ( migrate_ehci_debug  )

◆ ROMSTAGE_CBMEM_INIT_HOOK()

ROMSTAGE_CBMEM_INIT_HOOK ( migrate_ehci_debug  )

◆ usbdebug_hw_init()

int usbdebug_hw_init ( bool  force)

Definition at line 658 of file ehci_debug.c.

References dbgp_ehci_info(), dbgp_enabled(), dbgp_not_present(), ehci_debug_info::ehci_base, ehci_debug_hw_enable(), ENV_POSTCAR, and usbdebug_init_().

Referenced by migrate_ehci_debug(), sdram_initialize(), and usbdebug_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usbdebug_init()

void usbdebug_init ( void  )

Definition at line 729 of file ehci_debug.c.

References CONFIG, ENV_BOOTBLOCK, ENV_RAMSTAGE, ENV_ROMSTAGE, and usbdebug_hw_init().

Here is the call graph for this function:

◆ usbdebug_init_()

Variable Documentation

◆ __packed

◆ glob_dbg_info

struct ehci_debug_info glob_dbg_info
static

Definition at line 48 of file ehci_debug.c.

Referenced by dbgp_ehci_info().

◆ glob_dbg_info_p

struct ehci_debug_info* glob_dbg_info_p
static

Definition at line 51 of file ehci_debug.c.

Referenced by dbgp_ehci_info(), and migrate_ehci_debug().