Commit dec5e0d1 authored by Dan Handley's avatar Dan Handley Committed by Achin Gupta
Browse files

Move BL porting functions into platform.h

Some platform porting functions were in BL specific header files.
These have been moved to platform.h so that all porting functions
are in the same place. The functions are now grouped by BL.
Obsolete BL headers files have been removed.

Also, the weak declaration of the init_bl2_mem_layout() function
has been moved out the header file and into the source file
(bl_common.c) using the more succinct #pragma syntax. This
mitigates the risk of 2 weak definitions being created and the
wrong one being picked up by the compiler.

Change-Id: Ib19934939fd755f3e5a5a5bceec88da684308a83
parent 5f0cdb05
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <arch_helpers.h> #include <arch_helpers.h>
#include <assert.h> #include <assert.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl1.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
#include <platform_def.h> #include <platform_def.h>
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <arch_helpers.h> #include <arch_helpers.h>
#include <assert.h> #include <assert.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl2.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
#include <platform_def.h> #include <platform_def.h>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <bl_common.h> #include <bl_common.h>
#include <bl31.h> #include <bl31.h>
#include <context_mgmt.h> #include <context_mgmt.h>
#include <platform.h>
#include <runtime_svc.h> #include <runtime_svc.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <arch_helpers.h> #include <arch_helpers.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl32.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
#include <platform_def.h> #include <platform_def.h>
......
...@@ -74,9 +74,10 @@ void change_security_state(unsigned int target_security_state) ...@@ -74,9 +74,10 @@ void change_security_state(unsigned int target_security_state)
/******************************************************************************* /*******************************************************************************
* The next function is a weak definition. Platform specific * The next function has a weak definition. Platform specific code can override
* code can override it if it wishes to. * it if it wishes to.
******************************************************************************/ ******************************************************************************/
#pragma weak init_bl2_mem_layout
/******************************************************************************* /*******************************************************************************
* Function that takes a memory layout into which BL2 has been either top or * Function that takes a memory layout into which BL2 has been either top or
......
/*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BL1_H__
#define __BL1_H__
/******************************************
* Forward declarations
*****************************************/
struct meminfo;
/******************************************
* Function prototypes
*****************************************/
void bl1_platform_setup(void);
struct meminfo *bl1_plat_sec_mem_layout(void);
#endif /* __BL1_H__ */
/*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BL2_H__
#define __BL2_H__
/******************************************
* Forward declarations
*****************************************/
struct meminfo;
struct bl31_params;
struct entry_point_info;
/******************************************
* Function prototypes
*****************************************/
void bl2_platform_setup(void);
struct meminfo *bl2_plat_sec_mem_layout(void);
/*******************************************************************************
* This function returns a pointer to the shared memory that the platform has
* kept aside to pass trusted firmware related information that BL3-1
* could need
******************************************************************************/
struct bl31_params *bl2_plat_get_bl31_params(void);
/*******************************************************************************
* This function returns a pointer to the shared memory that the platform
* has kept to point to entry point information of BL31 to BL2
******************************************************************************/
struct entry_point_info *bl2_plat_get_bl31_ep_info(void);
/************************************************************************
* This function flushes to main memory all the params that are
* passed to BL3-1
**************************************************************************/
void bl2_plat_flush_bl31_params(void);
#endif /* __BL2_H__ */
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
* Forward declarations * Forward declarations
*****************************************/ *****************************************/
struct entry_point_info; struct entry_point_info;
struct bl31_parms;
/******************************************************************************* /*******************************************************************************
* Function prototypes * Function prototypes
...@@ -48,9 +47,6 @@ void bl31_set_next_image_type(uint32_t type); ...@@ -48,9 +47,6 @@ void bl31_set_next_image_type(uint32_t type);
uint32_t bl31_get_next_image_type(void); uint32_t bl31_get_next_image_type(void);
void bl31_prepare_next_image_entry(); void bl31_prepare_next_image_entry();
struct entry_point_info *bl31_get_next_image_info(uint32_t type); struct entry_point_info *bl31_get_next_image_info(uint32_t type);
void bl31_early_platform_setup(struct bl31_params *from_bl2,
void *plat_params_from_bl2);
void bl31_platform_setup(void);
void bl31_register_bl32_init(int32_t (*)(void)); void bl31_register_bl32_init(int32_t (*)(void));
#endif /* __BL31_H__ */ #endif /* __BL31_H__ */
/*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BL32_H__
#define __BL32_H__
#include <stdint.h>
/******************************************
* Forward declarations
*****************************************/
struct meminfo;
/******************************************
* Function prototypes
*****************************************/
void bl32_platform_setup(void);
struct meminfo *bl32_plat_sec_mem_layout(void);
uint64_t bl32_main(void);
#endif /* __BL32_H__ */
...@@ -196,13 +196,6 @@ CASSERT(sizeof(unsigned long) == ...@@ -196,13 +196,6 @@ CASSERT(sizeof(unsigned long) ==
******************************************************************************/ ******************************************************************************/
unsigned long page_align(unsigned long, unsigned); unsigned long page_align(unsigned long, unsigned);
void change_security_state(unsigned int); void change_security_state(unsigned int);
void init_bl2_mem_layout(meminfo_t *,
meminfo_t *,
unsigned int,
unsigned long) __attribute__((weak));
void init_bl31_mem_layout(const meminfo_t *,
meminfo_t *,
unsigned int) __attribute__((weak));
unsigned long image_size(const char *); unsigned long image_size(const char *);
int load_image(meminfo_t *, int load_image(meminfo_t *,
const char *, const char *,
...@@ -210,7 +203,6 @@ int load_image(meminfo_t *, ...@@ -210,7 +203,6 @@ int load_image(meminfo_t *,
unsigned long, unsigned long,
image_info_t *, image_info_t *,
entry_point_info_t *); entry_point_info_t *);
unsigned long *get_el_change_mem_ptr(void);
extern const char build_message[]; extern const char build_message[];
#endif /*__ASSEMBLY__*/ #endif /*__ASSEMBLY__*/
......
...@@ -41,33 +41,25 @@ struct plat_pm_ops; ...@@ -41,33 +41,25 @@ struct plat_pm_ops;
struct meminfo; struct meminfo;
struct image_info; struct image_info;
struct entry_point_info; struct entry_point_info;
struct bl31_params;
/******************************************************************************* /*******************************************************************************
* Function and variable prototypes * Function declarations
******************************************************************************/ ******************************************************************************/
void bl1_plat_arch_setup(void); /*******************************************************************************
void bl2_plat_arch_setup(void); * Mandatory common functions
void bl31_plat_arch_setup(void); ******************************************************************************/
int platform_setup_pm(const struct plat_pm_ops **); uint64_t plat_get_syscnt_freq(void);
unsigned int platform_get_core_pos(unsigned long mpidr);
void enable_mmu_el1(void); void enable_mmu_el1(void);
void enable_mmu_el3(void); void enable_mmu_el3(void);
void configure_mmu_el1(unsigned long total_base, int plat_get_image_source(const char *image_name,
unsigned long total_size, uintptr_t *dev_handle,
unsigned long, uintptr_t *image_spec);
unsigned long,
unsigned long,
unsigned long);
void configure_mmu_el3(unsigned long total_base,
unsigned long total_size,
unsigned long,
unsigned long,
unsigned long,
unsigned long);
void plat_report_exception(unsigned long);
unsigned long plat_get_ns_image_entrypoint(void); unsigned long plat_get_ns_image_entrypoint(void);
unsigned long platform_get_stack(unsigned long mpidr);
uint64_t plat_get_syscnt_freq(void); /*******************************************************************************
* Mandatory interrupt management functions
******************************************************************************/
uint32_t ic_get_pending_interrupt_id(void); uint32_t ic_get_pending_interrupt_id(void);
uint32_t ic_get_pending_interrupt_type(void); uint32_t ic_get_pending_interrupt_type(void);
uint32_t ic_acknowledge_interrupt(void); uint32_t ic_acknowledge_interrupt(void);
...@@ -76,12 +68,19 @@ void ic_end_of_interrupt(uint32_t id); ...@@ -76,12 +68,19 @@ void ic_end_of_interrupt(uint32_t id);
uint32_t plat_interrupt_type_to_line(uint32_t type, uint32_t plat_interrupt_type_to_line(uint32_t type,
uint32_t security_state); uint32_t security_state);
int plat_get_max_afflvl(void); /*******************************************************************************
unsigned int plat_get_aff_count(unsigned int, unsigned long); * Optional common functions (may be overridden)
unsigned int plat_get_aff_state(unsigned int, unsigned long); ******************************************************************************/
int plat_get_image_source(const char *image_name, unsigned int platform_get_core_pos(unsigned long mpidr);
uintptr_t *dev_handle, unsigned long platform_get_stack(unsigned long mpidr);
uintptr_t *image_spec); void plat_report_exception(unsigned long);
/*******************************************************************************
* Mandatory BL1 functions
******************************************************************************/
void bl1_plat_arch_setup(void);
void bl1_platform_setup(void);
struct meminfo *bl1_plat_sec_mem_layout(void);
/* /*
* Before calling this function BL2 is loaded in memory and its entrypoint * Before calling this function BL2 is loaded in memory and its entrypoint
...@@ -92,6 +91,40 @@ int plat_get_image_source(const char *image_name, ...@@ -92,6 +91,40 @@ int plat_get_image_source(const char *image_name,
void bl1_plat_set_bl2_ep_info(struct image_info *image, void bl1_plat_set_bl2_ep_info(struct image_info *image,
struct entry_point_info *ep); struct entry_point_info *ep);
/*******************************************************************************
* Optional BL1 functions (may be overridden)
******************************************************************************/
void init_bl2_mem_layout(struct meminfo *,
struct meminfo *,
unsigned int,
unsigned long);
/*******************************************************************************
* Mandatory BL2 functions
******************************************************************************/
void bl2_plat_arch_setup(void);
void bl2_platform_setup(void);
struct meminfo *bl2_plat_sec_mem_layout(void);
/*
* This function returns a pointer to the shared memory that the platform has
* kept aside to pass trusted firmware related information that BL3-1
* could need
*/
struct bl31_params *bl2_plat_get_bl31_params(void);
/*
* This function returns a pointer to the shared memory that the platform
* has kept to point to entry point information of BL31 to BL2
*/
struct entry_point_info *bl2_plat_get_bl31_ep_info(void);
/*
* This function flushes to main memory all the params that are
* passed to BL3-1
*/
void bl2_plat_flush_bl31_params(void);
/* /*
* Before calling this function BL31 is loaded in memory and its entrypoint * Before calling this function BL31 is loaded in memory and its entrypoint
* is set by load_image. This is a placeholder for the platform to change * is set by load_image. This is a placeholder for the platform to change
...@@ -125,5 +158,30 @@ void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info); ...@@ -125,5 +158,30 @@ void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
/* Gets the memory layout for BL33 */ /* Gets the memory layout for BL33 */
void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info); void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info);
/*******************************************************************************
* Optional BL2 functions (may be overridden)
******************************************************************************/
/*******************************************************************************
* Mandatory BL3-1 functions
******************************************************************************/
void bl31_early_platform_setup(struct bl31_params *from_bl2,
void *plat_params_from_bl2);
void bl31_plat_arch_setup(void);
void bl31_platform_setup(void);
struct entry_point_info *bl31_get_next_image_info(uint32_t type);
/*******************************************************************************
* Mandatory PSCI functions (BL3-1)
******************************************************************************/
int platform_setup_pm(const struct plat_pm_ops **);
int plat_get_max_afflvl(void);
unsigned int plat_get_aff_count(unsigned int, unsigned long);
unsigned int plat_get_aff_state(unsigned int, unsigned long);
/*******************************************************************************
* Mandatory BL3-2 functions (only if platform contains a BL3-2)
******************************************************************************/
void bl32_platform_setup(void);
#endif /* __PLATFORM_H__ */ #endif /* __PLATFORM_H__ */
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <arch_helpers.h> #include <arch_helpers.h>
#include <assert.h> #include <assert.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl1.h>
#include <console.h> #include <console.h>
#include <mmio.h> #include <mmio.h>
#include <platform.h> #include <platform.h>
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <arch_helpers.h> #include <arch_helpers.h>
#include <assert.h> #include <assert.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl2.h>
#include <console.h> #include <console.h>
#include <platform.h> #include <platform.h>
#include <platform_def.h> #include <platform_def.h>
......
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <arch_helpers.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl32.h>
#include <console.h> #include <console.h>
#include <platform.h> #include <platform.h>
#include "fvp_def.h" #include "fvp_def.h"
......
...@@ -55,9 +55,26 @@ typedef struct bl2_to_bl31_params_mem { ...@@ -55,9 +55,26 @@ typedef struct bl2_to_bl31_params_mem {
entry_point_info_t bl31_ep_info; entry_point_info_t bl31_ep_info;
} bl2_to_bl31_params_mem_t; } bl2_to_bl31_params_mem_t;
/*******************************************************************************
* Forward declarations
******************************************************************************/
struct meminfo;
/******************************************************************************* /*******************************************************************************
* Function and variable prototypes * Function and variable prototypes
******************************************************************************/ ******************************************************************************/
void configure_mmu_el1(unsigned long total_base,
unsigned long total_size,
unsigned long,
unsigned long,
unsigned long,
unsigned long);
void configure_mmu_el3(unsigned long total_base,
unsigned long total_size,
unsigned long,
unsigned long,
unsigned long,
unsigned long);
unsigned long platform_get_cfgvar(unsigned int); unsigned long platform_get_cfgvar(unsigned int);
int platform_config_setup(void); int platform_config_setup(void);
......
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