1
1
//! Command TRBs.
2
2
3
- use super :: Link ;
3
+ use super :: { Link , Type } ;
4
4
use bit_field:: BitField ;
5
5
use core:: convert:: TryInto ;
6
+ use num_traits:: FromPrimitive ;
6
7
7
8
allowed ! {
8
9
/// TRBs which are allowed to be pushed to the Command Ring.
@@ -45,17 +46,66 @@ allowed! {
45
46
SetExtendedProperty
46
47
}
47
48
}
49
+ impl TryFrom < [ u32 ; 4 ] > for Allowed {
50
+ type Error = [ u32 ; 4 ] ;
51
+
52
+ fn try_from ( raw : [ u32 ; 4 ] ) -> Result < Self , Self :: Error > {
53
+ try_from ! (
54
+ raw =>
55
+ Link ,
56
+ EnableSlot ,
57
+ DisableSlot ,
58
+ AddressDevice ,
59
+ ConfigureEndpoint ,
60
+ EvaluateContext ,
61
+ ResetEndpoint ,
62
+ StopEndpoint ,
63
+ SetTrDequeuePointer ,
64
+ ResetDevice ,
65
+ ForceEvent ,
66
+ NegotiateBandwidth ,
67
+ SetLatencyToleranceValue ,
68
+ GetPortBandwidth ,
69
+ ForceHeader ,
70
+ Noop ( Command ) ,
71
+ GetExtendedProperty ,
72
+ SetExtendedProperty ,
73
+ ) ;
74
+ Err ( raw)
75
+ }
76
+ }
48
77
49
78
add_trb_with_default ! ( Noop , "No Op Command TRB" , Type :: NoopCommand ) ;
79
+ reserved ! ( Noop ( Type :: NoopCommand ) {
80
+ [ 0 ] 0 ..=31 ;
81
+ [ 1 ] 0 ..=31 ;
82
+ [ 2 ] 0 ..=31 ;
83
+ [ 3 ] 1 ..=9 ;
84
+ [ 3 ] 21 ..=31 ;
85
+ } ) ;
50
86
impl_debug_for_trb ! ( Noop { } ) ;
51
87
52
88
add_trb_with_default ! ( EnableSlot , "Enable Slot Command TRB" , Type :: EnableSlot ) ;
89
+ reserved ! ( EnableSlot ( Type :: EnableSlot ) {
90
+ [ 0 ] 0 ..=31 ;
91
+ [ 1 ] 0 ..=31 ;
92
+ [ 2 ] 0 ..=31 ;
93
+ [ 3 ] 1 ..=9 ;
94
+ [ 3 ] 21 ..=31 ;
95
+ } ) ;
53
96
impl EnableSlot {
54
97
rw_field ! ( [ 3 ] ( 16 ..=20 ) , slot_type, "Slot Type" , u8 ) ;
55
98
}
56
99
impl_debug_for_trb ! ( EnableSlot { slot_type } ) ;
57
100
58
101
add_trb_with_default ! ( DisableSlot , "Disable Slot Command TRB" , Type :: DisableSlot ) ;
102
+ reserved ! ( DisableSlot ( Type :: DisableSlot ) {
103
+ [ 0 ] 0 ..=31 ;
104
+ [ 1 ] 0 ..=31 ;
105
+ [ 2 ] 0 ..=31 ;
106
+ [ 3 ] 1 ..=9 ;
107
+ [ 3 ] 16 ..=23 ;
108
+ } ) ;
59
109
impl DisableSlot {
60
110
rw_field ! ( [ 3 ] ( 24 ..=31 ) , slot_id, "Slot ID" , u8 ) ;
61
111
}
@@ -66,6 +116,12 @@ add_trb_with_default!(
66
116
"Address Device Command TRB" ,
67
117
Type :: AddressDevice
68
118
) ;
119
+ reserved ! ( AddressDevice ( Type :: AddressDevice ) {
120
+ [ 0 ] 0 ..=3 ;
121
+ [ 2 ] 0 ..=31 ;
122
+ [ 3 ] 1 ..=8 ;
123
+ [ 3 ] 16 ..=23 ;
124
+ } ) ;
69
125
impl AddressDevice {
70
126
/// Sets the value of the Input Context Pointer field.
71
127
///
@@ -114,6 +170,12 @@ add_trb_with_default!(
114
170
"Configure Endpoint Command TRB" ,
115
171
Type :: ConfigureEndpoint
116
172
) ;
173
+ reserved ! ( ConfigureEndpoint ( Type :: ConfigureEndpoint ) {
174
+ [ 0 ] 0 ..=3 ;
175
+ [ 2 ] 0 ..=31 ;
176
+ [ 3 ] 1 ..=8 ;
177
+ [ 3 ] 16 ..=23 ;
178
+ } ) ;
117
179
impl ConfigureEndpoint {
118
180
/// Sets the value of the Input Context Pointer field.
119
181
///
@@ -158,6 +220,12 @@ add_trb_with_default!(
158
220
"Evaluate Context Command TRB" ,
159
221
Type :: EvaluateContext
160
222
) ;
223
+ reserved ! ( EvaluateContext ( Type :: EvaluateContext ) {
224
+ [ 0 ] 0 ..=3 ;
225
+ [ 2 ] 0 ..=31 ;
226
+ [ 3 ] 1 ..=8 ;
227
+ [ 3 ] 16 ..=23 ;
228
+ } ) ;
161
229
impl EvaluateContext {
162
230
/// Sets the value of the Input Context Pointer field.
163
231
///
@@ -199,6 +267,13 @@ add_trb_with_default!(
199
267
"Reset Endpoint Command TRB" ,
200
268
Type :: ResetEndpoint
201
269
) ;
270
+ reserved ! ( ResetEndpoint ( Type :: ResetEndpoint ) {
271
+ [ 0 ] 0 ..=31 ;
272
+ [ 1 ] 0 ..=31 ;
273
+ [ 2 ] 0 ..=31 ;
274
+ [ 3 ] 1 ..=8 ;
275
+ [ 3 ] 21 ..=23 ;
276
+ } ) ;
202
277
impl ResetEndpoint {
203
278
rw_bit ! ( [ 3 ] ( 9 ) , transfer_state_preserve, "Transfer State Preserve" ) ;
204
279
rw_field ! ( [ 3 ] ( 16 ..=20 ) , endpoint_id, "Endpoint ID" , u8 ) ;
@@ -215,6 +290,13 @@ add_trb_with_default!(
215
290
"Stop Endpoint Command TRB" ,
216
291
Type :: StopEndpoint
217
292
) ;
293
+ reserved ! ( StopEndpoint ( Type :: StopEndpoint ) {
294
+ [ 0 ] 0 ..=31 ;
295
+ [ 1 ] 0 ..=31 ;
296
+ [ 2 ] 0 ..=31 ;
297
+ [ 3 ] 1 ..=9 ;
298
+ [ 3 ] 21 ..=22 ;
299
+ } ) ;
218
300
impl StopEndpoint {
219
301
rw_field ! ( [ 3 ] ( 16 ..=20 ) , endpoint_id, "Endpoint ID" , u8 ) ;
220
302
rw_bit ! ( [ 3 ] ( 23 ) , suspend, "Suspend" ) ;
@@ -231,6 +313,11 @@ add_trb_with_default!(
231
313
"Set TR Dequeue Pointer Command TRB" ,
232
314
Type :: SetTrDequeuePointer
233
315
) ;
316
+ reserved ! ( SetTrDequeuePointer ( Type :: SetTrDequeuePointer ) {
317
+ [ 2 ] 0 ..=15 ;
318
+ [ 3 ] 1 ..=9 ;
319
+ [ 3 ] 21 ..=23 ;
320
+ } ) ;
234
321
impl SetTrDequeuePointer {
235
322
rw_bit ! ( [ 0 ] ( 0 ) , dequeue_cycle_state, "Dequeue Cycle State" ) ;
236
323
rw_field ! ( [ 0 ] ( 1 ..=3 ) , stream_context_type, "Stream Context Type" , u8 ) ;
@@ -278,12 +365,25 @@ impl_debug_for_trb!(SetTrDequeuePointer {
278
365
} ) ;
279
366
280
367
add_trb_with_default ! ( ResetDevice , "Reset Device Command TRB" , Type :: ResetDevice ) ;
368
+ reserved ! ( ResetDevice ( Type :: ResetDevice ) {
369
+ [ 0 ] 0 ..=31 ;
370
+ [ 1 ] 0 ..=31 ;
371
+ [ 2 ] 0 ..=31 ;
372
+ [ 3 ] 1 ..=9 ;
373
+ [ 3 ] 16 ..=23 ;
374
+ } ) ;
281
375
impl ResetDevice {
282
376
rw_field ! ( [ 3 ] ( 24 ..=31 ) , slot_id, "Slot ID" , u8 ) ;
283
377
}
284
378
impl_debug_for_trb ! ( ResetDevice { slot_id } ) ;
285
379
286
380
add_trb_with_default ! ( ForceEvent , "Force Event Command TRB" , Type :: ForceEvent ) ;
381
+ reserved ! ( ForceEvent ( Type :: ForceEvent ) {
382
+ [ 0 ] 0 ..=3 ;
383
+ [ 2 ] 0 ..=21 ;
384
+ [ 3 ] 1 ..=9 ;
385
+ [ 3 ] 24 ..=31 ;
386
+ } ) ;
287
387
impl ForceEvent {
288
388
/// Sets the value of the Event TRB Pointer field.
289
389
///
@@ -330,6 +430,13 @@ add_trb_with_default!(
330
430
"Negotiate Bandwidth Command TRB" ,
331
431
Type :: NegotiateBandwidth
332
432
) ;
433
+ reserved ! ( NegotiateBandwidth ( Type :: NegotiateBandwidth ) {
434
+ [ 0 ] 0 ..=31 ;
435
+ [ 1 ] 0 ..=31 ;
436
+ [ 2 ] 0 ..=31 ;
437
+ [ 3 ] 1 ..=9 ;
438
+ [ 3 ] 16 ..=23 ;
439
+ } ) ;
333
440
impl NegotiateBandwidth {
334
441
rw_field ! ( [ 3 ] ( 24 ..=31 ) , slot_id, "Slot ID" , u8 ) ;
335
442
}
@@ -340,6 +447,13 @@ add_trb_with_default!(
340
447
"Set Latency Tolerance Value Command TRB" ,
341
448
Type :: SetLatencyToleranceValue
342
449
) ;
450
+ reserved ! ( SetLatencyToleranceValue ( Type :: SetLatencyToleranceValue ) {
451
+ [ 0 ] 0 ..=31 ;
452
+ [ 1 ] 0 ..=31 ;
453
+ [ 2 ] 0 ..=31 ;
454
+ [ 3 ] 1 ..=9 ;
455
+ [ 3 ] 28 ..=31 ;
456
+ } ) ;
343
457
impl SetLatencyToleranceValue {
344
458
rw_field ! (
345
459
[ 3 ] ( 16 ..=27 ) ,
@@ -357,6 +471,12 @@ add_trb_with_default!(
357
471
"Get Port Bandwidth Command TRB" ,
358
472
Type :: GetPortBandwidth
359
473
) ;
474
+ reserved ! ( GetPortBandwidth ( Type :: GetPortBandwidth ) {
475
+ [ 0 ] 0 ..=3 ;
476
+ [ 2 ] 0 ..=31 ;
477
+ [ 3 ] 1 ..=9 ;
478
+ [ 3 ] 20 ..=23 ;
479
+ } ) ;
360
480
impl GetPortBandwidth {
361
481
/// Sets the value of the Port Bandwidth Context Pointer field.
362
482
///
@@ -396,6 +516,10 @@ impl_debug_for_trb!(GetPortBandwidth {
396
516
} ) ;
397
517
398
518
add_trb_with_default ! ( ForceHeader , "Force Header Command TRB" , Type :: ForceHeader ) ;
519
+ reserved ! ( ForceHeader ( Type :: ForceHeader ) {
520
+ [ 3 ] 1 ..=9 ;
521
+ [ 3 ] 16 ..=23 ;
522
+ } ) ;
399
523
impl ForceHeader {
400
524
rw_field ! ( [ 0 ] ( 0 ..=4 ) , packet_type, "Packet Type" , u8 ) ;
401
525
@@ -440,6 +564,11 @@ add_trb_with_default!(
440
564
"Get Extended Property Command TRB" ,
441
565
Type :: GetExtendedProperty
442
566
) ;
567
+ reserved ! ( GetExtendedProperty ( Type :: GetExtendedProperty ) {
568
+ [ 0 ] 0 ..=3 ;
569
+ [ 2 ] 16 ..=31 ;
570
+ [ 3 ] 1 ..=9 ;
571
+ } ) ;
443
572
impl GetExtendedProperty {
444
573
/// Sets the value of the Extended Property Context Pointer field.
445
574
///
@@ -493,6 +622,12 @@ add_trb_with_default!(
493
622
"Set Extended Property Command TRB" ,
494
623
Type :: SetExtendedProperty
495
624
) ;
625
+ reserved ! ( SetExtendedProperty ( Type :: SetExtendedProperty ) {
626
+ [ 0 ] 0 ..=31 ;
627
+ [ 1 ] 0 ..=31 ;
628
+ [ 2 ] 24 ..=31 ;
629
+ [ 3 ] 1 ..=9 ;
630
+ } ) ;
496
631
impl SetExtendedProperty {
497
632
rw_field ! (
498
633
[ 2 ] ( 0 ..=15 ) ,
0 commit comments