1
2
3
4
5
6
7
8
9#include <linux/types.h>
10
11#ifndef _OPAL_PROTO_H
12#define _OPAL_PROTO_H
13
14
15
16
17
18
19enum {
20 TCG_SECP_00 = 0,
21 TCG_SECP_01,
22};
23
24
25
26
27
28
29enum opal_response_token {
30 OPAL_DTA_TOKENID_BYTESTRING = 0xe0,
31 OPAL_DTA_TOKENID_SINT = 0xe1,
32 OPAL_DTA_TOKENID_UINT = 0xe2,
33 OPAL_DTA_TOKENID_TOKEN = 0xe3,
34 OPAL_DTA_TOKENID_INVALID = 0X0
35};
36
37#define DTAERROR_NO_METHOD_STATUS 0x89
38#define GENERIC_HOST_SESSION_NUM 0x41
39#define FIRST_TPER_SESSION_NUM 4096
40
41#define TPER_SYNC_SUPPORTED 0x01
42
43#define LOCKING_SUPPORTED_MASK 0x01
44#define LOCKING_ENABLED_MASK 0x02
45#define LOCKED_MASK 0x04
46#define MBR_ENABLED_MASK 0x10
47#define MBR_DONE_MASK 0x20
48
49#define TINY_ATOM_DATA_MASK 0x3F
50#define TINY_ATOM_SIGNED 0x40
51
52#define SHORT_ATOM_ID 0x80
53#define SHORT_ATOM_BYTESTRING 0x20
54#define SHORT_ATOM_SIGNED 0x10
55#define SHORT_ATOM_LEN_MASK 0xF
56
57#define MEDIUM_ATOM_ID 0xC0
58#define MEDIUM_ATOM_BYTESTRING 0x10
59#define MEDIUM_ATOM_SIGNED 0x8
60#define MEDIUM_ATOM_LEN_MASK 0x7
61
62#define LONG_ATOM_ID 0xe0
63#define LONG_ATOM_BYTESTRING 0x2
64#define LONG_ATOM_SIGNED 0x1
65
66
67
68
69
70#define TINY_ATOM_BYTE 0x7F
71#define SHORT_ATOM_BYTE 0xBF
72#define MEDIUM_ATOM_BYTE 0xDF
73#define LONG_ATOM_BYTE 0xE3
74#define EMPTY_ATOM_BYTE 0xFF
75
76#define OPAL_INVAL_PARAM 12
77#define OPAL_MANUFACTURED_INACTIVE 0x08
78#define OPAL_DISCOVERY_COMID 0x0001
79
80#define LOCKING_RANGE_NON_GLOBAL 0x03
81
82
83
84
85
86#define OPAL_METHOD_LENGTH 8
87#define OPAL_MSID_KEYLEN 15
88#define OPAL_UID_LENGTH_HALF 4
89
90
91
92
93
94
95#define OPAL_BOOLEAN_AND 0
96#define OPAL_BOOLEAN_OR 1
97#define OPAL_BOOLEAN_NOT 2
98
99
100enum opal_uid {
101
102 OPAL_SMUID_UID,
103 OPAL_THISSP_UID,
104 OPAL_ADMINSP_UID,
105 OPAL_LOCKINGSP_UID,
106 OPAL_ENTERPRISE_LOCKINGSP_UID,
107 OPAL_ANYBODY_UID,
108 OPAL_SID_UID,
109 OPAL_ADMIN1_UID,
110 OPAL_USER1_UID,
111 OPAL_USER2_UID,
112 OPAL_PSID_UID,
113 OPAL_ENTERPRISE_BANDMASTER0_UID,
114 OPAL_ENTERPRISE_ERASEMASTER_UID,
115
116 OPAL_TABLE_TABLE,
117 OPAL_LOCKINGRANGE_GLOBAL,
118 OPAL_LOCKINGRANGE_ACE_START_TO_KEY,
119 OPAL_LOCKINGRANGE_ACE_RDLOCKED,
120 OPAL_LOCKINGRANGE_ACE_WRLOCKED,
121 OPAL_MBRCONTROL,
122 OPAL_MBR,
123 OPAL_AUTHORITY_TABLE,
124 OPAL_C_PIN_TABLE,
125 OPAL_LOCKING_INFO_TABLE,
126 OPAL_ENTERPRISE_LOCKING_INFO_TABLE,
127 OPAL_DATASTORE,
128
129 OPAL_C_PIN_MSID,
130 OPAL_C_PIN_SID,
131 OPAL_C_PIN_ADMIN1,
132
133 OPAL_HALF_UID_AUTHORITY_OBJ_REF,
134 OPAL_HALF_UID_BOOLEAN_ACE,
135
136 OPAL_UID_HEXFF,
137};
138
139
140enum opal_method {
141 OPAL_PROPERTIES,
142 OPAL_STARTSESSION,
143 OPAL_REVERT,
144 OPAL_ACTIVATE,
145 OPAL_EGET,
146 OPAL_ESET,
147 OPAL_NEXT,
148 OPAL_EAUTHENTICATE,
149 OPAL_GETACL,
150 OPAL_GENKEY,
151 OPAL_REVERTSP,
152 OPAL_GET,
153 OPAL_SET,
154 OPAL_AUTHENTICATE,
155 OPAL_RANDOM,
156 OPAL_ERASE,
157};
158
159enum opal_token {
160
161 OPAL_TRUE = 0x01,
162 OPAL_FALSE = 0x00,
163 OPAL_BOOLEAN_EXPR = 0x03,
164
165 OPAL_TABLE = 0x00,
166 OPAL_STARTROW = 0x01,
167 OPAL_ENDROW = 0x02,
168 OPAL_STARTCOLUMN = 0x03,
169 OPAL_ENDCOLUMN = 0x04,
170 OPAL_VALUES = 0x01,
171
172 OPAL_TABLE_UID = 0x00,
173 OPAL_TABLE_NAME = 0x01,
174 OPAL_TABLE_COMMON = 0x02,
175 OPAL_TABLE_TEMPLATE = 0x03,
176 OPAL_TABLE_KIND = 0x04,
177 OPAL_TABLE_COLUMN = 0x05,
178 OPAL_TABLE_COLUMNS = 0x06,
179 OPAL_TABLE_ROWS = 0x07,
180 OPAL_TABLE_ROWS_FREE = 0x08,
181 OPAL_TABLE_ROW_BYTES = 0x09,
182 OPAL_TABLE_LASTID = 0x0A,
183 OPAL_TABLE_MIN = 0x0B,
184 OPAL_TABLE_MAX = 0x0C,
185
186 OPAL_PIN = 0x03,
187
188 OPAL_RANGESTART = 0x03,
189 OPAL_RANGELENGTH = 0x04,
190 OPAL_READLOCKENABLED = 0x05,
191 OPAL_WRITELOCKENABLED = 0x06,
192 OPAL_READLOCKED = 0x07,
193 OPAL_WRITELOCKED = 0x08,
194 OPAL_ACTIVEKEY = 0x0A,
195
196 OPAL_LIFECYCLE = 0x06,
197
198 OPAL_MAXRANGES = 0x04,
199
200 OPAL_MBRENABLE = 0x01,
201 OPAL_MBRDONE = 0x02,
202
203 OPAL_HOSTPROPERTIES = 0x00,
204
205 OPAL_STARTLIST = 0xf0,
206 OPAL_ENDLIST = 0xf1,
207 OPAL_STARTNAME = 0xf2,
208 OPAL_ENDNAME = 0xf3,
209 OPAL_CALL = 0xf8,
210 OPAL_ENDOFDATA = 0xf9,
211 OPAL_ENDOFSESSION = 0xfa,
212 OPAL_STARTTRANSACTON = 0xfb,
213 OPAL_ENDTRANSACTON = 0xfC,
214 OPAL_EMPTYATOM = 0xff,
215 OPAL_WHERE = 0x00,
216};
217
218
219enum opal_lockingstate {
220 OPAL_LOCKING_READWRITE = 0x01,
221 OPAL_LOCKING_READONLY = 0x02,
222 OPAL_LOCKING_LOCKED = 0x03,
223};
224
225enum opal_parameter {
226 OPAL_SUM_SET_LIST = 0x060000,
227};
228
229enum opal_revertlsp {
230 OPAL_KEEP_GLOBAL_RANGE_KEY = 0x060000,
231};
232
233
234
235
236
237
238
239struct opal_compacket {
240 __be32 reserved0;
241 u8 extendedComID[4];
242 __be32 outstandingData;
243 __be32 minTransfer;
244 __be32 length;
245};
246
247
248struct opal_packet {
249 __be32 tsn;
250 __be32 hsn;
251 __be32 seq_number;
252 __be16 reserved0;
253 __be16 ack_type;
254 __be32 acknowledgment;
255 __be32 length;
256};
257
258
259struct opal_data_subpacket {
260 u8 reserved0[6];
261 __be16 kind;
262 __be32 length;
263};
264
265
266struct opal_header {
267 struct opal_compacket cp;
268 struct opal_packet pkt;
269 struct opal_data_subpacket subpkt;
270};
271
272#define FC_TPER 0x0001
273#define FC_LOCKING 0x0002
274#define FC_GEOMETRY 0x0003
275#define FC_ENTERPRISE 0x0100
276#define FC_DATASTORE 0x0202
277#define FC_SINGLEUSER 0x0201
278#define FC_OPALV100 0x0200
279#define FC_OPALV200 0x0203
280
281
282
283
284
285
286struct d0_header {
287 __be32 length;
288 __be32 revision;
289 __be32 reserved01;
290 __be32 reserved02;
291
292
293
294
295 u8 ignored[32];
296};
297
298
299
300
301
302
303
304
305struct d0_tper_features {
306
307
308
309
310
311
312
313
314
315
316
317 u8 supported_features;
318
319
320
321
322 u8 reserved01[3];
323 __be32 reserved02;
324 __be32 reserved03;
325};
326
327
328
329
330
331
332
333
334struct d0_locking_features {
335
336
337
338
339
340
341
342
343
344
345 u8 supported_features;
346
347
348
349
350 u8 reserved01[3];
351 __be32 reserved02;
352 __be32 reserved03;
353};
354
355
356
357
358
359
360
361
362struct d0_geometry_features {
363
364
365
366 u8 header[4];
367
368
369
370
371
372 u8 reserved01;
373 u8 reserved02[7];
374 __be32 logical_block_size;
375 __be64 alignment_granularity;
376 __be64 lowest_aligned_lba;
377};
378
379
380
381
382
383
384struct d0_enterprise_ssc {
385 __be16 baseComID;
386 __be16 numComIDs;
387
388
389
390
391 u8 range_crossing;
392 u8 reserved01;
393 __be16 reserved02;
394 __be32 reserved03;
395 __be32 reserved04;
396};
397
398
399
400
401
402
403struct d0_opal_v100 {
404 __be16 baseComID;
405 __be16 numComIDs;
406};
407
408
409
410
411
412
413struct d0_single_user_mode {
414 __be32 num_locking_objects;
415
416
417
418
419
420
421 u8 reserved01;
422 u8 reserved02;
423 __be16 reserved03;
424 __be32 reserved04;
425};
426
427
428
429
430
431
432struct d0_datastore_table {
433 __be16 reserved01;
434 __be16 max_tables;
435 __be32 max_size_tables;
436 __be32 table_size_alignment;
437};
438
439
440
441
442
443
444struct d0_opal_v200 {
445 __be16 baseComID;
446 __be16 numComIDs;
447
448
449
450
451 u8 range_crossing;
452
453
454
455
456
457
458 u8 num_locking_admin_auth[2];
459
460
461
462
463
464
465 u8 num_locking_user_auth[2];
466 u8 initialPIN;
467 u8 revertedPIN;
468 u8 reserved01;
469 __be32 reserved02;
470};
471
472
473struct d0_features {
474 __be16 code;
475
476
477
478
479
480 u8 r_version;
481 u8 length;
482 u8 features[];
483};
484
485#endif
486