Soby Mathew [Fri, 9 May 2014 19:49:17 +0000 (20:49 +0100)]
Non-Secure Interrupt support during Standard SMC processing in TSP
Implements support for Non Secure Interrupts preempting the
Standard SMC call in EL1. Whenever an IRQ is trapped in the
Secure world we securely handover to the Normal world
to process the interrupt. The normal world then issues
"resume" smc call to resume the previous interrupted SMC call.
Fixes ARM-software/tf-issues#105
Change-Id: I72b760617dee27438754cdfc9fe9bcf4cc024858
Achin Gupta [Fri, 9 May 2014 12:33:42 +0000 (13:33 +0100)]
Enable secure timer to generate S-EL1 interrupts
This patch enables secure physical timer during TSP initialisation and
maintains it across power management operations so that a timer
interrupt is generated every half second.
Fixes ARM-software/tf-issues#104
Fixes ARM-software/tf-issues#134
Change-Id: I66c6cfd24bd5e6035ba75ebf0f047e568770a369
Achin Gupta [Fri, 9 May 2014 12:21:31 +0000 (13:21 +0100)]
Add S-EL1 interrupt handling support in the TSPD
This patch adds support in the TSPD for registering a handler for
S-EL1 interrupts. This handler ferries the interrupts generated in the
non-secure state to the TSP at 'tsp_fiq_entry'. Support has been added
to the smc handler to resume execution in the non-secure state once
interrupt handling has been completed by the TSP.
There is also support for resuming execution in the normal world if
the TSP receives a EL3 interrupt. This code is currently unused.
Change-Id: I816732595a2635e299572965179f11aa0bf93b69
Achin Gupta [Fri, 9 May 2014 11:17:56 +0000 (12:17 +0100)]
Add support for asynchronous FIQ handling in TSP
This patch adds support in the TSP to handle FIQ interrupts that are
generated when execution is in the TSP. S-EL1 interrupt are handled
normally and execution resumes at the instruction where the exception
was originally taken. S-EL3 interrupts i.e. any interrupt not
recognized by the TSP are handed to the TSPD. Execution resumes
normally once such an interrupt has been handled at EL3.
Change-Id: Ia3ada9a4fb15670afcc12538a6456f21efe58a8f
Achin Gupta [Fri, 9 May 2014 10:42:56 +0000 (11:42 +0100)]
Add support for synchronous FIQ handling in TSP
This patch adds support in the TSP for handling S-EL1 interrupts
handed over by the TSPD. It includes GIC support in its platform port,
updates various statistics related to FIQ handling, exports an entry
point that the TSPD can use to hand over interrupts and defines the
handover protocol w.r.t what context is the TSP expected to preserve
and the state in which the entry point is invoked by the TSPD.
Change-Id: I93b22e5a8133400e4da366f5fc862f871038df39
Achin Gupta [Fri, 9 May 2014 11:00:17 +0000 (12:00 +0100)]
Use secure timer to generate S-EL1 interrupts
This patch adds support in the TSP to program the secure physical
generic timer to generate a EL-1 interrupt every half second. It also
adds support for maintaining the timer state across power management
operations. The TSPD ensures that S-EL1 can access the timer by
programming the SCR_EL3.ST bit.
This patch does not actually enable the timer. This will be done in a
subsequent patch once the complete framework for handling S-EL1
interrupts is in place.
Change-Id: I1b3985cfb50262f60824be3a51c6314ce90571bc
Achin Gupta [Fri, 9 May 2014 10:07:09 +0000 (11:07 +0100)]
Introduce interrupt handling framework in BL3-1
This patch adds a common handler for FIQ and IRQ exceptions in the
BL3-1 runtime exception vector table. This function determines the
interrupt type and calls its handler. A crash is reported if an
inconsistency in the interrupt management framework is detected. In
the event of a spurious interrupt, execution resumes from the
instruction where the interrupt was generated.
This patch also removes 'cm_macros.S' as its contents have been moved
to 'runtime_exceptions.S'
Change-Id: I3c85ecf8eaf43a3fac429b119ed0bd706d2e2093
Achin Gupta [Sun, 4 May 2014 18:02:52 +0000 (19:02 +0100)]
Introduce platform api to access an ARM GIC
This patch introduces a set of functions which allow generic firmware
code e.g. the interrupt management framework to access the platform
interrupt controller. APIs for finding the type and id of the highest
pending interrupt, acknowledging and EOIing an interrupt and finding
the security state of an interrupt have been added. It is assumed that
the platform interrupt controller implements the v2.0 of the ARM GIC
architecture specification. Support for v3.0 of the specification for
managing interrupts in EL3 and the platform port will be added in the
future.
Change-Id: Ib3a01c2cf3e3ab27806930f1be79db2b29f91bcf
Achin Gupta [Fri, 9 May 2014 09:03:15 +0000 (10:03 +0100)]
Introduce interrupt registration framework in BL3-1
This patch introduces a framework for registering interrupts routed to
EL3. The interrupt routing model is governed by the SCR_EL3.IRQ and
FIQ bits and the security state an interrupt is generated in. The
framework recognizes three type of interrupts depending upon which
exception level and security state they should be handled in
i.e. Secure EL1 interrupts, Non-secure interrupts and EL3
interrupts. It provides an API and macros that allow a runtime service
to register an handler for a type of interrupt and specify the routing
model. The framework validates the routing model and uses the context
management framework to ensure that it is applied to the SCR_EL3 prior
to entry into the target security state. It saves the handler in
internal data structures. An API is provided to retrieve the handler
when an interrupt of a particular type is asserted. Registration is
expected to be done once by the primary CPU. The same handler and
routing model is used for all CPUs.
Support for EL3 interrupts will be added to the framework in the
future. A makefile flag has been added to allow the FVP port choose
between ARM GIC v2 and v3 support in EL3. The latter version is
currently unsupported.
A framework for handling interrupts in BL3-1 will be introduced in
subsequent patches. The default routing model in the absence of any
handlers expects no interrupts to be routed to EL3.
Change-Id: Idf7c023b34fcd4800a5980f2bef85e4b5c29e649
Achin Gupta [Sun, 4 May 2014 17:38:28 +0000 (18:38 +0100)]
Add context library API to change a bit in SCR_EL3
This patch adds an API to write to any bit in the SCR_EL3 member of
the 'cpu_context' structure of the current CPU for a specified
security state. This API will be used in subsequent patches which
introduce interrupt management in EL3 to specify the interrupt routing
model when execution is not in EL3.
It also renames the cm_set_el3_elr() function to cm_set_elr_el3()
which is more in line with the system register name being targeted by
the API.
Change-Id: I310fa7d8f827ad3f350325eca2fb28cb350a85ed
Achin Gupta [Sun, 4 May 2014 17:23:26 +0000 (18:23 +0100)]
Rework 'state' field usage in per-cpu TSP context
This patch lays the foundation for using the per-cpu 'state' field in
the 'tsp_context' structure for other flags apart from the power state
of the TSP.
It allocates 2 bits for the power state, introduces the necessary
macros to manipulate the power state in the 'state' field and
accordingly reworks all use of the TSP_STATE_* states.
It also allocates a flag bit to determine if the TSP is handling a
standard SMC. If this flag is set then the TSP was interrupted due to
non-secure or EL3 interupt depending upon the chosen routing
model. Macros to get, set and clear this flag have been added as
well. This flag will be used by subsequent patches.
Change-Id: Ic6ee80bd5895812c83b35189cf2c3be70a9024a6
Vikram Kanigiri [Thu, 24 Apr 2014 10:02:16 +0000 (11:02 +0100)]
Add support for BL3-1 as a reset vector
This change adds optional reset vector support to BL3-1
which means BL3-1 entry point can detect cold/warm boot,
initialise primary cpu, set up cci and mail box.
When using BL3-1 as a reset vector it is assumed that
the BL3-1 platform code can determine the location of
the BL3-2 images, or load them as there are no parameters
that can be passed to BL3-1 at reset.
It also fixes the incorrect initialisation of mailbox
registers on the FVP platform
This feature can be enabled by building the code with
make variable RESET_TO_BL31 set as 1
Fixes ARM-software/TF-issues#133
Fixes ARM-software/TF-issues#20
Change-Id: I4e23939b1c518614b899f549f1e8d412538ee570
Vikram Kanigiri [Fri, 16 May 2014 17:48:12 +0000 (18:48 +0100)]
Rework memory information passing to BL3-x images
The issues addressed in this patch are:
1. Remove meminfo_t from the common interfaces in BL3-x,
expecting that platform code will find a suitable mechanism
to determine the memory extents in these images and provide
it to the BL3-x images.
2. Remove meminfo_t and bl31_plat_params_t from all FVP BL3-x
code as the images use link-time information to determine
memory extents.
meminfo_t is still used by common interface in BL1/BL2 for
loading images
Change-Id: I4e825ebf6f515b59d84dc2bdddf6edbf15e2d60f
Vikram Kanigiri [Tue, 15 Apr 2014 17:08:08 +0000 (18:08 +0100)]
Populate BL31 input parameters as per new spec
This patch is based on spec published at
https://github.com/ARM-software/tf-issues/issues/133
It rearranges the bl31_args struct into
bl31_params and bl31_plat_params which provide the
information needed for Trusted firmware and platform
specific data via x0 and x1
On the FVP platform BL3-1 params and BL3-1 plat params
and its constituents are stored at the start of TZDRAM.
The information about memory availability and size for
BL3-1, BL3-2 and BL3-3 is moved into platform specific data.
Change-Id: I8b32057a3d0dd3968ea26c2541a0714177820da9
Vikram Kanigiri [Thu, 15 May 2014 17:27:15 +0000 (18:27 +0100)]
Rework handover interface between BL stages
This patch reworks the handover interface from: BL1 to BL2 and
BL2 to BL3-1. It removes the raise_el(), change_el(), drop_el()
and run_image() functions as they catered for code paths that were
never exercised.
BL1 calls bl1_run_bl2() to jump into BL2 instead of doing the same
by calling run_image(). Similarly, BL2 issues the SMC to transfer
execution to BL3-1 through BL1 directly. Only x0 and x1 are used
to pass arguments to BL31. These arguments and parameters for
running BL3-1 are passed through a reference to a
'el_change_info_t' structure. They were being passed value in
general purpose registers earlier.
Change-Id: Id4fd019a19a9595de063766d4a66295a2c9307e1
Vikram Kanigiri [Tue, 13 May 2014 13:42:08 +0000 (14:42 +0100)]
Introduce macros to manipulate the SPSR
This patch introduces macros (SPSR_64 and SPSR_32) to
create a SPSR for both aarch32 and aarch64 execution
states. These macros allow the user to set fields
in the SPSR depending upon its format.
The make_spsr() function which did not allow
manipulation of all the fields in the aarch32 SPSR
has been replaced by these new macros.
Change-Id: I9425dda0923e8d5f03d03ddb8fa0e28392c4c61e
Andrew Thoelke [Mon, 19 May 2014 11:54:05 +0000 (12:54 +0100)]
Merge pull request #78 from jeenuv:tf-issues-148
Jeenu Viswambharan [Mon, 12 May 2014 14:28:47 +0000 (15:28 +0100)]
Add build configuration for timer save/restore
At present, non-secure timer register contents are saved and restored as
part of world switch by BL3-1. This effectively means that the
non-secure timer stops, and non-secure timer interrupts are prevented
from asserting until BL3-1 switches back, introducing latency for
non-secure services. Often, secure world might depend on alternate
sources for secure interrupts (secure timer or platform timer) instead
of non-secure timers, in which case this save and restore is
unnecessary.
This patch introduces a boolean build-time configuration NS_TIMER_SWITCH
to choose whether or not to save and restore non-secure timer registers
upon world switch. The default choice is made not to save and restore
them.
Fixes ARM-software/tf-issues#148
Change-Id: I1b9d623606acb9797c3e0b02fb5ec7c0a414f37e
Jeenu Viswambharan [Thu, 15 May 2014 13:47:21 +0000 (14:47 +0100)]
Document summary of build options in user guide
Change-Id: I6bd077955bf3780168a874705974bbe72ea0f5f1
Jeenu Viswambharan [Thu, 15 May 2014 13:40:58 +0000 (14:40 +0100)]
Reorganize build options
At present, various build options are initialized at various places in
the Makefile. This patch gathers all build option declarations at the
top of the Makefile and assigns them default values.
Change-Id: I9f527bc8843bf69c00cb754dc60377bdb407a951
Jeenu Viswambharan [Fri, 16 May 2014 10:38:10 +0000 (11:38 +0100)]
Introduce convenience functions to build
This patch introduces two convenience functions to the build system:
- assert_boolean: asserts that a given option is assigned either 0 or
1 as values
- add_define: helps add/append macro definitions to build tool command
line. This also introduces the variable DEFINES which is used to
collect and pass all relevant configurations to build tools
Change-Id: I3126894b034470d39858ebb3bd183bda681c7126
Soby Mathew [Mon, 7 Apr 2014 14:28:55 +0000 (15:28 +0100)]
Rework BL3-1 unhandled exception handling and reporting
This patch implements the register reporting when unhandled exceptions are
taken in BL3-1. Unhandled exceptions will result in a dump of registers
to the console, before halting execution by that CPU. The Crash Stack,
previously called the Exception Stack, is used for this activity.
This stack is used to preserve the CPU context and runtime stack
contents for debugging and analysis.
This also introduces the per_cpu_ptr_cache, referenced by tpidr_el3,
to provide easy access to some of BL3-1 per-cpu data structures.
Initially, this is used to provide a pointer to the Crash stack.
panic() now prints the the error file and line number in Debug mode
and prints the PC value in release mode.
The Exception Stack is renamed to Crash Stack with this patch.
The original intention of exception stack is no longer valid
since we intend to support several valid exceptions like IRQ
and FIQ in the trusted firmware context. This stack is now
utilized for dumping and reporting the system state when a
crash happens and hence the rename.
Fixes ARM-software/tf-issues#79 Improve reporting of unhandled exception
Change-Id: I260791dc05536b78547412d147193cdccae7811a
Andrew Thoelke [Fri, 16 May 2014 11:27:33 +0000 (12:27 +0100)]
Merge pull request #71 from sandrine-bailleux:sb/fix-tsp-fvp-makefile
Andrew Thoelke [Fri, 16 May 2014 11:26:26 +0000 (12:26 +0100)]
Merge pull request #69 from sandrine-bailleux:sb/split-mmu-fcts-per-el
Andrew Thoelke [Fri, 16 May 2014 11:02:12 +0000 (12:02 +0100)]
Merge pull request #68 from jcastillo-arm/jc/tf-issues/137
Change-Id: If8744c38c2d5c50caa7454b055e2ba418cf1e8bf
danh-arm [Fri, 16 May 2014 08:12:25 +0000 (09:12 +0100)]
Merge pull request #66 from athoelke/tzc-config-fix
Fixes for TZC configuration on FVP
Sandrine Bailleux [Tue, 13 May 2014 15:41:25 +0000 (16:41 +0100)]
fvp: Use the right implem. of plat_report_exception() in BL3-2
On FVP, the file 'plat/fvp/aarch64/plat_helpers.S' contains an
FVP-specific implementation of the function 'plat_report_exception()',
which is meant to override the default implementation. However, this
file was not included into the BL3-2 image, meaning it was still
using the default implementation. This patch fixes the FVP makefile
to compile this file in.
Change-Id: I3d44b9ec3a9de7e2762e0887d3599b185d3e28d2
Juan Castillo [Mon, 28 Apr 2014 11:48:40 +0000 (12:48 +0100)]
Fix C accessors to GIC distributor registers with set/clear semantics
This patch fixes C accessors to GIC registers that follow a set/clear
semantic to change the state of an interrupt, instead of read/write/modify.
These registers are:
Set-Enable
Clear-Enable
Set-Pending
Clear-Pending
Set-Active
Clear-Active
For instance, to enable an interrupt we write a one to the corresponding bit
in the Set-Enable register, whereas to disable it we write a one to the
corresponding bit in the Clear-Enable register.
Fixes ARM-software/tf-issues#137
Change-Id: I3b66bad94d0b28e0fe08c9042bac0bf5ffa07944
Andrew Thoelke [Fri, 9 May 2014 14:36:13 +0000 (15:36 +0100)]
Fixes for TZC configuration on FVP
The TZC configuration on FVP was incorrectly allowing both secure
and non-secure accesses to the DRAM, which can cause aliasing
problems for software. It was also not enabling virtio access on
some models.
This patch fixes both of those issues. The patch also enabless
non-secure access to the DDR RAM for all devices with defined IDs.
The third region of DDR RAM has been removed from the configuration
as this is not used in any of the FVP models.
Fixes ARM-software/tf-issues#150
Fixes ARM-software/tf-issues#151
Change-Id: I60ad5daaf55e14f178affb8afd95d17e7537abd7
Sandrine Bailleux [Fri, 9 May 2014 10:35:36 +0000 (11:35 +0100)]
fvp: Provide per-EL MMU setup functions
Instead of having a single version of the MMU setup functions for all
bootloader images that can execute either in EL3 or in EL1, provide
separate functions for EL1 and EL3. Each bootloader image can then
call the appropriate version of these functions. The aim is to reduce
the amount of code compiled in each BL image by embedding only what's
needed (e.g. BL1 to embed only EL3 variants).
Change-Id: Ib86831d5450cf778ae78c9c1f7553fe91274c2fa
Sandrine Bailleux [Fri, 9 May 2014 10:23:11 +0000 (11:23 +0100)]
Introduce IS_IN_ELX() macros
The goal of these macros is to improve code readability by providing
a concise way to check whether we are running in the expected
exception level.
Change-Id: If9aebadfb6299a5196e9a582b442f0971d9909b1
danh-arm [Thu, 8 May 2014 11:27:15 +0000 (12:27 +0100)]
Merge pull request #65 from vikramkanigiri/vk/console_init
Ensure a console is initialized before it is used
danh-arm [Thu, 8 May 2014 11:25:02 +0000 (12:25 +0100)]
Merge pull request #63 from soby-mathew/sm/save_callee_saved_registers_in_cpu_context-1
Preserve x19-x29 across world switch for exception handling
Vikram Kanigiri [Thu, 27 Mar 2014 14:33:15 +0000 (14:33 +0000)]
Ensure a console is initialized before it is used
This patch moves console_init() to bl32_early_platform_setup(). It
also ensures that console_init() is called in each
blX_early_platform_setup() function before the console is used
e.g. through a printf call in an assert() statement.
Fixes ARM-software/TF-issues#127
Change-Id: I5b1f17e0152bab674d807d2a95ff3689c5d4794e
danh-arm [Thu, 8 May 2014 11:01:24 +0000 (12:01 +0100)]
Merge pull request #62 from athoelke/set-little-endian-v2
Set processor endianness immediately after RESET v2
Soby Mathew [Wed, 30 Apr 2014 14:36:37 +0000 (15:36 +0100)]
Preserve x19-x29 across world switch for exception handling
Previously exception handlers in BL3-1, X19-X29 were not saved
and restored on every SMC/trap into EL3. Instead these registers
were 'saved as needed' as a side effect of the A64 ABI used by the C
compiler.
That approach failed when world switching but was not visible
with the TSP/TSPD code because the TSP is 64-bit, did not
clobber these registers when running and did not support pre-emption
by normal world interrupts. These scenarios showed
that the values in these registers can be passed through a world
switch, which broke the normal and trusted world assumptions
about these registers being preserved.
The Ideal solution saves and restores these registers when a
world switch occurs - but that type of implementation is more complex.
So this patch always saves and restores these registers on entry and
exit of EL3.
Fixes ARM-software/tf-issues#141
Change-Id: I9a727167bbc594454e81cf78a97ca899dfb11c27
danh-arm [Thu, 8 May 2014 11:01:10 +0000 (12:01 +0100)]
Merge pull request #58 from athoelke/optimise-cache-flush-v2
Optimise data cache clean/invalidate operation v2
danh-arm [Thu, 8 May 2014 11:00:10 +0000 (12:00 +0100)]
Merge pull request #61 from athoelke/use-mrs-msr-from-assembler-v2
Use MRS/MSR instructions in assembler code v2
danh-arm [Thu, 8 May 2014 10:55:19 +0000 (11:55 +0100)]
Merge pull request #60 from athoelke/disable-mmu-v2
Replace disable_mmu with assembler version v2
danh-arm [Thu, 8 May 2014 10:55:13 +0000 (11:55 +0100)]
Merge pull request #59 from athoelke/review-barriers-v2
Correct usage of data and instruction barriers v2
danh-arm [Thu, 8 May 2014 09:13:01 +0000 (10:13 +0100)]
Merge pull request #57 from sandrine-bailleux/sb/remove-pl011-base
Remove unused 'PL011_BASE' macro
Sandrine Bailleux [Tue, 6 May 2014 12:25:37 +0000 (13:25 +0100)]
Remove unused 'PL011_BASE' macro
'PL011_BASE' macro is no longer used because the right UART base
address is now directly given to the 'console_init()' function.
This patch removes it.
Change-Id: I94759c99602df4876291a56f9f6a75de337a65ec
Andrew Thoelke [Fri, 25 Apr 2014 09:49:30 +0000 (10:49 +0100)]
Optimise data cache clean/invalidate operation
The data cache clean and invalidate operations dcsw_op_all()
and dcsw_op_loius() were implemented to invoke a DSB and ISB
barrier for every set/way operation. This adds a substantial
performance penalty to an already expensive operation.
These functions have been reworked to provide an optimised
implementation derived from the code in section D3.4 of the
ARMv8 ARM. The helper macro setup_dcsw_op_args has been moved
and reworked alongside the implementation.
Fixes ARM-software/tf-issues#146
Change-Id: Icd5df57816a83f0a842fce935320a369f7465c7f
Andrew Thoelke [Mon, 28 Apr 2014 11:33:52 +0000 (12:33 +0100)]
Remove unused or invalid asm helper functions
There are a small number of non-EL specific helper functions
which are no longer used, and also some unusable helper
functions for non-existant registers.
This change removes all of these functions.
Change-Id: Idd656cef3b59cf5c46fe2be4029d72288b649c24
Andrew Thoelke [Mon, 28 Apr 2014 11:32:02 +0000 (12:32 +0100)]
Access system registers directly in assembler
Instead of using the system register helper functions to read
or write system registers, assembler coded functions should
use MRS/MSR instructions. This results in faster and more
compact code.
This change replaces all usage of the helper functions with
direct register accesses.
Change-Id: I791d5f11f257010bb3e6a72c6c5ab8779f1982b3
Andrew Thoelke [Mon, 28 Apr 2014 11:06:18 +0000 (12:06 +0100)]
Replace disable_mmu with assembler version
disable_mmu() cannot work as a C function as there is no control
over data accesses generated by the compiler between disabling and
cleaning the data cache. This results in reading stale data from
main memory.
As assembler version is provided for EL3, and a variant that also
disables the instruction cache which is now used by the BL1
exception handling function.
Fixes ARM-software/tf-issues#147
Change-Id: I0cf394d2579a125a23c2f2989c2e92ace6ddb1a6
Andrew Thoelke [Mon, 28 Apr 2014 11:28:39 +0000 (12:28 +0100)]
Correct usage of data and instruction barriers
The current code does not always use data and instruction
barriers as required by the architecture and frequently uses
barriers excessively due to their inclusion in all of the
write_*() helper functions.
Barriers should be used explicitly in assembler or C code
when modifying processor state that requires the barriers in
order to enable review of correctness of the code.
This patch removes the barriers from the helper functions and
introduces them as necessary elsewhere in the code.
PORTING NOTE: check any port of Trusted Firmware for use of
system register helper functions for reliance on the previous
barrier behaviour and add explicit barriers as necessary.
Fixes ARM-software/tf-issues#92
Change-Id: Ie63e187404ff10e0bdcb39292dd9066cb84c53bf
Andrew Thoelke [Thu, 24 Apr 2014 14:33:24 +0000 (15:33 +0100)]
Set processor endianness immediately after RESET
SCTLR_EL3.EE is being configured too late in bl1_arch_setup() and
bl31_arch_setup() after data accesses have already occured on
the cold and warm boot paths.
This control bit must be configured immediately on CPU reset to
match the endian state of the firmware (little endian).
Fixes ARM-software/tf-issues#145
Change-Id: Ie12e46fbbed6baf024c30beb50751591bb8c8655
danh-arm [Tue, 6 May 2014 16:57:34 +0000 (17:57 +0100)]
Merge pull request #49 from danh-arm/dh/remove-non-const-data
Remove variables from .data section
Dan Handley [Wed, 23 Apr 2014 12:47:06 +0000 (13:47 +0100)]
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
danh-arm [Tue, 6 May 2014 16:54:03 +0000 (17:54 +0100)]
Merge pull request #48 from danh-arm/dh/major-refactoring
dh/major refactoring
Dan Handley [Wed, 9 Apr 2014 12:14:54 +0000 (13:14 +0100)]
Reduce deep nesting of header files
Reduce the number of header files included from other header
files as much as possible without splitting the files. Use forward
declarations where possible. This allows removal of some unnecessary
"#ifndef __ASSEMBLY__" statements.
Also, review the .c and .S files for which header files really need
including and reorder the #include statements alphabetically.
Fixes ARM-software/tf-issues#31
Change-Id: Iec92fb976334c77453e010b60bcf56f3be72bd3e
Dan Handley [Thu, 10 Apr 2014 14:37:22 +0000 (15:37 +0100)]
Always use named structs in header files
Add tag names to all unnamed structs in header files. This
allows forward declaration of structs, which is necessary to
reduce header file nesting (to be implemented in a subsequent
commit).
Also change the typedef names across the codebase to use the _t
suffix to be more conformant with the Linux coding style. The
coding style actually prefers us not to use typedefs at all but
this is considered a step too far for Trusted Firmware.
Also change the IO framework structs defintions to use typedef'd
structs to be consistent with the rest of the codebase.
Change-Id: I722b2c86fc0d92e4da3b15e5cab20373dd26786f
Dan Handley [Wed, 23 Apr 2014 14:22:18 +0000 (15:22 +0100)]
Move PSCI global functions out of private header
Move the PSCI global functions out of psci_private.h and into
psci.h to allow the standard service to only depend on psci.h.
Change-Id: I8306924a3814b46e70c1dcc12524c7aefe06eed1
Dan Handley [Thu, 17 Apr 2014 17:53:42 +0000 (18:53 +0100)]
Separate BL functions out of arch.h
Move the BL function prototypes out of arch.h and into the
appropriate header files to allow more efficient header file
inclusion. Create new BL private header files where there is no
sensible existing header file.
Change-Id: I45f3e10b72b5d835254a6f25a5e47cf4cfb274c3
Dan Handley [Thu, 17 Apr 2014 16:48:52 +0000 (17:48 +0100)]
Refactor GIC header files
Move the function prototypes from gic.h into either gic_v2.h or
gic_v3.h as appropriate. Update the source files to include the
correct headers.
Change-Id: I368cfda175cdcbd3a68f46e2332738ec49048e19
Dan Handley [Thu, 17 Apr 2014 16:29:58 +0000 (17:29 +0100)]
Separate out CASSERT macro into own header
Separate out the CASSERT macro out of bl_common.h into its own
header to allow more efficient header inclusion.
Change-Id: I291be0b6b8f9879645e839a8f0dd1ec9b3db9639
Dan Handley [Tue, 15 Apr 2014 17:20:09 +0000 (18:20 +0100)]
Remove vpath usage in makefiles
Remove all usage of the vpath keyword in makefiles as it was prone
to mistakes. Specify the relative paths to source files instead.
Also reorder source files in makefiles alphabetically.
Fixes ARM-software/tf-issues#121
Change-Id: Id15f60655444bae60e0e2165259efac71a50928b
Dan Handley [Wed, 9 Apr 2014 12:13:04 +0000 (13:13 +0100)]
Make use of user/system includes more consistent
Make codebase consistent in its use of #include "" syntax for
user includes and #include <> syntax for system includes.
Fixes ARM-software/tf-issues#65
Change-Id: If2f7c4885173b1fd05ac2cde5f1c8a07000c7a33
Dan Handley [Fri, 11 Apr 2014 10:52:12 +0000 (11:52 +0100)]
Move FVP power driver to FVP platform
Move the FVP power driver to a directory under the FVP platform
port as this is not a generically usable driver.
Change-Id: Ibc78bd88752eb3e3964336741488349ac345f4f0
Dan Handley [Wed, 9 Apr 2014 11:48:25 +0000 (12:48 +0100)]
Move include and source files to logical locations
Move almost all system include files to a logical sub-directory
under ./include. The only remaining system include directories
not under ./include are specific to the platform. Move the
corresponding source files to match the include directory
structure.
Also remove pm.h as it is no longer used.
Change-Id: Ie5ea6368ec5fad459f3e8a802ad129135527f0b3
achingupta [Thu, 1 May 2014 12:16:33 +0000 (13:16 +0100)]
Merge pull request #50 from vikramkanigiri/vk/tf-issues#26
Preserve PSCI cpu_suspend 'power_state' parameter.
Vikram Kanigiri [Tue, 1 Apr 2014 18:26:26 +0000 (19:26 +0100)]
Preserve PSCI cpu_suspend 'power_state' parameter.
This patch saves the 'power_state' parameter prior to suspending
a cpu and invalidates it upon its resumption. The 'affinity level'
and 'state id' fields of this parameter can be read using a set of
public and private apis. Validation of power state parameter is
introduced which checks for SBZ bits are zero.
This change also takes care of flushing the parameter from the cache
to main memory. This ensures that it is available after cpu reset
when the caches and mmu are turned off. The earlier support for
saving only the 'affinity level' field of the 'power_state' parameter
has also been reworked.
Fixes ARM-Software/tf-issues#26
Fixes ARM-Software/tf-issues#130
Change-Id: Ic007ccb5e39bf01e0b67390565d3b4be33f5960a
danh-arm [Thu, 24 Apr 2014 18:38:28 +0000 (19:38 +0100)]
Merge pull request #33 from hliebel/hl/secure-memory
Hl/secure memory
Harry Liebel [Tue, 1 Apr 2014 18:28:07 +0000 (19:28 +0100)]
FVP secure memory support documentation
Fixes ARM-software/tf-issues#64
Change-Id: I4e56c25f9dc7f486fbf6fa2f7d8253874119b989
Harry Liebel [Tue, 1 Apr 2014 18:27:38 +0000 (19:27 +0100)]
Enable secure memory support for FVPs
- Use the TrustZone controller on Base FVP to program DRAM access
permissions. By default no access to DRAM is allowed if
'secure memory' is enabled on the Base FVP.
- The Foundation FVP does not have a TrustZone controller but instead
has fixed access permissions.
- Update FDTs for Linux to use timers at the correct security level.
- Starting the FVPs with 'secure memory' disabled is also supported.
Limitations:
Virtio currently uses a reserved NSAID. This will be corrected in
future FVP releases.
Change-Id: I0b6c003a7b5982267815f62bcf6eb82aa4c50a31
Harry Liebel [Tue, 1 Apr 2014 18:19:22 +0000 (19:19 +0100)]
Add TrustZone (TZC-400) driver
The TZC-400 performs security checks on transactions to memory or
peripherals. Separate regions can be created in the address space each
with individual security settings.
Limitations:
This driver does not currently support raising an interrupt on access
violation.
Change-Id: Idf8ed64b4d8d218fc9b6f9d75acdb2cd441d2449
danh-arm [Tue, 22 Apr 2014 10:02:13 +0000 (11:02 +0100)]
Merge pull request #43 from danh-arm/dh/tf-issues#129
Move console.c to pl011 specific driver location
danh-arm [Tue, 22 Apr 2014 10:01:58 +0000 (11:01 +0100)]
Merge pull request #44 from danh-arm/dh/tf-issues#136
Remove redundant code from bl1_plat_helpers.S
danh-arm [Wed, 16 Apr 2014 16:20:11 +0000 (17:20 +0100)]
Merge pull request #45 from danh-arm/dh/tf-issues#114
Rename FVP "mmap" array to avoid name confusion
Dan Handley [Tue, 15 Apr 2014 11:25:28 +0000 (12:25 +0100)]
Remove redundant code from bl1_plat_helpers.S
Remove redundant code in plat_secondary_cold_boot_setup() in
plat/fvp/aarch64/bl1_plat_helpers.S.
Fixes ARM-software/tf-issues#136
Change-Id: I98c0a46d95cfea33125e34e609c83dc2c97cd86e
danh-arm [Wed, 16 Apr 2014 14:29:03 +0000 (15:29 +0100)]
Merge pull request #40 from athoelke/at/up-stacks-76-v2
Allocate single stacks for BL1 and BL2 (v2)
Andrew Thoelke [Thu, 20 Mar 2014 10:48:23 +0000 (10:48 +0000)]
Allocate single stacks for BL1 and BL2
The BL images share common stack management code which provides
one coherent and one cacheable stack for every CPU. BL1 and BL2
just execute on the primary CPU during boot and do not require
the additional CPU stacks. This patch provides separate stack
support code for UP and MP images, substantially reducing the
RAM usage for BL1 and BL2 for the FVP platform.
This patch also provides macros for declaring stacks and
calculating stack base addresses to improve consistency where
this has to be done in the firmware.
The stack allocation source files are now included via
platform.mk rather than the common BLx makefiles. This allows
each platform to select the appropriate MP/UP stack support
for each BL image.
Each platform makefile must be updated when including this
commit.
Fixes ARM-software/tf-issues#76
Change-Id: Ia251f61b8148ffa73eae3f3711f57b1ffebfa632
Dan Handley [Tue, 15 Apr 2014 09:38:02 +0000 (10:38 +0100)]
Rename FVP "mmap" array to avoid name confusion
Rename the array "mmap" in plat/fvp/aarch64/plat_common.c to
"fvp_mmap", to avoid confusion with the array of the same name
in lib/arch/aarch64/xlat_tables.c
Fixes ARM-software/tf-issues#114
Change-Id: I61478c0070aa52d5dcf5d85af2f353f56c060cfb
danh-arm [Tue, 15 Apr 2014 08:39:47 +0000 (09:39 +0100)]
Merge pull request #36 from athoelke/at/gc-sections-80
Using GCC --gc-sections to eliminate unused code and data
Dan Handley [Mon, 14 Apr 2014 16:03:01 +0000 (17:03 +0100)]
Move console.c to pl011 specific driver location
Rename drivers/console/console.c to
drivers/arm/peripherals/pl011/pl011_console.c. This makes it clear
that this is a pl011 specific console implementation.
Fixes ARM-software/tf-issues#129
Change-Id: Ie2f8109602134c5b86993e32452c70734c45a3ed
danh-arm [Fri, 11 Apr 2014 17:39:01 +0000 (18:39 +0100)]
Merge pull request #38 from sandrine-bailleux/sb/tf-issue-125
Fix system counter initialisation
Sandrine Bailleux [Mon, 31 Mar 2014 10:25:18 +0000 (11:25 +0100)]
Define frequency of system counter in platform code
BL3-1 architecture setup code programs the system counter frequency
into the CNTFRQ_EL0 register. This frequency is defined by the
platform, though. This patch introduces a new platform hook that
the architecture setup code can call to retrieve this information.
In the ARM FVP port, this returns the first entry of the frequency
modes table from the memory mapped generic timer.
All system counter setup code has been removed from BL1 as some
platforms may not have initialized the system counters at this stage.
The platform specific settings done exclusively in BL1 have been moved
to BL3-1. In the ARM FVP port, this consists in enabling and
initializing the System level generic timer. Also, the frequency change
request in the counter control register has been set to 0 to make it
explicit it's using the base frequency. The CNTCR_FCREQ() macro has been
fixed in this context to give an entry number rather than a bitmask.
In future, when support for firmware update is implemented, there
is a case where BL1 platform specific code will need to program
the counter frequency. This should be implemented at that time.
This patch also updates the relevant documentation.
It properly fixes ARM-software/tf-issues#24
Change-Id: If95639b279f75d66ac0576c48a6614b5ccb0e84b
Sandrine Bailleux [Mon, 31 Mar 2014 09:44:09 +0000 (10:44 +0100)]
Revert "Move architecture timer setup to platform-specific code"
This reverts commit
1c297bf015226c182b66498d5a64b8b51c7624f5
because it introduced a bug: the CNTFRQ_EL0 register was no
longer programmed by all CPUs. bl31_platform_setup() function
is invoked only in the cold boot path and consequently only
on the primary cpu.
A subsequent commit will correctly implement the necessary changes
to the counter frequency setup code.
Fixes ARM-software/tf-issues#125
Conflicts:
docs/firmware-design.md
plat/fvp/bl31_plat_setup.c
Change-Id: Ib584ad7ed069707ac04cf86717f836136ad3ab54
danh-arm [Mon, 7 Apr 2014 15:49:37 +0000 (16:49 +0100)]
Merge pull request #35 from sandrine-bailleux/sb/add-missing-include-guard
Add missing #include guard in xlat_tables.h
danh-arm [Fri, 4 Apr 2014 16:15:20 +0000 (17:15 +0100)]
Merge pull request #34 from danh-arm/dh/new-integration-process
Update contributing.md with new integration process
Sandrine Bailleux [Thu, 3 Apr 2014 12:48:04 +0000 (13:48 +0100)]
Add missing #include guard in xlat_tables.h
Change-Id: I7272a800accb7de71cbbf6b715a43061bbf79f8c
Dan Handley [Fri, 28 Mar 2014 10:49:39 +0000 (10:49 +0000)]
Update contributing.md with new integration process
Contributions will now be merged into an ARM Trusted Firmware
integration branch on GitHub instead of via an ARM internal
branch.
Andrew Thoelke [Tue, 18 Mar 2014 13:46:55 +0000 (13:46 +0000)]
Place assembler functions in separate sections
This extends the --gc-sections behaviour to the many assembler
support functions in the firmware images by placing each function
into its own code section. This is achieved by creating a 'func'
macro used to declare each function label.
Fixes ARM-software/tf-issues#80
Change-Id: I301937b630add292d2dec6d2561a7fcfa6fec690
Andrew Thoelke [Tue, 18 Mar 2014 07:13:52 +0000 (07:13 +0000)]
Use --gc-sections during link
All common functions are being built into all binary images,
whether or not they are actually used. This change enables the
use of -ffunction-sections, -fdata-sections and --gc-sections
in the compiler and linker to remove unused code and data from
the images.
Change-Id: Ia9f78c01054ac4fa15d145af38b88a0d6fb7d409
Achin Gupta [Wed, 26 Mar 2014 18:44:15 +0000 (18:44 +0000)]
Fix build failure due to a typo in TSPD code
This patch fixes a build failure when TSPD support is included. The failure was
due to a missing semi-colon at the end of a C statement in tspd_common.c
Change-Id: I8fbd0d500bd9145b15f862b8686e570b80fcce8c
Sandrine Bailleux [Fri, 21 Mar 2014 14:17:51 +0000 (14:17 +0000)]
Build system: Trigger dependency checking only for build targets
The Makefile used to specify a blacklist of rules for which
dependency checking must not be triggered. This list included
cleaning rules only, whereas all other non-build targets (e.g.
help, checkpatch, etc.) should also be included.
This approach seems a bit fragile because it is easy to forget
some non-building rules in the blacklist, as the experience
showed us. It is more robust to specify a whitelist of rules
for which dependency checking is required.
Fixes ARM-software/tf-issues#112
Change-Id: I030c405abb35972a726a5200396430316d18f963
Vikram Kanigiri [Tue, 25 Mar 2014 17:35:26 +0000 (17:35 +0000)]
Initialise UART console in all bootloader stages
This patch reworks the console driver to ensure that each bootloader stage
initializes it independently. As a result, both BL3-1 and BL2 platform code
now calls console_init() instead of relying on BL1 to perform console setup
Fixes ARM-software/tf-issues#120
Change-Id: Ic4d66e0375e40a2fc7434afcabc8bbb4715c14ab
Soby Mathew [Wed, 12 Mar 2014 14:52:51 +0000 (14:52 +0000)]
Move console functions out of pl011.c
This commit isolates the accessor functions in pl011.c and builds
a wrapper layer for console functions.
This also modifies the console driver to use the pl011 FIFO.
Fixes ARM-software/tf-issues#63
Change-Id: I3b402171cd14a927831bf5e5d4bb310b6da0e9a8
Sandrine Bailleux [Fri, 21 Mar 2014 13:16:35 +0000 (13:16 +0000)]
Build system: Remove last traces of 'PLAT=all'
It used to be possible to build all bootloader binaries for all platforms
using 'PLAT=all'. This feature has been removed but there are still some
traces of its existence. This patch removes them.
Change-Id: Ic671a5c20c5b64acbd0a912d2e4db8f9d9574610
Vikram Kanigiri [Mon, 24 Mar 2014 11:21:35 +0000 (11:21 +0000)]
Fix build by correcting asm helper function usage in TSPD
This patch fixes a regression failure due to the use of functions by the
TSPD code which access system registers with partially qualified names.
These functions had been removed in an earlier patch. The relevant code
has been updated to access these registers with their fully qualified
names.
Fixes ARM-software/tf-issues#119
Change-Id: Ide1bc5036e1b8164a42f7b7fe86186ad860e0ef9
Sandrine Bailleux [Mon, 24 Mar 2014 10:24:08 +0000 (10:24 +0000)]
Separate out BL2, BL3-1 and BL3-2 early exception vectors from BL1
bl1/aarch64/early_exceptions.S used to be re-used by BL2, BL3-1 and
BL3-2. There was some early SMC handling code in there that was not
required by the other bootloader stages. Therefore this patch
introduces an even simpler exception vector source file for BL2,
BL3-1 and BL3-2.
Fixes ARM-software/tf-issues#38
Change-Id: I0244b80e9930b0f8035156a0bf91cc3e9a8f995d
Vikram Kanigiri [Thu, 20 Mar 2014 16:27:01 +0000 (16:27 +0000)]
Move per cpu exception stack in BL31 to tzfw_normal_stacks
Fixes ARM-software/tf-issues#70
Change-Id: I7f024f173fbdecd315076f528b05d6295aff7276
Vikram Kanigiri [Fri, 21 Mar 2014 11:57:10 +0000 (11:57 +0000)]
Add standby state support in PSCI cpu_suspend api
This patch adds support in the generic PSCI implementation to call a
platform specific function to enter a standby state using an example
implementation in ARM FVP port
Fixes ARM-software/tf-issues#94
Change-Id: Ic1263fcf25f28e09162ad29dca954125f9aa8cc9
Sandrine Bailleux [Thu, 20 Mar 2014 15:51:02 +0000 (15:51 +0000)]
Semihosting: Fix file mode to load binaries on Windows
Trusted firmware binaries loaded via semihosting used to be
opened using 'r' mode (i.e. read mode). This is fine on POSIX
conforming systems (including Linux) but for Windows it also means
that the file should be opened in text mode. 'rb' mode must be
specified instead for binary mode. On POSIX conforming systems,
'rb' mode is equivalent to 'r' mode so it does no harm.
Fixes ARM-software/tf-issues#69
Change-Id: Ifa53f2ecfd765f572dea5dd73191f9fe2b2c2011
Vikram Kanigiri [Tue, 11 Mar 2014 17:41:00 +0000 (17:41 +0000)]
Remove partially qualified asm helper functions
Each ARM Trusted Firmware image should know in which EL it is running
and it should use the corresponding register directly instead of reading
currentEL and knowing which asm register to read/write
Change-Id: Ief35630190b6f07c8fbb7ba6cb20db308f002945
Vikram Kanigiri [Thu, 20 Mar 2014 12:23:21 +0000 (12:23 +0000)]
Fix the disable_mmu code
Remove the hard coding of all the MMU related registers with 0 and disable MMU
by clearing the M and C bit in SCTLR_ELx
Change-Id: I4a0b1bb14a604734b74c32eb31315d8504a7b8d8
Sandrine Bailleux [Thu, 13 Mar 2014 14:48:31 +0000 (14:48 +0000)]
TSP: Make the platform-specific makefile mandatory
The Test Secure-EL1 Payload implementation should always have a
platform-specific component. Therefore, there should always
be a platform-specific sub-makefile for the TSP. If there is
none then assume TSP is not supported on this specific platform
and throw an error at build time if the user tries to compile it.
Change-Id: Ibfbe6e4861cc7786a29f2fc0341035b852925193
Sandrine Bailleux [Wed, 19 Mar 2014 16:03:48 +0000 (16:03 +0000)]
Fix file_to_uuid() function
This patch fixes a bug in the 'file_to_uuid()' function: it used
to cause an exception by dereferencing a null pointer when
a given UUID was not found in the UUID array. The fix is to delete
the final null entry in the UUID array, which is not needed because
the array is statically declared so its size is known at build time.
Fixes ARM-software/tf-issues#43
Change-Id: I0a003485b88134564c0d36f57c274215d9e16532
Sandrine Bailleux [Wed, 19 Mar 2014 13:39:52 +0000 (13:39 +0000)]
FIP tool: Fix error message for missing FIP filename
Previously to this path, the FIP tool used to print the following,
misleading error message when called without any argument or with
'--help' option:
ERROR: Too many arguments
This patch fixes this behavior by printing the following error
message instead:
ERROR: Missing FIP filename
If called with '--help', no error message is printed and only the
help message is displayed.
Change-Id: Ib281b056f5cd3bc2f66d98be0b0cb2a0aed7c6a8