41 lines
1.7 KiB
C
41 lines
1.7 KiB
C
#pragma once
|
|
// io_driver.h - driver-side interface for registering disk controllers
|
|
//
|
|
// DISK_DRIVER.SubmitIrp is the async path. IRP is forward-declared here so
|
|
// this header (and hal_disk.c) remain free of kernel sync-object dependencies.
|
|
// Drivers that implement SubmitIrp include ke_irp.h themselves.
|
|
|
|
#include <stdint.h>
|
|
#include <hal_api.h>
|
|
#include <ke_status.h>
|
|
#include <io_file.h>
|
|
|
|
typedef KSTATUS (*DRIVER_ENTRY_FN)(const HAL_API* hal);
|
|
typedef void (*DRIVER_UNLOAD_FN)(void);
|
|
|
|
// Forward declaration only - avoids dragging ke_event.h into the HAL layer.
|
|
struct IRP;
|
|
|
|
typedef struct DISK_DRIVER {
|
|
void *Ctx;
|
|
|
|
// --- Synchronous path (always present) ---------------------------------
|
|
KSTATUS (*ReadSectors) (void *ctx, uint64_t lba, uint32_t count, void *buf);
|
|
KSTATUS (*WriteSectors)(void *ctx, uint64_t lba, uint32_t count, const void *buf);
|
|
|
|
// --- Asynchronous path (optional) --------------------------------------
|
|
// NULL = driver has not implemented async; IoSubmitIrp() falls back to
|
|
// the sync path. Returns STATUS_PENDING when the IRP is accepted.
|
|
KSTATUS (*SubmitIrp)(void *ctx, struct IRP *irp);
|
|
|
|
uint64_t SectorCount;
|
|
} DISK_DRIVER;
|
|
|
|
__declspec(dllexport) KSTATUS IoRegisterDisk(uint8_t driveIndex, const DISK_DRIVER *driver);
|
|
|
|
// Internal dispatch used by ke_irp.c. Calls SubmitIrp if present, otherwise
|
|
// runs the sync callbacks inline and writes irp->Status; does NOT touch any
|
|
// kernel sync objects so it is safe to call from the HAL layer.
|
|
// Returns STATUS_PENDING (async path taken) or STATUS_SUCCESS (ran inline).
|
|
__declspec(dllexport) KSTATUS HalDiskDispatch(uint8_t drive, struct IRP *irp);
|