Commit ee25fca8 authored by Jing Li's avatar Jing Li Committed by guzitao
Browse files

sw64: receive new boot params from firmware

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB73UR



--------------------------------

Starting from junzhang, firmware pass a magic number (0xDEED2024UL) via
r16 and dtb base address via r17 when jumping to kernel.

When kernel receives the magic number, it means that we can parse the
required boot params from the chosen node in DTB. Otherwise, kernel will
use legacy "struct boot_params" for backward compatibility.

Signed-off-by: default avatarJing Li <jingli@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 90b8b6c3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ extern unsigned long bios_version;
#endif

extern struct boot_params *sunway_boot_params;
extern unsigned long sunway_boot_magic;
extern unsigned long sunway_dtb_address;

extern void sw64_halt(void);
extern void sw64_poweroff(void);
+23 −0
Original line number Diff line number Diff line
@@ -37,6 +37,16 @@ __start:
	/* ... and find our stack ... */
	ldi	$30, ASM_THREAD_SIZE($30)

	/**
	 * Starting from Core4, Grub uses $16 to pass magic num
	 * and use $17 to pass DTB base address.
	 *
	 * So, we need to save $16 and $17 before clearing bss.
	 */
	ldi     $30, -16($30)
	stl     $16, 8($30)
	stl     $17, 0($30)

	/* ... and then we can clear bss data.  */
	ldi	$16, __bss_start
	ldi	$18, __bss_stop
@@ -44,6 +54,18 @@ __start:
	mov	$31, $17
	call	$26, __constant_c_memset
	ldgp	$29, 0($26)

	/* Get magic num and DTB base address. */
	ldl     $16, 8($30)
	ldl     $17, 0($30)
	ldi     $30, 16($30)
	/* sunway_boot_magic = $16 */
	ldi     $7, sunway_boot_magic
	stl     $16, 0($7)
	/* sunway_dtb_address = $17 */
	ldi     $7, sunway_dtb_address
	stl     $17, 0($7)

#ifdef CONFIG_RELOCATABLE
	ldi	$30, -8($30)
	stl	$29, 0($30)
@@ -56,6 +78,7 @@ __start:
	/* Repoint the sp into the new kernel image */
	addl	$30, $0, $30
#endif

	/* ... and then we can start the kernel.  */
	call	$26, sw64_start_kernel
	sys_call HMC_halt
+10 −0
Original line number Diff line number Diff line
@@ -125,8 +125,18 @@ static char builtin_cmdline[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
#endif

/* boot_params */
/**
 * Keep sunway_boot_params for backward compatibility. All related code
 * will be removed when kernel no longer support C3B(xuelang).
 */
struct boot_params *sunway_boot_params = (struct boot_params *) (PARAM + 0x100);

unsigned long sunway_boot_magic;
EXPORT_SYMBOL(sunway_boot_magic);

unsigned long sunway_dtb_address;
EXPORT_SYMBOL(sunway_dtb_address);

/*
 * The format of "screen_info" is strange, and due to early
 * i386-setup code. This is just enough to make the console