2019-04-29 14:25:19 +08:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sbi/fw_dynamic.h>
|
|
|
|
|
|
|
|
#include "fw_base.S"
|
|
|
|
|
2019-11-06 18:54:35 +08:00
|
|
|
.section .entry, "ax", %progbits
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-11-06 18:54:35 +08:00
|
|
|
.global fw_boot_hart
|
|
|
|
/*
|
|
|
|
* This function is called very early even before
|
|
|
|
* fw_save_info() is called.
|
|
|
|
* We can only use a0, a1, and a2 registers here.
|
|
|
|
* The boot HART id should be returned in 'a0'.
|
|
|
|
*/
|
|
|
|
fw_boot_hart:
|
|
|
|
/* Sanity checks */
|
|
|
|
li a1, FW_DYNAMIC_INFO_MAGIC_VALUE
|
|
|
|
REG_L a0, FW_DYNAMIC_INFO_MAGIC_OFFSET(a2)
|
2024-03-04 20:15:50 +08:00
|
|
|
bne a0, a1, _start_hang
|
2019-11-06 18:54:35 +08:00
|
|
|
li a1, FW_DYNAMIC_INFO_VERSION_MAX
|
|
|
|
REG_L a0, FW_DYNAMIC_INFO_VERSION_OFFSET(a2)
|
2024-03-04 20:15:50 +08:00
|
|
|
bgt a0, a1, _start_hang
|
2019-11-06 18:54:35 +08:00
|
|
|
|
|
|
|
/* Read boot HART id */
|
2021-07-07 16:22:41 +08:00
|
|
|
li a1, FW_DYNAMIC_INFO_VERSION_2
|
2019-11-06 18:54:35 +08:00
|
|
|
blt a0, a1, 2f
|
|
|
|
REG_L a0, FW_DYNAMIC_INFO_BOOT_HART_OFFSET(a2)
|
|
|
|
ret
|
|
|
|
2: li a0, -1
|
|
|
|
ret
|
|
|
|
|
2019-04-29 14:25:19 +08:00
|
|
|
.section .entry, "ax", %progbits
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-04-29 14:25:19 +08:00
|
|
|
.global fw_save_info
|
|
|
|
/*
|
|
|
|
* We can only use a0, a1, a2, a3, and a4 registers here.
|
|
|
|
* The a0, a1, and a2 registers will be same as passed by
|
|
|
|
* previous booting stage.
|
|
|
|
* Nothing to be returned here.
|
|
|
|
*/
|
|
|
|
fw_save_info:
|
2019-11-06 18:54:35 +08:00
|
|
|
/* Save next arg1 in 'a1' */
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a4, _dynamic_next_arg1
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_S a1, (a4)
|
2019-11-06 18:54:35 +08:00
|
|
|
|
|
|
|
/* Save version == 0x1 fields */
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a4, _dynamic_next_addr
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a3, FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET(a2)
|
|
|
|
REG_S a3, (a4)
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a4, _dynamic_next_mode
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a3, FW_DYNAMIC_INFO_NEXT_MODE_OFFSET(a2)
|
|
|
|
REG_S a3, (a4)
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a4, _dynamic_options
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a3, FW_DYNAMIC_INFO_OPTIONS_OFFSET(a2)
|
|
|
|
REG_S a3, (a4)
|
2019-11-06 18:54:35 +08:00
|
|
|
|
|
|
|
/* Save version == 0x2 fields */
|
2021-07-07 16:22:41 +08:00
|
|
|
li a4, FW_DYNAMIC_INFO_VERSION_2
|
2019-11-06 18:54:35 +08:00
|
|
|
REG_L a3, FW_DYNAMIC_INFO_VERSION_OFFSET(a2)
|
|
|
|
blt a3, a4, 2f
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a4, _dynamic_boot_hart
|
2019-11-06 18:54:35 +08:00
|
|
|
REG_L a3, FW_DYNAMIC_INFO_BOOT_HART_OFFSET(a2)
|
|
|
|
REG_S a3, (a4)
|
|
|
|
2:
|
2019-04-29 14:25:19 +08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.section .entry, "ax", %progbits
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-04-29 14:25:19 +08:00
|
|
|
.global fw_next_arg1
|
|
|
|
/*
|
|
|
|
* We can only use a0, a1, and a2 registers here.
|
2019-12-27 11:24:24 +08:00
|
|
|
* The a0, a1, and a2 registers will be same as passed by
|
|
|
|
* previous booting stage.
|
2019-04-29 14:25:19 +08:00
|
|
|
* The next arg1 should be returned in 'a0'.
|
|
|
|
*/
|
|
|
|
fw_next_arg1:
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a0, _dynamic_next_arg1
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a0, (a0)
|
|
|
|
ret
|
|
|
|
|
|
|
|
.section .entry, "ax", %progbits
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-04-29 14:25:19 +08:00
|
|
|
.global fw_next_addr
|
|
|
|
/*
|
|
|
|
* We can only use a0, a1, and a2 registers here.
|
|
|
|
* The next address should be returned in 'a0'.
|
|
|
|
*/
|
|
|
|
fw_next_addr:
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a0, _dynamic_next_addr
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a0, (a0)
|
|
|
|
ret
|
|
|
|
|
|
|
|
.section .entry, "ax", %progbits
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-04-29 14:25:19 +08:00
|
|
|
.global fw_next_mode
|
|
|
|
/*
|
|
|
|
* We can only use a0, a1, and a2 registers here.
|
|
|
|
* The next address should be returned in 'a0'
|
|
|
|
*/
|
|
|
|
fw_next_mode:
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a0, _dynamic_next_mode
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a0, (a0)
|
|
|
|
ret
|
|
|
|
|
|
|
|
.section .entry, "ax", %progbits
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-04-29 14:25:19 +08:00
|
|
|
.global fw_options
|
|
|
|
/*
|
|
|
|
* We can only use a0, a1, and a2 registers here.
|
|
|
|
* The 'a4' register will have default options.
|
|
|
|
* The next address should be returned in 'a0'.
|
|
|
|
*/
|
|
|
|
fw_options:
|
2021-03-17 09:16:37 +08:00
|
|
|
lla a0, _dynamic_options
|
2019-04-29 14:25:19 +08:00
|
|
|
REG_L a0, (a0)
|
|
|
|
ret
|
|
|
|
|
2023-12-05 23:13:44 +08:00
|
|
|
.section .data
|
2020-01-09 19:49:38 +08:00
|
|
|
.align 3
|
2019-04-29 14:25:19 +08:00
|
|
|
_dynamic_next_arg1:
|
|
|
|
RISCV_PTR 0x0
|
|
|
|
_dynamic_next_addr:
|
|
|
|
RISCV_PTR 0x0
|
|
|
|
_dynamic_next_mode:
|
|
|
|
RISCV_PTR PRV_S
|
|
|
|
_dynamic_options:
|
|
|
|
RISCV_PTR 0x0
|
2019-11-06 18:54:35 +08:00
|
|
|
_dynamic_boot_hart:
|
|
|
|
RISCV_PTR -1
|