This will remove more warnings for -Wmissing-prototypes. --- Makefrag.am | 2 + kern/gnumach.h | 62 +++++++++++ kern/ipc_tt.c | 1 + kern/mach.h | 223 +++++++++++++++++++++++++++++++++++++++ kern/mach_host.h | 9 ++ kern/slab.c | 1 + kern/syscall_emulation.c | 1 + kern/task.c | 2 + kern/thread.c | 2 +- kern/thread_swap.c | 2 +- vm/memory_object.c | 3 +- vm/vm_map.c | 1 + vm/vm_object.c | 1 + vm/vm_user.c | 4 +- 14 files changed, 310 insertions(+), 4 deletions(-) create mode 100644 kern/gnumach.h create mode 100644 kern/mach.h
diff --git a/Makefrag.am b/Makefrag.am index cb5651a2..e09defaa 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -159,6 +159,7 @@ libkernel_a_SOURCES += \ kern/ipc_sched.h \ kern/ipc_tt.c \ kern/ipc_tt.h \ + kern/gnumach.h \ kern/kalloc.h \ kern/kern_types.h \ kern/kmutex.c \ @@ -168,6 +169,7 @@ libkernel_a_SOURCES += \ kern/lock.h \ kern/lock_mon.c \ kern/log2.h \ + kern/mach.h \ kern/mach_clock.c \ kern/mach_clock.h \ kern/mach_debug.h \ diff --git a/kern/gnumach.h b/kern/gnumach.h new file mode 100644 index 00000000..f7ae7c3a --- /dev/null +++ b/kern/gnumach.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * This file is part of GNU Mach. + * + * GNU Mach 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 2, 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KERN_GNUMACH_H +#define _KERN_GNUMACH_H + +#include <mach/mach_types.h> +#include <kern/host.h> + +/* RPCs */ + +kern_return_t +register_new_task_notification( + const host_t host, + ipc_port_t notification); + +kern_return_t vm_wire_all(const ipc_port_t port, vm_map_t map, vm_wire_t flags); + +kern_return_t vm_object_sync( + vm_object_t object, + vm_offset_t offset, + vm_size_t size, + boolean_t should_flush, + boolean_t should_return, + boolean_t should_iosync); + +kern_return_t vm_msync( + vm_map_t map, + vm_address_t address, + vm_size_t size, + vm_sync_t sync_flags); + +kern_return_t vm_allocate_contiguous( + host_t host_priv, + vm_map_t map, + vm_address_t *result_vaddr, + rpc_phys_addr_t *result_paddr, + vm_size_t size, + rpc_phys_addr_t pmin, + rpc_phys_addr_t pmax, + rpc_phys_addr_t palign); + +/* End of RPCs */ + +#endif /* _KERN_GNUMACH_H */ diff --git a/kern/ipc_tt.c b/kern/ipc_tt.c index 63f6e77a..025f9be0 100644 --- a/kern/ipc_tt.c +++ b/kern/ipc_tt.c @@ -42,6 +42,7 @@ #include <kern/thread.h> #include <kern/ipc_kobject.h> #include <kern/ipc_tt.h> +#include <kern/mach.h> #include <ipc/ipc_space.h> #include <ipc/ipc_table.h> #include <ipc/ipc_port.h> diff --git a/kern/mach.h b/kern/mach.h new file mode 100644 index 00000000..17345926 --- /dev/null +++ b/kern/mach.h @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * This file is part of GNU Mach. + * + * GNU Mach 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 2, 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KERN_MACH_H +#define _KERN_MACH_H + +#include <mach/mach_types.h> + +/* RPCs */ + +kern_return_t vm_cache_statistics( + vm_map_t map, + vm_cache_statistics_data_t *stats); + +kern_return_t vm_allocate( + vm_map_t map, + vm_offset_t *addr, + vm_size_t size, + boolean_t anywhere); + +kern_return_t vm_copy( + vm_map_t map, + vm_address_t source_address, + vm_size_t size, + vm_address_t dest_address); + +kern_return_t vm_deallocate( + vm_map_t map, + vm_offset_t start, + vm_size_t size); + +kern_return_t vm_inherit( + vm_map_t map, + vm_offset_t start, + vm_size_t size, + vm_inherit_t new_inheritance); + +kern_return_t vm_machine_attribute( + vm_map_t map, + vm_address_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t* value); /* IN/OUT */ + +kern_return_t vm_map( + vm_map_t target_map, + vm_offset_t *address, + vm_size_t size, + vm_offset_t mask, + boolean_t anywhere, + ipc_port_t memory_object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance); + +kern_return_t vm_protect( + vm_map_t map, + vm_offset_t start, + vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection); + +kern_return_t vm_read( + vm_map_t map, + vm_address_t address, + vm_size_t size, + pointer_t *data, + mach_msg_type_number_t *data_size); + +kern_return_t vm_region( + vm_map_t map, + vm_offset_t *address, /* IN/OUT */ + vm_size_t *size, /* OUT */ + vm_prot_t *protection, /* OUT */ + vm_prot_t *max_protection, /* OUT */ + vm_inherit_t *inheritance, /* OUT */ + boolean_t *is_shared, /* OUT */ + ipc_port_t *object_name, /* OUT */ + vm_offset_t *offset_in_object); /* OUT */ + +kern_return_t vm_write( + vm_map_t map, + vm_address_t address, + pointer_t data, + mach_msg_type_number_t size); + +kern_return_t +mach_ports_register( + task_t task, + mach_port_array_t memory, + mach_msg_type_number_t portsCnt); + +kern_return_t +mach_ports_lookup( + task_t task, + ipc_port_t **portsp, + mach_msg_type_number_t *portsCnt); + +kern_return_t task_set_emulation( + task_t task, + vm_offset_t routine_entry_pt, + int routine_number); + +kern_return_t +task_get_emulation_vector( + task_t task, + int *vector_start, /* out */ + emulation_vector_t *emulation_vector, /* out */ + unsigned int *emulation_vector_count); /* out */ + +kern_return_t +task_set_emulation_vector( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + unsigned int emulation_vector_count); + +kern_return_t task_get_assignment( + task_t task, + processor_set_t *pset); + +kern_return_t +task_set_essential( + task_t task, + boolean_t essential); + +kern_return_t +task_ras_control( + task_t task, + vm_offset_t pc, + vm_offset_t endpc, + int flavor); + +kern_return_t +task_priority( + task_t task, + int priority, + boolean_t change_threads); + +kern_return_t memory_object_data_supply( + vm_object_t object, + vm_offset_t offset, + vm_map_copy_t data_copy, + unsigned int data_cnt, + vm_prot_t lock_value, + boolean_t precious, + ipc_port_t reply_to, + mach_msg_type_name_t reply_to_type); + +kern_return_t memory_object_data_error( + vm_object_t object, + vm_offset_t offset, + vm_size_t size, + kern_return_t error_value); + +kern_return_t memory_object_data_unavailable( + vm_object_t object, + vm_offset_t offset, + vm_size_t size); + +kern_return_t +memory_object_lock_request( + vm_object_t object, + vm_offset_t offset, + vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t prot, + ipc_port_t reply_to, + mach_msg_type_name_t reply_to_type); + +kern_return_t memory_object_change_attributes( + vm_object_t object, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + ipc_port_t reply_to, + mach_msg_type_name_t reply_to_type); + +kern_return_t memory_object_get_attributes( + vm_object_t object, + boolean_t *object_ready, + boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy); + +kern_return_t memory_object_ready( + vm_object_t object, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy); + +kern_return_t memory_object_destroy( + vm_object_t object, + kern_return_t reason); + +kern_return_t vm_set_default_memory_manager( + const host_t host, + ipc_port_t *default_manager); + +kern_return_t vm_statistics( + vm_map_t map, + vm_statistics_data_t *stat); + +/* End of RPCs */ + +#endif /* _KERN_MACH_H */ diff --git a/kern/mach_host.h b/kern/mach_host.h index de644494..d314bf5d 100644 --- a/kern/mach_host.h +++ b/kern/mach_host.h @@ -21,9 +21,12 @@ #ifndef _KERN_MACH_HOST_H #define _KERN_MACH_HOST_H +#include <ipc/ipc_types.h> #include <kern/processor.h> #include <kern/host.h> #include <mach/host_info.h> +#include <mach/vm_prot.h> +#include <vm/vm_types.h> /* RPCs */ @@ -81,6 +84,12 @@ kern_return_t thread_get_assignment( thread_t thread, processor_set_t *pset); +kern_return_t vm_wire(const ipc_port_t port, + vm_map_t map, + vm_offset_t start, + vm_size_t size, + vm_prot_t access); + /* End of RPCs */ #endif /* _KERN_MACH_HOST_H */ diff --git a/kern/slab.c b/kern/slab.c index d44da165..d14bc080 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -79,6 +79,7 @@ #include <kern/slab.h> #include <kern/kalloc.h> #include <kern/cpu_number.h> +#include <kern/mach_debug.h> #include <mach/vm_param.h> #include <mach/machine/vm_types.h> #include <vm/vm_kern.h> diff --git a/kern/syscall_emulation.c b/kern/syscall_emulation.c index 5a477006..baad246d 100644 --- a/kern/syscall_emulation.c +++ b/kern/syscall_emulation.c @@ -31,6 +31,7 @@ #include <kern/syscall_emulation.h> #include <kern/task.h> #include <kern/kalloc.h> +#include <kern/mach.h> #include <vm/vm_kern.h> /* XXX */ diff --git a/kern/task.c b/kern/task.c index d5bd14c2..beb0252b 100644 --- a/kern/task.c +++ b/kern/task.c @@ -44,7 +44,9 @@ #include <kern/task.h> #include <kern/thread.h> #include <kern/slab.h> +#include <kern/gnumach.h> #include <kern/kalloc.h> +#include <kern/mach.h> #include <kern/processor.h> #include <kern/printf.h> #include <kern/sched_prim.h> /* for thread_wakeup */ diff --git a/kern/thread.c b/kern/thread.c index 06825bff..db290f7e 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2403,7 +2403,7 @@ void stack_finalize( * *maxusagep must be initialized by the caller. */ -void stack_statistics( +static void stack_statistics( natural_t *totalp, vm_size_t *maxusagep) { diff --git a/kern/thread_swap.c b/kern/thread_swap.c index 20ad0409..ecfe48e4 100644 --- a/kern/thread_swap.c +++ b/kern/thread_swap.c @@ -156,7 +156,7 @@ kern_return_t thread_doswapin(thread_t thread) * This procedure executes as a kernel thread. Threads that need to * be swapped in are swapped in by this thread. */ -void __attribute__((noreturn)) swapin_thread_continue(void) +static void __attribute__((noreturn)) swapin_thread_continue(void) { for (;;) { thread_t thread; diff --git a/vm/memory_object.c b/vm/memory_object.c index 464a036e..7778a9f3 100644 --- a/vm/memory_object.c +++ b/vm/memory_object.c @@ -61,6 +61,7 @@ #include <kern/debug.h> /* For panic() */ #include <kern/thread.h> /* For current_thread() */ #include <kern/host.h> +#include <kern/mach.h> /* For rpc prototypes */ #include <vm/vm_kern.h> /* For kernel_map, vm_move */ #include <vm/vm_map.h> /* For vm_map_pageable */ #include <ipc/ipc_port.h> @@ -425,7 +426,7 @@ kern_return_t memory_object_data_unavailable( #define MEMORY_OBJECT_LOCK_RESULT_MUST_CLEAN 2 #define MEMORY_OBJECT_LOCK_RESULT_MUST_RETURN 3 -memory_object_lock_result_t memory_object_lock_page( +static memory_object_lock_result_t memory_object_lock_page( vm_page_t m, memory_object_return_t should_return, boolean_t should_flush, diff --git a/vm/vm_map.c b/vm/vm_map.c index b142ab9d..5668c11b 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -43,6 +43,7 @@ #include <kern/assert.h> #include <kern/debug.h> #include <kern/kalloc.h> +#include <kern/mach.h> #include <kern/list.h> #include <kern/rbtree.h> #include <kern/slab.h> diff --git a/vm/vm_object.c b/vm/vm_object.c index 141bd094..7bc5d12a 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -44,6 +44,7 @@ #include <ipc/ipc_space.h> #include <kern/assert.h> #include <kern/debug.h> +#include <kern/mach.h> #include <kern/lock.h> #include <kern/queue.h> #include <kern/xpr.h> diff --git a/vm/vm_user.c b/vm/vm_user.c index b3887ad1..a305c76a 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -40,9 +40,11 @@ #include <mach/vm_statistics.h> #include <mach/vm_cache_statistics.h> #include <mach/vm_sync.h> +#include <kern/gnumach.h> #include <kern/host.h> +#include <kern/mach.h> +#include <kern/mach_host.h> #include <kern/task.h> -#include <kern/mach.server.h> #include <vm/vm_fault.h> #include <vm/vm_kern.h> #include <vm/vm_map.h> -- 2.39.0