diff --git a/Makefile b/Makefile index fdaafd80d8..747e06dba0 100644 --- a/Makefile +++ b/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... " diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 7fa6b80cce..b5e75231d8 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -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 + + diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1de46dcca0..3d961ffd02 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -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 diff --git a/arch/x86/cachemain.c b/arch/x86/cachemain.c index bc8467382d..6981bb553c 100644 --- a/arch/x86/cachemain.c +++ b/arch/x86/cachemain.c @@ -23,7 +23,6 @@ #include #include #include -#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 diff --git a/arch/x86/config.h b/arch/x86/config.h deleted file mode 100644 index 104e532cad..0000000000 --- a/arch/x86/config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of the LinuxBIOS project. - * - * Copyright (C) 2007 Stefan Reinauer - * - * 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 diff --git a/arch/x86/console.c b/arch/x86/console.c index e945add45e..81c7710d3b 100644 --- a/arch/x86/console.c +++ b/arch/x86/console.c @@ -1,24 +1,12 @@ #include #include #include -#include "config.h" +#include // FIXME: we need this for varargs #include -#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, ...) diff --git a/arch/x86/serial.c b/arch/x86/serial.c index d3eb1d3e0b..05f291dfc5 100644 --- a/arch/x86/serial.c +++ b/arch/x86/serial.c @@ -21,47 +21,7 @@ */ #include - -/* 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 void uart_init(void) { diff --git a/include/uart8250.h b/include/uart8250.h index 00bd902565..e7e21594b1 100644 --- a/include/uart8250.h +++ b/include/uart8250.h @@ -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 */ diff --git a/lib/uart8250.c b/lib/uart8250.c index 9eca833be2..92c928422b 100644 --- a/lib/uart8250.c +++ b/lib/uart8250.c @@ -1,7 +1,6 @@ /* Should support 8250, 16450, 16550, 16550A type uarts */ #include #include -#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); -} diff --git a/util/dtc/Makefile b/util/dtc/Makefile index 34dfb3fe46..55046d674f 100644 --- a/util/dtc/Makefile +++ b/util/dtc/Makefile @@ -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) diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile new file mode 100755 index 0000000000..563e264c7d --- /dev/null +++ b/util/xcompile/xcompile @@ -0,0 +1,49 @@ +#!/bin/sh +# +# This file is part of the LinuxBIOS project. +# +# Copyright (C) 2007 coresystems GmbH +# Written by Stefan Reinauer 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 +