2024-03-22 14:48:33 +02:00
|
|
|
# uint32_t read_ip()
|
|
|
|
.global read_ip
|
|
|
|
read_ip:
|
2023-02-02 23:24:12 +02:00
|
|
|
popl %eax
|
|
|
|
jmp *%eax
|
|
|
|
|
2024-04-02 12:34:42 +03:00
|
|
|
# void start_kernel_thread()
|
|
|
|
.global start_kernel_thread
|
|
|
|
start_kernel_thread:
|
2024-04-03 02:23:23 +03:00
|
|
|
call get_thread_start_sp
|
2024-04-02 12:34:42 +03:00
|
|
|
movl %eax, %esp
|
2024-03-26 19:42:14 +02:00
|
|
|
|
|
|
|
# STACK LAYOUT
|
2024-04-02 12:34:42 +03:00
|
|
|
# on_exit arg
|
|
|
|
# on_exit func
|
|
|
|
# entry arg
|
|
|
|
# entry func
|
2024-03-26 19:42:14 +02:00
|
|
|
|
2024-04-02 12:34:42 +03:00
|
|
|
movl 4(%esp), %edi
|
|
|
|
movl 0(%esp), %esi
|
2024-03-26 19:42:14 +02:00
|
|
|
|
2024-04-02 12:34:42 +03:00
|
|
|
subl $12, %esp
|
|
|
|
pushl %edi
|
2024-03-26 19:42:14 +02:00
|
|
|
sti
|
2024-04-02 12:34:42 +03:00
|
|
|
call *%esi
|
|
|
|
addl $16, %esp
|
2024-03-26 19:42:14 +02:00
|
|
|
|
2024-04-02 12:34:42 +03:00
|
|
|
movl 12(%esp), %edi
|
|
|
|
movl 8(%esp), %esi
|
2024-03-26 19:42:14 +02:00
|
|
|
|
2024-04-02 12:34:42 +03:00
|
|
|
subl $12, %esp
|
|
|
|
pushl %edi
|
|
|
|
call *%esi
|
|
|
|
addl $16, %esp
|
2024-04-03 02:23:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
.global start_userspace_thread
|
|
|
|
start_userspace_thread:
|
|
|
|
call get_thread_start_sp
|
|
|
|
movl %eax, %esp
|
|
|
|
|
|
|
|
# STACK LAYOUT
|
|
|
|
# entry
|
|
|
|
# argc
|
|
|
|
# argv
|
|
|
|
# envp
|
|
|
|
# userspace stack
|
|
|
|
|
|
|
|
call get_userspace_thread_stack_top
|
|
|
|
|
|
|
|
movw $(0x20 | 3), %bx
|
|
|
|
movw %bx, %ds
|
|
|
|
movw %bx, %es
|
|
|
|
movw %bx, %fs
|
|
|
|
movw %bx, %gs
|
|
|
|
xorw %bx, %bx
|
|
|
|
|
|
|
|
popl %edx
|
|
|
|
popl %esi
|
|
|
|
popl %edi
|
|
|
|
popl %ecx
|
|
|
|
|
|
|
|
pushl $(0x20 | 3)
|
|
|
|
pushl %eax
|
|
|
|
pushl $0x202
|
|
|
|
pushl $(0x18 | 3)
|
|
|
|
pushl %ecx
|
|
|
|
iret
|