summaryrefslogtreecommitdiff
path: root/device
AgeCommit message (Collapse)Author
2025-07-19interrupt.S: Change interrupt EOI strategyDamien Zammit
We now have a different strategy for EOI depending on trigger mode: For edge triggered, the behaviour is unchanged; the eoi comes before the handler so we don't miss interrupts. For level triggered, the eoi comes after the handler since the high interrupt line will trigger the interrupt again and stack up, before we mask it in queue_intr (and we don't risk missing interrupts). Message-ID: <20250719074547.288203-1-damien@zamaudio.com>
2025-07-16irq: Print process name on irq handler setupSamuel Thibault
2025-02-12Use MACRO_BEGIN/ENDSamuel Thibault
This notably fixes at least a SAVE_HINT call.
2025-02-08Add names to kernel tasks and threadsSamuel Thibault
2024-12-24irq: make device_intr_register reject bogus intr idSamuel Thibault
2024-12-23intr: Note which interrupt is being refused to userlandSamuel Thibault
2024-12-10intr: Protect internals with a lockSergey Bugaev
On SMP builds with 2 CPU cores, we've seen whole-system lock-ups caused by irqdev.tot_num_intr getting set to -1, even though it's supposed to always stay non-negative. Indeed, it was modified without the appropriate synchronization. Fix this by protecting it, as well as various other internals of device/intr with a simple_lock_irq. Reported-by: Damien Zammit <damien@zamaudio.com> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20241210115705.710555-3-bugaevc@gmail.com>
2024-11-24device/intr: Account for interrupts that could not be deliveredDamien Zammit via Bug reports for the GNU Hurd
When an irq handler dies, we are decrementing the n_unacked count and calling __enable_irq() the right number of times, but we need to decrement the total interrupt count by the number that were lost and also clear that number. This fixes a hang when a shared irq handler quits and leaves some unacked interrupts. Message-ID: <20241123222020.245519-1-damien@zamaudio.com>
2024-03-15Do not install device/input.hSamuel Thibault
Is _IO{,R,W,WR} macros conflict with the glibc-provided macros and bring confusion as to what is supposed to be the right definition. There is currently no user of it anyway, the Hurd console driver has its own copy.
2024-03-09remove machine/machspl.h as it duplicates machine/spl.hLD
Message-ID: <20240309140244.347835-2-luca@orpolo.org>
2024-02-12Replace kernel header includes in include/mach/mach_types.h with forward ↵Flavio Cruz
declarations. I was trying to reuse TASK_NAME_SIZE in kern/thread.h but it was impossible because files included from kern/task.h end up requiring kern/thread.h (through percpu.h), creating a recursive dependency. With this change, mach_types.h only defines forward declarations and modules have to explicitly include the appropriate header file if they want to be able touch those structures. Most of the other includes are required because we no longer grab many different includes through mach_types.h. Message-ID: <20240212062634.1082207-1-flaviocruz@gmail.com>
2023-10-03Fix interrupt handlingDamien Zammit
Logic for interrupts: - interrupt.S raises spl (thus IF cleared) - interrupt.S EOI - interrupt.S calls the handler - for pure in-kernel handlers, they do whatever they want with IF cleared. - when a userland handler is registers, queue_intr masks the irq. - interrupt.S lowers spl with splx_cli, thus IF still cleared - iret, that sets IF - later on, userland acks the IRQ, that unmasks the irq The key to this change is that all interrupts, including IPIs, are treated the same way. Eg. the spl level is now raised before an IPI and restored after. Also, EOI is not needed inside irq_acknowledge. With this change and the experimental change not to dispatch threads direct to idle processors in the scheduler, I no longer observe kernel faults, but an occasional hang does occur. Message-Id: <20231002033906.124427-1-damien@zamaudio.com>
2023-08-28Fix crash at bootSamuel Thibault
spl cannot be called before the clock is set up.
2023-08-12kmsg: Fix concurrency against irqsSamuel Thibault
by using simple_lock_irq.
2023-08-12device: Convert io_done_list_lock to simple_lock_irqSamuel Thibault
2023-08-12tty: Convert t_lock to using simple_lock_irqSamuel Thibault
2023-08-08net_io: Fix long / int confusionSamuel Thibault
In network terms, long is 32bit, i.e. an int for us.
2023-06-12intr: Fix crash on irq notification port destructionSamuel Thibault
When the Linux IRQ driver is used we don't really control the list, so we end up with a small leak.
2023-05-26x86_64: enable code for managing interruptsLuca Dariz
* device/ds_routines.c: enable interrupt registration and acknowledge for x86_64. We can reuse the 32-bit mechanisms. Message-Id: <20230526184801.753581-3-luca@orpolo.org>
2023-05-05Improve portability for device/net_io.c and use designated initializersFlavio Cruz
Message-Id: <ZFMz+B3dsMAWl3hM@jupiter.tail36e24.ts.net>
2023-04-29Use c_string for dev_name_t in the device subsystem.Flavio Cruz
Added device_open_new and device_open_new_request and reused the old MiG ID for xxx_device_set_status which has not been in used in the past decade. Note that device_open_new is gated on defining DEVICE_ENABLE_DEVICE_OPEN_NEW because otherwise some hurd servers wouldn't compile anymore unless patched. This macro allows us to control the rollout. Message-Id: <ZEi1LV+9ShuXqtcr@jupiter.tail36e24.ts.net>
2023-02-16intr: Simplify clearing after intr port deallocationSamuel Thibault
This notably avoids calling ipc_port_release from the interrupt handler, which was completely unsafe.
2023-02-15Document spl levels of locks taken during interruptsSamuel Thibault
2023-02-08slock: Fix initialization of statically-allocated slocksSamuel Thibault
(this is actually a no-op for i386)
2023-01-25dev_pager.c: use mach_msg_type_number_tFlavio Cruz
Otherwise it will fail to compile due to conflicting types. Message-Id: <Y89jA/6y4BgKW2Jb@jupiter.tail36e24.ts.net>
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-19Remove existing old style definitions and use -Wold-style-definition.Flavio Cruz
Message-Id: <Y8mYd/pt/og4Tj5I@mercury.tail36e24.ts.net>
2023-01-19Include mig generated device headers to avoid missing prototypesFlavio Cruz
Some of the existing definitions lacked the const qualifier, which was added. Message-Id: <Y8mYZEKqWN43n2SA@mercury.tail36e24.ts.net>
2023-01-18update writev syscall signature with rpc typesLuca Dariz
* device/device_emul.h: write/writev: update trap argument types * device/ds_routines.c: update argument types and adjust copyin * device/ds_routines.h: write/writev: update trap argument type * include/device/device_types.h: add rpc_io_buf_vec_t type * kern/ipc_mig.c: write/writev: update trap argument type * kern/ipc_mig.h: Likewise Message-Id: <20230116105857.240210-5-luca@orpolo.org>
2023-01-16add missing argument namesLuca Dariz
* ddb/db_break.c: add argument name, compilation fails on Debian/Linux stable with gcc 10.2 otherwise. For some reason on Debian/Hurd a simple test program without argname succeeds, unless I force -std=c11 or similar; I suppose because newer gcc have different defaults. Gnumach seem to still require c89 for some older code, otherwise we could explicitely use gnu99/c99 or gnu11/c11. * ddb/db_cond.c: Likewise * ddb/db_examine.c: Likewise * ddb/db_macro.c: Likewise * ddb/db_watch.c: Likewise * device/dev_name.c: Likewise Message-Id: <20230116130426.246584-1-luca@orpolo.org>
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-12-21Use -Wstrict-prototypes and fix warningsFlavio Cruz
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>
2022-12-18Use long_natural_t for recnum_tFlavio Cruz
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>
2022-12-06Define vm_size_t and vm_offset_t as __mach_uintptr_t.Flavio Cruz
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>
2022-08-27fix warnings for 32 bit buildsLuca Dariz
Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
2022-08-09dev_pager.c: fix wrong condition to remove entriesJoan Lledó
* device/dev_pager.c: * dev_pager_hash_delete() and dev_device_hash_delete(): * Fix condition to call kmem_cache_free(), it was being called always. * https://lists.gnu.org/archive/html/bug-hurd/2022-08/msg00002.html
2022-03-13device intr: Return an error on bogus intr portSamuel Thibault
Rather than risking dereferencing NULL.
2022-03-13device intr: Fix hypothetical NULL dererefenceSamuel Thibault
2022-03-13device: Fix NULL dereferenceSamuel Thibault
2022-03-13device: Avoid NULL dereferenceSamuel Thibault
2022-02-18device_map_page: update prototypeSamuel Thibault
2022-02-16vm_object: Fix vm_object_page_map map function prototypeSamuel Thibault
The map function is supposed to return physical addresses, thus phys_addr_t.
2021-12-30Convert from K&R to ANSIv1.8+git202112301.8+git20211230Etienne Brateau
* device/dev_name.c: Convert function prototypes from K&R to ANSI. * device/subr.c: Convert function prototypes from K&R to ANSI. Message-Id: <20211230112249.13682-2-etienne.brateau@gmail.com>
2021-11-28Fix rejecting the mapping of some pagesSamuel Thibault
The memmmap method may reject some offsets (because it falls in non-device ranges), so device_map_page has to notice this and report the error. device_pager_data_request then has to notice as well and report.
2021-11-07Drop unused device_pager_releaseSamuel Thibault
* device/dev_pager.c (device_pager_release): Drop unused function.
2021-08-28dev_pager: rename hash macrosJoan Lledó
Remove the reference to the pager hash since they are used both in the pager and the device hashes. * device/dev_pager.c: * Rename DEV_PAGER_HASH_COUNT to DEV_HASH_COUNT * Rename dev_pager_hash to dev_hash Message-Id: <20210828100252.18376-3-jlledom@mailfence.com>
2021-08-28dev_pager: implement offsetJoan Lledó
* device/dev_pager.c: * struct dev_pager: add offset field * new struct dev_device_entry: includes device and offset * new hash table dev_device_hashtable * index [device + offset] * new functions dev_device_hash[init,insert,delete,lookup] * do the same as their counterparts for dev_pager_hashtable * dev_pager_setup(): record the offset * device_map_page(): add the recorded offset on the fly Message-Id: <20210828100252.18376-2-jlledom@mailfence.com>
2021-04-04SMP: Fix warningsSamuel Thibault
2021-03-31intr: Always share irqsSamuel Thibault
We currently already always assume that irqs user handlers can be shared * device/intr.c (install_user_intr_handler): Add SA_SHIRQ to flags.
2021-03-31intr: Add user interrupt handling code for non-Linux caseDamien Zammit
* device/intr.c: Include <kern/assert.h> (struct intr_list): New structure. (user_intr_handlers): New array. (user_irq_handler): New function. (install_user_intr_handler): New function. Message-Id: <20210330025830.63528-2-damien@zamaudio.com>