Commit eb52759a authored by Biju Das's avatar Biju Das
Browse files

drivers: renesas: rcar: io: Code cleanup



This patch fixes checkpatch warnings and arrange header
as per TF-A coding style.
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Change-Id: I46cd4d9b2851202324fe714e776cf3ad2ee1d923
parent cb413426
/* /*
* Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved. * Copyright (c) 2015-2021, Renesas Electronics Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
#include <drivers/io/io_driver.h> #include <drivers/io/io_driver.h>
#include <drivers/io/io_storage.h> #include <drivers/io/io_storage.h>
#include "io_common.h"
#include "io_emmcdrv.h"
#include "io_private.h"
#include "emmc_config.h" #include "emmc_config.h"
#include "emmc_def.h"
#include "emmc_hal.h" #include "emmc_hal.h"
#include "emmc_std.h" #include "emmc_std.h"
#include "emmc_def.h" #include "io_common.h"
#include "io_emmcdrv.h"
#include "io_private.h"
static int32_t emmcdrv_dev_open(const uintptr_t spec __attribute__ ((unused)), static int32_t emmcdrv_dev_open(const uintptr_t spec __attribute__ ((unused)),
io_dev_info_t **dev_info); io_dev_info_t **dev_info);
...@@ -41,8 +41,9 @@ static io_type_t device_type_emmcdrv(void) ...@@ -41,8 +41,9 @@ static io_type_t device_type_emmcdrv(void)
static int32_t emmcdrv_block_seek(io_entity_t *entity, int32_t mode, static int32_t emmcdrv_block_seek(io_entity_t *entity, int32_t mode,
signed long long offset) signed long long offset)
{ {
if (mode != IO_SEEK_SET) if (mode != IO_SEEK_SET) {
return IO_FAIL; return IO_FAIL;
}
((file_state_t *) entity->info)->file_pos = offset; ((file_state_t *) entity->info)->file_pos = offset;
...@@ -64,12 +65,14 @@ static int32_t emmcdrv_block_read(io_entity_t *entity, uintptr_t buffer, ...@@ -64,12 +65,14 @@ static int32_t emmcdrv_block_read(io_entity_t *entity, uintptr_t buffer,
current_file.partition, current_file.file_pos, current_file.partition, current_file.file_pos,
sector_add, length, sector_num); sector_add, length, sector_num);
if ((buffer + length - 1U) <= (uintptr_t)UINT32_MAX) if ((buffer + length - 1U) <= (uintptr_t)UINT32_MAX) {
emmc_dma = LOADIMAGE_FLAGS_DMA_ENABLE; emmc_dma = LOADIMAGE_FLAGS_DMA_ENABLE;
}
if (emmc_read_sector((uint32_t *) buffer, sector_add, sector_num, if (emmc_read_sector((uint32_t *) buffer, sector_add, sector_num,
emmc_dma) != EMMC_SUCCESS) emmc_dma) != EMMC_SUCCESS) {
result = IO_FAIL; result = IO_FAIL;
}
*length_read = length; *length_read = length;
fp->file_pos += (signed long long)length; fp->file_pos += (signed long long)length;
...@@ -92,8 +95,8 @@ static int32_t emmcdrv_block_open(io_dev_info_t *dev_info, ...@@ -92,8 +95,8 @@ static int32_t emmcdrv_block_open(io_dev_info_t *dev_info,
if (emmcdrv_bootpartition == PARTITION_ID_USER) { if (emmcdrv_bootpartition == PARTITION_ID_USER) {
emmcdrv_bootpartition = mmc_drv_obj.boot_partition_en; emmcdrv_bootpartition = mmc_drv_obj.boot_partition_en;
if ((PARTITION_ID_BOOT_1 == emmcdrv_bootpartition) || if ((emmcdrv_bootpartition == PARTITION_ID_BOOT_1) ||
(PARTITION_ID_BOOT_2 == emmcdrv_bootpartition)) { (emmcdrv_bootpartition == PARTITION_ID_BOOT_2)) {
current_file.partition = emmcdrv_bootpartition; current_file.partition = emmcdrv_bootpartition;
NOTICE("BL2: eMMC boot from partition %d\n", NOTICE("BL2: eMMC boot from partition %d\n",
...@@ -103,16 +106,18 @@ static int32_t emmcdrv_block_open(io_dev_info_t *dev_info, ...@@ -103,16 +106,18 @@ static int32_t emmcdrv_block_open(io_dev_info_t *dev_info,
return IO_FAIL; return IO_FAIL;
} }
if ((PARTITION_ID_USER == block_spec->partition) || if ((block_spec->partition == PARTITION_ID_USER) ||
(PARTITION_ID_BOOT_1 == block_spec->partition) || (block_spec->partition == PARTITION_ID_BOOT_1) ||
(PARTITION_ID_BOOT_2 == block_spec->partition)) (block_spec->partition == PARTITION_ID_BOOT_2)) {
current_file.partition = block_spec->partition; current_file.partition = block_spec->partition;
else } else {
current_file.partition = emmcdrv_bootpartition; current_file.partition = emmcdrv_bootpartition;
}
done: done:
if (emmc_select_partition(current_file.partition) != EMMC_SUCCESS) if (emmc_select_partition(current_file.partition) != EMMC_SUCCESS) {
return IO_FAIL; return IO_FAIL;
}
entity->info = (uintptr_t) &current_file; entity->info = (uintptr_t) &current_file;
...@@ -166,8 +171,9 @@ int32_t rcar_register_io_dev_emmcdrv(const io_dev_connector_t **dev_con) ...@@ -166,8 +171,9 @@ int32_t rcar_register_io_dev_emmcdrv(const io_dev_connector_t **dev_con)
int32_t rc; int32_t rc;
rc = io_register_device(&emmcdrv_dev_info); rc = io_register_device(&emmcdrv_dev_info);
if (rc == IO_SUCCESS) if (rc == IO_SUCCESS) {
*dev_con = &emmcdrv_dev_connector; *dev_con = &emmcdrv_dev_connector;
}
return rc; return rc;
} }
/* /*
* Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved. * Copyright (c) 2015-2021, Renesas Electronics Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include <drivers/io/io_storage.h> #include <drivers/io/io_storage.h>
#include "io_common.h" #include "io_common.h"
#include "io_private.h"
#include "io_memdrv.h" #include "io_memdrv.h"
#include "io_private.h"
#include "rcar_def.h" #include "rcar_def.h"
extern void rcar_dma_exec(uintptr_t dst, uint32_t src, uint32_t len); extern void rcar_dma_exec(uintptr_t dst, uint32_t src, uint32_t len);
...@@ -21,7 +21,8 @@ static int32_t memdrv_dev_open(const uintptr_t dev __attribute__ ((unused)), ...@@ -21,7 +21,8 @@ static int32_t memdrv_dev_open(const uintptr_t dev __attribute__ ((unused)),
io_dev_info_t **dev_info); io_dev_info_t **dev_info);
static int32_t memdrv_dev_close(io_dev_info_t *dev_info); static int32_t memdrv_dev_close(io_dev_info_t *dev_info);
/* As we need to be able to keep state for seek, only one file can be open /*
* As we need to be able to keep state for seek, only one file can be open
* at a time. Make this a structure and point to the entity->info. When we * at a time. Make this a structure and point to the entity->info. When we
* can malloc memory we can change this to support more open files. * can malloc memory we can change this to support more open files.
*/ */
...@@ -43,12 +44,14 @@ static int32_t memdrv_block_open(io_dev_info_t *dev_info, const uintptr_t spec, ...@@ -43,12 +44,14 @@ static int32_t memdrv_block_open(io_dev_info_t *dev_info, const uintptr_t spec,
{ {
const io_drv_spec_t *block_spec = (io_drv_spec_t *) spec; const io_drv_spec_t *block_spec = (io_drv_spec_t *) spec;
/* Since we need to track open state for seek() we only allow one open /*
* Since we need to track open state for seek() we only allow one open
* spec at a time. When we have dynamic memory we can malloc and set * spec at a time. When we have dynamic memory we can malloc and set
* entity->info. * entity->info.
*/ */
if (current_file.in_use != 0U) if (current_file.in_use != 0U) {
return IO_RESOURCES_EXHAUSTED; return IO_RESOURCES_EXHAUSTED;
}
/* File cursor offset for seek and incremental reads etc. */ /* File cursor offset for seek and incremental reads etc. */
current_file.base = block_spec->offset; current_file.base = block_spec->offset;
...@@ -63,8 +66,9 @@ static int32_t memdrv_block_open(io_dev_info_t *dev_info, const uintptr_t spec, ...@@ -63,8 +66,9 @@ static int32_t memdrv_block_open(io_dev_info_t *dev_info, const uintptr_t spec,
static int32_t memdrv_block_seek(io_entity_t *entity, int32_t mode, static int32_t memdrv_block_seek(io_entity_t *entity, int32_t mode,
signed long long offset) signed long long offset)
{ {
if (mode != IO_SEEK_SET) if (mode != IO_SEEK_SET) {
return IO_FAIL; return IO_FAIL;
}
((file_state_t *) entity->info)->file_pos = offset; ((file_state_t *) entity->info)->file_pos = offset;
...@@ -142,8 +146,9 @@ int32_t rcar_register_io_dev_memdrv(const io_dev_connector_t **dev_con) ...@@ -142,8 +146,9 @@ int32_t rcar_register_io_dev_memdrv(const io_dev_connector_t **dev_con)
int32_t result; int32_t result;
result = io_register_device(&memdrv_dev_info); result = io_register_device(&memdrv_dev_info);
if (result == IO_SUCCESS) if (result == IO_SUCCESS) {
*dev_con = &memdrv_dev_connector; *dev_con = &memdrv_dev_connector;
}
return result; return result;
} }
/* /*
* Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved. * Copyright (c) 2015-2021, Renesas Electronics Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <platform_def.h>
#include <arch_helpers.h> #include <arch_helpers.h>
#include <common/bl_common.h> #include <common/bl_common.h>
#include <common/debug.h> #include <common/debug.h>
...@@ -24,6 +22,7 @@ ...@@ -24,6 +22,7 @@
#include "io_rcar.h" #include "io_rcar.h"
#include "io_common.h" #include "io_common.h"
#include "io_private.h" #include "io_private.h"
#include <platform_def.h>
extern int32_t plat_get_drv_source(uint32_t id, uintptr_t *dev, extern int32_t plat_get_drv_source(uint32_t id, uintptr_t *dev,
uintptr_t *image_spec); uintptr_t *image_spec);
...@@ -39,7 +38,8 @@ typedef struct { ...@@ -39,7 +38,8 @@ typedef struct {
} plat_rcar_name_offset_t; } plat_rcar_name_offset_t;
typedef struct { typedef struct {
/* Put position above the struct to allow {0} on static init. /*
* Put position above the struct to allow {0} on static init.
* It is a workaround for a known bug in GCC * It is a workaround for a known bug in GCC
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
*/ */
...@@ -59,7 +59,7 @@ typedef struct { ...@@ -59,7 +59,7 @@ typedef struct {
#define RCAR_ATTR_SET_ISNOLOAD(a) (((a) & 0x1) << 16U) #define RCAR_ATTR_SET_ISNOLOAD(a) (((a) & 0x1) << 16U)
#define RCAR_ATTR_SET_CERTOFF(a) (((a) & 0xF) << 8U) #define RCAR_ATTR_SET_CERTOFF(a) (((a) & 0xF) << 8U)
#define RCAR_ATTR_SET_ALL(a, b, c) ((uint32_t)(RCAR_ATTR_SET_CALCADDR(a) |\ #define RCAR_ATTR_SET_ALL(a, b, c) ((uint32_t)(RCAR_ATTR_SET_CALCADDR(a) |\
RCAR_ATTR_SET_ISNOLOAD(b) | \ RCAR_ATTR_SET_ISNOLOAD(b) |\
RCAR_ATTR_SET_CERTOFF(c))) RCAR_ATTR_SET_CERTOFF(c)))
#define RCAR_ATTR_GET_CALCADDR(a) ((a) & 0xFU) #define RCAR_ATTR_GET_CALCADDR(a) ((a) & 0xFU)
...@@ -136,9 +136,11 @@ int32_t rcar_get_certificate(const int32_t name, uint32_t *cert) ...@@ -136,9 +136,11 @@ int32_t rcar_get_certificate(const int32_t name, uint32_t *cert)
{ {
#if TRUSTED_BOARD_BOOT #if TRUSTED_BOARD_BOOT
int32_t i; int32_t i;
for (i = 0; i < ARRAY_SIZE(cert_offset); i++) { for (i = 0; i < ARRAY_SIZE(cert_offset); i++) {
if (name != cert_offset[i].name) if (name != cert_offset[i].name) {
continue; continue;
}
*cert = RCAR_CERT_SIZE; *cert = RCAR_CERT_SIZE;
*cert *= RCAR_ATTR_GET_CERTOFF(cert_offset[i].attr); *cert *= RCAR_ATTR_GET_CERTOFF(cert_offset[i].attr);
...@@ -157,12 +159,14 @@ static int32_t file_to_offset(const int32_t name, uintptr_t *offset, ...@@ -157,12 +159,14 @@ static int32_t file_to_offset(const int32_t name, uintptr_t *offset,
int32_t i; int32_t i;
for (i = 0; i < ARRAY_SIZE(name_offset); i++) { for (i = 0; i < ARRAY_SIZE(name_offset); i++) {
if (name != name_offset[i].name) if (name != name_offset[i].name) {
continue; continue;
}
addr = RCAR_ATTR_GET_CALCADDR(name_offset[i].attr); addr = RCAR_ATTR_GET_CALCADDR(name_offset[i].attr);
if (rcar_image_number + 2 < addr) if (rcar_image_number + 2U < addr) {
continue; continue;
}
*offset = rcar_image_header[addr]; *offset = rcar_image_header[addr];
*cert = RCAR_CERT_SIZE; *cert = RCAR_CERT_SIZE;
...@@ -175,8 +179,9 @@ static int32_t file_to_offset(const int32_t name, uintptr_t *offset, ...@@ -175,8 +179,9 @@ static int32_t file_to_offset(const int32_t name, uintptr_t *offset,
#if TRUSTED_BOARD_BOOT #if TRUSTED_BOARD_BOOT
for (i = 0; i < ARRAY_SIZE(cert_offset); i++) { for (i = 0; i < ARRAY_SIZE(cert_offset); i++) {
if (name != cert_offset[i].name) if (name != cert_offset[i].name) {
continue; continue;
}
*no_load = RCAR_ATTR_GET_ISNOLOAD(cert_offset[i].attr); *no_load = RCAR_ATTR_GET_ISNOLOAD(cert_offset[i].attr);
*partition = 0U; *partition = 0U;
...@@ -282,8 +287,9 @@ static int32_t check_load_area(uintptr_t dst, uintptr_t len) ...@@ -282,8 +287,9 @@ static int32_t check_load_area(uintptr_t dst, uintptr_t len)
result = IO_FAIL; result = IO_FAIL;
} }
done: done:
if (result == IO_FAIL) if (result == IO_FAIL) {
ERROR("BL2: Out of range : dst=0x%lx len=0x%lx\n", dst, len); ERROR("BL2: Out of range : dst=0x%lx len=0x%lx\n", dst, len);
}
return result; return result;
} }
...@@ -307,14 +313,15 @@ static int32_t load_bl33x(void) ...@@ -307,14 +313,15 @@ static int32_t load_bl33x(void)
BL338_IMAGE_ID BL338_IMAGE_ID
}; };
if (loaded != IO_NOT_SUPPORTED) if (loaded != IO_NOT_SUPPORTED) {
return loaded; return loaded;
}
for (i = 1; i < rcar_image_number; i++) { for (i = 1; i < rcar_image_number; i++) {
rc = file_to_offset(img[i], &offset, &cert, &noload, rc = file_to_offset(img[i], &offset, &cert, &noload,
&partition); &partition);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("load_bl33x: failed to get offset\n"); WARN("%s: failed to get offset\n", __func__);
loaded = IO_FAIL; loaded = IO_FAIL;
return loaded; return loaded;
} }
...@@ -324,34 +331,34 @@ static int32_t load_bl33x(void) ...@@ -324,34 +331,34 @@ static int32_t load_bl33x(void)
rc = io_open(rcar_handle, rcar_spec, &handle); rc = io_open(rcar_handle, rcar_spec, &handle);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("Failed to open FIP (%i)\n", rc); WARN("%s: Failed to open FIP (%i)\n", __func__, rc);
loaded = IO_FAIL; loaded = IO_FAIL;
return loaded; return loaded;
} }
rc = io_seek(handle, IO_SEEK_SET, offset); rc = io_seek(handle, IO_SEEK_SET, offset);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("load_bl33x: failed to seek\n"); WARN("%s: failed to seek\n", __func__);
loaded = IO_FAIL; loaded = IO_FAIL;
return loaded; return loaded;
} }
rc = check_load_area(dst, len); rc = check_load_area(dst, len);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("load_bl33x: check load area\n"); WARN("%s: check load area\n", __func__);
loaded = IO_FAIL; loaded = IO_FAIL;
return loaded; return loaded;
} }
rc = io_read(handle, dst, len, &cnt); rc = io_read(handle, dst, len, &cnt);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("load_bl33x: failed to read\n"); WARN("%s: failed to read\n", __func__);
loaded = IO_FAIL; loaded = IO_FAIL;
return loaded; return loaded;
} }
#if TRUSTED_BOARD_BOOT #if TRUSTED_BOARD_BOOT
rc = auth_mod_verify_img(img[i], (void *)dst, len); rc = auth_mod_verify_img(img[i], (void *)dst, len);
if (rc) { if (rc != 0) {
memset((void *)dst, 0x00, len); memset((void *)dst, 0x00, len);
loaded = IO_FAIL; loaded = IO_FAIL;
return loaded; return loaded;
...@@ -367,8 +374,7 @@ static int32_t load_bl33x(void) ...@@ -367,8 +374,7 @@ static int32_t load_bl33x(void)
static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name) static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name)
{ {
uint64_t header[64] __aligned(FLASH_TRANS_SIZE_UNIT) = { uint64_t header[64] __aligned(FLASH_TRANS_SIZE_UNIT) = {0UL};
0};
uintptr_t handle; uintptr_t handle;
ssize_t offset; ssize_t offset;
uint32_t i; uint32_t i;
...@@ -382,8 +388,9 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name) ...@@ -382,8 +388,9 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name)
return IO_FAIL; return IO_FAIL;
} }
if (RCAR_CERT_LOAD == rcar_cert_load) if (rcar_cert_load == RCAR_CERT_LOAD) {
return IO_SUCCESS; return IO_SUCCESS;
}
rc = io_open(rcar_handle, rcar_spec, &handle); rc = io_open(rcar_handle, rcar_spec, &handle);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
...@@ -391,16 +398,18 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name) ...@@ -391,16 +398,18 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name)
return IO_FAIL; return IO_FAIL;
} }
/* get start address list */ /*
/* [0] address num */ * get start address list
/* [1] BL33-1 image address */ * [0] address num
/* [2] BL33-2 image address */ * [1] BL33-1 image address
/* [3] BL33-3 image address */ * [2] BL33-2 image address
/* [4] BL33-4 image address */ * [3] BL33-3 image address
/* [5] BL33-5 image address */ * [4] BL33-4 image address
/* [6] BL33-6 image address */ * [5] BL33-5 image address
/* [7] BL33-7 image address */ * [6] BL33-6 image address
/* [8] BL33-8 image address */ * [7] BL33-7 image address
* [8] BL33-8 image address
*/
offset = name == EMMC_DEV_ID ? RCAR_EMMC_CERT_HEADER : offset = name == EMMC_DEV_ID ? RCAR_EMMC_CERT_HEADER :
RCAR_FLASH_CERT_HEADER; RCAR_FLASH_CERT_HEADER;
rc = io_seek(handle, IO_SEEK_SET, offset); rc = io_seek(handle, IO_SEEK_SET, offset);
...@@ -447,8 +456,9 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name) ...@@ -447,8 +456,9 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name)
rcar_cert_load = RCAR_CERT_LOAD; rcar_cert_load = RCAR_CERT_LOAD;
error: error:
if (rc != IO_SUCCESS) if (rc != IO_SUCCESS) {
rc = IO_FAIL; rc = IO_FAIL;
}
io_close(handle); io_close(handle);
...@@ -464,13 +474,15 @@ static int32_t rcar_file_open(io_dev_info_t *info, const uintptr_t file_spec, ...@@ -464,13 +474,15 @@ static int32_t rcar_file_open(io_dev_info_t *info, const uintptr_t file_spec,
uint32_t noload, cert, len; uint32_t noload, cert, len;
int32_t rc; int32_t rc;
/* Only one file open at a time. We need to track state (ie, file /*
* cursor position). Since the header lives at * offset zero, this entry * Only one file open at a time. We need to track state (ie, file
* cursor position). Since the header lives at offset zero, this entry
* should never be zero in an active file. * should never be zero in an active file.
* Once the system supports dynamic memory allocation we will allow more * Once the system supports dynamic memory allocation we will allow more
* than one open file at a time. */ * than one open file at a time.
*/
if (current_file.offset != 0U) { if (current_file.offset != 0U) {
WARN("rcar_file_open : Only one open file at a time.\n"); WARN("%s: Only one open file at a time.\n", __func__);
return IO_RESOURCES_EXHAUSTED; return IO_RESOURCES_EXHAUSTED;
} }
...@@ -480,7 +492,7 @@ static int32_t rcar_file_open(io_dev_info_t *info, const uintptr_t file_spec, ...@@ -480,7 +492,7 @@ static int32_t rcar_file_open(io_dev_info_t *info, const uintptr_t file_spec,
return IO_FAIL; return IO_FAIL;
} }
if (noload) { if (noload != 0U) {
current_file.offset = 1; current_file.offset = 1;
current_file.dst = 0; current_file.dst = 0;
current_file.size = 1; current_file.size = 1;
...@@ -494,12 +506,10 @@ static int32_t rcar_file_open(io_dev_info_t *info, const uintptr_t file_spec, ...@@ -494,12 +506,10 @@ static int32_t rcar_file_open(io_dev_info_t *info, const uintptr_t file_spec,
rcar_read_certificate((uint64_t) cert, &len, &dst); rcar_read_certificate((uint64_t) cert, &len, &dst);
/*----------------* /* Baylibre: HACK */
* Baylibre: HACK * if (spec->offset == BL31_IMAGE_ID && len < RCAR_TRUSTED_SRAM_SIZE) {
*----------------*/ WARN("%s,%s\n", "r-car ignoring the BL31 size from certificate",
if (BL31_IMAGE_ID == spec->offset && len < RCAR_TRUSTED_SRAM_SIZE) { "using RCAR_TRUSTED_SRAM_SIZE instead");
WARN("r-car ignoring the BL31 size from certificate,"
"using RCAR_TRUSTED_SRAM_SIZE instead\n");
len = RCAR_TRUSTED_SRAM_SIZE; len = RCAR_TRUSTED_SRAM_SIZE;
} }
...@@ -536,7 +546,7 @@ static int32_t rcar_file_read(io_entity_t *entity, uintptr_t buffer, ...@@ -536,7 +546,7 @@ static int32_t rcar_file_read(io_entity_t *entity, uintptr_t buffer,
#else #else
static uint32_t load_bl33x_counter; static uint32_t load_bl33x_counter;
#endif #endif
if (current_file.no_load) { if (current_file.no_load != 0U) {
*cnt = length; *cnt = length;
return IO_SUCCESS; return IO_SUCCESS;
} }
...@@ -551,14 +561,14 @@ static int32_t rcar_file_read(io_entity_t *entity, uintptr_t buffer, ...@@ -551,14 +561,14 @@ static int32_t rcar_file_read(io_entity_t *entity, uintptr_t buffer,
rc = io_seek(handle, IO_SEEK_SET, offset); rc = io_seek(handle, IO_SEEK_SET, offset);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("rcar_file_read: failed to seek\n"); WARN("%s: failed to seek\n", __func__);
goto error; goto error;
} }
if (load_bl33x_counter == RCAR_COUNT_LOAD_BL33) { if (load_bl33x_counter == RCAR_COUNT_LOAD_BL33) {
rc = check_load_area(buffer, length); rc = check_load_area(buffer, length);
if (rc != IO_SUCCESS) { if (rc != IO_SUCCESS) {
WARN("rcar_file_read: load area err\n"); WARN("%s: load area err\n", __func__);
goto error; goto error;
} }
} }
...@@ -573,8 +583,9 @@ static int32_t rcar_file_read(io_entity_t *entity, uintptr_t buffer, ...@@ -573,8 +583,9 @@ static int32_t rcar_file_read(io_entity_t *entity, uintptr_t buffer,
io_close(handle); io_close(handle);
load_bl33x_counter += 1; load_bl33x_counter += 1;
if (load_bl33x_counter == RCAR_COUNT_LOAD_BL33X) if (load_bl33x_counter == RCAR_COUNT_LOAD_BL33X) {
return load_bl33x(); return load_bl33x();
}
return IO_SUCCESS; return IO_SUCCESS;
error: error:
...@@ -584,8 +595,9 @@ error: ...@@ -584,8 +595,9 @@ error:
static int32_t rcar_file_close(io_entity_t *entity) static int32_t rcar_file_close(io_entity_t *entity)
{ {
if (current_file.offset) if (current_file.offset != 0U) {
memset(&current_file, 0, sizeof(current_file)); memset(&current_file, 0, sizeof(current_file));
}
entity->info = 0U; entity->info = 0U;
...@@ -634,8 +646,9 @@ int32_t rcar_register_io_dev(const io_dev_connector_t **dev_con) ...@@ -634,8 +646,9 @@ int32_t rcar_register_io_dev(const io_dev_connector_t **dev_con)
int32_t result; int32_t result;
result = io_register_device(&rcar_dev_info); result = io_register_device(&rcar_dev_info);
if (result == IO_SUCCESS) if (result == IO_SUCCESS) {
*dev_con = &rcar_dev_connector; *dev_con = &rcar_dev_connector;
}
return result; return result;
} }
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