Re: Running/Debugging RTEMS applications on Zynq
On 7/2/17 11:18 pm, Jose Pedro Canilho wrote: > Hey all! Hi and welcome. > I'm trying to run a simple RTEMS program in my Zedboard, and I'm having > some issues figuring out how to actually run my program on the board. > I have my program successfully compiled with the ARM cross-compiling > tool and the appropriate BSP ('Xilinx_zynq_zedboard'). Great. > However, the only way I know to actually upload the executables to Zynq > devices is through the Xilinx tool-chain, which already provides its own > BSP based on the CPU+FPGA bistream file created. > > > I've tried to create a small baremetal application for the Zedboard and > somewhat blindly replace the generated .elf with my RTEMS executable. > Obviously this didn't work... :) > > > As I've read throughout some posts in the mailing list, it is advised to > keep the hardware and software development workflows separated. Yes this is what I recommend. It is about allowing the hardware and software tools to updated without impacting the each other. The hardware development and software does need to combine on the target. > But at > some point I'll have to upload my software to the device. Is there a > straightforward way to accomplish this? I'm a bit lost at this point... I have started to document what you need to do ... https://devel.rtems.org/wiki/Boards/Zynq%20-%20Zedboard It is missing some steps which I will fill in when I can. I hope it helps get you going. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
C++ thread library
Hello all, I would like to know which is the proper way configuring our tool chain for gnu threads support. Currently if RTEMS thread compatibility is selected, gthr-rtems.h is used, which enables #define __GTHREADS 1 If instead of RTEMS, POSIX thread compatibility is selected, gthr-posix.h is used, which defines: #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 The problem I face is that if __GTHREADS_CXX0X is not defined, the toolchain does not build any C++ support for threads or mutexes, so applications that use that interface fail to run properly. Thus the question here is: how easy would it be to add/provide __GTHREADS_CXX0X in the RTEMS header? Is it just a matter of adding it into the toolchain and providing some wrapper functions/stubs to existing RTEMS functionality, or this functionality is not there at the moment, which is the reason __GTHREADS_CXX0X is not currently defined? Best Regards, Stavros ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Problem while linking rtems-libbsd with application
Hello all, I have setup rtems for arm/xilinx_zynq_a9_qemu pair and installed rtems-libbsd. Im trying to run NFS in an application but i get an error while linking libbsd drivers. I use the following commands to compile the application: arm-rtems4.12-gcc -B../../../../../xilinx_zynq_a9_qemu/lib/ -specs bsp_specs -qrtems -DHAVE_CONFIG_H -I. -I/home/vivek/sandbox/rtems/c/src/../../testsuites/samples/fileio -I.. -I/home/vivek/sandbox/rtems/c/src/../../testsuites/samples/../support/include -I/home/vivek/sandbox/rtems-libbsd/rtemsbsd/include -I/home/vivek/sandbox/rtems-libbsd/freebsd/include -I/home/vivek/sandbox/rtems-libbsd/freebsd/sys -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 -O0 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -MT init.o -MD -MP -MF .deps/init.Tpo -c -o init.o /home/vivek/sandbox/rtems/c/src/../../testsuites/samples/fileio/init.c mv -f .deps/init.Tpo .deps/init.Po arm-rtems4.12-gcc -B../../../../../xilinx_zynq_a9_qemu/lib/ -specs bsp_specs -qrtems -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 -O0 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 -o fileio.exe init.o /home/vivek/sandbox/rtems-libbsd/build/arm-rtems4.12-xilinx_zynq_a9_qemu/libbsd.a I'm getting the following error: /home/vivek/sandbox/rtems-libbsd/build/arm-rtems4.12-xilinx_zynq_a9_qemu/libbsd.a(sfp.c.12.o): In function `convert_sff_power': /home/vivek/sandbox/rtems-libbsd/build/arm-rtems4.12-xilinx_zynq_a9_qemu/../../freebsd/sbin/ifconfig/sfp.c:614: undefined reference to `log10' I think this is a linking issue(in the rtems-libbsd build) and i'm reinstalling libbsd to double-check. If anyone has come across this error before please help me resolve it. Regards, Vivek ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Running/Debugging RTEMS applications on Zynq
On 08/02/2017 21:37, Chris Johns wrote: It is missing some steps which I will fill in when I can. I hope it helps get you going. I have completed documenting the set up to run RTEMS applications including running the RTEMS debugger test built by libbsd. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: perf tool for RTEMS?
On 08/02/2017 16:56, 구철회 wrote: I am CHEOL. H. KOO from KARI, and newbie here. For application and project to be required, I think perf tool just like as linux perf tool is interesting to perform performance analysis of time critical application on RTEMS. Tool such perf sample the program counter or inject code in the path and that effects the data captured. But I have no found such a tool in RTEMS society yet. What you may need depends on your specific requirements. There are some open projects to add better support to RTEMS however this work needs funding to be completed. Often users instrument specific code in applications to help profile specific pieces of code. Maybe I missed existing tools. If there weren’t, is it interesting to you for porting it from linux perf or developing new one for RTEMS? There are tools like the Lauterbach debugger that can profile architectures with suitable hardware support. They provide some of the best solutions you can get however even these excellent and expensive tools can effect the cycle times of running code. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Problem while linking rtems-libbsd with application
On 09/02/2017 09:54, vivek kukreja wrote: Hello all, Hello and welcome back to RTEMS. I have setup rtems for arm/xilinx_zynq_a9_qemu pair and installed rtems-libbsd. Im trying to run NFS in an application but i get an error while linking libbsd drivers. I use the following commands to compile the application: arm-rtems4.12-gcc -B../../../../../xilinx_zynq_a9_qemu/lib/ -specs bsp_specs -qrtems -DHAVE_CONFIG_H -I. -I/home/vivek/sandbox/rtems/c/src/../../testsuites/samples/fileio -I.. -I/home/vivek/sandbox/rtems/c/src/../../testsuites/samples/../support/include -I/home/vivek/sandbox/rtems-libbsd/rtemsbsd/include -I/home/vivek/sandbox/rtems-libbsd/freebsd/include -I/home/vivek/sandbox/rtems-libbsd/freebsd/sys -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 -O0 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -MT init.o -MD -MP -MF .deps/init.Tpo -c -o init.o /home/vivek/sandbox/rtems/c/src/../../testsuites/samples/fileio/init.c mv -f .deps/init.Tpo .deps/init.Po arm-rtems4.12-gcc -B../../../../../xilinx_zynq_a9_qemu/lib/ -specs bsp_specs -qrtems -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 -O0 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 -o fileio.exe init.o /home/vivek/sandbox/rtems-libbsd/build/arm-rtems4.12-xilinx_zynq_a9_qemu/libbsd.a I'm getting the following error: /home/vivek/sandbox/rtems-libbsd/build/arm-rtems4.12-xilinx_zynq_a9_qemu/libbsd.a(sfp.c.12.o): In function `convert_sff_power': /home/vivek/sandbox/rtems-libbsd/build/arm-rtems4.12-xilinx_zynq_a9_qemu/../../freebsd/sbin/ifconfig/sfp.c:614: undefined reference to `log10' I think this is a linking issue(in the rtems-libbsd build) and i'm reinstalling libbsd to double-check. If anyone has come across this error before please help me resolve it. Try adding -lm to the libraries you need to link with. It looks to me like the recent changes Sebastian has made with libbsd has added a dependence on the libm.a library. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 4/9] Adding RTEMS termios FREEBSD support
--- rtemsbsd/include/machine/rtems-bsd-termios.h | 68 + rtemsbsd/rtems/rtems-bsd-termios.c | 213 +++ 2 files changed, 281 insertions(+) create mode 100755 rtemsbsd/include/machine/rtems-bsd-termios.h create mode 100755 rtemsbsd/rtems/rtems-bsd-termios.c diff --git a/rtemsbsd/include/machine/rtems-bsd-termios.h b/rtemsbsd/include/machine/rtems-bsd-termios.h new file mode 100755 index 000..0acb23f --- /dev/null +++ b/rtemsbsd/include/machine/rtems-bsd-termios.h @@ -0,0 +1,68 @@ +/** + * @file + * + * @ingroup rtems_bsd_machine + * + * @brief TODO. + */ + +/* + * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_TERMIOS_H_ +#define _RTEMS_BSD_MACHINE_RTEMS_BSD_TERMIOS_H_ + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +u_long +rtems_bsd_ioctl_cmd_to_bsd(struct termios *t, u_long cmd, caddr_t data, int* flush_flags); + +speed_t +rtems_bsd_rtems_speed_to_bsd_speed(speed_t spd); + +speed_t +rtems_bsd_bsd_speed_to_rtems_speed(speed_t spd); + +speed_t +rtems_bsd_get_input_speed(struct termios *t); + +speed_t +rtems_bsd_get_output_speed(struct termios *t); + +__END_DECLS + +#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_TERMIOS_H_ */ diff --git a/rtemsbsd/rtems/rtems-bsd-termios.c b/rtemsbsd/rtems/rtems-bsd-termios.c new file mode 100755 index 000..cd86581 --- /dev/null +++ b/rtemsbsd/rtems/rtems-bsd-termios.c @@ -0,0 +1,213 @@ +/** + * @file + * + * @ingroup rtems_bsd_rtems + * + * @brief TODO. + */ + +/* + * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#define TTYDEFCHARS +#include +#undef TTYDEFCHARS +#include + +typedef struct +{ + speed_t rtems_speed; + speed_t bsd_speed; +}rtems_bsd_termios_speed_entry; + +static rtems_bsd_termios_speed_entry rtems_bsd_speed_table[] = { + { B0, 0 }, + { B50, 50 }, + { B75, 75 }, + { B110,110}, + { B134,134}, + { B150,150}, + { B200,200}, + { B300,300}, + { B600,600}, + { B1200, 1200 }, + { B1800, 1800 }, + { B2400,
[PATCH 3/9] Adding files for stty command
--- freebsd/bin/stty/cchar.c | 142 freebsd/bin/stty/extern.h | 45 ++ freebsd/bin/stty/gfmt.c | 129 +++ freebsd/bin/stty/key.c| 296 ++ freebsd/bin/stty/modes.c | 248 freebsd/bin/stty/print.c | 283 freebsd/bin/stty/stty.c | 169 +++ freebsd/bin/stty/stty.h | 55 +++ freebsd/bin/stty/util.c | 66 rtemsbsd/rtems/rtems-bsd-shell-stty.c | 40 + 10 files changed, 1473 insertions(+) create mode 100644 freebsd/bin/stty/cchar.c create mode 100644 freebsd/bin/stty/extern.h create mode 100644 freebsd/bin/stty/gfmt.c create mode 100644 freebsd/bin/stty/key.c create mode 100644 freebsd/bin/stty/modes.c create mode 100644 freebsd/bin/stty/print.c create mode 100644 freebsd/bin/stty/stty.c create mode 100644 freebsd/bin/stty/stty.h create mode 100644 freebsd/bin/stty/util.c create mode 100755 rtemsbsd/rtems/rtems-bsd-shell-stty.c diff --git a/freebsd/bin/stty/cchar.c b/freebsd/bin/stty/cchar.c new file mode 100644 index 000..a6bdeb5 --- /dev/null +++ b/freebsd/bin/stty/cchar.c @@ -0,0 +1,142 @@ +#include + +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + *may be used to endorse or promote products derived from this software + *without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cchar.c8.5 (Berkeley) 4/2/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include + +#include "stty.h" +#include "extern.h" + +static int c_cchar(const void *, const void *); + +/* + * Special control characters. + * + * Cchars1 are the standard names, cchars2 are the old aliases. + * The first are displayed, but both are recognized on the + * command line. + */ +struct cchar cchars1[] = { + { "discard",VDISCARD, CDISCARD }, + { "dsusp", VDSUSP, CDSUSP }, + { "eof",VEOF, CEOF }, + { "eol",VEOL, CEOL }, + { "eol2", VEOL2, CEOL }, + { "erase", VERASE, CERASE }, + { "erase2", VERASE2,CERASE2 }, + { "intr", VINTR, CINTR }, + { "kill", VKILL, CKILL }, + { "lnext", VLNEXT, CLNEXT }, + { "min",VMIN, CMIN }, + { "quit", VQUIT, CQUIT }, + { "reprint",VREPRINT, CREPRINT }, + { "start", VSTART, CSTART }, + { "status", VSTATUS,CSTATUS }, + { "stop", VSTOP, CSTOP }, + { "susp", VSUSP, CSUSP }, + { "time", VTIME, CTIME }, + { "werase", VWERASE,CWERASE }, + { NULL, 0, 0}, +}; + +struct cchar cchars2[] = { + { "brk",VEOL, CEOL }, + { "flush", VDISCARD, CDISCARD }, + { "rprnt", VREPRINT, CREPRINT }, + { NULL, 0, 0 }, +}; + +static int +c_cchar(const void *a, const void *b) +{ + +return (strcmp(((const struct cchar *)a)->name, ((const struct cchar *)b)->name)); +} + +int +csearch(char ***argvp, struct info *ip) +{ + struct cchar *cp, tmp; + long val; + char *arg, *ep, *name; + +
[PATCH 5/9] Adding RTEMS support for FREEBSD virtual device operations
--- rtemsbsd/sys/fs/devfs/devfs_vnops.c | 136 1 file changed, 136 insertions(+) create mode 100755 rtemsbsd/sys/fs/devfs/devfs_vnops.c diff --git a/rtemsbsd/sys/fs/devfs/devfs_vnops.c b/rtemsbsd/sys/fs/devfs/devfs_vnops.c new file mode 100755 index 000..8c4a786 --- /dev/null +++ b/rtemsbsd/sys/fs/devfs/devfs_vnops.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static MALLOC_DEFINE(M_CDEVPDATA, "DEVFSP", "Metainfo for cdev-fp data"); + +struct mtx cdevpriv_mtx; +MTX_SYSINIT(cdevpriv_mtx, &cdevpriv_mtx, "cdevpriv lock", MTX_DEF); + +int +devfs_get_cdevpriv(void **datap) +{ + struct file *fp; + struct cdev_privdata *p; + int error; + + fp = curthread->td_fpop; + if (fp == NULL) + return (EBADF); + p = fp->f_cdevpriv; + if (p != NULL) { + error = 0; + *datap = p->cdpd_data; + } else + error = ENOENT; + return (error); +} + +int +devfs_set_cdevpriv(void *priv, d_priv_dtor_t *priv_dtr) +{ + struct file *fp; + struct cdev_priv *cdp; + struct cdev_privdata *p; + int error; + + fp = curthread->td_fpop; + if (fp == NULL) + return (ENOENT); + cdp = cdev2priv((struct cdev *)fp->f_data); + p = malloc(sizeof(struct cdev_privdata), M_CDEVPDATA, M_WAITOK); + p->cdpd_data = priv; + p->cdpd_dtr = priv_dtr; + p->cdpd_fp = fp; + mtx_lock(&cdevpriv_mtx); + if (fp->f_cdevpriv == NULL) { + LIST_INSERT_HEAD(&cdp->cdp_fdpriv, p, cdpd_list); + fp->f_cdevpriv = p; + mtx_unlock(&cdevpriv_mtx); + error = 0; + } else { + mtx_unlock(&cdevpriv_mtx); + free(p, M_CDEVPDATA); + error = EBUSY; + } + return (error); +} + +void +devfs_destroy_cdevpriv(struct cdev_privdata *p) +{ + + mtx_assert(&cdevpriv_mtx, MA_OWNED); + KASSERT(p->cdpd_fp->f_cdevpriv == p, + ("devfs_destoy_cdevpriv %p != %p", p->cdpd_fp->f_cdevpriv, p)); + p->cdpd_fp->f_cdevpriv = NULL; + LIST_REMOVE(p, cdpd_list); + mtx_unlock(&cdevpriv_mtx); + (p->cdpd_dtr)(p->cdpd_data); + free(p, M_CDEVPDATA); +} + +static void +devfs_fpdrop(struct file *fp) +{ + struct cdev_privdata *p; + + mtx_lock(&cdevpriv_mtx); + if ((p = fp->f_cdevpriv) == NULL) { +mtx_unlock(&cdevpriv_mtx); +return; + } + devfs_destroy_cdevpriv(p); +} + +void +devfs_clear_cdevpriv(void) +{ + struct file *fp; + + fp = curthread->td_fpop; + if (fp == NULL) +return; + devfs_fpdrop(fp); +} -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 6/9] Adding USB serial driver test cases
--- .../include/rtems/bsd/test/default-usb-init.h | 158 + testsuite/usbserial/init.c | 373 testsuite/usbserial01/test_main.c | 666 + testsuite/usbserial02/test_main.c | 252 testsuite/usbserial03/test_main.c | 240 testsuite/usbserial04/test_main.c | 226 +++ testsuite/usbserial05/test_main.c | 303 ++ testsuite/usbserial06/test_main.c | 218 +++ 8 files changed, 2436 insertions(+) create mode 100755 testsuite/include/rtems/bsd/test/default-usb-init.h create mode 100755 testsuite/usbserial/init.c create mode 100755 testsuite/usbserial01/test_main.c create mode 100755 testsuite/usbserial02/test_main.c create mode 100755 testsuite/usbserial03/test_main.c create mode 100755 testsuite/usbserial04/test_main.c create mode 100755 testsuite/usbserial05/test_main.c create mode 100755 testsuite/usbserial06/test_main.c diff --git a/testsuite/include/rtems/bsd/test/default-usb-init.h b/testsuite/include/rtems/bsd/test/default-usb-init.h new file mode 100755 index 000..051da86 --- /dev/null +++ b/testsuite/include/rtems/bsd/test/default-usb-init.h @@ -0,0 +1,158 @@ +/* + * Shared Network Test Initialization File + */ + +#ifndef RTEMS_BSD_TEST_DEFAULT_INIT_H +#define RTEMS_BSD_TEST_DEFAULT_INIT_H + +#include +#include +#include +#include +#include +#include +#include + +static void default_set_self_prio( rtems_task_priority prio ) +{ + rtems_status_code sc; + + sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio); + assert(sc == RTEMS_SUCCESSFUL); +} + +static void default_on_exit( int exit_code, void *arg ) +{ + rtems_printer printer; + + rtems_print_printer_printf(&printer); + rtems_stack_checker_report_usage_with_plugin(&printer); + + if ( exit_code == 0 ) { +puts( "*** END OF TEST " TEST_NAME " ***" ); + } +} + +rtems_task Init( + rtems_task_argument ignored +) +{ + rtems_status_code sc; + + /* + * Default the syslog priority to 'debug' to aid developers. + */ + rtems_bsd_setlogpriority("debug"); + + puts( "*** " TEST_NAME " TEST ***" ); + + /* + * BSD must support the new "shared IRQ PIC implementation" at this point. + * BSPs must also provide rtems_interrupt_server_initialize() which + * just requires including irq-server.[ch] in their build. + */ + + on_exit( default_on_exit, NULL ); + +#ifdef DEFAULT_EARLY_INITIALIZATION + early_initialization(); +#endif + + /* Let other tasks run to complete background work */ + default_set_self_prio( RTEMS_MAXIMUM_PRIORITY - 2 ); + + rtems_bsd_initialize(); + + /* Let the callout timer allocate its resources */ + sc = rtems_task_wake_after( 2 ); + assert(sc == RTEMS_SUCCESSFUL); + + test_main(); + /* should not return */ + + assert( 0 ); +} + +/* + * Configure RTEMS. + */ +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK + +#define CONFIGURE_MAXIMUM_DRIVERS 32 + +#define CONFIGURE_FILESYSTEM_DOSFS + +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 + +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 + +#define CONFIGURE_UNLIMITED_OBJECTS +#define CONFIGURE_UNIFIED_WORK_AREAS + +#define CONFIGURE_STACK_CHECKER_ENABLED + +#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024) +#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (256 * 1024) + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024) +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + +#define CONFIGURE_INIT + +#include + +/* + * Configure LIBBSD device. + */ + #include + +/* + * Configure RTEMS Shell. + */ +#define CONFIGURE_SHELL_COMMANDS_INIT + +#include + +#include + +#define CONFIGURE_SHELL_USER_COMMANDS \ + &bsp_interrupt_shell_command, \ + &rtems_shell_STTY_Command, \ + &rtems_shell_SYSCTL_Command + +#define CONFIGURE_SHELL_COMMAND_CPUUSE +#define CONFIGURE_SHELL_COMMAND_PERIODUSE +#define CONFIGURE_SHELL_COMMAND_STACKUSE +#define CONFIGURE_SHELL_COMMAND_PROFREPORT + +#define CONFIGURE_SHELL_COMMAND_CP +#define CONFIGURE_SHELL_COMMAND_PWD +#define CONFIGURE_SHELL_COMMAND_LS +#define CONFIGURE_SHELL_COMMAND_LN +#define CONFIGURE_SHELL_COMMAND_LSOF +#define CONFIGURE_SHELL_COMMAND_CHDIR +#define CONFIGURE_SHELL_COMMAND_CD +#define CONFIGURE_SHELL_COMMAND_MKDIR +#define CONFIGURE_SHELL_COMMAND_RMDIR +#define CONFIGURE_SHELL_COMMAND_CAT +#define CONFIGURE_SHELL_COMMAND_MV +#define CONFIGURE_SHELL_COMMAND_RM +#define CONFIGURE_SHELL_COMMAND_MALLOC_INFO + +#define CONFIGURE_SHELL_COMMAND_BLKSTATS +#define CONFIGURE_SHELL_COMMAND_BLKSYNC +#define CONFIGURE_SHELL_COMMAND_MOUNT +#define CONFIGURE_SHELL_CO
[PATCH 1/9] Adding Prolific USB Serial driver
--- freebsd/sys/dev/usb/serial/uplcom.c | 936 + freebsd/sys/dev/usb/serial/usb_serial.c | 1719 +++ freebsd/sys/dev/usb/serial/usb_serial.h | 221 3 files changed, 2876 insertions(+) create mode 100644 freebsd/sys/dev/usb/serial/uplcom.c create mode 100644 freebsd/sys/dev/usb/serial/usb_serial.c create mode 100644 freebsd/sys/dev/usb/serial/usb_serial.h diff --git a/freebsd/sys/dev/usb/serial/uplcom.c b/freebsd/sys/dev/usb/serial/uplcom.c new file mode 100644 index 000..31b5867 --- /dev/null +++ b/freebsd/sys/dev/usb/serial/uplcom.c @@ -0,0 +1,936 @@ +#include + +/* $NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $*/ + +#include +__FBSDID("$FreeBSD$"); + +/*- + * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Ichiro FUKUHARA (ich...@ichiro.org). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This driver supports several USB-to-RS232 serial adapters driven by + * Prolific PL-2303, PL-2303X and probably PL-2303HX USB-to-RS232 + * bridge chip. The adapters are sold under many different brand + * names. + * + * Datasheets are available at Prolific www site at + * http://www.prolific.com.tw. The datasheets don't contain full + * programming information for the chip. + * + * PL-2303HX is probably programmed the same as PL-2303X. + * + * There are several differences between PL-2303 and PL-2303(H)X. + * PL-2303(H)X can do higher bitrate in bulk mode, has _probably_ + * different command for controlling CRTSCTS and needs special + * sequence of commands for initialization which aren't also + * documented in the datasheet. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#defineUSB_DEBUG_VAR uplcom_debug +#include +#include + +#include + +#ifdef USB_DEBUG +static int uplcom_debug = 0; + +static SYSCTL_NODE(_hw_usb, OID_AUTO, uplcom, CTLFLAG_RW, 0, "USB uplcom"); +SYSCTL_INT(_hw_usb_uplcom, OID_AUTO, debug, CTLFLAG_RWTUN, +&uplcom_debug, 0, "Debug le
[PATCH 2/9] Adding files to support FREEBSD termios which is needed for the USB serial drivers
--- freebsd/sys/kern/tty.c | 2299 freebsd/sys/kern/tty_inq.c | 491 + freebsd/sys/kern/tty_outq.c| 341 ++ freebsd/sys/kern/tty_ttydisc.c | 1267 ++ freebsd/sys/sys/_termios.h | 222 freebsd/sys/sys/cons.h | 144 +++ freebsd/sys/sys/serial.h | 92 ++ freebsd/sys/sys/timepps.h | 266 + freebsd/sys/sys/ttydefaults.h | 111 ++ 9 files changed, 5233 insertions(+) create mode 100644 freebsd/sys/kern/tty.c create mode 100644 freebsd/sys/kern/tty_inq.c create mode 100644 freebsd/sys/kern/tty_outq.c create mode 100644 freebsd/sys/kern/tty_ttydisc.c create mode 100644 freebsd/sys/sys/_termios.h create mode 100644 freebsd/sys/sys/cons.h create mode 100644 freebsd/sys/sys/serial.h create mode 100644 freebsd/sys/sys/timepps.h create mode 100644 freebsd/sys/sys/ttydefaults.h diff --git a/freebsd/sys/kern/tty.c b/freebsd/sys/kern/tty.c new file mode 100644 index 000..47932ee --- /dev/null +++ b/freebsd/sys/kern/tty.c @@ -0,0 +1,2299 @@ +#include + +/*- + * Copyright (c) 2008 Ed Schouten + * All rights reserved. + * + * Portions of this software were developed under sponsorship from Snow + * B.V., the Netherlands. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef COMPAT_43TTY +#include +#endif /* COMPAT_43TTY */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define TTYDEFCHARS +#include +#undef TTYDEFCHARS +#include +#include + +#include + +static MALLOC_DEFINE(M_TTY, "tty", "tty device"); + +static void tty_rel_free(struct tty *tp); + +static TAILQ_HEAD(, tty) tty_list = TAILQ_HEAD_INITIALIZER(tty_list); +static struct sx tty_list_sx; +SX_SYSINIT(tty_list, &tty_list_sx, "tty list"); +static unsigned int tty_list_count = 0; + +/* Character device of /dev/console. */ +static struct cdev *dev_console; +static const char *dev_console_filename; + +/* + * Flags that are supported and stored by this implementation. + */ +#define TTYSUP_IFLAG (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|\ + INLCR|IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL) +#define TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) +#define TTYSUP_LFLAG (ECHOKE|ECHOE|ECHOK|ECHO|ECHONL|ECHOPRT|\ + ECHOCTL|ISIG|ICANON|ALTWERASE|IEXTEN|TOSTOP|\ + FLUSHO|NOKERNINFO|NOFLSH) +#define TTYSUP_CFLAG (CIGNORE|CSIZE|CSTOPB|CREAD|PARENB|PARODD|\ + HUPCL|CLOCAL|CCTS_OFLOW|CRTS_IFLOW|CDTR_IFLOW|\ + CDSR_OFLOW|CCAR_OFLOW) + +#defineTTY_CALLOUT(tp,d) (dev2unit(d) & TTYUNIT_CALLOUT) + +/* + * Set TTY buffer sizes. + */ + +#defineTTYBUF_MAX 65536 + +static void +tty_watermarks(struct tty *tp) +{ + size_t bs = 0; + + /* Provide an input buffer for 0.2 seconds of data. */ + if (tp->t_termios.c_cflag & CREAD) + bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX); + ttyinq_setsize(&tp->t_inq, tp, bs); + + /* Set low watermark at 10% (when 90% is available). */ + tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10; + + /* Provide an output buffer for 0.2 seconds of data. */ + bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX); + ttyoutq_setsize(&tp->t_outq, tp, bs); + + /* Set low watermark at 10% (when 90% is available). */ + tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10; +} +
[PATCH 7/9] Patching STTY command for use in RTEMS
--- freebsd/bin/stty/cchar.c | 11 freebsd/bin/stty/gfmt.c | 22 freebsd/bin/stty/key.c| 21 freebsd/bin/stty/modes.c | 9 freebsd/bin/stty/print.c | 14 + freebsd/bin/stty/rtems-bsd-stty-cchar-data.h | 4 ++ freebsd/bin/stty/rtems-bsd-stty-data.h| 11 freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h | 4 ++ freebsd/bin/stty/rtems-bsd-stty-key-data.h| 5 ++ freebsd/bin/stty/rtems-bsd-stty-modes-data.h | 4 ++ freebsd/bin/stty/rtems-bsd-stty-namespace.h | 34 freebsd/bin/stty/rtems-bsd-stty-print-data.h | 6 +++ freebsd/bin/stty/rtems-bsd-stty-stty-data.h | 4 ++ freebsd/bin/stty/rtems-bsd-stty-util-data.h | 4 ++ freebsd/bin/stty/stty.c | 78 +++ freebsd/bin/stty/stty.h | 12 + freebsd/bin/stty/util.c | 9 rtemsbsd/include/machine/rtems-bsd-commands.h | 2 + rtemsbsd/include/rtems/netcmds-config.h | 2 + 19 files changed, 256 insertions(+) mode change 100644 => 100755 freebsd/bin/stty/cchar.c mode change 100644 => 100755 freebsd/bin/stty/gfmt.c mode change 100644 => 100755 freebsd/bin/stty/key.c mode change 100644 => 100755 freebsd/bin/stty/modes.c mode change 100644 => 100755 freebsd/bin/stty/print.c create mode 100755 freebsd/bin/stty/rtems-bsd-stty-cchar-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-key-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-modes-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-namespace.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-print-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-stty-data.h create mode 100755 freebsd/bin/stty/rtems-bsd-stty-util-data.h mode change 100644 => 100755 freebsd/bin/stty/stty.c mode change 100644 => 100755 freebsd/bin/stty/stty.h mode change 100644 => 100755 freebsd/bin/stty/util.c mode change 100644 => 100755 rtemsbsd/include/machine/rtems-bsd-commands.h mode change 100644 => 100755 rtemsbsd/include/rtems/netcmds-config.h diff --git a/freebsd/bin/stty/cchar.c b/freebsd/bin/stty/cchar.c old mode 100644 new mode 100755 index a6bdeb5..f46204c --- a/freebsd/bin/stty/cchar.c +++ b/freebsd/bin/stty/cchar.c @@ -1,5 +1,8 @@ #include +#ifdef __rtems__ +#include "rtems-bsd-stty-namespace.h" +#endif /* __rtems__ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -37,6 +40,9 @@ static char sccsid[] = "@(#)cchar.c 8.5 (Berkeley) 4/2/94"; #include __FBSDID("$FreeBSD$"); +#ifdef __rtems__ +#include +#endif /* __rtems__ */ #include #include @@ -47,6 +53,9 @@ __FBSDID("$FreeBSD$"); #include "stty.h" #include "extern.h" +#ifdef __rtems__ +#include "rtems-bsd-stty-cchar-data.h" +#endif /* __rtems__ */ static int c_cchar(const void *, const void *); @@ -59,7 +68,9 @@ static int c_cchar(const void *, const void *); */ struct cchar cchars1[] = { { "discard",VDISCARD, CDISCARD }, +#ifndef __rtems__ { "dsusp", VDSUSP, CDSUSP }, +#endif /* __rtems__ */ { "eof",VEOF, CEOF }, { "eol",VEOL, CEOL }, { "eol2", VEOL2, CEOL }, diff --git a/freebsd/bin/stty/gfmt.c b/freebsd/bin/stty/gfmt.c old mode 100644 new mode 100755 index 6670e2d..f8839ba --- a/freebsd/bin/stty/gfmt.c +++ b/freebsd/bin/stty/gfmt.c @@ -1,5 +1,8 @@ #include +#ifdef __rtems__ +#include "rtems-bsd-stty-namespace.h" +#endif /* __rtems__ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -37,6 +40,9 @@ static char sccsid[] = "@(#)gfmt.c8.6 (Berkeley) 4/2/94"; #include __FBSDID("$FreeBSD$"); +#ifdef __rtems__ +#include +#endif /* __rtems__ */ #include #include @@ -45,6 +51,9 @@ __FBSDID("$FreeBSD$"); #include "stty.h" #include "extern.h" +#ifdef __rtems__ +#include "rtems-bsd-stty-gfmt-data.h" +#endif /* __rtems__ */ static void gerr(const char *s) __dead2; @@ -67,8 +76,13 @@ gprint(struct termios *tp, struct winsize *wp __unused, int ldisc __unused) (u_long)tp->c_oflag); for (cp = cchars1; cp->name; ++cp) (void)printf("%s=%x:", cp->name, tp->c_cc[cp->sub]); +#ifndef __rtems__ (void)printf("ispeed=%lu:ospeed=%lu\n", (u_long)cfgetispeed(tp), (u_long)cfgetospeed(tp)); +#else /* __rtems__ */ + (void)printf("ispeed=%lu:ospeed=%lu\n", + (u_long)rtems_bsd_get_input_speed(tp), (u_long)rtems_bsd_get_output_speed(tp)); +#endif /* __rtems__ */ } void @@ -100,7 +114,11 @@ gread(struct termios *tp, char *s) } if (CHK("ispeed")) {
[PATCH 8/9] Patching USB serial drivers and Termios for use in RTEMS
--- freebsd/sys/dev/usb/serial/uplcom.c| 22 freebsd/sys/dev/usb/serial/usb_serial.c| 24 freebsd/sys/dev/usb/usb_dev.c | 18 +++ freebsd/sys/fs/devfs/devfs_int.h | 2 +- freebsd/sys/kern/kern_conf.c | 16 +-- freebsd/sys/kern/subr_taskqueue.c | 10 -- freebsd/sys/kern/tty.c | 179 - freebsd/sys/kern/tty_ttydisc.c | 22 freebsd/sys/sys/_termios.h | 30 + freebsd/sys/sys/conf.h | 2 + freebsd/sys/sys/file.h | 4 + freebsd/sys/sys/proc.h | 2 + freebsd/sys/sys/ttydefaults.h | 15 +++ rtemsbsd/include/rtems/bsd/local/opt_gdb.h | 1 + rtemsbsd/include/rtems/bsd/local/opt_usb.h | 2 +- rtemsbsd/sys/fs/devfs/devfs_devs.c | 86 +- 16 files changed, 406 insertions(+), 29 deletions(-) mode change 100644 => 100755 freebsd/sys/dev/usb/serial/uplcom.c mode change 100644 => 100755 freebsd/sys/dev/usb/serial/usb_serial.c mode change 100644 => 100755 freebsd/sys/dev/usb/usb_dev.c mode change 100644 => 100755 freebsd/sys/fs/devfs/devfs_int.h mode change 100644 => 100755 freebsd/sys/kern/kern_conf.c mode change 100644 => 100755 freebsd/sys/kern/subr_taskqueue.c mode change 100644 => 100755 freebsd/sys/kern/tty.c mode change 100644 => 100755 freebsd/sys/kern/tty_ttydisc.c mode change 100644 => 100755 freebsd/sys/sys/_termios.h mode change 100644 => 100755 freebsd/sys/sys/conf.h mode change 100644 => 100755 freebsd/sys/sys/file.h mode change 100644 => 100755 freebsd/sys/sys/proc.h mode change 100644 => 100755 freebsd/sys/sys/ttydefaults.h create mode 100755 rtemsbsd/include/rtems/bsd/local/opt_gdb.h mode change 100644 => 100755 rtemsbsd/include/rtems/bsd/local/opt_usb.h diff --git a/freebsd/sys/dev/usb/serial/uplcom.c b/freebsd/sys/dev/usb/serial/uplcom.c old mode 100644 new mode 100755 index 31b5867..9ad11b7 --- a/freebsd/sys/dev/usb/serial/uplcom.c +++ b/freebsd/sys/dev/usb/serial/uplcom.c @@ -651,6 +651,9 @@ uplcom_pre_param(struct ucom_softc *ucom, struct termios *t) { struct uplcom_softc *sc = ucom->sc_parent; uint8_t i; +#ifdef __rtems__ + uint32_t c_ospeed = rtems_bsd_get_output_speed(t); +#endif /* __rtems__ */ DPRINTF("\n"); @@ -666,15 +669,27 @@ uplcom_pre_param(struct ucom_softc *ucom, struct termios *t) */ if (sc->sc_chiptype != TYPE_PL2303HX) { for (i = 0; i < N_UPLCOM_RATES; i++) { +#ifndef __rtems__ if (uplcom_rates[i] == t->c_ospeed) +#else /* __rtems__ */ + if (uplcom_rates[i] == c_ospeed) +#endif /* __rtems__ */ return (0); } } else { +#ifndef __rtems__ if (t->c_ospeed <= 600) +#else /* __rtems__ */ + if (c_ospeed <= 600) +#endif /* __rtems__ */ return (0); } +#ifndef __rtems__ DPRINTF("uplcom_param: bad baud rate (%d)\n", t->c_ospeed); +#else /* __rtems__ */ + DPRINTF("uplcom_param: bad baud rate (%d)\n", c_ospeed); +#endif /* __rtems__ */ return (EIO); } @@ -684,12 +699,19 @@ uplcom_cfg_param(struct ucom_softc *ucom, struct termios *t) struct uplcom_softc *sc = ucom->sc_parent; struct usb_cdc_line_state ls; struct usb_device_request req; +#ifdef __rtems__ + uint32_t c_ospeed = rtems_bsd_get_output_speed(t); +#endif /* __rtems__ */ DPRINTF("sc = %p\n", sc); memset(&ls, 0, sizeof(ls)); +#ifndef __rtems__ USETDW(ls.dwDTERate, t->c_ospeed); +#else /* __rtems__ */ + USETDW(ls.dwDTERate, c_ospeed); +#endif /* __rtems__ */ if (t->c_cflag & CSTOPB) { ls.bCharFormat = UCDC_STOP_BIT_2; diff --git a/freebsd/sys/dev/usb/serial/usb_serial.c b/freebsd/sys/dev/usb/serial/usb_serial.c old mode 100644 new mode 100755 index f425a16..f9f735a --- a/freebsd/sys/dev/usb/serial/usb_serial.c +++ b/freebsd/sys/dev/usb/serial/usb_serial.c @@ -82,7 +82,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifndef __rtems__ #include +#endif /* __rtems__ */ #include #include @@ -99,11 +101,13 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, ucom, CTLFLAG_RW, 0, "USB ucom"); +#ifndef __rtems__ static int ucom_pps_mode; SYSCTL_INT(_hw_usb_ucom, OID_AUTO, pps_mode, CTLFLAG_RWTUN, &ucom_pps_mode, 0, "pulse capture mode: 0/1/2=disabled/CTS/DCD; add 0x10 to invert"); +#endif /* __rtems__ */ #ifdef USB_DEBUG static int ucom_debug = 0; @@ -418,10 +422,12 @@ ucom_attach_tty(struct ucom_super_softc *ssc, struct ucom_softc *sc) sc->sc_tty = tp; +#ifndef __rtems__ sc->sc_pps.ppscap = PPS_CAPTUREBOTH; sc->sc_pps.driver_abi = PPS_ABI_VERSION; sc->sc_pps.driver_mtx = sc->sc_mtx; pps_init_abi(&sc->sc_pps); +#endif /* __rtems_
[PATCH 9/9] Updating script files for USB serial devices
--- libbsd.py | 67 +- libbsd_waf.py | 86 +++ 2 files changed, 134 insertions(+), 19 deletions(-) diff --git a/libbsd.py b/libbsd.py index 7264ac4..a690a00 100755 --- a/libbsd.py +++ b/libbsd.py @@ -75,11 +75,13 @@ def rtems(mm): 'rtems/rtems-bsd-shell-pfctl.c', 'rtems/rtems-bsd-shell-ping.c', 'rtems/rtems-bsd-shell-route.c', +'rtems/rtems-bsd-shell-stty.c', 'rtems/rtems-bsd-shell-sysctl.c', 'rtems/rtems-bsd-shell-tcpdump.c', 'rtems/rtems-bsd-shell-vmstat.c', 'rtems/rtems-bsd-shell-wlanstats.c', 'rtems/rtems-bsd-syscall-api.c', +'rtems/rtems-bsd-termios.c', 'rtems/rtems-kernel-assert.c', 'rtems/rtems-kernel-autoconf.c', 'rtems/rtems-kernel-bus-dma.c', @@ -155,6 +157,7 @@ def rtems(mm): 'sys/dev/ffec/if_ffec_mcf548x.c', 'sys/dev/dw_mmc/dw_mmc.c', 'sys/fs/devfs/devfs_devs.c', +'sys/fs/devfs/devfs_vnops.c', 'sys/net/if_ppp.c', 'sys/net/ppp_tty.c', 'telnetd/check_passwd.c', @@ -717,31 +720,41 @@ def dev_usb_serial(mm): mod.addDependency(mm['dev_usb']) mod.addKernelSpaceHeaderFiles( [ -'sys/dev/usb/serial/uftdi_reg.h', +#'sys/dev/usb/serial/uftdi_reg.h', 'sys/dev/usb/serial/usb_serial.h', +'sys/sys/_termios.h', +'sys/sys/cons.h', +'sys/sys/serial.h', +'sys/sys/timepps.h', +'sys/sys/ttyqueue.h', +'sys/sys/ttydefaults.h', ] ) mod.addKernelSpaceSourceFiles( [ -'sys/dev/usb/serial/u3g.c', -'sys/dev/usb/serial/uark.c', -'sys/dev/usb/serial/ubsa.c', -'sys/dev/usb/serial/ubser.c', -'sys/dev/usb/serial/uchcom.c', -'sys/dev/usb/serial/ucycom.c', -'sys/dev/usb/serial/ufoma.c', -'sys/dev/usb/serial/uftdi.c', -'sys/dev/usb/serial/ugensa.c', -'sys/dev/usb/serial/uipaq.c', -'sys/dev/usb/serial/ulpt.c', -'sys/dev/usb/serial/umct.c', -'sys/dev/usb/serial/umodem.c', -'sys/dev/usb/serial/umoscom.c', +#'sys/dev/usb/serial/u3g.c', +#'sys/dev/usb/serial/uark.c', +#'sys/dev/usb/serial/ubsa.c', +#'sys/dev/usb/serial/ubser.c', +#'sys/dev/usb/serial/uchcom.c', +#'sys/dev/usb/serial/ucycom.c', +#'sys/dev/usb/serial/ufoma.c', +#'sys/dev/usb/serial/uftdi.c', +#'sys/dev/usb/serial/ugensa.c', +#'sys/dev/usb/serial/uipaq.c', +#'sys/dev/usb/serial/ulpt.c', +#'sys/dev/usb/serial/umct.c', +#'sys/dev/usb/serial/umodem.c', +#'sys/dev/usb/serial/umoscom.c', 'sys/dev/usb/serial/uplcom.c', 'sys/dev/usb/serial/usb_serial.c', -'sys/dev/usb/serial/uslcom.c', -'sys/dev/usb/serial/uvisor.c', -'sys/dev/usb/serial/uvscom.c', +#'sys/dev/usb/serial/uslcom.c', +#'sys/dev/usb/serial/uvisor.c', +#'sys/dev/usb/serial/uvscom.c', +'sys/kern/tty.c', +'sys/kern/tty_inq.c', +'sys/kern/tty_outq.c', +'sys/kern/tty_ttydisc.c', ], mm.generator['source']() ) @@ -2069,6 +2082,8 @@ def user_space(mm): mod = builder.Module('user_space') mod.addUserSpaceHeaderFiles( [ +'bin/stty/extern.h', +'bin/stty/stty.h', 'contrib/libxo/libxo/xo_buf.h', 'contrib/libxo/libxo/xo_encoder.h', 'contrib/libxo/libxo/xo.h', @@ -2229,6 +2244,13 @@ def user_space(mm): mod.addUserSpaceSourceFiles( [ 'bin/hostname/hostname.c', +'bin/stty/cchar.c', +'bin/stty/gfmt.c', +'bin/stty/key.c', +'bin/stty/modes.c', +'bin/stty/print.c', +'bin/stty/stty.c', +'bin/stty/util.c', 'contrib/libxo/libxo/libxo.c', 'contrib/libxo/libxo/xo_encoder.c', 'lib/lib80211/lib80211_ioctl.c', @@ -2926,6 +2948,13 @@ def tests(mm): mod.addTest(mm.generator['test']('program01', ['test_main'])) mod.addTest(mm.generator['test']('commands01', ['test_main'])) mod.addTest(mm.generator['test']('usb01', ['init'], False)) +mod.addTest(mm.generator['test']('usbserial', ['init'], False)) +mod.addTest(mm.generator['test']('usbserial01', ['test_main'], False)) +mod.addTest(mm.generator['test']('usbserial02', ['test_main'], False)) +mod.addTest(mm.generator['test']('usbserial03', ['test_main'], False)) +mod.addTest(mm.generator['test']('usbserial04', ['test_main'], False)) +
Re: [PATCH 6/9] Adding USB serial driver test cases
On 09/02/2017 14:21, Kevin Kirspel wrote: --- .../include/rtems/bsd/test/default-usb-init.h | 158 + testsuite/usbserial/init.c | 373 testsuite/usbserial01/test_main.c | 666 + testsuite/usbserial02/test_main.c | 252 testsuite/usbserial03/test_main.c | 240 testsuite/usbserial04/test_main.c | 226 +++ testsuite/usbserial05/test_main.c | 303 ++ testsuite/usbserial06/test_main.c | 218 +++ 8 files changed, 2436 insertions(+) create mode 100755 testsuite/include/rtems/bsd/test/default-usb-init.h create mode 100755 testsuite/usbserial/init.c create mode 100755 testsuite/usbserial01/test_main.c create mode 100755 testsuite/usbserial02/test_main.c create mode 100755 testsuite/usbserial03/test_main.c create mode 100755 testsuite/usbserial04/test_main.c create mode 100755 testsuite/usbserial05/test_main.c create mode 100755 testsuite/usbserial06/test_main.c Can the new termios support in FreeBSD be tested without needing USB serial support? In other words, is a separate test for termios possible and does it make sense? My concern is the basic termios functionality being added is not tested without having USB serial support which links both parts. +++ b/testsuite/usbserial/init.c @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2010, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * Is this copyright ok? I see other places in other patches where this is happening. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel