1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <stdbool.h> 20 #include <trusty_ipc.h> 21 #include "block_device.h" 22 23 typedef uint64_t ns_handle_t; 24 typedef uint64_t ns_off_t; 25 26 int ns_open_file(handle_t ipc_handle, 27 const char* name, 28 ns_handle_t* handlep, 29 bool create); 30 void ns_close_file(handle_t ipc_handle, ns_handle_t handle); 31 int ns_get_max_size(handle_t ipc_handle, 32 ns_handle_t handle, 33 data_block_t* size); 34 int ns_read_pos(handle_t ipc_handle, 35 ns_handle_t handle, 36 ns_off_t pos, 37 void* data, 38 int data_size); 39 int ns_write_pos(handle_t ipc_handle, 40 ns_handle_t handle, 41 ns_off_t pos, 42 const void* data, 43 int data_size, 44 bool is_userdata, 45 bool sync); 46