aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/abuf.h159
-rw-r--r--include/android_image.h14
-rw-r--r--include/configs/light-c910.h15
-rw-r--r--include/env_flags.h2
-rw-r--r--include/fdt_support.h13
5 files changed, 198 insertions, 5 deletions
diff --git a/include/abuf.h b/include/abuf.h
new file mode 100644
index 00000000..9badda64
--- /dev/null
+++ b/include/abuf.h
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Handles a buffer that can be allocated and freed
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __ABUF_H
+#define __ABUF_H
+
+#include <linux/types.h>
+
+/**
+ * struct abuf - buffer that can be allocated and freed
+ *
+ * This is useful for a block of data which may be allocated with malloc(), or
+ * not, so that it needs to be freed correctly when finished with.
+ *
+ * For now it has a very simple purpose.
+ *
+ * Using memset() to zero all fields is guaranteed to be equivalent to
+ * abuf_init().
+ *
+ * @data: Pointer to data
+ * @size: Size of data in bytes
+ * @alloced: true if allocated with malloc(), so must be freed after use
+ */
+struct abuf {
+ void *data;
+ size_t size;
+ bool alloced;
+};
+
+static inline void *abuf_data(const struct abuf *abuf)
+{
+ return abuf->data;
+}
+
+static inline size_t abuf_size(const struct abuf *abuf)
+{
+ return abuf->size;
+}
+
+/**
+ * abuf_set() - set the (unallocated) data in a buffer
+ *
+ * This simply makes the abuf point to the supplied data, which must be live
+ * for the lifetime of the abuf. It is not alloced.
+ *
+ * Any existing data in the abuf is freed and the alloced member is set to
+ * false.
+ *
+ * @abuf: abuf to adjust
+ * @data: New contents of abuf
+ * @size: New size of abuf
+ */
+void abuf_set(struct abuf *abuf, void *data, size_t size);
+
+/**
+ * abuf_map_sysmem() - calls map_sysmem() to set up an abuf
+ *
+ * This is equivalent to abuf_set(abuf, map_sysmem(addr, size), size)
+ *
+ * Any existing data in the abuf is freed and the alloced member is set to
+ * false.
+ *
+ * @abuf: abuf to adjust
+ * @addr: Address to set the abuf to
+ * @size: New size of abuf
+ */
+void abuf_map_sysmem(struct abuf *abuf, ulong addr, size_t size);
+
+/**
+ * abuf_realloc() - Change the size of a buffer
+ *
+ * This uses realloc() to change the size of the buffer, with the same semantics
+ * as that function. If the abuf is not currently alloced, then it will alloc
+ * it if the size needs to increase (i.e. set the alloced member to true)
+ *
+ * @abuf: abuf to adjust
+ * @new_size: new size in bytes.
+ * if 0, the abuf is freed
+ * if greater than the current size, the abuf is extended and the new
+ * space is not inited. The alloced member is set to true
+ * if less than the current size, the abuf is contracted and the data at
+ * the end is lost. If @new_size is 0, this sets the alloced member to
+ * false
+ * Return: true if OK, false if out of memory
+ */
+bool abuf_realloc(struct abuf *abuf, size_t new_size);
+
+/**
+ * abuf_uninit_move() - Return the allocated contents and uninit the abuf
+ *
+ * This returns the abuf data to the caller, allocating it if necessary, so that
+ * the caller receives data that it can be sure will hang around. The caller is
+ * responsible for freeing the data.
+ *
+ * If the abuf has allocated data, it is returned. If the abuf has data but it
+ * is not allocated, then it is first allocated, then returned.
+ *
+ * If the abuf size is 0, this returns NULL
+ *
+ * The abuf is uninited as part of this, except if the allocation fails, in
+ * which NULL is returned and the abuf remains untouched.
+ *
+ * The abuf must be inited before this can be called.
+ *
+ * @abuf: abuf to uninit
+ * @sizep: if non-NULL, returns the size of the returned data
+ * Return: data contents, allocated with malloc(), or NULL if the data could not
+ * be allocated, or the data size is 0
+ */
+void *abuf_uninit_move(struct abuf *abuf, size_t *sizep);
+
+/**
+ * abuf_init_move() - Make abuf take over the management of an allocated region
+ *
+ * After this, @data must not be used. All access must be via the abuf.
+ *
+ * @abuf: abuf to init
+ * @data: Existing allocated buffer to place in the abuf
+ * @size: Size of allocated buffer
+ */
+void abuf_init_move(struct abuf *abuf, void *data, size_t size);
+
+/**
+ * abuf_init_set() - Set up a new abuf
+ *
+ * Inits a new abuf and sets up its (unallocated) data
+ *
+ * @abuf: abuf to set up
+ * @data: New contents of abuf
+ * @size: New size of abuf
+ */
+void abuf_init_set(struct abuf *abuf, void *data, size_t size);
+
+/**
+ * abuf_uninit() - Free any memory used by an abuf
+ *
+ * The buffer must be inited before this can be called.
+ *
+ * @abuf: abuf to uninit
+ */
+void abuf_uninit(struct abuf *abuf);
+
+/**
+ * abuf_init() - Set up a new abuf
+ *
+ * This initially has no data and alloced is set to false. This is equivalent to
+ * setting all fields to 0, e.g. with memset(), so callers can do that instead
+ * if desired.
+ *
+ * @abuf: abuf to set up
+ */
+void abuf_init(struct abuf *abuf);
+
+#endif
diff --git a/include/android_image.h b/include/android_image.h
index 54d25af0..2a784607 100644
--- a/include/android_image.h
+++ b/include/android_image.h
@@ -136,4 +136,18 @@ struct andr_img_hdr {
* else: jump to kernel_addr
*/
+#define VENDOR_RAMDISK_NAME_SIZE 32
+#define VENDOR_RAMDISK_TABLE_ENTRY_BOARD_ID_SIZE 16
+
+#define VENDOR_RAMDISK_TYPE_RECOVERY 2
+struct vendor_ramdisk_table_entry {
+ u32 ramdisk_size; /* size in bytes for the ramdisk image */
+ u32 ramdisk_offset; /* offset to the ramdisk image in vendor ramdisk section */
+ u32 ramdisk_type; /* type of the ramdisk */
+ u8 ramdisk_name[VENDOR_RAMDISK_NAME_SIZE]; /* asciiz ramdisk name */
+
+ // Hardware identifiers describing the board, soc or platform which this
+ // ramdisk is intended to be loaded on.
+ u32 board_id[VENDOR_RAMDISK_TABLE_ENTRY_BOARD_ID_SIZE];
+} __attribute__((packed));
#endif
diff --git a/include/configs/light-c910.h b/include/configs/light-c910.h
index eb4fff54..baaa2966 100644
--- a/include/configs/light-c910.h
+++ b/include/configs/light-c910.h
@@ -77,11 +77,13 @@
#define TF_IMG_UPD_NAME "stashtf"
#define TEE_IMG_UPD_NAME "stashtee"
#define UBOOT_IMG_UPD_NAME "stashuboot"
+#define SBMETA_IMG_UPD_NAME "stashsbmeta"
#define TF_PART_NAME "tf"
#define TEE_PART_NAME "tee"
#define UBOOT_PART_NAME "uboot"
#define STASH_PART_NAME "stash"
#define KERNEL_PART_NAME "kernel"
+#define SBMETA_PART_NAME "sbmeta"
#define UBOOT_STAGE_ADDR SRAM_BASE_ADDR
@@ -96,6 +98,7 @@
#define TF_SEC_UPGRADE_FLAG 0x5555aaaa
#define TEE_SEC_UPGRADE_FLAG 0x5a5aa5a5
#define UBOOT_SEC_UPGRADE_FLAG 0xa5a5aa55
+#define SBMETA_SEC_UPGRADE_FLAG 0xaaaa5555
/* Define secure debug log level */
#define LOG_LEVEL 1
@@ -116,9 +119,13 @@
#define ENV_KERNEL_LOGLEVEL "kernel_loglevel=7\0"
#define ENV_STR_BOOT_DELAY
#define CONFIG_ENV_OVERWRITE
+#define ENV_STR_SERIAL "serial#=1234567890\0"
+#define ENV_KERNEL_KDUMP "kdump_buf=180M\0"
#else
#define ENV_KERNEL_LOGLEVEL "kernel_loglevel=4\0"
#define ENV_STR_BOOT_DELAY "bootdelay=0\0"
+#define ENV_STR_SERIAL "serial#=\0"
+#define ENV_KERNEL_KDUMP "kdump_buf=0M\0"
#endif
#define CONFIG_MISC_INIT_R
@@ -129,19 +136,19 @@
"scriptaddr=0x00500000\0" \
"pxefile_addr_r=0x00600000\0" \
"dtb_addr=0x03800000\0" \
- "fdt_addr=0x03800000\0" \
+ "fdt_addr_r=0x03800000\0" \
"kernel_addr_r=0x00200000\0" \
"ramdisk_addr_r=0x06000000\0" \
"boot_conf_addr_r=0xc0000000\0" \
"aon_ram_addr=0xffffef8000\0" \
"audio_ram_addr=0x32000000\0" \
- "str_ram_addr=0xffe0000000\0" \
+ "str_ram_addr=0xffe0000000\0" \
"opensbi_addr=0x0\0" \
"fwaddr=0x10000000\0" \
"splashimage=0x30000000\0" \
"splashpos=m,m\0" \
"fdt_high=0xffffffffffffffff\0" \
- ENV_STR_BOARD \
+ ENV_STR_BOARD \
"kernel_addr_r=0x00200000\0" \
"kdump_buf=180M\0" \
"mmcdev=0\0" \
@@ -158,4 +165,4 @@
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"\0"
-#endif /* __CONFIG_H */ \ No newline at end of file
+#endif /* __CONFIG_H */
diff --git a/include/env_flags.h b/include/env_flags.h
index 7b8bf7b7..e343c5d7 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -81,7 +81,7 @@ enum env_flags_varaccess {
NET_FLAGS \
SERIAL_FLAGS \
CONFIG_ENV_FLAGS_LIST_STATIC \
- BOARD_FLAGS
+ BOARD_FLAGS
#ifdef CONFIG_CMD_ENV_FLAGS
/*
diff --git a/include/fdt_support.h b/include/fdt_support.h
index a5bdf2f6..f0c09516 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -10,6 +10,7 @@
#ifdef CONFIG_OF_LIBFDT
#include <linux/libfdt.h>
+#include <abuf.h>
u32 fdt_getprop_u32_default_node(const void *fdt, int off, int cell,
const char *prop, const u32 dflt);
@@ -170,6 +171,18 @@ int fdt_find_or_add_subnode(void *fdt, int parentoffset, const char *name);
*/
int ft_board_setup(void *blob, bd_t *bd);
+/**
+ * board_rng_seed() - Provide a seed to be passed via /chosen/rng-seed
+ *
+ * This function is called if CONFIG_BOARD_RNG_SEED is set, and must
+ * be provided by the board. It should return, via @buf, some suitable
+ * seed value to pass to the kernel.
+ *
+ * @param buf A struct abuf for returning the seed and its size.
+ * @return 0 if ok, negative on error.
+ */
+int board_rng_seed(struct abuf *buf);
+
/*
* The keystone2 SOC requires all 32 bit aliased addresses to be converted
* to their 36 physical format. This has to happen after all fdt nodes