aboutsummaryrefslogtreecommitdiff
path: root/i386
Commit message (Collapse)AuthorAgeFilesLines
* Fix several warnings for -Wmissing-prototypesFlavio Cruz2023-01-2415-266/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Remove existing old style definitions and use -Wold-style-definition.Flavio Cruz2023-01-192-18/+7
| | | | Message-Id: <Y8mYd/pt/og4Tj5I@mercury.tail36e24.ts.net>
* Fix i386 PAE bootSamuel Thibault2023-01-191-3/+6
|
* x86_64: expand and shrink messages in copy{in, out}msg routinesLuca Dariz2023-01-181-0/+102
| | | | | | | | | | | | | | | | | | | * i386/i386/copy_user.h: new file to handle 32/64 bit differences - add msg_usize() to recontruct the user-space message size - add copyin/copyout helpers for addresses and ports * include/mach/message.h: add msg alignment macros * ipc/ipc_kmsg.c: - copyin/out ports names instead of using pointer magic * ipc/ipc_mqueue.c: use msg_usize() to check if we can actually receive the message * ipc/mach_msg.c: Likewise for continuations in receive path * x86_64/Makefrag.am: add x86_64/copy_user.c * x86_64/copy_user.c: new file to handle message expansion and shrinking during copyinmsg/copyoutmsg for 64 bit kernels. - port names -> port pointers on all 64-bit builds - 32-bit pointer -> 64 bit pointer when using 32-bit userspace * x86_64/locore.S: remove copyinmsg() and copyoutmsg() Message-Id: <20230116105857.240210-3-luca@orpolo.org>
* Delete x86 string functionsFlavio Cruz2023-01-181-54/+0
| | | | | | The i386 functions are not used and the more portable versions in kern/strings.c are faster (1-4x faster in synthetic benchmarks compiled with -O2 on my x86_64 box). Message-Id: <Y8Yt9FvIagB78uyR@jupiter.tail36e24.ts.net>
* Fix build for smpEtienne Brateau2023-01-131-1/+1
| | | | | | ad51c68171cb6a1cae15c61ca0218bbee2c05485 missed one replacement which was not discovered because it’s only when building with smp enabled. Message-Id: <20230113144732.49786-1-etienne.brateau@gmail.com>
* Use rpc_uintptr_t for protected payloads.Flavio Cruz2023-01-131-0/+2
| | | | | | | Not only is uintptr_t more accurate for what protected payloads are but we also provide compatibility for 64 + 32 bits. Also the use of natural_t in the RPC definition is wrong since it is always 32 bits. Message-Id: <Y7+LHVbmYxO/cSKs@jupiter.tail36e24.ts.net>
* Export input structures used by Hurd in device/input.h.Flavio Cruz2023-01-091-59/+1
| | | | | | Also delete sys/ioctl.h and merge it with device/input.h since it is only needed here. Message-Id: <Y7uirJzaJeOBzAmq@jupiter.tail36e24.ts.net>
* Fix warning at pic_isa.cFlavio Cruz2023-01-071-2/+2
| | | | Message-Id: <Y7exFz3ZkK6hLVdi@jupiter.tail36e24.ts.net>
* Fix ddb warnings introduced with -Wstrict-prototypesFlavio Cruz2023-01-051-2/+1
| | | | | | | 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-038-16/+20
| | | | | | | | | | | | 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-2712-54/+27
| | | | | | | | | | | 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 hardclock prototypeSamuel Thibault2022-12-271-1/+0
|
* intr: Drop irq parameterSamuel Thibault2022-12-243-16/+11
| | | | This is not actually used.
* Xen: Fix warningSamuel Thibault2022-12-241-1/+1
|
* Use -Wstrict-prototypes and fix warningsFlavio Cruz2022-12-219-63/+57
| | | | | | | 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>
* Remove custom stdint.h and rely on freestanding headersFlavio Cruz2022-12-195-74/+20
| | | | | GCC already provides this so we don't need to have our own. Message-Id: <Y5+02FVA6jf4GPgA@mars>
* Use long_natural_t for recnum_tFlavio Cruz2022-12-182-21/+52
| | | | | | | | | | | | For 64 bits, device operations will provide an addressing space of 64 bits. Also define the translation functions if long_natural_t or long_integer_t are ever used in RPCs. Note that MIG does not implicitly inherit the translation functions from types hence the need to redefine them for recnum_t. Message-Id: <Y59MFzekEA0YUXIw@mars>
* Use struct for time_value_t and define seconds as long_integer_t.Flavio Cruz2022-12-172-2/+22
| | | | | | | On 64 bit kernels, seconds will be 64 bits long and won't suffer from the 2038 problem. We also add a new type rpc_time_value_t to handle the conversion between 32 bit userland and 64 bit kernel. Message-Id: <Y50kIaIgaIdGjDAk@mars>
* Fix compiler warnings due to use of inline for mask_irq/unmask_irqFlavio Cruz2022-12-174-18/+16
| | | | Message-Id: <Y5z01C/L+pnSVNIP@mars>
* copy_to/from_phys: fix non-page-aligned caseSamuel Thibault2022-12-121-2/+2
| | | | | | | | The vaddr field of the returned map only points to the base address, we have to add the offset within the page before reading/writing. This fixes accessing tasks different from the current task, and the user part of ddb backtraces.
* i386 db: Fix db_read_bytes over multiple pagesSamuel Thibault2022-12-111-0/+1
| | | | The target pointer was not getting advanced between page chunks.
* i386 db: Add ud2 instructionSamuel Thibault2022-12-111-1/+1
|
* Define vm_size_t and vm_offset_t as __mach_uintptr_t.Flavio Cruz2022-12-066-12/+12
| | | | | | | | | | 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>
* Make task_info.h structs more portableFlavio Cruz2022-12-062-29/+32
| | | | | | | | | | Changed vm_size_t to rpc_size_t so that both userland and kernel agree on the same size. Also changed the denominator for the maximum struct sizes to be integer_t to match the other declarations. Introduced long_natural_t and rpc_long_natural_t to represent large counters. Replaced rpc_unsigned_long with rpc_long_natural_t. Message-Id: <Y47UhaOzKnqhgYq4@reue>
* task: Add task_set_essentialSamuel Thibault2022-12-031-2/+3
| | | | | | | | 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 kdb_kintr according to new interrupt stack layoutSamuel Thibault2022-11-272-4/+12
| | | | | | | | e2fcf261076b ("interrupt: Fix saving irq/ipl when linux drivers are disabled") changed the stack layout for interrupt handlers, but missed updating kdb_kintr's code that tries to mangle it. This restores the control-alt-d shortcut.
* Update mach_debug interfaces to use struct.Flavio Cruz2022-11-252-0/+16
| | | | | | | | | | | | | | | | | | | | | | The new interfaces will be compatible both with a 64 bits kernel and userland and 64 bits kernel and 32 bit userland. Also removed many of the uses of natural_t where an unsigned int suffices. Ideally we should replace natural_t with something more portable such as uintptr_t or a basic int type for counters since for the most part we don't need counters to have the same width as the pointer type. * i386/include/mach/i386/vm_types.h: Define rpc_unsigned_long. * include/mach/mach_types.defs: Define type rpc_vm_offset_t. * include/mach_debug/hash_info.h: Use unsigned int instead of natural_t. * include/mach_debug/mach_debug_types.defs: Update cache_info_t, hash_info_bucket_t, vm_region_info_t, vm_object_info_t and vm_page_info_t to use struct. * include/mach_debug/slab_info.h: Use rpc_vm_size_t and rpc_unsigned_long for compatibility with 32 bits userland. * include/mach_debug/vm_info.h: Update struct fields to use the correct types and avoid natural_t whenever we just want to keep a count of something. Message-Id: <Y32lp1SuV01ImCx9@viriathus>
* 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.
* i386/pit: Tune delaysDamien Zammit2022-10-262-4/+22
| | | | | | | - Add half a clock tick for more accuracy - Start the pit countdown during pit_sleep - Add pit_mdelay and pit_udelay functions Message-Id: <20221025105502.222708-8-damien@zamaudio.com>
* 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>
* proc_reg: Fix pushf/popfSamuel Thibault2022-10-251-6/+6
|
* kdb: Fix TODO for multiprocessorDamien Zammit2022-10-251-1/+3
| | | | Message-Id: <20221025105502.222708-2-damien@zamaudio.com>
* Fix when enabling APIC without SMPEtienne Brateau2022-09-262-10/+10
| | | | | | 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>
* x86_64: ignore warningSamuel Thibault2022-09-181-0/+1
|
* 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
|
* x86_64: fix warningSamuel Thibault2022-09-171-2/+2
|
* copyinmsg: Set msgh_size inside copyinmsg rather than the callerSamuel Thibault2022-08-282-0/+6
| | | | | In the 32/64 conversion case it is copyinmsg that will know the eventual size.
* Fix inclusability of <mach/mach_types.h>Samuel Thibault2022-08-283-8/+64
| | | | | Now that mach/machine/vm_types.h uses stdint types, we have to ship a header that defines them.
* add rpc_versions for vm typesLuca Dariz2022-08-271-4/+33
| | | | | | | | | | | | | | | * vm_types.h: add new types and conversion functions * mach_types.defs: adapt vm types depending on kernel user/server * vm_info.h: adapt rpc structure to have uniformly-sized members also on 64-bit * x86_64/configfrag.c: add new option to select the user-space variant. Note that with this change the user-space interface is somehow fixed, i.e. it can't support 32-bit and 64-bit tasks at the same time. If this would be needed at some point, this change needs to be reworked. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220403145955.120742-3-luca@orpolo.org>
* fix warnings for 32 bit buildsLuca Dariz2022-08-273-1/+3
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
* x86_64: fix exception stack alignmentLuca Dariz2022-08-273-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * i386/i386/pcb.c: - increase alignment of pcb cache to 16 - ensure the stack is properly aligned when switching ktss * i386/i386/thread.h: - add padding tomake iss field end aligned to 16 bytes * i386/i386/trap.c: - ensure the state we get after the trap points to the correct place in the pcb structure When handling exceptions from IA-32e compatibility mode in user space, on a 64-bit kernel, the exception stack where error info is pushed needs to be aligned to 16 bytes (see Intel System Programming guide, $6.14.2) The exception stack frame is set in the middle of pcb->iss, but it's not always 16-byte aligned; to make sure it is, we increase the alignment of the pcb cache and add a padding field in the pcb structure. This issue resulted in a general protection failure due to CS being corrupted after a page fault. The corruption was happening when the exception stack frame was not properly aligned and a page fault happened; the error info was then pushed after re-aligning the stack, so the value of eflags was actually written in CS place and other fields were shifted too. It also makes sense to ensure this by adding two assertions, although these were primarly useful during debug. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-10-luca@orpolo.org>
* fix Task State Segment layout for 64 bitLuca Dariz2022-08-274-3/+36
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-7-luca@orpolo.org>
* enable user accessLuca Dariz2022-08-271-2/+2
| | | | | | | | The pmap module is a bit limited on 64 bit paging, so this should be refined when we'll be able to use addresses over 4G. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-6-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-272-119/+14
| | | | | | | | | * 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>
* add support for booting from grub with x86_64Luca Dariz2022-08-275-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | * configure: compile for native x86_64 by default instead of xen * x86_64/Makefrag.am: introduce KERNEL_MAP_BASE to reuse the constant in both code and linker script * x86_64/ldscript: use a .boot section for the very first operations, until we reach long mode. This section is not really allocated, so it doesn't need to be freed later. The vm system is later initialized starting from .text and not including .boot * link kernel at 0x4000000 as the xen version, higher values causes linker errors * we can't use full segmentation in long mode, so we need to create a temporary mapping during early boot to be able to jump to high addresses * build direct map for first 4G in boothdr, it seems required by Linux drivers * add INTEL_PTE_PS bit definition to enable 2MB pages during bootstrap * ensure write bit is set in PDP entry access rights. This only applies to PAE-enabled kernels, mandatory for x86_64. On xen platform it seems to be handled differently Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-2-luca@orpolo.org>
* gnumach: Remove PCI_CFG2_* as a reserved ioport rangeDamien Zammit2022-08-231-4/+1
| | | | | | | | | | | | | PCI CONF2 access method was deprecated in PCI v2.0 Also, the conf2 ioport range is only activated for use as pci configuration space when conf1 registers are accessed in a particular sequence. Since the pci-arbiter does not access the conf1 forwarding register, we are safe to remove this completely from gnumach to allow normal I/O use of the conf2 range as modern hardware expects. Message-Id: <20220823032638.292813-1-damien@zamaudio.com>