be9d8f071d59ca7ac5b2e747c5b493c42fbbf316
[coreboot.git] / payloads / external / tint / libpayload_tint.patch
1 Patch tint 0.03b to be usable as coreboot payload, linked against
2 the libpayload library.
3
4 Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
5
6 diff -Naur tint-0.03b.orig/config.h tint-0.03b/config.h
7 --- tint-0.03b.orig/config.h    2001-12-08 00:03:24.000000000 +0100
8 +++ tint-0.03b/config.h 2008-04-11 22:19:35.000000000 +0200
9 @@ -29,7 +29,16 @@
10   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11   */
12
13 +#include <libpayload.h>
14 +#include <curses.h>
15 +#define random(x) rand(x)
16 +#define srandom(x) srand(x)
17 +#define curs_set(x)
18 +
19 +
20  /* Score file */
21 +#if 0
22  const char scorefile[] = SCOREFILE;
23 +#endif
24
25  #endif /* #ifndef CONFIG_H */
26 diff -Naur tint-0.03b.orig/engine.c tint-0.03b/engine.c
27 --- tint-0.03b.orig/engine.c    2005-07-17 13:26:22.000000000 +0200
28 +++ tint-0.03b/engine.c 2008-04-11 22:19:35.000000000 +0200
29 @@ -27,8 +27,12 @@
30   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31   */
32
33 +#include "config.h"
34 +
35 +#if 0
36  #include <stdlib.h>
37  #include <string.h>
38 +#endif
39
40  #include "typedefs.h"
41  #include "utils.h"
42 diff -Naur tint-0.03b.orig/io.c tint-0.03b/io.c
43 --- tint-0.03b.orig/io.c        2001-12-07 16:48:20.000000000 +0100
44 +++ tint-0.03b/io.c     2008-04-11 22:19:35.000000000 +0200
45 @@ -27,9 +27,13 @@
46   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47   */
48
49 +#include "config.h"
50 +
51 +#if 0
52  #include <stdarg.h>            /* va_list(), va_start(), va_end() */
53  #include <sys/time.h>  /* gettimeofday() */
54  #include <unistd.h>            /* gettimeofday() */
55 +#endif
56
57  #include <curses.h>
58
59 @@ -70,7 +74,11 @@
60  /* Initialize screen */
61  void io_init ()
62  {
63 +   curses_enable_serial(0);
64 +   curses_enable_vga(1);
65     initscr ();
66 +   halfdelay(1);
67 +   timeout(1);
68     start_color ();
69     curs_set (CURSOR_INVISIBLE);
70     out_attr = A_NORMAL;
71 @@ -176,11 +184,17 @@
72  /* Read a character. Please note that you MUST call in_timeout() before in_getch() */
73  int in_getch ()
74  {
75 +#if 0
76     struct timeval starttv,endtv;
77 +#endif
78     int ch;
79 +#if 0
80     timeout (in_timeleft / 1000);
81     gettimeofday (&starttv,NULL);
82 +#endif
83     ch = getch ();
84 +   mdelay(150);
85 +#if 0
86     gettimeofday (&endtv,NULL);
87     /* Timeout? */
88     if (ch == ERR)
89 @@ -198,6 +212,7 @@
90                 in_timeleft -= endtv.tv_usec;
91                 if (in_timeleft <= 0) in_timeleft = in_timetotal;
92          }
93 +#endif
94     return ch;
95  }
96
97 diff -Naur tint-0.03b.orig/Makefile tint-0.03b/Makefile
98 --- tint-0.03b.orig/Makefile    2005-07-17 13:30:54.000000000 +0200
99 +++ tint-0.03b/Makefile 2008-04-11 22:19:35.000000000 +0200
100 @@ -28,6 +28,36 @@
101  #  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
102  #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103
104 +LIBPAYLOAD_DIR := ../libpayload
105 +CC := $(LIBPAYLOAD_DIR)/bin/lpgcc
106 +AS := $(LIBPAYLOAD_DIR)/bin/lpas
107 +# CFLAGS := -Wall -Werror -Os
108 +CFLAGS := -Wall -Os
109 +TARGET := tint
110 +OBJS := $(TARGET).o engine.o io.o utils.o
111 +
112 +all: $(TARGET).elf
113 +
114 +$(TARGET).elf: $(OBJS)
115 +       $(CC) -o $@ $(OBJS)
116 +
117 +%.o: %.c
118 +       $(CC) $(CFLAGS) -c -o $@ $<
119 +
120 +%.S.o: %.S
121 +       $(AS) --32 -o $@ $<
122 +
123 +clean:
124 +       rm -f $(TARGET).elf *.o
125 +
126 +distclean: clean
127 +
128 +
129 +
130 +
131 +
132 +ifdef $(UNUSED)
133 +
134  #CROSS = arm-linux-
135
136  bindir = $(DESTDIR)/usr/games
137 @@ -110,3 +140,4 @@
138  distclean: clean
139         $(MAKE) -C debian clean
140
141 +endif
142 diff -Naur tint-0.03b.orig/tint.c tint-0.03b/tint.c
143 --- tint-0.03b.orig/tint.c      2005-07-17 13:26:43.000000000 +0200
144 +++ tint-0.03b/tint.c   2008-04-11 22:19:35.000000000 +0200
145 @@ -27,6 +27,7 @@
146   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147   */
148
149 +#if 0
150  #include <stdlib.h>
151  #include <stdio.h>
152  #include <string.h>
153 @@ -34,6 +35,7 @@
154  #include <pwd.h>
155  #include <sys/types.h>
156  #include <unistd.h>
157 +#endif
158
159  #include "typedefs.h"
160  #include "utils.h"
161 @@ -321,6 +323,7 @@
162     time_t timestamp;
163  } score_t;
164
165 +#if 0
166  static void getname (char *name)
167  {
168     struct passwd *pw = getpwuid (geteuid ());
169 @@ -337,7 +340,9 @@
170                 name[NAMELEN - 1] = '\0';
171          }
172  }
173 +#endif
174
175 +#if 0
176  static void err1 ()
177  {
178     fprintf (stderr,"Error creating %s\n",scorefile);
179 @@ -349,10 +354,11 @@
180     fprintf (stderr,"Error writing to %s\n",scorefile);
181     exit (EXIT_FAILURE);
182  }
183 +#endif
184
185  void showplayerstats (engine_t *engine)
186  {
187 -   fprintf (stderr,
188 +   printf (
189                         "\n\t   PLAYER STATISTICS\n\n\t"
190                         "Score       %11d\n\t"
191                         "Efficiency  %11d\n\t"
192 @@ -360,6 +366,7 @@
193                         GETSCORE (engine->score),engine->status.efficiency,GETSCORE (engine->score) / getsum ());
194  }
195
196 +#if 0
197  static void createscores (int score)
198  {
199     FILE *handle;
200 @@ -394,7 +401,9 @@
201     fprintf (stderr,"%s",scoretitle);
202     fprintf (stderr,"\t  1* %7d        %s\n\n",score,scores[0].name);
203  }
204 +#endif
205
206 +#if 0
207  static int cmpscores (const void *a,const void *b)
208  {
209     int result;
210 @@ -412,7 +421,9 @@
211     /* timestamps is equal */
212     return 0;
213  }
214 +#endif
215
216 +#if 0
217  static void savescores (int score)
218  {
219     FILE *handle;
220 @@ -490,11 +501,13 @@
221          }
222     fprintf (stderr,"\n");
223  }
224 +#endif
225
226            /***************************************************************************/
227            /***************************************************************************/
228            /***************************************************************************/
229
230 +#if 0
231  static void showhelp ()
232  {
233     fprintf (stderr,"USAGE: tint [-h] [-l level] [-n]\n");
234 @@ -504,9 +517,11 @@
235     fprintf (stderr,"  -d           Draw vertical dotted lines\n");
236     exit (EXIT_FAILURE);
237  }
238 +#endif
239
240  static void parse_options (int argc,char *argv[])
241  {
242 +#if 0
243     int i = 1;
244     while (i < argc)
245          {
246 @@ -536,10 +551,12 @@
247                   }
248                 i++;
249          }
250 +#endif
251  }
252
253  static void choose_level ()
254  {
255 +#if 0
256     char buf[NAMELEN];
257
258     do
259 @@ -549,6 +566,8 @@
260                 buf[strlen (buf) - 1] = '\0';
261          }
262     while (!str2int (&level,buf) || level < MINLEVEL || level > MAXLEVEL);
263 +#endif
264 +       level = 1;
265  }
266
267            /***************************************************************************/
268 @@ -663,8 +682,15 @@
269     if (ch != 'q')
270          {
271                 showplayerstats (&engine);
272 +#if 0
273                 savescores (GETSCORE (engine.score));
274 +#endif
275          }
276 +   mvprintw(10, 10, "Bye.");
277 +   refresh();
278 +   halt();
279 +#if 0
280     exit (EXIT_SUCCESS);
281 +#endif
282  }
283
284 diff -Naur tint-0.03b.orig/utils.c tint-0.03b/utils.c
285 --- tint-0.03b.orig/utils.c     2001-12-07 16:49:19.000000000 +0100
286 +++ tint-0.03b/utils.c  2008-04-11 22:19:35.000000000 +0200
287 @@ -27,9 +27,13 @@
288   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289   */
290
291 +#include "config.h"
292 +
293 +#if 0
294  #include <stdlib.h>
295  #include <time.h>
296  #include <limits.h>
297 +#endif
298
299  #include "typedefs.h"
300
301 @@ -41,8 +45,11 @@
302  #ifdef USE_RAND
303     srand (time (NULL));
304  #else
305 +#if 0
306     srandom (time (NULL));
307  #endif
308 +   srandom (123);
309 +#endif
310  }
311
312  /*
313 @@ -61,6 +68,7 @@
314   * Convert an str to long. Returns TRUE if successful,
315   * FALSE otherwise.
316   */
317 +#if 0
318  bool str2int (int *i,const char *str)
319  {
320     char *endptr;
321 @@ -69,3 +77,4 @@
322     return TRUE;
323  }
324
325 +#endif