LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
elf.c
Go to the documentation of this file.
1/* devtree preparation & initrd handling
2
3Copyright (C) 2010-2011 Hector Martin "marcan" <hector@marcansoft.com>
4
5This code is licensed to you under the terms of the GNU GPL, version 2;
6see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
7*/
8
9#include <fcntl.h>
10#include <libfdt/libfdt.h>
11#include <nocfe/cfe.h>
12#include <ppc/cache.h>
13#include <ppc/register.h>
14#include <ppc/timebase.h>
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18#include <time/time.h>
19#include <unistd.h>
21
22#include "elf.h"
23#include "elf_abi.h"
24#include "xetypes.h"
25
26#define ELF_DEVTREE_START ((void *)0x85FE0000)
27#define ELF_DEVTREE_MAX_SIZE 0x00010000
28#define MAX_CMDLINE_SIZE 255
29
30#define INITRD_RELOC_START ((void *)0x86000000)
31#define INITRD_MAX_SIZE (32 * 1024 * 1024) // 0x02000000
32
33// Address where the elf loading code is relocated.
34/* TODO: must keep this synced with lis %r4,0x86f8
35 and lis %r4,0x06f8 in elf_hold_thread elf_run.S */
36#define ELF_CODE_STACK_END ((void *)0x87F80000)
37#define ELF_CODE_RELOC_START ((void *)0x87F80000)
38#define ELF_CODE_MAX_SIZE 0x00080000
39
40// Temporary buffer to hold loaded elf data.
41#define ELF_TEMP_BEGIN ((void *)0x88000000)
42#define ELF_MAX_SIZE 0x03000000
43
44// ELF file relocation address.
45#define ELF_DATA_RELOC_START ((void *)0x8B000000)
46#define ELF_ARGV_BEGIN ((void *)0x8E000000)
47#define ELF_GET_RELOCATED(x) \
48 (ELF_CODE_RELOC_START + ((unsigned long)(x) - (unsigned long)elfldr_start))
49#define ELF_GET_RELOCATED_REAL(x) (void*)((uint64_t)ELF_GET_RELOCATED(x) & 0x1FFFFFFF)
50
51#define ELF_DEBUG 1
52
53extern void shutdown_drivers();
54
55// section start/end, defined by the compiler
56extern unsigned char elfldr_start[], elfldr_end[], pagetable_end[];
57extern void elf_call_real(uint64_t function, ...);
58extern void elf_run(unsigned long entry, unsigned long devtree);
59extern void elf_hold_thread();
60
61extern volatile unsigned long elf_secondary_hold_addr;
62extern volatile unsigned long elf_secondary_count;
63
64static char bootargs[MAX_CMDLINE_SIZE];
65
66static uint8_t *initrd_start = NULL;
67static size_t initrd_size = 0;
68
69static char _filename[256] = {0};
70static char _filepath[256] = {0};
71static char _device[256] = {0};
72
73static inline __attribute__((always_inline)) void elf_putch(unsigned char c) {
74 while (!((*(volatile uint32_t *)(0xea001000 + 0x18)) & 0x02000000))
75 ;
76 *(volatile uint32_t *)(0xea001000 + 0x14) = (c << 24) & 0xFF000000;
77}
78
79static inline __attribute__((always_inline)) void elf_puts(unsigned char *s) {
80 while (*s)
81 elf_putch(*s++);
82}
83
84static inline __attribute__((always_inline)) void
85elf_int2hex(unsigned long long n, unsigned char w, unsigned char *str) {
86 unsigned char i, d;
87
88 str += w;
89 *str = 0;
90
91 for (i = 0; i < w; ++i) {
92 d = (n >> (i << 2)) & 0x0f;
93 *--str = (d <= 9) ? d + 48 : d + 55;
94 };
95}
96
97static inline __attribute__((always_inline)) void elf_memset(unsigned char *dst,
98 int v, int l) {
99 while (l--)
100 *dst++ = v;
101}
102
103static inline __attribute__((always_inline)) void
104elf_memcpy(unsigned char *dst, const unsigned char *src, int l) {
105 while (l--)
106 *dst++ = *src++;
107}
108
109#define LINESIZE 128
110static inline __attribute__((always_inline)) void
111elf_sync(volatile void *addr) {
112 asm volatile("dcbst 0, %0" : : "b"(addr));
113 asm volatile("sync");
114 asm volatile("icbi 0, %0" : : "b"(addr));
115 asm volatile("isync");
116}
117
118static inline __attribute__((always_inline)) void
119elf_sync_before_exec(unsigned char *dst, int l) {
120 dst = (unsigned char *)((unsigned long)dst & (~(LINESIZE - 1)));
121
122 l += (LINESIZE - 1);
123 l &= ~(LINESIZE - 1);
124
125 while (l > 0) {
126 elf_sync(dst);
127 dst += LINESIZE;
128 l -= LINESIZE;
129 }
130}
131
132static inline __attribute__((always_inline)) void
133elf_smc_send_message(const unsigned char *msg) {
134 while ((read32(0xEA001000 + 0x84) & 4) == 0)
135 ;
136
137 write32(0xEA001000 + 0x84, 4);
138 write32n(0xEA001000 + 0x80, *(uint32_t *)(msg + 0));
139 write32n(0xEA001000 + 0x80, *(uint32_t *)(msg + 4));
140 write32n(0xEA001000 + 0x80, *(uint32_t *)(msg + 8));
141 write32n(0xEA001000 + 0x80, *(uint32_t *)(msg + 12));
142 write32(0xEA001000 + 0x84, 0);
143}
144
145static inline __attribute__((always_inline)) void elf_smc_set_led(int override,
146 int value) {
147 uint8_t buf[16];
148 elf_memset(buf, 0, 16);
149
150 buf[0] = 0x99;
151 buf[1] = override;
152 buf[2] = value;
153
154 elf_smc_send_message(buf);
155}
156
157// Stage 2 of prepare run: This function is called in real-mode.
158// WARNING: elf_prepare_run_s2 is relocated and you CANNOT call regular functions from here! The application *will* trap.
159// As a consequence of the relocation, the following optimizations are required to prevent function calls that will fail:
160// - optimize("O2") is required to prevent calls to _savegpr
161// - optimize("no-tree-loop-distribute-patterns") prevents GCC from replacing loops with calls to library functions
162static void
163 __attribute__((section(".elfldr"), used, noreturn, flatten, optimize("O2", "no-tree-loop-distribute-patterns")))
164 elf_prepare_run_s2(void *self, uint32_t entry, int mem_size) {
165 // GCC is allowed to optimize away writes to 0, so do a stupid trick.
166 volatile void* volatile zero = 0x0;
167
168 // Final copy, and synchronize icache. This is the point of no return.
169 elf_memcpy(zero, (void*)((uint64_t)ELF_TEMP_BEGIN & 0x1FFFFFFF), mem_size);
170 elf_sync_before_exec(zero, mem_size);
171
172 // Send secondary threads into the elf.
173 *(volatile unsigned long *)(ELF_GET_RELOCATED_REAL(
174 &elf_secondary_hold_addr)) = entry + 0x60;
175
176 // load the argv struct (if this isn't the kernel)
177 if (entry != 0) {
178 // disable argument for linux
179 void *new_argv = (void*)(0x00000008 + entry);
180 elf_memcpy(new_argv, (void*)((uint64_t)ELF_ARGV_BEGIN & 0x1FFFFFFF), sizeof(struct __argv));
181 elf_sync_before_exec(new_argv, sizeof(struct __argv));
182 }
183
184 // call elf_run() in elf_run.S
185 void (*call)(unsigned long, unsigned long) = ELF_GET_RELOCATED_REAL(elf_run);
186 call(entry, ((uint64_t)ELF_DEVTREE_START) & 0x1fffffff);
187
188 // This should never be reached.
189 for (;;)
190 ;
191}
192
193// WARNING: elf_prepare_run is relocated and you CANNOT call regular functions from here! The application *will* trap.
194// As a consequence of the relocation, the following optimizations are required to prevent function calls that will fail:
195// - optimize("O2") is required to prevent calls to _savegpr
196// - optimize("no-tree-loop-distribute-patterns") prevents GCC from replacing loops with calls to library functions
197static void
198 __attribute__((section(".elfldr"), used, noreturn, flatten, optimize("O2", "no-tree-loop-distribute-patterns")))
199 elf_prepare_run(void *addr, uint32_t size) {
200 Elf32_Ehdr *ehdr;
201 Elf32_Shdr *shdr;
202 Elf32_Phdr *phdr;
203 int i;
204
205 int mem_size = 0;
206 uint32_t pagetable_size = (uint32_t)pagetable_end & 0x1FFFFFFF;
207
208 ehdr = (Elf32_Ehdr *)addr;
209 shdr = (Elf32_Shdr *)(addr + ehdr->e_shoff +
210 (ehdr->e_shstrndx * sizeof(Elf32_Shdr)));
211 phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff);
212
213 for (i = 0; i < ehdr->e_phnum; ++i) {
214#if ELF_DEBUG
215 elf_smc_set_led(1, (i << 4) & 0xF0); // flash green LEDs
216#endif
217
218 phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff + (i * sizeof(Elf32_Phdr)));
219
220 // Track the high address (even for pages we don't load)
221 if (phdr->p_paddr + phdr->p_memsz > mem_size) {
222 mem_size = phdr->p_paddr + phdr->p_memsz;
223 }
224
225 if (phdr->p_type == PT_LOAD || phdr->p_type == PT_DYNAMIC ||
226 phdr->p_type == PT_NOTE) {
227 // Zero then copy into our temporary memory...
228 elf_memset(ELF_TEMP_BEGIN + phdr->p_paddr, 0, phdr->p_memsz);
229 elf_memcpy(ELF_TEMP_BEGIN + phdr->p_paddr, addr + phdr->p_offset,
230 phdr->p_filesz);
231 }
232 }
233
234 if (mem_size == 0) {
235 // Uh-oh, no loading occurred. We're boned.
236 elf_smc_set_led(1, 0x0F);
237 while (1)
238 ;
239 }
240
241#if ELF_DEBUG
242 elf_smc_set_led(1, 0x87); // 1 green 3 red
243#endif
244
245 void (*call_real)(void *, uint32_t, int) = ELF_GET_RELOCATED(elf_call_real);
246 call_real(ELF_GET_RELOCATED_REAL(elf_prepare_run_s2), ehdr->e_entry,
247 mem_size);
248
249 // Call these just so they aren't optimized out (this isn't reached).
251 elf_prepare_run_s2(NULL, 0, 0);
252
253 // This should never be reached.
254 for (;;)
255 ;
256}
257
258char *argv_GetFilename(const char *argv) {
259 char *tmp;
260
261 if (argv == NULL)
262 return NULL;
263
264 tmp = strrchr(argv, '/');
265
266 if (tmp == NULL)
267 return NULL;
268
269 strcpy(_filename, tmp + 1);
270
271 return _filename;
272}
273
274char *argv_GetFilepath(const char *argv) {
275 char *tmp;
276
277 if (argv == NULL)
278 return NULL;
279
280 tmp = strrchr(argv, '/');
281
282 if (tmp == NULL)
283 return NULL;
284
285 strncpy(_filepath, argv, tmp - argv);
286
287 return _filepath;
288}
289
290char *argv_GetDevice(const char *argv) {
291 char *tmp;
292
293 if (argv == NULL)
294 return NULL;
295
296 tmp = strrchr(argv, ':');
297
298 if (tmp == NULL)
299 return NULL;
300
301 strncpy(_device, argv, tmp - argv);
302
303 return _device;
304}
305
306void elf_setArgcArgv(int argc, char *argv[]) {
307 int i;
308
309 // create argv struct and initialize it
310 struct __argv args;
311 memset(&args, 0, sizeof(struct __argv));
312 args.magic = ARGV_MAGIC;
313 args.argc = argc;
314
315 // set the start of the argv array
316 args.argv = (char *)ELF_ARGV_BEGIN + sizeof(struct __argv);
317 char *position = args.argv + (sizeof(char *) * argc);
318
319 // copy all the argument strings
320 for (i = 0; i < argc; i++) {
321 strcpy(position, argv[i]);
322 args.argv[i] = position;
323 position += strlen(argv[i]);
324
325 // be sure its null terminated
326 strcpy(position, "\0");
327 position++;
328 }
329
330 // move the struct to its final position
331 memmove(ELF_ARGV_BEGIN, &args, sizeof(args));
332 elf_sync_before_exec(ELF_ARGV_BEGIN, sizeof(args) + position);
333}
334
335static int elf_VerifyHeaders(void *addr, int size) {
336 Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr;
337 Elf32_Shdr *shdr;
338 Elf32_Phdr *phdr;
339 unsigned char *strtab = 0;
340
341 if (ehdr->e_ident[0] != ELFMAG0 || ehdr->e_ident[1] != ELFMAG1 ||
342 ehdr->e_ident[2] != ELFMAG2 || ehdr->e_ident[3] != ELFMAG3) {
343 printf("ELF: Magic incorrect\n");
344 return -1;
345 }
346
347 if (ehdr->e_ident[EI_CLASS] != ELFCLASS32) {
348 printf("ELF: Not a 32-bit file!\n Did you forget to convert it?\n");
349 return -1;
350 }
351
352 shdr = (Elf32_Shdr *)(addr + ehdr->e_shoff +
353 (ehdr->e_shstrndx * sizeof(Elf32_Shdr)));
354 phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff);
355
356 if (shdr->sh_type == SHT_STRTAB) {
357 strtab = (unsigned char *)(addr + shdr->sh_offset);
358 }
359
360 for (int i = 0; i < ehdr->e_phnum; i++) {
361 phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff + (i * sizeof(Elf32_Phdr)));
362 if (phdr->p_offset + phdr->p_filesz > size) {
363 printf("ELF: Program header %d exceeds file size! (0x%.8X > 0x%.8X)\n",
364 phdr->p_offset + phdr->p_filesz, size);
365 return -1;
366 }
367 }
368
369 return 0;
370}
371
372int elf_runFromMemory(void *addr, int size) {
373 uint64_t start_time;
374 volatile uint32_t *elf_secondary_count_ptr =
376 int i;
377
378 if (elf_VerifyHeaders(addr, size) != 0) {
379 printf(" * Elf headers invalid, abort!\n", addr);
380 return -1;
381 }
382
383 if (size >= ELF_MAX_SIZE) {
384 printf(" * Elf is too large, abort! (size = 0x%.8X)\n", size);
385 return -1;
386 }
387
389 printf(" * Internal error: elfldr code is too large! (size = 0x%.8X)\n",
391 return -1;
392 }
393
394 printf(" * Executing @ 0x%.8X size 0x%.8X...\n", addr, size);
396
397 // relocate our code
400
401 // relocate elf data
402 memcpy(ELF_DATA_RELOC_START, addr, size);
403
404#if ELF_DEBUG
405 printf(" - Waiting for secondary threads...\n");
406#endif
407
408 // get all threads to be on hold in the relocated zone
409 // TODO: timeout and reset
410 *elf_secondary_count_ptr = 0;
412 printf(" - ");
413 for (i = 1; i < 6; ++i) {
415 ;
416
417 while (*elf_secondary_count_ptr < i) {
418 udelay(100);
419 }
420
422 printf(" - %d", i);
423 }
424 printf("\n");
425
426#if ELF_DEBUG
427 printf(" - elf_prepare_run\n");
428#endif
429
430 // call elf_prepare_run()
431 void (*call)(void *, uint32_t) = ELF_GET_RELOCATED(elf_prepare_run);
433
434 // never called, make sure the function survives linking
435 elf_prepare_run(NULL, 0);
436 return 0;
437}
438
439int elf_runFromDisk(char *filename) {
440 int f = open(filename, O_RDONLY);
441 if (f < 0) {
442 return f;
443 }
444
445 struct stat s;
446 stat(filename, &s);
447
448 int size = s.st_size;
449 void *buf = malloc(size);
450
451 int r = read(f, buf, size);
452 if (r < 0) {
453 close(f);
454 return r;
455 }
456
457 elf_runFromMemory(buf, r);
458
459 return 0;
460}
461
462int elf_runWithDeviceTree(void *elf_addr, int elf_size, void *dt_addr,
463 int dt_size) {
464 int res, node;
465 uint32_t cpufreq;
466
467 if (dt_size > ELF_DEVTREE_MAX_SIZE) {
468 printf("[ELF loader] Device tree too big (> %d bytes) !\n",
470 return -1;
471 }
473
475 if (res < 0) {
476 printf(" ! fdt_open_into() failed\n");
477 return res;
478 }
479
480 node = fdt_path_offset(ELF_DEVTREE_START, "/chosen");
481 if (node < 0) {
482 printf(" ! /chosen node not found in devtree\n");
483 return node;
484 }
485
486 if (bootargs[0]) {
487 res = fdt_setprop(ELF_DEVTREE_START, node, "bootargs", bootargs,
488 strlen(bootargs) + 1);
489 if (res < 0) {
490 printf(" ! couldn't set chosen.bootargs property\n");
491 return res;
492 }
493 }
494
495 if (initrd_start && initrd_size) {
496 kernel_relocate_initrd(initrd_start, initrd_size);
497
498 u64 start, end;
499 start = (u32)PHYSADDR((u32)initrd_start);
500 res = fdt_setprop(ELF_DEVTREE_START, node, "linux,initrd-start", &start,
501 sizeof(start));
502 if (res < 0) {
503 printf("couldn't set chosen.linux,initrd-start property\n");
504 return res;
505 }
506
507 end = (u32)PHYSADDR(((u32)initrd_start + (u32)initrd_size));
508 res = fdt_setprop(ELF_DEVTREE_START, node, "linux,initrd-end", &end,
509 sizeof(end));
510 if (res < 0) {
511 printf("couldn't set chosen.linux,initrd-end property\n");
512 return res;
513 }
514 res = fdt_add_mem_rsv(ELF_DEVTREE_START, start, initrd_size);
515 if (res < 0) {
516 printf("couldn't add reservation for the initrd\n");
517 return res;
518 }
519 }
520
521 node = fdt_path_offset(ELF_DEVTREE_START, "/memory");
522 if (node < 0) {
523 printf(" ! /memory node not found in devtree\n");
524 return node;
525 }
526 /*
527 res = fdt_add_mem_rsv(ELF_DEVTREE_START, (uint64_t)ELF_DEVTREE_START,
528 ELF_DEVTREE_MAX_SIZE); if (res < 0){ printf("couldn't add reservation for
529 the devtree\n"); return;
530 }
531 */
532
533 switch (xenon_get_speed()) {
534 case XENON_SPEED_FULL:
535 case XENON_SPEED_3_2: {
536 cpufreq = 3200000000;
537 break;
538 }
539 case XENON_SPEED_1_3: {
540 cpufreq = 1300000000;
541 break;
542 }
543 case XENON_SPEED_1_2: {
544 cpufreq = 1200000000;
545 break;
546 }
547 default: {
548 printf(" ! Weird CPU speed, assuming 3.2GHz\n");
549 cpufreq = 3200000000;
550 break;
551 }
552 }
553
554 node = fdt_path_offset(ELF_DEVTREE_START, "/cpus/Xenon,PPE@0");
555 if (node < 0) {
556 printf(" ! /cpus/Xenon,PPE@0 node not found in devtree\n");
557 return node;
558 }
559
560 res = fdt_setprop(ELF_DEVTREE_START, node, "clock-frequency", &cpufreq,
561 sizeof(cpufreq));
562 if (res < 0) {
563 printf(" ! couldn't set /cpus/Xenon,PPE@0.clock-frequency property\n");
564 return res;
565 }
566
567 node = fdt_path_offset(ELF_DEVTREE_START, "/cpus/Xenon,PPE@1");
568 if (node < 0) {
569 printf(" ! /cpus/Xenon,PPE@1 node not found in devtree\n");
570 return node;
571 }
572
573 res = fdt_setprop(ELF_DEVTREE_START, node, "clock-frequency", &cpufreq,
574 sizeof(cpufreq));
575 if (res < 0) {
576 printf(" ! couldn't set /cpus/Xenon,PPE@1.clock-frequency property\n");
577 return res;
578 }
579
580 node = fdt_path_offset(ELF_DEVTREE_START, "/cpus/Xenon,PPE@2");
581 if (node < 0) {
582 printf(" ! /cpus/Xenon,PPE@2 node not found in devtree\n");
583 return node;
584 }
585
586 res = fdt_setprop(ELF_DEVTREE_START, node, "clock-frequency", &cpufreq,
587 sizeof(cpufreq));
588 if (res < 0) {
589 printf(" ! couldn't set /cpus/Xenon,PPE@2.clock-frequency property\n");
590 return res;
591 }
592
594 if (res < 0) {
595 printf(" ! fdt_pack() failed\n");
596 return res;
597 }
598
600 printf(" * Device tree prepared\n");
601
602 elf_runFromMemory(elf_addr, elf_size);
603
604 return -1; // If this point is reached, elf execution failed
605}
606
607int kernel_prepare_initrd(void *start, size_t size) {
608 if (size > INITRD_MAX_SIZE) {
609 printf(" ! Initrd bigger than INITRD_MAX_SIZE (32 MB), Aborting!\n");
610 return -1;
611 }
612
613 if (initrd_start != NULL)
614 free(initrd_start);
615
616 initrd_start = (uint8_t *)malloc(size);
617
618 memcpy(initrd_start, start, size);
619 initrd_size = size;
620 return 0;
621}
622
623void kernel_relocate_initrd(void *start, size_t size) {
624 printf(" * Relocating initrd...\n");
625
627 memcpy(INITRD_RELOC_START, start, size);
629
630 initrd_start = INITRD_RELOC_START;
631 initrd_size = size;
632
633 printf("Initrd at %p/0x%lx: %ld bytes (%ldKiB)\n", initrd_start,
634 (u32)PHYSADDR((u32)initrd_start), initrd_size, initrd_size / 1024);
635}
636
638 if (initrd_start != NULL)
639 free(initrd_start);
640
641 initrd_start = NULL;
642 initrd_size = 0;
643}
644
645void kernel_build_cmdline(const char *parameters, const char *root) {
646 bootargs[0] = 0;
647
648 if (root) {
649 strlcat(bootargs, "root=", MAX_CMDLINE_SIZE);
650 strlcat(bootargs, root, MAX_CMDLINE_SIZE);
651 strlcat(bootargs, " ", MAX_CMDLINE_SIZE);
652 }
653
654 if (parameters)
655 strlcat(bootargs, parameters, MAX_CMDLINE_SIZE);
656
657 printf("Kernel command line: '%s'\n", bootargs);
658}
#define PHYSADDR(x)
Definition: cfe.h:14
void console_clrline()
Definition: console.c:100
#define NULL
Definition: def.h:47
void memicbi(void *addr, int len)
void memdcbst(void *addr, int len)
#define LINESIZE
Definition: elf.c:109
void kernel_reset_initrd(void)
Definition: elf.c:637
void elf_run(unsigned long entry, unsigned long devtree)
#define ELF_GET_RELOCATED_REAL(x)
Definition: elf.c:49
unsigned char elfldr_end[]
Definition: elf.c:56
#define ELF_ARGV_BEGIN
Definition: elf.c:46
#define MAX_CMDLINE_SIZE
Definition: elf.c:28
char * argv_GetFilepath(const char *argv)
Definition: elf.c:274
#define ELF_GET_RELOCATED(x)
Definition: elf.c:47
char * argv_GetFilename(const char *argv)
Definition: elf.c:258
int kernel_prepare_initrd(void *start, size_t size)
Definition: elf.c:607
int elf_runFromMemory(void *addr, int size)
Definition: elf.c:372
void kernel_build_cmdline(const char *parameters, const char *root)
Definition: elf.c:645
int elf_runFromDisk(char *filename)
Definition: elf.c:439
void elf_call_real(uint64_t function,...)
#define ELF_CODE_MAX_SIZE
Definition: elf.c:38
void elf_setArgcArgv(int argc, char *argv[])
Definition: elf.c:306
volatile unsigned long elf_secondary_hold_addr
void kernel_relocate_initrd(void *start, size_t size)
Definition: elf.c:623
volatile unsigned long elf_secondary_count
#define ELF_CODE_RELOC_START
Definition: elf.c:37
#define ELF_TEMP_BEGIN
Definition: elf.c:41
void shutdown_drivers()
unsigned char pagetable_end[]
Definition: elf.c:56
#define ELF_DEVTREE_START
Definition: elf.c:26
#define INITRD_RELOC_START
Definition: elf.c:30
#define ELF_DEVTREE_MAX_SIZE
Definition: elf.c:27
#define ELF_MAX_SIZE
Definition: elf.c:42
#define ELF_DATA_RELOC_START
Definition: elf.c:45
char * argv_GetDevice(const char *argv)
Definition: elf.c:290
void elf_hold_thread()
int elf_runWithDeviceTree(void *elf_addr, int elf_size, void *dt_addr, int dt_size)
Definition: elf.c:462
#define INITRD_MAX_SIZE
Definition: elf.c:31
unsigned char elfldr_start[]
#define PT_DYNAMIC
Definition: elf_abi.h:118
#define ELFMAG0
Definition: elf_abi.h:45
#define ELFMAG3
Definition: elf_abi.h:48
#define EI_CLASS
Definition: elf_abi.h:42
#define ELFCLASS32
Definition: elf_abi.h:51
#define ELFMAG1
Definition: elf_abi.h:46
#define PT_NOTE
Definition: elf_abi.h:119
#define PT_LOAD
Definition: elf_abi.h:117
#define ELFMAG2
Definition: elf_abi.h:47
#define SHT_STRTAB
Definition: elf_abi.h:107
int fdt_path_offset(const void *fdt, const char *path)
Definition: fdt_ro.c:157
int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
Definition: fdt_rw.c:172
int fdt_pack(void *fdt)
Definition: fdt_rw.c:453
int fdt_open_into(const void *fdt, void *buf, int bufsize)
Definition: fdt_rw.c:389
int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val, int len)
Definition: fdt_rw.c:274
u32 size
Definition: iso9660.c:558
u32 uint32_t
Definition: libfdt_env.h:11
u64 uint64_t
Definition: libfdt_env.h:12
u8 uint8_t
Definition: libfdt_env.h:9
unsigned int __mf_uintptr_t __attribute__((__mode__(__pointer__)))
Definition: mf-runtime.h:34
int close(int fileDesc)
Definition: newlib.c:829
int stat(const char *file, struct stat *st)
Definition: newlib.c:643
int read(int fileDesc, void *ptr, size_t len)
Definition: newlib.c:559
int open(const char *file, int flags, int mode)
Definition: newlib.c:522
Elf32_Word p_paddr
Definition: elf_abi.h:97
Elf32_Word p_type
Definition: elf_abi.h:94
Elf32_Word p_filesz
Definition: elf_abi.h:98
Elf32_Word p_offset
Definition: elf_abi.h:95
Elf32_Word p_memsz
Definition: elf_abi.h:99
Elf32_Off sh_offset
Definition: elf_abi.h:85
Elf32_Word sh_type
Definition: elf_abi.h:82
Definition: xetypes.h:76
int magic
Definition: xetypes.h:77
char ** argv
Definition: xetypes.h:79
int argc
Definition: xetypes.h:78
Definition: elf_abi.h:59
Elf32_Off e_phoff
Definition: elf_abi.h:65
Elf32_Off e_shoff
Definition: elf_abi.h:66
Elf32_Half e_shstrndx
Definition: elf_abi.h:73
Elf32_Addr e_entry
Definition: elf_abi.h:64
Elf32_Half e_phnum
Definition: elf_abi.h:70
unsigned char e_ident[EI_NIDENT]
Definition: elf_abi.h:60
void udelay(int u)
Definition: time.c:12
int xenon_run_thread_task(int thread, void *stack, void *task)
Definition: xenon_power.c:208
void xenon_thread_startup(void)
Definition: xenon_power.c:263
int xenon_get_speed()
Definition: xenon_power.c:202
#define XENON_SPEED_1_3
Definition: xenon_power.h:11
#define XENON_SPEED_1_2
Definition: xenon_power.h:12
#define XENON_SPEED_3_2
Definition: xenon_power.h:13
#define XENON_SPEED_FULL
Definition: xenon_power.h:14
u8 c
Definition: xenos_edid.h:7
u8 str[13]
Definition: xenos_edid.h:0
uint64_t u64
64bit unsigned integer
Definition: xetypes.h:15
#define ARGV_MAGIC
Definition: xetypes.h:84
uint32_t u32
32bit unsigned integer
Definition: xetypes.h:14