mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-24 19:34:01 +00:00
接着上个
This commit is contained in:
38
clks.local.bak/arch/aarch64/linker.ld
Normal file
38
clks.local.bak/arch/aarch64/linker.ld
Normal file
@@ -0,0 +1,38 @@
|
||||
OUTPUT_FORMAT(elf64-littleaarch64)
|
||||
ENTRY(_start)
|
||||
|
||||
PHDRS {
|
||||
text PT_LOAD FLAGS(5);
|
||||
rodata PT_LOAD FLAGS(4);
|
||||
data PT_LOAD FLAGS(7);
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
. = 0x100000;
|
||||
|
||||
.text : {
|
||||
*(.text .text.*)
|
||||
} :text
|
||||
|
||||
.rodata : {
|
||||
KEEP(*(.limine_requests_start))
|
||||
KEEP(*(.limine_requests))
|
||||
KEEP(*(.limine_requests_end))
|
||||
*(.rodata .rodata.*)
|
||||
} :rodata
|
||||
|
||||
.data : {
|
||||
*(.data .data.*)
|
||||
} :data
|
||||
|
||||
.bss : {
|
||||
*(COMMON)
|
||||
*(.bss .bss.*)
|
||||
} :data
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
*(.eh_frame)
|
||||
*(.note .note.*)
|
||||
}
|
||||
}
|
||||
7
clks.local.bak/arch/aarch64/startup/boot.c
Normal file
7
clks.local.bak/arch/aarch64/startup/boot.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <clks/cpu.h>
|
||||
#include <clks/kernel.h>
|
||||
|
||||
void _start(void) {
|
||||
clks_kernel_main();
|
||||
clks_cpu_halt_forever();
|
||||
}
|
||||
119
clks.local.bak/arch/x86_64/interrupt/interrupt_stubs.S
Normal file
119
clks.local.bak/arch/x86_64/interrupt/interrupt_stubs.S
Normal file
@@ -0,0 +1,119 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.global clks_isr_stub_default
|
||||
.extern clks_interrupt_dispatch
|
||||
|
||||
.macro ISR_NOERR num
|
||||
.global clks_isr_stub_\num
|
||||
clks_isr_stub_\num:
|
||||
push 0
|
||||
push \num
|
||||
jmp clks_isr_common
|
||||
.endm
|
||||
|
||||
.macro ISR_ERR num
|
||||
.global clks_isr_stub_\num
|
||||
clks_isr_stub_\num:
|
||||
push \num
|
||||
jmp clks_isr_common
|
||||
.endm
|
||||
|
||||
clks_isr_stub_default:
|
||||
push 0
|
||||
push 255
|
||||
jmp clks_isr_common
|
||||
|
||||
ISR_NOERR 0
|
||||
ISR_NOERR 1
|
||||
ISR_NOERR 2
|
||||
ISR_NOERR 3
|
||||
ISR_NOERR 4
|
||||
ISR_NOERR 5
|
||||
ISR_NOERR 6
|
||||
ISR_NOERR 7
|
||||
ISR_ERR 8
|
||||
ISR_NOERR 9
|
||||
ISR_ERR 10
|
||||
ISR_ERR 11
|
||||
ISR_ERR 12
|
||||
ISR_ERR 13
|
||||
ISR_ERR 14
|
||||
ISR_NOERR 15
|
||||
ISR_NOERR 16
|
||||
ISR_ERR 17
|
||||
ISR_NOERR 18
|
||||
ISR_NOERR 19
|
||||
ISR_NOERR 20
|
||||
ISR_ERR 21
|
||||
ISR_NOERR 22
|
||||
ISR_NOERR 23
|
||||
ISR_NOERR 24
|
||||
ISR_NOERR 25
|
||||
ISR_NOERR 26
|
||||
ISR_NOERR 27
|
||||
ISR_NOERR 28
|
||||
ISR_ERR 29
|
||||
ISR_ERR 30
|
||||
ISR_NOERR 31
|
||||
|
||||
ISR_NOERR 32
|
||||
ISR_NOERR 33
|
||||
ISR_NOERR 34
|
||||
ISR_NOERR 35
|
||||
ISR_NOERR 36
|
||||
ISR_NOERR 37
|
||||
ISR_NOERR 38
|
||||
ISR_NOERR 39
|
||||
ISR_NOERR 40
|
||||
ISR_NOERR 41
|
||||
ISR_NOERR 42
|
||||
ISR_NOERR 43
|
||||
ISR_NOERR 44
|
||||
ISR_NOERR 45
|
||||
ISR_NOERR 46
|
||||
ISR_NOERR 47
|
||||
ISR_NOERR 128
|
||||
|
||||
clks_isr_common:
|
||||
cld
|
||||
|
||||
push r15
|
||||
push r14
|
||||
push r13
|
||||
push r12
|
||||
push r11
|
||||
push r10
|
||||
push r9
|
||||
push r8
|
||||
push rbp
|
||||
push rdi
|
||||
push rsi
|
||||
push rdx
|
||||
push rcx
|
||||
push rbx
|
||||
push rax
|
||||
|
||||
mov rdi, rsp
|
||||
sub rsp, 8
|
||||
call clks_interrupt_dispatch
|
||||
add rsp, 8
|
||||
|
||||
pop rax
|
||||
pop rbx
|
||||
pop rcx
|
||||
pop rdx
|
||||
pop rsi
|
||||
pop rdi
|
||||
pop rbp
|
||||
pop r8
|
||||
pop r9
|
||||
pop r10
|
||||
pop r11
|
||||
pop r12
|
||||
pop r13
|
||||
pop r14
|
||||
pop r15
|
||||
|
||||
add rsp, 16
|
||||
iretq
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
42
clks.local.bak/arch/x86_64/linker.ld
Normal file
42
clks.local.bak/arch/x86_64/linker.ld
Normal file
@@ -0,0 +1,42 @@
|
||||
OUTPUT_FORMAT(elf64-x86-64)
|
||||
ENTRY(_start)
|
||||
|
||||
PHDRS {
|
||||
text PT_LOAD FLAGS(5);
|
||||
rodata PT_LOAD FLAGS(4);
|
||||
data PT_LOAD FLAGS(7);
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
. = 0xffffffff80000000;
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
.text : ALIGN(0x1000) {
|
||||
*(.text .text.*)
|
||||
} :text
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
.rodata : ALIGN(0x1000) {
|
||||
KEEP(*(.limine_requests_start))
|
||||
KEEP(*(.limine_requests))
|
||||
KEEP(*(.limine_requests_end))
|
||||
*(.rodata .rodata.*)
|
||||
} :rodata
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
.data : ALIGN(0x1000) {
|
||||
*(.data .data.*)
|
||||
} :data
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
.bss : ALIGN(0x1000) {
|
||||
*(COMMON)
|
||||
*(.bss .bss.*)
|
||||
} :data
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
*(.eh_frame)
|
||||
*(.note .note.*)
|
||||
}
|
||||
}
|
||||
7
clks.local.bak/arch/x86_64/startup/boot.c
Normal file
7
clks.local.bak/arch/x86_64/startup/boot.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <clks/cpu.h>
|
||||
#include <clks/kernel.h>
|
||||
|
||||
void _start(void) {
|
||||
clks_kernel_main();
|
||||
clks_cpu_halt_forever();
|
||||
}
|
||||
47
clks.local.bak/arch/x86_64/startup/exec_stack_call.S
Normal file
47
clks.local.bak/arch/x86_64/startup/exec_stack_call.S
Normal file
@@ -0,0 +1,47 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.global clks_exec_call_on_stack_x86_64
|
||||
.type clks_exec_call_on_stack_x86_64, @function
|
||||
.global clks_exec_abort_to_caller_x86_64
|
||||
.type clks_exec_abort_to_caller_x86_64, @function
|
||||
|
||||
clks_exec_call_on_stack_x86_64:
|
||||
mov r11, rsp
|
||||
mov rsp, rsi
|
||||
and rsp, -16
|
||||
sub rsp, 56
|
||||
mov [rsp], r11
|
||||
mov [rsp + 8], rbx
|
||||
mov [rsp + 16], rbp
|
||||
mov [rsp + 24], r12
|
||||
mov [rsp + 32], r13
|
||||
mov [rsp + 40], r14
|
||||
mov [rsp + 48], r15
|
||||
|
||||
call rdi
|
||||
|
||||
mov rbx, [rsp + 8]
|
||||
mov rbp, [rsp + 16]
|
||||
mov r12, [rsp + 24]
|
||||
mov r13, [rsp + 32]
|
||||
mov r14, [rsp + 40]
|
||||
mov r15, [rsp + 48]
|
||||
mov rsp, [rsp]
|
||||
ret
|
||||
|
||||
.size clks_exec_call_on_stack_x86_64, .-clks_exec_call_on_stack_x86_64
|
||||
|
||||
clks_exec_abort_to_caller_x86_64:
|
||||
mov rax, rsi
|
||||
mov rsp, rdi
|
||||
mov rbx, [rsp + 8]
|
||||
mov rbp, [rsp + 16]
|
||||
mov r12, [rsp + 24]
|
||||
mov r13, [rsp + 32]
|
||||
mov r14, [rsp + 40]
|
||||
mov r15, [rsp + 48]
|
||||
mov rsp, [rsp]
|
||||
ret
|
||||
|
||||
.size clks_exec_abort_to_caller_x86_64, .-clks_exec_abort_to_caller_x86_64
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
Reference in New Issue
Block a user