mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
* add config options for serial port and speed
* add license header to console/vtxprintf.c and arch/x86/serial.c * clean out dead code from console/vtxprintf.c * adapt arch/x86/serial.c to CONFIG_ stuff * actually include config.h in CFLAGS Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@104 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
afeb4e0b90
commit
b19bf330cf
6 changed files with 134 additions and 126 deletions
2
Makefile
2
Makefile
|
@ -60,6 +60,8 @@ Q := @
|
||||||
|
|
||||||
CPPFLAGS := $(LINUXBIOSINCLUDE)
|
CPPFLAGS := $(LINUXBIOSINCLUDE)
|
||||||
|
|
||||||
|
CFLAGS += $(LINUXBIOSINCLUDE)
|
||||||
|
|
||||||
export src obj KERNELVERSION
|
export src obj KERNELVERSION
|
||||||
|
|
||||||
ifeq ($(strip $(have_dotconfig)),)
|
ifeq ($(strip $(have_dotconfig)),)
|
||||||
|
|
|
@ -61,10 +61,17 @@ static void enable_rom(void)
|
||||||
void stage1_main(u32 bist)
|
void stage1_main(u32 bist)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct mem_file archive;
|
struct mem_file archive, result;
|
||||||
int elfboot_mem(struct lb_memory *mem, void *where, int size);
|
int elfboot_mem(struct lb_memory *mem, void *where, int size);
|
||||||
/* HACK -- fake memory table for now */
|
/* HACK -- fake memory table for now */
|
||||||
struct lb_memory mem = {LB_TAG_MEMORY, 1, .map = { {0, 32*1024*1024, LB_MEM_RAM}}};
|
struct lb_memory mem = {
|
||||||
|
.tag = LB_TAG_MEMORY,
|
||||||
|
.size = 1,
|
||||||
|
.map = {
|
||||||
|
{ .start = 0, .size = (32*1024*1024), .type = LB_MEM_RAM}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct mem_file result;
|
struct mem_file result;
|
||||||
|
|
||||||
post_code(0x02);
|
post_code(0x02);
|
||||||
|
|
|
@ -1,110 +1,82 @@
|
||||||
|
/*
|
||||||
|
* serial.c -- uart init function
|
||||||
|
*
|
||||||
|
* Copright (C) 2007 coresystems GmbH <stepan@coresystems.de>
|
||||||
|
* Copright (C) 2007 Ronald G. Minnich <rminnich@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
#include <fallback.h>
|
|
||||||
|
|
||||||
/* Base Address */
|
/* Base Address */
|
||||||
#ifndef TTYS0_BASE
|
#if defined(CONFIG_CONSOLE_SERIAL_COM1)
|
||||||
#define TTYS0_BASE 0x3f8
|
#define TTYSx_BASE 0x3f8
|
||||||
|
#elif defined(CONFIG_CONSOLE_SERIAL_COM2)
|
||||||
|
#define TTYSx_BASE 0x2f8
|
||||||
|
#else
|
||||||
|
#define TTYSx_BASE 0x3f8
|
||||||
|
#warning no serial port set
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TTYS0_BAUD
|
#if defined(CONFIG_CONSOLE_SERIAL_115200)
|
||||||
#define TTYS0_BAUD 115200
|
#define TTYSx_BAUD 115200
|
||||||
|
#elif defined(CONFIG_CONSOLE_SERIAL_57600)
|
||||||
|
#define TTYSx_BAUD 57600
|
||||||
|
#elif defined(CONFIG_CONSOLE_SERIAL_38400)
|
||||||
|
#define TTYSx_BAUD 38400
|
||||||
|
#elif defined(CONFIG_CONSOLE_SERIAL_19200)
|
||||||
|
#define TTYSx_BAUD 19200
|
||||||
|
#elif defined(CONFIG_CONSOLE_SERIAL_9600)
|
||||||
|
#define TTYSx_BAUD 9600
|
||||||
|
#else // default
|
||||||
|
#define TTYSx_BAUD 115200
|
||||||
|
#warning no serial speed set
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((115200%TTYS0_BAUD) != 0)
|
#if ((115200%TTYSx_BAUD) != 0)
|
||||||
#error Bad ttys0 baud rate
|
#error Bad ttys0 baud rate
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TTYS0_DIV (115200/TTYS0_BAUD)
|
#define TTYSx_DIV (115200/TTYSx_BAUD)
|
||||||
|
|
||||||
/* Line Control Settings */
|
/* Line Control Settings */
|
||||||
#ifndef TTYS0_LCS
|
#ifndef TTYSx_LCS
|
||||||
/* Set 8bit, 1 stop bit, no parity */
|
/* Set 8bit, 1 stop bit, no parity */
|
||||||
#define TTYS0_LCS 0x3
|
#define TTYSx_LCS 0x3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UART_LCS TTYS0_LCS
|
#define UART_LCS TTYSx_LCS
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_USE_INIT == 0
|
void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs);
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
static int uart_can_tx_byte(void)
|
|
||||||
{
|
|
||||||
return inb(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(TTYS0_BASE + UART_LSR) & 0x40))
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void uart_tx_byte(unsigned char data)
|
|
||||||
{
|
|
||||||
uart_wait_to_tx_byte();
|
|
||||||
outb(data, TTYS0_BASE + UART_TBR);
|
|
||||||
/* Make certain the data clears the fifos */
|
|
||||||
uart_wait_until_sent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void uart_init(void)
|
void uart_init(void)
|
||||||
{
|
{
|
||||||
/* disable interrupts */
|
unsigned ttysx_div;
|
||||||
outb(0x0, TTYS0_BASE + UART_IER);
|
#if 0
|
||||||
/* enable fifo's */
|
unsigned ttysx_index;
|
||||||
outb(0x01, TTYS0_BASE + UART_FCR);
|
|
||||||
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
|
|
||||||
outb(0x80 | UART_LCS, TTYS0_BASE + UART_LCR);
|
|
||||||
#if USE_OPTION_TABLE == 1
|
|
||||||
static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
|
|
||||||
unsigned ttys0_div, ttys0_index;
|
|
||||||
ttys0_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);
|
|
||||||
ttys0_index &= 7;
|
|
||||||
ttys0_div = divisor[ttys0_index];
|
|
||||||
outb(ttys0_div & 0xff, TTYS0_BASE + UART_DLL);
|
|
||||||
outb(0, TTYS0_BASE + UART_DLM);
|
|
||||||
#else
|
|
||||||
outb(TTYS0_DIV & 0xFF, TTYS0_BASE + UART_DLL);
|
|
||||||
outb((TTYS0_DIV >> 8) & 0xFF, TTYS0_BASE + UART_DLM);
|
|
||||||
#endif
|
|
||||||
outb(UART_LCS, TTYS0_BASE + UART_LCR);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
extern void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs);
|
|
||||||
void uart_init(void)
|
|
||||||
{
|
|
||||||
#if USE_OPTION_TABLE == 1
|
|
||||||
static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
|
static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
|
||||||
unsigned ttys0_div, ttys0_index;
|
|
||||||
ttys0_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);
|
// read CMOS settings?
|
||||||
ttys0_index &= 7;
|
ttysx_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);
|
||||||
ttys0_div = divisor[ttys0_index];
|
ttysx_index &= 7;
|
||||||
uart8250_init(TTYS0_BASE, ttys0_div, UART_LCS);
|
ttysx_div = divisor[ttysx_index];
|
||||||
#else
|
#else
|
||||||
uart8250_init(TTYS0_BASE, TTYS0_DIV, UART_LCS);
|
ttysx_div = TTYSx_DIV;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
uart8250_init(TTYSx_BASE, ttysx_div, UART_LCS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,55 @@ config CONSOLE_SERIAL
|
||||||
---help---
|
---help---
|
||||||
Send LinuxBIOS output to serial console
|
Send LinuxBIOS output to serial console
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Serial console COM port"
|
||||||
|
default CONSOLE_SERIAL_COM1
|
||||||
|
depends CONSOLE_SERIAL
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_COM1
|
||||||
|
bool "COM1/ttyS0"
|
||||||
|
---help---
|
||||||
|
Serial console on COM1.
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_COM2
|
||||||
|
bool "COM2/ttyS1"
|
||||||
|
---help---
|
||||||
|
Serial console on COM2.
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Serial console speed"
|
||||||
|
default CONSOLE_SERIAL_115200
|
||||||
|
depends CONSOLE_SERIAL
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_115200
|
||||||
|
bool "115200 bps"
|
||||||
|
---help---
|
||||||
|
Set speed to 115200 bps.
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_57600
|
||||||
|
bool "57600 bps"
|
||||||
|
---help---
|
||||||
|
Set speed to 57600 bps.
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_38400
|
||||||
|
bool "38400 bps"
|
||||||
|
---help---
|
||||||
|
Set speed to 38400 bps.
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_19200
|
||||||
|
bool "19200 bps"
|
||||||
|
---help---
|
||||||
|
Set speed to 19200 bps.
|
||||||
|
|
||||||
|
config CONSOLE_SERIAL_9600
|
||||||
|
bool "9600 bps"
|
||||||
|
---help---
|
||||||
|
Set speed to 9600 bps.
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
|
||||||
config CONSOLE_VGA
|
config CONSOLE_VGA
|
||||||
boolean "Support VGA console"
|
boolean "Support VGA console"
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
/* vtxprintf.c, from
|
/* vtxprintf.c, from
|
||||||
* linux/lib/vsprintf.c
|
* linux/lib/vsprintf.c
|
||||||
*
|
*
|
||||||
|
@ -6,47 +21,12 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <div64.h>
|
#include <div64.h>
|
||||||
|
|
||||||
/* haha, don't need ctype.c */
|
|
||||||
#define isdigit(c) ((c) >= '0' && (c) <= '9')
|
#define isdigit(c) ((c) >= '0' && (c) <= '9')
|
||||||
#define is_digit isdigit
|
#define is_digit isdigit
|
||||||
#define isxdigit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
#define isxdigit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
||||||
|
|
||||||
static unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
|
|
||||||
{
|
|
||||||
unsigned long result = 0,value;
|
|
||||||
|
|
||||||
if (!base) {
|
|
||||||
base = 10;
|
|
||||||
if (*cp == '0') {
|
|
||||||
base = 8;
|
|
||||||
cp++;
|
|
||||||
if ((*cp == 'x') && isxdigit(cp[1])) {
|
|
||||||
cp++;
|
|
||||||
base = 16;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
|
|
||||||
? toupper(*cp) : *cp)-'A'+10) < base) {
|
|
||||||
result = result*base + value;
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
if (endp)
|
|
||||||
*endp = (char *)cp;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static long simple_strtol(const char *cp,char **endp,unsigned int base)
|
|
||||||
{
|
|
||||||
if(*cp=='-')
|
|
||||||
return -simple_strtoul(cp+1,endp,base);
|
|
||||||
return simple_strtoul(cp,endp,base);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int skip_atoi(const char **s)
|
static int skip_atoi(const char **s)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* mem -- simple routines that have no optimizations for anything
|
* mem -- simple routines that have no optimizations for anything
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* Copright (C) 2007 Ronald G. Minnich <rminnich@gmail.com>
|
* Copright (C) 2007 Ronald G. Minnich <rminnich@gmail.com>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; version 2 of the License.
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
|
Loading…
Add table
Reference in a new issue