Browse Source

Remove some MISRA defects in common code

No functional changes.

Change-Id: I9638e02acb9b22eb794ebf45aad84348a710287e
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
pull/1611/head
Antonio Nino Diaz 6 years ago
parent
commit
81542c00d0
  1. 4
      bl31/aarch64/bl31_entrypoint.S
  2. 33
      common/bl_common.c
  3. 42
      common/desc_image_load.c
  4. 34
      common/runtime_svc.c
  5. 52
      include/common/bl_common.h
  6. 2
      include/common/fdt_wrappers.h
  7. 53
      include/common/runtime_svc.h
  8. 28
      include/lib/aarch32/smccc_helpers.h
  9. 3
      include/lib/aarch64/smccc_helpers.h
  10. 4
      include/lib/pmf/pmf_asm_macros.S
  11. 18
      include/lib/runtime_instr.h
  12. 9
      include/plat/common/common_def.h

4
bl31/aarch64/bl31_entrypoint.S

@ -124,7 +124,7 @@ func bl31_warm_entrypoint
* timestamp collection will need to do cache maintenance prior * timestamp collection will need to do cache maintenance prior
* to timestamp update. * to timestamp update.
*/ */
pmf_calc_timestamp_addr rt_instr_svc RT_INSTR_EXIT_HW_LOW_PWR pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_HW_LOW_PWR
mrs x1, cntpct_el0 mrs x1, cntpct_el0
str x1, [x0] str x1, [x0]
#endif #endif
@ -180,7 +180,7 @@ func bl31_warm_entrypoint
bl psci_warmboot_entrypoint bl psci_warmboot_entrypoint
#if ENABLE_RUNTIME_INSTRUMENTATION #if ENABLE_RUNTIME_INSTRUMENTATION
pmf_calc_timestamp_addr rt_instr_svc RT_INSTR_EXIT_PSCI pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_PSCI
mov x19, x0 mov x19, x0
/* /*

33
common/bl_common.c

@ -48,8 +48,8 @@ static int dyn_is_auth_disabled(void)
uintptr_t page_align(uintptr_t value, unsigned dir) uintptr_t page_align(uintptr_t value, unsigned dir)
{ {
/* Round up the limit to the next page boundary */ /* Round up the limit to the next page boundary */
if (value & (PAGE_SIZE - 1)) { if ((value & (PAGE_SIZE - 1U)) != 0U) {
value &= ~(PAGE_SIZE - 1); value &= ~(PAGE_SIZE - 1U);
if (dir == UP) if (dir == UP)
value += PAGE_SIZE; value += PAGE_SIZE;
} }
@ -106,7 +106,7 @@ size_t get_image_size(unsigned int image_id)
uintptr_t dev_handle; uintptr_t dev_handle;
uintptr_t image_handle; uintptr_t image_handle;
uintptr_t image_spec; uintptr_t image_spec;
size_t image_size = 0; size_t image_size = 0U;
int io_result; int io_result;
/* Obtain a reference to the image by querying the platform layer */ /* Obtain a reference to the image by querying the platform layer */
@ -127,7 +127,7 @@ size_t get_image_size(unsigned int image_id)
/* Find the size of the image */ /* Find the size of the image */
io_result = io_size(image_handle, &image_size); io_result = io_size(image_handle, &image_size);
if ((io_result != 0) || (image_size == 0)) { if ((io_result != 0) || (image_size == 0U)) {
WARN("Failed to determine the size of the image id=%u (%i)\n", WARN("Failed to determine the size of the image id=%u (%i)\n",
image_id, io_result); image_id, io_result);
} }
@ -182,12 +182,11 @@ static int load_image(unsigned int image_id, image_info_t *image_data)
return io_result; return io_result;
} }
INFO("Loading image id=%u at address %p\n", image_id, INFO("Loading image id=%u at address 0x%lx\n", image_id, image_base);
(void *) image_base);
/* Find the size of the image */ /* Find the size of the image */
io_result = io_size(image_handle, &image_size); io_result = io_size(image_handle, &image_size);
if ((io_result != 0) || (image_size == 0)) { if ((io_result != 0) || (image_size == 0U)) {
WARN("Failed to determine the size of the image id=%u (%i)\n", WARN("Failed to determine the size of the image id=%u (%i)\n",
image_id, io_result); image_id, io_result);
goto exit; goto exit;
@ -200,7 +199,11 @@ static int load_image(unsigned int image_id, image_info_t *image_data)
goto exit; goto exit;
} }
image_data->image_size = image_size; /*
* image_data->image_max_size is a uint32_t so image_size will always
* fit in image_data->image_size.
*/
image_data->image_size = (uint32_t)image_size;
/* We have enough space so load the image now */ /* We have enough space so load the image now */
/* TODO: Consider whether to try to recover/retry a partially successful read */ /* TODO: Consider whether to try to recover/retry a partially successful read */
@ -210,15 +213,15 @@ static int load_image(unsigned int image_id, image_info_t *image_data)
goto exit; goto exit;
} }
INFO("Image id=%u loaded: %p - %p\n", image_id, (void *) image_base, INFO("Image id=%u loaded: 0x%lx - 0x%lx\n", image_id, image_base,
(void *) (image_base + image_size)); (uintptr_t)(image_base + image_size));
exit: exit:
io_close(image_handle); (void)io_close(image_handle);
/* Ignore improbable/unrecoverable error in 'close' */ /* Ignore improbable/unrecoverable error in 'close' */
/* TODO: Consider maintaining open device connection from this bootloader stage */ /* TODO: Consider maintaining open device connection from this bootloader stage */
io_dev_close(dev_handle); (void)io_dev_close(dev_handle);
/* Ignore improbable/unrecoverable error in 'dev_close' */ /* Ignore improbable/unrecoverable error in 'dev_close' */
return io_result; return io_result;
@ -274,7 +277,7 @@ static int load_auth_image_internal(unsigned int image_id,
* the file has been successfully loaded and authenticated and flush * the file has been successfully loaded and authenticated and flush
* only for child images, not for the parents (certificates). * only for child images, not for the parents (certificates).
*/ */
if (!is_parent_image) { if (is_parent_image == 0) {
flush_dcache_range(image_data->image_base, flush_dcache_range(image_data->image_base,
image_data->image_size); image_data->image_size);
} }
@ -296,7 +299,7 @@ int load_auth_image(unsigned int image_id, image_info_t *image_data)
do { do {
err = load_auth_image_internal(image_id, image_data, 0); err = load_auth_image_internal(image_id, image_data, 0);
} while (err != 0 && plat_try_next_boot_source()); } while ((err != 0) && (plat_try_next_boot_source() != 0));
return err; return err;
} }
@ -306,7 +309,7 @@ int load_auth_image(unsigned int image_id, image_info_t *image_data)
******************************************************************************/ ******************************************************************************/
void print_entry_point_info(const entry_point_info_t *ep_info) void print_entry_point_info(const entry_point_info_t *ep_info)
{ {
INFO("Entry point address = %p\n", (void *)ep_info->pc); INFO("Entry point address = 0x%lx\n", ep_info->pc);
INFO("SPSR = 0x%x\n", ep_info->spsr); INFO("SPSR = 0x%x\n", ep_info->spsr);
#define PRINT_IMAGE_ARG(n) \ #define PRINT_IMAGE_ARG(n) \

42
common/desc_image_load.c

@ -35,12 +35,12 @@ void flush_bl_params_desc(void)
******************************************************************************/ ******************************************************************************/
int get_bl_params_node_index(unsigned int image_id) int get_bl_params_node_index(unsigned int image_id)
{ {
int index; unsigned int index;
assert(image_id != INVALID_IMAGE_ID); assert(image_id != INVALID_IMAGE_ID);
for (index = 0; index < bl_mem_params_desc_num; index++) { for (index = 0U; index < bl_mem_params_desc_num; index++) {
if (bl_mem_params_desc_ptr[index].image_id == image_id) if (bl_mem_params_desc_ptr[index].image_id == image_id)
return index; return (int)index;
} }
return -1; return -1;
@ -72,17 +72,17 @@ bl_mem_params_node_t *get_bl_mem_params_node(unsigned int image_id)
******************************************************************************/ ******************************************************************************/
bl_load_info_t *get_bl_load_info_from_mem_params_desc(void) bl_load_info_t *get_bl_load_info_from_mem_params_desc(void)
{ {
int index = 0; unsigned int index = 0;
/* If there is no image to start with, return NULL */ /* If there is no image to start with, return NULL */
if (!bl_mem_params_desc_num) if (bl_mem_params_desc_num == 0U)
return NULL; return NULL;
/* Assign initial data structures */ /* Assign initial data structures */
bl_load_info_node_t *bl_node_info = bl_load_info_node_t *bl_node_info =
&bl_mem_params_desc_ptr[index].load_node_mem; &bl_mem_params_desc_ptr[index].load_node_mem;
bl_load_info.head = bl_node_info; bl_load_info.head = bl_node_info;
SET_PARAM_HEAD(&bl_load_info, PARAM_BL_LOAD_INFO, VERSION_2, 0); SET_PARAM_HEAD(&bl_load_info, PARAM_BL_LOAD_INFO, VERSION_2, 0U);
/* Go through the image descriptor array and create the list */ /* Go through the image descriptor array and create the list */
for (; index < bl_mem_params_desc_num; index++) { for (; index < bl_mem_params_desc_num; index++) {
@ -92,10 +92,10 @@ bl_load_info_t *get_bl_load_info_from_mem_params_desc(void)
bl_node_info->image_info = &bl_mem_params_desc_ptr[index].image_info; bl_node_info->image_info = &bl_mem_params_desc_ptr[index].image_info;
/* Link next image if present */ /* Link next image if present */
if ((index + 1) < bl_mem_params_desc_num) { if ((index + 1U) < bl_mem_params_desc_num) {
/* Get the memory and link the next node */ /* Get the memory and link the next node */
bl_node_info->next_load_info = bl_node_info->next_load_info =
&bl_mem_params_desc_ptr[index + 1].load_node_mem; &bl_mem_params_desc_ptr[index + 1U].load_node_mem;
bl_node_info = bl_node_info->next_load_info; bl_node_info = bl_node_info->next_load_info;
} }
} }
@ -112,19 +112,19 @@ bl_load_info_t *get_bl_load_info_from_mem_params_desc(void)
******************************************************************************/ ******************************************************************************/
bl_params_t *get_next_bl_params_from_mem_params_desc(void) bl_params_t *get_next_bl_params_from_mem_params_desc(void)
{ {
int count; unsigned int count;
unsigned int img_id = 0; unsigned int img_id = 0U;
int link_index = 0; unsigned int link_index = 0U;
bl_params_node_t *bl_current_exec_node = NULL; bl_params_node_t *bl_current_exec_node = NULL;
bl_params_node_t *bl_last_exec_node = NULL; bl_params_node_t *bl_last_exec_node = NULL;
bl_mem_params_node_t *desc_ptr; bl_mem_params_node_t *desc_ptr;
/* If there is no image to start with, return NULL */ /* If there is no image to start with, return NULL */
if (!bl_mem_params_desc_num) if (bl_mem_params_desc_num == 0U)
return NULL; return NULL;
/* Get the list HEAD */ /* Get the list HEAD */
for (count = 0; count < bl_mem_params_desc_num; count++) { for (count = 0U; count < bl_mem_params_desc_num; count++) {
desc_ptr = &bl_mem_params_desc_ptr[count]; desc_ptr = &bl_mem_params_desc_ptr[count];
@ -140,13 +140,13 @@ bl_params_t *get_next_bl_params_from_mem_params_desc(void)
assert(next_bl_params.head != NULL); assert(next_bl_params.head != NULL);
/* Populate the HEAD information */ /* Populate the HEAD information */
SET_PARAM_HEAD(&next_bl_params, PARAM_BL_PARAMS, VERSION_2, 0); SET_PARAM_HEAD(&next_bl_params, PARAM_BL_PARAMS, VERSION_2, 0U);
/* /*
* Go through the image descriptor array and create the list. * Go through the image descriptor array and create the list.
* This bounded loop is to make sure that we are not looping forever. * This bounded loop is to make sure that we are not looping forever.
*/ */
for (count = 0 ; count < bl_mem_params_desc_num; count++) { for (count = 0U; count < bl_mem_params_desc_num; count++) {
desc_ptr = &bl_mem_params_desc_ptr[link_index]; desc_ptr = &bl_mem_params_desc_ptr[link_index];
@ -161,7 +161,7 @@ bl_params_t *get_next_bl_params_from_mem_params_desc(void)
bl_current_exec_node->image_info = &desc_ptr->image_info; bl_current_exec_node->image_info = &desc_ptr->image_info;
bl_current_exec_node->ep_info = &desc_ptr->ep_info; bl_current_exec_node->ep_info = &desc_ptr->ep_info;
if (bl_last_exec_node) { if (bl_last_exec_node != NULL) {
/* Assert if loop detected */ /* Assert if loop detected */
assert(bl_last_exec_node->next_params_info == NULL); assert(bl_last_exec_node->next_params_info == NULL);
@ -179,7 +179,7 @@ bl_params_t *get_next_bl_params_from_mem_params_desc(void)
/* Get the index for the next hand-off image */ /* Get the index for the next hand-off image */
link_index = get_bl_params_node_index(img_id); link_index = get_bl_params_node_index(img_id);
assert((link_index > 0) && assert((link_index > 0U) &&
(link_index < bl_mem_params_desc_num)); (link_index < bl_mem_params_desc_num));
} }
@ -243,17 +243,17 @@ void populate_next_bl_params_config(bl_params_t *bl2_to_next_bl_params)
* overwriting the previous initialisations. * overwriting the previous initialisations.
*/ */
if (params_node == bl2_to_next_bl_params->head) { if (params_node == bl2_to_next_bl_params->head) {
if (params_node->ep_info->args.arg1 == 0) if (params_node->ep_info->args.arg1 == 0U)
params_node->ep_info->args.arg1 = params_node->ep_info->args.arg1 =
fw_config_base; fw_config_base;
if (params_node->ep_info->args.arg2 == 0) if (params_node->ep_info->args.arg2 == 0U)
params_node->ep_info->args.arg2 = params_node->ep_info->args.arg2 =
hw_config_base; hw_config_base;
} else { } else {
if (params_node->ep_info->args.arg0 == 0) if (params_node->ep_info->args.arg0 == 0U)
params_node->ep_info->args.arg0 = params_node->ep_info->args.arg0 =
fw_config_base; fw_config_base;
if (params_node->ep_info->args.arg1 == 0) if (params_node->ep_info->args.arg1 == 0U)
params_node->ep_info->args.arg1 = params_node->ep_info->args.arg1 =
hw_config_base; hw_config_base;
} }

34
common/runtime_svc.c

@ -35,16 +35,16 @@ uintptr_t handle_runtime_svc(uint32_t smc_fid,
unsigned int flags) unsigned int flags)
{ {
u_register_t x1, x2, x3, x4; u_register_t x1, x2, x3, x4;
int index; unsigned int index;
unsigned int idx; unsigned int idx;
const rt_svc_desc_t *rt_svc_descs; const rt_svc_desc_t *rt_svc_descs;
assert(handle); assert(handle != NULL);
idx = get_unique_oen_from_smc_fid(smc_fid); idx = get_unique_oen_from_smc_fid(smc_fid);
assert(idx < MAX_RT_SVCS); assert(idx < MAX_RT_SVCS);
index = rt_svc_descs_indices[idx]; index = rt_svc_descs_indices[idx];
if (index < 0 || index >= (int)RT_SVC_DECS_NUM) if (index >= RT_SVC_DECS_NUM)
SMC_RET1(handle, SMC_UNK); SMC_RET1(handle, SMC_UNK);
rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START; rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START;
@ -96,7 +96,7 @@ static int32_t validate_rt_svc_desc(const rt_svc_desc_t *desc)
void __init runtime_svc_init(void) void __init runtime_svc_init(void)
{ {
int rc = 0; int rc = 0;
unsigned int index, start_idx, end_idx; uint8_t index, start_idx, end_idx;
rt_svc_desc_t *rt_svc_descs; rt_svc_desc_t *rt_svc_descs;
/* Assert the number of descriptors detected are less than maximum indices */ /* Assert the number of descriptors detected are less than maximum indices */
@ -108,10 +108,10 @@ void __init runtime_svc_init(void)
return; return;
/* Initialise internal variables to invalid state */ /* Initialise internal variables to invalid state */
memset(rt_svc_descs_indices, -1, sizeof(rt_svc_descs_indices)); (void)memset(rt_svc_descs_indices, -1, sizeof(rt_svc_descs_indices));
rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START; rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START;
for (index = 0; index < RT_SVC_DECS_NUM; index++) { for (index = 0U; index < RT_SVC_DECS_NUM; index++) {
rt_svc_desc_t *service = &rt_svc_descs[index]; rt_svc_desc_t *service = &rt_svc_descs[index];
/* /*
@ -120,7 +120,7 @@ void __init runtime_svc_init(void)
* of this service. * of this service.
*/ */
rc = validate_rt_svc_desc(service); rc = validate_rt_svc_desc(service);
if (rc) { if (rc != 0) {
ERROR("Invalid runtime service descriptor %p\n", ERROR("Invalid runtime service descriptor %p\n",
(void *) service); (void *) service);
panic(); panic();
@ -133,9 +133,9 @@ void __init runtime_svc_init(void)
* an initialisation routine defined. Call the initialisation * an initialisation routine defined. Call the initialisation
* routine for this runtime service, if it is defined. * routine for this runtime service, if it is defined.
*/ */
if (service->init) { if (service->init != NULL) {
rc = service->init(); rc = service->init();
if (rc) { if (rc != 0) {
ERROR("Error initializing runtime service %s\n", ERROR("Error initializing runtime service %s\n",
service->name); service->name);
continue; continue;
@ -149,15 +149,15 @@ void __init runtime_svc_init(void)
* entity range. * entity range.
*/ */
#if SMCCC_MAJOR_VERSION == 1 #if SMCCC_MAJOR_VERSION == 1
start_idx = get_unique_oen(service->start_oen, start_idx = (uint8_t)get_unique_oen(service->start_oen,
service->call_type); service->call_type);
end_idx = get_unique_oen(service->end_oen, end_idx = (uint8_t)get_unique_oen(service->end_oen,
service->call_type); service->call_type);
#elif SMCCC_MAJOR_VERSION == 2 #elif SMCCC_MAJOR_VERSION == 2
start_idx = get_rt_desc_idx(service->start_oen, start_idx = (uint8_t)get_rt_desc_idx(service->start_oen,
service->is_vendor); service->is_vendor);
end_idx = get_rt_desc_idx(service->end_oen, end_idx = (uint8_t)get_rt_desc_idx(service->end_oen,
service->is_vendor); service->is_vendor);
#endif #endif
assert(start_idx <= end_idx); assert(start_idx <= end_idx);
assert(end_idx < MAX_RT_SVCS); assert(end_idx < MAX_RT_SVCS);

52
include/common/bl_common.h

@ -11,26 +11,26 @@
#include <param_header.h> #include <param_header.h>
#include <utils_def.h> #include <utils_def.h>
#define UP 1 #define UP U(1)
#define DOWN 0 #define DOWN U(0)
/******************************************************************************* /*******************************************************************************
* Constants to identify the location of a memory region in a given memory * Constants to identify the location of a memory region in a given memory
* layout. * layout.
******************************************************************************/ ******************************************************************************/
#define TOP 0x1 #define TOP U(0x1)
#define BOTTOM !TOP #define BOTTOM U(0x0)
/* /*
* The following are used for image state attributes. * The following are used for image state attributes.
* Image can only be in one of the following state. * Image can only be in one of the following state.
*/ */
#define IMAGE_STATE_RESET 0 #define IMAGE_STATE_RESET U(0)
#define IMAGE_STATE_COPIED 1 #define IMAGE_STATE_COPIED U(1)
#define IMAGE_STATE_COPYING 2 #define IMAGE_STATE_COPYING U(2)
#define IMAGE_STATE_AUTHENTICATED 3 #define IMAGE_STATE_AUTHENTICATED U(3)
#define IMAGE_STATE_EXECUTED 4 #define IMAGE_STATE_EXECUTED U(4)
#define IMAGE_STATE_INTERRUPTED 5 #define IMAGE_STATE_INTERRUPTED U(5)
#define IMAGE_ATTRIB_SKIP_LOADING U(0x02) #define IMAGE_ATTRIB_SKIP_LOADING U(0x02)
#define IMAGE_ATTRIB_PLAT_SETUP U(0x04) #define IMAGE_ATTRIB_PLAT_SETUP U(0x04)
@ -40,22 +40,22 @@
/******************************************************************************* /*******************************************************************************
* Constants to indicate type of exception to the common exception handler. * Constants to indicate type of exception to the common exception handler.
******************************************************************************/ ******************************************************************************/
#define SYNC_EXCEPTION_SP_EL0 0x0 #define SYNC_EXCEPTION_SP_EL0 U(0x0)
#define IRQ_SP_EL0 0x1 #define IRQ_SP_EL0 U(0x1)
#define FIQ_SP_EL0 0x2 #define FIQ_SP_EL0 U(0x2)
#define SERROR_SP_EL0 0x3 #define SERROR_SP_EL0 U(0x3)
#define SYNC_EXCEPTION_SP_ELX 0x4 #define SYNC_EXCEPTION_SP_ELX U(0x4)
#define IRQ_SP_ELX 0x5 #define IRQ_SP_ELX U(0x5)
#define FIQ_SP_ELX 0x6 #define FIQ_SP_ELX U(0x6)
#define SERROR_SP_ELX 0x7 #define SERROR_SP_ELX U(0x7)
#define SYNC_EXCEPTION_AARCH64 0x8 #define SYNC_EXCEPTION_AARCH64 U(0x8)
#define IRQ_AARCH64 0x9 #define IRQ_AARCH64 U(0x9)
#define FIQ_AARCH64 0xa #define FIQ_AARCH64 U(0xa)
#define SERROR_AARCH64 0xb #define SERROR_AARCH64 U(0xb)
#define SYNC_EXCEPTION_AARCH32 0xc #define SYNC_EXCEPTION_AARCH32 U(0xc)
#define IRQ_AARCH32 0xd #define IRQ_AARCH32 U(0xd)
#define FIQ_AARCH32 0xe #define FIQ_AARCH32 U(0xe)
#define SERROR_AARCH32 0xf #define SERROR_AARCH32 U(0xf)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h> #include <cassert.h>

2
include/common/fdt_wrappers.h

@ -10,7 +10,7 @@
#define __FDT_WRAPPERS__ #define __FDT_WRAPPERS__
/* Number of cells, given total length in bytes. Each cell is 4 bytes long */ /* Number of cells, given total length in bytes. Each cell is 4 bytes long */
#define NCELLS(len) ((len) / 4) #define NCELLS(len) ((len) / 4U)
int fdtw_read_cells(const void *dtb, int node, const char *prop, int fdtw_read_cells(const void *dtb, int node, const char *prop,
unsigned int cells, void *value); unsigned int cells, void *value);

53
include/common/runtime_svc.h

@ -21,15 +21,15 @@
* descriptor * descriptor
*/ */
#ifdef AARCH32 #ifdef AARCH32
#define RT_SVC_SIZE_LOG2 4 #define RT_SVC_SIZE_LOG2 U(4)
#define RT_SVC_DESC_INIT 8 #define RT_SVC_DESC_INIT U(8)
#define RT_SVC_DESC_HANDLE 12 #define RT_SVC_DESC_HANDLE U(12)
#else #else
#define RT_SVC_SIZE_LOG2 5 #define RT_SVC_SIZE_LOG2 U(5)
#define RT_SVC_DESC_INIT 16 #define RT_SVC_DESC_INIT U(16)
#define RT_SVC_DESC_HANDLE 24 #define RT_SVC_DESC_HANDLE U(24)
#endif /* AARCH32 */ #endif /* AARCH32 */
#define SIZEOF_RT_SVC_DESC (1 << RT_SVC_SIZE_LOG2) #define SIZEOF_RT_SVC_DESC (U(1) << RT_SVC_SIZE_LOG2)
/* /*
@ -43,9 +43,9 @@
* handler and so the total number of runtime services is 32. * handler and so the total number of runtime services is 32.
*/ */
#if SMCCC_MAJOR_VERSION == 1 #if SMCCC_MAJOR_VERSION == 1
#define MAX_RT_SVCS 128 #define MAX_RT_SVCS U(128)
#elif SMCCC_MAJOR_VERSION == 2 #elif SMCCC_MAJOR_VERSION == 2
#define MAX_RT_SVCS 32 #define MAX_RT_SVCS U(32)
#endif #endif
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
@ -146,35 +146,42 @@ CASSERT(RT_SVC_DESC_HANDLE == __builtin_offsetof(rt_svc_desc_t, handle), \
#if SMCCC_MAJOR_VERSION == 1 #if SMCCC_MAJOR_VERSION == 1
/* /*
* This macro combines the call type and the owning entity number corresponding * This function combines the call type and the owning entity number
* to a runtime service to generate a unique owning entity number. This unique * corresponding to a runtime service to generate a unique owning entity number.
* oen is used to access an entry in the 'rt_svc_descs_indices' array. The entry * This unique oen is used to access an entry in the 'rt_svc_descs_indices'
* contains the index of the service descriptor in the 'rt_svc_descs' array. * array. The entry contains the index of the service descriptor in the
* 'rt_svc_descs' array.
*/ */
#define get_unique_oen(oen, call_type) \ static inline uint32_t get_unique_oen(uint32_t oen, uint32_t call_type)
(((uint32_t)(oen) & FUNCID_OEN_MASK) | \ {
(((uint32_t)(call_type) & FUNCID_TYPE_MASK) << FUNCID_OEN_WIDTH)) return ((call_type & FUNCID_TYPE_MASK) << FUNCID_OEN_WIDTH) |
(oen & FUNCID_OEN_MASK);
}
/* /*
* This macro generates the unique owning entity number from the SMC Function * This function generates the unique owning entity number from the SMC Function
* ID. This unique oen is used to access an entry in the 'rt_svc_descs_indices' * ID. This unique oen is used to access an entry in the 'rt_svc_descs_indices'
* array to invoke the corresponding runtime service handler during SMC * array to invoke the corresponding runtime service handler during SMC
* handling. * handling.
*/ */
#define get_unique_oen_from_smc_fid(fid) \ static inline uint32_t get_unique_oen_from_smc_fid(uint32_t fid)
get_unique_oen(GET_SMC_OEN(fid), GET_SMC_TYPE(fid)) {
return get_unique_oen(GET_SMC_OEN(fid), GET_SMC_TYPE(fid));
}
#elif SMCCC_MAJOR_VERSION == 2 #elif SMCCC_MAJOR_VERSION == 2
/* /*
* This macro combines the owning entity number corresponding to a runtime * This function combines the owning entity number corresponding to a runtime
* service with one extra bit for the vendor namespace to generate an index into * service with one extra bit for the vendor namespace to generate an index into
* the 'rt_svc_descs_indices' array. The entry contains the index of the service * the 'rt_svc_descs_indices' array. The entry contains the index of the service
* descriptor in the 'rt_svc_descs' array. * descriptor in the 'rt_svc_descs' array.
*/ */
#define get_rt_desc_idx(oen, is_vendor) \ static inline uint32_t get_rt_desc_idx(uint32_t oen, uint32_t is_vendor)
(((uint32_t)(oen) & FUNCID_OEN_MASK) | \ {
(((uint32_t)(is_vendor) & 1U) << FUNCID_OEN_WIDTH)) return ((is_vendor & 1U) << FUNCID_OEN_WIDTH) |
(oen & FUNCID_OEN_MASK);
}
#endif #endif

28
include/lib/aarch32/smccc_helpers.h

@ -10,19 +10,19 @@
#include <smccc.h> #include <smccc.h>
/* These are offsets to registers in smc_ctx_t */ /* These are offsets to registers in smc_ctx_t */
#define SMC_CTX_GPREG_R0 0x0 #define SMC_CTX_GPREG_R0 U(0x0)
#define SMC_CTX_GPREG_R1 0x4 #define SMC_CTX_GPREG_R1 U(0x4)
#define SMC_CTX_GPREG_R2 0x8 #define SMC_CTX_GPREG_R2 U(0x8)
#define SMC_CTX_GPREG_R3 0xC #define SMC_CTX_GPREG_R3 U(0xC)
#define SMC_CTX_GPREG_R4 0x10 #define SMC_CTX_GPREG_R4 U(0x10)
#define SMC_CTX_GPREG_R5 0x14 #define SMC_CTX_GPREG_R5 U(0x14)
#define SMC_CTX_SP_USR 0x34 #define SMC_CTX_SP_USR U(0x34)
#define SMC_CTX_SPSR_MON 0x78 #define SMC_CTX_SPSR_MON U(0x78)
#define SMC_CTX_SP_MON 0x7C #define SMC_CTX_SP_MON U(0x7C)
#define SMC_CTX_LR_MON 0x80 #define SMC_CTX_LR_MON U(0x80)
#define SMC_CTX_SCR 0x84 #define SMC_CTX_SCR U(0x84)
#define SMC_CTX_PMCR 0x88 #define SMC_CTX_PMCR U(0x88)
#define SMC_CTX_SIZE 0x90 #define SMC_CTX_SIZE U(0x90)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h> #include <cassert.h>
@ -105,7 +105,7 @@ CASSERT(SMC_CTX_LR_MON == __builtin_offsetof(smc_ctx_t, lr_mon), \
CASSERT(SMC_CTX_SPSR_MON == __builtin_offsetof(smc_ctx_t, spsr_mon), \ CASSERT(SMC_CTX_SPSR_MON == __builtin_offsetof(smc_ctx_t, spsr_mon), \
assert_smc_ctx_spsr_mon_offset_mismatch); assert_smc_ctx_spsr_mon_offset_mismatch);
CASSERT((sizeof(smc_ctx_t) & 0x7) == 0, assert_smc_ctx_not_aligned); CASSERT((sizeof(smc_ctx_t) & 0x7U) == 0U, assert_smc_ctx_not_aligned);
CASSERT(SMC_CTX_SIZE == sizeof(smc_ctx_t), assert_smc_ctx_size_mismatch); CASSERT(SMC_CTX_SIZE == sizeof(smc_ctx_t), assert_smc_ctx_size_mismatch);
/* Convenience macros to return from SMC handler */ /* Convenience macros to return from SMC handler */

3
include/lib/aarch64/smccc_helpers.h

@ -11,6 +11,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <context.h> #include <context.h>
#include <stdbool.h>
/* Convenience macros to return from SMC handler */ /* Convenience macros to return from SMC handler */
#define SMC_RET0(_h) { \ #define SMC_RET0(_h) { \
@ -77,7 +78,7 @@
_x2 = read_ctx_reg(regs, CTX_GPREG_X2); \ _x2 = read_ctx_reg(regs, CTX_GPREG_X2); \
_x3 = read_ctx_reg(regs, CTX_GPREG_X3); \ _x3 = read_ctx_reg(regs, CTX_GPREG_X3); \
_x4 = read_ctx_reg(regs, CTX_GPREG_X4); \ _x4 = read_ctx_reg(regs, CTX_GPREG_X4); \
} while (0) } while (false)
#endif /*__ASSEMBLY__*/ #endif /*__ASSEMBLY__*/

4
include/lib/pmf/pmf_asm_macros.S

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -14,7 +14,7 @@
* for the given service name and local timestamp id. * for the given service name and local timestamp id.
* Clobbers: x0 - x9 * Clobbers: x0 - x9
*/ */
.macro pmf_calc_timestamp_addr _name _tid .macro pmf_calc_timestamp_addr _name, _tid
mov x9, x30 mov x9, x30
bl plat_my_core_pos bl plat_my_core_pos
mov x30, x9 mov x30, x9

18
include/lib/runtime_instr.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -7,13 +7,15 @@
#ifndef __RUNTIME_INSTR_H__ #ifndef __RUNTIME_INSTR_H__
#define __RUNTIME_INSTR_H__ #define __RUNTIME_INSTR_H__
#define RT_INSTR_ENTER_PSCI 0 #include <utils_def.h>
#define RT_INSTR_EXIT_PSCI 1
#define RT_INSTR_ENTER_HW_LOW_PWR 2 #define RT_INSTR_ENTER_PSCI U(0)
#define RT_INSTR_EXIT_HW_LOW_PWR 3 #define RT_INSTR_EXIT_PSCI U(1)
#define RT_INSTR_ENTER_CFLUSH 4 #define RT_INSTR_ENTER_HW_LOW_PWR U(2)
#define RT_INSTR_EXIT_CFLUSH 5 #define RT_INSTR_EXIT_HW_LOW_PWR U(3)
#define RT_INSTR_TOTAL_IDS 6 #define RT_INSTR_ENTER_CFLUSH U(4)
#define RT_INSTR_EXIT_CFLUSH U(5)
#define RT_INSTR_TOTAL_IDS U(6)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
PMF_DECLARE_CAPTURE_TIMESTAMP(rt_instr_svc) PMF_DECLARE_CAPTURE_TIMESTAMP(rt_instr_svc)

9
include/plat/common/common_def.h

@ -8,6 +8,7 @@
#include <bl_common.h> #include <bl_common.h>
#include <platform_def.h> #include <platform_def.h>
#include <utils_def.h>
#include <xlat_tables_defs.h> #include <xlat_tables_defs.h>
/****************************************************************************** /******************************************************************************
@ -73,12 +74,12 @@
#define BL2_RO_DATA_END round_up(BL2_ROM_END, PAGE_SIZE) #define BL2_RO_DATA_END round_up(BL2_ROM_END, PAGE_SIZE)
#endif /* BL2_IN_XIP_MEM */ #endif /* BL2_IN_XIP_MEM */
#else #else
#define BL_RO_DATA_BASE 0 #define BL_RO_DATA_BASE UL(0)
#define BL_RO_DATA_END 0 #define BL_RO_DATA_END UL(0)
#define BL1_CODE_END round_up(BL1_ROM_END, PAGE_SIZE) #define BL1_CODE_END round_up(BL1_ROM_END, PAGE_SIZE)
#if BL2_IN_XIP_MEM #if BL2_IN_XIP_MEM
#define BL2_RO_DATA_BASE 0 #define BL2_RO_DATA_BASE UL(0)
#define BL2_RO_DATA_END 0 #define BL2_RO_DATA_END UL(0)
#define BL2_CODE_END round_up(BL2_ROM_END, PAGE_SIZE) #define BL2_CODE_END round_up(BL2_ROM_END, PAGE_SIZE)
#endif /* BL2_IN_XIP_MEM */ #endif /* BL2_IN_XIP_MEM */
#endif /* SEPARATE_CODE_AND_RODATA */ #endif /* SEPARATE_CODE_AND_RODATA */

Loading…
Cancel
Save