17310c0d0Sopenharmony_ci/* 27310c0d0Sopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 37310c0d0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47310c0d0Sopenharmony_ci * you may not use this file except in compliance with the License. 57310c0d0Sopenharmony_ci * You may obtain a copy of the License at 67310c0d0Sopenharmony_ci * 77310c0d0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87310c0d0Sopenharmony_ci * 97310c0d0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107310c0d0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117310c0d0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127310c0d0Sopenharmony_ci * See the License for the specific language governing permissions and 137310c0d0Sopenharmony_ci * limitations under the License. 147310c0d0Sopenharmony_ci */ 157310c0d0Sopenharmony_ci#ifndef __HVB_OPS_H_ 167310c0d0Sopenharmony_ci#define __HVB_OPS_H_ 177310c0d0Sopenharmony_ci#pragma once 187310c0d0Sopenharmony_ci 197310c0d0Sopenharmony_ci#include <stdbool.h> 207310c0d0Sopenharmony_ci#include <stdint.h> 217310c0d0Sopenharmony_ci 227310c0d0Sopenharmony_ci#ifdef __cplusplus 237310c0d0Sopenharmony_ciextern "C" 247310c0d0Sopenharmony_ci{ 257310c0d0Sopenharmony_ci#endif 267310c0d0Sopenharmony_ci 277310c0d0Sopenharmony_cienum hvb_io_errno { 287310c0d0Sopenharmony_ci HVB_IO_OK, 297310c0d0Sopenharmony_ci HVB_IO_ERROR_OOM, 307310c0d0Sopenharmony_ci HVB_IO_ERROR_IO, 317310c0d0Sopenharmony_ci HVB_IO_ERROR_NO_SUCH_PARTITION, 327310c0d0Sopenharmony_ci HVB_IO_ERROR_RANGE_OUTSIDE_PARTITION, 337310c0d0Sopenharmony_ci HVB_IO_ERROR_NO_SUCH_VALUE, 347310c0d0Sopenharmony_ci HVB_IO_ERROR_INVALID_VALUE_SIZE, 357310c0d0Sopenharmony_ci HVB_IO_ERROR_INSUFFICIENT_SPACE, 367310c0d0Sopenharmony_ci}; 377310c0d0Sopenharmony_ci 387310c0d0Sopenharmony_cistruct hvb_ops { 397310c0d0Sopenharmony_ci const void *user_data; 407310c0d0Sopenharmony_ci enum hvb_io_errno (*read_partition)(struct hvb_ops *ops, const char *ptn, int64_t offset, 417310c0d0Sopenharmony_ci uint64_t num_bytes, void *buffer, uint64_t *out_num_read); 427310c0d0Sopenharmony_ci enum hvb_io_errno (*write_partition)(struct hvb_ops *ops, const char *ptn, int64_t offset, 437310c0d0Sopenharmony_ci uint64_t num_bytes, const void *buffer); 447310c0d0Sopenharmony_ci enum hvb_io_errno (*valid_rvt_key)(struct hvb_ops *ops, const uint8_t *pubkey, 457310c0d0Sopenharmony_ci uint64_t pubkey_length, const uint8_t *pubkey_metadata, 467310c0d0Sopenharmony_ci uint64_t pubkey_metadata_length, bool *out_is_trusted); 477310c0d0Sopenharmony_ci enum hvb_io_errno (*read_rollback)(struct hvb_ops *ops, 487310c0d0Sopenharmony_ci uint64_t rollback_index_location, 497310c0d0Sopenharmony_ci uint64_t *out_rollback_index); 507310c0d0Sopenharmony_ci enum hvb_io_errno (*write_rollback)(struct hvb_ops *ops, uint64_t rollback_index_location, 517310c0d0Sopenharmony_ci uint64_t rollback_index); 527310c0d0Sopenharmony_ci enum hvb_io_errno (*read_lock_state)(struct hvb_ops *ops, bool *lock_state); 537310c0d0Sopenharmony_ci enum hvb_io_errno (*get_partiton_size)(struct hvb_ops *ops, const char *ptn, uint64_t *out_bytes); 547310c0d0Sopenharmony_ci}; 557310c0d0Sopenharmony_ci 567310c0d0Sopenharmony_ci#ifdef __cplusplus 577310c0d0Sopenharmony_ci} 587310c0d0Sopenharmony_ci#endif 597310c0d0Sopenharmony_ci 607310c0d0Sopenharmony_ci#endif