commit f56312c5ed0e7d6fcc1b7c9a8f7e0e8d34376815 from: Aleksey Ryndin date: Tue Feb 14 14:44:39 2023 UTC Add boot code commit - fb7f0bd881cf45679dafb16895d4efc3a6c4b5f3 commit + f56312c5ed0e7d6fcc1b7c9a8f7e0e8d34376815 blob - e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 blob + 4ddf4f2b5d040e0c877f3ab43fc1db2de20e61e8 --- Makefile +++ Makefile @@ -0,0 +1,19 @@ +ARCH = aarch64 +TARGET = ${ARCH}-none-elf + +CC = clang +ASFLAGS = -target ${TARGET} +ASRC = boot.S + +OBJS = ${ASRC:.S=.o} + +.PHONY: clean + +all: boot.o + +clean: + rm -rf *.o + +.SUFFIXES: .S.o +.S.o: + ${CC} ${ASFLAGS} -c $< -o $@ blob - /dev/null blob + ce243fcb062a6ae12e8af2c6ef87c94b360c5f60 (mode 644) --- /dev/null +++ boot.S @@ -0,0 +1,27 @@ +.section ".text.boot" + +.global _start +_start: + mrs x0, mpidr_el1 + and x0, x0, #0xffffff + cbz x0, _first_processor + + // hang all non primary CPU +_idle: + wfe + b _idle + +_first_processor: + // zero out BSS section + adr x0, bss_begin + adr x1, bss_end +_zero_bss: + str xzr, [x0], #8 + cmp x0, x1 + b.lt _zero_bss + + # set stack before boot code and call kernel + adr x0, _start + mov sp, x0 + bl kernel_entry_point + b _idle