aboutsummaryrefslogtreecommitdiff
path: root/i386/i386at
Commit message (Collapse)AuthorAgeFilesLines
* interrupt: Fix passing parameter to splx_cli and ioapic_irq_eoiSamuel Thibault2022-11-101-2/+2
| | | | | | | e2fcf261076b (""interrupt: Fix saving irq/ipl when linux drivers are disabled") broke booting under some conditions, because the parameters were erroneously written 4 bytes too far for splx_cli and ioapic_irq_eoi to read them.
* acpi: Add lapic_addrDamien Zammit2022-10-252-0/+3
| | | | | | Message-Id: <20221025105502.222708-5-damien@zamaudio.com> Co-authored-by: Almudena Garcia <liberamenso10000@gmail.com>
* 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>
* interrupt: Fix saving irq/ipl when linux drivers are disabledSamuel Thibault2022-09-171-14/+37
| | | | | | | | | | | | | | When Linux drivers are disabled, in hardclock() the linux_timer_intr() call is dropped, and gcc can tail-recursion-optimize the call to clock_interrupt(). To do so, it overwrites the hardclock() parameters to suit the clock_interrupt parameters layout. This however means it thrashes the backups that the interrupt() function had made of irq/ipl, leading to mayhem. interrupt should thus really properly separate its irq/ipl backups from the interrupt function parameters. Thanks a lot to Etienne Brateau for the tricky investigation!
* kd_mouse: Fix warningSamuel Thibault2022-09-172-4/+5
|
* fix warnings for 32 bit buildsLuca Dariz2022-08-272-1/+2
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
* fix console setting from cmdlineLuca Dariz2022-08-271-0/+5
| | | | | | | | The leading space prevents it working if console=comX is the only argument, so handle this case separately. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-5-luca@orpolo.org>
* 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-274-21/+7
| | | | Message-Id: <Yo+lzS7RtW5ZjQHN@debian>
* biosmem: Narrow e820 regions as requiredDamien Zammit2022-02-151-0/+28
| | | | Message-Id: <20220215064133.68593-1-damien@zamaudio.com>
* Convert from K&R to ANSIEtienne Brateau2022-01-213-41/+22
| | | | | | | | * hardclock.c: convert to ANSI * com.c: ditto * lpr.c: ditto * mem.c: ditto Message-Id: <20220120170004.21722-1-etienne.brateau@gmail.com>
* rtc: drop message on setting RTC timeSamuel Thibault2021-12-161-8/+0
| | | | | We haven't seen the 2032 bug for a long time, f040677be3c0 ("kd: Do not read the CMOS ram") probably fixed it at last.
* memmmap: Use biosmem_addr_available rather than vm_page_lookup_paSamuel Thibault2021-11-283-17/+25
| | | | | | | The segment code actually has vm_page entries for reserved pages, and thus memmmap would reject mapping ACPI pages. Taking the information from biosmem is much more precise, and indeed knows all hardware quirks which can now be dropped from memmmap.
* rtc: Add read/write messagesSamuel Thibault2021-04-051-1/+16
| | | | | | | | | | | We are still having issues with bogus dates. This adds prints at boot and time set, to make sure what we actually read and write. * i386/i386at/rtc.c: Include <kern/printf.h> (readtodc): Warning about reaching CENTURY_START. Print the time read from RTC. (writetodc): Record in RTC remainder of division of year by 100 rather than subtracting 1900. Print the time written to RTC.
* kd: Do not read the CMOS ramSamuel Thibault2021-04-052-3/+10
| | | | | | | This could conflict with read/writing the RTC. * i386/i386at/kd.c (kd_xga_init): Do not read the CRAM. We were always assuming VGA anyway.
* 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.
* ioapic: Fix arg passing of redirection entryDamien Zammit2021-04-051-6/+7
| | | | Message-Id: <20210405115921.184572-3-damien@zamaudio.com>
* ioapic: Refactor EOIDamien Zammit2021-04-052-1/+2
| | | | Message-Id: <20210405115921.184572-2-damien@zamaudio.com>
* ioapic: Use irq specific EOI properly when detectedDamien Zammit2021-04-051-8/+22
| | | | Message-Id: <20210405052916.174771-5-damien@zamaudio.com>
* Don't call EOI on spurious interruptsDamien Zammit2021-04-051-6/+3
| | | | Message-Id: <20210405052916.174771-4-damien@zamaudio.com>
* ioapic: target first processor for interruptsDamien Zammit2021-04-051-1/+2
| | | | Message-Id: <20210405052916.174771-3-damien@zamaudio.com>
* ioapic: Enable processor focus to BSPDamien Zammit2021-04-051-0/+3
| | | | Message-Id: <20210405052916.174771-2-damien@zamaudio.com>
* SMP: fix getting the interrupt stack address and sizeSamuel Thibault2021-04-041-0/+1
| | | | | | | * i386/i386at/boothdr.S (_eintstack): Add missing common. * i386/xen/xen_boothdr.S (_eintstack): Add missing common. * x86_64/xen/xen_boothdr.S (_eintstack): Add missing common. * i386/i386/mp_desc.c (intstack, eintstack): Add missing underscore.
* Add ioapic support disabled by defaultDamien Zammit2021-04-047-16/+464
| | | | | | | 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.
* pic: Move to interrupts 0x20-0x2fDamien Zammit2021-03-281-4/+2
| | | | | | * i386/i386/pic.h (PICM_VECTBASE): Set to 0x20. * i386/i386at/idt.h (IDTSZ): Set to 0x20 + 0x10. (PIC_INT_BASE): Set to 0x20.
* Existing SMP apic code improvementsDamien Zammit2021-03-282-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * i386/i386/apic.c (acpi_get_irq_override): New function. (apic_get_ioapic): Make it return IoApicData* rather than IoApicData. (apic_print_info): Manage IoApicData* rather than IoApicData. * i386/i386/apic.h (struct ApicReg): Use uint32_t instead of unsigned. (struct ioapic_route_entry): New structure. (union ioapic_route_entry_union): New union. (ApicLocalUnit): Rename base to gsi_base. Add ioapic field. (APIC_IRQ_OVERRIDE_POLARITY_MASK, APIC_IRQ_OVERRIDE_TRIGGER_MASK): New macros. (acpi_get_irq_override, ): New prototype. (apic_get_ioapic): Update prototype. (lapic): New declaration. (IMCR_SELECT, IMCR_DATA, MODE_IMCR, IMCR_USE_PIC, IMCR_USE_APIC, LAPIC_ENABLE, LAPIC_NMI, LAPIC_DISABLE, LAPIC_TIMER_PERIODIC, LAPIC_TIMER_DIVIDE_2, LAPIC_TIMER_DIVIDE_4, LAPIC_TIMER_DIVIDE_8, LAPIC_TIMER_DIVIDE_16, LAPIC_TIMER_BASEDIV, NINTR, IOAPIC_FIXED, IOAPIC_PHYSICAL, IOAPIC_LOGICAL, IOAPIC_NMI, IOAPIC_EXTINT, IOAPIC_ACTIVE_HIGH, IOAPIC_ACTIVE_LOW, IOAPIC_EDGE_TRIGGERED, IOAPIC_LEVEL_TRIGGERED, IOAPIC_MASK_ENABLED, IOAPIC_MASK_DISABLED): New macros. * i386/i386at/acpi_parse_apic.h (struct acpi_apic_ioapic): Rename base field to gsi_base. * i386/i386at/acpi_parse_apic.c (acpi_apic_add_ioapic): Update to gsi_base new name. Set ioapic field. (acpi_apic_setup): Rename lapic to lapic_unit. Message-Id: <20210328060320.36194-5-damien@zamaudio.com>
* Don't allow writing to acpi table in memoryDamien Zammit2021-03-281-1/+1
| | | | | | * i386/i386at/acpi_parse_apic.c (acpi_get_apic): Map rsdt entries read-only. Message-Id: <20210328060320.36194-4-damien@zamaudio.com>
* fixup acpi base table searchDamien Zammit2021-03-281-18/+12
| | | | | | | | | * i386/i386at/acpi_parse_apic.c (acpi_check_rsdp_align): Make it take a void* instead of uint32_t. (acpi_get_rsdp): Apply phystokv on the EBDA base and 0xE0000. (acpi_apic_setup): Drop spurious negation. Message-Id: <20210328060320.36194-3-damien@zamaudio.com>
* com: Fix bogus NCOM testAndrea G. Monaco2021-02-031-1/+1
| | | | * i386/i386at/com.c (comprobe_general): Reject unit being equal to NCOM.
* add a missing include header guard.guy fleury iteriteka2021-01-091-0/+5
| | | | | * i386/i386at/comreg.h: Add header guard angaist multiple inclusion. Message-Id: <20210109180149.11861-1-gfleury@disroot.org>
* i386at: Really disable com and lpr above NCOM and NLPRSamuel Thibault2020-12-072-0/+10
| | | | | | | commmodem and lprinfo arrays would otherwise overflow. * i386/i386at/com.c (comattach): Return early when unit is beyond NCOM. * i386/i386at/lpr.c (lprattach): Return early when unit is beyond NLPR.
* 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-192-5/+8
| | | | | | | | | | | | | | | | | | | | | | | * 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
* acpi parser: Fix build warningsSamuel Thibault2020-09-191-7/+5
|
* smp: Add APIC finder and parserAlmudena Garcia2020-09-192-0/+706
| | | | | | | | | | | To find the processors, It's necessary to find the APIC (MADT) table This table is found inside ACPI tables. This set of functions find the MADT table, and parse it to find the APIC structures and register it in the kernel. *acpi_parse_apic.h: ACPI structures and function prototypes. *acpi_parse_apic.c: ACPI/APIC function definitions.
* Add hardware interrupt notification mechanismSamuel Thibault2020-07-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 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.
* com: Fix 64bit warningsSamuel Thibault2020-03-291-6/+6
| | | | | * i386/i386at/com.c (comopen, comclose, comparam, comstart, comtimer): Cast tp->t_addr to uinptr_t instead of int.
* 64bit: Fix format warningsSamuel Thibault2020-03-291-2/+3
| | | | | * i386/i386at/biosmem.c: Include <inttypes.h> (biosmem_map_show, biosmem_load_segment): Use PRIx64.
* kdasm: Add 64bit variantSamuel Thibault2020-03-281-6/+6
| | | | | | * i386/i386at/kdasm.S (start, count, value, from, to): Use B_ARG* instead of reimplementing them. * x86_64/kdasm.S: New file.
* 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-093-5/+5
| | | | | | | | | 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.
* PIC: Acknowledge interrupts more carefullySamuel Thibault2019-11-111-7/+37
| | | | | | | | | Specs seems to be saying that we should mask an irq out while acknowledging it with EOI. Also, better acknowledge only the concerned irq. * i386/i386at/interrupt.S (interrupt): Mask irq before notifying EOI. Using specific EOI instead of unspecific EOI.
* spl: Remove intpri arraySamuel Thibault2019-11-103-18/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And simplify prtnull vs intnull vs linux_bad_intr. * i386/i386/ipl.h (intpri): Remove declaration * i386/i386/pic.c (prtnull_count): Remove variable. (prtnull): Remove function. * i386/i386/pic.h (prtnull): Remove declaration. * i386/i386at/autoconf.c (take_dev_irq, take_ctlr_irq): Use ivect instead of intpri to determine irq availability. Do not set intpri. * i386/i386at/pic_isa.c (ivect): Replace prtnull with intnull. (intpri): Remove array. * linux/dev/arch/i386/kernel/irq.c (linux_intr_pri): Remove variable. (linux_bad_intr): Remove function. (setup_x86_irq): Do not check intpri coherency. Do not set intpri. Set default ivect to intnull instead of linux_bad_intr. (probe_irq_on): Check ivect against intnull instead of linux_bad_intr. Do not set intpri. (probe_irq_off): Likewise. (reserve_mach_irqs): Do not check against prtnull. (old_clock_pri): Remove variable. (init_IRQ): Do not set intpri. Do not set ivect to linux_bad_intr. (restore_IRQ): Do not set ivect. * i386/i386/pit.c (clkstart): Do not set intpri. * i386/i386at/kd_mouse.c (kd_mouse_open, kd_mouse_close): Likewise. * linux/dev/drivers/block/genhd.c (device_setup): Do not set linux_intr_pri. * linux/dev/glue/block.c (init_partition, device_open): Likewise. * linux/dev/glue/net.c (device_open): Likewise. * linux/dev/glue/glue.h (linux_intr_pri, linux_bad_intr): Remove declarations.
* Run interrupt handlers at spl7Samuel Thibault2019-11-101-2/+1
| | | | | * i386/i386at/interrupt.S (interrupt): Call spl7 instead of the intpri-provided one.