示例#1
0
文件: commands.c 项目: M1cha/lk
static int do_boot(void *arg) {
	thread_sleep(250);

	/* sniff it to see if it's a bootimage or a raw image */
	bootimage_t *bi;
	if (bootimage_open(lkb_iobuffer, lkb_iobuffer_size, &bi) >= 0) {
		void *ptr;
		size_t len;

		/* it's a bootimage */
		TRACEF("detected bootimage\n");

		/* find the lk image */
		if (bootimage_get_file_section(bi, TYPE_LK, &ptr, &len) >= 0) {
			TRACEF("found lk section at %p\n", ptr);

			arch_chain_load(ptr, 5, 6, 7, 8);
		}
	} else {
		/* raw image, just chain load it directly */
		TRACEF("raw image, chainloading\n");
		arch_chain_load(lkb_iobuffer, 1, 2, 3, 4);
	}
	return 0;
}
示例#2
0
文件: commands.c 项目: 0xBADCA7/lk
static int chainload_thread(void *arg)
{
    struct chainload_args *args = (struct chainload_args *)arg;

    thread_sleep(250);

    TRACEF("chain loading address %p, args 0x%lx 0x%lx 0x%lx 0x%lx\n",
            args->func, args->args[0], args->args[1], args->args[2], args->args[3]);
    arch_chain_load((void *)args->func, args->args[0], args->args[1], args->args[2], args->args[3]);

    for (;;);
}
示例#3
0
static int cmd_chain(int argc, const cmd_args *argv)
{
    if (argc < 2) {
        printf("not enough arguments\n");
        printf("%s <address>\n", argv[0].str);
        return -1;
    }

    arch_chain_load(argv[1].p, 0, 0, 0, 0);

    return 0;
}
示例#4
0
文件: commands.c 项目: 0xBADCA7/lk
/* try to boot the system from a flash partition */
status_t do_flash_boot(void)
{
    status_t err;

    LTRACE_ENTRY;

    /* construct a boot argument list */
    const size_t bootargs_size = PAGE_SIZE;
#if 0
    /* old code */
    void *args = (void *)((uintptr_t)lkb_iobuffer + lkb_iobuffer_size - bootargs_size);
    paddr_t args_phys = lkb_iobuffer_phys + lkb_iobuffer_size - bootargs_size;
#elif PLATFORM_ZYNQ
    /* grab the top page of sram */
    paddr_t args_phys = SRAM_BASE + SRAM_SIZE - bootargs_size;
    void *args = paddr_to_kvaddr(args_phys);
#else
#error need better way
#endif
    LTRACEF("boot args %p, phys 0x%lx, len %zu\n", args, args_phys, bootargs_size);

    bootargs_start(args, bootargs_size);
    bootargs_add_command_line(args, bootargs_size, "what what");
    arch_clean_cache_range((vaddr_t)args, bootargs_size);

    ulong lk_args[4];
    bootargs_generate_lk_arg_values(args_phys, lk_args);

    const void *ptr;

    if (!ptable_found_valid()) {
        TRACEF("ptable not found\n");
        return ERR_NOT_FOUND;
    }

    /* find the system partition */
    struct ptable_entry entry;
    err = ptable_find("system", &entry);
    if (err < 0) {
        TRACEF("cannot find system partition\n");
        return ERR_NOT_FOUND;
    }

    /* get a direct pointer to the device */
    bdev_t *bdev = ptable_get_device();
    if (!bdev) {
        TRACEF("error opening boot device\n");
        return ERR_NOT_FOUND;
    }

    /* convert the bdev to a memory pointer */
    err = bio_ioctl(bdev, BIO_IOCTL_GET_MEM_MAP, (void *)&ptr);
    TRACEF("err %d, ptr %p\n", err, ptr);
    if (err < 0) {
        TRACEF("error getting direct pointer to block device\n");
        return ERR_NOT_FOUND;
    }

    /* sniff it to see if it's a bootimage or a raw image */
    bootimage_t *bi;
    if (bootimage_open((char *)ptr + entry.offset, entry.length, &bi) >= 0) {
        size_t len;

        /* it's a bootimage */
        TRACEF("detected bootimage\n");

        /* find the lk image */
        if (bootimage_get_file_section(bi, TYPE_LK, &ptr, &len) >= 0) {
            TRACEF("found lk section at %p\n", ptr);

            /* add the boot image to the argument list */
            size_t bootimage_size;
            bootimage_get_range(bi, NULL, &bootimage_size);

            bootargs_add_bootimage_pointer(args, bootargs_size, bdev->name, entry.offset, bootimage_size);
        }
    } else {
        /* did not find a bootimage, abort */
        bio_ioctl(bdev, BIO_IOCTL_PUT_MEM_MAP, NULL);
        return ERR_NOT_FOUND;
    }

    TRACEF("chain loading binary at %p\n", ptr);
    arch_chain_load((void *)ptr, lk_args[0], lk_args[1], lk_args[2], lk_args[3]);

    /* put the block device back into block mode (though we never get here) */
    bio_ioctl(bdev, BIO_IOCTL_PUT_MEM_MAP, NULL);

    return NO_ERROR;
}
示例#5
0
文件: commands.c 项目: chychc/lk
static int do_ramboot(void *arg) {
	thread_sleep(250);
	arch_chain_load(lkb_iobuffer);
	return 0;
}