/** * Called plainly from assembler code * * @note The C environment isn't initialized yet */ void __bare_init main_entry(void *fdt, u32 fdt_size) { unsigned long malloc_start, malloc_end; /* clear the BSS first */ memset(__bss_start, 0x00, __bss_stop - __bss_start); cpu_probe(); if (cpu_has_4k_cache) { extern void r4k_cache_init(void); r4k_cache_init(); } trap_init(); malloc_end = _stext; if (MALLOC_SIZE > 0) malloc_start = malloc_end - MALLOC_SIZE; else malloc_start = malloc_end - SZ_8M; pr_debug("initializing malloc pool at 0x%08lx (size 0x%08lx)\n", malloc_start, malloc_end - malloc_start); mem_malloc_init((void *)malloc_start, (void *)_stext - 1); mips_stack_top = malloc_start; glob_fdt = fdt; glob_fdt_size = fdt_size; start_barebox(); }
void __noreturn nios_start_barebox(void) { mem_malloc_init((void *)(NIOS_SOPC_TEXT_BASE - MALLOC_SIZE), (void *)(NIOS_SOPC_TEXT_BASE - 1)); start_barebox(); }
/** * Called plainly from assembler code * * @note The C environment isn't initialized yet */ void main_entry(void) { /* clear the BSS first */ memset(__bss_start, 0x00, __bss_stop - __bss_start); cpu_probe(); if (cpu_has_4k_cache) { extern void r4k_cache_init(void); r4k_cache_init(); } trap_init(); start_barebox(); }
__noreturn void barebox_non_pbl_start(unsigned long membase, unsigned long memsize, void *boarddata) { unsigned long endmem = membase + memsize; unsigned long malloc_start, malloc_end; unsigned long barebox_size = barebox_image_size + MAX_BSS_SIZE; if (IS_ENABLED(CONFIG_RELOCATABLE)) { unsigned long barebox_base = arm_mem_barebox_image(membase, endmem, barebox_size); relocate_to_adr(barebox_base); } setup_c(); barrier(); pr_debug("memory at 0x%08lx, size 0x%08lx\n", membase, memsize); arm_stack_top = endmem; arm_barebox_size = barebox_size; malloc_end = arm_mem_barebox_image(membase, endmem, arm_barebox_size); if (IS_ENABLED(CONFIG_MMU_EARLY)) { unsigned long ttb = arm_mem_ttb(membase, endmem); if (IS_ENABLED(CONFIG_PBL_IMAGE)) { arm_set_cache_functions(); } else { pr_debug("enabling MMU, ttb @ 0x%08lx\n", ttb); arm_early_mmu_cache_invalidate(); mmu_early_enable(membase, memsize, ttb); } } if (boarddata) { uint32_t totalsize = 0; const char *name; if (blob_is_fdt(boarddata)) { totalsize = get_unaligned_be32(boarddata + 4); name = "DTB"; } else if (blob_is_compressed_fdt(boarddata)) { struct barebox_arm_boarddata_compressed_dtb *bd = boarddata; totalsize = bd->datalen + sizeof(*bd); name = "Compressed DTB"; } else if (blob_is_arm_boarddata(boarddata)) { totalsize = sizeof(struct barebox_arm_boarddata); name = "machine type"; } if (totalsize) { unsigned long mem = arm_mem_boarddata(membase, endmem, totalsize); pr_debug("found %s in boarddata, copying to 0x%08lx\n", name, mem); barebox_boarddata = memcpy((void *)mem, boarddata, totalsize); barebox_boarddata_size = totalsize; malloc_end = mem; } } /* * Maximum malloc space is the Kconfig value if given * or 1GB. */ if (MALLOC_SIZE > 0) { malloc_start = malloc_end - MALLOC_SIZE; if (malloc_start < membase) malloc_start = membase; } else { malloc_start = malloc_end - (malloc_end - membase) / 2; if (malloc_end - malloc_start > SZ_1G) malloc_start = malloc_end - SZ_1G; } pr_debug("initializing malloc pool at 0x%08lx (size 0x%08lx)\n", malloc_start, malloc_end - malloc_start); mem_malloc_init((void *)malloc_start, (void *)malloc_end - 1); pr_debug("starting barebox...\n"); start_barebox(); }
/** * Called plainly from assembler that switches from real to flat mode * * @note The C environment isn't initialized yet */ void uboot_entry(void) { /* clear the BSS first */ memset(__bss_start, 0x00, __bss_stop - __bss_start); start_barebox(); }
int main(int argc, char *argv[]) { void *ram; int opt, ret, fd; int malloc_size = CONFIG_MALLOC_SIZE; int fdno = 0, envno = 0, option_index = 0; while (1) { option_index = 0; opt = getopt_long(argc, argv, optstring, long_options, &option_index); if (opt == -1) break; switch (opt) { case 'h': print_usage(basename(argv[0])); exit(0); case 'm': malloc_size = strtoul(optarg, NULL, 0); break; case 'i': break; case 'e': break; case 'd': ret = add_dtb(optarg); if (ret) { printf("Failed to load dtb: '%s'\n", optarg); exit(1); } break; case 'O': fd = open(optarg, O_WRONLY); if (fd < 0) { perror("open"); exit(1); } barebox_register_console("cout", -1, fd); break; case 'I': fd = open(optarg, O_RDWR); if (fd < 0) { perror("open"); exit(1); } barebox_register_console("cin", fd, -1); break; case 'x': sdl_xres = strtoul(optarg, NULL, 0); break; case 'y': sdl_yres = strtoul(optarg, NULL, 0); break; default: exit(1); } } ram = malloc(malloc_size); if (!ram) { printf("unable to get malloc space\n"); exit(1); } mem_malloc_init(ram, ram + malloc_size - 1); /* * Reset getopt. * We need to run a second getopt to count -i parameters. * This is for /dev/fd# devices. */ optind = 1; while (1) { option_index = 0; opt = getopt_long(argc, argv, optstring, long_options, &option_index); if (opt == -1) break; switch (opt) { case 'i': ret = add_image(optarg, "fd%d", &fdno); if (ret) exit(1); break; case 'e': ret = add_image(optarg, "env%d", &envno); if (ret) exit(1); break; default: break; } } barebox_register_console("console", fileno(stdin), fileno(stdout)); rawmode(); start_barebox(); /* never reached */ return 0; }