1 Patch tint 0.03b to be usable as coreboot payload, linked against
2 the libpayload library.
4 Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
7 Add default libpayload build, xcompile, and lpgcc setup to tint.
9 Signed-off-by: Marc Jones <marc.jones@gmail.com>
11 diff -rupN tintorig/Makefile tint/Makefile
12 --- tintorig/Makefile 2005-07-17 05:30:54.000000000 -0600
13 +++ tint/Makefile 2010-08-23 18:06:24.671875000 -0600
15 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
16 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18 +$(if $(wildcard .xcompile),,$(eval $(shell bash ./xcompile.sh &> .xcompile)))
21 +LIBCONFIG_PATH := ../libpayload
22 +LIBPAYLOAD_DIR := ./libpayloadbin
23 +LPCC := $(LIBPAYLOAD_DIR)/libpayload/bin/lpgcc
24 +LPAS := $(LIBPAYLOAD_DIR)/libpayload/bin/lpas
25 +HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/libpayload/lib/libpayload.a)
26 +LIB_CONFIG ?= defconfig
28 +# CFLAGS := -Wall -Werror -Os
29 +CFLAGS := -Wall -g -Os
31 +OBJS := $(TARGET).o engine.o io.o utils.o
33 +# Make is silent per default, but 'make V=1' will show all compiler calls.
39 +# printf" CC $(CC)\n"
41 +$(TARGET).elf: $(OBJS) libpayload
42 + $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n"
43 + $(Q)$(LPCC) -o $@ $(OBJS)
44 + $(Q)$(OBJCOPY) --only-keep-debug $@ tint.debug
45 + $(Q)$(OBJCOPY) --strip-debug $@
46 + $(Q)$(OBJCOPY) --add-gnu-debuglink=tint.debug $@
49 + $(Q)printf " LPCC $(subst $(shell pwd)/,,$(@))\n"
50 + $(Q)$(LPCC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
52 +%.S.o: %.S libpayload
53 + $(Q)printf " LPAS $(subst $(shell pwd)/,,$(@))\n"
54 + $(Q)$(LPAS) $(ASFLAGS) --32 -o $@ $<
56 +ifneq ($(strip $(HAVE_LIBPAYLOAD)),)
58 + $(Q)printf "Found Libpayload $(LIBPAYLOAD_DIR).\n"
61 + $(Q)printf "Building libpayload @ $(LIBCONFIG_PATH).\n"
62 + $(Q)make -C $(LIBCONFIG_PATH) distclean
63 + $(Q)make -C $(LIBCONFIG_PATH) $(LIB_CONFIG)
64 + $(Q)make -C $(LIBCONFIG_PATH) DESTDIR=$(shell pwd)/$(LIBPAYLOAD_DIR) install
68 + $(Q)rm -f $(TARGET).elf $(TARGET).debug *.o
72 + $(Q)rm -rf $(LIBPAYLOAD_DIR)
74 +# Original tint targets
79 bindir = $(DESTDIR)/usr/games
80 @@ -110,3 +169,4 @@ clean:
82 $(MAKE) -C debian clean
85 diff -rupN tintorig/config.h tint/config.h
86 --- tintorig/config.h 2001-12-07 16:03:24.000000000 -0700
87 +++ tint/config.h 2010-01-27 13:59:18.000000000 -0700
89 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92 +#include <libpayload.h>
94 +#define random(x) rand(x)
95 +#define srandom(x) srand(x)
101 const char scorefile[] = SCOREFILE;
104 #endif /* #ifndef CONFIG_H */
105 diff -rupN tintorig/engine.c tint/engine.c
106 --- tintorig/engine.c 2005-07-17 05:26:22.000000000 -0600
107 +++ tint/engine.c 2010-01-27 13:59:18.000000000 -0700
109 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
119 #include "typedefs.h"
121 diff -rupN tintorig/io.c tint/io.c
122 --- tintorig/io.c 2001-12-07 08:48:20.000000000 -0700
123 +++ tint/io.c 2010-01-27 13:59:18.000000000 -0700
125 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131 #include <stdarg.h> /* va_list(), va_start(), va_end() */
132 #include <sys/time.h> /* gettimeofday() */
133 #include <unistd.h> /* gettimeofday() */
138 @@ -70,7 +74,11 @@ static int in_timeleft;
139 /* Initialize screen */
142 + curses_enable_serial(0);
143 + curses_enable_vga(1);
148 curs_set (CURSOR_INVISIBLE);
150 @@ -176,11 +184,17 @@ void out_beep ()
151 /* Read a character. Please note that you MUST call in_timeout() before in_getch() */
155 struct timeval starttv,endtv;
159 timeout (in_timeleft / 1000);
160 gettimeofday (&starttv,NULL);
165 gettimeofday (&endtv,NULL);
168 @@ -198,6 +212,7 @@ int in_getch ()
169 in_timeleft -= endtv.tv_usec;
170 if (in_timeleft <= 0) in_timeleft = in_timetotal;
176 diff -rupN tintorig/tint.c tint/tint.c
177 --- tintorig/tint.c 2005-07-17 05:26:43.000000000 -0600
178 +++ tint/tint.c 2010-08-23 18:13:53.281250000 -0600
182 * Copyright (c) Abraham vd Merwe <abz@blio.net>
183 * All rights reserved.
185 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
194 #include <sys/types.h>
198 #include "typedefs.h"
200 @@ -321,6 +322,7 @@ typedef struct
205 static void getname (char *name)
207 struct passwd *pw = getpwuid (geteuid ());
208 @@ -337,7 +339,9 @@ static void getname (char *name)
209 name[NAMELEN - 1] = '\0';
217 fprintf (stderr,"Error creating %s\n",scorefile);
218 @@ -349,10 +353,11 @@ static void err2 ()
219 fprintf (stderr,"Error writing to %s\n",scorefile);
224 void showplayerstats (engine_t *engine)
228 "\n\t PLAYER STATISTICS\n\n\t"
230 "Efficiency %11d\n\t"
231 @@ -360,6 +365,7 @@ void showplayerstats (engine_t *engine)
232 GETSCORE (engine->score),engine->status.efficiency,GETSCORE (engine->score) / getsum ());
236 static void createscores (int score)
239 @@ -394,7 +400,9 @@ static void createscores (int score)
240 fprintf (stderr,"%s",scoretitle);
241 fprintf (stderr,"\t 1* %7d %s\n\n",score,scores[0].name);
246 static int cmpscores (const void *a,const void *b)
249 @@ -412,7 +420,9 @@ static int cmpscores (const void *a,cons
250 /* timestamps is equal */
256 static void savescores (int score)
259 @@ -490,11 +500,13 @@ static void savescores (int score)
261 fprintf (stderr,"\n");
265 /***************************************************************************/
266 /***************************************************************************/
267 /***************************************************************************/
270 static void showhelp ()
272 fprintf (stderr,"USAGE: tint [-h] [-l level] [-n]\n");
273 @@ -504,9 +516,11 @@ static void showhelp ()
274 fprintf (stderr," -d Draw vertical dotted lines\n");
279 static void parse_options (int argc,char *argv[])
285 @@ -536,10 +550,12 @@ static void parse_options (int argc,char
292 static void choose_level ()
298 @@ -549,6 +565,8 @@ static void choose_level ()
299 buf[strlen (buf) - 1] = '\0';
301 while (!str2int (&level,buf) || level < MINLEVEL || level > MAXLEVEL);
306 /***************************************************************************/
307 @@ -663,8 +681,15 @@ int main (int argc,char *argv[])
310 showplayerstats (&engine);
312 savescores (GETSCORE (engine.score));
323 diff -rupN tintorig/utils.c tint/utils.c
324 --- tintorig/utils.c 2001-12-07 08:49:19.000000000 -0700
325 +++ tint/utils.c 2010-01-27 13:59:18.000000000 -0700
327 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
338 #include "typedefs.h"
340 @@ -41,8 +45,11 @@ void rand_init ()
345 srandom (time (NULL));
352 @@ -61,6 +68,7 @@ int rand_value (int range)
353 * Convert an str to long. Returns TRUE if successful,
357 bool str2int (int *i,const char *str)
360 @@ -69,3 +77,4 @@ bool str2int (int *i,const char *str)
365 diff -rupN tintorig/xcompile.sh tint/xcompile.sh
366 --- tintorig/xcompile.sh 1969-12-31 17:00:00.000000000 -0700
367 +++ tint/xcompile.sh 2010-03-10 15:34:51.421875000 -0700
372 +SCRIPT_DIR=`dirname "$0"`
374 +for make in make gmake gnumake; do
375 + if [ "`$make --version 2>/dev/null | grep -c GNU`" -gt 0 ]; then
382 +for gccprefixes in `pwd`/$SCRIPT_DIR/../../util/crossgcc/xgcc/bin/i386-elf- i386-elf- ""; do
383 + TMP=`mktemp /tmp/temp.XXXX`
384 + echo "mov %eax, %eax" > ${TMP}.s
385 + printf "\x7fELF" > ${TMP}.compare
386 + if which ${gccprefixes}as 2>/dev/null >/dev/null; then
391 + if ${gccprefixes}as --32 -o ${TMP}.o ${TMP}.s; then
392 + dd bs=4 count=1 if=${TMP}.o > ${TMP}.test 2>/dev/null
393 + if cmp ${TMP}.test ${TMP}.compare; then
394 + GCCPREFIX=$gccprefixes
395 + rm -f $TMP ${TMP}.s ${TMP}.o ${TMP}.compare ${TMP}.test
399 + rm -f $TMP ${TMP}.s ${TMP}.o ${TMP}.compare ${TMP}.test
402 +if [ "$GCCPREFIX" = "invalid" ]; then
403 + echo no suitable gcc found
408 +# AS=\"${GCCPREFIX}as --32\" \
409 +# CC=\"${GCCPREFIX}gcc -m32\" \
410 +# AR=\"${GCCPREFIX}ar\" \
411 +# LD=\"${GCCPREFIX}ld -b elf32-i386\" \
412 +# STRIP=\"${GCCPREFIX}strip\" \
413 +# NM=\"${GCCPREFIX}nm\" \
419 +export AS:=${GCCPREFIX}as --32
420 +export CC:=${GCCPREFIX}gcc -m32
421 +export CPP:=${GCCPREFIX}cpp
422 +export AR:=${GCCPREFIX}ar
423 +export LD:=${GCCPREFIX}ld -b elf32-i386
424 +export STRIP:=${GCCPREFIX}strip
425 +export NM:=${GCCPREFIX}nm
426 +export OBJCOPY:=${GCCPREFIX}objcopy
427 +export OBJDUMP:=${GCCPREFIX}objdump
431 +# Should we let the payload build libpayload or do it for them?
432 +#test -d ./build || (
436 +# cp configs/$CONFIG .config
438 +# eval $MAKE $MAKEFLAGS
439 +# eval $MAKE $MAKEFLAGS DESTDIR=$BUILDDIR/build install
443 +# eval $MAKE -C $SCRIPT_DIR $MAKEFLAGS