Changeset 880a17c in rtems-libbsd


Ignore:
Timestamp:
May 4, 2017, 12:27:59 PM (2 years ago)
Author:
Kevin Kirspel <kevin-kirspel@…>
Branches:
fd86c091b97759106da7355ce1dd81ebe030e285, f020f08430150c1656a0ad0a1de13699db9b980b
Children:
333bfb6
Parents:
4a8f953
git-author:
Kevin Kirspel <kevin-kirspel@…> (05/04/17 12:27:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/11/17 09:15:41)
Message:

Adding RTEMS support for FREEBSD TTY

Location:
rtemsbsd
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/include/machine/rtems-bsd-commands.h

    r4a8f953 r880a17c  
    7171int rtems_bsd_command_wlanstats(int argc, char **argv);
    7272
     73int rtems_bsd_command_stty(int argc, char **argv);
     74
    7375__END_DECLS
    7476
  • rtemsbsd/include/machine/rtems-bsd-kernel-space.h

    r4a8f953 r880a17c  
    4949
    5050#define O_CLOEXEC 0
     51#define IO_NDELAY O_NONBLOCK
    5152
    5253#define __FreeBSD__ 1
  • rtemsbsd/include/rtems/netcmds-config.h

    r4a8f953 r880a17c  
    4646extern rtems_shell_cmd_t rtems_shell_WLANSTATS_Command;
    4747
     48extern rtems_shell_cmd_t rtems_shell_STTY_Command;
     49
    4850#ifdef __cplusplus
    4951}
  • rtemsbsd/sys/fs/devfs/devfs_devs.c

    • Property mode changed from 100755 to 100644
    r4a8f953 r880a17c  
    3737#include <sys/file.h>
    3838#include <sys/malloc.h>
     39#include <sys/proc.h>
    3940#include <stdlib.h>
    4041#include <string.h>
     
    5152const char rtems_cdev_directory[] = RTEMS_CDEV_DIRECTORY;
    5253
     54/*
     55 * The one true (but secret) list of active devices in the system.
     56 * Locked by dev_lock()/devmtx
     57 */
     58struct cdev_priv_list cdevp_list = TAILQ_HEAD_INITIALIZER(cdevp_list);
     59
    5360struct unrhdr *devfs_inos;
     61
     62static MALLOC_DEFINE(M_CDEVP, "DEVFS1", "DEVFS cdev_priv storage");
    5463
    5564static struct cdev *
     
    6372{
    6473        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
     74        struct file *fp = rtems_bsd_iop_to_fp(iop);
    6575        struct thread *td = rtems_bsd_get_curthread_or_null();
     76        struct file *fpop;
    6677        int error;
    6778
    6879        if (td != NULL) {
     80                fpop = td->td_fpop;
     81                curthread->td_fpop = fp;
    6982                error = cdev->si_devsw->d_open(cdev, oflag, 0, td);
     83                /* Clean up any cdevpriv upon error. */
     84                if (error != 0)
     85                        devfs_clear_cdevpriv();
     86                curthread->td_fpop = fpop;
    7087        } else {
    7188                error = ENOMEM;
     
    7996{
    8097        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
     98        struct file *fp = rtems_bsd_iop_to_fp(iop);
    8199        struct thread *td = rtems_bsd_get_curthread_or_null();
    82100        int flags = rtems_libio_to_fcntl_flags(iop->flags);
     101        struct file *fpop;
    83102        int error;
    84103
    85104        if (td != NULL) {
     105                fpop = td->td_fpop;
     106                curthread->td_fpop = fp;
    86107                error = cdev->si_devsw->d_close(cdev, flags, 0, td);
     108                curthread->td_fpop = fpop;
    87109        } else {
    88110                error = ENOMEM;
     
    97119{
    98120        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
     121        struct file *fp = rtems_bsd_iop_to_fp(iop);
    99122        struct thread *td = rtems_bsd_get_curthread_or_null();
    100123        struct uio uio = {
     
    107130                .uio_td = td
    108131        };
     132        struct file *fpop;
    109133        int error;
    110134
    111135        if (td != NULL) {
     136                fpop = td->td_fpop;
     137                curthread->td_fpop = fp;
    112138                error = cdev->si_devsw->d_read(cdev, &uio,
    113139                    rtems_libio_to_fcntl_flags(iop->flags));
     140                td->td_fpop = fpop;
    114141        } else {
    115142                error = ENOMEM;
     
    139166{
    140167        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
     168        struct file *fp = rtems_bsd_iop_to_fp(iop);
    141169        struct thread *td = rtems_bsd_get_curthread_or_null();
    142170        struct uio uio = {
     
    149177                .uio_td = td
    150178        };
     179        struct file *fpop;
    151180        int error;
    152181
    153182        if (td != NULL) {
     183                fpop = td->td_fpop;
     184                curthread->td_fpop = fp;
    154185                error = cdev->si_devsw->d_write(cdev, &uio,
    155186                    rtems_libio_to_fcntl_flags(iop->flags));
     187                td->td_fpop = fpop;
    156188        } else {
    157189                error = ENOMEM;
     
    180212{
    181213        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
     214        struct file *fp = rtems_bsd_iop_to_fp(iop);
    182215        struct thread *td = rtems_bsd_get_curthread_or_null();
     216        struct file *fpop;
    183217        int error;
    184218        int flags = rtems_libio_to_fcntl_flags(iop->flags);
    185219
    186220        if (td != 0) {
     221                fpop = td->td_fpop;
     222                curthread->td_fpop = fp;
    187223                error = cdev->si_devsw->d_ioctl(cdev, request, buffer, flags,
    188224                    td);
     225                td->td_fpop = fpop;
    189226        } else {
    190227                error = ENOMEM;
     
    198235{
    199236        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
    200 
    201         return (cdev->si_devsw->d_poll(cdev, events,
    202             rtems_bsd_get_curthread_or_wait_forever()));
     237        struct file *fp = rtems_bsd_iop_to_fp(iop);
     238        struct thread *td = rtems_bsd_get_curthread_or_wait_forever();
     239        struct file *fpop;
     240        int error;
     241
     242        fpop = td->td_fpop;
     243        curthread->td_fpop = fp;
     244        error = cdev->si_devsw->d_poll(cdev, events, td);
     245        td->td_fpop = fpop;
     246
     247        return error;
    203248}
    204249
     
    207252{
    208253        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
    209 
    210         return (cdev->si_devsw->d_kqfilter(cdev, kn));
     254        struct file *fp = rtems_bsd_iop_to_fp(iop);
     255        struct thread *td = rtems_bsd_get_curthread_or_wait_forever();
     256        struct file *fpop;
     257        int error;
     258
     259        fpop = td->td_fpop;
     260        curthread->td_fpop = fp;
     261        error = cdev->si_devsw->d_kqfilter(cdev, kn);
     262        td->td_fpop = fpop;
     263
     264        return error;
    211265}
    212266
     
    236290devfs_alloc(int flags)
    237291{
     292        struct cdev_priv *cdp;
    238293        struct cdev *cdev;
    239294
    240         cdev = malloc(sizeof *cdev, M_TEMP, M_ZERO);
    241         if (cdev == NULL)
     295        cdp = malloc(sizeof *cdp, M_CDEVP, M_ZERO |
     296            ((flags & MAKEDEV_NOWAIT) ? M_NOWAIT : M_WAITOK));
     297        if (cdp == NULL)
    242298                return (NULL);
     299
     300        cdev = &cdp->cdp_c;
     301        LIST_INIT(&cdev->si_children);
    243302
    244303        memcpy(cdev->si_path, rtems_cdev_directory, sizeof(cdev->si_path));
     
    249308devfs_free(struct cdev *cdev)
    250309{
    251         free(cdev, M_TEMP);
     310        struct cdev_priv *cdp;
     311
     312        cdp = cdev2priv(cdev);
     313        devfs_free_cdp_inode(cdp->cdp_inode);
     314        free(cdp, M_CDEVP);
    252315}
    253316
     
    287350devfs_create(struct cdev *dev)
    288351{
     352        struct cdev_priv *cdp;
    289353        int rv;
    290354        mode_t mode = S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO;
     
    295359            dev);
    296360        BSD_ASSERT(rv == 0);
     361
     362        cdp = cdev2priv(dev);
     363        cdp->cdp_flags |= CDP_ACTIVE;
     364        cdp->cdp_inode = alloc_unrl(devfs_inos);
     365        dev_refl(dev);
     366        TAILQ_INSERT_TAIL(&cdevp_list, cdp, cdp_list);
    297367}
    298368
     
    300370devfs_destroy(struct cdev *dev)
    301371{
     372        struct cdev_priv *cdp;
    302373        int rv;
     374
     375        cdp = cdev2priv(dev);
     376        cdp->cdp_flags &= ~CDP_ACTIVE;
    303377
    304378        rv = unlink(dev->si_path);
Note: See TracChangeset for help on using the changeset viewer.