arch: rockchip: support resource file in spl
Change-Id: I00a1d9731554cf401b0a82e6d4f07440af1f554d Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
This commit is contained in:
parent
fec9980f93
commit
8956822660
|
|
@ -0,0 +1,93 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2020 Rockchip Electronics Co., Ltd
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SPL_RESOURCE_IMG_H_
|
||||||
|
#define _SPL_RESOURCE_IMG_H_
|
||||||
|
|
||||||
|
#define RESOURCE_MAGIC "RSCE"
|
||||||
|
#define RESOURCE_MAGIC_SIZE 4
|
||||||
|
#define RESOURCE_VERSION 0
|
||||||
|
#define CONTENT_VERSION 0
|
||||||
|
#define ENTRY_TAG "ENTR"
|
||||||
|
#define ENTRY_TAG_SIZE 4
|
||||||
|
#define MAX_FILE_NAME_LEN 220
|
||||||
|
#define MAX_HASH_LEN 32
|
||||||
|
|
||||||
|
#define DTB_FILE "rk-kernel.dtb"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* resource image structure
|
||||||
|
* ----------------------------------------------
|
||||||
|
* | |
|
||||||
|
* | header (1 block) |
|
||||||
|
* | |
|
||||||
|
* ---------------------------------------------|
|
||||||
|
* | | |
|
||||||
|
* | entry0 (1 block) | |
|
||||||
|
* | | |
|
||||||
|
* ------------------------ |
|
||||||
|
* | | |
|
||||||
|
* | entry1 (1 block) | contents (n blocks) |
|
||||||
|
* | | |
|
||||||
|
* ------------------------ |
|
||||||
|
* | ...... | |
|
||||||
|
* ------------------------ |
|
||||||
|
* | | |
|
||||||
|
* | entryn (1 block) | |
|
||||||
|
* | | |
|
||||||
|
* ----------------------------------------------
|
||||||
|
* | |
|
||||||
|
* | file0 (x blocks) |
|
||||||
|
* | |
|
||||||
|
* ----------------------------------------------
|
||||||
|
* | |
|
||||||
|
* | file1 (y blocks) |
|
||||||
|
* | |
|
||||||
|
* ----------------------------------------------
|
||||||
|
* | ...... |
|
||||||
|
* |---------------------------------------------
|
||||||
|
* | |
|
||||||
|
* | filen (z blocks) |
|
||||||
|
* | |
|
||||||
|
* ----------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct resource_image_header
|
||||||
|
*
|
||||||
|
* @magic: should be "RSCE"
|
||||||
|
* @version: resource image version, current is 0
|
||||||
|
* @c_version: content version, current is 0
|
||||||
|
* @blks: the size of the header ( 1 block = 512 bytes)
|
||||||
|
* @c_offset: contents offset(by block) in the image
|
||||||
|
* @e_blks: the size(by block) of the entry in the contents
|
||||||
|
* @e_num: numbers of the entries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct resource_img_hdr {
|
||||||
|
char magic[4];
|
||||||
|
uint16_t version;
|
||||||
|
uint16_t c_version;
|
||||||
|
uint8_t blks;
|
||||||
|
uint8_t c_offset;
|
||||||
|
uint8_t e_blks;
|
||||||
|
uint32_t e_nums;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct resource_entry {
|
||||||
|
char tag[4];
|
||||||
|
char name[MAX_FILE_NAME_LEN];
|
||||||
|
char hash[MAX_HASH_LEN];
|
||||||
|
uint32_t hash_size;
|
||||||
|
uint32_t f_offset;
|
||||||
|
uint32_t f_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
int spl_resource_image_check_header(const struct resource_img_hdr *hdr);
|
||||||
|
|
||||||
|
struct resource_entry *
|
||||||
|
spl_resource_image_get_dtb_entry(const struct resource_img_hdr *hdr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -36,6 +36,7 @@ endif
|
||||||
|
|
||||||
obj-$(CONFIG_$(SPL_TPL_)RAM) += param.o
|
obj-$(CONFIG_$(SPL_TPL_)RAM) += param.o
|
||||||
obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram.o
|
obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram.o
|
||||||
|
obj-$(CONFIG_SPL_KERNEL_BOOT) += spl_resource_img.o
|
||||||
|
|
||||||
obj-$(CONFIG_ROCKCHIP_PX30) += px30/
|
obj-$(CONFIG_ROCKCHIP_PX30) += px30/
|
||||||
obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
|
obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Fuzhou Rockchip Electronics Co., Ltd
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
#include <linux/list.h>
|
||||||
|
#include <asm/arch/spl_resource_img.h>
|
||||||
|
|
||||||
|
int spl_resource_image_check_header(const struct resource_img_hdr *hdr)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = memcmp(RESOURCE_MAGIC, hdr->magic, RESOURCE_MAGIC_SIZE);
|
||||||
|
if (ret) {
|
||||||
|
debug("bad resource image magic: %s\n",
|
||||||
|
hdr->magic ? hdr->magic : "none");
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("resource image header:\n");
|
||||||
|
debug("magic:%s\n", hdr->magic);
|
||||||
|
debug("version:%d\n", hdr->version);
|
||||||
|
debug("c_version:%d\n", hdr->c_version);
|
||||||
|
debug("blks:%d\n", hdr->blks);
|
||||||
|
debug("c_offset:%d\n", hdr->c_offset);
|
||||||
|
debug("e_blks:%d\n", hdr->e_blks);
|
||||||
|
debug("e_num:%d\n", hdr->e_nums);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct resource_entry *spl_resource_image_get_dtb_entry(const struct
|
||||||
|
resource_img_hdr *hdr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct resource_entry *entry = NULL;
|
||||||
|
|
||||||
|
if (!hdr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < hdr->e_nums; i++) {
|
||||||
|
entry = (struct resource_entry *)((char *)hdr
|
||||||
|
+ (hdr->blks + hdr->e_blks * i) * 512);
|
||||||
|
if (!memcmp(entry->name, DTB_FILE, strlen(DTB_FILE)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue