1 /**
2  * Copyright(c) 2011 Trusted Logic.   All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *  * Neither the name Trusted Logic nor the names of its
15  *    contributors may be used to endorse or promote products derived
16  *    from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef __SERVICE_DELEGATION_PROTOCOL_H__
32 #define __SERVICE_DELEGATION_PROTOCOL_H__
33 
34 #include "s_type.h"
35 
36 /* -----------------------------------------------------------------------------
37    UUID
38 ----------------------------------------------------------------------------- */
39 /** Service Identifier: {71139E60-ECAE-11DF-98CF-0800200C9A66} */
40 #define SERVICE_DELEGATION_UUID { 0x71139e60, 0xecae, 0x11df, { 0x98, 0xcf, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
41 
42 
43 /* -----------------------------------------------------------------------------
44    Command identifiers
45 ----------------------------------------------------------------------------- */
46 /* See your Product Reference Manual for a specification of the delegation protocol */
47 
48 /**
49  * Command identifier : get instruction
50  *
51  */
52 #define SERVICE_DELEGATION_GET_INSTRUCTIONS      0x00000002
53 
54 /* Instruction codes */
55 #define DELEGATION_INSTRUCTION_SHUTDOWN             0xF0
56 #define DELEGATION_INSTRUCTION_NOTIFY               0xE0
57 
58 /* Partition-specific instruction codes (high-nibble encodes the partition identifier) */
59 #define DELEGATION_INSTRUCTION_PARTITION_CREATE     0x01
60 #define DELEGATION_INSTRUCTION_PARTITION_OPEN       0x02
61 #define DELEGATION_INSTRUCTION_PARTITION_READ       0x03
62 #define DELEGATION_INSTRUCTION_PARTITION_WRITE      0x04
63 #define DELEGATION_INSTRUCTION_PARTITION_SET_SIZE   0x05
64 #define DELEGATION_INSTRUCTION_PARTITION_SYNC       0x06
65 #define DELEGATION_INSTRUCTION_PARTITION_CLOSE      0x07
66 #define DELEGATION_INSTRUCTION_PARTITION_DESTROY    0x08
67 
68 #define DELEGATION_NOTIFY_TYPE_ERROR                0x000000E1
69 #define DELEGATION_NOTIFY_TYPE_WARNING              0x000000E2
70 #define DELEGATION_NOTIFY_TYPE_INFO                 0x000000E3
71 #define DELEGATION_NOTIFY_TYPE_DEBUG                0x000000E4
72 
73 typedef struct
74 {
75    uint32_t nInstructionID;
76 } DELEGATION_GENERIC_INSTRUCTION;
77 
78 typedef struct
79 {
80    uint32_t nInstructionID;
81    uint32_t nMessageType;
82    uint32_t nMessageSize;
83    char     nMessage[1];
84 } DELEGATION_NOTIFY_INSTRUCTION;
85 
86 typedef struct
87 {
88    uint32_t nInstructionID;
89    uint32_t nSectorID;
90    uint32_t nWorkspaceOffset;
91 } DELEGATION_RW_INSTRUCTION;
92 
93 typedef struct
94 {
95    uint32_t nInstructionID;
96    uint32_t nNewSize;
97 } DELEGATION_SET_SIZE_INSTRUCTION;
98 
99 typedef union
100 {
101    DELEGATION_GENERIC_INSTRUCTION    sGeneric;
102    DELEGATION_NOTIFY_INSTRUCTION     sNotify;
103    DELEGATION_RW_INSTRUCTION         sReadWrite;
104    DELEGATION_SET_SIZE_INSTRUCTION   sSetSize;
105 } DELEGATION_INSTRUCTION;
106 
107 typedef struct
108 {
109    uint32_t    nSyncExecuted;
110    uint32_t    nPartitionErrorStates[16];
111    uint32_t    nPartitionOpenSizes[16];
112 } DELEGATION_ADMINISTRATIVE_DATA;
113 
114 #endif /* __SERVICE_DELEGATION_PROTOCOL_H__ */
115