aboutsummaryrefslogtreecommitdiff
path: root/kern
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* boot_script: Explicit missing symbol nameSamuel Thibault2020-04-061-0/+2
| | | | | * kern/boot_script.c: Include <kern/printf.h>. (boot_script_exec): Print missing symbol name on symbol lookup error.
* x86_64: Fix passing argumentSamuel Thibault2020-04-051-1/+1
| | | | * kern/boot_script.c (add_arg): Make val parameter long.
* Fix build with -fno-commonSamuel Thibault2020-03-314-2/+6
| | | | | | | | | | | | | | | | which will be the default in gcc-10. * device/io_req.h (io_inband_cache): Add extern qualifier. * device/tty.h (tthiwat, ttlowat): Likewise. * i386/i386/db_machdep.h (ddb_regs): Likewise. * kern/cpu_number.h (master_cpu): Likewise. * kern/time_stamp.h (ts_tick_count): Likewise. * linux/src/drivers/scsi/in2000.h (proc_scsi_in2000): Likewise. * device/ds_routines.c (io_inband_cache): New variable. * i386/i386/db_interface.c (ddb_regs): Likewise. * kern/processor.c (master_cpu): Likewise. * kern/time_stamp.c (ts_tick_count): Likewise. * linux/pcmcia-cs/modules/pci_fixup.c (pci_root): Remove variable.
* bootstrap.c: Add 32-on-64bit supportSamuel Thibault2020-03-281-2/+20
| | | | | * kern/bootstrap.c (bootstrap_create): Support loading 32bit binaries on 64bit.
* syscall_sw.h: Add 64bit variantSamuel Thibault2020-03-281-0/+3
| | | | * kern/syscall_sw.h (mach_trap_t): Fix structure for 64bit.
* Cope with machine_info.memory_size overflowSamuel Thibault2020-01-011-1/+6
| | | | | * kern/startup.c (setup_main): When memory size overflows machine_info.memory_size, set to maximum size.
* sched: cause ast on master processor tooSamuel Thibault2019-11-011-7/+2
| | | | | | | Nowadays' processors are way fast enough to handle everything fine. * kern/sched_prim.c (thread_setrun): Do not check against target processor being master.
* patch: add last_processor to thread info structuresAlmudena Garcia2019-10-271-2/+11
| | | | | | | * include/mach/thread_info.h (thread info structures): Add new member "last_processor" in thread_sched_info. * kern/thread.c (thread management): Fill new member "last_processor" in thread_info() function.
* Fix formatSamuel Thibault2019-08-111-1/+1
| | | | * kern/task.c (task_create_kernel): Fix passing string size.
* Fix uninitialized valueSamuel Thibault2019-08-111-1/+1
| | | | | * kern/gsync.c (temp_mapping): Initialize start address to VM_MIN_KERNEL_ADDRESS.
* Fix interactivity of inactive threadsSamuel Thibault2018-11-191-0/+11
| | | | | | | | | | | A new thread will mosty probably start working, assume it will take its share of CPU, to avoid having to find it out slowly. Decaying will however fix that quickly if it actually does not work. This fixes stalling issues when a program keeps creating threads. * kern/thread.c (thread_create): Set new_thread's cpu_usage and sched_usage to a fair share of the current load.
* Fix task and thread collection frequencySamuel Thibault2018-11-192-2/+4
| | | | | | | | | sched_tick is incremented only once per second, not once per tick. * kern/task.c (consider_task_collect): Divide task_collect_max_rate by (hz / 1) to get a number of scheduler ticks. * kern/thread.c (consider_thread_collect): Divide thread_collect_max_rate by (hz / 1) to get a number of scheduler ticks.
* Drop SIMPLE_CLOCK supportSamuel Thibault2018-11-193-36/+0
| | | | | | | | | | | | | This wasn't building and is not useful with nowaday's hardware. * configfrag.ac (SIMPLE_CLOCK): Do not define. * kern/sched.h [SIMPLE_CLOCK] (sched_usec): Remove variable declaration. * kern/sched_prim.c [SIMPLE_CLOCK] (sched_usec): Remove variable. [SIMPLE_CLOCK] (sched_init): Do not initialize sched_usec variable. [SIMPLE_CLOCK] (recompute_priorities): Do not tinker sched_usec variable. * kern/thread.c [SIMPLE_CLOCK] (thread_info): Do not ajust for clock drift.
* Make scheduling more reactiveSamuel Thibault2018-11-192-1/+2
| | | | | | | | Give smaller quantums to processes, to get more frequent context switches. This fixes some reactivity for concurrent processes. * kern/sched.h (MIN_QUANTUM): Define to hz / 33. * kern/sched_prim.c (sched_init): Use MIN_QUANTUM instead of hz / 10.
* Fix using all dynamic prioritiesSamuel Thibault2018-11-041-3/+3
| | | | | | | | | | | 6a2342010811 ("Increase number of priorities") increased NRQS but didn't increase PRI_SHIFT to extend the use of the additional queues by the scheduler. This does it. While at it, extend to NRQS to 64, the double of the original 32, to keep all values coherent. * i386/i386/sched_param.h (PRI_SHIFT): Set from 18 to 17. * kern/sched.h (PRI_SHIFT): Set from 18 to 17. (NRQS): Set to 64.
* Add cause_ast_check prototypeSamuel Thibault2018-06-271-0/+5
| | | | | | As reported by Almudena Garcia <liberamenso10000@gmail.com> * kern/ast.h [NCPUS > 1] (cause_ast_check): Add prototype.
* Define CPU_L1_SIZE even when NCPUS != 1Samuel Thibault2018-06-271-1/+2
| | | | | | As reported by Almudena Garcia <liberamenso10000@gmail.com> * kern/cpu_number.h [NCPUS != 1] (CPU_L1_SIZE): Define macro.
* Add missing prototypeSamuel Thibault2018-06-171-0/+1
| | | | * kern/machine.h (action_thread): Add prototype.
* Fix warningSamuel Thibault2018-01-281-1/+1
| | | | * kern/sched_prim.c (assert_wait): Fix panic format.
* Fix warningSamuel Thibault2018-01-281-1/+1
| | | | * kern/ast.c (ast_check): Fix panic format.
* Fix commit 10ebf9565f69760e46a8f271e22c5367d54e10ff.Justus Winter2017-10-271-13/+0
| | | | | | * kern/task.c (task_ledger_acquire): Remove function that I added by accident. (task_ledger_release): Likewise.
* kern: Fix new task notifications.Justus Winter2017-10-261-1/+3
| | | | * kern/task.c (task_create_kernel): Handle NULL parent tasks.