summaryrefslogtreecommitdiff
path: root/payloads/external/tint/libpayload_tint.patch
blob: be9d8f071d59ca7ac5b2e747c5b493c42fbbf316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
Patch tint 0.03b to be usable as coreboot payload, linked against
the libpayload library.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>

diff -Naur tint-0.03b.orig/config.h tint-0.03b/config.h
--- tint-0.03b.orig/config.h	2001-12-08 00:03:24.000000000 +0100
+++ tint-0.03b/config.h	2008-04-11 22:19:35.000000000 +0200
@@ -29,7 +29,16 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include <libpayload.h>
+#include <curses.h>
+#define random(x) rand(x)
+#define srandom(x) srand(x)
+#define curs_set(x)
+
+
 /* Score file */
+#if 0
 const char scorefile[] = SCOREFILE;
+#endif

 #endif	/* #ifndef CONFIG_H */
diff -Naur tint-0.03b.orig/engine.c tint-0.03b/engine.c
--- tint-0.03b.orig/engine.c	2005-07-17 13:26:22.000000000 +0200
+++ tint-0.03b/engine.c	2008-04-11 22:19:35.000000000 +0200
@@ -27,8 +27,12 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include "config.h"
+
+#if 0
 #include <stdlib.h>
 #include <string.h>
+#endif

 #include "typedefs.h"
 #include "utils.h"
diff -Naur tint-0.03b.orig/io.c tint-0.03b/io.c
--- tint-0.03b.orig/io.c	2001-12-07 16:48:20.000000000 +0100
+++ tint-0.03b/io.c	2008-04-11 22:19:35.000000000 +0200
@@ -27,9 +27,13 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include "config.h"
+
+#if 0
 #include <stdarg.h>		/* va_list(), va_start(), va_end() */
 #include <sys/time.h>	/* gettimeofday() */
 #include <unistd.h>		/* gettimeofday() */
+#endif

 #include <curses.h>

@@ -70,7 +74,11 @@
 /* Initialize screen */
 void io_init ()
 {
+   curses_enable_serial(0);
+   curses_enable_vga(1);
    initscr ();
+   halfdelay(1);
+   timeout(1);
    start_color ();
    curs_set (CURSOR_INVISIBLE);
    out_attr = A_NORMAL;
@@ -176,11 +184,17 @@
 /* Read a character. Please note that you MUST call in_timeout() before in_getch() */
 int in_getch ()
 {
+#if 0
    struct timeval starttv,endtv;
+#endif
    int ch;
+#if 0
    timeout (in_timeleft / 1000);
    gettimeofday (&starttv,NULL);
+#endif
    ch = getch ();
+   mdelay(150);
+#if 0
    gettimeofday (&endtv,NULL);
    /* Timeout? */
    if (ch == ERR)
@@ -198,6 +212,7 @@
 		in_timeleft -= endtv.tv_usec;
 		if (in_timeleft <= 0) in_timeleft = in_timetotal;
 	 }
+#endif
    return ch;
 }

diff -Naur tint-0.03b.orig/Makefile tint-0.03b/Makefile
--- tint-0.03b.orig/Makefile	2005-07-17 13:30:54.000000000 +0200
+++ tint-0.03b/Makefile	2008-04-11 22:19:35.000000000 +0200
@@ -28,6 +28,36 @@
 #  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+LIBPAYLOAD_DIR := ../libpayload
+CC := $(LIBPAYLOAD_DIR)/bin/lpgcc
+AS := $(LIBPAYLOAD_DIR)/bin/lpas
+# CFLAGS := -Wall -Werror -Os
+CFLAGS := -Wall -Os
+TARGET := tint
+OBJS := $(TARGET).o engine.o io.o utils.o
+
+all: $(TARGET).elf
+
+$(TARGET).elf: $(OBJS)
+	$(CC) -o $@ $(OBJS)
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+%.S.o: %.S
+	$(AS) --32 -o $@ $<
+
+clean:
+	rm -f $(TARGET).elf *.o
+
+distclean: clean
+
+
+
+
+
+ifdef $(UNUSED)
+
 #CROSS = arm-linux-

 bindir = $(DESTDIR)/usr/games
@@ -110,3 +140,4 @@
 distclean: clean
 	$(MAKE) -C debian clean

+endif
diff -Naur tint-0.03b.orig/tint.c tint-0.03b/tint.c
--- tint-0.03b.orig/tint.c	2005-07-17 13:26:43.000000000 +0200
+++ tint-0.03b/tint.c	2008-04-11 22:19:35.000000000 +0200
@@ -27,6 +27,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#if 0
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,6 +35,7 @@
 #include <pwd.h>
 #include <sys/types.h>
 #include <unistd.h>
+#endif

 #include "typedefs.h"
 #include "utils.h"
@@ -321,6 +323,7 @@
    time_t timestamp;
 } score_t;

+#if 0
 static void getname (char *name)
 {
    struct passwd *pw = getpwuid (geteuid ());
@@ -337,7 +340,9 @@
 		name[NAMELEN - 1] = '\0';
 	 }
 }
+#endif

+#if 0
 static void err1 ()
 {
    fprintf (stderr,"Error creating %s\n",scorefile);
@@ -349,10 +354,11 @@
    fprintf (stderr,"Error writing to %s\n",scorefile);
    exit (EXIT_FAILURE);
 }
+#endif

 void showplayerstats (engine_t *engine)
 {
-   fprintf (stderr,
+   printf (
 			"\n\t   PLAYER STATISTICS\n\n\t"
 			"Score       %11d\n\t"
 			"Efficiency  %11d\n\t"
@@ -360,6 +366,7 @@
 			GETSCORE (engine->score),engine->status.efficiency,GETSCORE (engine->score) / getsum ());
 }

+#if 0
 static void createscores (int score)
 {
    FILE *handle;
@@ -394,7 +401,9 @@
    fprintf (stderr,"%s",scoretitle);
    fprintf (stderr,"\t  1* %7d        %s\n\n",score,scores[0].name);
 }
+#endif

+#if 0
 static int cmpscores (const void *a,const void *b)
 {
    int result;
@@ -412,7 +421,9 @@
    /* timestamps is equal */
    return 0;
 }
+#endif

+#if 0
 static void savescores (int score)
 {
    FILE *handle;
@@ -490,11 +501,13 @@
 	 }
    fprintf (stderr,"\n");
 }
+#endif

           /***************************************************************************/
           /***************************************************************************/
           /***************************************************************************/

+#if 0
 static void showhelp ()
 {
    fprintf (stderr,"USAGE: tint [-h] [-l level] [-n]\n");
@@ -504,9 +517,11 @@
    fprintf (stderr,"  -d           Draw vertical dotted lines\n");
    exit (EXIT_FAILURE);
 }
+#endif

 static void parse_options (int argc,char *argv[])
 {
+#if 0
    int i = 1;
    while (i < argc)
 	 {
@@ -536,10 +551,12 @@
 		  }
 		i++;
 	 }
+#endif
 }

 static void choose_level ()
 {
+#if 0
    char buf[NAMELEN];

    do
@@ -549,6 +566,8 @@
 		buf[strlen (buf) - 1] = '\0';
 	 }
    while (!str2int (&level,buf) || level < MINLEVEL || level > MAXLEVEL);
+#endif
+	level = 1;
 }

           /***************************************************************************/
@@ -663,8 +682,15 @@
    if (ch != 'q')
 	 {
 		showplayerstats (&engine);
+#if 0
 		savescores (GETSCORE (engine.score));
+#endif
 	 }
+   mvprintw(10, 10, "Bye.");
+   refresh();
+   halt();
+#if 0
    exit (EXIT_SUCCESS);
+#endif
 }

diff -Naur tint-0.03b.orig/utils.c tint-0.03b/utils.c
--- tint-0.03b.orig/utils.c	2001-12-07 16:49:19.000000000 +0100
+++ tint-0.03b/utils.c	2008-04-11 22:19:35.000000000 +0200
@@ -27,9 +27,13 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include "config.h"
+
+#if 0
 #include <stdlib.h>
 #include <time.h>
 #include <limits.h>
+#endif

 #include "typedefs.h"

@@ -41,8 +45,11 @@
 #ifdef USE_RAND
    srand (time (NULL));
 #else
+#if 0
    srandom (time (NULL));
 #endif
+   srandom (123);
+#endif
 }

 /*
@@ -61,6 +68,7 @@
  * Convert an str to long. Returns TRUE if successful,
  * FALSE otherwise.
  */
+#if 0
 bool str2int (int *i,const char *str)
 {
    char *endptr;
@@ -69,3 +77,4 @@
    return TRUE;
 }

+#endif