summaryrefslogtreecommitdiffstats
path: root/arch/riscv/boot/entry.c
blob: eb286423d875d2a837d08cc8535960320841cfd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* SPDX-License-Identifier: GPL-2.0 */
#include <types.h>

#include <asm/barebox-riscv.h>

#include "entry.h"
#include <debug_ll.h>

/*
 * Main RISC-V entry point. Call this with the memory region you can
 * spare for barebox. This doesn't necessarily have to be the full
 * SDRAM. The currently running binary can be inside or outside of
 * this region. The PBL can be running inside or outside of this
 * region.
 *
 * -> membase + memsize
 *   STACK_SIZE              - stack
 *   128KiB                  - early memory space
 * -> maximum end of barebox binary
 */

void __noreturn __naked barebox_riscv_entry(unsigned long membase,
					    unsigned long memsize, void *boarddata)
{
	unsigned long stack_top = riscv_mem_stack_top(membase, membase + memsize);
	asm volatile ("move sp, %0" : : "r"(stack_top));
	barebox_pbl_start(membase, memsize, boarddata);
}