[PATCH rtems-libbsd v2 2/5] usb_template: Configure template driver only for CDC Ethernet

Christian MAUDERER christian.mauderer at embedded-brains.de
Thu Jul 29 06:20:44 UTC 2021


Hello Chris,

Am 29.07.21 um 02:07 schrieb Chris Johns:
> On 29/7/21 1:10 am, Ahamed Husni wrote:
>>
>>
>> On Wed, 28 Jul 2021, 17:27 Husni Faiz, <ahamedhusni73 at gmail.com
>> <mailto:ahamedhusni73 at gmail.com>> wrote:
>>
>>      Add the conditional macro to prevent the driver from referencing
>>      the templates which are not imported yet.
>>
>>      Include functions which adds the hw.usb.template sysctl variable.
>>
>>      Signed-off-by: Husni Faiz <ahamedhusni73 at gmail.com
>>      <mailto:ahamedhusni73 at gmail.com>>
>>      ---
>>       freebsd/sys/dev/usb/template/usb_template.c | 4 ++++
>>       freebsd/sys/dev/usb/usb_device.c            | 8 ++++++--
>>       2 files changed, 10 insertions(+), 2 deletions(-)
>>
>>      diff --git a/freebsd/sys/dev/usb/template/usb_template.c
>>      b/freebsd/sys/dev/usb/template/usb_template.c
>>      index 0650da15..76567e85 100644
>>      --- a/freebsd/sys/dev/usb/template/usb_template.c
>>      +++ b/freebsd/sys/dev/usb/template/usb_template.c
>>      @@ -1433,12 +1433,15 @@ usb_temp_setup_by_index(struct usb_device *udev,
>>      uint16_t index)
>>              usb_error_t err;
>>
>>              switch (index) {
>>      +#ifndef __rtems__
>>              case USB_TEMP_MSC:
>>                      err = usb_temp_setup(udev, &usb_template_msc);
>>                      break;
>>      +#endif /* __rtems__ */
>>              case USB_TEMP_CDCE:
>>                      err = usb_temp_setup(udev, &usb_template_cdce);
>>                      break;
>>      +#ifndef __rtems__
>>              case USB_TEMP_MTP:
>>                      err = usb_temp_setup(udev, &usb_template_mtp);
>>                      break;
>>      @@ -1469,6 +1472,7 @@ usb_temp_setup_by_index(struct usb_device *udev,
>>      uint16_t index)
>>              case USB_TEMP_CDCEEM:
>>                      err = usb_temp_setup(udev, &usb_template_cdceem);
>>                      break;
>>      +#endif /* __rtems__ */
>>              default:
>>                      return (USB_ERR_INVAL);
>>              }
>>      diff --git a/freebsd/sys/dev/usb/usb_device.c b/freebsd/sys/dev/usb/usb_device.c
>>      index ee240949..619cae5a 100644
>>      --- a/freebsd/sys/dev/usb/usb_device.c
>>      +++ b/freebsd/sys/dev/usb/usb_device.c
>>      @@ -28,6 +28,10 @@
>>        * SUCH DAMAGE.
>>        */
>>
>>      +#ifdef __rtems__
>>      +#include <rtems/bsd/modules.h>
>>      +#endif
>>      +
>>       #ifdef USB_GLOBAL_INCLUDE_FILE
>>       #include USB_GLOBAL_INCLUDE_FILE
>>       #else
>>      @@ -123,7 +127,7 @@ int usb_template = USB_TEMPLATE;
>>       int    usb_template = -1;
>>       #endif
>>
>>      -#ifndef __rtems__
>>      +#if !defined(__rtems__) || defined(RTEMS_BSD_MODULE_DEV_USB_TEMPLATE)
> 
> Is doing this supported by the freebsd-to-rtems.py script?

I sure hope that it is. I know that I used similar constructions in the 
past and it seems that I'm not the only one, because I'm sure that I 
haven't touched some of these files:

freebsd/crypto/openssl/crypto/init.c:188:# elif !defined(DSO_NONE) && 
!defined(__rtems__)
freebsd/crypto/openssl/crypto/arm_arch.h:13:#if defined(__rtems__) && 
defined(__arm__)
freebsd/contrib/wpa/src/utils/os_unix.c:236:#if defined(__uClinux__) || 
defined(__sun__) || defined(__rtems__)
freebsd/sbin/ping6/ping6.c:74:#if defined(__rtems__) && defined(INET6)
freebsd/sbin/ping6/ping6.c:2935:#endif /* defined(__rtems__) && 
defined(INET6) */
freebsd/sys/net/bpf.h:49:#if defined(__rtems__) && !defined(__FreeBSD__)
freebsd/sys/net/bpf.h:51:#endif /* defined(__rtems__) && 
!defined(__FreeBSD__) */
freebsd/sys/cam/cam_debug.h:49:#if defined(_KERNEL) && !defined(__rtems__)
freebsd/sys/dev/e1000/e1000_osdep.h:256:#if defined(INVARIANTS) && 
!defined(__rtems__)
freebsd/sys/dev/rtwn/usb/rtwn_usb_tx.c:177:#if defined(__rtems__) && 
defined(CPU_DATA_CACHE_ALIGNMENT)
freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.c:122:#if defined(__rtems__) && 
defined(CPU_DATA_CACHE_ALIGNMENT)
freebsd/sys/dev/pci/pci.c:5403:#if defined(__rtems__) && defined(__i386__)
freebsd/sys/dev/extres/regulator/regulator.c:54:#if !defined(__rtems__) 
|| defined(FDT)
freebsd/sys/dev/gpio/ofw_gpiobus.c:46:#if defined(__rtems__) && defined(FDT)
freebsd/sys/dev/usb/usb_busdma.c:549:#if defined(__rtems__) && 
defined(CPU_DATA_CACHE_ALIGNMENT)
freebsd/sys/dev/usb/usb_busdma.c:599:#if !defined(__rtems__) || 
USB_NEED_BUSDMA_COHERENT_ALLOC
freebsd/sys/dev/usb/usb_busdma.c:620:#if defined(__rtems__) && 
CPU_DATA_CACHE_ALIGNMENT
freebsd/sys/contrib/ck/include/gcc/arm/ck_pr.h:63:#if 
defined(__FreeBSD__) && !defined(__rtems__)
freebsd/sys/kern/subr_sleepqueue.c:152:#if defined(__rtems__) && 
defined(RTEMS_SMP)
freebsd/sys/kern/subr_sbuf.c:611:#if defined(_KERNEL) && !defined(__rtems__)
freebsd/sys/kern/kern_timeout.c:46:#if defined(__arm__) || 
defined(__rtems__)
freebsd/sys/sys/sigio.h:69:#elif defined(__rtems__) && defined(_KERNEL)
freebsd/sys/sys/mbuf.h:351:#if defined(__rtems__) && !defined(__i386__)
dhcpcd/dhcp6.c:33:#if defined(__rtems__) && defined(INET6)
dhcpcd/dhcp6.c:2816:#endif /* defined(__rtems__) && defined(INET6) */
dhcpcd/ipv6.c:31:#if defined(__rtems__) && defined(INET6)
dhcpcd/ipv6.c:1052:#endif /* defined(__rtems__) && defined(INET6) */
dhcpcd/ipv6nd.c:31:#if defined(__rtems__) && defined(INET6)
dhcpcd/ipv6nd.c:1840:#endif /* defined(__rtems__) && defined(INET6) */
rtemsbsd/nfsclient/nfs_prot_xdr.c:17:  #if !defined(__rtems__)
rtemsbsd/sys/arm/at91/at91_mci.c:73:#if defined(__rtems__) && 
defined(LIBBSP_ARM_ATSAM_BSP_H)
freebsd-org/contrib/libstdc++/config/cpu/m68k/atomicity.h:53:#elif 
defined(__rtems__)
freebsd-org/contrib/compiler-rt/lib/ubsan/ubsan_platform.h:20: 
defined(_WIN32) || defined(__Fuchsia__) || defined(__rtems__)
freebsd-org/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform.h:18: 
  !defined(__Fuchsia__) && !defined(__rtems__) && \
freebsd-org/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform.h:108:#if 
defined(__rtems__)

(Hope that get's through the mail well enoguth that it is readable. If 
not: Just grep for "defined(__rtems__)" yourself.)

I don't think that our script touches the "#ifdef(__rtems__)" except 
maybe in some special header cases, does it? I thought that's basically 
how the rebase works: Just copying all that stuff unchanged to 
freebsd-org and then do a rebase with all changes. The guards are more 
or less to make it simpler to see what's been added by RTEMS.

Best regards

Christian

> 
> Why is the RTEMS_BSD_MODULE_DEV_USB_TEMPLATE needed? >
>>       SYSCTL_PROC(_hw_usb, OID_AUTO, template,
>>           CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
>>           NULL, 0, sysctl_hw_usb_template,
>>      @@ -255,7 +259,7 @@ sysctl_hw_usb_template(SYSCTL_HANDLER_ARGS)
>>
>>              return (0);
>>       }
>>      -#endif /* __rtems__ */
>>      +#endif /* !__rtmes__ || RTEMS_BSD_MODULE_DEV_USB_TEMPLATE */
>>
>> Ah, a typo here (rtmes). Should I send a new set of patches?
> 
> Yes it needs to be correct for the script to work but I would check the
> freebsd-to-rtems.py script works with these guard comments.
> 
> Chris
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
> 

-- 
--------------------------------------------
embedded brains GmbH
Herr Christian MAUDERER
Dornierstr. 4
82178 Puchheim
Germany
email: christian.mauderer at embedded-brains.de
phone: +49-89-18 94 741 - 18
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list