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 #ifdef SUPPORT_RPMB_PARTITION 74 #define RPMB_PARTITION_ID 14 75 #endif 76 77 typedef struct 78 { 79 uint32_t nInstructionID; 80 } DELEGATION_GENERIC_INSTRUCTION; 81 82 typedef struct 83 { 84 uint32_t nInstructionID; 85 uint32_t nMessageType; 86 uint32_t nMessageSize; 87 char nMessage[1]; 88 } DELEGATION_NOTIFY_INSTRUCTION; 89 90 typedef struct 91 { 92 uint32_t nInstructionID; 93 uint32_t nSectorID; 94 uint32_t nWorkspaceOffset; 95 } DELEGATION_RW_INSTRUCTION; 96 97 #ifdef SUPPORT_RPMB_PARTITION 98 typedef struct 99 { 100 uint32_t nInstructionID; 101 uint8_t nMAC[32]; 102 uint32_t nWorkspaceOffset[16]; 103 uint8_t pNonce[16]; 104 uint32_t nMC; 105 uint16_t nAddr; 106 uint16_t nBlockCount; 107 uint16_t nResult; 108 uint16_t nRequest; 109 } DELEGATION_RPMB_INSTRUCTION; 110 #endif 111 112 typedef struct 113 { 114 uint32_t nInstructionID; 115 uint32_t nNewSize; 116 } DELEGATION_SET_SIZE_INSTRUCTION; 117 118 typedef union 119 { 120 DELEGATION_GENERIC_INSTRUCTION sGeneric; 121 DELEGATION_NOTIFY_INSTRUCTION sNotify; 122 DELEGATION_RW_INSTRUCTION sReadWrite; 123 DELEGATION_SET_SIZE_INSTRUCTION sSetSize; 124 #ifdef SUPPORT_RPMB_PARTITION 125 DELEGATION_RPMB_INSTRUCTION sAuthRW; 126 #endif 127 } DELEGATION_INSTRUCTION; 128 129 typedef struct 130 { 131 uint32_t nSyncExecuted; 132 uint32_t nPartitionErrorStates[16]; 133 uint32_t nPartitionOpenSizes[16]; 134 } DELEGATION_ADMINISTRATIVE_DATA; 135 136 #endif /* __SERVICE_DELEGATION_PROTOCOL_H__ */ 137