aboutsummaryrefslogtreecommitdiff
path: root/i386/i386at/model_dep.c
Commit message (Collapse)AuthorAgeFilesLines
* pmap: Separate temporary_mapping from set_page_dirDamien Zammit via Bug reports for the GNU Hurd2024-12-091-0/+1
| | | | | | | Prepare for smp parallel init where we want to call these two functions on different cpus at different times. Message-ID: <20241209121706.879984-5-damien@zamaudio.com>
* Expose device(mbinfo) with read access to multiboot raw infoDamien Zammit2024-10-271-0/+3
| | | | Message-ID: <20241027092828.3162279-1-damien@zamaudio.com>
* remove machine/machspl.h as it duplicates machine/spl.hLD2024-03-091-1/+1
| | | | Message-ID: <20240309140244.347835-2-luca@orpolo.org>
* Fix build with APIC without SMPSamuel Thibault2024-02-101-1/+1
|
* SMP: Fix allocating the apboot pageSamuel Thibault2024-02-091-8/+0
| | | | | vm_page_grab_contig does not necessarily allocate at the beginning of the DMA segment, so rather allocate by hand very early.
* Add HPET timer for small accurate delaysDamien Zammit2024-02-081-0/+6
| | | | | | | 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>
* apboot: avoid self-modifying codeSamuel Thibault2024-02-051-1/+6
| | | | | | 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.
* smp: Remove hardcoded AP_BOOT_ADDRDamien Zammit2024-02-051-0/+18
| | | | | | | | | | | | | 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
* ACPI: Support XSDT (ACPI >= v2.0)Damien Zammit2024-02-011-1/+7
| | | | | | | | | 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>
* model_dep: Fix serial console with APIC enabledDamien Zammit2024-02-011-5/+5
| | | | | | | 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>
* Xen: fix buildSamuel Thibault2023-12-031-0/+2
|
* com/lpr: Handle masking of interrupts in the driverDamien Zammit2023-10-011-8/+0
| | | | Message-Id: <20231001045755.95707-1-damien@zamaudio.com>
* kd: Handle masking of keyboard interrupt in the driverDamien Zammit2023-10-011-2/+0
| | | | Message-Id: <20231001045731.95682-1-damien@zamaudio.com>
* percpu area using gs segmentDamien Zammit2023-09-241-0/+1
| | | | | | | | | | | | | | | 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>
* Fix crash at bootSamuel Thibault2023-08-281-0/+1
| | | | spl cannot be called before the clock is set up.
* model_dep: drop duplicate declarationSamuel Thibault2023-08-121-4/+0
|
* Do not expose CPU_TYPE_X86_64 when running 32bit userlandSamuel Thibault2023-05-111-1/+1
| | | | So that userland's uname -m still reports i686-AT386.
* x86_64: Add CPU_TYPE_X86_64 CPU typeSamuel Thibault2023-05-061-0/+4
|
* Fix Xen buildSamuel Thibault2023-04-111-0/+2
|
* lapic timer: Calibrate via mach timer not PITDamien Zammit2023-03-071-2/+6
| | | | | | | | | | | 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>
* model_dep: Call acpi_apic_init if APIC definedDamien Zammit2023-02-191-2/+3
| | | | | | | | | | | 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>
* i386: Refactor int stacks to be per cpu for SMPDamien Zammit2023-02-131-17/+16
| | | | | | | This also serialises the AP bringup, so paging can be enabled per cpu one by one. Also-by: Almudena Garcia <liberamenso10000@gmail.com>
* Remove a.out support for ddbFlavio Cruz2023-02-091-27/+0
| | | | | | We haven't built gnumach using a.out for a very long time. Message-Id: <Y+SgsQ3y8pPqfxRV@jupiter.tail36e24.ts.net>
* pmap: Refactor temporary mapping functionsDamien Zammit2023-02-031-71/+2
| | | | Message-Id: <20230203100133.835589-1-damien@zamaudio.com>
* Fix other confusions between KERNEL_STACK_SIZE and INTSTACK_SIZESamuel Thibault2023-01-311-2/+2
|
* Fix several warnings for -Wmissing-prototypesFlavio Cruz2023-01-241-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Introduce time_value64_t to keep track of real time in the kernelFlavio Cruz2023-01-031-3/+2
| | | | | | | | | | | | 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.
* Fix inttypes.h format constants for uintptr_t and intptr_t.Flavio Cruz2022-12-271-2/+3
| | | | | | | | 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>
* Fix some warnings with -Wmissing-prototypes.Flavio Cruz2022-12-271-1/+1
| | | | | | | | | | | 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>
* Fix when enabling APIC without SMPEtienne Brateau2022-09-261-2/+8
| | | | | | 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>
* cleanup multibootLuca Dariz2022-08-271-11/+12
| | | | | | | | | * 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-271-4/+1
| | | | Message-Id: <Yo+lzS7RtW5ZjQHN@debian>
* apic: Also unmask irq 3 and 4 earlySamuel Thibault2021-04-051-0/+7
| | | | | | | 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.
* Add ioapic support disabled by defaultDamien Zammit2021-04-041-6/+15
| | | | | | | 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>
* Keep BIOS mapped even without LinuxSamuel Thibault2021-03-311-5/+1
| | | | | | | | 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.
* Add comment about mp_desc_init callAlmudena Garcia2020-10-071-0/+1
|
* fix: fix kernel panic in SMP mode Add mp_desc_init() call in BSP processor, ↵Almudena Garcia2020-10-071-0/+5
| | | | to initialize some structures needed for SMP
* smp: Add --enable-ncpus option and fix buildSamuel Thibault2020-09-191-3/+6
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* model_dep.c: Add smp_init callAlmudena Garcia2020-09-191-1/+7
| | | | | | 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
* Restore vm_size_t to natural_tSamuel Thibault2020-03-311-1/+1
| | | | | | | | | | | 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.
* 64bit: fix warningsSamuel Thibault2020-03-291-4/+5
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* 64bit: Fix vm_size_t sizeSamuel Thibault2020-03-291-1/+1
| | | | | | | | | | 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.
* pmap.h: Add 64bit variantSamuel Thibault2020-03-281-3/+7
| | | | | | | | | | | | | | * 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.
* Set readtodc parameter 64bitSamuel Thibault2020-03-091-3/+3
| | | | | | | | | 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.
* Avoid calling biosmem with size 0Samuel Thibault2019-04-281-3/+6
| | | | | * i386/i386at/model_dep.c (register_boot_data): Register reserved biosmem areas only when they have a non-zero size.
* Avoid calling biosmem with size 0Samuel Thibault2019-04-281-2/+2
| | | | | | * i386/configfrag.ac (register_boot_data): Process modules only when their count is non-zero. (i386at_init): Likewise.
* device: Fix d_mmap typeSamuel Thibault2018-07-281-1/+1
| | | | | | | | | | | | | | | * 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.
* Fix halt messageSamuel Thibault2017-11-121-1/+2
| | | | | * i386/i386at/model_dep.c (halt_all_cpus): Change halt message to better explain what happened.
* Revert "i386: use ACPI to power off the machine"Justus Winter2016-11-061-2/+0
| | | | | | | | | 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.
* i386: Use discontiguous page directories when using PAE.Justus Winter2016-11-011-8/+8
| | | | | | | | | | | | | | | | | | | | | | 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.