Browse Source

Merge changes from topic "fix_misra_st_platform" into integration

* changes:
  fix(stm32mp1): rework DWL buffer cache invalidation
  fix(stm32mp1): add const for strings in stm32mp_get_soc_name()
  fix(st): use Boolean type for tests
  fix(st): rework secure-status check in fdt_get_status()
  fix(st): use indices when counting GPIOs in DT
  fix(st): add U suffix for unsigned numbers
  fix(st): explicitly check operators precedence
pull/1992/head
Manish Pandey 2 years ago
committed by TrustedFirmware Code Review
parent
commit
d6ce990789
  1. 2
      plat/st/common/bl2_io_storage.c
  2. 5
      plat/st/common/include/stm32mp_efi.h
  3. 19
      plat/st/common/stm32mp_dt.c
  4. 13
      plat/st/stm32mp1/bl2_plat_setup.c
  5. 9
      plat/st/stm32mp1/stm32mp1_fconf_firewall.c
  6. 14
      plat/st/stm32mp1/stm32mp1_private.c
  7. 4
      plat/st/stm32mp1/stm32mp1_syscfg.c

2
plat/st/common/bl2_io_storage.c

@ -607,7 +607,7 @@ int plat_get_image_source(unsigned int image_id, uintptr_t *dev_handle,
* - we already boot FWU_MAX_TRIAL_REBOOT times in trial mode.
* we select the previous_active_index.
*/
#define INVALID_BOOT_IDX 0xFFFFFFFF
#define INVALID_BOOT_IDX 0xFFFFFFFFU
uint32_t plat_fwu_get_boot_idx(void)
{

5
plat/st/common/include/stm32mp_efi.h

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright (c) 2021, Linaro Limited
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*/
#ifndef STM32MP_EFI_H
@ -9,7 +10,7 @@
#include <drivers/partition/efi.h>
#define STM32MP_FIP_GUID \
EFI_GUID(0x19d5df83, 0x11b0, 0x457b, \
0xbe, 0x2c, 0x75, 0x59, 0xc1, 0x31, 0x42, 0xa5)
EFI_GUID(0x19d5df83U, 0x11b0U, 0x457bU, \
0xbeU, 0x2cU, 0x75U, 0x59U, 0xc1U, 0x31U, 0x42U, 0xa5U)
#endif /* STM32MP_EFI_H */

19
plat/st/common/stm32mp_dt.c

@ -79,11 +79,8 @@ uint8_t fdt_get_status(int node)
}
cchar = fdt_getprop(fdt, node, "secure-status", NULL);
if (cchar == NULL) {
if (status == DT_NON_SECURE) {
status |= DT_SECURE;
}
} else if (strncmp(cchar, "okay", strlen("okay")) == 0) {
if (((cchar == NULL) && (status == DT_NON_SECURE)) ||
((cchar != NULL) && (strncmp(cchar, "okay", strlen("okay")) == 0))) {
status |= DT_SECURE;
}
@ -350,7 +347,7 @@ int dt_find_otp_name(const char *name, uint32_t *otp, uint32_t *otp_len)
return -FDT_ERR_BADVALUE;
}
if (fdt32_to_cpu(*cuint) % sizeof(uint32_t)) {
if ((fdt32_to_cpu(*cuint) % sizeof(uint32_t)) != 0U) {
ERROR("Misaligned nvmem %s element: ignored\n", name);
return -FDT_ERR_BADVALUE;
}
@ -386,7 +383,7 @@ int fdt_get_gpio_bank_pin_count(unsigned int bank)
fdt_for_each_subnode(node, fdt, pinctrl_node) {
const fdt32_t *cuint;
int pin_count;
int pin_count = 0;
int len;
int i;
@ -415,11 +412,9 @@ int fdt_get_gpio_bank_pin_count(unsigned int bank)
}
/* Get the last defined gpio line (offset + nb of pins) */
pin_count = fdt32_to_cpu(*(cuint + 1)) + fdt32_to_cpu(*(cuint + 3));
for (i = 0; i < len / 4; i++) {
pin_count = MAX(pin_count, (int)(fdt32_to_cpu(*(cuint + 1)) +
fdt32_to_cpu(*(cuint + 3))));
cuint += 4;
for (i = 0; i < len; i += 4) {
pin_count = MAX(pin_count, (int)(fdt32_to_cpu(cuint[i + 1]) +
fdt32_to_cpu(cuint[i + 3])));
}
return pin_count;

13
plat/st/stm32mp1/bl2_plat_setup.c

@ -543,20 +543,15 @@ int bl2_plat_handle_post_image_load(unsigned int image_id)
void bl2_el3_plat_prepare_exit(void)
{
#if STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER
uint16_t boot_itf = stm32mp_get_boot_itf_selected();
switch (boot_itf) {
#if STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER
case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART:
case BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB:
if ((boot_itf == BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART) ||
(boot_itf == BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB)) {
/* Invalidate the downloaded buffer used with io_memmap */
inv_dcache_range(DWL_BUFFER_BASE, DWL_BUFFER_SIZE);
break;
#endif /* STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER */
default:
/* Do nothing in default case */
break;
}
#endif /* STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER */
stm32mp1_security_setup();
}

9
plat/st/stm32mp1/stm32mp1_fconf_firewall.c

@ -99,15 +99,16 @@ static int fconf_populate_stm32mp1_firewall(uintptr_t config)
/* Locate the memory cells and read all values */
for (i = 0U; i < (unsigned int)(len / (sizeof(uint32_t) * STM32MP_REGION_PARAMS)); i++) {
uint32_t idx = i * STM32MP_REGION_PARAMS;
uint32_t base;
uint32_t size;
uint32_t sec_attr;
uint32_t nsaid;
base = fdt32_to_cpu(conf_list->id_attr[i * STM32MP_REGION_PARAMS]);
size = fdt32_to_cpu(conf_list->id_attr[i * STM32MP_REGION_PARAMS + 1]);
sec_attr = fdt32_to_cpu(conf_list->id_attr[i * STM32MP_REGION_PARAMS + 2]);
nsaid = fdt32_to_cpu(conf_list->id_attr[i * STM32MP_REGION_PARAMS + 3]);
base = fdt32_to_cpu(conf_list->id_attr[idx]);
size = fdt32_to_cpu(conf_list->id_attr[idx + 1]);
sec_attr = fdt32_to_cpu(conf_list->id_attr[idx + 2]);
nsaid = fdt32_to_cpu(conf_list->id_attr[idx + 3]);
VERBOSE("FCONF: stm32mp1-firewall cell found with value = 0x%x 0x%x 0x%x 0x%x\n",
base, size, sec_attr, nsaid);

14
plat/st/stm32mp1/stm32mp1_private.c

@ -140,14 +140,14 @@ void configure_mmu(void)
uintptr_t stm32_get_gpio_bank_base(unsigned int bank)
{
#if STM32MP13
assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_I);
assert((GPIO_BANK_A == 0) && (bank <= GPIO_BANK_I));
#endif
#if STM32MP15
if (bank == GPIO_BANK_Z) {
return GPIOZ_BASE;
}
assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_K);
assert((GPIO_BANK_A == 0) && (bank <= GPIO_BANK_K));
#endif
return GPIOA_BASE + (bank * GPIO_BANK_OFFSET);
@ -156,14 +156,14 @@ uintptr_t stm32_get_gpio_bank_base(unsigned int bank)
uint32_t stm32_get_gpio_bank_offset(unsigned int bank)
{
#if STM32MP13
assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_I);
assert((GPIO_BANK_A == 0) && (bank <= GPIO_BANK_I));
#endif
#if STM32MP15
if (bank == GPIO_BANK_Z) {
return 0;
}
assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_K);
assert((GPIO_BANK_A == 0) && (bank <= GPIO_BANK_K));
#endif
return bank * GPIO_BANK_OFFSET;
@ -186,14 +186,14 @@ bool stm32_gpio_is_secure_at_reset(unsigned int bank)
unsigned long stm32_get_gpio_bank_clock(unsigned int bank)
{
#if STM32MP13
assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_I);
assert((GPIO_BANK_A == 0) && (bank <= GPIO_BANK_I));
#endif
#if STM32MP15
if (bank == GPIO_BANK_Z) {
return GPIOZ;
}
assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_K);
assert((GPIO_BANK_A == 0) && (bank <= GPIO_BANK_K));
#endif
return GPIOA + (bank - GPIO_BANK_A);
@ -378,7 +378,7 @@ static uint32_t get_cpu_package(void)
void stm32mp_get_soc_name(char name[STM32_SOC_NAME_SIZE])
{
char *cpu_s, *cpu_r, *pkg;
const char *cpu_s, *cpu_r, *pkg;
/* MPUs Part Numbers */
switch (get_part_number()) {

4
plat/st/stm32mp1/stm32mp1_syscfg.c

@ -235,7 +235,9 @@ static void enable_hslv_by_index(uint32_t index)
}
if (apply_hslv) {
mmio_write_32(SYSCFG_BASE + SYSCFG_HSLVEN0R + index * sizeof(uint32_t), HSLV_KEY);
uint32_t reg_offset = index * sizeof(uint32_t);
mmio_write_32(SYSCFG_BASE + SYSCFG_HSLVEN0R + reg_offset, HSLV_KEY);
}
}
#endif

Loading…
Cancel
Save