BL1: Add linker symbol identifying end of ROM content
This patch adds a new linker symbol in BL1's linker script named '__BL1_ROM_END__', which marks the end of BL1's ROM content. This covers BL1's code, read-only data and read-write data to relocate in Trusted SRAM. The address of this new linker symbol is exported to C code through the 'BL1_ROM_END' macro. The section related to linker symbols in the Firmware Design guide has been updated and improved. Change-Id: I5c442ff497c78d865ffba1d7d044511c134e11c7
This commit is contained in:
parent
b9161469fa
commit
c02fcc4a38
10
bl1/bl1.ld.S
10
bl1/bl1.ld.S
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -139,12 +139,14 @@ SECTIONS
|
||||||
|
|
||||||
__DATA_ROM_START__ = LOADADDR(.data);
|
__DATA_ROM_START__ = LOADADDR(.data);
|
||||||
__DATA_SIZE__ = SIZEOF(.data);
|
__DATA_SIZE__ = SIZEOF(.data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The .data section is the last PROGBITS section so its end marks the end
|
* The .data section is the last PROGBITS section so its end marks the end
|
||||||
* of the read-only part of BL1's binary.
|
* of BL1's actual content in Trusted ROM.
|
||||||
*/
|
*/
|
||||||
ASSERT(__DATA_ROM_START__ + __DATA_SIZE__ <= BL1_RO_LIMIT,
|
__BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__;
|
||||||
"BL1's RO section has exceeded its limit.")
|
ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
|
||||||
|
"BL1's ROM content has exceeded its limit.")
|
||||||
|
|
||||||
__BSS_SIZE__ = SIZEOF(.bss);
|
__BSS_SIZE__ = SIZEOF(.bss);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -35,8 +35,11 @@
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Declarations of linker defined symbols which will tell us where BL1 lives
|
* Declarations of linker defined symbols which will tell us where BL1 lives
|
||||||
* in Trusted RAM
|
* in Trusted ROM and RAM
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
extern uint64_t __BL1_ROM_END__;
|
||||||
|
#define BL1_ROM_END (uint64_t)(&__BL1_ROM_END__)
|
||||||
|
|
||||||
extern uint64_t __BL1_RAM_START__;
|
extern uint64_t __BL1_RAM_START__;
|
||||||
extern uint64_t __BL1_RAM_END__;
|
extern uint64_t __BL1_RAM_END__;
|
||||||
#define BL1_RAM_BASE (uint64_t)(&__BL1_RAM_START__)
|
#define BL1_RAM_BASE (uint64_t)(&__BL1_RAM_START__)
|
||||||
|
|
|
@ -1052,10 +1052,10 @@ Each bootloader image can be divided in 2 parts:
|
||||||
All PROGBITS sections are grouped together at the beginning of the image,
|
All PROGBITS sections are grouped together at the beginning of the image,
|
||||||
followed by all NOBITS sections. This is true for all Trusted Firmware images
|
followed by all NOBITS sections. This is true for all Trusted Firmware images
|
||||||
and it is governed by the linker scripts. This ensures that the raw binary
|
and it is governed by the linker scripts. This ensures that the raw binary
|
||||||
images are as small as possible. If a NOBITS section would sneak in between
|
images are as small as possible. If a NOBITS section was inserted in between
|
||||||
PROGBITS sections then the resulting binary file would contain a bunch of zero
|
PROGBITS sections then the resulting binary file would contain zero bytes in
|
||||||
bytes at the location of this NOBITS section, making the image unnecessarily
|
place of this NOBITS section, making the image unnecessarily bigger. Smaller
|
||||||
bigger. Smaller images allow faster loading from the FIP to the main memory.
|
images allow faster loading from the FIP to the main memory.
|
||||||
|
|
||||||
### Linker scripts and symbols
|
### Linker scripts and symbols
|
||||||
|
|
||||||
|
@ -1110,47 +1110,42 @@ layout as they are easy to spot in the link map files.
|
||||||
|
|
||||||
#### Common linker symbols
|
#### Common linker symbols
|
||||||
|
|
||||||
Early setup code needs to know the extents of the BSS section to zero-initialise
|
All BL images share the following requirements:
|
||||||
it before executing any C code. The following linker symbols are defined for
|
|
||||||
this purpose:
|
|
||||||
|
|
||||||
* `__BSS_START__` This address must be aligned on a 16-byte boundary.
|
* The BSS section must be zero-initialised before executing any C code.
|
||||||
* `__BSS_SIZE__`
|
* The coherent memory section (if enabled) must be zero-initialised as well.
|
||||||
|
* The MMU setup code needs to know the extents of the coherent and read-only
|
||||||
|
memory regions to set the right memory attributes.
|
||||||
|
|
||||||
Similarly, the coherent memory section (if enabled) must be zero-initialised.
|
The following linker symbols are defined for this purpose:
|
||||||
Also, the MMU setup code needs to know the extents of this section to set the
|
|
||||||
right memory attributes for it. The following linker symbols are defined for
|
|
||||||
this purpose:
|
|
||||||
|
|
||||||
* `__COHERENT_RAM_START__` This address must be aligned on a page-size boundary.
|
* `__BSS_START__` Must be aligned on a 16-byte boundary.
|
||||||
* `__COHERENT_RAM_END__` This address must be aligned on a page-size boundary.
|
* `__BSS_SIZE__`
|
||||||
* `__COHERENT_RAM_UNALIGNED_SIZE__`
|
* `__COHERENT_RAM_START__` Must be aligned on a page-size boundary.
|
||||||
|
* `__COHERENT_RAM_END__` Must be aligned on a page-size boundary.
|
||||||
|
* `__COHERENT_RAM_UNALIGNED_SIZE__`
|
||||||
|
* `__RO_START__`
|
||||||
|
* `__RO_END__`
|
||||||
|
|
||||||
#### BL1's linker symbols
|
#### BL1's linker symbols
|
||||||
|
|
||||||
BL1's early setup code needs to know the extents of the .data section to
|
BL1 being the ROM image, it has additional requirements. BL1 resides in ROM and
|
||||||
relocate it from ROM to RAM before executing any C code. The following linker
|
it is entirely executed in place but it needs some read-write memory for its
|
||||||
symbols are defined for this purpose:
|
mutable data. Its `.data` section (i.e. its allocated read-write data) must be
|
||||||
|
relocated from ROM to RAM before executing any C code.
|
||||||
|
|
||||||
* `__DATA_ROM_START__` This address must be aligned on a 16-byte boundary.
|
The following additional linker symbols are defined for BL1:
|
||||||
* `__DATA_RAM_START__` This address must be aligned on a 16-byte boundary.
|
|
||||||
* `__DATA_SIZE__`
|
|
||||||
|
|
||||||
BL1's platform setup code needs to know the extents of its read-write data
|
* `__BL1_ROM_END__` End address of BL1's ROM contents, covering its code
|
||||||
region to figure out its memory layout. The following linker symbols are defined
|
and `.data` section in ROM.
|
||||||
for this purpose:
|
* `__DATA_ROM_START__` Start address of the `.data` section in ROM. Must be
|
||||||
|
aligned on a 16-byte boundary.
|
||||||
|
* `__DATA_RAM_START__` Address in RAM where the `.data` section should be
|
||||||
|
copied over. Must be aligned on a 16-byte boundary.
|
||||||
|
* `__DATA_SIZE__` Size of the `.data` section (in ROM or RAM).
|
||||||
|
* `__BL1_RAM_START__` Start address of BL1 read-write data.
|
||||||
|
* `__BL1_RAM_END__` End address of BL1 read-write data.
|
||||||
|
|
||||||
* `__BL1_RAM_START__` This is the start address of BL1 RW data.
|
|
||||||
* `__BL1_RAM_END__` This is the end address of BL1 RW data.
|
|
||||||
|
|
||||||
#### BL2's, BL31's and TSP's linker symbols
|
|
||||||
|
|
||||||
BL2, BL31 and TSP need to know the extents of their read-only section to set
|
|
||||||
the right memory attributes for this memory region in their MMU setup code. The
|
|
||||||
following linker symbols are defined for this purpose:
|
|
||||||
|
|
||||||
* `__RO_START__`
|
|
||||||
* `__RO_END__`
|
|
||||||
|
|
||||||
### How to choose the right base addresses for each bootloader stage image
|
### How to choose the right base addresses for each bootloader stage image
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue