Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use consistent __attribute__((__packed__)) #339

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parts/I2CPeripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class I2CPeripheral: public BasePeripheral
uint8_t writeRegAddr;
uint8_t isAddrRead :1; // Write bit on address. IDK if this is used given msgBits.isWrite.
uint8_t address :7;
}__attribute__ ((__packed__));
} __attribute__((__packed__));
};

using NativeI2CMsg_t = union NativeI2CMsg {
Expand All @@ -75,7 +75,7 @@ class I2CPeripheral: public BasePeripheral
uint8_t isWrite :1; // Write bit on address. IDK if this is used given msgBits.isWrite.
uint8_t address :7;
uint8_t data :8 ;
} __attribute__ ((__packed__));
} __attribute__((__packed__));
};

// I2C transaction handler.
Expand Down
4 changes: 2 additions & 2 deletions parts/components/MCP23S17.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using mcp_reg_bank_1_t = struct mcp_reg_bank_1_t {
uint8_t SEQOP :1;
uint8_t MIRROR :1;
uint8_t BANK :1;
} __attribute__ ((__packed__)) IOCON;
} __attribute__((__packed__)) IOCON;
};
uint8_t GPPU; //0x06
uint8_t INTF; //0x07
Expand Down Expand Up @@ -119,7 +119,7 @@ class MCP23S17: public SPIPeripheral
uint8_t READ :1;
uint8_t HADDR :3;
uint8_t _FIXED :4;
} __attribute__ ((__packed__));
} __attribute__((__packed__));
} m_hdr = {0};

union {
Expand Down
4 changes: 2 additions & 2 deletions parts/components/SDCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SDCard:public SPIPeripheral, public Scriptable, private IKeyClient
unsigned int address :32;
Command cmd :6;
unsigned char :2; // Start/position
} __attribute__ ((__packed__)) bits;
} __attribute__((__packed__)) bits;
uint8_t bytes[6];
} m_CmdIn {.all = 0};

Expand All @@ -161,7 +161,7 @@ class SDCard:public SPIPeripheral, public Scriptable, private IKeyClient
uint32_t function :4;
uint32_t mio :1;

} __attribute__ ((__packed__)) bits;
} __attribute__((__packed__)) bits;
};

struct {
Expand Down
14 changes: 7 additions & 7 deletions parts/components/TMC2130.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint32_t data :32; // 32 bits of data
uint8_t address :7;
uint8_t RW :1;
} __attribute__ ((__packed__)) bitsIn;
} __attribute__((__packed__)) bitsIn;
struct {
uint32_t data :32; // 32 bits of data
uint8_t reset_flag :1;
uint8_t driver_error :1;
uint8_t sg2 :1;
uint8_t standstill :1;
uint8_t :4; // unused
} __attribute__ ((__packed__)) bitsOut;
} __attribute__((__packed__)) bitsOut;
uint8_t bytes[5] {0,0,0,0,0}; // Raw bytes as piped in/out by SPI.
};

Expand Down Expand Up @@ -152,14 +152,14 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint8_t stop_enable :1;
uint8_t direct_mode :1;
uint16_t :14;
} __attribute__ ((__packed__)) GCONF; // 0x00
} __attribute__((__packed__)) GCONF; // 0x00
struct // 0x01
{
uint8_t reset :1;
uint8_t drv_err :1;
uint8_t uv_cp :1;
uint32_t :29; // unused
} __attribute__ ((__packed__)) GSTAT;
} __attribute__((__packed__)) GSTAT;
uint32_t _unimplemented[2]; //0x02 - 0x03
struct // 0x04
{
Expand All @@ -168,7 +168,7 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint8_t :1; // unused
uint16_t :16; // unused
uint8_t version :8;
} __attribute__ ((__packed__)) IOIN;
} __attribute__((__packed__)) IOIN;
uint32_t _unimplemented2[103]; //0x05 - 0x6B
struct //0x6C
{
Expand All @@ -189,7 +189,7 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint32_t dedge :1;
uint32_t diss2g :1;
uint32_t :1;
} __attribute__ ((__packed__)) CHOPCONF;
} __attribute__((__packed__)) CHOPCONF;
uint32_t _unimplemented3[2]; //0x6D - 0x6E
struct //0x6F
{
Expand All @@ -206,7 +206,7 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint8_t ola :1;
uint8_t olb :1;
uint8_t stst :1;
} __attribute__ ((__packed__)) DRV_STATUS;
} __attribute__((__packed__)) DRV_STATUS;
}defs;
};

Expand Down
6 changes: 3 additions & 3 deletions parts/components/usb_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct usb_device_descriptor {
byte iProduct; // Index of String Descriptor describing the product.
byte iSerialNumber; // Index of String Descriptor with the device's serial number.
byte bNumConfigurations; // Number of possible configurations.
} __attribute__ ((__packed__));
} __attribute__((__packed__));

struct usb_configuration_descriptor
{
Expand All @@ -74,7 +74,7 @@ struct usb_configuration_descriptor
byte iConfiguration; // Index of String Descriptor describing the configuration.
byte bmAttributes; // Configuration characteristics.
byte bMaxPower; // Maximum power consumed by this configuration.
} __attribute__ ((__packed__));
} __attribute__((__packed__));


struct usb_interface_descriptor
Expand All @@ -88,4 +88,4 @@ struct usb_interface_descriptor
byte bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
byte bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
byte iInterface; // Index of String Descriptor describing the interface.
} __attribute__ ((__packed__));
} __attribute__((__packed__));
28 changes: 14 additions & 14 deletions parts/components/usbip_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct usbip_usb_interface {
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t padding; /* alignment */
} __attribute__((packed));
} __attribute__((__packed__));

struct usbip_usb_device {
char path[USBIP_SYSFS_PATH_MAX];
Expand All @@ -51,7 +51,7 @@ struct usbip_usb_device {
uint8_t bConfigurationValue;
uint8_t bNumConfigurations;
uint8_t bNumInterfaces;
} __attribute__((packed));
} __attribute__((__packed__));


#define USBIP_PROTO_VERSION 0x111
Expand All @@ -66,41 +66,41 @@ struct usbip_op_common {
#define USBIP_ST_NA 0x01
uint32_t status;

} __attribute__((packed));
} __attribute__((__packed__));

#define USBIP_OP_DEVLIST 0x05

struct usbip_op_devlist_request {
} __attribute__((packed));
} __attribute__((__packed__));

struct usbip_op_devlist_reply {
uint32_t ndev;
/* followed by reply_extra[] */
} __attribute__((packed));
} __attribute__((__packed__));

struct usbip_op_devlist_reply_extra {
struct usbip_usb_device udev;
struct usbip_usb_interface uinf[];
} __attribute__((packed));
} __attribute__((__packed__));


#define USBIP_OP_IMPORT 0x03
struct usbip_op_import_request {
char busid[USBIP_SYSFS_BUS_ID_SIZE];
} __attribute__((packed));
} __attribute__((__packed__));

struct usbip_op_import_reply {
struct usbip_usb_device udev;
// struct usbip_usb_interface uinf[];
} __attribute__((packed));
} __attribute__((__packed__));

struct usbip_common_hdr {
uint32_t command;
uint32_t seqnum;
uint32_t devid; // (busnum << 16) | devnum
uint32_t direction;
uint32_t ep;
} __attribute__ ((__packed__));
} __attribute__((__packed__));

#define USBIP_CMD_SUBMIT 0x0001
#define USBIP_CMD_UNLINK 0x0002
Expand All @@ -117,7 +117,7 @@ struct usbip_cmd_submit {
int32_t number_of_packets;
int32_t interval;
unsigned char setup[8];
} __attribute__ ((__packed__));
} __attribute__((__packed__));

/*
+ Allowed transfer_flags | value | control | interrupt | bulk | isochronous
Expand All @@ -139,7 +139,7 @@ struct usbip_ret_submit {
int32_t number_of_packets;
int32_t error_count;
long long setup;
} __attribute__ ((__packed__));
} __attribute__((__packed__));


struct usbip_cmd_unlink {
Expand All @@ -149,7 +149,7 @@ struct usbip_cmd_unlink {
int32_t pad3;
int32_t pad4;
long long pad5;
} __attribute__ ((__packed__));
} __attribute__((__packed__));


struct usbip_ret_unlink {
Expand All @@ -159,7 +159,7 @@ struct usbip_ret_unlink {
int32_t pad3;
int32_t pad4;
long long pad5;
} __attribute__ ((__packed__));
} __attribute__((__packed__));

struct usbip_header {
struct usbip_common_hdr hdr;
Expand All @@ -169,4 +169,4 @@ struct usbip_header {
struct usbip_cmd_unlink unlink;
struct usbip_ret_unlink retunlink;
} u;
} __attribute__ ((__packed__));
} __attribute__((__packed__));