Add cross compilation support and simplify the far to complex serial
code (This goes hand in hand, as some parts of serial were hardcoded to one architecture until now) * include/uart8250.h: add TTYSx defines that are used in multiple places. formerly part of arch/x86/serial.c. Drop init_uart8250 (unused) * lib/uart8250.c: drop arch/x86/config.h usage Drop init_uart8250 (unused) * arch/powerpc/Kconfig, arch/x86/Kconfig: add CONFIG_ARCH to contain the directory name under LinuxBIOSv3/arch/ * arch/x86/console.c: drop some dead code. Drop hardcoded config.h values. use generic uart8250.h header * arch/x86/cachemain.c: Drop hardcoded config.h values. Still use hardcoded ROM size for now. (To be changed later) * arch/x86/config.h: dropped, no longer needed * arch/x86/serial.c: factor out generically used defines to uart8250.h * Makefile: use mainboard architecture instead of target architecture to choose include path. Read .xcompile if available (configure replacement). Create build.h with compile time and version. * util/xcompile/xcompile: new file. Search for supported cross compilers linkers, assemblers (and potentially supported compiler flags etc) This is a very slick configure replacement. * util/dtc/Makefile: fix Makefile for cross compilation Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@190 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
4dac3a3dc2
commit
ff7df4f7ad
11 changed files with 144 additions and 134 deletions
54
Makefile
54
Makefile
|
|
@ -24,24 +24,12 @@ VERSION = 3
|
|||
PATCHLEVEL = 0
|
||||
SUBLEVEL = 0
|
||||
|
||||
|
||||
ARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \
|
||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
|
||||
|
||||
KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
|
||||
|
||||
# TODO: Check whether this really works!
|
||||
ifdef $(CONFIG_LOCALVERSION)
|
||||
KERNELVERSION = "$(KERNELVERSION)-$(CONFIG_LOCALVERSION)"
|
||||
endif
|
||||
|
||||
have_dotconfig := $(wildcard .config)
|
||||
have_dotxcompile := $(wildcard .xcompile)
|
||||
|
||||
src:=$(shell pwd)
|
||||
obj:=$(shell pwd)/lbobj
|
||||
|
||||
export src obj
|
||||
|
||||
# Do not print "Entering directory ..."
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
|
@ -57,11 +45,6 @@ HOSTCXX := g++
|
|||
HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
|
||||
-Wno-unused -Wno-sign-compare -Wno-pointer-sign
|
||||
|
||||
LINUXBIOSINCLUDE := -I$(src) -Iinclude \
|
||||
-I$(src)/include \
|
||||
-I$(src)/include/cpu/generic/$(ARCH)/ \
|
||||
-include $(obj)/config.h
|
||||
|
||||
DOXYGEN := doxygen
|
||||
DOXYGEN_OUTPUT_DIR := doxygen
|
||||
|
||||
|
|
@ -70,11 +53,8 @@ ifneq ($(V),1)
|
|||
Q := @
|
||||
endif
|
||||
|
||||
CPPFLAGS := $(LINUXBIOSINCLUDE)
|
||||
|
||||
CFLAGS += $(LINUXBIOSINCLUDE)
|
||||
|
||||
export src obj KERNELVERSION
|
||||
KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
|
||||
export KERNELVERSION
|
||||
|
||||
ifeq ($(strip $(have_dotconfig)),)
|
||||
|
||||
|
|
@ -84,11 +64,34 @@ all:
|
|||
else
|
||||
|
||||
include $(src)/.config
|
||||
|
||||
ifneq ($(CONFIG_LOCALVERSION),)
|
||||
LINUXBIOS_EXTRA_VERSION := -$(shell echo $(CONFIG_LOCALVERSION))
|
||||
endif
|
||||
|
||||
all: prepare prepare2 $(obj)/linuxbios.rom
|
||||
$(Q)echo "Build process finished."
|
||||
|
||||
ARCH:=$(shell echo $(CONFIG_ARCH))
|
||||
MAINBOARDDIR=$(shell echo $(CONFIG_MAINBOARD_NAME))
|
||||
|
||||
LINUXBIOSINCLUDE := -I$(src) -Iinclude \
|
||||
-I$(src)/include \
|
||||
-I$(src)/include/cpu/generic/$(ARCH)/ \
|
||||
-include $(obj)/config.h \
|
||||
-include $(obj)/build.h
|
||||
|
||||
|
||||
ifneq ($(strip $(have_dotxcompile)),)
|
||||
include $(src)/.xcompile
|
||||
CC := $(CC_$(ARCH))
|
||||
AS := $(AS_$(ARCH))
|
||||
LD := $(LD_$(ARCH))
|
||||
endif
|
||||
|
||||
CPPFLAGS := $(LINUXBIOSINCLUDE)
|
||||
CFLAGS += $(LINUXBIOSINCLUDE)
|
||||
|
||||
include lib/Makefile
|
||||
include device/Makefile
|
||||
include console/Makefile
|
||||
|
|
@ -106,6 +109,9 @@ prepare:
|
|||
|
||||
prepare2:
|
||||
$(Q)cp $(src)/.tmpconfig.h $(obj)/config.h
|
||||
$(Q)echo "#define LINUXBIOS_VERSION \"$(KERNELVERSION)\"" > $(obj)/build.h
|
||||
$(Q)echo "#define LINUXBIOS_EXTRA_VERSION \"$(LINUXBIOS_EXTRA_VERSION)\"" >> $(obj)/build.h
|
||||
$(Q)echo "#define LINUXBIOS_BUILD \"`date`\"" >> $(obj)/build.h
|
||||
|
||||
clean:
|
||||
$(Q)echo -n "Cleaning up... "
|
||||
|
|
|
|||
|
|
@ -25,3 +25,11 @@ config ARCH_POWERPC
|
|||
This option is used to set the architecture of a mainboard.
|
||||
It is usually set in mainboard/*/Kconfig.
|
||||
|
||||
config ARCH
|
||||
string
|
||||
default powerpc
|
||||
depends ARCH_POWERPC
|
||||
help
|
||||
This is the arch directory name
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,13 @@ config ARCH_X86
|
|||
This option is used to set the architecture of a mainboard.
|
||||
It is usually set in mainboard/*/Kconfig.
|
||||
|
||||
config ARCH
|
||||
string
|
||||
default x86
|
||||
depends ARCH_X86
|
||||
help
|
||||
This is the arch directory name
|
||||
|
||||
config CAR_TYPE_I586
|
||||
boolean
|
||||
help
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include <console/loglevel.h>
|
||||
#include <lar.h>
|
||||
#include <linuxbios_tables.h>
|
||||
#include "config.h"
|
||||
|
||||
/* these prototypes should go into headers */
|
||||
void uart_init(void);
|
||||
|
|
@ -31,6 +30,9 @@ void console_init(void);
|
|||
void die(const char *msg);
|
||||
int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
|
||||
|
||||
// FIXME: This should go somewhere else (.config?)
|
||||
#define LINUXBIOS_ROMSIZE_KB 256
|
||||
|
||||
// Is this value correct?
|
||||
#define DCACHE_RAM_SIZE 0x8000
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This file is part of the LinuxBIOS project.
|
||||
*
|
||||
* Copyright (C) 2007 Stefan Reinauer <stepan@coresystems.de>
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* This config file is a place holder and will be created dynamically soon */
|
||||
|
||||
#define LINUXBIOS_VERSION "3.0.0"
|
||||
#define LINUXBIOS_BUILD "Fri Jan 19 15:24:28 CET 2007"
|
||||
|
||||
#define LINUXBIOS_ROMSIZE_KB 256
|
||||
|
||||
#define TTYS0_BASE 0x3f8
|
||||
|
|
@ -1,24 +1,12 @@
|
|||
#include <arch/types.h>
|
||||
#include <arch/hlt.h>
|
||||
#include <console/loglevel.h>
|
||||
#include "config.h"
|
||||
#include <uart8250.h>
|
||||
|
||||
// FIXME: we need this for varargs
|
||||
#include <stdarg.h>
|
||||
|
||||
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_DEBUG
|
||||
#define debug(msg_level, fmt, arg...) printk(msg_level, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef LINUXBIOS_EXTRA_VERSION
|
||||
#define LINUXBIOS_EXTRA_VERSION ""
|
||||
#endif
|
||||
|
||||
/* printk's without a loglevel use this.. */
|
||||
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
|
||||
|
||||
extern int vtxprintf(void (*)(unsigned char), const char *, va_list);
|
||||
extern void uart8250_tx_byte(unsigned, unsigned char);
|
||||
|
||||
int console_loglevel(void)
|
||||
{
|
||||
|
|
@ -28,8 +16,8 @@ int console_loglevel(void)
|
|||
void console_tx_byte(unsigned char byte)
|
||||
{
|
||||
if (byte == '\n')
|
||||
uart8250_tx_byte(TTYS0_BASE, '\r');
|
||||
uart8250_tx_byte(TTYS0_BASE, byte);
|
||||
uart8250_tx_byte(TTYSx_BASE, '\r');
|
||||
uart8250_tx_byte(TTYSx_BASE, byte);
|
||||
}
|
||||
|
||||
int printk(int msg_level, const char *fmt, ...)
|
||||
|
|
|
|||
|
|
@ -21,47 +21,7 @@
|
|||
*/
|
||||
|
||||
#include <arch/io.h>
|
||||
|
||||
/* Base Address */
|
||||
#if defined(CONFIG_CONSOLE_SERIAL_COM1)
|
||||
#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
|
||||
|
||||
#if defined(CONFIG_CONSOLE_SERIAL_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
|
||||
|
||||
#if ((115200%TTYSx_BAUD) != 0)
|
||||
#error Bad ttys0 baud rate
|
||||
#endif
|
||||
|
||||
#define TTYSx_DIV (115200/TTYSx_BAUD)
|
||||
|
||||
/* Line Control Settings */
|
||||
#ifndef TTYSx_LCS
|
||||
/* Set 8bit, 1 stop bit, no parity */
|
||||
#define TTYSx_LCS 0x3
|
||||
#endif
|
||||
|
||||
#define UART_LCS TTYSx_LCS
|
||||
|
||||
void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs);
|
||||
#include <uart8250.h>
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,15 +1,48 @@
|
|||
#ifndef UART8250_H
|
||||
#define UART8250_H
|
||||
|
||||
struct uart8250 {
|
||||
unsigned int baud;
|
||||
/* Do I need an lcs parameter here? */
|
||||
};
|
||||
/* Base Address */
|
||||
#if defined(CONFIG_CONSOLE_SERIAL_COM1)
|
||||
#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
|
||||
|
||||
#if defined(CONFIG_CONSOLE_SERIAL_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
|
||||
|
||||
#if ((115200%TTYSx_BAUD) != 0)
|
||||
#error Bad ttys0 baud rate
|
||||
#endif
|
||||
|
||||
#define TTYSx_DIV (115200/TTYSx_BAUD)
|
||||
|
||||
/* Line Control Settings */
|
||||
#ifndef TTYSx_LCS
|
||||
/* Set 8bit, 1 stop bit, no parity */
|
||||
#define TTYSx_LCS 0x3
|
||||
#endif
|
||||
|
||||
#define UART_LCS TTYSx_LCS
|
||||
|
||||
unsigned char uart8250_rx_byte(unsigned base_port);
|
||||
int uart8250_can_rx_byte(unsigned base_port);
|
||||
void uart8250_tx_byte(unsigned base_port, unsigned char data);
|
||||
void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs);
|
||||
void init_uart8250(unsigned base_port, struct uart8250 *uart);
|
||||
|
||||
#endif /* UART8250_H */
|
||||
#endif /* UART8250_H */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* Should support 8250, 16450, 16550, 16550A type uarts */
|
||||
#include <arch/io.h>
|
||||
#include <uart8250.h>
|
||||
#include "../arch/x86/config.h" // for ttyS0 base FIXME!
|
||||
|
||||
/* Data */
|
||||
#define UART_RBR 0x00
|
||||
|
|
@ -58,6 +57,7 @@ unsigned char uart8250_rx_byte(unsigned base_port)
|
|||
return inb(base_port + UART_RBR);
|
||||
}
|
||||
|
||||
/* Initialize a generic uart */
|
||||
void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs)
|
||||
{
|
||||
lcs &= 0x7f;
|
||||
|
|
@ -74,18 +74,3 @@ void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs)
|
|||
outb(lcs, base_port + UART_LCR);
|
||||
}
|
||||
|
||||
/* Initialize a generic uart */
|
||||
void init_uart8250(unsigned base_port, struct uart8250 *uart)
|
||||
{
|
||||
int divisor;
|
||||
int lcs;
|
||||
divisor = 115200/(uart->baud ? uart->baud: 1);
|
||||
lcs = 3;
|
||||
if (base_port == TTYS0_BASE) {
|
||||
/* Don't reinitialize the console serial port,
|
||||
* This is espeically nasty in SMP.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
uart8250_init(base_port, divisor, lcs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ DEPFILES = $(DTC_OBJS:.o=.d)
|
|||
|
||||
$(obj)/util/dtc/dtc: $(patsubst %,$(obj)/%,$(DTC_OBJS))
|
||||
$(Q)mkdir -p $(obj)/util/dtc/
|
||||
$(Q)$(LINK.c) -o $@ $^
|
||||
$(Q)$(HOSTCC) -o $@ $^
|
||||
|
||||
ftdump: ftdump.o
|
||||
$(Q)$(LINK.c) -o $@ $^
|
||||
$(Q)$(HOSTCC) -o $@ $^
|
||||
|
||||
$(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h $(obj)/dtc-parser.output: $(src)/util/dtc/dtc-parser.y
|
||||
$(Q)cd $(obj); $(BISON) -d $< &> $(obj)/dtc.bison.out
|
||||
|
|
@ -59,6 +59,6 @@ clean:
|
|||
endif
|
||||
|
||||
%.d: %.c
|
||||
$(CC) -MM -MG -MT "$*.o $@" $< > $@
|
||||
$(HOSTCC) -MM -MG -MT "$*.o $@" $< > $@
|
||||
|
||||
-include $(DEPFILES)
|
||||
|
|
|
|||
49
util/xcompile/xcompile
Executable file
49
util/xcompile/xcompile
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This file is part of the LinuxBIOS project.
|
||||
#
|
||||
# Copyright (C) 2007 coresystems GmbH
|
||||
# Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH.
|
||||
#
|
||||
# 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; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
ARCH=`uname -m | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \
|
||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/`
|
||||
|
||||
case "$ARCH" in
|
||||
"x86_64")
|
||||
echo "CC_x86 := \"gcc -m32\""
|
||||
echo "AS_x86 := \"as --32\""
|
||||
echo "LD_x86 := \"ld -b elf32-i386 -melf_i386\""
|
||||
;;
|
||||
"x86")
|
||||
echo "CC_x86 := \"gcc\""
|
||||
echo "AS_x86 := \"as\""
|
||||
echo "LD_x86 := \"ld\""
|
||||
;;
|
||||
*)
|
||||
# FIXME: This should be detected
|
||||
echo "CC_x86 := \"i386-linux-gcc\""
|
||||
echo "AS_x86 := \"i386-linux-as\""
|
||||
echo "LD_x86 := \"i386-linux-ld\""
|
||||
;;
|
||||
esac
|
||||
|
||||
# TODO: The same as above for powerpc, and other architectures
|
||||
# as soon as they are supported by LinuxBIOSv3
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue