blob: 1b8cb961102ee84f83c481ffb68738828a4315d3 [file] [log] [blame]
Ronald G. Minnich5965cba2016-10-19 08:07:13 -07001/*
2 * This file is part of the coreboot project.
3 *
Jonathan Neuschäfer042a8332018-02-16 13:36:47 +01004 * Copyright (C) 2016 Google Inc
5 * Copyright (C) 2018 Jonathan Neuschäfer
6 *
Ronald G. Minnich5965cba2016-10-19 08:07:13 -07007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
Jonathan Neuschäfer042a8332018-02-16 13:36:47 +010017// "return" to a payload. a0: FDT, a1: entry point
Ronald G. Minnich5965cba2016-10-19 08:07:13 -070018 .global riscvpayload
19riscvpayload:
Jonathan Neuschäfer042a8332018-02-16 13:36:47 +010020 /* Load the entry point */
21 mv t0, a1
22 csrw mepc, t0
23 csrr t0, mstatus
24
25 /* Set mstatus.MPP (the previous privilege mode) to supervisor mode */
26 li t1, ~(3<<11)
27 and t0, t0, t1
28 li t2, (1<<11)
29 or t0, t0, t2
30 csrw mstatus, t0
31
32 /* Pass the right arguments and jump! */
33 mv a1, a0
34 csrr a0, mhartid
Jonathan Neuschäfer140a8272017-09-29 01:36:58 +020035 mret