Contiki 2.5
spc2_struct.h
1 #ifndef __SPC2_STRUCT_H__6R1KTJP0NJ__
2 #define __SPC2_STRUCT_H__6R1KTJP0NJ__
3 
4 typedef uint8_t uint40_bytes[5];
5 typedef uint8_t uint32_bytes[4];
6 typedef uint8_t uint16_bytes[2];
7 
8 #ifndef CC_BYTE_ALIGNED
9 #ifdef __GNUC__
10 #define CC_BYTE_ALIGNED __attribute__ ((packed))
11 #endif
12 #endif
13 
14 #ifndef CC_BYTE_ALIGNED
15 #define CC_BYTE_ALIGNED
16 #endif
17 
18 #define HOST16_TO_BE_BYTES(x) {(((x) >> 8) & 0xff), ((x) & 0xff)}
19 #define HOST32_TO_BE_BYTES(x) {(((x) >> 24) & 0xff), (((x) >> 16) & 0xff), \
20  (((x) >> 8) & 0xff), ((x) & 0xff)}
21 #define HOST40_TO_BE_BYTES(x) {(((x) >> 32) & 0xff), (((x) >> 24) & 0xff), (((x) >> 16) & 0xff), \
22  (((x) >> 8) & 0xff), ((x) & 0xff)}
23 
24 inline unsigned long
25 be16_to_host(uint16_bytes bytes)
26 {
27  return bytes[0] << 8 | bytes[1];
28 }
29 
30 inline unsigned long
31 be32_to_host(uint32_bytes bytes)
32 {
33  return (be16_to_host(bytes) << 16) | be16_to_host(bytes + 2);
34 }
35 
36 
37 #define BE16_TO_HOST(bytes) ((bytes)[0] << 8 | (bytes)[1])
38 #define BE32_TO_HOST(bytes) \
39 ((BE16_TO_HOST(bytes) << 16) | BE16_TO_HOST((bytes)+2))
40 struct spc2_inquiry_cmd
41 {
42  uint8_t op_code;
43  uint8_t flags;
44  uint8_t page;
45  uint8_t reserved;
46  uint8_t allocation_length;
47  uint8_t control;
48 } CC_BYTE_ALIGNED;
49 
50 struct spc2_std_inquiry_data
51 {
52  uint8_t device;
53  uint8_t flags1;
54  uint8_t version;
55  uint8_t flags2;
56  uint8_t additional_length;
57  uint8_t flags3;
58  uint8_t flags4;
59  uint8_t flags5;
60  char vendor_id[8];
61  char product_id[16];
62  char product_rev[4];
63 } CC_BYTE_ALIGNED;
64 
65 struct spc2_vital_product_data_head
66 {
67  uint8_t device;
68  uint8_t page;
69  uint8_t reserved;
70  uint8_t page_length;
71 } CC_BYTE_ALIGNED;
72 
73 struct spc2_identification_descriptor
74 {
75  uint8_t code_set;
76  uint8_t identifier_type;
77  uint8_t reserved;
78  uint8_t identifier_length;
79 };
80 
81 struct spc2_request_sense_cmd
82 {
83  uint8_t op_code;
84  uint8_t reserved1;
85  uint8_t reserved2;
86  uint8_t reserved3;
87  uint8_t allocation_length;
88  uint8_t control;
89 } CC_BYTE_ALIGNED;
90 
91 struct spc2_sense_data
92 {
93  uint8_t response_code;
94  uint8_t obsolete;
95  uint8_t sense_key;
96  uint8_t information[4];
97  uint8_t additional_length;
98  uint8_t command_specific[4];
99  uint8_t asc;
100  uint8_t ascq;
101  uint8_t unit_code;
102  uint8_t sense_key_specific[3];
103 } CC_BYTE_ALIGNED;
104 
105 struct spc2_mode_sence_6_cmd
106 {
107  uint8_t op_code;
108  uint8_t flags;
109  uint8_t page_code;
110  uint8_t reserved;
111  uint8_t allocation_length;
112  uint8_t control;
113 } CC_BYTE_ALIGNED;
114 
115 struct spc2_mode_select_6_cmd
116 {
117  uint8_t op_code;
118  uint8_t flags;
119  uint8_t reserved1;
120  uint8_t reserved2;
121  uint8_t parameter_list_length;
122  uint8_t control;
123 };
124 
125 struct spc2_mode_parameter_header_6
126 {
127  uint8_t mode_data_length;
128  uint8_t medium_type;
129  uint8_t device_specific_parameter;
130  uint8_t block_descriptor_length;
131 } CC_BYTE_ALIGNED;
132 
133 struct spc2_mode_page
134 {
135  uint8_t page_code;
136  uint8_t page_length;
137 } CC_BYTE_ALIGNED;
138 
139 #endif /* __SPC2_STRUCT_H__6R1KTJP0NJ__ */