blob: b9bf136fc7c578e73a0a6c3a2890a84839af5404 [file] [log] [blame] [edit]
/*
* Copyright (c) 2018 The Fuchsia Authors
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <image.h>
#include <zbi/zbi.h>
#include <zircon/boot/image.h>
/**
* zircon_image_get_kernel() - processes kernel part of Zircon bootdata
* @bootdata: Pointer to bootdata.
* @verify: Checksum verification flag. Currently unimplemented.
* @os_data: Pointer to a ulong variable, will hold os data start
* address.
* @os_len: Pointer to a ulong variable, will hold os data length.
*
* This function returns the os image's start address and length. Also,
* it appends the kernel command line to the bootargs env variable.
*
* Return: Zero, os start address and length on success,
* otherwise on failure.
*/
int zircon_image_get_kernel(const void *hdr, int verify, ulong *os_data,
ulong *os_len)
{
if (zbi_check_bootable(hdr, NULL) != ZBI_RESULT_OK) {
return -1;
}
const zbi_header_t *zbi = hdr;
*os_data = (ulong)zbi;
*os_len = zbi->length + sizeof(*zbi);
return 0;
}
ulong zircon_image_get_end(const void *hdr)
{
const zbi_header_t *zbi = hdr;
return (ulong)hdr + zbi->length + sizeof(*zbi);
}
ulong zircon_image_get_kload(const void *hdr)
{
return simple_strtoul(getenv("loadaddr"), NULL, 16);
}
ulong zircon_image_get_comp(const void *hdr)
{
return IH_COMP_NONE;
}