aboutsummaryrefslogtreecommitdiff
path: root/kern
Commit message (Collapse)AuthorAgeFilesLines
* replace mach_port_t with mach_port_name_tLuca Dariz2023-01-182-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a cleanup following the introduction of mach_port_name_t. The same set of changes is applied to all files: - rename mach_port_t to mach_port_name_t where a port name is used, - use MACH_PORT_NAME_NULL and MACH_PORT_NAME_DEAD where appropriate, - use invalid_port_to_name() and invalid_name_to_port() for conversion where appropriate, - use regular copyout() insted of copyout_port() when we deal with mach_port_name_t already before copyout, - use the new helper ipc_kmsg_copyout_object_to_port() when we really want to place a port name in the space of a mach_port_t. * include/mach/notify.h: Likewise * ipc/ipc_entry.c: Likewise * ipc/ipc_kmsg.c: Likewise * ipc/ipc_kmsg.h: Likewise, and add ipc_kmsg_copyout_object_to_port() * ipc/ipc_marequest.c: Likewise * ipc/ipc_object.c: Likewise * ipc/ipc_port.c: Likewise * ipc/ipc_space.h: Likewise * ipc/mach_msg.c: Likewise * ipc/mach_port.c: Likewise * kern/exception.c: Likewise * kern/ipc_mig.c: Likewise Message-Id: <20230116105857.240210-8-luca@orpolo.org>
* update writev syscall signature with rpc typesLuca Dariz2023-01-182-6/+6
| | | | | | | | | | * device/device_emul.h: write/writev: update trap argument types * device/ds_routines.c: update argument types and adjust copyin * device/ds_routines.h: write/writev: update trap argument type * include/device/device_types.h: add rpc_io_buf_vec_t type * kern/ipc_mig.c: write/writev: update trap argument type * kern/ipc_mig.h: Likewise Message-Id: <20230116105857.240210-5-luca@orpolo.org>
* update syscall signature with rpc_vm_* and mach_port_name_tLuca Dariz2023-01-182-34/+37
| | | | | | | | | * include/mach/mach_types.h: use mach port names * kern/ipc_mig.c: update vm types and use copyin/copyout helpers * kern/ipc_mig.h: Likewise Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20230116105857.240210-4-luca@orpolo.org>
* add msg_user_header_t for user-side msg structureLuca Dariz2023-01-181-1/+1
| | | | | | | | | | | * include/mach/message.h: use mach_msg_user_header_t only in KERNEL, and define it as mach_msh_header_t for user space * ipc/ipc_kmsg.c: use mach_msg_user_header_t where appropriate * ipc/ipc_kmsg.h: Likewise * ipc/mach_msg.c: Likewise * ipc/mach_msg.h: Likewise * kern/thread.h: Likewise Message-Id: <20230116105857.240210-2-luca@orpolo.org>
* Add static qualifiersFlavio Cruz2023-01-182-2/+2
| | | | | stack_statistics, swapin_thread_continue, and memory_object_lock_page are not used outside their module.
* fix warningsLuca Dariz2023-01-161-1/+1
| | | | | | | * ipc/ipc_kmsg.c: drop useless cast. * ipc/ipc_port.c: upcast rpc_vm_offset_t to full vm_offset_t * kern/pc_sample.c: Likewise Message-Id: <20230116130426.246584-4-luca@orpolo.org>
* add required includeLuca Dariz2023-01-161-0/+2
| | | | | | | * kern/syscall_sw.h: add missing include Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20230116130426.246584-2-luca@orpolo.org>
* Delete ffs and strrchr prototypes.Flavio Cruz2023-01-151-21/+0
| | | | | | | | We use __builtin_ffs instead of ffs. strrchr is not used. Also removed the commented out memset implementation since it is implemented in arch-specific code. Message-Id: <Y8NOXbVzhBJknR29@mercury.tail36e24.ts.net>
* Create kern/mach4.h and kern/mach_host.h and define the RPC prototypes for ↵Flavio Cruz2023-01-1310-0/+242
| | | | | | | mach4.defs and mach_host.defs. Also move more mach_debug rpcs to kern/mach_debug.h. Message-Id: <Y7+LPMLOafUQrNHZ@jupiter.tail36e24.ts.net>
* Preemptively fix warnings that will be caused by -Wmissing-prototypesFlavio Cruz2023-01-101-0/+40
| | | | | | | Declared RPCs in ipc/mach_port.c and ddb/db_ext_symtab.c in their corresponding headers. Ideally these should be used by mig instead of mig declaring its own prototypes. Message-Id: <Y7z/BQhmsBbRgxhe@jupiter.tail36e24.ts.net>
* Move cpu_down and other functions inside SMP ifdefFlavio Cruz2023-01-072-60/+60
| | | | | | | cpu_down is shown as not required when disabling SMP so moving it inside NCPUS > 1 to eliminate the warning. Note that the diff ended up looking a bit different due the way functions are laid out. Message-Id: <Y7ZH6aI3fhWNzyrY@jupiter.tail36e24.ts.net>
* Fix ddb warnings introduced with -Wstrict-prototypesFlavio Cruz2023-01-051-1/+3
| | | | | | | Changed some ddb command functions to have the expected signature but not all of them due to the being difficult to inter-dependency between header files (for those just used cast). Message-Id: <Y7UO9HTfpZ8U0Nfy@mars>
* Introduce time_value64_t to keep track of real time in the kernelFlavio Cruz2023-01-032-15/+16
| | | | | | | | | | | | time_value64_t uses int64_t to track seconds and nanoseconds and hence is Y2038 proof. It does not have nano second resolution but it could be provided in the future. Removed include/sys/time.h as it remaps time_value_t into timeval which can create confusion. The timestamp from keyboard and mouse events is no longer set and replaced with rpc_time_value for better compatibility.
* convert K&R into ansi.Guy-Fleury Iteriteka2023-01-011-13/+7
| | | | Message-Id: <Y7GBIF6mBjV6kBM+@falom>
* Delete kern_timestamp system call since it is not usedFlavio Cruz2022-12-276-141/+0
| | | | Message-Id: <Y6r72z4cKVCMDSKy@mars>
* Fix some warnings with -Wmissing-prototypes.Flavio Cruz2022-12-2714-36/+30
| | | | | | | | | | | Marked some functions as static (private) as needed and added missing includes. This also revealed some dead code which was removed. Note that -Wmissing-prototypes is not enabled here since there is a bunch more warnings. Message-Id: <Y6j72lWRL9rsYy4j@mars>
* Use -Wstrict-prototypes and fix warningsFlavio Cruz2022-12-213-10/+8
| | | | | | | Most of the changes include defining and using proper function type declarations (with argument types declared) and avoiding using the K&R style of function declarations. Message-Id: <Y6Jazsuis1QA0lXI@mars>
* Delete thread_get_state_KERNEL and thread_set_state_KERNELFlavio Cruz2022-12-111-41/+0
| | | | | | These are not used. Message-Id: <Y5V95ibk9Z+3OJxN@jupiter.tail36e24.ts.net>
* Update kern/ directory to use mach_port_name_t.Flavio Cruz2022-12-078-17/+17
| | | | | Make it clear where exactly we use port names vs port addresses. Message-Id: <Y5AdJGuzXBMO7YRK@reue>
* Use long_natural_t in kern/task.h and kern/slab.hFlavio Cruz2022-12-072-12/+12
| | | | | | RPC interfaces already use long_natural_t so internally we can also use this type. Message-Id: <Y5AdPNqg4l5jAZ3n@reue>
* Define vm_size_t and vm_offset_t as __mach_uintptr_t.Flavio Cruz2022-12-061-1/+1
| | | | | | | | | | This allows *printf to use %zd/%zu/%zx to print vm_size_t and vm_offset_t. Warnings using the incorrect specifiers were fixed. Note that MACH_PORT_NULL became just 0 because GCC thinks that we were comparing a pointer to a character (due to it being an unsigned int) so I removed the explicit cast. Message-Id: <Y47UNdcUF35Ag4Vw@reue>
* task: Add task_set_essentialSamuel Thibault2022-12-032-1/+18
| | | | | | | | Whenever a Hurd essential task crashes, startup just reboots the system since there's not much that can be done at that point. When we have a kernel debugger, however, we could at least get crashing information, so let's let Hurd's startup tell the kernel which tasks are essential, and trigger the debugger whenever they crash.
* Update ipc/ directory to use mach_port_name_tFlavio Cruz2022-11-306-78/+79
| | | | | | | | | | | | | | | Make it explicit where we use port names versus actual ports. For the 64 bit kernel, port names and ports are of different size so this corrects the syscall arguments and internal structs to have the right size. This patch also uncovered several issues we need to solve to make GNUMach work well on 64 bits. First, the mach_msg call will receive 4 byte port names while the kernel "thinks" they are 8 bytes, which will be a problem. Also, when we send a message, the kernel translates the port names into port pointers in the message copied from user space. This also won't work on 64 bits. In this patch, I added several TODOs to fix the issues later. Message-Id: <Y4cCzNmc6vC4bjsX@viriathus>
* Add missing gitignore rulesSamuel Thibault2022-11-291-0/+2
|
* Use portable rpc types to define 'struct sample'.Flavio Cruz2022-11-281-2/+2
| | | | Message-Id: <Y4QQFkTUR4M60Gx0@viriathus>
* Fix 64-to-32 copyoutSamuel Thibault2022-08-281-3/+5
| | | | We cannot assume that the processor is little-endian.
* fix argument passing to bootstrap modulesLuca Dariz2022-08-281-13/+9
| | | | | | | | * kern/bootstrap.c: use rpc_ vm types to put the bootstrap module arguments on the stack, make it consistent with user-space types. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-4-luca@orpolo.org>
* cleanup headers in printf.cLuca Dariz2022-08-271-2/+2
| | | | | | | | | * kern/printf.c: remove unnecessary #include and reorder This allows the file to be reused for minimal user-space tests. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-14-luca@orpolo.org>
* add port name typesLuca Dariz2022-08-272-4/+4
| | | | | | | | | | | | | | | | | | | | * include/mach/mach_port.defs - use C type mach_port_name_array_t * include/mach/port.h: - add new types mach_port_name_t and mach_port_name_array_t - refine mach_port_t type for user and kernel space - use port names in mach_port_status to allow compilation of 64-bit - use port name to have uniform sizes and remove the old_mach_port_status_t as it's unused * include/mach/std_types.defs - use C type mach_port_name_array_t * kern/thread.{h,c} - fix prototype to use port names. So far it seems the only rpc to cause a conflict between the mig-generated header and the regular header, so compilation fails. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220403145955.120742-2-luca@orpolo.org>
* fix warnings for 32 bit buildsLuca Dariz2022-08-273-1/+5
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
* cleanup multibootLuca Dariz2022-08-271-2/+18
| | | | | | | | | * use _raw_ structs where we refer to the bootloader-provided data * remove unused structures * fix 64 bit boot Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-3-luca@orpolo.org>
* convert K&R into ansiGuy-Fleury Iteriteka2022-05-272-15/+7
| | | | Message-Id: <Yo+lzS7RtW5ZjQHN@debian>
* thread_terminate_release: Error out early if thread is NULLSamuel Thibault2022-01-211-0/+3
| | | | | We do not want to destroy the port and release the stack if thread is NULL, i.e. we will fail.
* task_set_name: make string parameter constSamuel Thibault2022-01-162-2/+2
| | | | | This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
* thread: Fix thread_abort clearing of an event waitAlicia2021-12-311-0/+1
| | | | | 881fe9da8bd1 ("kern/thread.c: some minor style changes") introduced a spurious comment.
* kern/thread.c: some minor style changesAdam Kandur2021-12-301-34/+22
| | | | | | | Greeting, I have changed some stuff in kern/thread.c which makes code more readable for me. Maybe it will be usefull. Message-Id: <20211230082643.8171-1-sys.arch.adam@gmail.com>
* vm_page_grab: allow allocating in high memorySamuel Thibault2021-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_page_grab was systematically using the VM_PAGE_SEL_DIRECTMAP selector to play safe with existing code. This adds a flags parameter to let callers of vm_page_grab specify their constraints. Linux drivers need 32bit dmas, Xen drivers use kvtophys to clear some data. Callers of kmem_pagealloc_physmem and vm_page_grab_phys_addr also use kvtophys. Otherwise allocations can go to highmem. This fixes the allocation jam in the directmap segment. * vm/vm_page.h (VM_PAGE_DMA, VM_PAGE_DMA32, VM_PAGE_DIRECTMAP, VM_PAGE_HIGHMEM): New macros. (vm_page_grab): Add flags parameter. * vm/vm_resident.c (vm_page_grab): Choose allocation selector according to flags parameter. (vm_page_convert, vm_page_alloc): Pass VM_PAGE_HIGHMEM to vm_page_grab. (vm_page_grab_phys_addr): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * vm/vm_fault.c (vm_fault_page): Pass VM_PAGE_HIGHMEM to vm_page_grab. * vm/vm_map.c (vm_map_copy_steal_pages): Pass VM_PAGE_HIGHMEM to vm_page_grab. * kern/slab.c (kmem_pagealloc_physmem): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * i386/intel/pmap.c (pmap_page_table_page_alloc): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * xen/block.c (device_read): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * linux/dev/glue/block.c (alloc_buffer): Pass VM_PAGE_DMA32 to vm_page_grab.
* assert: Tell the compiler that failures are unlikelySamuel Thibault2021-08-121-1/+1
|
* thread_info: Fix crash when requesting for thread that never ranSamuel Thibault2021-04-051-3/+4
| | | | | * kern/thread.c (thread_info): Set last_processor to 0 when the thread never ran.
* thread_info: Fix returning last_processorSamuel Thibault2021-04-051-1/+1
| | | | | | | thread->last_processor is a processor_t, not a slot number. * kern/thread.c (thread_info): Set sched_info->last_processor to thread->last_processor->slot_num rather than thread->last_processor.
* SMP: Fix warningsSamuel Thibault2021-04-043-1/+8
|
* clock: Let timer proceed even before we have set threadsDamien Zammit2021-03-271-1/+4
| | | | Message-Id: <20210326094850.2606-4-damien@zamaudio.com>
* elf-load: Avoid loading PIE binaries at address 0Samuel Thibault2020-10-071-2/+9
| | | | | | | It seems that ld.so sometimes gets into troubles and hangs at bootstrap. * kern/elf-load.c (exec_load): When x.e_type == ET_DYN || x.e_type == ET_REL, add 128MiB as loadbase.
* bootstrap: Increase STACK_SIZESamuel Thibault2020-10-071-1/+1
| | | | | * kern/bootstrap.c (STACK_SIZE): Set to 128KB. glibc's __MAX_ALLOCA_CUTOFF is 64K by default.
* smp: Add --enable-ncpus option and fix buildSamuel Thibault2020-09-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | * configfrag.ac (--enable-ncpus): Add option to set $mach_ncpus. * i386/i386/cpu_number.h (CPU_NUMBER, cpu_number): New macros, set to 0 for now. * i386/i386/db_interface.c (cpu_interrupt_to_db): New function. * i386/i386/db_interface.h (cpu_interrupt_to_db): New declaration. * i386/i386/mp_desc.c (int_stack_base): New array. (intel_startCPU): New function. * i386/i386at/model_dep.c: Include <i386/smp.h> (int_stack_top, int_stack_base): Turn into arrays (i386at_init): Update accesses accordingly. * i386/i386at/model_dep.h (int_stack_top, int_stack_base, ON_INT_STACK): Likewise. * i386/intel/pmap.c (cpus_active, cpus_idle, cpu_update_needed): Add variables. * i386/intel/pmap.h (cpus_active, cpus_idle, cpu_update_needed): Mark extern. * kern/cpu_number.h: Include <machine/cpu_number.h> * linux/dev/arch/i386/kernel/irq.c (local_bh_count, local_irq_count): Hardcode to the address of intr_count. We will not use the Linux code in SMP mode anyway.
* smp: Add generic smp pseudoclassAlmudena Garcia2020-09-192-0/+73
| | | | | | | | | | This pseudoclass generalize the initialization and access of SMP data, allowing expands it to other architectures. In x86, the functions calls to apic functions. *kern/smp.c: Source file. Implements a interface to load the SMP functions for the current architecture. *kern/smp.h: Header file. Add declaration for smp_data structure. *i386/i386/smp.c: Source file. Implements a set of functions to manage the SMP actions in i386 *i386/i386/smp.h: Header file. Add declarations for SMP functions in i386.
* Add hardware interrupt notification mechanismSamuel Thibault2020-07-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows privileged userland drivers to get notifications of hardware interrupts. Initial work by Zheng Da, reworked by Damien Zammit and myself. * Makefrag.am (libkernel_a_SOURCES): Add device/intr.c and device/intr.h. (include_device_HEADERS): Add include/device/notify.defs and include/device/notify.h. * device/dev_hdr.h (name_equal): Add declaration. * device/ds_routines.c: Include <device/intr.h> (ds_device_intr_register, ds_device_intr_ack): New functions. * device/intr.c, device/intr.h: New files. * doc/mach.texi (Device Interrupt): New section. * i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386/irq.c and i386/i386/irq.h. * i386/i386/irq.c, i386/i386/irq.h: New files. * i386/i386at/conf.c: Include <device/intr.h>. (irqname): New macro. (dev_name_list): Add irq device. * include/device/device.defs (device_intr_register, device_intr_ack): New RPCs. * include/device/notify.defs, include/device/notify.h: New files. * kern/startup.c: Include <device/intr.h> (start_kernel_threads): Start intr_thread thread. * linux/dev/arch/i386/kernel/irq.c: Include <device/intr.h> (linux_action): Add user_intr field. (linux_intr): Call user_intr action if any. (mask_irq, unmask_irq): Move functions to i386/i386/pic.c (__disable_irq, __enable_irq): Move functions to i386/i386/irq.c. (install_user_intr_handler): New function. (request_irq): Initialize user_intr field. * linux/src/include/asm-i386/irq.h (__disable_irq, __enable_irq): Remove prototypes. * i386/i386/pic.c (mask_irq, unmask_irq): New functions. * i386/i386/pic.h (mask_irq, unmask_irq): New prototypes.
* Add experimental RPC infrastructureSamuel Thibault2020-07-092-0/+5
| | | | | | | | | | | | | | | | This is free for experimenting RPCs, with no backward compatibility guarantees. * Makefrag.am (EXTRA_DIST): Add kern/experimental.srv. (include_mach_HEADERS): Add include/mach/experimental.defs. (nodist_lib_dep_tr_for_defs_a_SOURCES): Add kern/experimental.server.defs.c. (nodist_libkernel_a_SOURCES): Add kern/experimental.server.h, kern/experimental.server.c, kern/experimental.server.msgids. (nodist_libkernel_a_SOURCES): Add kern/experimental.server.defs. * include/mach/experimental.defs: New file. * kern/experimental.srv: New file. * kern/ipc_kobject.c: Include <kern/experimental.server.h>. (ipc_kobject_server): Call experimental_server_routine.
* mach_trap_table: Fix 64bit versionSamuel Thibault2020-04-061-3/+2
| | | | | | | The addition of the mach_trap_name field made the 64bit unused field spurious. * kern/syscall_sw.h (mach_trap_t): Remove `unused' field.
* bootstrap: Add missing reference to send port between tasksSamuel Thibault2020-04-061-1/+2
| | | | | | | | | When giving the port to a bootstrap task to another bootstrap task, we need to add a reference. This shows up on error-cleanup (e.g. when forgetting to define the root). * kern/bootstrap.c (boot_script_insert_task_port): Call ipc_port_make_send on `task''s itk_sself.