Commit 408c3768 authored by danh-arm's avatar danh-arm
Browse files

Merge pull request #48 from danh-arm/dh/major-refactoring

dh/major refactoring
parents b495bdef 97043ac9
......@@ -29,16 +29,12 @@
#
TSPD_DIR := services/spd/tspd
SPD_INCLUDES := -Iinclude/spd/tspd \
-I${TSPD_DIR}
SPD_INCLUDES := -Iinclude/bl32/payloads
SPD_SOURCES := tspd_common.c \
tspd_main.c \
tspd_pm.c \
tspd_helpers.S
vpath %.c ${TSPD_DIR}
vpath %.S ${TSPD_DIR}
SPD_SOURCES := services/spd/tspd/tspd_common.c \
services/spd/tspd/tspd_helpers.S \
services/spd/tspd/tspd_main.c \
services/spd/tspd/tspd_pm.c
# This dispatcher is paired with a Test Secure Payload source and we intend to
# build the Test Secure Payload along with this dispatcher.
......
......@@ -28,16 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <arch_helpers.h>
#include <platform.h>
#include <assert.h>
#include <bl_common.h>
#include <runtime_svc.h>
#include <context_mgmt.h>
#include <tspd_private.h>
#include <platform.h>
#include <string.h>
#include "tspd_private.h"
/*******************************************************************************
* Given a secure payload entrypoint, register width, cpu id & pointer to a
......@@ -47,10 +44,10 @@
int32_t tspd_init_secure_context(uint64_t entrypoint,
uint32_t rw,
uint64_t mpidr,
tsp_context *tsp_ctx)
tsp_context_t *tsp_ctx)
{
uint32_t scr, sctlr;
el1_sys_regs *el1_state;
el1_sys_regs_t *el1_state;
uint32_t spsr;
/* Passing a NULL context is a critical programming error */
......@@ -110,7 +107,7 @@ int32_t tspd_init_secure_context(uint64_t entrypoint,
* 3. Calls el3_exit() so that the EL3 system and general purpose registers
* from the tsp_ctx->cpu_ctx are used to enter the secure payload image.
******************************************************************************/
uint64_t tspd_synchronous_sp_entry(tsp_context *tsp_ctx)
uint64_t tspd_synchronous_sp_entry(tsp_context_t *tsp_ctx)
{
uint64_t rc;
......@@ -138,7 +135,7 @@ uint64_t tspd_synchronous_sp_entry(tsp_context *tsp_ctx)
* 3. It does not need to save any general purpose or EL3 system register state
* as the generic smc entry routine should have saved those.
******************************************************************************/
void tspd_synchronous_sp_exit(tsp_context *tsp_ctx, uint64_t ret)
void tspd_synchronous_sp_exit(tsp_context_t *tsp_ctx, uint64_t ret)
{
/* Save the Secure EL1 system register context */
assert(cm_get_context(read_mpidr(), SECURE) == &tsp_ctx->cpu_ctx);
......
......@@ -28,10 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <context.h>
#include <tspd_private.h>
#include <asm_macros.S>
#include <cm_macros.S>
#include "tspd_private.h"
.global tspd_enter_sp
/* ---------------------------------------------
......
......@@ -38,31 +38,27 @@
* handle the request locally or delegate it to the Secure Payload. It is also
* responsible for initialising and maintaining communication with the SP.
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <assert.h>
#include <bl_common.h>
#include <bl31.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
#include <bl31.h>
#include <stddef.h>
#include <tsp.h>
#include <psci.h>
#include <tspd_private.h>
#include <debug.h>
#include <uuid.h>
#include "tspd_private.h"
/*******************************************************************************
* Single structure to hold information about the various entry points into the
* Secure Payload. It is initialised once on the primary core after a cold boot.
******************************************************************************/
entry_info *tsp_entry_info;
entry_info_t *tsp_entry_info;
/*******************************************************************************
* Array to keep track of per-cpu Secure Payload state
******************************************************************************/
tsp_context tspd_sp_context[TSPD_CORE_COUNT];
tsp_context_t tspd_sp_context[TSPD_CORE_COUNT];
/* TSP UID */
......@@ -70,7 +66,7 @@ DEFINE_SVC_UUID(tsp_uuid,
0x5b3056a0, 0x3291, 0x427b, 0x98, 0x11,
0x71, 0x68, 0xca, 0x50, 0xf3, 0xfa);
int32_t tspd_init(meminfo *bl32_meminfo);
int32_t tspd_init(meminfo_t *bl32_meminfo);
/*******************************************************************************
......@@ -80,7 +76,7 @@ int32_t tspd_init(meminfo *bl32_meminfo);
******************************************************************************/
int32_t tspd_setup(void)
{
el_change_info *image_info;
el_change_info_t *image_info;
int32_t rc;
uint64_t mpidr = read_mpidr();
uint32_t linear_id;
......@@ -133,12 +129,12 @@ int32_t tspd_setup(void)
* back to this routine through a SMC. It also passes the extents of memory made
* available to BL32 by BL31.
******************************************************************************/
int32_t tspd_init(meminfo *bl32_meminfo)
int32_t tspd_init(meminfo_t *bl32_meminfo)
{
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
uint64_t rc;
tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
/*
* Arrange for passing a pointer to the meminfo structure
......@@ -189,11 +185,11 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
void *handle,
uint64_t flags)
{
cpu_context *ns_cpu_context;
gp_regs *ns_gp_regs;
cpu_context_t *ns_cpu_context;
gp_regs_t *ns_gp_regs;
unsigned long mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr), ns;
tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
/* Determine which security state this SMC originated from */
ns = is_caller_non_secure(flags);
......@@ -213,7 +209,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
* only once on the primary cpu
*/
assert(tsp_entry_info == NULL);
tsp_entry_info = (entry_info *) x1;
tsp_entry_info = (entry_info_t *) x1;
/*
* SP reports completion. The SPD must have initiated
......
......@@ -28,19 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <assert.h>
#include <bl_common.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
#include <bl31.h>
#include <bl32.h>
#include <psci.h>
#include <tspd_private.h>
#include <debug.h>
#include <tsp.h>
#include "tspd_private.h"
/*******************************************************************************
* The target cpu is being turned on. Allow the TSPD/TSP to perform any actions
......@@ -59,7 +53,7 @@ static int32_t tspd_cpu_off_handler(uint64_t cookie)
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_ON);
......@@ -93,7 +87,7 @@ static void tspd_cpu_suspend_handler(uint64_t power_state)
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_ON);
......@@ -127,7 +121,7 @@ static void tspd_cpu_on_finish_handler(uint64_t cookie)
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_OFF);
......@@ -162,7 +156,7 @@ static void tspd_cpu_suspend_finish_handler(uint64_t suspend_level)
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_SUSPEND);
......@@ -198,7 +192,7 @@ static int32_t tspd_cpu_migrate_info(uint64_t *resident_cpu)
* Structure populated by the TSP Dispatcher to be given a chance to perform any
* TSP bookkeeping before PSCI executes a power mgmt. operation.
******************************************************************************/
const spd_pm_ops tspd_pm = {
const spd_pm_ops_t tspd_pm = {
tspd_cpu_on_handler,
tspd_cpu_off_handler,
tspd_cpu_suspend_handler,
......
......@@ -28,13 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SPD_PRIVATE_H__
#define __SPD_PRIVATE_H__
#ifndef __TSPD_PRIVATE_H__
#define __TSPD_PRIVATE_H__
#include <context.h>
#include <arch.h>
#include <context.h>
#include <platform.h>
#include <psci.h>
#include <tsp.h>
/*******************************************************************************
* Secure Payload PM state information e.g. SP is suspended, uninitialised etc
......@@ -90,6 +90,9 @@
#ifndef __ASSEMBLY__
#include <cassert.h>
#include <stdint.h>
/* AArch64 callee saved general purpose register context structure. */
DEFINE_REG_STRUCT(c_rt_regs, TSPD_C_RT_CTX_ENTRIES);
......@@ -98,7 +101,7 @@ DEFINE_REG_STRUCT(c_rt_regs, TSPD_C_RT_CTX_ENTRIES);
* have the same double word aligned view of the size of the C runtime
* register context.
*/
CASSERT(TSPD_C_RT_CTX_SIZE == sizeof(c_rt_regs), \
CASSERT(TSPD_C_RT_CTX_SIZE == sizeof(c_rt_regs_t), \
assert_spd_c_rt_regs_size_mismatch);
/*******************************************************************************
......@@ -109,29 +112,34 @@ CASSERT(TSPD_C_RT_CTX_SIZE == sizeof(c_rt_regs), \
* from a synchronous entry into the SP.
* 'cpu_ctx' - space to maintain SP architectural state
******************************************************************************/
typedef struct {
typedef struct tsp_context {
uint32_t state;
uint64_t mpidr;
uint64_t c_rt_ctx;
cpu_context cpu_ctx;
} tsp_context;
cpu_context_t cpu_ctx;
} tsp_context_t;
/* TSPD power management handlers */
extern const spd_pm_ops tspd_pm;
extern const spd_pm_ops_t tspd_pm;
/*******************************************************************************
* Forward declarations
******************************************************************************/
struct entry_info;
/*******************************************************************************
* Function & Data prototypes
******************************************************************************/
extern uint64_t tspd_enter_sp(uint64_t *c_rt_ctx);
extern void __dead2 tspd_exit_sp(uint64_t c_rt_ctx, uint64_t ret);
extern uint64_t tspd_synchronous_sp_entry(tsp_context *tsp_ctx);
extern void __dead2 tspd_synchronous_sp_exit(tsp_context *tsp_ctx, uint64_t ret);
extern uint64_t tspd_synchronous_sp_entry(tsp_context_t *tsp_ctx);
extern void __dead2 tspd_synchronous_sp_exit(tsp_context_t *tsp_ctx, uint64_t ret);
extern int32_t tspd_init_secure_context(uint64_t entrypoint,
uint32_t rw,
uint64_t mpidr,
tsp_context *tsp_ctx);
extern tsp_context tspd_sp_context[TSPD_CORE_COUNT];
extern entry_info *tsp_entry_info;
tsp_context_t *tsp_ctx);
extern tsp_context_t tspd_sp_context[TSPD_CORE_COUNT];
extern struct entry_info *tsp_entry_info;
#endif /*__ASSEMBLY__*/
#endif /* __SPD_PRIVATE_H__ */
#endif /* __TSPD_PRIVATE_H__ */
......@@ -28,23 +28,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <debug.h>
#include <arch.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <psci.h>
#include <psci_private.h>
#include <assert.h>
#include <string.h>
#include "psci_private.h"
typedef int (*afflvl_off_handler)(unsigned long, aff_map_node *);
typedef int (*afflvl_off_handler_t)(unsigned long, aff_map_node_t *);
/*******************************************************************************
* The next three functions implement a handler for each supported affinity
* level which is called when that affinity level is turned off.
******************************************************************************/
static int psci_afflvl0_off(unsigned long mpidr, aff_map_node *cpu_node)
static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node)
{
unsigned int index, plat_state;
int rc = PSCI_E_SUCCESS;
......@@ -111,7 +107,7 @@ static int psci_afflvl0_off(unsigned long mpidr, aff_map_node *cpu_node)
return rc;
}
static int psci_afflvl1_off(unsigned long mpidr, aff_map_node *cluster_node)
static int psci_afflvl1_off(unsigned long mpidr, aff_map_node_t *cluster_node)
{
int rc = PSCI_E_SUCCESS;
unsigned int plat_state;
......@@ -148,7 +144,7 @@ static int psci_afflvl1_off(unsigned long mpidr, aff_map_node *cluster_node)
return rc;
}
static int psci_afflvl2_off(unsigned long mpidr, aff_map_node *system_node)
static int psci_afflvl2_off(unsigned long mpidr, aff_map_node_t *system_node)
{
int rc = PSCI_E_SUCCESS;
unsigned int plat_state;
......@@ -178,7 +174,7 @@ static int psci_afflvl2_off(unsigned long mpidr, aff_map_node *system_node)
return rc;
}
static const afflvl_off_handler psci_afflvl_off_handlers[] = {
static const afflvl_off_handler_t psci_afflvl_off_handlers[] = {
psci_afflvl0_off,
psci_afflvl1_off,
psci_afflvl2_off,
......@@ -189,13 +185,13 @@ static const afflvl_off_handler psci_afflvl_off_handlers[] = {
* topology tree and calls the off handler for the corresponding affinity
* levels
******************************************************************************/
static int psci_call_off_handlers(mpidr_aff_map_nodes mpidr_nodes,
static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl,
int end_afflvl,
unsigned long mpidr)
{
int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node *node;
aff_map_node_t *node;
for (level = start_afflvl; level <= end_afflvl; level++) {
node = mpidr_nodes[level];
......@@ -242,7 +238,7 @@ int psci_afflvl_off(unsigned long mpidr,
int end_afflvl)
{
int rc = PSCI_E_SUCCESS;
mpidr_aff_map_nodes mpidr_nodes;
mpidr_aff_map_nodes_t mpidr_nodes;
mpidr &= MPIDR_AFFINITY_MASK;;
......
......@@ -28,19 +28,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <debug.h>
#include <arch.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <psci.h>
#include <psci_private.h>
#include <assert.h>
#include <bl_common.h>
#include <bl31.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
#include <stddef.h>
#include "psci_private.h"
typedef int (*afflvl_on_handler)(unsigned long,
aff_map_node *,
typedef int (*afflvl_on_handler_t)(unsigned long,
aff_map_node_t *,
unsigned long,
unsigned long);
......@@ -48,7 +47,7 @@ typedef int (*afflvl_on_handler)(unsigned long,
* This function checks whether a cpu which has been requested to be turned on
* is OFF to begin with.
******************************************************************************/
static int cpu_on_validate_state(aff_map_node *node)
static int cpu_on_validate_state(aff_map_node_t *node)
{
unsigned int psci_state;
......@@ -71,7 +70,7 @@ static int cpu_on_validate_state(aff_map_node *node)
* TODO: Split this code across separate handlers for each type of setup?
******************************************************************************/
static int psci_afflvl0_on(unsigned long target_cpu,
aff_map_node *cpu_node,
aff_map_node_t *cpu_node,
unsigned long ns_entrypoint,
unsigned long context_id)
{
......@@ -139,7 +138,7 @@ static int psci_afflvl0_on(unsigned long target_cpu,
* TODO: Split this code across separate handlers for each type of setup?
******************************************************************************/
static int psci_afflvl1_on(unsigned long target_cpu,
aff_map_node *cluster_node,
aff_map_node_t *cluster_node,
unsigned long ns_entrypoint,
unsigned long context_id)
{
......@@ -180,7 +179,7 @@ static int psci_afflvl1_on(unsigned long target_cpu,
* TODO: Split this code across separate handlers for each type of setup?
******************************************************************************/
static int psci_afflvl2_on(unsigned long target_cpu,
aff_map_node *system_node,
aff_map_node_t *system_node,
unsigned long ns_entrypoint,
unsigned long context_id)
{
......@@ -217,7 +216,7 @@ static int psci_afflvl2_on(unsigned long target_cpu,
}
/* Private data structure to make this handlers accessible through indexing */
static const afflvl_on_handler psci_afflvl_on_handlers[] = {
static const afflvl_on_handler_t psci_afflvl_on_handlers[] = {
psci_afflvl0_on,
psci_afflvl1_on,
psci_afflvl2_on,
......@@ -228,7 +227,7 @@ static const afflvl_on_handler psci_afflvl_on_handlers[] = {
* topology tree and calls the on handler for the corresponding affinity
* levels
******************************************************************************/
static int psci_call_on_handlers(mpidr_aff_map_nodes target_cpu_nodes,
static int psci_call_on_handlers(mpidr_aff_map_nodes_t target_cpu_nodes,
int start_afflvl,
int end_afflvl,
unsigned long target_cpu,
......@@ -236,7 +235,7 @@ static int psci_call_on_handlers(mpidr_aff_map_nodes target_cpu_nodes,
unsigned long context_id)
{
int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node *node;
aff_map_node_t *node;
for (level = end_afflvl; level >= start_afflvl; level--) {
node = target_cpu_nodes[level];
......@@ -282,7 +281,7 @@ int psci_afflvl_on(unsigned long target_cpu,
int end_afflvl)
{
int rc = PSCI_E_SUCCESS;
mpidr_aff_map_nodes target_cpu_nodes;
mpidr_aff_map_nodes_t target_cpu_nodes;
unsigned long mpidr = read_mpidr() & MPIDR_AFFINITY_MASK;
/*
......@@ -334,7 +333,7 @@ int psci_afflvl_on(unsigned long target_cpu,
* are called by the common finisher routine in psci_common.c.
******************************************************************************/
static unsigned int psci_afflvl0_on_finish(unsigned long mpidr,
aff_map_node *cpu_node)
aff_map_node_t *cpu_node)
{
unsigned int index, plat_state, state, rc = PSCI_E_SUCCESS;
......@@ -409,7 +408,7 @@ static unsigned int psci_afflvl0_on_finish(unsigned long mpidr,
}
static unsigned int psci_afflvl1_on_finish(unsigned long mpidr,
aff_map_node *cluster_node)
aff_map_node_t *cluster_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;
......@@ -441,7 +440,7 @@ static unsigned int psci_afflvl1_on_finish(unsigned long mpidr,
static unsigned int psci_afflvl2_on_finish(unsigned long mpidr,
aff_map_node *system_node)
aff_map_node_t *system_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;
......@@ -477,7 +476,7 @@ static unsigned int psci_afflvl2_on_finish(unsigned long mpidr,
return rc;
}
const afflvl_power_on_finisher psci_afflvl_on_finishers[] = {
const afflvl_power_on_finisher_t psci_afflvl_on_finishers[] = {
psci_afflvl0_on_finish,
psci_afflvl1_on_finish,
psci_afflvl2_on_finish,
......
......@@ -28,19 +28,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <debug.h>
#include <bl_common.h>
#include <arch.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <psci.h>
#include <psci_private.h>
#include <context.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
#include <stddef.h>
#include "psci_private.h"
typedef int (*afflvl_suspend_handler)(unsigned long,
aff_map_node *,
typedef int (*afflvl_suspend_handler_t)(unsigned long,
aff_map_node_t *,
unsigned long,
unsigned long,
unsigned int);
......@@ -49,7 +48,7 @@ typedef int (*afflvl_suspend_handler)(unsigned long,
* This function sets the power state of the current cpu while
* powering down during a cpu_suspend call
******************************************************************************/
void psci_set_suspend_power_state(aff_map_node *node, unsigned int power_state)
void psci_set_suspend_power_state(aff_map_node_t *node, unsigned int power_state)
{
/*
* Check that nobody else is calling this function on our behalf &
......@@ -67,7 +66,7 @@ void psci_set_suspend_power_state(aff_map_node *node, unsigned int power_state)
*/
flush_dcache_range(
(unsigned long)&psci_suspend_context[node->data],
sizeof(suspend_context));
sizeof(suspend_context_t));
}
/*******************************************************************************
......@@ -77,7 +76,7 @@ void psci_set_suspend_power_state(aff_map_node *node, unsigned int power_state)
******************************************************************************/
int psci_get_suspend_afflvl(unsigned long mpidr)
{
aff_map_node *node;
aff_map_node_t *node;
node = psci_get_aff_map_node(mpidr & MPIDR_AFFINITY_MASK,
MPIDR_AFFLVL0);
......@@ -92,7 +91,7 @@ int psci_get_suspend_afflvl(unsigned long mpidr)
* down during a cpu_suspend call. Returns PSCI_INVALID_DATA if the
* power state saved for the node is invalid
******************************************************************************/
int psci_get_aff_map_node_suspend_afflvl(aff_map_node *node)
int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node)
{
unsigned int power_state;
......@@ -110,7 +109,7 @@ int psci_get_aff_map_node_suspend_afflvl(aff_map_node *node)
******************************************************************************/
int psci_get_suspend_stateid(unsigned long mpidr)
{
aff_map_node *node;
aff_map_node_t *node;
unsigned int power_state;
node = psci_get_aff_map_node(mpidr & MPIDR_AFFINITY_MASK,
......@@ -128,14 +127,14 @@ int psci_get_suspend_stateid(unsigned long mpidr)
* level which is called when that affinity level is about to be suspended.
******************************************************************************/
static int psci_afflvl0_suspend(unsigned long mpidr,
aff_map_node *cpu_node,
aff_map_node_t *cpu_node,
unsigned long ns_entrypoint,
unsigned long context_id,
unsigned int power_state)
{
unsigned int index, plat_state;
unsigned long psci_entrypoint, sctlr;
el3_state *saved_el3_state;
el3_state_t *saved_el3_state;
int rc = PSCI_E_SUCCESS;
/* Sanity check to safeguard against data corruption */
......@@ -227,7 +226,7 @@ static int psci_afflvl0_suspend(unsigned long mpidr,
}
static int psci_afflvl1_suspend(unsigned long mpidr,
aff_map_node *cluster_node,
aff_map_node_t *cluster_node,
unsigned long ns_entrypoint,
unsigned long context_id,
unsigned int power_state)
......@@ -281,7 +280,7 @@ static int psci_afflvl1_suspend(unsigned long mpidr,
static int psci_afflvl2_suspend(unsigned long mpidr,
aff_map_node *system_node,
aff_map_node_t *system_node,
unsigned long ns_entrypoint,
unsigned long context_id,
unsigned int power_state)
......@@ -325,7 +324,7 @@ static int psci_afflvl2_suspend(unsigned long mpidr,
return rc;
}
static const afflvl_suspend_handler psci_afflvl_suspend_handlers[] = {
static const afflvl_suspend_handler_t psci_afflvl_suspend_handlers[] = {
psci_afflvl0_suspend,
psci_afflvl1_suspend,
psci_afflvl2_suspend,
......@@ -336,7 +335,7 @@ static const afflvl_suspend_handler psci_afflvl_suspend_handlers[] = {
* topology tree and calls the suspend handler for the corresponding affinity
* levels
******************************************************************************/
static int psci_call_suspend_handlers(mpidr_aff_map_nodes mpidr_nodes,
static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl,
int end_afflvl,
unsigned long mpidr,
......@@ -345,7 +344,7 @@ static int psci_call_suspend_handlers(mpidr_aff_map_nodes mpidr_nodes,
unsigned int power_state)
{
int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node *node;
aff_map_node_t *node;
for (level = start_afflvl; level <= end_afflvl; level++) {
node = mpidr_nodes[level];
......@@ -399,7 +398,7 @@ int psci_afflvl_suspend(unsigned long mpidr,
int end_afflvl)
{
int rc = PSCI_E_SUCCESS;
mpidr_aff_map_nodes mpidr_nodes;
mpidr_aff_map_nodes_t mpidr_nodes;
mpidr &= MPIDR_AFFINITY_MASK;
......@@ -452,7 +451,7 @@ int psci_afflvl_suspend(unsigned long mpidr,
* are called by the common finisher routine in psci_common.c.
******************************************************************************/
static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr,
aff_map_node *cpu_node)
aff_map_node_t *cpu_node)
{
unsigned int index, plat_state, state, rc = PSCI_E_SUCCESS;
int32_t suspend_level;
......@@ -532,7 +531,7 @@ static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr,
}
static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr,
aff_map_node *cluster_node)
aff_map_node_t *cluster_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;
......@@ -564,7 +563,7 @@ static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr,
static unsigned int psci_afflvl2_suspend_finish(unsigned long mpidr,
aff_map_node *system_node)
aff_map_node_t *system_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;;
......@@ -600,7 +599,7 @@ static unsigned int psci_afflvl2_suspend_finish(unsigned long mpidr,
return rc;
}
const afflvl_power_on_finisher psci_afflvl_suspend_finishers[] = {
const afflvl_power_on_finisher_t psci_afflvl_suspend_finishers[] = {
psci_afflvl0_suspend_finish,
psci_afflvl1_suspend_finish,
psci_afflvl2_suspend_finish,
......
......@@ -28,23 +28,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <arch.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <psci.h>
#include <psci_private.h>
#include <assert.h>
#include <bl_common.h>
#include <context.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
#include "debug.h"
#include <debug.h>
#include "psci_private.h"
/*
* SPD power management operations, expected to be supplied by the registered
* SPD on successful SP initialization
*/
const spd_pm_ops *psci_spd_pm;
const spd_pm_ops_t *psci_spd_pm;
/*******************************************************************************
* Arrays that contains information needs to resume a cpu's execution when woken
......@@ -52,8 +49,8 @@ const spd_pm_ops *psci_spd_pm;
* free index in the 'psci_ns_entry_info' & 'psci_suspend_context' arrays. Each
* cpu is allocated a single entry in each array during startup.
******************************************************************************/
suspend_context psci_suspend_context[PSCI_NUM_AFFS];
ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS];
suspend_context_t psci_suspend_context[PSCI_NUM_AFFS];
ns_entry_info_t psci_ns_entry_info[PSCI_NUM_AFFS];
unsigned int psci_ns_einfo_idx;
/*******************************************************************************
......@@ -61,7 +58,7 @@ unsigned int psci_ns_einfo_idx;
* management of affinity instances. Each node (aff_map_node) in the array
* corresponds to an affinity instance e.g. cluster, cpu within an mpidr
******************************************************************************/
aff_map_node psci_aff_map[PSCI_NUM_AFFS]
aff_map_node_t psci_aff_map[PSCI_NUM_AFFS]
__attribute__ ((section("tzfw_coherent_mem")));
/*******************************************************************************
......@@ -72,12 +69,12 @@ __attribute__ ((section("tzfw_coherent_mem")));
* level i.e. start index and end index needs to be present. 'psci_aff_limits'
* stores this information.
******************************************************************************/
aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
aff_limits_node_t psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
/*******************************************************************************
* Pointer to functions exported by the platform to complete power mgmt. ops
******************************************************************************/
plat_pm_ops *psci_plat_pm_ops;
plat_pm_ops_t *psci_plat_pm_ops;
/*******************************************************************************
* Routine to return the maximum affinity level to traverse to after a cpu has
......@@ -89,7 +86,7 @@ plat_pm_ops *psci_plat_pm_ops;
******************************************************************************/
int get_power_on_target_afflvl(unsigned long mpidr)
{
aff_map_node *node;
aff_map_node_t *node;
unsigned int state;
int afflvl;
......@@ -180,7 +177,7 @@ int psci_check_afflvl_range(int start_afflvl, int end_afflvl)
void psci_acquire_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
mpidr_aff_map_nodes mpidr_nodes)
mpidr_aff_map_nodes_t mpidr_nodes)
{
int level;
......@@ -199,7 +196,7 @@ void psci_acquire_afflvl_locks(unsigned long mpidr,
void psci_release_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
mpidr_aff_map_nodes mpidr_nodes)
mpidr_aff_map_nodes_t mpidr_nodes)
{
int level;
......@@ -216,7 +213,7 @@ void psci_release_afflvl_locks(unsigned long mpidr,
******************************************************************************/
int psci_validate_mpidr(unsigned long mpidr, int level)
{
aff_map_node *node;
aff_map_node_t *node;
node = psci_get_aff_map_node(mpidr, level);
if (node && (node->state & PSCI_AFF_PRESENT))
......@@ -234,8 +231,8 @@ void psci_get_ns_entry_info(unsigned int index)
{
unsigned long sctlr = 0, scr, el_status, id_aa64pfr0;
uint64_t mpidr = read_mpidr();
cpu_context *ns_entry_context;
gp_regs *ns_entry_gpregs;
cpu_context_t *ns_entry_context;
gp_regs_t *ns_entry_gpregs;
scr = read_scr();
......@@ -267,7 +264,7 @@ void psci_get_ns_entry_info(unsigned int index)
write_sctlr_el1(sctlr);
/* Fulfill the cpu_on entry reqs. as per the psci spec */
ns_entry_context = (cpu_context *) cm_get_context(mpidr, NON_SECURE);
ns_entry_context = (cpu_context_t *) cm_get_context(mpidr, NON_SECURE);
assert(ns_entry_context);
/*
......@@ -380,7 +377,7 @@ int psci_set_ns_entry_info(unsigned int index,
* This function takes a pointer to an affinity node in the topology tree and
* returns its state. State of a non-leaf node needs to be calculated.
******************************************************************************/
unsigned short psci_get_state(aff_map_node *node)
unsigned short psci_get_state(aff_map_node_t *node)
{
assert(node->level >= MPIDR_AFFLVL0 && node->level <= MPIDR_MAX_AFFLVL);
......@@ -407,7 +404,7 @@ unsigned short psci_get_state(aff_map_node *node)
* a target state. State of a non-leaf node needs to be converted to a reference
* count. State of a leaf node can be set directly.
******************************************************************************/
void psci_set_state(aff_map_node *node, unsigned short state)
void psci_set_state(aff_map_node_t *node, unsigned short state)
{
assert(node->level >= MPIDR_AFFLVL0 && node->level <= MPIDR_MAX_AFFLVL);
......@@ -448,7 +445,7 @@ void psci_set_state(aff_map_node *node, unsigned short state)
* tell whether that's actually happenned or not. So we err on the side of
* caution & treat the affinity level as being turned off.
******************************************************************************/
unsigned short psci_get_phys_state(aff_map_node *node)
unsigned short psci_get_phys_state(aff_map_node_t *node)
{
unsigned int state;
......@@ -461,14 +458,14 @@ unsigned short psci_get_phys_state(aff_map_node *node)
* topology tree and calls the physical power on handler for the corresponding
* affinity levels
******************************************************************************/
static int psci_call_power_on_handlers(mpidr_aff_map_nodes mpidr_nodes,
static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl,
int end_afflvl,
afflvl_power_on_finisher *pon_handlers,
afflvl_power_on_finisher_t *pon_handlers,
unsigned long mpidr)
{
int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node *node;
aff_map_node_t *node;
for (level = end_afflvl; level >= start_afflvl; level--) {
node = mpidr_nodes[level];
......@@ -511,9 +508,9 @@ static int psci_call_power_on_handlers(mpidr_aff_map_nodes mpidr_nodes,
void psci_afflvl_power_on_finish(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
afflvl_power_on_finisher *pon_handlers)
afflvl_power_on_finisher_t *pon_handlers)
{
mpidr_aff_map_nodes mpidr_nodes;
mpidr_aff_map_nodes_t mpidr_nodes;
int rc;
mpidr &= MPIDR_AFFINITY_MASK;
......@@ -565,7 +562,7 @@ void psci_afflvl_power_on_finish(unsigned long mpidr,
* management operation. The power management hooks are expected to be provided
* by the SPD, after it finishes all its initialization
******************************************************************************/
void psci_register_spd_pm_hook(const spd_pm_ops *pm)
void psci_register_spd_pm_hook(const spd_pm_ops_t *pm)
{
psci_spd_pm = pm;
}
......@@ -29,12 +29,9 @@
*/
#include <arch.h>
#include <platform.h>
#include <psci.h>
#include <psci_private.h>
#include <runtime_svc.h>
#include <asm_macros.S>
#include <cm_macros.S>
#include <psci.h>
.globl psci_aff_on_finish_entry
.globl psci_aff_suspend_finish_entry
......
......@@ -28,16 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <arch.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <psci_private.h>
#include <assert.h>
#include <runtime_svc.h>
#include <debug.h>
#include <context_mgmt.h>
#include "psci_private.h"
/*******************************************************************************
* PSCI frontend api for servicing SMCs. Described in the PSCI spec.
......@@ -144,7 +140,7 @@ int psci_affinity_info(unsigned long target_affinity,
{
int rc = PSCI_E_INVALID_PARAMS;
unsigned int aff_state;
aff_map_node *node;
aff_map_node_t *node;
if (lowest_affinity_level > get_max_afflvl())
return rc;
......
......@@ -33,79 +33,79 @@
#include <arch.h>
#include <bakery_lock.h>
#include <psci.h>
#ifndef __ASSEMBLY__
/*******************************************************************************
* The following two data structures hold the generic information to bringup
* a suspended/hotplugged out cpu
******************************************************************************/
typedef struct {
typedef struct eret_params {
unsigned long entrypoint;
unsigned long spsr;
} eret_params;
} eret_params_t;
typedef struct {
eret_params eret_info;
typedef struct ns_entry_info {
eret_params_t eret_info;
unsigned long context_id;
unsigned int scr;
unsigned int sctlr;
} ns_entry_info;
} ns_entry_info_t;
/*******************************************************************************
* The following two data structures hold the topology tree which in turn tracks
* the state of the all the affinity instances supported by the platform.
******************************************************************************/
typedef struct {
typedef struct aff_map_node {
unsigned long mpidr;
unsigned short ref_count;
unsigned char state;
unsigned char level;
unsigned int data;
bakery_lock lock;
} aff_map_node;
bakery_lock_t lock;
} aff_map_node_t;
typedef struct {
typedef struct aff_limits_node {
int min;
int max;
} aff_limits_node;
} aff_limits_node_t;
/*******************************************************************************
* This data structure holds secure world context that needs to be preserved
* across cpu_suspend calls which enter the power down state.
******************************************************************************/
typedef struct {
typedef struct suspend_context {
unsigned int power_state;
} __aligned(CACHE_WRITEBACK_GRANULE) suspend_context;
} __aligned(CACHE_WRITEBACK_GRANULE) suspend_context_t;
typedef aff_map_node (*mpidr_aff_map_nodes[MPIDR_MAX_AFFLVL]);
typedef unsigned int (*afflvl_power_on_finisher)(unsigned long,
aff_map_node *);
typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]);
typedef unsigned int (*afflvl_power_on_finisher_t)(unsigned long,
aff_map_node_t *);
/*******************************************************************************
* Data prototypes
******************************************************************************/
extern suspend_context psci_suspend_context[PSCI_NUM_AFFS];
extern ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS];
extern suspend_context_t psci_suspend_context[PSCI_NUM_AFFS];
extern ns_entry_info_t psci_ns_entry_info[PSCI_NUM_AFFS];
extern unsigned int psci_ns_einfo_idx;
extern aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
extern plat_pm_ops *psci_plat_pm_ops;
extern aff_map_node psci_aff_map[PSCI_NUM_AFFS];
extern afflvl_power_on_finisher psci_afflvl_off_finish_handlers[];
extern afflvl_power_on_finisher psci_afflvl_sus_finish_handlers[];
extern aff_limits_node_t psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
extern plat_pm_ops_t *psci_plat_pm_ops;
extern aff_map_node_t psci_aff_map[PSCI_NUM_AFFS];
extern afflvl_power_on_finisher_t psci_afflvl_off_finish_handlers[];
extern afflvl_power_on_finisher_t psci_afflvl_sus_finish_handlers[];
/*******************************************************************************
* SPD's power management hooks registered with PSCI
******************************************************************************/
extern const spd_pm_ops *psci_spd_pm;
extern const spd_pm_ops_t *psci_spd_pm;
/*******************************************************************************
* Function prototypes
******************************************************************************/
/* Private exported functions from psci_common.c */
extern int get_max_afflvl(void);
extern unsigned short psci_get_state(aff_map_node *node);
extern unsigned short psci_get_phys_state(aff_map_node *node);
extern void psci_set_state(aff_map_node *node, unsigned short state);
extern unsigned short psci_get_state(aff_map_node_t *node);
extern unsigned short psci_get_phys_state(aff_map_node_t *node);
extern void psci_set_state(aff_map_node_t *node, unsigned short state);
extern void psci_get_ns_entry_info(unsigned int index);
extern unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int);
extern int psci_validate_mpidr(unsigned long, int);
......@@ -113,7 +113,7 @@ extern int get_power_on_target_afflvl(unsigned long mpidr);
extern void psci_afflvl_power_on_finish(unsigned long,
int,
int,
afflvl_power_on_finisher *);
afflvl_power_on_finisher_t *);
extern int psci_set_ns_entry_info(unsigned int index,
unsigned long entrypoint,
unsigned long context_id);
......@@ -121,18 +121,18 @@ extern int psci_check_afflvl_range(int start_afflvl, int end_afflvl);
extern void psci_acquire_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
mpidr_aff_map_nodes mpidr_nodes);
mpidr_aff_map_nodes_t mpidr_nodes);
extern void psci_release_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
mpidr_aff_map_nodes mpidr_nodes);
mpidr_aff_map_nodes_t mpidr_nodes);
/* Private exported functions from psci_setup.c */
extern int psci_get_aff_map_nodes(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
mpidr_aff_map_nodes mpidr_nodes);
extern aff_map_node *psci_get_aff_map_node(unsigned long, int);
mpidr_aff_map_nodes_t mpidr_nodes);
extern aff_map_node_t *psci_get_aff_map_node(unsigned long, int);
/* Private exported functions from psci_affinity_on.c */
extern int psci_afflvl_on(unsigned long,
......@@ -145,9 +145,9 @@ extern int psci_afflvl_on(unsigned long,
extern int psci_afflvl_off(unsigned long, int, int);
/* Private exported functions from psci_affinity_suspend.c */
extern void psci_set_suspend_power_state(aff_map_node *node,
extern void psci_set_suspend_power_state(aff_map_node_t *node,
unsigned int power_state);
extern int psci_get_aff_map_node_suspend_afflvl(aff_map_node *node);
extern int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node);
extern int psci_afflvl_suspend(unsigned long,
unsigned long,
unsigned long,
......@@ -156,19 +156,5 @@ extern int psci_afflvl_suspend(unsigned long,
int);
extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int);
/* Private exported functions from psci_main.c */
extern uint64_t psci_smc_handler(uint32_t smc_fid,
uint64_t x1,
uint64_t x2,
uint64_t x3,
uint64_t x4,
void *cookie,
void *handle,
uint64_t flags);
/* PSCI setup function */
extern int32_t psci_setup(void);
#endif /*__ASSEMBLY__*/
#endif /* __PSCI_PRIVATE_H__ */
......@@ -28,15 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <arch.h>
#include <arch_helpers.h>
#include <console.h>
#include <platform.h>
#include <psci_private.h>
#include <assert.h>
#include <bl_common.h>
#include <context.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
#include <platform.h>
#include <stddef.h>
#include "psci_private.h"
/*******************************************************************************
* Per cpu non-secure contexts used to program the architectural state prior
......@@ -45,7 +45,7 @@
* of relying on platform defined constants. Using PSCI_NUM_AFFS will be an
* overkill.
******************************************************************************/
static cpu_context psci_ns_context[PLATFORM_CORE_COUNT];
static cpu_context_t psci_ns_context[PLATFORM_CORE_COUNT];
/*******************************************************************************
* Routines for retrieving the node corresponding to an affinity level instance
......@@ -81,7 +81,7 @@ static int psci_aff_map_get_idx(unsigned long key,
return mid;
}
aff_map_node *psci_get_aff_map_node(unsigned long mpidr, int aff_lvl)
aff_map_node_t *psci_get_aff_map_node(unsigned long mpidr, int aff_lvl)
{
int rc;
......@@ -106,10 +106,10 @@ aff_map_node *psci_get_aff_map_node(unsigned long mpidr, int aff_lvl)
int psci_get_aff_map_nodes(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
mpidr_aff_map_nodes mpidr_nodes)
mpidr_aff_map_nodes_t mpidr_nodes)
{
int rc = PSCI_E_INVALID_PARAMS, level;
aff_map_node *node;
aff_map_node_t *node;
rc = psci_check_afflvl_range(start_afflvl, end_afflvl);
if (rc != PSCI_E_SUCCESS)
......@@ -285,7 +285,7 @@ int32_t psci_setup(void)
{
unsigned long mpidr = read_mpidr();
int afflvl, affmap_idx, max_afflvl;
aff_map_node *node;
aff_map_node_t *node;
psci_ns_einfo_idx = 0;
psci_plat_pm_ops = NULL;
......
......@@ -28,14 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <uuid.h>
#include <context_mgmt.h>
#include <debug.h>
#include <psci.h>
#include <runtime_svc.h>
#include <std_svc.h>
#include <psci.h>
#include <psci_private.h>
#include <debug.h>
#include <stdint.h>
#include <uuid.h>
/* Standard Service UUID */
DEFINE_SVC_UUID(arm_svc_uid,
......
......@@ -43,7 +43,7 @@
#define OPT_DUMP 1
#define OPT_HELP 2
file_info files[MAX_FILES];
file_info_t files[MAX_FILES];
unsigned file_info_count = 0;
uuid_t uuid_null = {0};
......@@ -54,7 +54,7 @@ uuid_t uuid_null = {0};
*/
/* Currently only BL2 and BL31 images are supported. */
static entry_lookup_list toc_entry_lookup_list[] = {
static entry_lookup_list_t toc_entry_lookup_list[] = {
{ "Trusted Boot Firmware BL2", UUID_TRUSTED_BOOT_FIRMWARE_BL2,
"bl2", NULL, FLAG_FILENAME },
{ "SCP Firmware BL3-0", UUID_SCP_FIRMWARE_BL30,
......@@ -84,7 +84,7 @@ static inline void copy_uuid(uuid_t *to_uuid, const uuid_t *from_uuid)
static void print_usage(void)
{
entry_lookup_list *entry = toc_entry_lookup_list;
entry_lookup_list_t *entry = toc_entry_lookup_list;
printf("Usage: fip_create [options] FIP_FILENAME\n\n");
printf("\tThis tool is used to create a Firmware Image Package.\n\n");
......@@ -102,7 +102,7 @@ static void print_usage(void)
}
static entry_lookup_list *get_entry_lookup_from_uuid(const uuid_t *uuid)
static entry_lookup_list_t *get_entry_lookup_from_uuid(const uuid_t *uuid)
{
unsigned int lookup_index = 0;
......@@ -117,7 +117,7 @@ static entry_lookup_list *get_entry_lookup_from_uuid(const uuid_t *uuid)
}
static file_info *find_file_info_from_uuid(const uuid_t *uuid)
static file_info_t *find_file_info_from_uuid(const uuid_t *uuid)
{
int index;
......@@ -130,9 +130,9 @@ static file_info *find_file_info_from_uuid(const uuid_t *uuid)
}
static int add_file_info_entry(entry_lookup_list *lookup_entry, char *filename)
static int add_file_info_entry(entry_lookup_list_t *lookup_entry, char *filename)
{
file_info *file_info_entry;
file_info_t *file_info_entry;
int error;
struct stat file_status;
bool is_new_entry = false;
......@@ -213,7 +213,7 @@ static int write_memory_to_file(const uint8_t *start, const char *filename,
}
static int read_file_to_memory(void *memory, const file_info *info)
static int read_file_to_memory(void *memory, const file_info_t *info)
{
FILE *stream;
unsigned int bytes_read;
......@@ -258,8 +258,8 @@ static int pack_images(const char *fip_filename)
int status;
uint8_t *fip_base_address;
void *entry_address;
fip_toc_header *toc_header;
fip_toc_entry *toc_entry;
fip_toc_header_t *toc_header;
fip_toc_entry_t *toc_entry;
unsigned int entry_index;
unsigned int toc_size;
unsigned int fip_size;
......@@ -277,8 +277,8 @@ static int pack_images(const char *fip_filename)
}
/* Allocate memory for entire package, including the final null entry */
toc_size = (sizeof(fip_toc_header) +
(sizeof(fip_toc_entry) * (file_info_count + 1)));
toc_size = (sizeof(fip_toc_header_t) +
(sizeof(fip_toc_entry_t) * (file_info_count + 1)));
fip_size = toc_size + payload_size;
fip_base_address = malloc(fip_size);
if (fip_base_address == NULL) {
......@@ -289,13 +289,13 @@ static int pack_images(const char *fip_filename)
memset(fip_base_address, 0, fip_size);
/* Create ToC Header */
toc_header = (fip_toc_header *)fip_base_address;
toc_header = (fip_toc_header_t *)fip_base_address;
toc_header->name = TOC_HEADER_NAME;
toc_header->serial_number = TOC_HEADER_SERIAL_NUMBER;
toc_header->flags = 0;
toc_entry = (fip_toc_entry *)(fip_base_address +
sizeof(fip_toc_header));
toc_entry = (fip_toc_entry_t *)(fip_base_address +
sizeof(fip_toc_header_t));
/* Calculate the starting address of the first image, right after the
* toc header.
......@@ -345,8 +345,8 @@ static void dump_toc(void)
unsigned int image_offset;
unsigned int image_size = 0;
image_offset = sizeof(fip_toc_header) +
(sizeof(fip_toc_entry) * (file_info_count + 1));
image_offset = sizeof(fip_toc_header_t) +
(sizeof(fip_toc_entry_t) * (file_info_count + 1));
printf("Firmware Image Package ToC:\n");
printf("---------------------------\n");
......@@ -376,10 +376,10 @@ static int parse_fip(const char *fip_filename)
char *fip_buffer;
char *fip_buffer_end;
int fip_size, read_fip_size;
fip_toc_header *toc_header;
fip_toc_entry *toc_entry;
fip_toc_header_t *toc_header;
fip_toc_entry_t *toc_entry;
bool found_last_toc_entry = false;
file_info *file_info_entry;
file_info_t *file_info_entry;
int status = -1;
struct stat st;
......@@ -419,19 +419,19 @@ static int parse_fip(const char *fip_filename)
fip = NULL;
/* The package must at least contain the ToC Header */
if (fip_size < sizeof(fip_toc_header)) {
if (fip_size < sizeof(fip_toc_header_t)) {
printf("ERROR: Given FIP is smaller than the ToC header.\n");
status = EINVAL;
goto parse_fip_free;
}
/* Set the ToC Header at the base of the buffer */
toc_header = (fip_toc_header *)fip_buffer;
toc_header = (fip_toc_header_t *)fip_buffer;
/* The first toc entry should be just after the ToC header */
toc_entry = (fip_toc_entry *)(toc_header + 1);
toc_entry = (fip_toc_entry_t *)(toc_header + 1);
/* While the ToC entry is contained into the buffer */
int cnt = 0;
while (((char *)toc_entry + sizeof(fip_toc_entry)) < fip_buffer_end) {
while (((char *)toc_entry + sizeof(fip_toc_entry_t)) < fip_buffer_end) {
cnt++;
/* Check if the ToC Entry is the last one */
if (compare_uuids(&toc_entry->uuid, &uuid_null) == 0) {
......@@ -444,7 +444,7 @@ static int parse_fip(const char *fip_filename)
/* Get the new entry in the array and clear it */
file_info_entry = &files[file_info_count++];
memset(file_info_entry, 0, sizeof(file_info));
memset(file_info_entry, 0, sizeof(file_info_t));
/* Copy the info from the ToC entry */
copy_uuid(&file_info_entry->name_uuid, &toc_entry->uuid);
......@@ -523,7 +523,7 @@ static int parse_cmdline(int argc, char **argv, struct option *options,
int c;
int status = 0;
int option_index = 0;
entry_lookup_list *lookup_entry;
entry_lookup_list_t *lookup_entry;
int do_dump = 0;
/* restart parse to process all options. starts at 1. */
......@@ -591,11 +591,11 @@ int main(int argc, char **argv)
* Add 'dump' option, 'help' option and end marker.
*/
static struct option long_options[(sizeof(toc_entry_lookup_list)/
sizeof(entry_lookup_list)) + 2];
sizeof(entry_lookup_list_t)) + 2];
for (i = 0;
/* -1 because we dont want to process end marker in toc table */
i < sizeof(toc_entry_lookup_list)/sizeof(entry_lookup_list) - 1;
i < sizeof(toc_entry_lookup_list)/sizeof(entry_lookup_list_t) - 1;
i++) {
long_options[i].name = toc_entry_lookup_list[i].command_line_name;
/* The only flag defined at the moment is for a FILENAME */
......
......@@ -41,20 +41,20 @@
#define FLAG_FILENAME (1 << 0)
typedef struct {
typedef struct entry_lookup_list {
const char *name;
uuid_t name_uuid;
const char *command_line_name;
struct file_info *info;
unsigned int flags;
} entry_lookup_list;
} entry_lookup_list_t;
typedef struct {
typedef struct file_info {
uuid_t name_uuid;
const char *filename;
unsigned int size;
void *image_buffer;
entry_lookup_list *entry;
} file_info;
entry_lookup_list_t *entry;
} file_info_t;
#endif /* __FIP_CREATE_H__ */
../../include/firmware_image_package.h
\ No newline at end of file
../../include/common/firmware_image_package.h
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment