diff options
| author | Colin Davidson <colrdavidson@gmail.com> | 2024-08-28 23:50:17 -0700 |
|---|---|---|
| committer | Colin Davidson <colrdavidson@gmail.com> | 2024-08-28 23:50:17 -0700 |
| commit | 3209b319e85fa943f904d3af8e37c14ba58b6080 (patch) | |
| tree | 91bdf32fccb48e7b6543e03a7ac2f26bd5de4661 /core/sys/darwin | |
| parent | b396280df76b34bc2d741ded6a72e89d32c70565 (diff) | |
more useful pieces
Diffstat (limited to 'core/sys/darwin')
| -rw-r--r-- | core/sys/darwin/mach_darwin.odin | 80 |
1 files changed, 74 insertions, 6 deletions
diff --git a/core/sys/darwin/mach_darwin.odin b/core/sys/darwin/mach_darwin.odin index 33f37637d..1482a93d0 100644 --- a/core/sys/darwin/mach_darwin.odin +++ b/core/sys/darwin/mach_darwin.odin @@ -13,8 +13,10 @@ task_t :: mach_port_t semaphore_t :: distinct u64 -kern_return_t :: distinct u64 -thread_act_t :: distinct u64 +kern_return_t :: distinct u64 +thread_act_t :: distinct u64 +thread_state_t :: distinct ^u32 +thread_list_t :: [^]thread_act_t MACH_MSG_PORT_DESCRIPTOR :: 0 @@ -30,15 +32,30 @@ MACH_MSGH_BITS_COMPLEX :: 0x80000000 MACH_PORT_RIGHT_SEND :: 0 MACH_PORT_RIGHT_RECEIVE :: 1 +VM_PROT_NONE :: 0 +VM_PROT_READ :: 1 +VM_PROT_WRITE :: 2 +VM_PROT_EXECUTE :: 4 + +VM_INHERIT_SHARE :: 0 +VM_INHERIT_COPY :: 1 +VM_INHERIT_NONE :: 2 +VM_INHERIT_DONATE_COPY :: 3 + TASK_BOOTSTRAP_PORT :: 4 +X86_THREAD_STATE32 :: 1 +X86_THREAD_STATE64 :: 4 +X86_THREAD_STATE32_COUNT :: size_of(x86_thread_state32_t) / size_of(u32) +X86_THREAD_STATE64_COUNT :: size_of(x86_thread_state64_t) / size_of(u32) + mach_msg_option_t :: distinct i32 name_t :: distinct cstring mach_msg_port_descriptor_t :: struct { name: mach_port_t, _: u32, - extra: bit_field u32 { + using _: bit_field u32 { _: u32 | 16, disposition: u32 | 8, type: u32 | 8, @@ -63,17 +80,68 @@ mach_msg_trailer_t :: struct { msgh_trailer_size: u32, } +x86_thread_state32_t :: struct { + eax: u32, + ebx: u32, + ecx: u32, + edx: u32, + edi: u32, + esi: u32, + ebp: u32, + esp: u32, + ss: u32, + eflags: u32, + eip: u32, + cs: u32, + ds: u32, + es: u32, + fs: u32, + gs: u32, +} + +x86_thread_state64_t :: struct { + rax: u64, + rbx: u64, + rcx: u64, + rdx: u64, + rdi: u64, + rsi: u64, + rbp: u64, + rsp: u64, + r8: u64, + r9: u64, + r10: u64, + r11: u64, + r12: u64, + r13: u64, + r14: u64, + r15: u64, + rip: u64, + rflags: u64, + cs: u64, + fs: u64, + gs: u64, +} + @(default_calling_convention="c") foreign mach { - mach_task_self :: proc() -> task_t --- - mach_msg :: proc(header: rawptr, option: mach_msg_option_t, send_size: u32, receive_limit: u32, receive_name: mach_port_t, timeout: u32, notify: mach_port_t) -> kern_return_t --- - mach_msg_send :: proc(header: rawptr) -> kern_return_t --- + mach_task_self :: proc() -> task_t --- + mach_msg :: proc(header: rawptr, option: mach_msg_option_t, send_size: u32, receive_limit: u32, receive_name: mach_port_t, timeout: u32, notify: mach_port_t) -> kern_return_t --- + mach_msg_send :: proc(header: rawptr) -> kern_return_t --- + mach_vm_allocate :: proc(target_task: task_t, adddress: u64, size: u64, flags: i32) -> kern_return_t --- + mach_vm_deallocate :: proc(target_task: task_t, adddress: ^u64, size: u64) -> kern_return_t --- + mach_vm_remap :: proc(target_task: task_t, page: rawptr, size: u64, mask: u64, flags: i32, src_task: task_t, src_address: u64, copy: b32, cur_protection: ^i32, max_protection: ^i32, inheritance: i32) -> kern_return_t --- mach_port_allocate :: proc(task: task_t, right: u32, name: rawptr) -> kern_return_t --- mach_port_deallocate :: proc(task: task_t, name: u32) -> kern_return_t --- mach_port_extract_right :: proc(task: task_t, name: u32, msgt_name: u32, poly: ^mach_port_t, poly_poly: ^mach_port_t) -> kern_return_t --- task_get_special_port :: proc(task: task_t, port: i32, special_port: ^mach_port_t) -> kern_return_t --- + task_suspend :: proc(task: task_t) -> kern_return_t --- + task_resume :: proc(task: task_t) -> kern_return_t --- + task_threads :: proc(task: task_t, thread_list: ^thread_list_t, list_count: ^u32) -> kern_return_t --- + thread_get_state :: proc(thread: thread_act_t, flavor: i32, thread_state: thread_state_t, old_state_count: ^u32) -> kern_return_t --- + bootstrap_register2 :: proc(bp: mach_port_t, service_name: name_t, sp: mach_port_t, flags: u64) -> kern_return_t --- bootstrap_look_up :: proc(bp: mach_port_t, service_name: name_t, sp: ^mach_port_t) -> kern_return_t --- |