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-03-22 14:48:33 +02:00
|
|
|
# void start_thread(uint32_t sp, uint32_t ip)
|
2023-02-02 23:24:12 +02:00
|
|
|
.global start_thread
|
|
|
|
start_thread:
|
2024-03-26 19:42:14 +02:00
|
|
|
movl 8(%esp), %edi # ip
|
|
|
|
movl 4(%esp), %esp # sp
|
|
|
|
|
|
|
|
# STACK LAYOUT
|
|
|
|
# NULL
|
|
|
|
# thread ptr
|
|
|
|
# &Thread::on_exit
|
|
|
|
# data
|
|
|
|
|
|
|
|
xorl %ebp, %ebp
|
|
|
|
|
|
|
|
sti
|
|
|
|
call *%edi
|
|
|
|
|
|
|
|
movl 4(%esp), %edi # &Thread::on_exit
|
|
|
|
|
|
|
|
movl 8(%esp), %eax # thread ptr
|
|
|
|
movl %eax, (%esp)
|
|
|
|
|
|
|
|
call *%edi
|
|
|
|
|
2023-02-02 23:24:12 +02:00
|
|
|
|
2024-03-22 14:48:33 +02:00
|
|
|
# void continue_thread(uint32_t sp, uint32_t ip)
|
2023-02-02 23:24:12 +02:00
|
|
|
.global continue_thread
|
|
|
|
continue_thread:
|
2024-03-26 19:42:14 +02:00
|
|
|
movl 8(%esp), %edi # ip
|
|
|
|
movl 4(%esp), %esp # sp
|
|
|
|
xorl %eax, %eax
|
|
|
|
jmp *%edi
|
2023-04-12 17:51:36 +03:00
|
|
|
|
2024-03-26 00:07:24 +02:00
|
|
|
# void thread_userspace_trampoline(uint32_t sp, uint32_t ip, int argc, char** argv, char** envp)
|
|
|
|
.global thread_userspace_trampoline
|
|
|
|
thread_userspace_trampoline:
|
|
|
|
ud2
|