aboutsummaryrefslogtreecommitdiff
path: root/device
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash at bootSamuel Thibault2023-08-281-5/+8
| | | | spl cannot be called before the clock is set up.
* kmsg: Fix concurrency against irqsSamuel Thibault2023-08-121-17/+18
| | | | by using simple_lock_irq.
* device: Convert io_done_list_lock to simple_lock_irqSamuel Thibault2023-08-121-12/+8
|
* tty: Convert t_lock to using simple_lock_irqSamuel Thibault2023-08-122-63/+37
|
* net_io: Fix long / int confusionSamuel Thibault2023-08-081-5/+5
| | | | In network terms, long is 32bit, i.e. an int for us.
* intr: Fix crash on irq notification port destructionSamuel Thibault2023-06-121-1/+8
| | | | | When the Linux IRQ driver is used we don't really control the list, so we end up with a small leak.
* x86_64: enable code for managing interruptsLuca Dariz2023-05-261-6/+6
| | | | | | * 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>
* Improve portability for device/net_io.c and use designated initializersFlavio Cruz2023-05-051-15/+17
| | | | Message-Id: <ZFMz+B3dsMAWl3hM@jupiter.tail36e24.ts.net>
* Use c_string for dev_name_t in the device subsystem.Flavio Cruz2023-04-291-0/+8
| | | | | | | | | | | | 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>
* intr: Simplify clearing after intr port deallocationSamuel Thibault2023-02-161-35/+21
| | | | | This notably avoids calling ipc_port_release from the interrupt handler, which was completely unsafe.
* Document spl levels of locks taken during interruptsSamuel Thibault2023-02-153-2/+5
|
* slock: Fix initialization of statically-allocated slocksSamuel Thibault2023-02-085-12/+9
| | | | (this is actually a no-op for i386)
* dev_pager.c: use mach_msg_type_number_tFlavio Cruz2023-01-251-1/+1
| | | | | Otherwise it will fail to compile due to conflicting types. Message-Id: <Y89jA/6y4BgKW2Jb@jupiter.tail36e24.ts.net>
* Fix several warnings for -Wmissing-prototypesFlavio Cruz2023-01-242-47/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-194-26/+19
| | | | Message-Id: <Y8mYd/pt/og4Tj5I@mercury.tail36e24.ts.net>
* Include mig generated device headers to avoid missing prototypesFlavio Cruz2023-01-196-13/+15
| | | | | | Some of the existing definitions lacked the const qualifier, which was added. Message-Id: <Y8mYZEKqWN43n2SA@mercury.tail36e24.ts.net>
* update writev syscall signature with rpc typesLuca Dariz2023-01-183-17/+21
| | | | | | | | | | * 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>
* add missing argument namesLuca Dariz2023-01-161-3/+3
| | | | | | | | | | | | | | | * 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>
* Fix some warnings with -Wmissing-prototypes.Flavio Cruz2022-12-2711-75/+32
| | | | | | | | | | | 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>
* Use -Wstrict-prototypes and fix warningsFlavio Cruz2022-12-218-68/+25
| | | | | | | 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>
* Use long_natural_t for recnum_tFlavio Cruz2022-12-181-1/+1
| | | | | | | | | | | | 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>
* Define vm_size_t and vm_offset_t as __mach_uintptr_t.Flavio Cruz2022-12-061-1/+1
| | | | | | | | | | 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>
* fix warnings for 32 bit buildsLuca Dariz2022-08-271-2/+2
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
* dev_pager.c: fix wrong condition to remove entriesJoan Lledó2022-08-091-2/+2
| | | | | | | * 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
* device intr: Return an error on bogus intr portSamuel Thibault2022-03-131-3/+5
| | | | Rather than risking dereferencing NULL.
* device intr: Fix hypothetical NULL dererefenceSamuel Thibault2022-03-131-1/+1
|
* device: Fix NULL dereferenceSamuel Thibault2022-03-131-2/+6
|
* device: Avoid NULL dereferenceSamuel Thibault2022-03-131-1/+1
|
* device_map_page: update prototypeSamuel Thibault2022-02-181-1/+1
|
* vm_object: Fix vm_object_page_map map function prototypeSamuel Thibault2022-02-161-1/+1
| | | | The map function is supposed to return physical addresses, thus phys_addr_t.
* Convert from K&R to ANSIEtienne Brateau2021-12-302-22/+8
| | | | | | * 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>
* Fix rejecting the mapping of some pagesSamuel Thibault2021-11-281-6/+20
| | | | | | 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.
* Drop unused device_pager_releaseSamuel Thibault2021-11-071-13/+0
| | | | * device/dev_pager.c (device_pager_release): Drop unused function.
* dev_pager: rename hash macrosJoan Lledó2021-08-281-13/+13
| | | | | | | | | | 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>
* dev_pager: implement offsetJoan Lledó2021-08-281-5/+110
| | | | | | | | | | | | | | * 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>
* SMP: Fix warningsSamuel Thibault2021-04-041-2/+2
|
* intr: Always share irqsSamuel Thibault2021-03-311-0/+2
| | | | | | We currently already always assume that irqs user handlers can be shared * device/intr.c (install_user_intr_handler): Add SA_SHIRQ to flags.
* intr: Add user interrupt handling code for non-Linux caseDamien Zammit2021-03-311-0/+80
| | | | | | | | | | * 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>
* device_pager_setup: Add FIXME commentSamuel Thibault2020-09-101-0/+1
|
* device intr: Fix reference leakSamuel Thibault2020-07-191-1/+7
| | | | | | | | On RPC success we have to release the passed send rights, otherwise references accumulate and we never notice when the receiver dies. * device/ds_routines.c (ds_device_intr_ack): On success, call ipc_port_release_send on the notification receive port.
* intr_register: better document how we'd handle crashesSamuel Thibault2020-07-191-3/+2
|
* 64bit: fix buildSamuel Thibault2020-07-181-6/+6
| | | | | | | * device/ds_routines.c (ds_device_intr_register, ds_device_intr_ack) [__x86_64__]: Disable. * x86_64/Makefrag.am (libkernel_a_SOURCES): Add i386/i386/irq.c and i386/i386/irq.h.
* Fix xen buildSamuel Thibault2020-07-151-0/+8
| | | | | | | | * device/ds_routines.c (ds_device_intr_register, ds_device_intr_ack) [MACH_XEN]: Return D_INVALID_OPERATION. * i386/Makefrag.am [!PLATFORM_at] (libkernel_a_SOURCES): Remove i386/i386/irq.c and i386/i386/irq.h. * i386/i386/irq.c: Include <kern/assert.h>.
* Add hardware interrupt notification mechanismSamuel Thibault2020-07-104-0/+408
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix build with -fno-commonSamuel Thibault2020-03-313-2/+3
| | | | | | | | | | | | | | | | which will be the default in gcc-10. * device/io_req.h (io_inband_cache): Add extern qualifier. * device/tty.h (tthiwat, ttlowat): Likewise. * i386/i386/db_machdep.h (ddb_regs): Likewise. * kern/cpu_number.h (master_cpu): Likewise. * kern/time_stamp.h (ts_tick_count): Likewise. * linux/src/drivers/scsi/in2000.h (proc_scsi_in2000): Likewise. * device/ds_routines.c (io_inband_cache): New variable. * i386/i386/db_interface.c (ddb_regs): Likewise. * kern/processor.c (master_cpu): Likewise. * kern/time_stamp.c (ts_tick_count): Likewise. * linux/pcmcia-cs/modules/pci_fixup.c (pci_root): Remove variable.
* 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-292-0/+13
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* device: Fix d_mmap typeSamuel Thibault2018-07-284-6/+6
| | | | | | | | | | | | | | | * 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 dev_ops typesSamuel Thibault2018-07-289-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * device/conf.h: Include <device/device_types.h>. (dev_ops): Make d_getstat and d_setstat fields use dev_flavor_t, dev_status_t, and mach_msg_type_number_t types. * device/tty.h: (t_getstat, t_setstat): Likewise. * device/conf.h (nulldev_getstat, nulldev_setstat): Fix parameter types accordingly. * device/dev_name.c (nulldev_getstat, nulldev_setstat): Likewise. * device/kmsg.c (kmsggetstat): Likewise. * device/kmsg.h (kmsggetstat): Likewise. * device/net_io.c (net_getstat): Likewise. * device/net_io.h (net_getstat): Likewise. * i386/i386at/com.c (comgetstat, comsetstat): Likewise. * i386/i386at/com.h (comgetstat, comsetstat): Likewise. * i386/i386at/kd.c (kdgetstat, kdsetstat): Likewise. * i386/i386at/kd.h (kdgetstat, kdsetstat): Likewise. * i386/i386at/kd_event.c (kbdgetstat, kbdsetstat): Likewise. * i386/i386at/kd_event.h (kbdgetstat, kbdsetstat): Likewise. * i386/i386at/kd_mouse.c (mousegetstat): Likewise. * i386/i386at/kd_mouse.h (mousegetstat): Likewise. * i386/i386at/lpr.c (lprgetstat, lprsetstat): Likewise. * i386/i386at/lpr.h (lprgetstat, lprsetstat): Likewise. * xen/console.c (hypcngetstat, hypcnsetstat): Likewise. * xen/console.h (hypcngetstat, hypcnsetstat): Likewise. * device/dev_hdr.h: Forward-declare struct dev_ops and dev_ops_t type instead of including <device/conf.h>. * device/dev_pager.c: Include <device/conf.h> * i386/i386/pcb.h: Include <machine/io_perm.h> * i386/i386/thread.h: Do not include <i386/tss.h>