summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke go <sangch.go@gmail.com>2021-07-20 04:13:13 +0300
committerDongjin Kim <tobetter@gmail.com>2021-12-11 12:24:03 +0300
commiteec8e7803c46ca4a817879394c84a9b9000c1348 (patch)
tree5ea488525d252ebbd72e7215c44d5404c2f129a1
parentdde526ccf457d8fba53b00a035ec22df155f9e54 (diff)
downloadu-boot-eec8e7803c46ca4a817879394c84a9b9000c1348.tar.xz
ODROID-COMMON: renamed and replaced android_bootloader msg stuffs.
- Rockchip used their's bootloader_message structures instead of original bootloader_message structures. This commit replaced it to original stuffs. Change-Id: I094622d4866287b6e5de1d2805319eb6fffc5aff
-rw-r--r--arch/arm/mach-rockchip/boot_mode.c1
-rw-r--r--arch/arm/mach-rockchip/boot_rkimg.c1
-rw-r--r--arch/arm/mach-rockchip/spl.c1
-rw-r--r--common/android_ab.c26
-rw-r--r--common/android_bootloader.c12
-rw-r--r--include/android_bootloader_message.h29
-rw-r--r--include/boot_rkimg.h16
7 files changed, 37 insertions, 49 deletions
diff --git a/arch/arm/mach-rockchip/boot_mode.c b/arch/arm/mach-rockchip/boot_mode.c
index cd5a6a2135..2ed1a9112d 100644
--- a/arch/arm/mach-rockchip/boot_mode.c
+++ b/arch/arm/mach-rockchip/boot_mode.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <boot_rkimg.h>
+#include <android_bootloader_message.h>
#include <malloc.h>
#include <asm/io.h>
#include <asm/arch/boot_mode.h>
diff --git a/arch/arm/mach-rockchip/boot_rkimg.c b/arch/arm/mach-rockchip/boot_rkimg.c
index 89c554b879..1281b72833 100644
--- a/arch/arm/mach-rockchip/boot_rkimg.c
+++ b/arch/arm/mach-rockchip/boot_rkimg.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <adc.h>
#include <android_bootloader.h>
+#include <android_bootloader_message.h>
#include <android_image.h>
#include <bidram.h>
#include <bootm.h>
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index 58cf3a63ff..ae59a7d187 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <boot_rkimg.h>
+#include <android_bootloader_message.h>
#include <debug_uart.h>
#include <dm.h>
#include <key.h>
diff --git a/common/android_ab.c b/common/android_ab.c
index 2182d3da50..8691f314e8 100644
--- a/common/android_ab.c
+++ b/common/android_ab.c
@@ -21,20 +21,20 @@
* the CRC-32 calculation.
*/
static uint32_t android_boot_control_compute_crc(
- struct android_bootloader_control *abc)
+ struct bootloader_control *abc)
{
return crc32(0, (void *)abc, offsetof(typeof(*abc), crc32_le));
}
-/** android_boot_control_default - Initialize android_bootloader_control to the
+/** android_boot_control_default - Initialize bootloader_control to the
* default value which allows to boot all slots in order from the first one.
* This value should be used when the bootloader message is corrupted, but not
* when a valid message indicates that all slots are unbootable.
*/
-void android_boot_control_default(struct android_bootloader_control *abc)
+void android_boot_control_default(struct bootloader_control *abc)
{
int i;
- const struct android_slot_metadata metadata = {
+ const struct slot_metadata metadata = {
.priority = 15,
.tries_remaining = 7,
.successful_boot = 0,
@@ -70,7 +70,7 @@ static void *android_boot_control_create_from_disk(
ulong abc_offset, abc_blocks;
void *buf;
- abc_offset = offsetof(struct android_bootloader_message_ab,
+ abc_offset = offsetof(struct bootloader_message_ab,
slot_suffix);
if (abc_offset % part_info->blksz) {
printf("ANDROID: Boot control block not block aligned.\n");
@@ -78,7 +78,7 @@ static void *android_boot_control_create_from_disk(
}
abc_offset /= part_info->blksz;
- abc_blocks = DIV_ROUND_UP(sizeof(struct android_bootloader_control),
+ abc_blocks = DIV_ROUND_UP(sizeof(struct bootloader_control),
part_info->blksz);
if (abc_offset + abc_blocks > part_info->size) {
printf("ANDROID: boot control partition too small. Need at"
@@ -116,9 +116,9 @@ static int android_boot_control_store(void *abc_data_block,
{
ulong abc_offset, abc_blocks;
- abc_offset = offsetof(struct android_bootloader_message_ab,
+ abc_offset = offsetof(struct bootloader_message_ab,
slot_suffix) / part_info->blksz;
- abc_blocks = DIV_ROUND_UP(sizeof(struct android_bootloader_control),
+ abc_blocks = DIV_ROUND_UP(sizeof(struct bootloader_control),
part_info->blksz);
if (blk_dwrite(dev_desc, part_info->start + abc_offset, abc_blocks,
abc_data_block) != abc_blocks) {
@@ -135,8 +135,8 @@ static int android_boot_control_store(void *abc_data_block,
* @return negative if the slot "a" is better, positive of the slot "b" is
* better or 0 if they are equally good.
*/
-static int android_ab_compare_slots(const struct android_slot_metadata *a,
- const struct android_slot_metadata *b)
+static int android_ab_compare_slots(const struct slot_metadata *a,
+ const struct slot_metadata *b)
{
/* Higher priority is better */
if (a->priority != b->priority)
@@ -155,7 +155,7 @@ static int android_ab_compare_slots(const struct android_slot_metadata *a,
int android_ab_select(struct blk_desc *dev_desc, disk_partition_t *part_info)
{
- struct android_bootloader_control *abc;
+ struct bootloader_control *abc;
u32 crc32_le;
int slot, i;
bool store_needed = false;
@@ -274,7 +274,7 @@ int read_misc_virtual_ab_message(struct misc_virtual_ab_message *message)
{
struct blk_desc *dev_desc;
disk_partition_t part_info;
- u32 bcb_offset = (ANDROID_VIRTUAL_AB_METADATA_OFFSET_IN_MISC >> 9);
+ u32 bcb_offset = (VIRTUAL_AB_METADATA_OFFSET_IN_MISC >> 9);
int cnt, ret;
if (!message) {
@@ -308,7 +308,7 @@ int write_misc_virtual_ab_message(struct misc_virtual_ab_message *message)
{
struct blk_desc *dev_desc;
disk_partition_t part_info;
- u32 bcb_offset = (ANDROID_VIRTUAL_AB_METADATA_OFFSET_IN_MISC >> 9);
+ u32 bcb_offset = (VIRTUAL_AB_METADATA_OFFSET_IN_MISC >> 9);
int cnt, ret;
if (!message) {
diff --git a/common/android_bootloader.c b/common/android_bootloader.c
index 52d4d0131d..952eecda98 100644
--- a/common/android_bootloader.c
+++ b/common/android_bootloader.c
@@ -34,9 +34,9 @@ DECLARE_GLOBAL_DATA_PTR;
int android_bootloader_message_load(
struct blk_desc *dev_desc,
const disk_partition_t *part_info,
- struct android_bootloader_message *message)
+ struct bootloader_message *message)
{
- ulong message_blocks = sizeof(struct android_bootloader_message) /
+ ulong message_blocks = sizeof(struct bootloader_message) /
part_info->blksz;
if (message_blocks > part_info->size) {
printf("misc partition too small.\n");
@@ -56,9 +56,9 @@ int android_bootloader_message_load(
static int android_bootloader_message_write(
struct blk_desc *dev_desc,
const disk_partition_t *part_info,
- struct android_bootloader_message *message)
+ struct bootloader_message *message)
{
- ulong message_blocks = sizeof(struct android_bootloader_message) /
+ ulong message_blocks = sizeof(struct bootloader_message) /
part_info->blksz + android_bcb_msg_sector_offset();
if (message_blocks > part_info->size) {
@@ -79,7 +79,7 @@ static enum android_boot_mode android_bootloader_load_and_clear_mode(
struct blk_desc *dev_desc,
const disk_partition_t *misc_part_info)
{
- struct android_bootloader_message bcb;
+ struct bootloader_message bcb;
#ifdef CONFIG_FASTBOOT
char *bootloader_str;
@@ -121,7 +121,7 @@ static enum android_boot_mode android_bootloader_load_and_clear_mode(
int android_bcb_write(char *cmd)
{
- struct android_bootloader_message message = {0};
+ struct bootloader_message message = {0};
disk_partition_t part_info;
struct blk_desc *dev_desc;
int ret;
diff --git a/include/android_bootloader_message.h b/include/android_bootloader_message.h
index 9fa8cf0d2e..c3c513b532 100644
--- a/include/android_bootloader_message.h
+++ b/include/android_bootloader_message.h
@@ -26,9 +26,9 @@
* Note that these offsets are admitted by bootloader,recovery and uncrypt, so they
* are not configurable without changing all of them.
*/
-static const size_t ANDROID_BOOTLOADER_MESSAGE_OFFSET_IN_MISC = 0;
-static const size_t ANDROID_WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024;
-static const size_t ANDROID_VIRTUAL_AB_METADATA_OFFSET_IN_MISC = 32 * 1024;
+static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = 0;
+static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024;
+static const size_t VIRTUAL_AB_METADATA_OFFSET_IN_MISC = 32 * 1024;
/* Bootloader Message (2-KiB)
*
@@ -58,7 +58,7 @@ static const size_t ANDROID_VIRTUAL_AB_METADATA_OFFSET_IN_MISC = 32 * 1024;
* uncrypt. Move it into struct bootloader_message_ab to avoid the
* issue.
*/
-struct android_bootloader_message {
+struct bootloader_message {
char command[32];
char status[32];
char recovery[768];
@@ -82,7 +82,7 @@ struct android_bootloader_message {
* because A/B-specific fields may end up with different offsets.
*/
#if (__STDC_VERSION__ >= 201112L) || defined(__cplusplus)
-static_assert(sizeof(struct android_bootloader_message) == 2048,
+static_assert(sizeof(struct bootloader_message) == 2048,
"struct bootloader_message size changes, which may break A/B devices");
#endif
@@ -102,12 +102,13 @@ static_assert(sizeof(struct android_bootloader_message) == 2048,
* data past the first NUL-byte in this field. It is encouraged, but
* not mandatory, to use 'struct bootloader_control' described below.
*/
-struct android_bootloader_message_ab {
- struct android_bootloader_message message;
+struct bootloader_message_ab {
+ struct bootloader_message message;
char slot_suffix[32];
+ char update_channel[128];
/* Round up the entire struct to 4096-byte. */
- char reserved[2016];
+ char reserved[1888];
};
/**
@@ -115,14 +116,14 @@ struct android_bootloader_message_ab {
* bootloader_message_ab struct (b/29159185).
*/
#if (__STDC_VERSION__ >= 201112L) || defined(__cplusplus)
-static_assert(sizeof(struct android_bootloader_message_ab) == 4096,
+static_assert(sizeof(struct bootloader_message_ab) == 4096,
"struct bootloader_message_ab size changes");
#endif
#define ANDROID_BOOT_CTRL_MAGIC 0x42414342 /* Bootloader Control AB */
#define ANDROID_BOOT_CTRL_VERSION 1
-struct android_slot_metadata {
+struct slot_metadata {
/* Slot priority with 15 meaning highest priority, 1 lowest
* priority and 0 the slot is unbootable. */
uint8_t priority : 4;
@@ -145,7 +146,7 @@ struct android_slot_metadata {
* 'bootloader_control' structure to store the A/B metadata, but not
* mandatory.
*/
-struct android_bootloader_control {
+struct bootloader_control {
/* NUL terminated active slot suffix. */
char slot_suffix[4];
/* Bootloader Control AB magic number (see BOOT_CTRL_MAGIC). */
@@ -159,7 +160,7 @@ struct android_bootloader_control {
/* Ensure 4-bytes alignment for slot_info field. */
uint8_t reserved0[2];
/* Per-slot information. Up to 4 slots. */
- struct android_slot_metadata slot_info[4];
+ struct slot_metadata slot_info[4];
/* Reserved for further use. */
uint8_t reserved1[8];
/* CRC32 of all 28 bytes preceding this field (little endian
@@ -168,8 +169,8 @@ struct android_bootloader_control {
} __attribute__((packed));
#if (__STDC_VERSION__ >= 201112L) || defined(__cplusplus)
-static_assert(sizeof(struct android_bootloader_control) ==
- sizeof(((struct android_bootloader_message_ab *)0)->slot_suffix),
+static_assert(sizeof(struct bootloader_control) ==
+ sizeof(((struct bootloader_message_ab *)0)->slot_suffix),
"struct bootloader_control has wrong size");
#endif
diff --git a/include/boot_rkimg.h b/include/boot_rkimg.h
index 4e9643b3b1..c288ee69dd 100644
--- a/include/boot_rkimg.h
+++ b/include/boot_rkimg.h
@@ -22,22 +22,6 @@ enum _boot_mode {
BOOT_MODE_UNDEFINE,
};
-struct bootloader_message {
- char command[32];
- char status[32];
- char recovery[768];
- /*
- * The 'recovery' field used to be 1024 bytes. It has only ever
- * been used to store the recovery command line, so 768 bytes
- * should be plenty. We carve off the last 256 bytes to store the
- * stage string (for multistage packages) and possible future
- * expansion.
- */
- char stage[32];
- char slot_suffix[32];
- char reserved[192];
-};
-
struct rockchip_image {
uint32_t tag;
uint32_t size;