Skip to content

Commit

Permalink
[bl33] add aarch linux boot support
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzukiTsuru committed Jan 6, 2024
1 parent 4ae6b71 commit 9b62a73
Show file tree
Hide file tree
Showing 29 changed files with 222 additions and 178 deletions.
2 changes: 1 addition & 1 deletion board/longanpi-3h/load_bl31/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ int main(void) {

clean_syterkit_data();

jmp_to_arm64(CONFIG_UBOOT_LOAD_ADDR);
jmp_to_arm64(CONFIG_BL31_LOAD_ADDR);

printk(LOG_LEVEL_INFO, "Back to SyterKit\n");

Expand Down
32 changes: 0 additions & 32 deletions utils/bl32/include/linkage.h

This file was deleted.

38 changes: 0 additions & 38 deletions utils/bl32/link.ld

This file was deleted.

61 changes: 0 additions & 61 deletions utils/bl32/source/main.c

This file was deleted.

36 changes: 0 additions & 36 deletions utils/bl32/source/start.S

This file was deleted.

File renamed without changes.
10 changes: 5 additions & 5 deletions utils/bl32/Makefile → utils/bl33/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

CROSS ?= arm-linux-gnueabi-
NAME := syter_bl32
NAME := syter_bl33

#
# System environment variable.
Expand All @@ -19,14 +19,14 @@ endif
#
# Load default variables.
#
ASFLAGS := -g -ggdb -Wall -O0
CFLAGS := -g -ggdb -Wall -O0
CXXFLAGS := -g -ggdb -Wall -O0
ASFLAGS := -g -ggdb -Wall -Os
CFLAGS := -g -ggdb -Wall -Os
CXXFLAGS := -g -ggdb -Wall -Os
LDFLAGS := -T link.ld -nostdlib
ARFLAGS := -rcs
OCFLAGS := -v -O binary
ODFLAGS :=
MCFLAGS := -nostdinc -nostdlib -g -ggdb -mcpu=cortex-a53 -Wno-builtin-declaration-mismatch -Wno-int-to-pointer-cast
MCFLAGS := -nostdinc -nostdlib -g -ggdb -mabi=aapcs-linux -march=armv7-a -Wno-builtin-declaration-mismatch -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast

LIBDIRS :=
LIBS :=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions utils/bl33/include/linkage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* SPDX-License-Identifier: Apache-2.0 */

#ifndef __ARM32_LINKAGE_H__
#define __ARM32_LINKAGE_H__

#ifdef __cplusplus
extern "C" {
#endif

#define ALIGN .align 0
#define ALIGN_STR ".align 0"

#define ENTRY(name) \
.globl name; \
ALIGN; \
name:

#define WEAK(name) \
.weak name; \
name:

#define END(name) .size name, .- name

#define ENDPROC(name) \
.type name, % function; \
END(name)

/*
* CR1 bits (CP#15 CR1)
*/
#define CR_M (1 << 0) /* MMU enable */
#define CR_A (1 << 1) /* Alignment abort enable */
#define CR_C (1 << 2) /* Dcache enable */
#define CR_W (1 << 3) /* Write buffer enable */
#define CR_P (1 << 4) /* 32-bit exception handler */
#define CR_D (1 << 5) /* 32-bit data address range */
#define CR_L (1 << 6) /* Implementation defined */
#define CR_B (1 << 7) /* Big endian */
#define CR_S (1 << 8) /* System MMU protection */
#define CR_R (1 << 9) /* ROM MMU protection */
#define CR_F (1 << 10) /* Implementation defined */
#define CR_Z (1 << 11) /* Implementation defined */
#define CR_I (1 << 12) /* Icache enable */
#define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */
#define CR_RR (1 << 14) /* Round Robin cache replacement */
#define CR_L4 (1 << 15) /* LDR pc can set T bit */
#define CR_DT (1 << 16)
#define CR_IT (1 << 18)
#define CR_ST (1 << 19)
#define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */
#define CR_U (1 << 22) /* Unaligned access operation */
#define CR_XP (1 << 23) /* Extended page tables */
#define CR_VE (1 << 24) /* Vectored interrupts */
#define CR_EE (1 << 25) /* Exception (Big) Endian */
#define CR_TRE (1 << 28) /* TEX remap enable */
#define CR_AFE (1 << 29) /* Access flag enable */
#define CR_TE (1 << 30) /* Thumb exception enable */

/* ARM relocs */
#define R_ARM_NONE 0 /* No reloc */
#define R_ARM_RELATIVE 23 /* Adjust by program base */

#ifdef __cplusplus
}
#endif

#endif /* __ARM32_LINKAGE_H__ */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions utils/bl33/link.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x4a000000;
. = ALIGN(4);
.text :
{
.obj/source/start.o (*.text)
*(.text*)
}

. = ALIGN(4);
.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }

. = ALIGN(4);
.data : {
*(.data*)
}

.interp : { *(.interp*) }
.gnu.hash : { *(.gnu.hash) }
.gnu : { *(.gnu*) }
.ARM.exidx : { *(.ARM.exidx*) }
.gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) }
}
34 changes: 34 additions & 0 deletions utils/bl33/source/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <byteorder.h>
#include <endian.h>
#include <io.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <types.h>

#define CONFIG_DTB_LOAD_ADDR (0x4a200000)
#define CONFIG_KERNEL_LOAD_ADDR (0x40080000)

extern uint32_t __sunxi_smc_call(uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3);

static inline uint32_t sunxi_smc_call_atf(uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3) {
return __sunxi_smc_call(arg0, arg1, arg2, arg3);
}

void print_banner(void) {
printf(" _____ _ _____ __ ___ ___ \n");
printf("| __|_ _| |_ ___ ___| __ | | |_ |_ |\n");
printf("|__ | | | _| -_| _| __ -| |__|_ |_ |\n");
printf("|_____|_ |_| |___|_| |_____|_____|___|___|\n");
printf(" |___| \n");
printf("\n");
printf("Hello Syter BL33!\n");
printf("load kernel 0x%08x to aarch64 mode...\n", CONFIG_KERNEL_LOAD_ADDR);
printf("load dtb 0x%08x...\n\n", CONFIG_DTB_LOAD_ADDR);

printf("Start Kernel...\n\n");

mdelay(10);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.align 0
.globl __sunxi_smc_call ;
#include <linkage.h>

__sunxi_smc_call:
ENTRY(__sunxi_smc_call)
stmfd sp!, {r4-r12, lr} @ save reg state
.arch_extension sec
smc #0
ldmfd sp!, {r4-r12, pc} @ restore saved regs and return
ENDPROC(__sunxi_smc_call)

.type __sunxi_smc_call 2 ;
.size __sunxi_smc_call, .-__sunxi_smc_call
Loading

0 comments on commit 9b62a73

Please sign in to comment.