56 lines
1.2 KiB
NASM
56 lines
1.2 KiB
NASM
; Calcite, src/kernel/process.asm
|
|
; Copyright 2025 Benji Dial
|
|
;
|
|
; This program is free software: you can redistribute it and/or modify
|
|
; it under the terms of the GNU General Public License as published by
|
|
; the Free Software Foundation, either version 3 of the License, or
|
|
; (at your option) any later version.
|
|
;
|
|
; This program is distributed in the hope that it will be useful, but
|
|
; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
; for more details.
|
|
;
|
|
; You should have received a copy of the GNU General Public License along
|
|
; with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
bits 64
|
|
|
|
extern running_thread
|
|
|
|
section .text
|
|
|
|
;referenced in process.c
|
|
global thread_start
|
|
thread_start:
|
|
|
|
mov rax, qword [running_thread]
|
|
test rax, rax
|
|
jnz .assert_fail
|
|
|
|
mov qword [running_thread], rbx
|
|
|
|
mov cr3, rbp
|
|
mov rcx, r12
|
|
mov r11, 0x200
|
|
|
|
xor rax, rax
|
|
xor rbx, rbx
|
|
xor rdx, rdx
|
|
xor rdi, rdi
|
|
xor rsi, rsi
|
|
xor rbp, rbp
|
|
xor r8, r8
|
|
xor r9, r9
|
|
xor r10, r10
|
|
xor r12, r12
|
|
xor r13, r13
|
|
xor r14, r14
|
|
xor r15, r15
|
|
|
|
o64 sysret
|
|
|
|
.assert_fail:
|
|
;could be nice to handle this more gracefully in the future
|
|
ud2
|