Add support to run SMM handler in TSEG instead of ASEG
[coreboot.git] / src / cpu / x86 / smm / smiutil.c
index 1baaecf2a1c2224d844b8fd65d9c0a9631f3d1ea..9cd63edc3921813720fccd52f64598ed9bae751d 100644 (file)
 
 #include <arch/io.h>
 #include <arch/romcc_io.h>
-#include <console/console.h>
 #include <cpu/x86/cache.h>
 #include <cpu/x86/smm.h>
+#include <console/console.h>
+#include <console/vtxprintf.h>
 
-/* ********************* smi_util ************************* */
-
-/* Data */
-#define UART_RBR 0x00
-#define UART_TBR 0x00
-
-/* Control */
-#define UART_IER 0x01
-#define UART_IIR 0x02
-#define UART_FCR 0x02
-#define UART_LCR 0x03
-#define UART_MCR 0x04
-#define UART_DLL 0x00
-#define UART_DLM 0x01
-
-/* Status */
-#define UART_LSR 0x05
-#define UART_MSR 0x06
-#define UART_SCR 0x07
-
-#ifndef CONFIG_TTYS0_BASE
-#define CONFIG_TTYS0_BASE 0x3f8
-#endif
-
-#ifndef CONFIG_TTYS0_BAUD
-#define CONFIG_TTYS0_BAUD 115200
-#endif
-
-#ifndef CONFIG_TTYS0_DIV
-#define CONFIG_TTYS0_DIV       (115200/CONFIG_TTYS0_BAUD)
-#endif
-
-/* Line Control Settings */
-#ifndef CONFIG_TTYS0_LCS
-/* Set 8bit, 1 stop bit, no parity */
-#define CONFIG_TTYS0_LCS       0x3
+#if CONFIG_CONSOLE_SERIAL8250MEM
+static u32 serial8250mem_base_address = 0;
 #endif
 
-#define UART_LCS       CONFIG_TTYS0_LCS
-
-static int uart_can_tx_byte(void)
-{
-       return inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x20;
-}
-
-static void uart_wait_to_tx_byte(void)
-{
-       while(!uart_can_tx_byte()) 
-       ;
-}
-
-static void uart_wait_until_sent(void)
-{
-       while(!(inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x40))
-       ; 
-}
-
-static void uart_tx_byte(unsigned char data)
-{
-       uart_wait_to_tx_byte();
-       outb(data, CONFIG_TTYS0_BASE + UART_TBR);
-       /* Make certain the data clears the fifos */
-       uart_wait_until_sent();
-}
-
 void console_tx_flush(void)
 {
-       uart_wait_to_tx_byte();
+       // the tx_byte functions take care of the flush.
+       // if not, this should be implemented.
 }
 
 void console_tx_byte(unsigned char byte)
 {
        if (byte == '\n')
-               uart_tx_byte('\r');
-       uart_tx_byte(byte);
-}
+               console_tx_byte('\r');
 
-void uart_init(void)
-{
-       /* disable interrupts */
-       outb(0x0, CONFIG_TTYS0_BASE + UART_IER);
-       /* enable fifo's */
-       outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
-       /* Set Baud Rate Divisor to 12 ==> 115200 Baud */
-       outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
-       outb(CONFIG_TTYS0_DIV & 0xFF,   CONFIG_TTYS0_BASE + UART_DLL);
-       outb((CONFIG_TTYS0_DIV >> 8) & 0xFF,    CONFIG_TTYS0_BASE + UART_DLM);
-       outb(UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
+#if CONFIG_CONSOLE_SERIAL8250MEM
+       if (serial8250mem_base_address)
+               uart8250_mem_tx_byte(serial8250mem_base_address, byte);
+#endif
+#if CONFIG_CONSOLE_SERIAL8250
+       uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
+#endif
+#if CONFIG_USBDEBUG
+       usbdebug_tx_byte(byte);
+#endif
+#if CONFIG_CONSOLE_NE2K
+       ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
+#endif
 }
 
 void console_init(void)
 {
 #if CONFIG_DEBUG_SMI
        console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
+#if CONFIG_CONSOLE_SERIAL8250
        uart_init();
+#endif
+#if CONFIG_CONSOLE_SERIAL8250MEM
+       serial8250mem_base_address = uart_mem_init();
+#endif
 #else
        console_loglevel = 1;
 #endif
 }
 
-/* ********************* smi_util ************************* */