On 1/27/21 7:54 AM, Jiaxun Yang wrote:
> Add a bootloader helper to generate simple bootloaders for kernel.
> It can help us reduce inline hex hack and also keep MIPS release 6
> compatibility easier.
>
> Signed-off-by: Jiaxun Yang <[email protected]>
> ---
> include/hw/mips/bootloader.h | 49 +++++++++++
> hw/mips/bootloader.c | 164 +++++++++++++++++++++++++++++++++++
> hw/mips/meson.build | 2 +-
> 3 files changed, 214 insertions(+), 1 deletion(-)
> create mode 100644 include/hw/mips/bootloader.h
> create mode 100644 hw/mips/bootloader.c
>
> diff --git a/include/hw/mips/bootloader.h b/include/hw/mips/bootloader.h
> new file mode 100644
> index 0000000000..2a0e1a11c9
> --- /dev/null
> +++ b/include/hw/mips/bootloader.h
> @@ -0,0 +1,49 @@
> +#ifndef HW_MIPS_BOOTLOADER_H
> +#define HW_MIPS_BOOTLOADER_H
> +
> +#include "exec/cpu-defs.h"
> +
> +void bl_gen_jump_to(uint32_t **p, target_ulong jump_addr);
> +void bl_gen_jump_kernel(uint32_t **p, target_ulong sp, target_ulong a0,
> + target_ulong a1, target_ulong a2, target_ulong a3,
> + target_ulong kernel_addr);
> +void bl_gen_write_ulong(uint32_t **p, target_ulong val, target_ulong addr);
> +void bl_gen_write_u32(uint32_t **p, uint32_t val, target_ulong addr);
> +void bl_gen_write_u64(uint32_t **p, uint64_t val, target_ulong addr);
Again, if you don't mind, I inverted bl_gen_write() arguments:
void bl_gen_write_TYPE(uint32_t **p, target_ulong addr, TYPE val);
> +typedef enum bl_reg {
> + BL_REG_ZERO = 0,
> + BL_REG_AT = 1,
> + BL_REG_V0 = 2,
> + BL_REG_V1 = 3,
> + BL_REG_A0 = 4,
And moved the enum declaration to the source file.