Files
rust_raidguardx/raidguard_c_gui_server_mock/mock_driver.h
T
2026-03-29 14:53:26 +08:00

112 lines
2.5 KiB
C

#ifndef MOCK_DRIVER_H
#define MOCK_DRIVER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
// Types
typedef uint8_t UCHAR;
typedef uint16_t USHORT;
typedef uint32_t ULONG;
typedef int8_t CHAR;
typedef int SHORT;
typedef int BOOL;
// Constants
#define MAX_DTR_IN_HOST 4
#define MAX_EVENT_NO 512
#define MAX_EDB_SZ 512
// Status
#define CTLR_STATUS_ALIVE 0x01
#define CTLR_STATUS_DEAD 0x00
#define SYSOK 0x50
#define SYSFAIL 0x40
// Mock Controller Info Structure
typedef struct {
UCHAR bStatus;
UCHAR bCtlrSN[16];
UCHAR bModelName[32];
UCHAR bPad[16];
UCHAR bPage0Data[1024];
UCHAR bPage1Data[1024];
UCHAR bPage7Data[512];
UCHAR bPage10Data[1024];
UCHAR bPage11Data[1024];
UCHAR bPage14Data[1024];
UCHAR bPage20Data[512];
UCHAR bPage26Data[512];
UCHAR bPage27Data[512];
} MOCK_CTRL_INFO;
// Event Structure
typedef struct {
UCHAR bStatus;
UCHAR bEventBuf[MAX_EDB_SZ];
} EVENT_INFO;
// Function Declarations
// Initialization
void mock_init(void);
void mock_cleanup(void);
// Driver Functions
UCHAR mock_DevIoControl(
UCHAR bDevNo,
ULONG lControlCode,
ULONG lInSize,
char *pInBuf,
ULONG lOutSize,
char *pOutBuf,
USHORT *pusInBandErrCode);
CHAR mock_QuaryDTR(
UCHAR ucCtlrIndex,
UCHAR *bPageBuf,
UCHAR *pbHeatsink);
UCHAR mock_GetCtlrEvent(
UCHAR bCtlrNo,
EVENT_INFO *pEvent_info);
// Configuration
void mock_set_controller_count(int count);
void mock_set_controller_serial(int index, const char *sn);
void mock_set_controller_model(int index, const char *model);
void mock_set_controller_status(int index, UCHAR status);
void mock_set_verbose(bool verbose);
bool mock_is_verbose(void);
void mock_set_verbose(bool verbose);
// Event Simulation
void mock_push_event(UCHAR *eventData, int length);
void mock_clear_events(void);
void mock_generate_disk_event(int slot, int eventType);
void mock_generate_raid_event(int raidId, int eventType);
// Internal functions
void mock_fill_page0(int ctrlIndex);
void mock_fill_page1(int ctrlIndex);
void mock_fill_page7(int ctrlIndex);
void mock_fill_page10(int ctrlIndex);
void mock_fill_page11(int ctrlIndex);
void mock_fill_page14(int ctrlIndex);
void mock_fill_page27(int ctrlIndex);
void mock_register_default_events(void);
// Configuration File
int mock_load_config(const char *filename);
void mock_print_config(void);
// Accessors for testing
MOCK_CTRL_INFO* mock_get_ctrl_info(int index);
int mock_get_event_queue_count(void);
#endif // MOCK_DRIVER_H