@@ -69,8 +69,12 @@ use self::emac_consts::*;
69
69
/// Note that Copy and Clone are derived to support initialising an
70
70
/// array of TDes, but you may not move a TDes after its address has
71
71
/// been given to the ETH_DMA engine.
72
+ ///
73
+ /// Both order and alignment is required by the ETH peripheral. The repr(C)
74
+ /// ensures that alignment of the members is 4 with no padding on the target
75
+ /// platform.
72
76
#[ derive( Copy , Clone ) ]
73
- #[ repr( C , packed ) ]
77
+ #[ repr( C ) ]
74
78
struct TDes {
75
79
tdes0 : u32 ,
76
80
tdes1 : u32 ,
@@ -94,7 +98,6 @@ impl TDes {
94
98
}
95
99
96
100
/// Store a ring of TDes and associated buffers
97
- #[ repr( C , packed) ]
98
101
struct TDesRing < const TD : usize > {
99
102
td : [ TDes ; TD ] ,
100
103
tbuf : [ [ u32 ; ETH_BUF_SIZE / 4 ] ; TD ] ,
@@ -187,7 +190,7 @@ impl<const TD: usize> TDesRing<TD> {
187
190
self . td [ x] . tdes2 = ( length as u32 ) & EMAC_TDES2_B1L ;
188
191
189
192
// Create a raw pointer in place without an intermediate reference. Use
190
- // this to return a slice from the packed buffer
193
+ // this to return a slice from the buffer
191
194
let addr = ptr:: addr_of_mut!( self . tbuf[ x] ) as * mut _ ;
192
195
core:: slice:: from_raw_parts_mut ( addr, len)
193
196
}
@@ -203,8 +206,12 @@ impl<const TD: usize> TDesRing<TD> {
203
206
/// Note that Copy and Clone are derived to support initialising an
204
207
/// array of RDes, but you may not move a RDes after its address has
205
208
/// been given to the ETH_DMA engine.
209
+ ///
210
+ /// Both order and alignment is required by the ETH peripheral. The repr(C)
211
+ /// ensures that alignment of the members is 4 with no padding on the target
212
+ /// platform.
206
213
#[ derive( Copy , Clone ) ]
207
- #[ repr( C , packed ) ]
214
+ #[ repr( C ) ]
208
215
struct RDes {
209
216
rdes0 : u32 ,
210
217
rdes1 : u32 ,
@@ -239,7 +246,6 @@ impl RDes {
239
246
}
240
247
241
248
/// Store a ring of RDes and associated buffers
242
- #[ repr( C , packed) ]
243
249
struct RDesRing < const RD : usize > {
244
250
rd : [ RDes ; RD ] ,
245
251
rbuf : [ [ u32 ; ETH_BUF_SIZE / 4 ] ; RD ] ,
0 commit comments