Remove variables from .data section
Update code base to remove variables from the .data section,
mainly by using const static data where possible and adding
the const specifier as required. Most changes are to the IO
subsystem, including the framework APIs. The FVP power
management code is also affected.
Delay initialization of the global static variable,
next_image_type in bl31_main.c, until it is realy needed.
Doing this moves the variable from the .data to the .bss
section.
Also review the IO interface for inconsistencies, using
uintptr_t where possible instead of void *. Remove the
io_handle and io_dev_handle typedefs, which were
unnecessary, replacing instances with uintptr_t.
Fixes ARM-software/tf-issues#107.
Change-Id: I085a62197c82410b566e4698e5590063563ed304
diff --git a/plat/fvp/plat_io_storage.c b/plat/fvp/plat_io_storage.c
index 3727d26..aac8a96 100644
--- a/plat/fvp/plat_io_storage.c
+++ b/plat/fvp/plat_io_storage.c
@@ -41,69 +41,91 @@
/* IO devices */
static io_plat_data_t io_data;
-static io_dev_connector_t *sh_dev_con;
-static void *const sh_dev_spec;
-static void *const sh_init_params;
-static io_dev_handle sh_dev_handle;
-static io_dev_connector_t *fip_dev_con;
-static void *const fip_dev_spec;
-static io_dev_handle fip_dev_handle;
-static io_dev_connector_t *memmap_dev_con;
-static void *const memmap_dev_spec;
-static void *const memmap_init_params;
-static io_dev_handle memmap_dev_handle;
+static const io_dev_connector_t *sh_dev_con;
+static uintptr_t sh_dev_spec;
+static uintptr_t sh_init_params;
+static uintptr_t sh_dev_handle;
+static const io_dev_connector_t *fip_dev_con;
+static uintptr_t fip_dev_spec;
+static uintptr_t fip_dev_handle;
+static const io_dev_connector_t *memmap_dev_con;
+static uintptr_t memmap_dev_spec;
+static uintptr_t memmap_init_params;
+static uintptr_t memmap_dev_handle;
-static io_block_spec_t fip_block_spec = {
+static const io_block_spec_t fip_block_spec = {
.offset = FLASH0_BASE,
.length = FLASH0_SIZE
};
-static io_file_spec_t bl2_file_spec = {
+static const io_file_spec_t bl2_file_spec = {
.path = BL2_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static io_file_spec_t bl31_file_spec = {
+static const io_file_spec_t bl31_file_spec = {
.path = BL31_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static io_file_spec_t bl32_file_spec = {
+static const io_file_spec_t bl32_file_spec = {
.path = BL32_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static io_file_spec_t bl33_file_spec = {
+static const io_file_spec_t bl33_file_spec = {
.path = BL33_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static int open_fip(void *spec);
-static int open_memmap(void *spec);
+static int open_fip(const uintptr_t spec);
+static int open_memmap(const uintptr_t spec);
struct plat_io_policy {
char *image_name;
- io_dev_handle *dev_handle;
- void *image_spec;
- int (*check)(void *spec);
+ uintptr_t *dev_handle;
+ uintptr_t image_spec;
+ int (*check)(const uintptr_t spec);
};
-static struct plat_io_policy policies[] = {
- { FIP_IMAGE_NAME, &memmap_dev_handle, &fip_block_spec, open_memmap },
- { BL2_IMAGE_NAME, &fip_dev_handle, &bl2_file_spec, open_fip },
- { BL31_IMAGE_NAME, &fip_dev_handle, &bl31_file_spec, open_fip },
- { BL32_IMAGE_NAME, &fip_dev_handle, &bl32_file_spec, open_fip },
- { BL33_IMAGE_NAME, &fip_dev_handle, &bl33_file_spec, open_fip },
- {0, 0, 0 }
+static const struct plat_io_policy policies[] = {
+ {
+ FIP_IMAGE_NAME,
+ &memmap_dev_handle,
+ (uintptr_t)&fip_block_spec,
+ open_memmap
+ }, {
+ BL2_IMAGE_NAME,
+ &fip_dev_handle,
+ (uintptr_t)&bl2_file_spec,
+ open_fip
+ }, {
+ BL31_IMAGE_NAME,
+ &fip_dev_handle,
+ (uintptr_t)&bl31_file_spec,
+ open_fip
+ }, {
+ BL32_IMAGE_NAME,
+ &fip_dev_handle,
+ (uintptr_t)&bl32_file_spec,
+ open_fip
+ }, {
+ BL33_IMAGE_NAME,
+ &fip_dev_handle,
+ (uintptr_t)&bl33_file_spec,
+ open_fip
+ }, {
+ 0, 0, 0
+ }
};
-static int open_fip(void *spec)
+static int open_fip(const uintptr_t spec)
{
int result = IO_FAIL;
/* See if a Firmware Image Package is available */
- result = io_dev_init(fip_dev_handle, (void *)FIP_IMAGE_NAME);
+ result = io_dev_init(fip_dev_handle, (uintptr_t)FIP_IMAGE_NAME);
if (result == IO_SUCCESS) {
INFO("Using FIP\n");
/*TODO: Check image defined in spec is present in FIP. */
@@ -112,10 +134,10 @@
}
-static int open_memmap(void *spec)
+static int open_memmap(const uintptr_t spec)
{
int result = IO_FAIL;
- io_handle local_image_handle;
+ uintptr_t local_image_handle;
result = io_dev_init(memmap_dev_handle, memmap_init_params);
if (result == IO_SUCCESS) {
@@ -129,10 +151,10 @@
}
-static int open_semihosting(void *spec)
+static int open_semihosting(const uintptr_t spec)
{
int result = IO_FAIL;
- io_handle local_image_handle;
+ uintptr_t local_image_handle;
/* See if the file exists on semi-hosting.*/
result = io_dev_init(sh_dev_handle, sh_init_params);
@@ -181,11 +203,11 @@
/* Return an IO device handle and specification which can be used to access
* an image. Use this to enforce platform load policy */
-int plat_get_image_source(const char *image_name, io_dev_handle *dev_handle,
- void **image_spec)
+int plat_get_image_source(const char *image_name, uintptr_t *dev_handle,
+ uintptr_t *image_spec)
{
int result = IO_FAIL;
- struct plat_io_policy *policy;
+ const struct plat_io_policy *policy;
if ((image_name != NULL) && (dev_handle != NULL) &&
(image_spec != NULL)) {
@@ -194,8 +216,7 @@
if (strcmp(policy->image_name, image_name) == 0) {
result = policy->check(policy->image_spec);
if (result == IO_SUCCESS) {
- *(io_file_spec_t **)image_spec =
- policy->image_spec;
+ *image_spec = policy->image_spec;
*dev_handle = *(policy->dev_handle);
break;
} else {
@@ -203,7 +224,7 @@
policy->image_spec);
if (result == IO_SUCCESS) {
*dev_handle = sh_dev_handle;
- *(io_file_spec_t **)image_spec =
+ *image_spec =
policy->image_spec;
}
}
diff --git a/plat/fvp/plat_pm.c b/plat/fvp/plat_pm.c
index c80d315..5430fff 100644
--- a/plat/fvp/plat_pm.c
+++ b/plat/fvp/plat_pm.c
@@ -388,7 +388,7 @@
/*******************************************************************************
* Export the platform handlers to enable psci to invoke them
******************************************************************************/
-static plat_pm_ops_t fvp_plat_pm_ops = {
+static const plat_pm_ops_t fvp_plat_pm_ops = {
fvp_affinst_standby,
fvp_affinst_on,
fvp_affinst_off,
@@ -400,7 +400,7 @@
/*******************************************************************************
* Export the platform specific power ops & initialize the fvp power controller
******************************************************************************/
-int platform_setup_pm(plat_pm_ops_t **plat_ops)
+int platform_setup_pm(const plat_pm_ops_t **plat_ops)
{
*plat_ops = &fvp_plat_pm_ops;
return 0;
diff --git a/plat/fvp/platform.h b/plat/fvp/platform.h
index 1ffdc98..1f4e432 100644
--- a/plat/fvp/platform.h
+++ b/plat/fvp/platform.h
@@ -349,7 +349,6 @@
******************************************************************************/
struct plat_pm_ops;
struct meminfo;
-struct io_dev_info;
/*******************************************************************************
* Function and variable prototypes
@@ -370,7 +369,7 @@
extern void bl1_plat_arch_setup(void);
extern void bl2_plat_arch_setup(void);
extern void bl31_plat_arch_setup(void);
-extern int platform_setup_pm(struct plat_pm_ops **);
+extern int platform_setup_pm(const struct plat_pm_ops **);
extern unsigned int platform_get_core_pos(unsigned long mpidr);
extern void disable_mmu(void);
extern void enable_mmu(void);
@@ -401,7 +400,7 @@
/* Declarations for plat_io_storage.c */
extern void io_setup(void);
extern int plat_get_image_source(const char *image_name,
- struct io_dev_info **dev_handle, void **image_spec);
+ uintptr_t *dev_handle, uintptr_t *image_spec);
/* Declarations for plat_security.c */
extern void plat_security_setup(void);