2 * This file is part of the coreboot project.
4 * Copyright 2013 Google Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <arch/cache.h>
21 #include <arch/lib_helpers.h>
22 #include <arch/secmon.h>
23 #include <arch/stages.h>
24 #include <arch/spintable.h>
25 #include <arch/transition.h>
27 #include <console/console.h>
28 #include <program_loading.h>
31 void arch_payload_run(const struct payload
*payload
)
33 void (*payload_entry
)(void *) = payload
->entry
;
35 void *cb_tables
= cbmem_find(CBMEM_ID_CBTABLE
);
36 uint8_t current_el
= get_current_el();
38 printk(BIOS_SPEW
, "entry = %p\n", payload
->entry
);
40 secmon_run(payload_entry
, cb_tables
);
42 /* Start the other CPUs spinning. */
45 /* If current EL is not EL3, jump to payload at same EL. */
46 if (current_el
!= EL3
) {
47 cache_sync_instructions();
48 /* Point of no-return */
49 payload_entry(cb_tables
);
52 /* If current EL is EL3, we transition to payload in EL2. */
53 struct exc_state exc_state
;
55 memset(&exc_state
, 0, sizeof(exc_state
));
57 exc_state
.elx
.spsr
= get_eret_el(EL2
, SPSR_USE_L
);
59 cache_sync_instructions();
60 transition_with_entry(payload
->entry
, cb_tables
, &exc_state
);