2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
5 Desc: DeviceTuple() function.
9 #include <proto/exec.h>
11 #include "card_intern.h"
13 AROS_LH2(ULONG
, DeviceTuple
,
14 AROS_LHA(UBYTE
*, tuple_data
, A0
),
15 AROS_LHA(struct DeviceTData
*, storage
, A1
),
16 struct CardResource
*, CardResource
, 13, Card
)
20 UWORD type
, tuplesize
, units
, size
, mantissa
, exponent
;
23 CARDDEBUG(bug("DeviceTuple(%p,%p)\n", tuple_data
, storage
));
25 storage
->dtd_DTspeed
= 0;
26 storage
->dtd_DTsize
= 0;
27 storage
->dtd_DTflags
= 0;
30 tuplesize
= tuple_data
[1];
32 if ((type
!= CISTPL_DEVICE
&& type
!= CISTPL_DEVICE_A
) || tuplesize
== 0)
37 storage
->dtd_DTtype
= tuple_data
[offset
] >> 4;
38 if (storage
->dtd_DTtype
> 7 && storage
->dtd_DTtype
!= 13)
41 if (tuplesize
>= offset
) {
42 switch (tuple_data
[offset
] & 7)
45 storage
->dtd_DTspeed
= 250;
48 storage
->dtd_DTspeed
= 200;
51 storage
->dtd_DTspeed
= 150;
54 storage
->dtd_DTspeed
= 100;
56 case 7: /* SPEED_EXT */
58 mantissa
= (tuple_data
[offset
] >> 3) & 15;
59 exponent
= tuple_data
[offset
] & 7;
61 storage
->dtd_DTspeed
= 10;
62 else if (mantissa
== 2)
63 storage
->dtd_DTspeed
= 12;
64 else if (mantissa
== 3)
65 storage
->dtd_DTspeed
= 13;
66 else if (mantissa
== 4)
67 storage
->dtd_DTspeed
= 15;
69 storage
->dtd_DTspeed
= 20 + (mantissa
- 5) * 5;
71 storage
->dtd_DTspeed
/= 2;
72 if (!storage
->dtd_DTspeed
)
73 storage
->dtd_DTspeed
= 1;
75 while (exponent
-- > 1)
76 storage
->dtd_DTspeed
*= 10;
78 /* skip possible extended data */
79 while (tuplesize
>= offset
&& (tuple_data
[offset
] & 0x80))
90 if (tuplesize
>= offset
) {
91 size
= tuple_data
[offset
] & 7;
92 units
= tuple_data
[offset
] >> 3;
93 storage
->dtd_DTsize
= (512 << (size
* 2)) * (units
+ 1);
94 } else if (storage
->dtd_DTtype
== 13) { /* IO device? */
95 storage
->dtd_DTsize
= 1;
98 storage
->dtd_DTflags
= 0;