Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Use attribute packed for on-the-wire data struct...



details:   https://anonhg.NetBSD.org/src/rev/7a7c590f2737
branches:  trunk
changeset: 486901:7a7c590f2737
user:      augustss <augustss%NetBSD.org@localhost>
date:      Tue May 30 10:10:17 2000 +0000

description:
Use attribute packed for on-the-wire data structures.

diffstat:

 sys/dev/usb/uaudioreg.h |  36 ++++++++++++++++++------------------
 sys/dev/usb/usb.h       |  26 ++++++++++++++------------
 sys/dev/usb/usbcdc.h    |  16 ++++++++--------
 sys/dev/usb/usbhid.h    |   4 ++--
 4 files changed, 42 insertions(+), 40 deletions(-)

diffs (truncated from 361 to 300 lines):

diff -r 150a5325fb80 -r 7a7c590f2737 sys/dev/usb/uaudioreg.h
--- a/sys/dev/usb/uaudioreg.h   Tue May 30 09:26:19 2000 +0000
+++ b/sys/dev/usb/uaudioreg.h   Tue May 30 10:10:17 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uaudioreg.h,v 1.5 2000/04/27 15:26:47 augustss Exp $   */
+/*     $NetBSD: uaudioreg.h,v 1.6 2000/05/30 10:10:17 augustss Exp $   */
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
         */
        uByte           bRefresh;
        uByte           bSynchAddress;
-} usb_endpoint_descriptor_audio_t;
+} UPACKED usb_endpoint_descriptor_audio_t;
 
 struct usb_audio_control_descriptor {
        uByte           bLength;
@@ -81,7 +81,7 @@
        uWord           wTotalLength;
        uByte           bInCollection;
        uByte           baInterfaceNr[1];
-};
+} UPACKED;
 
 struct usb_audio_streaming_interface_descriptor {
        uByte           bLength;
@@ -90,7 +90,7 @@
        uByte           bTerminalLink;
        uByte           bDelay;
        uWord           wFormatTag;
-};
+} UPACKED;
 
 struct usb_audio_streaming_endpoint_descriptor {
        uByte           bLength;
@@ -99,7 +99,7 @@
        uByte           bmAttributes;
        uByte           bLockDelayUnits;
        uWord           wLockDelay;
-};
+} UPACKED;
 
 struct usb_audio_streaming_type1_descriptor {
        uByte           bLength;
@@ -115,13 +115,13 @@
 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
-};
+} UPACKED;
 
 struct usb_audio_cluster {
        uByte           bNrChannels;
        uWord           wChannelConfig;
        uByte           iChannelNames;
-};
+} UPACKED;
 
 /* UDESCSUB_AC_INPUT */
 struct usb_audio_input_terminal {
@@ -135,7 +135,7 @@
        uWord           wChannelConfig;
        uByte           iChannelNames;
        uByte           iTerminal;
-};
+} UPACKED;
 
 /* UDESCSUB_AC_OUTPUT */
 struct usb_audio_output_terminal {
@@ -147,7 +147,7 @@
        uByte           bAssocTerminal;
        uByte           bSourceId;
        uByte           iTerminal;
-};
+} UPACKED;
 
 /* UDESCSUB_AC_MIXER */
 struct usb_audio_mixer_unit {
@@ -158,14 +158,14 @@
        uByte           bNrInPins;
        uByte           baSourceId[255]; /* [bNrInPins] */
        /* struct usb_audio_mixer_unit_1 */
-};
+} UPACKED;
 struct usb_audio_mixer_unit_1 {
        uByte           bNrChannels;
        uWord           wChannelConfig;
        uByte           iChannelNames;
        uByte           bmControls[255]; /* [bNrChannels] */
        /*uByte         iMixer;*/
-};
+} UPACKED;
 
 /* UDESCSUB_AC_SELECTOR */
 struct usb_audio_selector_unit {
@@ -176,7 +176,7 @@
        uByte           bNrInPins;
        uByte           baSourceId[255]; /* [bNrInPins] */
        /* uByte        iSelector; */
-};
+} UPACKED;
 
 /* UDESCSUB_AC_FEATURE */
 struct usb_audio_feature_unit {
@@ -188,7 +188,7 @@
        uByte           bControlSize;
        uByte           bmaControls[255]; /* size for more than enough */
        /* uByte        iFeature; */
-};
+} UPACKED;
 
 /* UDESCSUB_AC_PROCESSING */
 struct usb_audio_processing_unit {
@@ -200,7 +200,7 @@
        uByte           bNrInPins;
        uByte           baSourceId[255]; /* [bNrInPins] */
        /* struct usb_audio_processing_unit_1 */
-};
+} UPACKED;
 struct usb_audio_processing_unit_1{
        uByte           bNrChannels;
        uWord           wChannelConfig;
@@ -208,13 +208,13 @@
        uByte           bControlSize;
        uByte           bmControls[255]; /* [bControlSize] */
 #define UA_PROC_ENABLE_MASK 1
-};
+} UPACKED;
 
 struct usb_audio_processing_unit_updown {
        uByte           iProcessing;
        uByte           bNrModes;
        uWord           waModes[255]; /* [bNrModes] */
-};
+} UPACKED;
 
 /* UDESCSUB_AC_EXTENSION */
 struct usb_audio_extension_unit {
@@ -226,7 +226,7 @@
        uByte           bNrInPins;
        uByte           baSourceId[255]; /* [bNrInPins] */
        /* struct usb_audio_extension_unit_1 */
-};
+} UPACKED;
 struct usb_audio_extension_unit_1 {
        uByte           bNrChannels;
        uWord           wChannelConfig;
@@ -236,7 +236,7 @@
 #define UA_EXT_ENABLE_MASK 1
 #define UA_EXT_ENABLE 1
        /*uByte         iExtension;*/
-};
+} UPACKED;
 
 #define UAT_STREAM 0x0101
 
diff -r 150a5325fb80 -r 7a7c590f2737 sys/dev/usb/usb.h
--- a/sys/dev/usb/usb.h Tue May 30 09:26:19 2000 +0000
+++ b/sys/dev/usb/usb.h Tue May 30 10:10:17 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.h,v 1.48 2000/04/27 15:26:49 augustss Exp $        */
+/*     $NetBSD: usb.h,v 1.49 2000/05/30 10:10:17 augustss Exp $        */
 /*     $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $        */
 
 /*
@@ -99,13 +99,15 @@
 #define USETW(w,v) (*(u_int16_t *)(w) = (v))
 #endif
 
+#define UPACKED __attribute__((__packed__))
+
 typedef struct {
        uByte           bmRequestType;
        uByte           bRequest;
        uWord           wValue;
        uWord           wIndex;
        uWord           wLength;
-} usb_device_request_t;
+} UPACKED usb_device_request_t;
 
 #define UT_WRITE               0x00
 #define UT_READ                        0x80
@@ -174,7 +176,7 @@
        uByte           bLength;
        uByte           bDescriptorType;
        uByte           bDescriptorSubtype;
-} usb_descriptor_t;
+} UPACKED usb_descriptor_t;
 
 typedef struct {
        uByte           bLength;
@@ -192,7 +194,7 @@
        uByte           iProduct;
        uByte           iSerialNumber;
        uByte           bNumConfigurations;
-} usb_device_descriptor_t;
+} UPACKED usb_device_descriptor_t;
 #define USB_DEVICE_DESCRIPTOR_SIZE 18
 
 typedef struct {
@@ -208,7 +210,7 @@
 #define UC_REMOTE_WAKEUP       0x20
        uByte           bMaxPower; /* max current in 2 mA units */
 #define UC_POWER_FACTOR 2
-} usb_config_descriptor_t;
+} UPACKED usb_config_descriptor_t;
 #define USB_CONFIG_DESCRIPTOR_SIZE 9
 
 typedef struct {
@@ -221,7 +223,7 @@
        uByte           bInterfaceSubClass;
        uByte           bInterfaceProtocol;
        uByte           iInterface;
-} usb_interface_descriptor_t;
+} UPACKED usb_interface_descriptor_t;
 #define USB_INTERFACE_DESCRIPTOR_SIZE 9
 
 typedef struct {
@@ -248,14 +250,14 @@
 #define UE_GET_ISO_TYPE(a)     ((a) & UE_ISO_TYPE)
        uWord           wMaxPacketSize;
        uByte           bInterval;
-} usb_endpoint_descriptor_t;
+} UPACKED usb_endpoint_descriptor_t;
 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
 
 typedef struct {
        uByte           bLength;
        uByte           bDescriptorType;
        uWord           bString[127];
-} usb_string_descriptor_t;
+} UPACKED usb_string_descriptor_t;
 #define USB_MAX_STRING_LEN 128
 #define USB_LANGUAGE_TABLE 0   /* # of the string language id table */
 
@@ -299,7 +301,7 @@
 #define UHD_NOT_REMOV(desc, i) \
     (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
        /* deprecated */ uByte          PortPowerCtrlMask[1];
-} usb_hub_descriptor_t;
+} UPACKED usb_hub_descriptor_t;
 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
 
 typedef struct {
@@ -309,14 +311,14 @@
 #define UDS_REMOTE_WAKEUP              0x0002
 /* Endpoint status flags */
 #define UES_HALT                       0x0001
-} usb_status_t;
+} UPACKED usb_status_t;
 
 typedef struct {
        uWord           wHubStatus;
 #define UHS_LOCAL_POWER                        0x0001
 #define UHS_OVER_CURRENT               0x0002
        uWord           wHubChange;
-} usb_hub_status_t;
+} UPACKED usb_hub_status_t;
 
 typedef struct {
        uWord           wPortStatus;
@@ -333,7 +335,7 @@
 #define UPS_C_SUSPEND                  0x0004
 #define UPS_C_OVERCURRENT_INDICATOR    0x0008
 #define UPS_C_PORT_RESET               0x0010
-} usb_port_status_t;
+} UPACKED usb_port_status_t;
 
 /* Device class codes */
 #define UDCLASS_AUDIO          0x00
diff -r 150a5325fb80 -r 7a7c590f2737 sys/dev/usb/usbcdc.h
--- a/sys/dev/usb/usbcdc.h      Tue May 30 09:26:19 2000 +0000
+++ b/sys/dev/usb/usbcdc.h      Tue May 30 10:10:17 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbcdc.h,v 1.6 2000/04/27 15:26:50 augustss Exp $      */
+/*     $NetBSD: usbcdc.h,v 1.7 2000/05/30 10:10:18 augustss Exp $      */
 /*     $FreeBSD: src/sys/dev/usb/usbcdc.h,v 1.7 1999/11/17 22:33:48 n_hibma Exp $      */
 
 /*
@@ -57,7 +57,7 @@
        uByte           bDescriptorType;
        uByte           bDescriptorSubtype;
        uWord           bcdCDC;
-} usb_cdc_header_descriptor_t;
+} UPACKED usb_cdc_header_descriptor_t;
 
 typedef struct {
        uByte           bLength;
@@ -67,7 +67,7 @@
 #define USB_CDC_CM_DOES_CM             0x01
 #define USB_CDC_CM_OVER_DATA           0x02
        uByte           bDataInterface;
-} usb_cdc_cm_descriptor_t;
+} UPACKED usb_cdc_cm_descriptor_t;
 
 typedef struct {
        uByte           bLength;
@@ -78,7 +78,7 @@
 #define USB_CDC_ACM_HAS_LINE           0x02



Home | Main Index | Thread Index | Old Index