blob: 252eadc4f83c592beb04c410839e3083327fcd0d [file] [log] [blame] [edit]
/*
* Copyright (c) 2018 The Fuchsia Authors
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <image.h>
#include <lib/zbi/zbi.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 0x1080000;
}
size_t zircon_image_get_capacity(const void *hdr)
{
// TODO(b/300537708) Come up with safe limit for capacity
return SIZE_MAX;
}
ulong zircon_image_get_comp(const void *hdr)
{
return IH_COMP_NONE;
}