syscall.h (3863B)
1 /* -*-comment-start: "//";comment-end:""-*- 2 * GNU Mes --- Maxwell Equations of Software 3 * Copyright © 2019,2024 Janneke Nieuwenhuizen <janneke@gnu.org> 4 * 5 * This file is part of GNU Mes. 6 * 7 * GNU Mes is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or (at 10 * your option) any later version. 11 * 12 * GNU Mes is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __MES_GNU_SYSCALL_H 22 #define __MES_GNU_SYSCALL_H 23 24 #define _GNU_SOURCE 1 25 #define __USE_GNU 1 26 27 #include <mach/mach_types.h> 28 #include <mach/port.h> 29 #include <mach/message.h> 30 #include <gnu/hurd.h> 31 #include <gnu/hurd-types.h> 32 33 // mach/mach.defs 34 enum 35 { 36 SYS__task_terminate = 2008, 37 SYS__vm_allocate = 2021, 38 SYS__vm_statistics = 2030, 39 SYS__task_get_special_port = 2058, 40 }; 41 42 // hurd/fsys.defs 43 enum 44 { 45 SYS__dir_lookup = 20018, 46 }; 47 48 // hurd/io.defs 49 enum 50 { 51 SYS__io_write = 21000, 52 SYS__io_read, 53 }; 54 55 // hurd/process.defs 56 enum 57 { 58 SYS__proc_mark_exit = 24025, 59 }; 60 61 // hurd/startup.defs 62 enum 63 { 64 SYS__exec_startup_get_info = 30500, 65 }; 66 67 extern mach_msg_type_t mach_msg_type_int32; 68 extern mach_msg_type_t mach_msg_type_int64; 69 extern mach_msg_type_long_t mach_msg_type_pointer; 70 71 struct mach_msg 72 { 73 mach_msg_header_t header; 74 }; 75 76 struct mach_msg_1 77 { 78 mach_msg_header_t header; 79 mach_msg_type_t type_one; int one; 80 }; 81 82 struct mach_msg_2 83 { 84 mach_msg_header_t header; 85 mach_msg_type_t type_one; int one; 86 mach_msg_type_t type_two; int two; 87 }; 88 89 struct mach_msg_loff_int 90 { 91 mach_msg_header_t header; 92 mach_msg_type_t type_one; loff_t one; 93 mach_msg_type_t type_two; int two; 94 }; 95 96 struct mach_msg_startup_info 97 { 98 mach_msg_header_t header; 99 mach_msg_type_t RetCodeType; 100 kern_return_t RetCode; 101 mach_msg_type_t user_entryType; 102 vm_address_t user_entry; 103 mach_msg_type_t phdrType; 104 vm_address_t phdr; 105 mach_msg_type_t phdr_sizeType; 106 vm_size_t phdr_size; 107 mach_msg_type_t stack_baseType; 108 vm_address_t stack_base; 109 mach_msg_type_t stack_sizeType; 110 vm_size_t stack_size; 111 mach_msg_type_t flagsType; 112 int flags; 113 mach_msg_type_long_t argvType; 114 char *argv; 115 mach_msg_type_long_t envpType; 116 char *envp; 117 mach_msg_type_long_t dtableType; 118 mach_port_t *dtable; 119 mach_msg_type_long_t portarrayType; 120 mach_port_t *portarray; 121 mach_msg_type_long_t intarrayType; 122 int *intarray; 123 }; 124 125 kern_return_t __syscall (mach_port_t port, int sys_call); 126 kern_return_t __syscall2 (mach_port_t port, int sys_call, int one, int two); 127 kern_return_t __syscall_get (mach_port_t port, int sys_call, mach_msg_header_t *message, size_t size); 128 kern_return_t __syscall_put (mach_port_t port, int sys_call, mach_msg_header_t *message, size_t size); 129 130 // mach.defs 131 kern_return_t __task_terminate (mach_port_t task); 132 kern_return_t __task_get_special_port (mach_port_t task, int which, mach_port_t *port); 133 kern_return_t __vm_allocate (mach_port_t task, vm_address_t *address, vm_size_t size, boolean_t anywhere); 134 kern_return_t __vm_statistics (mach_port_t task, vm_statistics_data_t *vm_stats); 135 136 // process.defs 137 kern_return_t __proc_mark_exit (mach_port_t process, int one, int two); 138 kern_return_t __exec_startup_get_data (mach_port_t bootstrap, struct hurd_startup_data *data); 139 140 // io.c 141 kern_return_t __io_read (io_t io, data_t *data, size_t *read, loff_t offset, vm_size_t size); 142 kern_return_t __io_write (io_t io_object, const_data_t data, size_t size, loff_t offset, vm_size_t *wrote); 143 144 #endif // __MES_GNU_SYSCALL_H