mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Updated driver API
This commit is contained in:
parent
1633a34414
commit
bed43b3769
176
DAPI.hpp
176
DAPI.hpp
@ -23,10 +23,13 @@ enum DriverReturnCode
|
|||||||
NOT_AUTHORIZED,
|
NOT_AUTHORIZED,
|
||||||
NOT_VALID,
|
NOT_VALID,
|
||||||
NOT_ACCEPTED,
|
NOT_ACCEPTED,
|
||||||
|
INVALID_PCI_BAR,
|
||||||
INVALID_KERNEL_API,
|
INVALID_KERNEL_API,
|
||||||
|
INVALID_MEMORY_ALLOCATION,
|
||||||
|
INVALID_DATA,
|
||||||
DEVICE_NOT_SUPPORTED,
|
DEVICE_NOT_SUPPORTED,
|
||||||
SYSTEM_NOT_SUPPORTED,
|
SYSTEM_NOT_SUPPORTED,
|
||||||
KERNEL_API_VERSION_NOT_SUPPORTED
|
KERNEL_API_VERSION_NOT_SUPPORTED,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DriverBindType
|
enum DriverBindType
|
||||||
@ -73,6 +76,8 @@ struct KernelAPI
|
|||||||
void (*DisplayPrint)(char *Value);
|
void (*DisplayPrint)(char *Value);
|
||||||
void *(*memcpy)(void *Destination, void *Source, unsigned long Size);
|
void *(*memcpy)(void *Destination, void *Source, unsigned long Size);
|
||||||
void *(*memset)(void *Destination, int Value, unsigned long Size);
|
void *(*memset)(void *Destination, int Value, unsigned long Size);
|
||||||
|
void (*Sleep)(unsigned long Milliseconds);
|
||||||
|
int (*sprintf)(char *Buffer, const char *Format, ...);
|
||||||
} Util;
|
} Util;
|
||||||
|
|
||||||
struct KAPIDriverTalk
|
struct KAPIDriverTalk
|
||||||
@ -105,18 +110,78 @@ struct KernelAPI
|
|||||||
|
|
||||||
enum CallbackReason
|
enum CallbackReason
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief This is used to detect memory corruption, not used.
|
||||||
|
*/
|
||||||
UnknownReason,
|
UnknownReason,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is called once the kernel is ready to use the driver and call @see ConfigurationReason .
|
||||||
|
*/
|
||||||
AcknowledgeReason,
|
AcknowledgeReason,
|
||||||
SendReason,
|
|
||||||
ReceiveReason,
|
/**
|
||||||
|
* @brief This is used after the driver is loaded and the kernel is ready to use the driver.
|
||||||
|
*
|
||||||
|
* For PCI drivers, @see RawPtr will be the PCI device address.
|
||||||
|
*/
|
||||||
ConfigurationReason,
|
ConfigurationReason,
|
||||||
FetchReason,
|
|
||||||
StopReason,
|
/**
|
||||||
BindReason,
|
* @brief This will be called when the registered interrupt is triggered.
|
||||||
UnbindReason,
|
*/
|
||||||
InterruptReason,
|
InterruptReason,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is used when the kernel wants to stop the driver.
|
||||||
|
*
|
||||||
|
* The memory allocated by the driver will be freed automatically.
|
||||||
|
*/
|
||||||
|
StopReason,
|
||||||
|
|
||||||
ProcessReason,
|
ProcessReason,
|
||||||
InputReason,
|
InputReason,
|
||||||
|
|
||||||
|
/* Kernel reserved callbacks. */
|
||||||
|
/* ------------------------------------------------------- */
|
||||||
|
/* Driver callbacks for basic usage. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is used when the kernel sends data.
|
||||||
|
*
|
||||||
|
* - Network
|
||||||
|
* - Packet
|
||||||
|
* - Audio
|
||||||
|
* - PCM Data
|
||||||
|
*/
|
||||||
|
SendReason,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is used when the kernel wants to receive data.
|
||||||
|
* Currently not used.
|
||||||
|
*/
|
||||||
|
ReceiveReason,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is used to adjust driver settings.
|
||||||
|
*
|
||||||
|
* - Audio
|
||||||
|
* - Volume
|
||||||
|
* - PCM Encoding
|
||||||
|
*/
|
||||||
|
AdjustReason,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is used when the kernel wants to fetch information about the driver.
|
||||||
|
*
|
||||||
|
* - Input
|
||||||
|
* - Mouse
|
||||||
|
* - Position
|
||||||
|
* - Buttons
|
||||||
|
* - Keyboard
|
||||||
|
* - Key
|
||||||
|
*/
|
||||||
|
FetchReason,
|
||||||
};
|
};
|
||||||
|
|
||||||
union KernelCallback
|
union KernelCallback
|
||||||
@ -179,6 +244,103 @@ union KernelCallback
|
|||||||
} Mouse;
|
} Mouse;
|
||||||
} InputCallback;
|
} InputCallback;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool _Volume;
|
||||||
|
bool _Encoding;
|
||||||
|
bool _SampleRate;
|
||||||
|
bool _Channels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adjust the volume.
|
||||||
|
*
|
||||||
|
* 0 - 100
|
||||||
|
* @note It may be measured in decibels.
|
||||||
|
*/
|
||||||
|
unsigned char Volume;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adjust the encoding.
|
||||||
|
*
|
||||||
|
* 0 - None, use default
|
||||||
|
*
|
||||||
|
* 1 - Signed PCM 8-bit
|
||||||
|
* 2 - Unsigned PCM 8-bit
|
||||||
|
*
|
||||||
|
* 3 - Signed PCM 16-bit Little Endian
|
||||||
|
* 4 - Signed PCM 20-bit Little Endian
|
||||||
|
* 5 - Signed PCM 24-bit Little Endian
|
||||||
|
* 6 - Signed PCM 32-bit Little Endian
|
||||||
|
*
|
||||||
|
* 7 - Unsigned PCM 16-bit Little Endian
|
||||||
|
* 8 - Unsigned PCM 20-bit Little Endian
|
||||||
|
* 9 - Unsigned PCM 24-bit Little Endian
|
||||||
|
* 10 - Unsigned PCM 32-bit Little Endian
|
||||||
|
*
|
||||||
|
* 11 - Signed PCM 16-bit Big Endian
|
||||||
|
* 12 - Signed PCM 20-bit Big Endian
|
||||||
|
* 13 - Signed PCM 24-bit Big Endian
|
||||||
|
* 14 - Signed PCM 32-bit Big Endian
|
||||||
|
*
|
||||||
|
* 15 - Unsigned PCM 16-bit Big Endian
|
||||||
|
* 16 - Unsigned PCM 20-bit Big Endian
|
||||||
|
* 17 - Unsigned PCM 24-bit Big Endian
|
||||||
|
* 18 - Unsigned PCM 32-bit Big Endian
|
||||||
|
*
|
||||||
|
* 19 - Float PCM 32-bit Little Endian
|
||||||
|
* 20 - Float PCM 64-bit Little Endian
|
||||||
|
*
|
||||||
|
* 21 - Float PCM 32-bit Big Endian
|
||||||
|
* 22 - Float PCM 64-bit Big Endian
|
||||||
|
*
|
||||||
|
* 23 - PCM A-law
|
||||||
|
* 24 - PCM Mu-law
|
||||||
|
*
|
||||||
|
* ... - More
|
||||||
|
*/
|
||||||
|
unsigned short Encoding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adjust the sample rate.
|
||||||
|
*
|
||||||
|
* 0 - 8000 Hz
|
||||||
|
* 1 - 11025 Hz
|
||||||
|
* 2 - 16000 Hz
|
||||||
|
* 3 - 22050 Hz
|
||||||
|
* 4 - 32000 Hz
|
||||||
|
* 5 - 44100 Hz
|
||||||
|
* 6 - 48000 Hz
|
||||||
|
* 7 - 88200 Hz
|
||||||
|
* 8 - 96000 Hz
|
||||||
|
*/
|
||||||
|
unsigned char SampleRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adjust the channels.
|
||||||
|
*
|
||||||
|
* 0 - Mono
|
||||||
|
* 1 - Stereo
|
||||||
|
*/
|
||||||
|
unsigned char Channels;
|
||||||
|
} Adjust;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned char *Data;
|
||||||
|
unsigned long Length;
|
||||||
|
} Send;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned char Volume;
|
||||||
|
unsigned short Encoding;
|
||||||
|
unsigned char SampleRate;
|
||||||
|
unsigned char Channels;
|
||||||
|
} Fetch;
|
||||||
|
} AudioCallback;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned char Vector;
|
unsigned char Vector;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user