From ca641bba8356851dd8144bde4a10bc5e5c647930 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 26 Mar 2009 03:22:02 +0000 Subject: [PATCH] Corrected bitfields -- the smallest datatype required for each bitfield is now used, rather than relying on GCC to truncate unused bytes in bitfields (thanks to Walt Sacuta). --- Demos/Device/MassStorage/SCSI.h | 44 +++++++++---------- Demos/Device/RNDISEthernet/IP.h | 20 ++++----- Demos/Device/RNDISEthernet/TCP.h | 4 +- .../Host/MassStorageHost/MassStoreCommands.h | 14 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Demos/Device/MassStorage/SCSI.h b/Demos/Device/MassStorage/SCSI.h index a0be39001b..58eea1b414 100644 --- a/Demos/Device/MassStorage/SCSI.h +++ b/Demos/Device/MassStorage/SCSI.h @@ -74,31 +74,31 @@ */ typedef struct { - unsigned int DeviceType : 5; - unsigned int PeripheralQualifier : 3; + unsigned char DeviceType : 5; + unsigned char PeripheralQualifier : 3; - unsigned int _RESERVED1 : 7; - unsigned int Removable : 1; + unsigned char _RESERVED1 : 7; + unsigned char Removable : 1; uint8_t Version; - unsigned int ResponseDataFormat : 4; - unsigned int _RESERVED2 : 1; - unsigned int NormACA : 1; - unsigned int TrmTsk : 1; - unsigned int AERC : 1; + unsigned char ResponseDataFormat : 4; + unsigned char _RESERVED2 : 1; + unsigned char NormACA : 1; + unsigned char TrmTsk : 1; + unsigned char AERC : 1; uint8_t AdditionalLength; uint8_t _RESERVED3[2]; - unsigned int SoftReset : 1; - unsigned int CmdQue : 1; - unsigned int _RESERVED4 : 1; - unsigned int Linked : 1; - unsigned int Sync : 1; - unsigned int WideBus16Bit : 1; - unsigned int WideBus32Bit : 1; - unsigned int RelAddr : 1; + unsigned char SoftReset : 1; + unsigned char CmdQue : 1; + unsigned char _RESERVED4 : 1; + unsigned char Linked : 1; + unsigned char Sync : 1; + unsigned char WideBus16Bit : 1; + unsigned char WideBus32Bit : 1; + unsigned char RelAddr : 1; uint8_t VendorID[8]; uint8_t ProductID[16]; @@ -114,11 +114,11 @@ uint8_t SegmentNumber; - unsigned int SenseKey : 4; - unsigned int _RESERVED1 : 1; - unsigned int ILI : 1; - unsigned int EOM : 1; - unsigned int FileMark : 1; + unsigned char SenseKey : 4; + unsigned char _RESERVED1 : 1; + unsigned char ILI : 1; + unsigned char EOM : 1; + unsigned char FileMark : 1; uint8_t Information[4]; uint8_t AdditionalLength; diff --git a/Demos/Device/RNDISEthernet/IP.h b/Demos/Device/RNDISEthernet/IP.h index 119d219e2e..be928e68f8 100644 --- a/Demos/Device/RNDISEthernet/IP.h +++ b/Demos/Device/RNDISEthernet/IP.h @@ -70,18 +70,18 @@ /** Type define of an IP packet header. */ typedef struct { - unsigned int HeaderLength : 4; /**< Total length of the packet header, in 4-byte blocks */ - unsigned int Version : 4; /**< IP protocol version */ - unsigned int TypeOfService : 8; /**< Special service type identifier, indicating delay/throughput/reliability levels */ - unsigned int TotalLength : 16; /**< Total length of the IP packet, in bytes */ + unsigned char HeaderLength : 4; /**< Total length of the packet header, in 4-byte blocks */ + unsigned char Version : 4; /**< IP protocol version */ + uint8_t TypeOfService; /**< Special service type identifier, indicating delay/throughput/reliability levels */ + uint16_t TotalLength; /**< Total length of the IP packet, in bytes */ - unsigned int Identification : 16; /**< Idenfication value for identifying fragmented packets */ - unsigned int FragmentOffset : 13; /**< Offset of this IP fragment */ - unsigned int Flags : 3; /**< Fragment flags, to indicate if a packet is fragmented */ + uint16_t Identification; /**< Idenfication value for identifying fragmented packets */ + unsigned int FragmentOffset : 13; /**< Offset of this IP fragment */ + unsigned int Flags : 3; /**< Fragment flags, to indicate if a packet is fragmented */ - unsigned int TTL : 8; /**< Maximum allowable number of hops to reach the packet destination */ - unsigned int Protocol : 8; /**< Encapsulated protocol type */ - unsigned int HeaderChecksum : 16; /**< Ethernet checksum of the IP header */ + uint8_t TTL; /**< Maximum allowable number of hops to reach the packet destination */ + uint8_t Protocol; /**< Encapsulated protocol type */ + uint16_t HeaderChecksum; /**< Ethernet checksum of the IP header */ IP_Address_t SourceAddress; /**< Source protocol IP address of the packet */ IP_Address_t DestinationAddress; /**< Destination protocol IP address of the packet */ diff --git a/Demos/Device/RNDISEthernet/TCP.h b/Demos/Device/RNDISEthernet/TCP.h index 21254859eb..25fa6575d3 100644 --- a/Demos/Device/RNDISEthernet/TCP.h +++ b/Demos/Device/RNDISEthernet/TCP.h @@ -221,8 +221,8 @@ uint32_t SequenceNumber; /**< Data sequence number of the packet */ uint32_t AcknowledgmentNumber; /**< Data acknowledgment number of the packet */ - unsigned int Reserved : 4; /**< Reserved, must be all 0 */ - unsigned int DataOffset : 4; /**< Offset of the data from the start of the header, in 4 byte chunks */ + unsigned char Reserved : 4; /**< Reserved, must be all 0 */ + unsigned char DataOffset : 4; /**< Offset of the data from the start of the header, in 4 byte chunks */ uint8_t Flags; /**< TCP packet flags */ uint16_t WindowSize; /**< Current data window size (bytes remaning in reception buffer) */ diff --git a/Demos/Host/MassStorageHost/MassStoreCommands.h b/Demos/Host/MassStorageHost/MassStoreCommands.h index d3ddfeeb92..adab4fb0a9 100644 --- a/Demos/Host/MassStorageHost/MassStoreCommands.h +++ b/Demos/Host/MassStorageHost/MassStoreCommands.h @@ -109,16 +109,16 @@ */ typedef struct { - unsigned int ReponseCode : 7; - unsigned int Valid : 1; + unsigned char ReponseCode : 7; + unsigned char Valid : 1; uint8_t SegmentNumber; - unsigned int SenseKey : 4; - unsigned int _RESERVED1 : 1; - unsigned int ILI : 1; - unsigned int EOM : 1; - unsigned int FileMark : 1; + unsigned char SenseKey : 4; + unsigned char _RESERVED1 : 1; + unsigned char ILI : 1; + unsigned char EOM : 1; + unsigned char FileMark : 1; uint8_t Information[4]; uint8_t AdditionalLength;