From ef81173a39663641d2574b9c89e097d679fb24ff Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 23 Feb 2007 09:20:15 +0000 Subject: [PATCH] * drop objdir/srcdir * seperate vsprintf to a seperate file as it was in v2. Signed-off-by: Stefan Reinauer Acked-by: Ronald G. Minnich git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@83 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- Makefile | 12 ++++----- arch/x86/Makefile | 12 ++++----- console/vsprintf.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ console/vtxprintf.c | 20 --------------- util/lar/Makefile | 2 -- 5 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 console/vsprintf.c diff --git a/Makefile b/Makefile index 0f4e21d37f..84944a8413 100644 --- a/Makefile +++ b/Makefile @@ -34,10 +34,8 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) have_dotconfig := $(wildcard .config) -srcdir:=$(shell pwd) -src:=$(srcdir) -objdir:=$(shell pwd)/lbobj -obj:=$(objdir) +src:=$(shell pwd) +obj:=$(shell pwd)/lbobj # Do not print "Entering directory ..." @@ -59,7 +57,7 @@ LINUXBIOSINCLUDE := -I$(src) -Iinclude \ CPPFLAGS := $(LINUXBIOSINCLUDE) -export srcdir src objdir obj KERNELVERSION +export src obj KERNELVERSION ifeq ($(strip $(have_dotconfig)),) all: @@ -80,14 +78,14 @@ MAINBOARDDIR=$(shell echo $(CONFIG_MAINBOARD_NAME)) prepare: - @mkdir -p $(objdir) + @mkdir -p $(obj) prepare2: @cp $(src)/.tmpconfig.h $(obj)/config.h clean: @echo "Cleaning up..." - rm -rf $(objdir) + rm -rf $(obj) %.o: %.c diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 639366921f..b886693185 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -18,9 +18,6 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -obj:=$(objdir) -src:=$(srcdir) - $(obj)/linuxbios.rom: $(obj)/linuxbios.lar $(obj)/stage0.init $(obj)/linuxbios.vpd @cat $(obj)/linuxbios.lar \ $(obj)/linuxbios.vpd \ @@ -66,8 +63,10 @@ $(obj)/linuxbios.stage2: $(obj)/stage0.init $(obj)/statictree.o $(Q)$(CC) $(INITCFLAGS) -c mainboard/$(MAINBOARDDIR)/mainboard.c -o $(obj)/mainboard.o # leave a .o with full symbols in it for debugging. - $(Q)cd $(obj); $(LD) -R stage0.o -Ttext 0x0 stage2.o \ - -o $(obj)/linuxbios.stage2.o device.o device_util.o mem.o malloc.o clog2.o mainboard.o statictree.o + $(Q)cd $(obj); $(LD) -R $(obj)/stage0.o -Ttext 0x0 \ + -o $(obj)/linuxbios.stage2.o stage2.o device.o \ + device_util.o mem.o malloc.o clog2.o mainboard.o \ + statictree.o objcopy -O binary $(obj)/linuxbios.stage2.o $(obj)/linuxbios.stage2 $(Q)chmod 644 $(obj)/linuxbios.stage2 @@ -119,12 +118,13 @@ $(obj)/stage0.init: @$(CC) $(INITCFLAGS) -c $(src)/arch/x86/console.c -o $(obj)/console.o @$(CC) $(INITCFLAGS) -c $(src)/arch/x86/serial.c -o $(obj)/serial.o @$(CC) $(INITCFLAGS) -c $(src)/console/vtxprintf.c -o $(obj)/vtxprintf.o + @$(CC) $(INITCFLAGS) -c $(src)/console/vsprintf.c -o $(obj)/vsprintf.o @$(CC) $(INITCFLAGS) -c $(src)/lib/uart8250.c -o $(obj)/uart8250.o # other lib parts @$(CC) $(INITCFLAGS) -c $(src)/lib/mem.c -o $(obj)/mem.o @cd $(obj); $(CC) -m32 -nostdlib -static -T $(src)/arch/x86/ldscript.ld cachemain.o console.o uart8250.o \ - serial.o vtxprintf.o lar.o mem.o stage0_i586.o -o stage0.o + serial.o vtxprintf.o vsprintf.o lar.o mem.o stage0_i586.o -o stage0.o @objcopy -O binary $(obj)/stage0.o $(obj)/stage0.init.pre # Pad boot block to 0x2000 - 0x100 diff --git a/console/vsprintf.c b/console/vsprintf.c new file mode 100644 index 0000000000..b6517ff551 --- /dev/null +++ b/console/vsprintf.c @@ -0,0 +1,59 @@ +/* + * 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 + */ + +/* + * linux/lib/vsprintf.c + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include +#include + +int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args); + +/* FIXME this global makes vsprintf non-reentrant */ + +static char *str_buf; +static void str_tx_byte(unsigned char byte) +{ + *str_buf = byte; + str_buf++; +} + +int vsprintf(char * buf, const char *fmt, va_list args) +{ + int i; + str_buf = buf; + i = vtxprintf(str_tx_byte, fmt, args); + *str_buf = '\0'; + return i; +} + +int sprintf(char * buf, const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i=vsprintf(buf,fmt,args); + va_end(args); + return i; +} diff --git a/console/vtxprintf.c b/console/vtxprintf.c index 6febaa0990..9ffc1f21dc 100644 --- a/console/vtxprintf.c +++ b/console/vtxprintf.c @@ -307,23 +307,3 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args return count; } -/* very gross simple thing that is non-reentrant. This should not matter though. */ -static unsigned char *ssp; -static void stxbyte(unsigned char byte) -{ - *ssp++ = byte; -} - -int sprintf(char *str, const char *format, ...) -{ - va_list args; - int i; - - ssp = (unsigned char *) str; - va_start(args, format); - i = vtxprintf(stxbyte, format, args); - va_end(args); - - return i; - -} diff --git a/util/lar/Makefile b/util/lar/Makefile index 9513871404..3300676226 100644 --- a/util/lar/Makefile +++ b/util/lar/Makefile @@ -24,8 +24,6 @@ SOURCE := lar.c create.c extract.c list.c lib.c HOSTCC=gcc HOSTCFLAGS=-O2 -Wall -W -obj:=$(objdir) - $(obj)/util/lar/lar: $(patsubst %,$(src)/util/lar/%,$(SOURCE)) @mkdir -p $(obj)/util/lar @$(HOSTCC) $(HOSTCFLAGS) -o $@ $^