• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __HVB_OPS_H_
16 #define __HVB_OPS_H_
17 #pragma once
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif
26 
27 enum hvb_io_errno {
28     HVB_IO_OK,
29     HVB_IO_ERROR_OOM,
30     HVB_IO_ERROR_IO,
31     HVB_IO_ERROR_NO_SUCH_PARTITION,
32     HVB_IO_ERROR_RANGE_OUTSIDE_PARTITION,
33     HVB_IO_ERROR_NO_SUCH_VALUE,
34     HVB_IO_ERROR_INVALID_VALUE_SIZE,
35     HVB_IO_ERROR_INSUFFICIENT_SPACE,
36 };
37 
38 struct hvb_ops {
39     const void *user_data;
40     enum hvb_io_errno (*read_partition)(struct hvb_ops *ops, const char *ptn, int64_t offset,
41                         uint64_t num_bytes, void *buffer, uint64_t *out_num_read);
42     enum hvb_io_errno (*write_partition)(struct hvb_ops *ops, const char *ptn, int64_t offset,
43                          uint64_t num_bytes, const void *buffer);
44     enum hvb_io_errno (*valid_rvt_key)(struct hvb_ops *ops, const uint8_t *pubkey,
45                        uint64_t pubkey_length, const uint8_t *pubkey_metadata,
46                        uint64_t pubkey_metadata_length, bool *out_is_trusted);
47     enum hvb_io_errno (*read_rollback)(struct hvb_ops *ops,
48                        uint64_t rollback_index_location,
49                        uint64_t *out_rollback_index);
50     enum hvb_io_errno (*write_rollback)(struct hvb_ops *ops, uint64_t rollback_index_location,
51                         uint64_t rollback_index);
52     enum hvb_io_errno (*read_lock_state)(struct hvb_ops *ops, bool *lock_state);
53     enum hvb_io_errno (*get_partiton_size)(struct hvb_ops *ops, const char *ptn, uint64_t *out_bytes);
54 };
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif