source: trunk/payloads/external/tint/libpayload_tint.patch

Last change on this file was 5816, checked in by mjones, 3 years ago

Add default libpayload build, xcompile, and lpgcc setup to tint.

Signed-off-by: Marc Jones <marc.jones@…>
Acked-by: Peter Stuge <peter@…>
Acked-by: Myles Watson <mylesgw@…>

File size: 10.4 KB
  • Makefile

    Patch tint 0.03b to be usable as coreboot payload, linked against
    the libpayload library. 
    
    Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
    
    
    Add default libpayload build, xcompile, and lpgcc setup to tint.
    
    Signed-off-by: Marc Jones <marc.jones@gmail.com>
    
    diff -rupN tintorig/Makefile tint/Makefile
    old new  
    2828#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    2929#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3030 
     31$(if $(wildcard .xcompile),,$(eval $(shell bash ./xcompile.sh &> .xcompile))) 
     32include .xcompile 
     33 
     34LIBCONFIG_PATH := ../libpayload 
     35LIBPAYLOAD_DIR := ./libpayloadbin 
     36LPCC := $(LIBPAYLOAD_DIR)/libpayload/bin/lpgcc 
     37LPAS := $(LIBPAYLOAD_DIR)/libpayload/bin/lpas 
     38HAVE_LIBPAYLOAD := $(wildcard $(LIBPAYLOAD_DIR)/libpayload/lib/libpayload.a) 
     39LIB_CONFIG ?= defconfig  
     40 
     41# CFLAGS := -Wall -Werror -Os 
     42CFLAGS := -Wall -g -Os 
     43TARGET := tint 
     44OBJS := $(TARGET).o engine.o io.o utils.o 
     45 
     46# Make is silent per default, but 'make V=1' will show all compiler calls. 
     47ifneq ($(V),1) 
     48Q := @ 
     49endif 
     50 
     51all: $(TARGET).elf 
     52#       printf" CC   $(CC)\n" 
     53         
     54$(TARGET).elf: $(OBJS) libpayload 
     55        $(Q)printf "  LPCC      $(subst $(shell pwd)/,,$(@))\n" 
     56        $(Q)$(LPCC) -o $@ $(OBJS) 
     57        $(Q)$(OBJCOPY) --only-keep-debug $@ tint.debug 
     58        $(Q)$(OBJCOPY) --strip-debug $@ 
     59        $(Q)$(OBJCOPY) --add-gnu-debuglink=tint.debug $@ 
     60         
     61%.o: %.c libpayload 
     62        $(Q)printf "  LPCC      $(subst $(shell pwd)/,,$(@))\n" 
     63        $(Q)$(LPCC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< 
     64 
     65%.S.o: %.S libpayload 
     66        $(Q)printf "  LPAS      $(subst $(shell pwd)/,,$(@))\n" 
     67        $(Q)$(LPAS) $(ASFLAGS) --32 -o $@ $< 
     68 
     69ifneq ($(strip $(HAVE_LIBPAYLOAD)),) 
     70libpayload: 
     71        $(Q)printf "Found Libpayload $(LIBPAYLOAD_DIR).\n" 
     72else 
     73libpayload: 
     74        $(Q)printf "Building libpayload @ $(LIBCONFIG_PATH).\n" 
     75        $(Q)make -C $(LIBCONFIG_PATH) distclean 
     76        $(Q)make -C $(LIBCONFIG_PATH) $(LIB_CONFIG) 
     77        $(Q)make -C $(LIBCONFIG_PATH) DESTDIR=$(shell pwd)/$(LIBPAYLOAD_DIR) install 
     78endif 
     79 
     80clean: 
     81        $(Q)rm -f $(TARGET).elf $(TARGET).debug *.o  
     82        $(Q)rm .xcompile 
     83 
     84distclean: clean 
     85        $(Q)rm -rf $(LIBPAYLOAD_DIR) 
     86 
     87# Original tint targets 
     88ifdef $(UNUSED) 
     89 
    3190#CROSS = arm-linux- 
    3291 
    3392bindir = $(DESTDIR)/usr/games 
    clean: 
    110169distclean: clean 
    111170        $(MAKE) -C debian clean 
    112171 
     172endif 
  • config.h

    diff -rupN tintorig/config.h tint/config.h
    old new  
    2929 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3030 */ 
    3131 
     32#include <libpayload.h> 
     33#include <curses.h> 
     34#define random(x) rand(x) 
     35#define srandom(x) srand(x) 
     36#define curs_set(x) 
     37 
     38 
    3239/* Score file */ 
     40#if 0 
    3341const char scorefile[] = SCOREFILE; 
     42#endif 
    3443 
    3544#endif  /* #ifndef CONFIG_H */ 
  • engine.c

    diff -rupN tintorig/engine.c tint/engine.c
    old new  
    2727 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2828 */ 
    2929 
     30#include "config.h" 
     31 
     32#if 0 
    3033#include <stdlib.h> 
    3134#include <string.h> 
     35#endif 
    3236 
    3337#include "typedefs.h" 
    3438#include "utils.h" 
  • io.c

    diff -rupN tintorig/io.c tint/io.c
    old new  
    2727 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2828 */ 
    2929 
     30#include "config.h" 
     31 
     32#if 0 
    3033#include <stdarg.h>             /* va_list(), va_start(), va_end() */ 
    3134#include <sys/time.h>   /* gettimeofday() */ 
    3235#include <unistd.h>             /* gettimeofday() */ 
     36#endif 
    3337 
    3438#include <curses.h> 
    3539 
    static int in_timeleft; 
    7074/* Initialize screen */ 
    7175void io_init () 
    7276{ 
     77   curses_enable_serial(0); 
     78   curses_enable_vga(1); 
    7379   initscr (); 
     80   halfdelay(1); 
     81   timeout(1); 
    7482   start_color (); 
    7583   curs_set (CURSOR_INVISIBLE); 
    7684   out_attr = A_NORMAL; 
    void out_beep () 
    176184/* Read a character. Please note that you MUST call in_timeout() before in_getch() */ 
    177185int in_getch () 
    178186{ 
     187#if 0 
    179188   struct timeval starttv,endtv; 
     189#endif 
    180190   int ch; 
     191#if 0 
    181192   timeout (in_timeleft / 1000); 
    182193   gettimeofday (&starttv,NULL); 
     194#endif 
    183195   ch = getch (); 
     196   mdelay(150); 
     197#if 0 
    184198   gettimeofday (&endtv,NULL); 
    185199   /* Timeout? */ 
    186200   if (ch == ERR) 
    int in_getch () 
    198212                in_timeleft -= endtv.tv_usec; 
    199213                if (in_timeleft <= 0) in_timeleft = in_timetotal; 
    200214         } 
     215#endif 
    201216   return ch; 
    202217} 
    203218 
  • tint.c

    diff -rupN tintorig/tint.c tint/tint.c
    old new  
    1  
    21/* 
    32 * Copyright (c) Abraham vd Merwe <abz@blio.net> 
    43 * All rights reserved. 
     
    2726 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2827 */ 
    2928 
     29#if 0 
    3030#include <stdlib.h> 
    3131#include <stdio.h> 
    3232#include <string.h> 
     
    3434#include <pwd.h> 
    3535#include <sys/types.h> 
    3636#include <unistd.h> 
     37#endif 
    3738 
    3839#include "typedefs.h" 
    3940#include "utils.h" 
    typedef struct 
    321322   time_t timestamp; 
    322323} score_t; 
    323324 
     325#if 0 
    324326static void getname (char *name) 
    325327{ 
    326328   struct passwd *pw = getpwuid (geteuid ()); 
    static void getname (char *name) 
    337339                name[NAMELEN - 1] = '\0'; 
    338340         } 
    339341} 
     342#endif 
    340343 
     344#if 0 
    341345static void err1 () 
    342346{ 
    343347   fprintf (stderr,"Error creating %s\n",scorefile); 
    static void err2 () 
    349353   fprintf (stderr,"Error writing to %s\n",scorefile); 
    350354   exit (EXIT_FAILURE); 
    351355} 
     356#endif 
    352357 
    353358void showplayerstats (engine_t *engine) 
    354359{ 
    355    fprintf (stderr, 
     360   printf ( 
    356361                        "\n\t   PLAYER STATISTICS\n\n\t" 
    357362                        "Score       %11d\n\t" 
    358363                        "Efficiency  %11d\n\t" 
    void showplayerstats (engine_t *engine) 
    360365                        GETSCORE (engine->score),engine->status.efficiency,GETSCORE (engine->score) / getsum ()); 
    361366} 
    362367 
     368#if 0 
    363369static void createscores (int score) 
    364370{ 
    365371   FILE *handle; 
    static void createscores (int score) 
    394400   fprintf (stderr,"%s",scoretitle); 
    395401   fprintf (stderr,"\t  1* %7d        %s\n\n",score,scores[0].name); 
    396402} 
     403#endif 
    397404 
     405#if 0 
    398406static int cmpscores (const void *a,const void *b) 
    399407{ 
    400408   int result; 
    static int cmpscores (const void *a,cons 
    412420   /* timestamps is equal */ 
    413421   return 0; 
    414422} 
     423#endif 
    415424 
     425#if 0 
    416426static void savescores (int score) 
    417427{ 
    418428   FILE *handle; 
    static void savescores (int score) 
    490500         } 
    491501   fprintf (stderr,"\n"); 
    492502} 
     503#endif 
    493504 
    494505          /***************************************************************************/ 
    495506          /***************************************************************************/ 
    496507          /***************************************************************************/ 
    497508 
     509#if 0 
    498510static void showhelp () 
    499511{ 
    500512   fprintf (stderr,"USAGE: tint [-h] [-l level] [-n]\n"); 
    static void showhelp () 
    504516   fprintf (stderr,"  -d           Draw vertical dotted lines\n"); 
    505517   exit (EXIT_FAILURE); 
    506518} 
     519#endif 
    507520 
    508521static void parse_options (int argc,char *argv[]) 
    509522{ 
     523#if 0 
    510524   int i = 1; 
    511525   while (i < argc) 
    512526         { 
    static void parse_options (int argc,char 
    536550                  } 
    537551                i++; 
    538552         } 
     553#endif 
    539554} 
    540555 
    541556static void choose_level () 
    542557{ 
     558#if 0 
    543559   char buf[NAMELEN]; 
    544560 
    545561   do 
    static void choose_level () 
    549565                buf[strlen (buf) - 1] = '\0'; 
    550566         } 
    551567   while (!str2int (&level,buf) || level < MINLEVEL || level > MAXLEVEL); 
     568#endif 
     569        level = 1; 
    552570} 
    553571 
    554572          /***************************************************************************/ 
    int main (int argc,char *argv[]) 
    663681   if (ch != 'q') 
    664682         { 
    665683                showplayerstats (&engine); 
     684#if 0 
    666685                savescores (GETSCORE (engine.score)); 
     686#endif 
    667687         } 
     688   printf("Bye.\n"); 
     689   refresh(); 
     690   for(;;); //halt(); 
     691#if 0 
    668692   exit (EXIT_SUCCESS); 
     693#endif 
    669694} 
    670695 
  • utils.c

    diff -rupN tintorig/utils.c tint/utils.c
    old new  
    2727 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2828 */ 
    2929 
     30#include "config.h" 
     31 
     32#if 0 
    3033#include <stdlib.h> 
    3134#include <time.h> 
    3235#include <limits.h> 
     36#endif 
    3337 
    3438#include "typedefs.h" 
    3539 
    void rand_init () 
    4145#ifdef USE_RAND 
    4246   srand (time (NULL)); 
    4347#else 
     48#if 0 
    4449   srandom (time (NULL)); 
    4550#endif 
     51   srandom (123); 
     52#endif 
    4653} 
    4754 
    4855/* 
    int rand_value (int range) 
    6168 * Convert an str to long. Returns TRUE if successful, 
    6269 * FALSE otherwise. 
    6370 */ 
     71#if 0 
    6472bool str2int (int *i,const char *str) 
    6573{ 
    6674   char *endptr; 
    bool str2int (int *i,const char *str) 
    6977   return TRUE; 
    7078} 
    7179 
     80#endif 
  • xcompile.sh

    diff -rupN tintorig/xcompile.sh tint/xcompile.sh
    old new  
     1#!/bin/bash 
     2 
     3CONFIG=defconfig 
     4SCRIPT_DIR=`dirname "$0"` 
     5 
     6for make in make gmake gnumake; do 
     7        if [ "`$make --version 2>/dev/null | grep -c GNU`" -gt 0 ]; then 
     8                MAKE=$make 
     9                break 
     10        fi 
     11done 
     12 
     13GCCPREFIX=invalid 
     14for gccprefixes in `pwd`/$SCRIPT_DIR/../../util/crossgcc/xgcc/bin/i386-elf- i386-elf- ""; do 
     15        TMP=`mktemp /tmp/temp.XXXX` 
     16        echo "mov %eax, %eax" > ${TMP}.s 
     17        printf "\x7fELF" > ${TMP}.compare 
     18        if which ${gccprefixes}as 2>/dev/null >/dev/null; then 
     19                printf "" 
     20        else 
     21                continue 
     22        fi 
     23        if ${gccprefixes}as --32 -o ${TMP}.o ${TMP}.s; then 
     24                dd bs=4 count=1 if=${TMP}.o > ${TMP}.test 2>/dev/null 
     25                if cmp ${TMP}.test ${TMP}.compare; then 
     26                        GCCPREFIX=$gccprefixes 
     27                        rm -f $TMP ${TMP}.s ${TMP}.o ${TMP}.compare ${TMP}.test 
     28                        break 
     29                fi 
     30        fi 
     31        rm -f $TMP ${TMP}.s ${TMP}.o ${TMP}.compare ${TMP}.test 
     32done 
     33 
     34if [ "$GCCPREFIX" = "invalid" ]; then 
     35        echo no suitable gcc found 
     36        exit 1 
     37fi 
     38 
     39#MAKEFLAGS=" \ 
     40#       AS=\"${GCCPREFIX}as --32\"              \ 
     41#       CC=\"${GCCPREFIX}gcc -m32\"             \ 
     42#       AR=\"${GCCPREFIX}ar\"                   \ 
     43#       LD=\"${GCCPREFIX}ld -b elf32-i386\"     \ 
     44#       STRIP=\"${GCCPREFIX}strip\"             \ 
     45#       NM=\"${GCCPREFIX}nm\"                   \ 
     46#       HOSTCC=gcc                              \ 
     47#       -j                                      \ 
     48#" 
     49 
     50cat << afteroptions 
     51export AS:=${GCCPREFIX}as --32 
     52export CC:=${GCCPREFIX}gcc -m32 
     53export CPP:=${GCCPREFIX}cpp 
     54export AR:=${GCCPREFIX}ar 
     55export LD:=${GCCPREFIX}ld -b elf32-i386 
     56export STRIP:=${GCCPREFIX}strip 
     57export NM:=${GCCPREFIX}nm 
     58export OBJCOPY:=${GCCPREFIX}objcopy 
     59export OBJDUMP:=${GCCPREFIX}objdump 
     60export HOSTCC:=gcc 
     61afteroptions 
     62 
     63# Should we let the payload build libpayload or do it for them? 
     64#test -d ./build || ( 
     65#       BUILDDIR=$PWD 
     66#       cd ../libpayload 
     67#       $MAKE distclean 
     68#       cp configs/$CONFIG .config 
     69#       $MAKE oldconfig 
     70#       eval $MAKE $MAKEFLAGS 
     71#       eval $MAKE $MAKEFLAGS DESTDIR=$BUILDDIR/build install  
     72#       cd .. 
     73#) 
     74 
     75# eval $MAKE -C $SCRIPT_DIR $MAKEFLAGS 
     76 
Note: See TracBrowser for help on using the repository browser.