Skip to content

Commit

Permalink
[fixup] core: init dt when no DTB observed from TL
Browse files Browse the repository at this point in the history
Enhance the backwards compatibility to try to map the pass-in
DTB PA when no DTB exists in TL.
Fix coding style issues.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
  • Loading branch information
raymo200915 committed Sep 21, 2023
1 parent df66d71 commit 6fb3c95
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 95 deletions.
35 changes: 21 additions & 14 deletions core/include/kernel/transfer_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

// version of the register convention used.
// Set to 1 for both AArch64 and AArch32 according to fw handoff spec v0.9
#define REGISTER_CONVENTION_VERSION_MASK (1 << 24)
#define REGISTER_CONVENTION_VERSION_MASK BIT(24)

// transfer list operation codes
#define TL_OPS_NON U(0) // invalid for any operation
#define TL_OPS_ALL U(1) // valid for all operations
#define TL_OPS_RO U(2) // valid for read only
#define TL_OPS_CUS U(3) // either abort or switch to special code to interpret
#define TL_OPS_NON U(0) // invalid for any operation
#define TL_OPS_ALL U(1) // valid for all operations
#define TL_OPS_RO U(2) // valid for read only
#define TL_OPS_CUS U(3) // either abort or special code to interpret

#ifndef __ASSEMBLER__

Expand Down Expand Up @@ -84,8 +84,9 @@ void transfer_list_unmap_nosync(struct transfer_list_header *tl);
void transfer_list_dump(struct transfer_list_header *tl);
struct transfer_list_header *transfer_list_init(void *pa, size_t max_size);

struct transfer_list_header *transfer_list_relocate(struct transfer_list_header *tl,
void *pa, size_t max_size);
struct transfer_list_header *transfer_list_relocate
(struct transfer_list_header *tl,
void *pa, size_t max_size);
int transfer_list_check_header(const struct transfer_list_header *tl);

void transfer_list_update_checksum(struct transfer_list_header *tl);
Expand All @@ -96,18 +97,24 @@ bool transfer_list_set_data_size(struct transfer_list_header *tl,
uint32_t new_data_size);

void *transfer_list_entry_data(struct transfer_list_entry *entry);
bool transfer_list_rem(struct transfer_list_header *tl, struct transfer_list_entry *entry);
bool transfer_list_rem(struct transfer_list_header *tl,
struct transfer_list_entry *entry);

struct transfer_list_entry *transfer_list_add(struct transfer_list_header *tl,
uint16_t tag_id, uint32_t data_size,
uint16_t tag_id,
uint32_t data_size,
const void *data);

struct transfer_list_entry *transfer_list_add_with_align(struct transfer_list_header *tl,
uint16_t tag_id, uint32_t data_size,
const void *data, uint8_t alignment);
struct transfer_list_entry *transfer_list_add_with_align
(struct transfer_list_header *tl,
uint16_t tag_id,
uint32_t data_size,
const void *data,
uint8_t alignment);

struct transfer_list_entry *transfer_list_next(struct transfer_list_header *tl,
struct transfer_list_entry *last);
struct transfer_list_entry *transfer_list_next
(struct transfer_list_header *tl,
struct transfer_list_entry *last);

struct transfer_list_entry *transfer_list_find(struct transfer_list_header *tl,
uint16_t tag_id);
Expand Down
13 changes: 8 additions & 5 deletions core/kernel/dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,12 @@ void init_external_dt(unsigned long phys_dt)
if (!IS_ENABLED(CFG_EXTERNAL_DT))
return;

if (IS_ENABLED(CFG_TRANSFER_LIST)) {
if (IS_ENABLED(CFG_TRANSFER_LIST))
// get DTB from the mapped TL
fdt = transfer_list_entry_data
(transfer_list_find(dt->tl, TL_TAG_FDT));
if (!fdt)
panic("No mapped DTB found from TL");
} else {
// map the DTB

if (!fdt) {
if (!phys_dt) {
/*
* No need to panic as we're not using the DT in OP-TEE
Expand All @@ -576,6 +574,10 @@ void init_external_dt(unsigned long phys_dt)
return;
}

/*
* if DTB does not exist in the mapped TL,
* try to map the PA for backwards compatibility
*/
fdt = core_mmu_add_mapping(MEM_AREA_EXT_DT, phys_dt,
CFG_DTB_MAX_SIZE);
if (!fdt)
Expand Down Expand Up @@ -635,6 +637,7 @@ static TEE_Result release_external_dt(void)
transfer_list_entry_data(te));
transfer_list_set_data_size
(tl, te, fdt_totalsize(external_dt.blob));

transfer_list_unmap_sync(tl); // unmap the TL
}
} else if (core_mmu_remove_mapping(MEM_AREA_EXT_DT, external_dt.blob,
Expand Down
Loading

0 comments on commit 6fb3c95

Please sign in to comment.