Replace lib/sm-related typedefs with struct types
This rewrite was mostly automatic:
sed -r -i 's/\b(ns_page_info)_t\b/struct \1/g'
sed -r -i 's/\b(smc32_args)_t\b/struct \1/g'
sed -r -i 's/\b(smc32_entity)_t\b/struct \1/g'
Bug: 144593477
Change-Id: Ibc7b196a99f69759b8a85efdf00a6cd3770f653e
diff --git a/lib/memlog/memlog.c b/lib/memlog/memlog.c
index 91ec773..840f20e 100644
--- a/lib/memlog/memlog.c
+++ b/lib/memlog/memlog.c
@@ -152,11 +152,11 @@
return err;
}
-static uint64_t args_get_pa(smc32_args_t* args) {
+static uint64_t args_get_pa(struct smc32_args* args) {
return (((uint64_t)args->params[1] << 32) | args->params[0]);
}
-static size_t args_get_sz(smc32_args_t* args) {
+static size_t args_get_sz(struct smc32_args* args) {
return (size_t)args->params[2];
}
@@ -235,7 +235,7 @@
return 0;
}
-static long memlog_stdcall(smc32_args_t* args) {
+static long memlog_stdcall(struct smc32_args* args) {
switch (args->smc_nr) {
case SMC_SC_SHARED_LOG_VERSION:
return TRUSTY_LOG_API_VERSION;
@@ -249,7 +249,7 @@
return 0;
}
-static smc32_entity_t log_sm_entity = {
+static struct smc32_entity log_sm_entity = {
.stdcall_handler = memlog_stdcall,
};
diff --git a/lib/sm/arch/arm/entry.S b/lib/sm/arch/arm/entry.S
index 0f579f1..fd104af 100644
--- a/lib/sm/arch/arm/entry.S
+++ b/lib/sm/arch/arm/entry.S
@@ -29,7 +29,7 @@
#include <kernel/vm.h>
#if !LIB_SM_CUSTOM_SCHED_NONSECURE
-/* sm_sched_nonsecure(uint32_t retval, smc32_args_t *args) */
+/* sm_sched_nonsecure(uint32_t retval, struct smc32_args *args) */
FUNCTION(sm_sched_nonsecure)
push {r1, lr}
mov r1, r0
diff --git a/lib/sm/include/lib/sm.h b/lib/sm/include/lib/sm.h
index 4b1df62..7dc3d81 100644
--- a/lib/sm/include/lib/sm.h
+++ b/lib/sm/include/lib/sm.h
@@ -31,45 +31,45 @@
typedef uint64_t ns_addr_t;
typedef uint32_t ns_size_t;
-typedef struct ns_page_info {
+struct ns_page_info {
uint64_t attr;
-} ns_page_info_t;
+};
-typedef struct smc32_args {
+struct smc32_args {
uint32_t smc_nr;
uint32_t params[SMC_NUM_PARAMS];
-} smc32_args_t;
+};
#define SMC32_ARGS_INITIAL_VALUE(args) \
{ \
0, { 0 } \
}
-typedef long (*smc32_handler_t)(smc32_args_t* args);
+typedef long (*smc32_handler_t)(struct smc32_args* args);
-typedef struct smc32_entity {
+struct smc32_entity {
smc32_handler_t fastcall_handler;
smc32_handler_t nopcall_handler;
smc32_handler_t stdcall_handler;
-} smc32_entity_t;
+};
/* Schedule Secure OS */
-long sm_sched_secure(smc32_args_t* args);
+long sm_sched_secure(struct smc32_args* args);
/* Schedule Non-secure OS */
-void sm_sched_nonsecure(long retval, smc32_args_t* args);
+void sm_sched_nonsecure(long retval, struct smc32_args* args);
/* Handle an interrupt */
enum handler_return sm_handle_irq(void);
void sm_handle_fiq(void);
/* Version */
-long smc_sm_api_version(smc32_args_t* args);
+long smc_sm_api_version(struct smc32_args* args);
/* Interrupt controller irq/fiq support */
-long smc_intc_get_next_irq(smc32_args_t* args);
-long smc_intc_request_fiq(smc32_args_t* args);
-long smc_intc_fiq_resume(smc32_args_t* args);
+long smc_intc_get_next_irq(struct smc32_args* args);
+long smc_intc_request_fiq(struct smc32_args* args);
+long smc_intc_fiq_resume(struct smc32_args* args);
/* return 0 to enter ns-fiq handler, return non-0 to return */
status_t sm_intc_fiq_enter(void);
void sm_intc_fiq_exit(void);
@@ -81,7 +81,7 @@
void sm_put_boot_args(void);
/* Register handler(s) for an entity */
-status_t sm_register_entity(uint entity_nr, smc32_entity_t* entity);
+status_t sm_register_entity(uint entity_nr, struct smc32_entity* entity);
status_t sm_decode_ns_memory_attr(struct ns_page_info* pinf,
ns_addr_t* ppa,
diff --git a/lib/sm/sm.c b/lib/sm/sm.c
index 5ceca80..1496351 100644
--- a/lib/sm/sm.c
+++ b/lib/sm/sm.c
@@ -42,7 +42,7 @@
struct sm_std_call_state {
spin_lock_t lock;
event_t event;
- smc32_args_t args;
+ struct smc32_args args;
long ret;
bool done;
int active_cpu; /* cpu that expects stdcall result */
@@ -79,7 +79,7 @@
extern smc32_handler_t sm_nopcall_table[];
extern smc32_handler_t sm_fastcall_table[];
-long smc_sm_api_version(smc32_args_t* args) {
+long smc_sm_api_version(struct smc32_args* args) {
uint32_t api_version = args->params[0];
spin_lock(&sm_api_version_lock);
@@ -140,7 +140,7 @@
}
/* must be called with irqs disabled */
-static long sm_queue_stdcall(smc32_args_t* args) {
+static long sm_queue_stdcall(struct smc32_args* args) {
long ret;
uint cpu = arch_curr_cpu_num();
@@ -184,7 +184,7 @@
return ret;
}
-static void sm_sched_nonsecure_fiq_loop(long ret, smc32_args_t* args) {
+static void sm_sched_nonsecure_fiq_loop(long ret, struct smc32_args* args) {
while (true) {
if (atomic_load(&platform_halted)) {
ret = SM_ERR_PANIC;
@@ -206,7 +206,7 @@
/* must be called with irqs disabled */
static void sm_return_and_wait_for_next_stdcall(long ret, int cpu) {
- smc32_args_t args = SMC32_ARGS_INITIAL_VALUE(args);
+ struct smc32_args args = SMC32_ARGS_INITIAL_VALUE(args);
do {
arch_disable_fiqs();
@@ -445,7 +445,7 @@
void sm_handle_fiq(void) {
uint32_t expected_return;
- smc32_args_t args = SMC32_ARGS_INITIAL_VALUE(args);
+ struct smc32_args args = SMC32_ARGS_INITIAL_VALUE(args);
if (sm_get_api_version() >= TRUSTY_API_VERSION_RESTART_FIQ) {
sm_sched_nonsecure_fiq_loop(SM_ERR_FIQ_INTERRUPTED, &args);
expected_return = SMC_SC_RESTART_FIQ;
@@ -464,7 +464,7 @@
void platform_halt(platform_halt_action suggested_action,
platform_halt_reason reason) {
bool already_halted;
- smc32_args_t args = SMC32_ARGS_INITIAL_VALUE(args);
+ struct smc32_args args = SMC32_ARGS_INITIAL_VALUE(args);
arch_disable_ints();
already_halted = atomic_exchange(&platform_halted, true);
diff --git a/lib/sm/smcall.c b/lib/sm/smcall.c
index 6ee12ae..b4c39e4 100644
--- a/lib/sm/smcall.c
+++ b/lib/sm/smcall.c
@@ -46,7 +46,7 @@
static mutex_t smc_table_lock = MUTEX_INITIAL_VALUE(smc_table_lock);
/* Defined elsewhere */
-long smc_fiq_exit(smc32_args_t* args);
+long smc_fiq_exit(struct smc32_args* args);
#define TRACE_SMC(msg, args) \
do { \
@@ -59,13 +59,13 @@
LTRACEF("param%d: 0x%x\n", _i, (args)->params[_i]); \
} while (0)
-long smc_undefined(smc32_args_t* args) {
+long smc_undefined(struct smc32_args* args) {
TRACE_SMC("Undefined monitor call!", args);
return SM_ERR_UNDEFINED_SMC;
}
/* Restarts should never be dispatched like this */
-static long smc_restart_stdcall(smc32_args_t* args) {
+static long smc_restart_stdcall(struct smc32_args* args) {
TRACE_SMC("Unexpected stdcall restart!", args);
return SM_ERR_UNEXPECTED_RESTART;
}
@@ -75,14 +75,14 @@
* but if an interrupt is pending, it will be handled, and can in turn trigger a
* context switch that will perform other secure work.
*/
-static long smc_nop_stdcall(smc32_args_t* args) {
+static long smc_nop_stdcall(struct smc32_args* args) {
return 0;
}
/*
* parameterized nop call handler
*/
-static long smc_nop_secure_monitor(smc32_args_t* args) {
+static long smc_nop_secure_monitor(struct smc32_args* args) {
return (!args->params[0]) ? 0 : SM_ERR_UNDEFINED_SMC;
}
@@ -94,7 +94,7 @@
[SMC_FUNCTION(SMC_SC_NOP)] = smc_undefined,
};
-static long smc_stdcall_secure_monitor(smc32_args_t* args) {
+static long smc_stdcall_secure_monitor(struct smc32_args* args) {
u_int function = SMC_FUNCTION(args->smc_nr);
smc32_handler_t handler_fn = NULL;
@@ -107,24 +107,24 @@
return handler_fn(args);
}
-long smc_fiq_exit(smc32_args_t* args) {
+long smc_fiq_exit(struct smc32_args* args) {
sm_intc_fiq_exit();
return 1; /* 0: reeenter fiq handler, 1: return */
}
-static long smc_fiq_enter(smc32_args_t* args) {
+static long smc_fiq_enter(struct smc32_args* args) {
return sm_intc_fiq_enter();
}
#if !WITH_LIB_SM_MONITOR
-static long smc_cpu_suspend(smc32_args_t* args) {
+static long smc_cpu_suspend(struct smc32_args* args) {
lk_init_level_all(args->params[0] ? LK_INIT_FLAG_CPU_OFF
: LK_INIT_FLAG_CPU_ENTER_IDLE);
return 0;
}
-static long smc_cpu_resume(smc32_args_t* args) {
+static long smc_cpu_resume(struct smc32_args* args) {
lk_init_level_all(args->params[0] ? LK_INIT_FLAG_CPU_ON
: LK_INIT_FLAG_CPU_EXIT_IDLE);
@@ -133,7 +133,7 @@
#endif
#if WITH_LIB_VERSION
-static long smc_get_version_str(smc32_args_t* args) {
+static long smc_get_version_str(struct smc32_args* args) {
int32_t index = (int32_t)args->params[0];
size_t version_len = strlen(lk_version);
@@ -163,7 +163,7 @@
[SMC_FUNCTION(SMC_FC_FIQ_RESUME)] = smc_intc_fiq_resume,
};
-static long smc_fastcall_secure_monitor(smc32_args_t* args) {
+static long smc_fastcall_secure_monitor(struct smc32_args* args) {
smc32_handler_t func = NULL;
uint16_t index = SMC_FUNCTION(args->smc_nr);
@@ -195,7 +195,7 @@
[SMC_ENTITY_SECURE_MONITOR + 1 ... SMC_NUM_ENTITIES - 1] =
smc_undefined};
-status_t sm_register_entity(uint entity_nr, smc32_entity_t* entity) {
+status_t sm_register_entity(uint entity_nr, struct smc32_entity* entity) {
status_t err = NO_ERROR;
if (entity_nr >= SMC_NUM_ENTITIES)
diff --git a/lib/trusty/smcall.c b/lib/trusty/smcall.c
index 8b944a0..fe0b2f4 100644
--- a/lib/trusty/smcall.c
+++ b/lib/trusty/smcall.c
@@ -98,7 +98,7 @@
/*
* Handle fastcall Trusted OS SMC call function
*/
-static long trusty_sm_fastcall(smc32_args_t* args) {
+static long trusty_sm_fastcall(struct smc32_args* args) {
long res;
ns_size_t ns_sz;
ns_paddr_t ns_pa;
@@ -126,7 +126,7 @@
/*
* Handle standard Trusted OS SMC call function
*/
-static long trusty_sm_stdcall(smc32_args_t* args) {
+static long trusty_sm_stdcall(struct smc32_args* args) {
long res;
ns_size_t ns_sz;
ns_paddr_t ns_pa;
@@ -193,7 +193,7 @@
/*
* Handle parameterized NOP Trusted OS SMC call function
*/
-static long trusty_sm_nopcall(smc32_args_t* args) {
+static long trusty_sm_nopcall(struct smc32_args* args) {
long res;
LTRACEF("Trusty SM service func %u args 0x%x 0x%x 0x%x\n",
@@ -214,7 +214,7 @@
return to_smc_error(res);
}
-static smc32_entity_t trusty_sm_entity = {
+static struct smc32_entity trusty_sm_entity = {
.fastcall_handler = trusty_sm_fastcall,
.stdcall_handler = trusty_sm_stdcall,
.nopcall_handler = trusty_sm_nopcall,