64 lines
2.0 KiB
C
64 lines
2.0 KiB
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <ntlite/status.h>
|
|
|
|
typedef struct NTL_DEVICE NTL_DEVICE;
|
|
typedef struct NTL_DEVICE_RESOURCE NTL_DEVICE_RESOURCE;
|
|
|
|
typedef enum NTL_BUS_TYPE {
|
|
NtlBusPci = 1,
|
|
NtlBusUsb = 2,
|
|
} NTL_BUS_TYPE;
|
|
|
|
typedef struct NTL_DEVICE_MATCH {
|
|
NTL_BUS_TYPE Bus;
|
|
const char* Id;
|
|
} NTL_DEVICE_MATCH;
|
|
|
|
typedef KSTATUS (*NTL_DEVICE_START)(NTL_DEVICE* device);
|
|
typedef void (*NTL_DEVICE_STOP)(NTL_DEVICE* device);
|
|
typedef void (*NTL_DEVICE_CANCEL_START)(NTL_DEVICE* device);
|
|
|
|
typedef struct NTL_DEVICE_DESC {
|
|
uint32_t Size;
|
|
uint32_t Flags;
|
|
const char* Name;
|
|
const NTL_DEVICE_MATCH* Matches;
|
|
uint32_t MatchCount;
|
|
uint32_t ContextSize;
|
|
NTL_DEVICE_START Start;
|
|
NTL_DEVICE_STOP Stop;
|
|
NTL_DEVICE_CANCEL_START CancelStart;
|
|
} NTL_DEVICE_DESC;
|
|
|
|
#define NTL_DEVICE_DESCRIPTOR(nameValue, matchesValue, contextType, startFn, stopFn) \
|
|
{ sizeof(NTL_DEVICE_DESC), 0u, (nameValue), (matchesValue), \
|
|
(uint32_t)(sizeof(matchesValue) / sizeof((matchesValue)[0])), \
|
|
(uint32_t)sizeof(contextType), (startFn), (stopFn), 0 }
|
|
|
|
typedef void (*NTL_DEVICE_RESOURCE_RELEASE)(void* context);
|
|
|
|
#ifdef NTL_KERNEL_BUILD
|
|
#define NTL_DDK_DEVICE_API __declspec(dllexport)
|
|
#else
|
|
#define NTL_DDK_DEVICE_API __declspec(dllimport)
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
NTL_DDK_DEVICE_API void* NtlDeviceContext(NTL_DEVICE* device);
|
|
NTL_DDK_DEVICE_API const char* NtlDeviceId(NTL_DEVICE* device, uint32_t index);
|
|
NTL_DDK_DEVICE_API NTL_BUS_TYPE NtlDeviceBus(NTL_DEVICE* device);
|
|
NTL_DDK_DEVICE_API KSTATUS NtlDeviceCompleteStart(NTL_DEVICE* device, KSTATUS result);
|
|
NTL_DDK_DEVICE_API KSTATUS NtlDeviceOwnResource(NTL_DEVICE* device,
|
|
void* context,
|
|
NTL_DEVICE_RESOURCE_RELEASE release,
|
|
NTL_DEVICE_RESOURCE** out);
|
|
NTL_DDK_DEVICE_API KSTATUS NtlDeviceReleaseResource(NTL_DEVICE_RESOURCE* resource);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|