NVIDIA DRIVE OS Linux API Reference

5.1.3.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ote_storage_protocol.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2018, NVIDIA CORPORATION. All rights reserved
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files
6  * (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify, merge,
8  * publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef __OTE_STORAGE_PROTOCOL_H
25 #define __OTE_STORAGE_PROTOCOL_H
26 
27 /*
28  * Internal secure storage protocol declaration.
29  */
30 enum {
49 };
50 
51 /* configuration flags */
52 #define OTE_STORAGE_NS_CONFIG_FLAGS_RPMB_AVAILABLE (1 << 0)
53 #define OTE_STORAGE_NS_CONFIG_FLAGS_CPC_AVAILABLE (1 << 1)
54 #define OTE_STORAGE_NS_CONFIG_FLAGS_USE_1K_BLOCKS (1 << 2)
55 
56 #define OTE_MAX_DIR_NAME_LEN (64)
57 #define OTE_MAX_FILE_NAME_LEN (128)
58 #define OTE_MAX_DATA_SIZE (8192)
59 
60 #define DAEMON_FLAG_OP_GET_GLOBAL 0
61 #define DAEMON_FLAG_OP_SET_GLOBAL 1
62 #define DAEMON_FLAG_OP_SET_FILE 2
63 #define DAEMON_FLAG_OP_SYNC 3
64 
65 /* global daemon flags (apply to all files) */
66 #define DAEMON_GFLAG_NONE 0x0000
67 #define DAEMON_GFLAG_FSYNC 0x0001
68 #define DAEMON_GFLAG_FDATASYNC 0x0002
69 /* file and global flags */
70 #define DAEMON_GFLAG_FILE_O_DIRECT 0x0010
71 #define DAEMON_GFLAG_FILE_O_SYNC 0x0020
72 #define DAEMON_GFLAG_FILE_O_DSYNC 0x0040
73 #define DAEMON_GFLAG_FILE_O_APPEND 0x0080
74 #define DAEMON_GFLAG_FILE_O_ASYNC 0x0100
75 #define DAEMON_GFLAG_FILE_O_NOATIME 0x0200
76 #define DAEMON_GFLAG_FILE_O_NONBLOCK 0x0400
77 
78 typedef struct {
79  char dname[OTE_MAX_DIR_NAME_LEN];
80  char fname[OTE_MAX_FILE_NAME_LEN];
81  uint32_t flags;
83 
84 typedef struct {
85  char dname[OTE_MAX_DIR_NAME_LEN];
86  char fname[OTE_MAX_FILE_NAME_LEN];
88 
89 typedef struct {
90  char dname[OTE_MAX_DIR_NAME_LEN];
91  char fname[OTE_MAX_FILE_NAME_LEN];
92  uint32_t flags;
93  uint32_t handle;
95 
96 typedef struct {
97  uint32_t handle;
99 
100 typedef struct {
101  uint32_t handle;
102  uint32_t data_size;
103  char data[OTE_MAX_DATA_SIZE];
105 
106 typedef struct {
107  uint32_t handle;
108  uint32_t data_size;
109  char data[OTE_MAX_DATA_SIZE];
111 
112 typedef struct {
113  uint32_t handle;
114  uint32_t size;
116 
117 typedef struct {
118  uint32_t handle;
119  int32_t offset;
121 
122 typedef struct {
123  uint32_t handle;
124  uint32_t length;
126 
127 typedef struct {
128  char dname[OTE_MAX_DIR_NAME_LEN];
131 
132 typedef struct {
133  uint32_t handle;
135 
136 typedef struct {
137  uint32_t handle;
138  uint32_t opcode;
139  uint32_t flags;
141 
142 /* Lookup Nth non-secure side file name from given file system type.
143  * The order of names does not change, but they may not be sorted in any
144  * expected way (i.e. they are in directory order, not sorted alphabetically).
145  *
146  * If the given file system contains non-secure side directories, they will
147  * get traversed (according to file system specification). This applies currenlty
148  * only to old format directories.
149  *
150  * If filesystem does not contain non-secure side directories: dname[0] = '\000'
151  */
152 #define FS_TYPE_0 0
153 #define FS_TYPE_1 1
154 #define FS_TYPE_OLD 2
155 
156 typedef struct {
157  uint32_t fs_type; // type of filesystem
158  uint32_t index; // get Nth name
159  char dname[OTE_MAX_DIR_NAME_LEN];
162 
163 /* size in bytes of RPMB frame */
164 #define OTE_RPMB_FRAME_SIZE 512
165 
166 typedef struct {
167  uint8_t req_frame[OTE_RPMB_FRAME_SIZE];
168  uint8_t req_resp_frame[OTE_RPMB_FRAME_SIZE];
169  uint8_t resp_frame[OTE_RPMB_FRAME_SIZE];
171 
172 typedef struct {
173  uint8_t req_frame[OTE_RPMB_FRAME_SIZE];
174  uint8_t resp_frame[OTE_RPMB_FRAME_SIZE];
176 
177 /* size (with some padding) in bytes of CPC frame */
178 #define OTE_CPC_FRAME_SIZE 128
179 
180 typedef struct {
181  uint8_t frame[OTE_CPC_FRAME_SIZE];
183 
184 typedef union {
202 
203 #define OTE_STORAGE_PROTOCOL_MAGIC (0xfeedbeefcafebabe)
204 /*
205  * Holds a parameter block that is exchanged on each file system operation
206  * request.
207  */
208 typedef struct {
209  uint64_t magic;
210  uint32_t req_size;
211  uint32_t type;
213  uint32_t params_size;
215 } ote_ss_req_t;
216 
217 #endif
ote_file_flag_params_t f_flags
ote_file_close_params_t f_close
ote_file_get_size_params_t f_getsize
#define OTE_MAX_FILE_NAME_LEN
ote_rpmb_write_params_t f_rpmb_write
#define OTE_MAX_DIR_NAME_LEN
ote_file_get_name_params_t f_get_name
ote_file_trunc_params_t f_trunc
ote_cpc_io_params_t f_cpc_io
ote_file_req_params_t params
ote_file_delete_params_t f_delete
ote_rpmb_read_params_t f_rpmb_read
#define OTE_MAX_DATA_SIZE
#define OTE_RPMB_FRAME_SIZE
ote_file_sync_params_t f_sync
ote_file_write_params_t f_write
ote_file_test_exist_params_t f_test_exist
ote_file_read_params_t f_read
#define OTE_CPC_FRAME_SIZE
ote_file_open_params_t f_open
ote_file_create_params_t f_create
te_error_t
Defines Open Trusted Environment (OTE) error codes.
Definition: ote_error.h:45
ote_file_seek_params_t f_seek