Add serial init function example to use coreboot early serial funcions Add selection which cpuid or msr functions to use (coreboot's or serialice's) Addapt for coreboot
Signed-off-by: Tadas Slotkus devtadas@gmail.com --- src/arch/x86/SerialICE/io.h | 8 +++--- src/arch/x86/SerialICE/serial.c | 23 ++++++++++++--------- src/arch/x86/SerialICE/serialice.c | 39 ++++++++++++++++++++++++----------- 3 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/src/arch/x86/SerialICE/io.h b/src/arch/x86/SerialICE/io.h index a47feef..efc0fe6 100644 --- a/src/arch/x86/SerialICE/io.h +++ b/src/arch/x86/SerialICE/io.h @@ -21,7 +21,7 @@ #define IO_H
/* Memory functions */ - +#if 0 static inline u8 read8(unsigned long addr) { return *((volatile u8 *)(addr)); @@ -125,8 +125,8 @@ static inline u32 inl(u16 port) /* MSR functions */
typedef struct { u32 lo, hi; } msr_t; - -static inline msr_t rdmsr(u32 index, u32 key) +#endif +static inline msr_t _rdmsr(u32 index, u32 key) { msr_t result; __asm__ __volatile__ ( @@ -137,7 +137,7 @@ static inline msr_t rdmsr(u32 index, u32 key) return result; }
-static inline void wrmsr(u32 index, msr_t msr, u32 key) +static inline void _wrmsr(u32 index, msr_t msr, u32 key) { __asm__ __volatile__ ( "wrmsr" diff --git a/src/arch/x86/SerialICE/serial.c b/src/arch/x86/SerialICE/serial.c index 9aaecb6..1181aff 100644 --- a/src/arch/x86/SerialICE/serial.c +++ b/src/arch/x86/SerialICE/serial.c @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+#if 0 /* Data */ #define UART_RBR 0x00 #define UART_TBR 0x00 @@ -34,22 +35,23 @@ #define UART_LSR 0x05 #define UART_MSR 0x06 #define UART_SCR 0x07 - +#endif /* SIO functions */
+/* Early serial includes and defines */ +#include <device/pnp_def.h> +#include <superio/winbond/w83977tf/early_serial.c> +#define SERIAL_DEV PNP_DEV(0x3f0, W83977TF_SP1) +#include <console/console.h> + +#define sio_putc __console_tx_byte +#define sio_getc __console_rx_byte static void sio_init(void) { - int divisor = 115200 / SIO_SPEED; - int lcs = 3; - outb(0x00, SIO_PORT + UART_IER); - outb(0x01, SIO_PORT + UART_FCR); - outb(0x03, SIO_PORT + UART_MCR); - outb(0x80 | lcs, SIO_PORT + UART_LCR); - outb(divisor & 0xff, SIO_PORT + UART_DLL); - outb((divisor >> 8) & 0xff, SIO_PORT + UART_DLM); - outb(lcs, SIO_PORT + UART_LCR); + w83977tf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); }
+#if 0 static void sio_putc(u8 data) { while (!(inb(SIO_PORT + UART_LSR) & 0x20)) ; @@ -69,6 +71,7 @@ static u8 sio_getc(void) #endif return val; } +#endif
/* SIO helpers */
diff --git a/src/arch/x86/SerialICE/serialice.c b/src/arch/x86/SerialICE/serialice.c index 35531dc..a503cb9 100644 --- a/src/arch/x86/SerialICE/serialice.c +++ b/src/arch/x86/SerialICE/serialice.c @@ -18,15 +18,27 @@ */
#include <types.h> -#include <serialice.h> -#include <io.h> + +//#define use_coreboot_stuff 1 +#ifdef use_coreboot_stuff +#include <arch/cpu.h> +#include <cpu/x86/msr.h> +#define _rdmsr(addr, key) rdmsr(addr) +#define _wrmsr(addr, msr, key) wrmsr(addr, msr) +#define cpuid_eax(eax, ecx) cpuid_eax(eax) +#define cpuid_ebx(eax, ecx) cpuid_ebx(eax) +#define cpuid_ecx(eax, ecx) cpuid_ecx(eax) +#define cpuid_edx(eax, ecx) cpuid_edx(eax) +#else +#include "io.h" +#endif
/* SIO functions */ #include "serial.c"
/* Hardware specific functions */
-#include "chipset.c" +//#include "chipset.c"
/* Accessor functions */
@@ -123,7 +135,7 @@ static void serialice_read_msr(void)
sio_putc('\r'); sio_putc('\n');
- msr = rdmsr(addr, key); + msr = _rdmsr(addr, key); sio_put32(msr.hi); sio_putc('.'); sio_put32(msr.lo); @@ -146,7 +158,7 @@ static void serialice_write_msr(void)
#ifdef __ROMCC__ /* Cheat to avoid register outage */ - wrmsr(addr, msr, 0x9c5a203a); + _wrmsr(addr, msr, 0x9c5a203a); #else wrmsr(addr, msr, key); #endif @@ -191,21 +203,22 @@ static void serialice_mainboard(void) sio_putc('\r'); sio_putc('\n');
/* must be defined in mainboard/<boardname>.c */ - sio_putstring(boardname); +// sio_putstring(boardname); }
static void serialice_version(void) { - sio_putstring("\nSerialICE v" VERSION " (" __DATE__ ")\n"); +// sio_putstring("\nSerialICE v" VERSION " (" __DATE__ ")\n"); }
-int main(void) +int serialice_main(void) { - chipset_init(); +// chipset_init();
sio_init(); + console_init(); +// serialice_version();
- serialice_version();
while(1) { u16 c; @@ -246,12 +259,14 @@ int main(void) case (('v' << 8)|'i'): // Read version info *vi serialice_version(); break; + case (('q' << 8)|'i'): // quit *qi + goto quits; + break; default: sio_putstring("ERROR\n"); break; } } - - // Never get here: +quits: return 0; }