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 #ifndef TPM_MANAGER_COMMON_TPM_NVRAM_INTERFACE_H_ 18 #define TPM_MANAGER_COMMON_TPM_NVRAM_INTERFACE_H_ 19 20 #include <base/callback.h> 21 22 #include "tpm_manager/common/export.h" 23 #include "tpm_manager/common/tpm_manager.pb.h" 24 25 namespace tpm_manager { 26 27 // The command interface for working with TPM NVRAM. Inherited by both IPC proxy 28 // and service classes. All methods are asynchronous because all TPM operations 29 // may take a long time to finish. 30 class TPM_MANAGER_EXPORT TpmNvramInterface { 31 public: 32 virtual ~TpmNvramInterface() = default; 33 34 // Processes a DefineSpaceRequest and responds with a DefineSpaceReply. 35 using DefineSpaceCallback = base::Callback<void(const DefineSpaceReply&)>; 36 virtual void DefineSpace(const DefineSpaceRequest& request, 37 const DefineSpaceCallback& callback) = 0; 38 39 // Processes a DestroySpaceRequest and responds with a DestroySpaceReply. 40 using DestroySpaceCallback = base::Callback<void(const DestroySpaceReply&)>; 41 virtual void DestroySpace(const DestroySpaceRequest& request, 42 const DestroySpaceCallback& callback) = 0; 43 44 // Processes a WriteSpaceRequest and responds with a WriteSpaceReply. 45 using WriteSpaceCallback = base::Callback<void(const WriteSpaceReply&)>; 46 virtual void WriteSpace(const WriteSpaceRequest& request, 47 const WriteSpaceCallback& callback) = 0; 48 49 // Processes a ReadSpaceRequest and responds with a ReadSpaceReply. 50 using ReadSpaceCallback = base::Callback<void(const ReadSpaceReply&)>; 51 virtual void ReadSpace(const ReadSpaceRequest& request, 52 const ReadSpaceCallback& callback) = 0; 53 54 // Processes a LockSpaceRequest and responds with a LockSpaceReply. 55 using LockSpaceCallback = base::Callback<void(const LockSpaceReply&)>; 56 virtual void LockSpace(const LockSpaceRequest& request, 57 const LockSpaceCallback& callback) = 0; 58 59 // Processes a ListSpacesRequest and responds with a ListSpacesReply. 60 using ListSpacesCallback = base::Callback<void(const ListSpacesReply&)>; 61 virtual void ListSpaces(const ListSpacesRequest& request, 62 const ListSpacesCallback& callback) = 0; 63 64 // Processes a GetSpaceInfoRequest and responds with a GetSpaceInfoReply. 65 using GetSpaceInfoCallback = base::Callback<void(const GetSpaceInfoReply&)>; 66 virtual void GetSpaceInfo(const GetSpaceInfoRequest& request, 67 const GetSpaceInfoCallback& callback) = 0; 68 }; 69 70 } // namespace tpm_manager 71 72 #endif // TPM_MANAGER_COMMON_TPM_NVRAM_INTERFACE_H_ 73