* updated firefox (133.0.3 -> 134.0.2)
[t2sde.git] / package / boot / arcload / 13_initrd_support.patch
blob479c5fa2dca1aa4282f1cd0f0fba2b52dbcaf5a6
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: package/*/arcload/13_initrd_support.patch
4 # Copyright (C) 2020 - 2024 The T2 SDE Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License version 2 as used by the T2 SDE.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 diff -urNad arcload-0.5~/loader/block.c arcload-0.5/loader/block.c
16 --- arcload-0.5~/loader/block.c 2006-01-20 05:06:27.000000000 +0000
17 +++ arcload-0.5/loader/block.c 2007-09-26 16:49:18.000000000 +0000
18 @@ -89,6 +89,7 @@
19 return -1;
21 dev->pos = 0;
22 + dev->size = i->file.size;
23 dev->file = i;
24 i->refcnt++;
26 diff -urNad arcload-0.5~/loader/block.h arcload-0.5/loader/block.h
27 --- arcload-0.5~/loader/block.h 2006-01-18 03:46:45.000000000 +0000
28 +++ arcload-0.5/loader/block.h 2007-09-26 16:49:18.000000000 +0000
29 @@ -10,6 +10,7 @@
30 typedef struct {
31 void *file;
32 ULONG pos;
33 + ULONG size;
34 } BDEV;
36 INT bopen(BDEV *dev, CHAR *path);
37 diff -urNad arcload-0.5~/loader/config.c arcload-0.5/loader/config.c
38 --- arcload-0.5~/loader/config.c 2006-01-20 05:06:50.000000000 +0000
39 +++ arcload-0.5/loader/config.c 2007-09-26 16:49:18.000000000 +0000
40 @@ -37,6 +37,8 @@
41 #define S_SYSIMG 7
42 #define S_DESCR 8
43 #define S_COMMENT 9
44 +#define S_INITRD 10
45 +#define S_SYSINITRD 11
47 static char *token_names[] = {
48 "NONE",
49 @@ -59,7 +61,9 @@
50 "TERM",
51 "SYSIMG",
52 "DESCR",
53 - "COMMENT"
54 + "COMMENT",
55 + "INITRD",
56 + "SYSINITRD"
59 static int is_space(char ch)
60 @@ -98,8 +102,8 @@
61 static int rx_token(int token, char *text, int *s_state, char **label, int n_label, int *label_count,
62 char *image, int n_image, char **append, int n_append,
63 char *append_space, int *append_space_ptr, int n_append_space,
64 - int *append_count, char *descr, char *lastl, int *s_level, int *s_ignore,
65 - char *system)
66 + int *append_count, char *initrd, int n_initrd, char *descr, char *lastl,
67 + int *s_level, int *s_ignore, char *system)
69 int len;
70 switch(*s_state) {
71 @@ -160,6 +164,11 @@
72 break;
75 + if(!strcmp(text, "initrd")) {
76 + *s_state = S_INITRD;
77 + break;
78 + }
80 if(!*label_count) {
81 strcpy(lastl,text);
82 descr[0] = 0;
83 @@ -299,6 +308,32 @@
85 *s_state = S_TERM;
86 break;
88 + case S_INITRD:
89 + case S_SYSINITRD:
90 + if(token != T_STRING)
91 + return token_bomb(token, text, *s_state, image, "STRING");
93 + if((*s_state == S_INITRD) && !strcmp(text, "system")) {
94 + strcpy(initrd, system);
95 + *s_state = S_SYSINITRD;
96 + break;
97 + }
99 + if((*s_state == S_INITRD) && !strcmp(text, "absolute")) {
100 + *s_state = S_SYSINITRD;
101 + break;
104 + if(strlen(text) >= (n_initrd - strlen(initrd))) {
105 + printf("Error: N_INITRD exceeded.\n\r");
106 + initrd[0] = 0;
107 + return 1;
110 + strcat(initrd, text);
111 + *s_state = S_TERM;
112 + break;
114 return 0;
116 @@ -308,6 +343,7 @@
117 if(rx_token(a, b, &s_state, label, n_label, label_count, image, \
118 n_image, append, n_append, append_space, \
119 &append_space_ptr, n_append_space, append_count, \
120 + initrd, n_initrd, \
121 descr, lastl, &s_level, &s_ignore, system)) { \
122 bclose(&file); \
123 return; \
124 @@ -317,7 +353,8 @@
126 void parseconfig(char **label, int n_label, int *label_count, char *image,
127 int n_image, char **append, int n_append, char *append_space,
128 - int n_append_space, int *append_count, char *system)
129 + int n_append_space, int *append_count, char *initrd, int n_initrd,
130 + char *system)
132 BDEV file;
133 char str[STRING_LEN], descr[STRING_LEN], lastl[STRING_LEN];
134 diff -urNad arcload-0.5~/loader/config.h arcload-0.5/loader/config.h
135 --- arcload-0.5~/loader/config.h 2005-09-02 13:56:02.000000000 +0000
136 +++ arcload-0.5/loader/config.h 2007-09-26 16:49:18.000000000 +0000
137 @@ -16,6 +16,8 @@
138 * append_space - in-out parameter, will contain append as linear string
139 * n_append_space - input parameter, size of append_space
140 * append_count - output parameter, count of kernel arguments
141 + * initrd - output parameter, will contain path to initrd image
142 + * n_initrd - input parameter, contains maximum length of initrd
144 * if image[0] == 0 on output, we failed
146 @@ -23,7 +25,8 @@
147 char *image, int n_image,
148 char **append, int n_append,
149 char *append_space, int n_append_space,
150 - int *append_count, char *system);
151 + int *append_count, char *initrd, int n_initrd,
152 + char *system);
154 /* this function parses text label format into an array
155 * I'm pretty sure that by know you can guess the meanings */
156 diff -urNad arcload-0.5~/loader/main.c arcload-0.5/loader/main.c
157 --- arcload-0.5~/loader/main.c 2007-09-26 16:48:57.000000000 +0000
158 +++ arcload-0.5/loader/main.c 2007-09-26 16:49:40.000000000 +0000
159 @@ -1,5 +1,6 @@
161 * ARCload (c) 2005 Stanislaw Skowronek
162 + * Copyright (C) 2007 Julien BLACHE
165 #include <arclib/arc.h>
166 @@ -21,6 +22,7 @@
167 #define N_IMAGE 256
168 #define N_APPEND 32
169 #define N_APPEND_SPACE 2048
170 +#define N_INITRD 256
172 #define PAGESHIFT 12
173 #define READBLOCK 16384
174 @@ -30,6 +32,12 @@
175 // malloc pool size
176 #define ARENA 1048576
178 +/* See load_initrd() */
179 +#define STACK_PAGES 4
181 +#define KSEG0ADDR(addr) (((addr) & 0x1fffffff) | 0x80000000)
183 +/* #define RD_DEBUG */
185 typedef union {
186 unsigned char e_ident[EI_NIDENT];
187 @@ -41,6 +49,13 @@
188 INT is_elf64 = 1;
189 #endif
191 +/* End address of kernel image */
192 +ULONG kernel_end = 0;
194 +/* Maximum page size supported by the machine */
195 +unsigned long max_page_size = 0;
198 INT checkmemmap(ULONG elf_start, ULONG elf_size)
200 MEMORYDESCRIPTOR *md;
201 @@ -70,10 +85,10 @@
202 return -1;
205 -ULONG vtophys(ULONG addr)
206 +ULONG vtophys(ULONG addr, int warn)
208 #ifdef M32
209 - if((addr & 0xC0000000) != 0x80000000)
210 + if(warn && ((addr & 0xC0000000) != 0x80000000))
211 printf("Warning: kernel is in a mapped area!\n\r");
213 return (addr & 0x1FFFFFFF);
214 @@ -82,28 +97,51 @@
215 if((addr >> 62) == 2)
216 return (addr & ((1UL << 40) - 1));
218 - /* ckseg */
219 + /* xkseg */
220 if((addr >> 60) == 15) {
221 - if((addr & 0xC0000000UL) != 0x80000000UL)
222 + if(warn && ((addr & 0xC0000000UL) != 0x80000000UL))
223 printf("Warning: kernel is in a mapped area!\n\r");
225 return (addr & 0x1FFFFFFF);
228 - printf("Warning: kernel is in a mapped area!\n\r");
229 + if(warn)
230 + printf("Warning: kernel is in a mapped area!\n\r");
232 return (addr & ((1UL << 40) - 1));
233 #endif
236 +static int load_file(BDEV *file, UCHAR *ptr, ULONG size)
238 + INT i;
239 + ULONG pos = 0;
241 + while(size > 0) {
242 + i = ((size > READBLOCK) ? READBLOCK : size);
243 + if(bread(file, i, ptr) < 0) {
244 + printf("failed at %u!\n\r", pos);
245 + return 1;
247 + size -= i;
248 + ptr += i;
249 + pos += i;
251 + printf("OK.\n\r");
253 + return 0;
256 #ifdef M32
257 Elf64_Addr load_elf32(Elf32_Ehdr *hdr, BDEV *file)
259 Elf32_Phdr ph[N_PHDR];
260 - INT i, j, nph = 0;
261 - ULONG left, pos;
262 + INT i, nph = 0;
263 + ULONG pos;
264 UCHAR *ptr;
266 + int ret;
268 /* Not Relocatable? */
269 if(hdr->e_type != ET_EXEC) {
270 printf("ELF file is not executable.\n\r");
271 @@ -125,6 +165,14 @@
272 return 0;
275 + /*
276 + * The offset of the first segment should be equal to the
277 + * maximal page size supported by the machine.
278 + */
279 + if(max_page_size == 0) {
280 + max_page_size = ph[nph].p_offset;
283 if(ph[nph].p_type != PT_LOAD)
284 continue;
286 @@ -144,31 +192,29 @@
287 /* Realize LOAD headers */
288 for(i = 0; i < nph; i++) {
289 /* Check the Memory Map */
290 - if(checkmemmap(vtophys(ph[i].p_vaddr), ph[i].p_memsz)) {
291 + if(checkmemmap(vtophys(ph[i].p_vaddr, 1), ph[i].p_memsz)) {
292 printf("File can't be loaded into current memory map.\n\r");
293 return 0;
296 /* Load the ELF into memory */
297 - printf("Reading %u bytes... ", (ULONG)ph[i].p_filesz);
298 - left = ph[i].p_filesz;
299 - pos = 0;
300 ptr = (UCHAR *)ph[i].p_vaddr;
302 + printf("Loading kernel at 0x%p; reading %u bytes... ", ptr, (ULONG)ph[i].p_filesz);
304 bseek(file, ph[i].p_offset);
305 - while(left > 0) {
306 - j = ((left > READBLOCK) ? READBLOCK : left);
307 - if(bread(file, j, ptr)<0) {
308 - printf("failed at %u!\n\r", (ULONG)pos);
309 - return 0;
311 - left -= j;
312 - ptr += j;
313 - pos += j;
315 - printf("OK.\n\r");
316 - ptr = (UCHAR *)(ph[i].p_vaddr + ph[i].p_filesz);
317 + ret = load_file(file, ptr, ph[i].p_filesz);
319 + if(ret != 0)
320 + return 0;
322 + ptr += ph[i].p_filesz;
323 for(pos = ph[i].p_filesz; pos < ph[i].p_memsz; pos++)
324 *(ptr++) = 0;
326 + /* Save the end of the kernel image, needed to load the initrd */
327 + if((ULONG)ptr > kernel_end)
328 + kernel_end = (ULONG)ptr;
331 return (Elf64_Addr) hdr->e_entry;
332 @@ -178,10 +224,12 @@
333 Elf64_Addr load_elf64(Elf64_Ehdr *hdr, BDEV *file)
335 Elf64_Phdr ph[N_PHDR];
336 - INT i, j, nph = 0;
337 - ULONG left, pos;
338 + INT i, nph = 0;
339 + ULONG pos;
340 UCHAR *ptr;
342 + int ret;
344 /* Not Relocatable? */
345 if(hdr->e_type != ET_EXEC) {
346 printf("ELF file is not executable.\n\r");
347 @@ -203,6 +251,14 @@
348 return 0;
351 + /*
352 + * The offset of the first segment should be equal to the
353 + * maximal page size supported by the machine.
354 + */
355 + if(max_page_size == 0) {
356 + max_page_size = ph[nph].p_offset;
359 if(ph[nph].p_type != PT_LOAD)
360 continue;
362 @@ -222,39 +278,33 @@
363 /* Realize LOAD headers */
364 for(i = 0; i < nph; i++) {
365 /* Check the Memory Map */
366 - if(checkmemmap(vtophys(ph[i].p_vaddr), ph[i].p_memsz)) {
367 + if(checkmemmap(vtophys(ph[i].p_vaddr, 1), ph[i].p_memsz)) {
368 printf("File can't be loaded into current memory map.\n\r");
369 return 0;
372 /* Load the ELF into memory */
373 - printf("Reading %u bytes... ", (ULONG)ph[i].p_filesz);
374 - left = ph[i].p_filesz;
375 - pos = 0;
376 #ifdef M32
377 ptr = (UCHAR *)(Elf32_Addr)ph[i].p_vaddr;
378 #else
379 ptr = (UCHAR *)ph[i].p_vaddr;
380 #endif
382 + printf("Loading kernel at 0x%p; reading %u bytes... ", ptr, (ULONG)ph[i].p_filesz);
384 bseek(file, ph[i].p_offset);
385 - while(left > 0) {
386 - j = ((left > READBLOCK) ? READBLOCK : left);
387 - if(bread(file, j, ptr)<0) {
388 - printf("failed at %u!\n\r", (ULONG)pos);
389 - return 0;
391 - left -= j;
392 - ptr += j;
393 - pos += j;
395 - printf("OK.\n\r");
396 -#ifdef M32
397 - ptr = (UCHAR *)(Elf32_Addr)(ph[i].p_vaddr + ph[i].p_filesz);
398 -#else
399 - ptr = (UCHAR *)(ph[i].p_vaddr + ph[i].p_filesz);
400 -#endif
401 + ret = load_file(file, ptr, ph[i].p_filesz);
403 + if(ret != 0)
404 + return 0;
406 + ptr += ph[i].p_filesz;
407 for(pos = ph[i].p_filesz; pos < ph[i].p_memsz; pos++)
408 *(ptr++) = 0;
410 + /* Save the end of the kernel image, needed to load the initrd */
411 + if((ULONG)ptr > kernel_end)
412 + kernel_end = (ULONG)ptr;
415 return hdr->e_entry;
416 @@ -280,7 +330,7 @@
417 goto close;
420 - /* Is is an ELF binary? */
421 + /* Is it an ELF binary? */
422 if((hdr.e_ident[0] != 0x7f) ||
423 (hdr.e_ident[1] != 'E') ||
424 (hdr.e_ident[2] != 'L') ||
425 @@ -322,6 +372,181 @@
429 +int load_initrd(char *fname, char **append, int n_append,
430 + char *append_space, int n_append_space, int *append_count)
432 + BDEV file;
434 + ULONG initrd_addr;
436 + char buf[64];
437 + char *append_ptr;
438 + int len, ret;
440 + MEMORYDESCRIPTOR *current = NULL;
441 + ULONG start = 0;
442 + ULONG end;
444 + ULONG stack = vtophys((ULONG) &end, 0);
446 + kernel_end = vtophys(kernel_end, 0) + 8 * max_page_size;
448 + printf("Loading initrd %s ...\n\r", fname);
450 +#ifdef RD_DEBUG
451 + printf("RD: Max page size seems to be 0x%x\n\r", max_page_size);
452 +#endif
454 + /* Open */
455 + if(bopen(&file, fname)) {
456 + printf("Opening %s failed.\n\r", fname);
457 + return 1;
459 + if (!file.size) file.size = 7 * 1024 * 1024; /* zero for bootp(): */
460 + /* Find a free memory region big enough to hold the initrd image */
461 + current = ArcGetMemoryDescriptor(current);
462 + if(!current) {
463 + printf("Can't find any valid memory descriptors!\n\r");
464 + goto rd_close;
467 +#ifdef RD_DEBUG
468 + printf("RD: stack at 0x%p, kernel ends at 0x%p\n\r", stack, kernel_end);
469 +#endif
471 + while ((current = ArcGetMemoryDescriptor(current)) != NULL) {
472 + if(current->Type == FreeMemory) {
473 + start = current->BasePage << PAGESHIFT;
474 + end = start + (current->PageCount << PAGESHIFT);
475 +#ifdef RD_DEBUG
476 + printf("RD: considering area 0x%p - 0x%p, %u pages\n\r", start, end, current->PageCount);
477 +#endif
478 + /* Leave some more room for our stack - at that point we don't need that much */
479 + if((stack >= start) && (stack < end)) {
480 +#ifdef RD_DEBUG
481 + printf("RD: area includes stack\n\r");
482 +#endif
483 + end = (stack - (STACK_PAGES << PAGESHIFT)) & ~((1 << PAGESHIFT) - 1);
486 + /* Did we load the kernel there already ? */
487 + if((kernel_end > start) && (kernel_end < end)) {
488 +#ifdef RD_DEBUG
489 + printf("RD: area includes kernel\n\r");
490 +#endif
491 + start = (kernel_end + (1 << PAGESHIFT)) & ~((1 << PAGESHIFT) - 1);
494 + if((end < start) || (end - start) < (file.size + max_page_size)) {
495 +#ifdef RD_DEBUG
496 + printf("RD: area too small: %u needs %u\n\r", (end - start), (file.size + max_page_size));
497 +#endif
498 + start = end = 0;
499 + continue;
501 +#ifdef RD_DEBUG
502 + printf("RD: area 0x%p - 0x%p OK for initrd\n\r", start, end);
503 +#endif
504 + break;
508 + if(start == 0) {
509 + printf("initrd can't be loaded into current memory map\n\r");
510 + goto rd_close;
513 +#ifdef M32
514 + /* Turn the physical start address into a KSEG0 address */
515 + start = KSEG0ADDR(start);
516 +#else
517 + /*
518 + * Turn the physical address into an uncached XKPHYS address
519 + * This should probably be flagged as FIXME.
520 + */
521 + start = start | 0xa800000000000000;
522 +#endif
524 + /*
525 + * Compute initrd address: must be page-aligned; as we don't know
526 + * what page size the kernel uses, we'll use the max page size we
527 + * determined from the ELF file structure when loading the kernel.
528 + */
529 + initrd_addr = (start + max_page_size) & ~(max_page_size - 1);
531 + /* Load the initrd image into memory */
532 + printf("Loading initrd at 0x%p; reading %u bytes... ", initrd_addr, file.size);
534 + ret = load_file(&file, (UCHAR *)initrd_addr, file.size);
535 + if(ret != 0)
536 + goto rd_close;
538 + /* Add rd_start= and rd_size= to the kernel arguments */
540 + if(*append_count + 2 >= n_append) {
541 + printf("Error: N_APPEND exceeded.\n\r");
542 + goto rd_close;
545 + /* Get the tail of the append_space currently used */
546 + if(*append_count == 0) {
547 + append_ptr = append_space;
548 + } else {
549 + append_ptr = append[(*append_count) - 1];
550 + append_ptr += strlen(append_ptr) + 1;
553 +#if 0 // def M64
554 + /* The kernel wants a KSEG0 address and takes care of the sign extension */
555 + initrd_addr = KSEG0ADDR(initrd_addr);
556 +#endif
558 + /* rd_start= */
559 + len = sprintf(buf, "rd_start=0x%x", initrd_addr);
561 +#ifdef RD_DEBUG
562 + printf("APPEND: '%s'\n\r", buf);
563 +#endif
565 + if((append_ptr - append_space + len + 1) > n_append_space) {
566 + printf("Error: N_APPEND_SPACE exceeded.\n\r");
567 + goto rd_close;
570 + strcpy(append_ptr, buf);
571 + append[*append_count] = append_ptr;
572 + (*append_count)++;
574 + append_ptr += len + 1;
576 + /* rd_size= */
577 + len = sprintf(buf, "rd_size=0x%x", file.size);
579 +#ifdef RD_DEBUG
580 + printf("APPEND: '%s'\n\r", buf);
581 +#endif
583 + if((append_ptr - append_space + len + 1) > n_append_space) {
584 + printf("Error: N_APPEND_SPACE exceeded.\n\r");
585 + goto rd_close;
588 + strcpy(append_ptr, buf);
589 + append[*append_count] = append_ptr;
590 + (*append_count)++;
592 + bclose(&file);
594 + return 0;
596 +/* Failed to do something, close and return */
597 +rd_close:
598 + bclose(&file);
599 + return 1;
604 #ifdef M64
605 unsigned fixup_trampolines_data[]={
606 0x03e00821, 0x04110001, 0x00000000, 0xdfe30014,
607 @@ -389,8 +616,12 @@
608 char append_space[N_APPEND_SPACE];
609 int append_count;
611 + char initrd[N_INITRD];
613 unsigned long arena_start;
615 - printf("ARCLoad version " VERSION " (c) 2004-5 Stanislaw Skowronek\n\r");
616 + int ret;
618 + printf("ARCLoad version " VERSION " (c)2004-5 Stanislaw Skowronek, (c)2006-2024 Ren\xe9 Rebe\n\r");
620 #ifdef M64
621 @@ -398,9 +629,9 @@
622 #endif
624 arena_start = (((ULONG)__start) - ARENA)&~((1UL<<PAGESHIFT)-1);
625 - if(checkmemmap(vtophys(arena_start), ARENA)) {
626 + if(checkmemmap(vtophys(arena_start, 1), ARENA)) {
627 printf("Internal error: dynamic memory arena allocation failed.\n\r");
628 - printf("Attempted: 0x%p bytes at 0x%p.\n\r", ARENA, vtophys(((ULONG)__start) - ARENA));
629 + printf("Attempted: 0x%p bytes at 0x%p.\n\r", ARENA, vtophys(((ULONG)__start) - ARENA, 1));
630 return 1;
632 arclib_malloc_add(arena_start, ARENA);
633 @@ -427,7 +658,9 @@
634 printf("Loading configuration for '%s'...\n\r", text_label);
635 parselabel(text_label, label, N_LABEL, &label_count, label_space, N_LABEL_SPACE);
637 - parseconfig(label, N_LABEL, &label_count, image, N_IMAGE, append, N_APPEND, append_space, N_APPEND_SPACE, &append_count, system);
638 + *initrd = 0;
640 + parseconfig(label, N_LABEL, &label_count, image, N_IMAGE, append, N_APPEND, append_space, N_APPEND_SPACE, &append_count, initrd, N_INITRD, system);
641 if(!*label)
642 return 0;
643 if(!*image) {
644 @@ -439,6 +672,12 @@
645 if(!entry)
646 return 1;
648 + if(*initrd) {
649 + ret = load_initrd(initrd, append, N_APPEND, append_space, N_APPEND_SPACE, &append_count);
650 + if (ret != 0)
651 + return 1;
654 #ifdef M32
655 if(!is_elf64) {
656 kernel_entry = (VOID(*)(INT, CHAR **, CHAR **))entry32;
657 --- arcload-0.5/loader/main.c.vanilla 2021-08-31 17:28:51.865158898 +0200
658 +++ arcload-0.5/loader/main.c 2021-08-31 18:03:45.529308219 +0200
659 @@ -112,20 +112,25 @@
660 #endif
663 -static int load_file(BDEV *file, UCHAR *ptr, ULONG size)
664 +static int load_file(BDEV *file, UCHAR *ptr, LONG size)
666 INT i;
667 ULONG pos = 0;
669 - while(size > 0) {
670 - i = ((size > READBLOCK) ? READBLOCK : size);
671 - if(bread(file, i, ptr) < 0) {
672 + while(size) {
673 + if (size < 0) i = READBLOCK;
674 + else i = ((size > READBLOCK) ? READBLOCK : size);
675 + if((i = bread(file, i, ptr)) < 0) {
676 printf("failed at %u!\n\r", pos);
677 return 1;
679 size -= i;
680 ptr += i;
681 pos += i;
682 + if ((size < 0) && (i < READBLOCK)) {
683 + file->size = pos;
684 + break;
687 printf("OK.\n\r");
689 @@ -384,6 +389,7 @@
690 BDEV file;
692 ULONG initrd_addr;
693 + ULONG initrd_size;
695 char buf[64];
696 char *append_ptr;
697 @@ -408,7 +414,7 @@
698 printf("Opening %s failed.\n\r", fname);
699 return 1;
701 - if (!file.size) file.size = 7 * 1024 * 1024; /* zero for bootp(): */
702 + initrd_size = file.size ? file.size : 32*1024*1024; /* zero for bootp(): */
703 /* Find a free memory region big enough to hold the initrd image */
704 current = ArcGetMemoryDescriptor(current);
705 if(!current) {
706 @@ -444,9 +450,9 @@
707 start = end = 0; continue;
710 - if((end < start) || (end - start) < (file.size + max_page_size)) {
711 + if((end < start) || (end - start) < (initrd_size + max_page_size)) {
712 #ifdef RD_DEBUG
713 - printf("RD: area too small: %u needs %u\n\r", (end - start), (file.size + max_page_size));
714 + printf("RD: area too small: %u needs %u\n\r", (end - start), (initrd_size + max_page_size));
715 #endif
716 start = end = 0;
718 @@ -483,9 +489,9 @@
719 initrd_addr = (start + max_page_size) & ~(max_page_size - 1);
721 /* Load the initrd image into memory */
722 - printf("Loading initrd at 0x%p; reading %u bytes... ", initrd_addr, file.size);
723 + printf("Loading initrd at 0x%p; reading %u bytes... ", initrd_addr, initrd_size);
725 - ret = load_file(&file, (UCHAR *)initrd_addr, file.size);
726 + ret = load_file(&file, (UCHAR *)initrd_addr, file.size ? file.size : -1);
727 if(ret != 0)
728 goto rd_close;