Rename almost all occurences of LinuxBIOS to coreboot.
[coreboot.git] / src / console / usbdebug_direct_console.c
1 #include <console/console.h>
2 #include <usbdebug_direct.h>
3 #include <pc80/mc146818rtc.h>
4
5 struct ehci_debug_info dbg_info;
6
7 void set_ehci_base(unsigned ehci_base)
8 {
9         unsigned diff;
10         if(!dbg_info.ehci_debug) return;
11         diff = dbg_info.ehci_caps - ehci_base;
12         dbg_info.ehci_regs -= diff;
13         dbg_info.ehci_debug -= diff;
14         dbg_info.ehci_caps = ehci_base;
15 }
16 void set_ehci_debug(unsigned ehci_debug)
17 {
18         dbg_info.ehci_debug = ehci_debug;
19 }
20
21 unsigned get_ehci_debug(void)
22 {
23        return dbg_info.ehci_debug;
24 }
25
26 static void dbgp_init(void)
27 {
28         struct ehci_debug_info *dbg_infox;
29         dbg_infox = (struct ehci_debug_info *)((CONFIG_LB_MEM_TOPK<<10) - sizeof (struct ehci_debug_info)); //in RAM
30         memcpy(&dbg_info, dbg_infox, sizeof(struct ehci_debug_info) );
31 }
32
33 static void dbgp_tx_byte(unsigned char data) 
34 {
35         if(dbg_info.ehci_debug) 
36                 dbgp_bulk_write_x(&dbg_info,&data,1);
37 }
38
39 static unsigned char dbgp_rx_byte(void) 
40 {
41         unsigned char data = 0xff;
42         if(dbg_info.ehci_debug) 
43                 dbgp_bulk_read_x(&dbg_info,&data,1);
44         return data;
45 }
46
47 static int dbgp_tst_byte(void) 
48 {
49         return dbg_info.ehci_debug;
50 }
51
52 static const struct console_driver usbdebug_direct_console __console = {
53         .init    = dbgp_init,
54         .tx_byte = dbgp_tx_byte,
55         .rx_byte = dbgp_rx_byte,
56         .tst_byte = dbgp_tst_byte,
57 };
58