#ifndef _INIT_BLOCK_DRIVER_H_
#define _INIT_BLOCK_DRIVER_H_

#include <aos/aos.h>

/**
 * @brief action to be performed by the block driver server
 */
enum block_driver_action {
    BLOCK_DRIVER_ACTION_READ,
    BLOCK_DRIVER_ACTION_WRITE,
    BLOCK_DRIVER_ACTION_LOCK,
    BLOCK_DRIVER_ACTION_UNLOCK,
    BLOCK_DRIVER_ACTION_REGISTER_HANDLE,
    BLOCK_DRIVER_ACTION_UNREGISTER_HANDLE,
    BLOCK_DRIVER_ACTION_COUNT_HANDLES
};

/**
 * @brief request sent from the client to the block driver server
 */
struct block_driver_request {
    enum block_driver_action action;
    size_t block_number;
    size_t offset;
    size_t bytes;
    uint64_t directory_entry_id;
};

/**
 * @brief response by the block driver server
 */
struct block_driver_result {
    errval_t err;
};

/**
 * @brief initialize the block driver client by connecting to the server
 */
errval_t block_driver_init(void);

errval_t block_driver_read_object(uint32_t sector_number, size_t offset, size_t size, void *dst);
errval_t block_driver_write_object(uint32_t sector_number, size_t offset, size_t size, const void *src);
errval_t block_driver_lock(void);
errval_t block_driver_unlock(void);

errval_t block_driver_register_handle(uint64_t directory_entry_id);
errval_t block_driver_unregister_handle(uint64_t directory_entry_id);
errval_t block_driver_count_handles(uint64_t directory_entry_id, size_t *count);

#endif /* _INIT_BLOCK_DRIVER_H_ */