1. 13 Sep, 2021 1 commit
  2. 05 Jul, 2021 4 commits
    • Jan Kiszka's avatar
      cobalt/posix/io: Unify native and compat versions of select · c4c2fc21
      Jan Kiszka authored
      Rather than duplicating lots of code for the sake of compat userspace
      accesses, provide a common version that is given a flag to decide
      whether to take the compat or regular code paths.
      
      This also brings restart support to the compat selection version which
      was forgotten by 36132cdb
      
      .
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      c4c2fc21
    • Jan Kiszka's avatar
      cobalt/select: Add proper handling of EADV · ef3dd5c0
      Jan Kiszka authored
      Since rtdm_fd_select started to return EADV for unknown fds
      (2db562ad
      
      ), we were returning that code to applications in case a
      selector had been allocated for the caller already. That was because
      libcobalt lacked handling of this error.
      
      This fixes it and also establish proper signaling of EBADF in case the
      is a real error related to an RTDM fd. For that purpose, detect if
      __cobalt_select_bind_all got EADV for the first fd or for a succeeding
      one, i.e. on an unsupported mixed fd set.
      
      Also return EADV if the early __cobalt_first_fd_valid_p test fails. That
      ensures that we only retry with the regular Linux call when it makes
      sense.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      ef3dd5c0
    • Jan Kiszka's avatar
      cobalt/posix/io: Avoid err variable shadowing · b2729f9f
      Jan Kiszka authored
      
      
      It worked, but it is not nice to read.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      b2729f9f
    • Jan Kiszka's avatar
      cobalt/posix/io: Remove unneeded special case of select_bind_one · 50c0367d
      Jan Kiszka authored
      Already at the time of introduction (8ac3db81
      
      ), -ENOENT was not
      returned by any sane function behind rtdm_fd_select(). Today
      rtdm_fd_select() officially only returns -EBADF or -EINVAL. By now it
      also returns -EADV, via rtdm_fd_get() or a default select handler. The
      only remaining possibility for -ENOENT is a select handler. In-tree,
      a4l_rt_select actually has such a case, but for no sane reason this or
      any out-of-tree driver case should receive special handling here.
      
      Remove this case, these is also no need for the select_bind_one wrapper
      anymore.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      50c0367d
  3. 05 May, 2021 1 commit
  4. 08 Mar, 2021 1 commit
  5. 06 Dec, 2018 1 commit
  6. 03 Jul, 2018 1 commit
  7. 26 Jan, 2018 1 commit
  8. 27 Dec, 2016 1 commit
    • Jan Kiszka's avatar
      cobalt/kernel: Allow to restart clock_nanosleep and select after signal processing · 36132cdb
      Jan Kiszka authored and Philippe Gerum's avatar Philippe Gerum committed
      
      
      Only if a signal was actually delivered to a thread that was blocked on
      sleep, [clock_]nanosleep or select, those calls should return -EINTR.
      Otherwise, they should resume with the timeout, accordingly adjusted in
      case of relative timeout. So far we returned -EINTR immediately which
      particularly disturbed the debugging of applications (SIGSTOP/CONT
      terminated those syscalls).
      
      This approach reuses the Linux restart mechanism to find out if those
      syscalls should be restarted or actually terminated after the signal
      was handled: Linux sets current->restart_block.fn in case a termination
      is required, unconditionally, thus also when the syscall did not return
      ERESTART_RESTARTBLOCK. We also use the restart_block.nanosleep.expires
      to transfer the remaining timeout to the restarted syscall.
      
      We can't use the original restart mechanism of Linux because it directs
      all ERESTART_RESTARTBLOCK through a special, Linux-only syscall. In our
      case, we would have to migrate the caller in that context to primary in
      order to resume the sleep, but this is not possible under Xenomai (we
      need to migration from within the syscall hooks).
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      36132cdb
  9. 15 Jul, 2016 1 commit
    • Philippe Gerum's avatar
      cobalt/rtdm: leave mode selection to I/O syscall handlers · a96a6d8e
      Philippe Gerum authored
      We don't want requests bearing invalid file descriptors (RTDM-wise) to
      trigger any mode switch, so that RTDM requests on regular fildes can
      be rejected with little overhead.
      
      Tell the core to hand over mode selection to RTDM I/O syscall
      handlers, which now check the file descriptor prior to triggering any
      mode transition.
      a96a6d8e
  10. 10 Nov, 2015 1 commit
  11. 18 Feb, 2015 1 commit
    • Philippe Gerum's avatar
      cobalt/kernel: sanitize usage of internal copy_to/from helpers · cc47a310
      Philippe Gerum authored
      Unless explicitly paired with access_w/rok() checks, all copy to/from
      helpers should implement the safe form, testing for the basic sanity
      of the address range.
      
      cobalt_copy_to/from_user() implement the safe call form in replacement
      of __xn_safe_copy_to/from_user(). __xn_copy_to/from_user() still
      implement the unchecked variant, assuming the address range will be
      checked separately.
      
      Drivers should stick with the rtdm_copy_to/from_user() helpers.
      cc47a310
  12. 13 Feb, 2015 1 commit
  13. 30 Oct, 2014 1 commit
  14. 29 Oct, 2014 1 commit
  15. 17 Oct, 2014 1 commit
  16. 21 Sep, 2014 8 commits
    • Philippe Gerum's avatar
      cobalt/rtdm, lib/cobalt: unify file descriptor management · 90f104d2
      Philippe Gerum authored
      Use regular kernel file descriptors for all kinds of connection
      handles, referring to regular file objects:
      
      - connection to devnode => filp on chrdev inode
      - socket => filp on anon inode
      
      User and kernel-originated connection handles are no more
      differenciated.
      
      The former procfs interface for RTDM is now entirely gone, as all file
      descriptors are now visible from /proc/<pid>/fd.
      
      Obtaining the list of all named devices can be done this way:
      
      $ grep named /sys/class/rtdm/*/flags
      
      Similarly, the list of all protocol devices can be obtained this way:
      
      $ grep protocol /sys/class/rtdm/*/flags
      
      Force closing a stuck file descriptor (formerly done by writing to
      rtdm/open_fildes) makes no sense anymore. Either the owner is a
      userland process and all file handles it holds will be automatically
      dropped at exit, or it is a kernel driver, in which case the driver
      direly needs fixing.
      90f104d2
    • Philippe Gerum's avatar
      cobalt/rtdm/fd: assume current context is target for all fd ops · 41374b4f
      Philippe Gerum authored
      Except in the only weird case of forcing a close on any random
      kernel-originated connection through the procfs interface
      (open_fildes), but this case is on its way out.
      
      For the sake of mental sanity, we really want to assume that only the
      current thread may affect its own file table, which is what this patch
      enforces.
      
      The rtdm_fd cleanup thread is a non-issue, as we are not supposed to
      run any fd ops recursively on behalf of a ->close() handler anyway.
      
      This change also fixes a rampant inconsistency where a Cobalt user
      thread running some driver code would actually look up into the wrong
      RTDM file table when using the rt_dev_* interface
      (i.e. __xnsys_global_ppd would not be the right context in such a
      case).
      41374b4f
    • Philippe Gerum's avatar
      cobalt/rtdm: split user/kernel paths to opening device · e445bb45
      Philippe Gerum authored
      This is preparation work before we may get rid of our private fd
      allocation system for in-kernel callers.
      e445bb45
    • Philippe Gerum's avatar
      fbafe724
    • Philippe Gerum's avatar
      cobalt/rtdm: drop poll_delay from rtdm_dev_unregister() · 0b21549f
      Philippe Gerum authored
      Sleep indefinitely on a plain waitqueue instead of polling, until the
      device becomes idle. For this reason, the routine loses its return
      value as well, as drivers are most often not willing to deal with
      receiving a device busy condition from a module exit routine (which is
      the place devices should be unregistered from).
      
      Drivers which really want to deal with such condition should simply
      use module refcounting in their own code.
      0b21549f
    • Philippe Gerum's avatar
      cobalt/rtdm, lib/cobalt: open named device on allocated devnode · 058ac453
      Philippe Gerum authored
      Now that named devices exist in the linux namespace (/dev/rtdm), file
      descriptors can be obtained on the associated chrdev, instead of the
      anon inode.
      
      With this change, active connections to RTDM named devices are visible
      from /proc/<pid>/fd.
      058ac453
    • Philippe Gerum's avatar
      cobalt/rtdm, kernel/drivers: split device class / instance abstractions · 1909729e
      Philippe Gerum authored
      How devices are described for registration with rtdm_dev_register() is
      significantly modified, affecting both named and protocol device
      drivers exactly the same way. Aside of fixing consistency issues, the
      bulk of changes is aimed at narrowing the gap between the regular
      Linux device driver model and RTDM.
      
      RTDM now shares the Linux namespace for named devices, which are
      backed by common character device objects from the regular Linux
      device model. As a consequence of this, file descriptors obtained on
      named RTDM devices are regular file descriptors on real chrdevs,
      visible from the /proc/<pid>/fd interface.
      
      The major change required for supporting this closer integration of
      RTDM into the regular Linux driver model involved splitting the device
      class properties from the device instance definitions, which used to
      be combined in Xenomai 2.x into the rtdm_device descriptor.
      
      A new rtdm_device_class descriptor is introduced, for describing the
      general static properties of the devices exposed by a
      driver. rtdm_device now represents an instance of such class.
      
      rtdm_device objects link to the descriptor of the rtdm_device class
      they belong to.
      
      Hotplug support
      ---------------
      
      RTDM first allocates and reserves a major and a range of device minors
      when the first device of a named device class is registered via
      rtdm_dev_register(). Up to class->device_count minors will be
      reserved. Minor number are assigned to devices in order of
      registration, starting from minor #0.
      
      Device nodes for named RTDM devices are automatically visible from the
      /dev/rtdm/ hierarchy with hotplug-enabled device fs (DEVTMPFS now
      recommended).
      1909729e
    • Philippe Gerum's avatar
      cobalt/rtdm, cobalt/posix/process: extend mmap() support to MMU-less · 5f8c21ce
      Philippe Gerum authored
      A file mapping on no-MMU requires the backing device to advertise
      direct mapping capabilities (i.e. BDI_CAP_MAP_DIRECT), which a file
      hooked on the anon inode doesn't.
      
      To fix this, we issue our internal mapping requests (i.e. for memdev
      heaps and mayday page) on a file pointer to /dev/mem instead, on
      MMU-mess systems (only).
      
      In addition, the .get_unmapped_area handler is added to the RTDM file
      descriptor operations, since this will be a prerequisite for allowing
      drivers to honor mapping requests to (quasi-)memory devices on
      MMU-less the same way.
      5f8c21ce
  17. 09 Sep, 2014 1 commit
  18. 03 Sep, 2014 1 commit
  19. 21 Aug, 2014 2 commits
    • Philippe Gerum's avatar
      cobalt/kernel, lib/cobalt: expose a single syscall table · a2b6ce8e
      Philippe Gerum authored
      Since all userland processes belong to the Cobalt personality, all
      syscalls have been merged into the Cobalt table.
      
      As a consequence, all process context information maintained by the
      core has moved to the cobalt_process descriptor.
      a2b6ce8e
    • Philippe Gerum's avatar
      cobalt/rtdm: merge with Cobalt/POSIX personality · 06609e08
      Philippe Gerum authored
      There is no need for a distinct RTDM personality. Features which can
      be accessed from user-space belong to the POSIX I/O API, while RTDM
      tasks directly sit on top of the core personality.
      
      This patch merges the RTDM syscalls into the Cobalt/POSIX table, and
      dropping the RTDM personality in the same move.
      06609e08
  20. 07 Aug, 2014 1 commit
    • Philippe Gerum's avatar
      cobalt/rtdm: introduce mmap() support · c8e9e166
      Philippe Gerum authored
      The new ->mmap() handler is introduced in the device operation
      descriptor. This service is restricted to secondary mode, switching a
      primary mode caller accordingly when invoked from an application.
      
      The prototype is:
      
      int mmap_handler(struct rtdm_fd *fd, struct vm_area_struct *vma);
      
      The semantics are identical to the corresponding handler from the
      regular linux file operations. The only difference is about receiving
      a RTDM file descriptor (struct rtdm_fd) instead of a regular struct
      file pointer. As such, a valid vma descriptor covering the target user
      address space is passed to the handler, therefore common mapping
      operations may be performed on it.
      
      Two new convenience routines for mapping a chunk of kernel memory and
      a physical I/O address range are provided, i.e. rtdm_mmap_kmem() and
      rtdm_mmap_iomem() respectively. Both take a vma descriptor as received
      by the ->mmap() handler, and the appropriate virtual/physical start
      address of the memory range to map to the target address range in
      user-space.
      
      The existing rtdm_mmap_to_user() and rtdm_iomap_to_user() calls are
      kept unmodified. The ->mmap() introduction has no impact on existing
      drivers currently relying on these calls.
      c8e9e166
  21. 30 May, 2014 1 commit
    • Philippe Gerum's avatar
      cobalt: include headers explicitly when needed · 75d61004
      Philippe Gerum authored
      include/asm-generic/xenomai/wrappers.h was pulling in all sorts of
      unrelated header files, which have become useless as we dropped most
      wrappers.
      
      This caused a bunch of implementation files to rely on implicit
      inclusion of some common kernel headers, which is wrong. Fix this.
      75d61004
  22. 16 May, 2014 2 commits
  23. 19 Jan, 2014 1 commit
  24. 10 Aug, 2013 1 commit
    • Philippe Gerum's avatar
      cobalt/kernel: introduce external clock support · 28eb37c8
      Philippe Gerum authored
      This patch introduces a mechanism for registering external clocks
      dynamically, in addition to Xenomai's built-in core clock
      (nkclock). Each external clock may drive Xenomai timers (struct
      xntimer) using the common timer infrastructure.
      
      Xenomai's core clock has nanosecond resolution; it is paced by the
      platform timer (which is driven by the interrupt pipeline).
      
      External clocks are driven by arbitrary timer sources, directly
      managed by the client code.
      
      Each clock provides an internal interface with the timer support code,
      through a set of common operations (e.g. reading time, converting time
      values, programming the next shot if applicable).
      
      The external interface is pretty simple:
      
      - xnclock_register() for instantiating a new clock
      - xnclock_deregister() for dropping an existing clock
      - xnclock_tick() for signaling an incoming tick, so that
        timers driven by the clock are elapsed appropriately.
      
      Since we may now have multiple clocks, each driving their ow...
      28eb37c8
  25. 29 Jun, 2013 1 commit
    • Philippe Gerum's avatar
      cobalt: introduce uapi headers · d928926f
      Philippe Gerum authored
      Following the uapi introduction in recent kernels, this jumbo patch
      splits the former Xenomai POSIX headers into kernel and userland
      counterparts, privatizing the former into the kernel section when
      applicable.
      
      This change is aimed at centralizing the shared API types and
      definitions used in system calls, making it easier to track changes to
      the APIs that the kernel presents to user space, and solving inclusion
      dependency issues the right way.
      
      Headers defining the API bits shared between the Cobalt kernel and the
      support libraries in userland are available from include/cobalt/uapi,
      organized as follows:
      
      - uapi/*.h => Cobalt/POSIX interface bits
      - uapi/rtdm => RTDM bits
      - uapi/sys/*.h => Low-level Cobalt kernel bits
      
      As a consequence of this split, files below include/cobalt/kernel
      become kernel-only headers, and POSIX headers in include/cobalt are
      exclusively reserved for inclusion in user-space builds.
      
      As an added benefit, this change significantly reduces the number of
      headers to be installed for building Xenomai applications.
      d928926f
  26. 18 Jun, 2013 1 commit
    • Philippe Gerum's avatar
      kernel/cobalt: reorganize file hierachy · 629fa126
      Philippe Gerum authored
      The main changes introduced are as follows:
      
      - Xenomai/cobalt core (nucleus) moved at top level, with the arch-dep
      bits, POSIX and RTDM personalities in sub-directories.
      
      - Renamed include/cobalt/nucleus to include/cobalt/kernel.
      
      - include/asm-* directories moved to include/cobalt/.
      
      - Removal of asm-<arch>/bits, with most code reintroduced as regular
        implementation files into lib/cobalt/sysdeps/<arch>/.
      629fa126
  27. 12 Jun, 2013 2 commits
    • Philippe Gerum's avatar
      f98d4b03
    • Philippe Gerum's avatar
      cobalt/nucleus: introduce per-thread resource management handlers · 1860675e
      Philippe Gerum authored
      Extend the operation handlers registered by personalities with
      per-thread handlers to be invoked upon thread mapping, exit and
      unmapping to/from the real-time system.
      
      This mechanism is useful for managing per-thread resources allocated
      by personalities in a more straightforward way than nucleus hooks,
      which unfortunately don't know about the originating interfaces.
      
      Handlers are called in sequence during any thread's lifetime, with the
      following semantics:
      
      - map_thread() is called when the shadow TCB is fully built for an
        emerging Xenomai thread, prior to enabling the I-pipe notification
        events.  The thread is guaranteed to match "current", unstarted yet,
        running in secondary mode. Interrupts are enabled, no lock is held.
      
      - exit_thread() is invoked on behalf of the task exit handler. The
        thread is guaranteed to be current, running in secondary
        mode. Interrupts are enabled, no lock is held.
      
      - unmap_thread() is invoked last, for performing the ultimate (fast)
        cleanup duties after a thread left the Xenomai system. This thread
        may be non-current (i.e. wiping out a dormant TCB), the current
        domain is unspecified. Interrupts are DISABLED, the nucleus lock is
        HELD.
      1860675e