| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <assert.h> |
| 9 |
|
| 10 |
#include <platform_def.h> |
| 11 |
|
| 12 |
#include <arch.h> |
| 13 |
#include <arch_helpers.h> |
| 14 |
#include <common/debug.h> |
| 15 |
#include <lib/mmio.h> |
| 16 |
#include <lib/xlat_tables/xlat_tables_v2.h> |
| 17 |
|
| 18 |
#include <plat_marvell.h> |
| 19 |
|
| 20 |
|
| 21 |
#pragma weak plat_get_ns_image_entrypoint |
| 22 |
#pragma weak plat_marvell_get_mmap |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
void marvell_setup_page_tables(uintptr_t total_base, |
| 34 |
size_t total_size, |
| 35 |
uintptr_t code_start, |
| 36 |
uintptr_t code_limit, |
| 37 |
uintptr_t rodata_start, |
| 38 |
uintptr_t rodata_limit |
| 39 |
#if USE_COHERENT_MEM |
| 40 |
, |
| 41 |
uintptr_t coh_start, |
| 42 |
uintptr_t coh_limit |
| 43 |
#endif |
| 44 |
) |
| 45 |
{ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
VERBOSE("Trusted SRAM seen by this BL image: %p - %p\n", |
| 51 |
(void *) total_base, (void *) (total_base + total_size)); |
| 52 |
mmap_add_region(total_base, total_base, |
| 53 |
total_size, |
| 54 |
MT_MEMORY | MT_RW | MT_SECURE); |
| 55 |
|
| 56 |
|
| 57 |
VERBOSE("Code region: %p - %p\n", |
| 58 |
(void *) code_start, (void *) code_limit); |
| 59 |
mmap_add_region(code_start, code_start, |
| 60 |
code_limit - code_start, |
| 61 |
MT_CODE | MT_SECURE); |
| 62 |
|
| 63 |
|
| 64 |
VERBOSE("Read-only data region: %p - %p\n", |
| 65 |
(void *) rodata_start, (void *) rodata_limit); |
| 66 |
mmap_add_region(rodata_start, rodata_start, |
| 67 |
rodata_limit - rodata_start, |
| 68 |
MT_RO_DATA | MT_SECURE); |
| 69 |
|
| 70 |
#if USE_COHERENT_MEM |
| 71 |
|
| 72 |
VERBOSE("Coherent region: %p - %p\n", |
| 73 |
(void *) coh_start, (void *) coh_limit); |
| 74 |
mmap_add_region(coh_start, coh_start, |
| 75 |
coh_limit - coh_start, |
| 76 |
MT_DEVICE | MT_RW | MT_SECURE); |
| 77 |
#endif |
| 78 |
|
| 79 |
|
| 80 |
mmap_add(plat_marvell_get_mmap()); |
| 81 |
|
| 82 |
|
| 83 |
init_xlat_tables(); |
| 84 |
} |
| 85 |
|
| 86 |
unsigned long plat_get_ns_image_entrypoint(void) |
| 87 |
{ |
| 88 |
return PLAT_MARVELL_NS_IMAGE_OFFSET; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
uint32_t marvell_get_spsr_for_bl32_entry(void) |
| 96 |
{ |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
return 0; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
uint32_t marvell_get_spsr_for_bl33_entry(void) |
| 109 |
{ |
| 110 |
unsigned long el_status; |
| 111 |
unsigned int mode; |
| 112 |
uint32_t spsr; |
| 113 |
|
| 114 |
|
| 115 |
el_status = read_id_aa64pfr0_el1() >> ID_AA64PFR0_EL2_SHIFT; |
| 116 |
el_status &= ID_AA64PFR0_ELX_MASK; |
| 117 |
|
| 118 |
mode = (el_status) ? MODE_EL2 : MODE_EL1; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
spsr = SPSR_64(mode, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS); |
| 126 |
return spsr; |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
const mmap_region_t *plat_marvell_get_mmap(void) |
| 134 |
{ |
| 135 |
return plat_marvell_mmap; |
| 136 |
} |
| 137 |
|