mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Make aarch64 compilable
This commit is contained in:
parent
74dab6c44e
commit
b265b4aced
36
Architecture/aarch64/Bootstrap/boot.S
Normal file
36
Architecture/aarch64/Bootstrap/boot.S
Normal file
@ -0,0 +1,36 @@
|
||||
/* Based on this tutorial:
|
||||
https://github.com/s-matyukevich/raspberry-pi-os */
|
||||
|
||||
.section ".text.boot"
|
||||
|
||||
.extern _bss_start
|
||||
.extern _bss_end
|
||||
|
||||
.extern arm64Entry
|
||||
memzero:
|
||||
str xzr, [x0], #8
|
||||
subs x1, x1, #8
|
||||
b.gt memzero
|
||||
ret
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
mrs x0, mpidr_el1
|
||||
and x0, x0, #0xFF
|
||||
cbz x0, _start2
|
||||
b CPU_Loop
|
||||
|
||||
_start2:
|
||||
adr x0, _bss_start
|
||||
adr x1, _bss_end
|
||||
sub x1, x1, x0
|
||||
bl memzero
|
||||
mov sp, #0x200000
|
||||
bl arm64Entry
|
||||
|
||||
Halt:
|
||||
wfe
|
||||
b Halt
|
||||
|
||||
CPU_Loop:
|
||||
b CPU_Loop
|
@ -50,6 +50,8 @@ CPUData *GetCurrentCPU()
|
||||
|
||||
namespace SMP
|
||||
{
|
||||
int CPUCores = 0;
|
||||
|
||||
void Initialize(void *madt)
|
||||
{
|
||||
fixme("SMP::Initialize() is not implemented!");
|
||||
|
@ -19,7 +19,15 @@ ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x80000;
|
||||
.text.boot :
|
||||
{
|
||||
*(.text.boot)
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
_bss_start = .;
|
||||
*(.text.bss)
|
||||
_bss_end = .;
|
||||
}
|
||||
|
||||
_kernel_start = .;
|
||||
.text :
|
||||
{
|
||||
@ -43,6 +51,22 @@ SECTIONS
|
||||
. = ALIGN(4096);
|
||||
_kernel_rodata_end = .;
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN(__init_array_start = .);
|
||||
KEEP(*(.init_array .ctors))
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
}
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP(*(.fini_array .dtors))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
}
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.bss .bss.*)
|
||||
|
@ -1,17 +1,17 @@
|
||||
.section ".text.boot"
|
||||
// .section ".text.boot"
|
||||
|
||||
.global _start
|
||||
.org 0x80000
|
||||
_start:
|
||||
ldr x5, =_start
|
||||
mov sp, x5
|
||||
ldr x5, =_kernel_rodata_end
|
||||
ldr w6, =_bss_size
|
||||
1: cbz w6, 2f
|
||||
str xzr, [x5], #8
|
||||
sub w6, w6, #1
|
||||
cbnz w6, 1b
|
||||
2: bl arm64Entry
|
||||
Halt:
|
||||
wfe
|
||||
b Halt
|
||||
// .global _start
|
||||
// .org 0x80000
|
||||
// _start:
|
||||
// ldr x5, =_start
|
||||
// mov sp, x5
|
||||
// ldr x5, =_kernel_rodata_end
|
||||
// ldr w6, =_bss_size
|
||||
// 1: cbz w6, 2f
|
||||
// str xzr, [x5], #8
|
||||
// sub w6, w6, #1
|
||||
// cbnz w6, 1b
|
||||
// 2: bl arm64Entry
|
||||
// Halt:
|
||||
// wfe
|
||||
// b Halt
|
||||
|
@ -1,13 +1,13 @@
|
||||
.section .init
|
||||
.global _init
|
||||
.type _init, @function
|
||||
_init:
|
||||
// .section .init
|
||||
// .global _init
|
||||
// .type _init, @function
|
||||
// _init:
|
||||
// push %rbp
|
||||
// movq %rsp, %rbp
|
||||
|
||||
.section .fini
|
||||
.global _fini
|
||||
.type _fini, @function
|
||||
_fini:
|
||||
// .section .fini
|
||||
// .global _fini
|
||||
// .type _fini, @function
|
||||
// _fini:
|
||||
// push %rbp
|
||||
// movq %rsp, %rbp
|
||||
|
20
Makefile
20
Makefile
@ -66,8 +66,8 @@ SIMD_FLAGS := -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -mavx51
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fno-pic -fno-pie \
|
||||
-mno-red-zone -march=core2 -pipe \
|
||||
CFLAGS += -fno-pic -fno-pie \
|
||||
-mno-red-zone -march=core2 -pipe \
|
||||
-mcmodel=kernel -fno-builtin -Da64
|
||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
||||
LDFLAGS += -TArchitecture/amd64/linker.ld \
|
||||
@ -92,9 +92,13 @@ LDFLAGS += -TArchitecture/i386/linker.ld \
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC -Wstack-protector -Daa64
|
||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all -fstack-clash-protection
|
||||
LDFLAGS += -TArchitecture/aarch64/linker.ld -fPIC
|
||||
CFLAGS += -pipe -fno-builtin -Wstack-protector -Daa64 -fPIC -mno-outline-atomics
|
||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
||||
LDFLAGS += -TArchitecture/aarch64/linker.ld -fPIC -pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map kernel.map -static
|
||||
|
||||
endif
|
||||
|
||||
@ -166,13 +170,7 @@ endif
|
||||
|
||||
%.o: %.S
|
||||
$(info Compiling $<)
|
||||
ifeq ($(OSARCH), amd64)
|
||||
$(AS) -c $< -o $@
|
||||
else ifeq ($(OSARCH), i386)
|
||||
$(AS) -c $< -o $@
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
$(AS) -c $< -o $@
|
||||
endif
|
||||
|
||||
%.o: %.psf
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user