summaryrefslogtreecommitdiff
path: root/i386/i386at/model_dep.c
AgeCommit message (Collapse)Author
2024-02-10Fix build with APIC without SMPSamuel Thibault
2024-02-09SMP: Fix allocating the apboot pageSamuel Thibault
vm_page_grab_contig does not necessarily allocate at the beginning of the DMA segment, so rather allocate by hand very early.
2024-02-08Add HPET timer for small accurate delaysDamien Zammit
TESTED: This works in qemu correctly TESTED: This works on an AMD board with ACPI v2.0 correctly Message-ID: <20240207050158.1640853-3-damien@zamaudio.com>
2024-02-05apboot: avoid self-modifying codeSamuel Thibault
self-modifying code is generally frowned upon, Intel largely says the support is model-dependent. We can as well just relocate from the C code like we did for the temporary gdt.
2024-02-05smp: Remove hardcoded AP_BOOT_ADDRDamien Zammit
This took some time to figure out. Involves a hand-crafted 16 bit assembly instruction [1] because it requires an immediate for the memory address of far jump. This required self-modifying code to inject the next instruction, therefore I added a near jump to clear the instruction cache queue in case the pipeline cached the unmodified jump location. [1] Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual
2024-02-01ACPI: Support XSDT (ACPI >= v2.0)Damien Zammit
This enables gnumach to additionally parse the XSDT table if the revision of ACPI is 2. TESTED: Still works on qemu (ACPI v1.0) TESTED: Works on a x86 board with XSDT (ACPI v2.0) Message-ID: <20240131021218.1335821-1-damien@zamaudio.com>
2024-02-01model_dep: Fix serial console with APIC enabledDamien Zammit
Move cninit() further down so that IOAPIC has a chance to initialize before the com port interrupt is unmasked in the IOAPIC, fixing a fault and reboot. Message-ID: <20240131100210.1354522-1-damien@zamaudio.com>
2023-12-03Xen: fix buildSamuel Thibault
2023-10-01com/lpr: Handle masking of interrupts in the driverDamien Zammit
Message-Id: <20231001045755.95707-1-damien@zamaudio.com>
2023-10-01kd: Handle masking of keyboard interrupt in the driverDamien Zammit
Message-Id: <20231001045731.95682-1-damien@zamaudio.com>
2023-09-24percpu area using gs segmentDamien Zammit
This speeds up smp again, by storing the struct processor in a percpu area and avoiding an expensive cpu_number every call of current_processor(), as well as getting the cpu_number by an offset into the percpu area. Untested on 64 bit and work remains to use other percpu arrays. TESTED: (NCPUS=8) -smp 1 boots to login shell ~2x slower than uniprocessor TESTED: (NCPUS=8) -smp 2 boots to INIT but hangs there TESTED: (NCPUS=8) -smp 4 gets stuck seemingly within rumpdisk and hangs TESTED: (NCPUS=1) uniprocessor is a bit faster than normal Message-Id: <20230924103428.455966-3-damien@zamaudio.com>
2023-08-28Fix crash at bootSamuel Thibault
spl cannot be called before the clock is set up.
2023-08-12model_dep: drop duplicate declarationSamuel Thibault
2023-05-11Do not expose CPU_TYPE_X86_64 when running 32bit userlandSamuel Thibault
So that userland's uname -m still reports i686-AT386.
2023-05-06x86_64: Add CPU_TYPE_X86_64 CPU typeSamuel Thibault
2023-04-11Fix Xen buildSamuel Thibault
2023-03-07lapic timer: Calibrate via mach timer not PITDamien Zammit
Previously the lapic timer was calibrated by one-shot PIT timer2. This method can be buggy and generally unused in emulation environments. This patch reworks the timer calibration to use a mach timer based on regular PIT interrupts to remapped IOAPIC pin. This also changes the primary clock source to use PIT timer0 remapped to an IOAPIC pin when APIC mode is enabled, instead of a periodic lapic timer. Message-Id: <20230306070452.292697-1-damien@zamaudio.com>
2023-02-19model_dep: Call acpi_apic_init if APIC definedDamien Zammit
Fixes boot --enable-ncpus=1 with --enable-apic configuration albeit the keyboard is stuck and network cannot be accessed. Error messages: Timeout reached while wating for return value /bin/console: Could not receive return value from daemon process: Connection timed out Message-Id: <20230219022351.25767-1-damien@zamaudio.com>
2023-02-13i386: Refactor int stacks to be per cpu for SMPDamien Zammit
This also serialises the AP bringup, so paging can be enabled per cpu one by one. Also-by: Almudena Garcia <liberamenso10000@gmail.com>
2023-02-09Remove a.out support for ddbFlavio Cruz
We haven't built gnumach using a.out for a very long time. Message-Id: <Y+SgsQ3y8pPqfxRV@jupiter.tail36e24.ts.net>
2023-02-03pmap: Refactor temporary mapping functionsDamien Zammit
Message-Id: <20230203100133.835589-1-damien@zamaudio.com>
2023-01-31Fix other confusions between KERNEL_STACK_SIZE and INTSTACK_SIZESamuel Thibault
2023-01-24Fix several warnings for -Wmissing-prototypesFlavio Cruz
* device/ds_routines.c: use static qualifier. * device/subrs.c: delete unused functions. * i386/i386/ast_check.c: include prototypes in kern/ast.h * i386/i386/db_disasm.c: Include prototypes in ddb/db_examine.h * i386/i386/db_interface.h: Define prototype for kdb_kentry. Expose debug methods feep and kd_debug_put. * i386/i386/db_trace.c: delete left over cthreads support, functions are not used. * i386/i386/model_dep.h: Define prototype for c_boot_entry. * i386/i386at/acpi_parse_apic.c: Static qualifiers. * i386/i386at/autoconf.c: Include header file for prototypes and remove dead code. * i386/i386at/autoconf.h: Fix prototype. * i386/i386at/com.c: Add static qualifiers, delete dead code. * i386/i386at/com.c: ditto. * i386/i386at/com.h: Define prototypes for debug functions. * i386/i386at/int_init.c: Include header. * i386/i386at/kd.c: Include header for debug interface. Remove dead kd_cmdreg_read and make xga_getpos static. * i386/i386at/kd_mouse.c: Static qualifiers. * i386/i386at/lpr.c: Dead lprpr. * i386/i386at/model_dep.c: Remove exit function. * kern/mach_clock.c: Include mig prototypes. * kern/mach_clock.h: Remove duplicates of mig prototypes. * kern/machine.c: Use static. * kern/startup.c: slave_main is unused. * kern/thread.h: Define thread_stats that is useful for debugging. * kern/timer.c: Keep db_thread_times since it can be used for debugging. * kern/timer.h: ditto. * linux/dev/glue/misc.c: Use mig header for host_get_time. Message-Id: <Y8oyiecaflCaYhaW@mercury.tail36e24.ts.net>
2023-01-03Introduce time_value64_t to keep track of real time in the kernelFlavio Cruz
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.
2022-12-27Fix inttypes.h format constants for uintptr_t and intptr_t.Flavio Cruz
The format constants are not correct for 32 bits and there was duplication for PRIx* constants (replaced with octal constants). Fixed a few format warnings too. Message-Id: <Y6o5KsvtPavCYe8f@mars>
2022-12-27Fix some warnings with -Wmissing-prototypes.Flavio Cruz
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>
2022-09-26Fix when enabling APIC without SMPEtienne Brateau
When we want to enable APIC, we must initialize the structure or otherwise, it will try to access to a not initialized memory addresses. Message-Id: <20220924163145.39894-1-etienne.brateau@gmail.com>
2022-08-27cleanup multibootLuca Dariz
* 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>
2022-05-27convert K&R into ansiGuy-Fleury Iteriteka
Message-Id: <Yo+lzS7RtW5ZjQHN@debian>
2021-04-05apic: Also unmask irq 3 and 4 earlySamuel Thibault
We unmasked by hand kd's irq 1, but com0/1 also need unmasking. More generally we should unmask irqs as appropriate. * i386/i386at/model_dep.c (machine_init): Unmask irq 3 and 4.
2021-04-04Add ioapic support disabled by defaultDamien Zammit
Use --enable-ncpus=x --enable-apic where x > 1 for SMP+APIC support. Use neither for no SMP and old PIC support. Message-Id: <20210404050812.145483-1-damien@zamaudio.com>
2021-03-31Keep BIOS mapped even without LinuxSamuel Thibault
Not only Linux drivers need BIOS mapped. * i386/i386at/model_dep.c (i386at_init) [!LINUX_DEV]: Map the low memory. * i386/intel/pmap.c (pmap_create) [!LINUX_DEV]: Likewise.
2020-10-07Add comment about mp_desc_init callAlmudena Garcia
2020-10-07fix: fix kernel panic in SMP mode Add mp_desc_init() call in BSP processor, ↵Almudena Garcia
to initialize some structures needed for SMP
2020-09-19smp: Add --enable-ncpus option and fix buildSamuel Thibault
* 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.
2020-09-19model_dep.c: Add smp_init callAlmudena Garcia
if NCPUS > 1, call to smp_init to start the search and enumeration of the cpus *i386/i386/model_dep.c (machine_init): add smp_init() call
2020-03-31Restore vm_size_t to natural_tSamuel Thibault
Plenty of places such as glibc RPC uses currently assume that vm_size_t is a natural_t (thus int on 32bit), not an unsigned long. * i386/include/mach/i386/vm_types.h (vm_size_t) [!__x86_64__]: Set type to natural_t. * device/dev_page.c (device_pager_data_request): Cast vm_size_t to unsigned long. * i386/i386at/model_dep.c (c_boot_entry): Likewise.
2020-03-2964bit: fix warningsSamuel Thibault
* device/net_io.h (net_set_filter, ethernet_priority): Add prototypes. * device/subrs.h: Include <device/if_hdr.h>. (if_init_queues): Add prototype. * i386/i386/model_dep.h (machine_relax): Add prototype. * i386/i386/trap.c (i386_astintr): Move mycpu variable definition to where it is used. * i386/i386at/model_dep.c (i386at_init): Likewise for nb_direct, addr, delta. * i386/xen/xen.c (return_to_iret): Change type to char[]. * xen/console.c: Include <i386at/kd.h>. * xen/evt.c (hyp_evt_handler): Cast NEVNT to int. * xen/grant.c: Include <model_dep.h>. (hyp_grant_takeback, hyp_grant_init): Fix print format. * xen/net.c: Include <device/subrs.h>. (paranoia): Remove variable. (hyp_net_init, device_close, device_open): Cast nd - vif_data to int. Fix print format. * xen/store.c (store_put): Cast sizeof to int. * xen/time.c: Include "xen.h". * xen/xen.h (hypclock_machine_intr): Add prototype.
2020-03-2964bit: Fix vm_size_t sizeSamuel Thibault
It needs to be able to hold > 4G size. * i386/include/mach/i386/vm_types.h (vm_size_t): Set type to unsigned long. * vm/vm_user.c (vm_read, vm_write): Fix type according to RPC. * i386/i386at/model_dep.c (c_boot_entry): Fix format. * device/dev_pager.c (device_pager_data_request): Fix format.
2020-03-28pmap.h: Add 64bit variantSamuel Thibault
* i386/intel/pmap.h (L4SHIFT, L4MASK, lin2l4num): New macros (PDPNUM, PDPMASK, set_pmap): Add 64bit variant. Make PAE use the 64bit mask too. (pmap): Add l4base, user_l4base, user_pdpbase fields. * i386/intel/pmap.c (pmap_bootstrap): Clear the whole PDP. Enable write bit in PDP. Set user pagetable to NULL. Initialize l4base. (pmap_clear_bootstrap_pagetable): Add 4th-level support. (pmap_ceate): Clear the whole PDP. Enable write bit in PDP. Initialize l4base, user_pdpbase, user_l4base. (pmap_destroy): Clear l4base, user_pdpbase, user_l4base. * i386/i386at/model_dep.c (i386at_init): Load l4base on 64bits.
2020-03-09Set readtodc parameter 64bitv1.8+git20200309Samuel Thibault
In order to fix year 2038 limit. * i386/i386at/rtc.h (readtodc): Make tp parameter uint64_t *. * i386/i386at/rtc.c (readtodc): Likewise. * xen/time.c (readtodc): Likewise. * i386/i386at/model_dep.c (inittodr): Pass uint64_t pointer to readtodc.
2019-04-28Avoid calling biosmem with size 0Samuel Thibault
* i386/i386at/model_dep.c (register_boot_data): Register reserved biosmem areas only when they have a non-zero size.
2019-04-28Avoid calling biosmem with size 0Samuel Thibault
* i386/configfrag.ac (register_boot_data): Process modules only when their count is non-zero. (i386at_init): Likewise.
2018-07-28device: Fix d_mmap typeSamuel Thibault
* device/conf.h (dev_ops): Make d_mmap return vm_offset_t instead of int. (nomap): Update accordingly. * device/blkio.c (block_io_mmap): Likewise. * device/blkio.h (block_io_mmap): Likewise. * device/dev_name.c (nomap): Likewise. * i386/i386at/kd.c (kdmmap): Likewise. * i386/i386at/kd.h (kdmmap): Likewise. * i386/i386at/mem.c (memmmap): Likewise. * i386/i386at/mem.h (memmmap): Likewise. * i386/i386at/model_dep.c (timemmap): Likewise. * i386/i386at/model_dep.h (timemmap): Likewise.
2017-11-12Fix halt messageSamuel Thibault
* i386/i386at/model_dep.c (halt_all_cpus): Change halt message to better explain what happened.
2016-11-06Revert "i386: use ACPI to power off the machine"Justus Winter
This reverts commit c031b41b783cc99c0bd5aac7d14c1d6e34520397. Adding the ACPI parser from GRUB was a mistake as its license conflicts with the one used by the legacy Linux drivers. Furthermore, adding support for ACPI to the kernel violates the minimality principle.
2016-11-01i386: Use discontiguous page directories when using PAE.Justus Winter
Previously, we used contiguous page directories four pages in length when using PAE. To prevent physical memory fragmentation, we need to use virtual memory for objects spanning multiple pages. Virtual kernel memory, however, is a scarce commodity. * i386/intel/pmap.h (lin2pdenum): Never include the page directory pointer table index. (lin2pdenum_cont): New macro which does include said index. (struct pmap): Remove the directory base pointer when using PAE. * i386/intel/pmap.c (pmap_pde): Fix lookup. (pmap_pte): Fix check for uninitialized pmap. (pmap_bootstrap): Do not store the page directory base if PAE. (pmap_init): Reduce size of page directories to one page, use direct-mapped memory. (pmap_create): Allocate four page directories per pmap. (pmap_destroy): Adapt to the discontinuous directories. (pmap_collect): Likewise. * i386/i386/xen.h (hyp_mmu_update_la): Adapt code manipulating the kernels page directory. * i386/i386at/model_dep.c (i386at_init): Likewise.
2016-10-31Make multiboot cmdline and modules non-permanent reservationsSamuel Thibault
* i386/i386at/model_dep.c (register_boot_data): For multiboot cmdline, module structure, module data and module strings, set biosmem_register_boot_data temporary parameter to TRUE.
2016-09-21Remove phys_first_addr and phys_last_addr global variablesRichard Braun
The old assumption that all physical memory is directly mapped in kernel space is about to go away. Those variables are directly linked to that assumption. * i386/i386/model_dep.h (phys_first_addr): Remove extern declaration. (phys_last_addr): Likewise. * i386/i386/phys.c (pmap_zero_page): Use VM_PAGE_DIRECTMAP_LIMIT instead of phys_last_addr. (pmap_copy_page, copy_to_phys, copy_from_phys): Likewise. * i386/i386/trap.c (user_trap): Remove check against phys_last_addr. * i386/i386at/biosmem.c (biosmem_bootstrap_common): Don't set phys_last_addr. * i386/i386at/mem.c (memmmap): Use vm_page_lookup_pa to determine if a physical address references physical memory. * i386/i386at/model_dep.c (phys_first_addr): Remove variable. (phys_last_addr): Likewise. (pmap_free_pages, pmap_valid_page): Remove functions. * i386/intel/pmap.c: Include i386at/biosmem.h. (pa_index): Turn into an alias for vm_page_table_index. (pmap_bootstrap): Replace uses of phys_first_addr and phys_last_addr as appropriate. (pmap_virtual_space): Use vm_page_table_size instead of phys_first_addr and phys_last_addr to obtain the number of physical pages. (pmap_verify_free): Remove function. (valid_page): Turn this macro into an inline function and rewrite using vm_page_lookup_pa. (pmap_page_table_page_alloc): Build the pmap VM object using vm_page_table_size to determine its size. (pmap_remove_range, pmap_page_protect, phys_attribute_clear, phys_attribute_test): Turn page indexes into unsigned long integers. (pmap_enter): Likewise. In addition, use either vm_page_lookup_pa or biosmem_directmap_end to determine if a physical address references physical memory. * i386/xen/xen.c (hyp_p2m_init): Use vm_page_table_size instead of phys_last_addr to obtain the number of physical pages. * kern/startup.c (phys_first_addr): Remove extern declaration. (phys_last_addr): Likewise. * linux/dev/init/main.c (linux_init): Use vm_page_seg_end with the appropriate segment selector instead of phys_last_addr to determine where high memory starts. * vm/pmap.h: Update requirements description. (pmap_free_pages, pmap_valid_page): Remove declarations. * vm/vm_page.c (vm_page_seg_end, vm_page_boot_table_size, vm_page_table_size, vm_page_table_index): New functions. * vm/vm_page.h (vm_page_seg_end, vm_page_table_size, vm_page_table_index): New function declarations. * vm/vm_resident.c (vm_page_bucket_count, vm_page_hash_mask): Define as unsigned long integers. (vm_page_bootstrap): Compute VP table size based on the page table size instead of the value returned by pmap_free_pages.
2016-09-06Fix registration of strings from in boot dataRichard Braun
* i386/i386at/model_dep.c (register_boot_data): Use phystokv on strings when computing their length.