mirror of
https://github.com/Fennix-Project/Drivers.git
synced 2025-05-28 07:24:29 +00:00
Update example module
This commit is contained in:
parent
ed7b19ce63
commit
2ee57b9756
@ -1,14 +1,14 @@
|
|||||||
#include "../../../Kernel/DAPI.hpp"
|
#include "../../../Kernel/mapi.hpp"
|
||||||
#include "../../../Kernel/Fex.hpp"
|
#include "../../../Kernel/Fex.hpp"
|
||||||
|
|
||||||
extern "C" int DriverEntry(void *Data);
|
extern "C" int ModuleEntry(void *Data);
|
||||||
int CallbackHandler(KernelCallback *Data);
|
int CallbackHandler(KernelCallback *Data);
|
||||||
int InterruptCallback(CPURegisters *Registers);
|
int InterruptCallback(CPURegisters *Registers);
|
||||||
|
|
||||||
/* The driver is
|
/* The module is
|
||||||
* This is a driver for Fennix Driver Entry Extended Header
|
* This is a module for Fennix Module Entry Extended Header
|
||||||
* * * * */
|
* * * * */
|
||||||
HEAD(FexFormatType_Driver, FexOSType_Fennix, DriverEntry);
|
HEAD(FexFormatType_Module, FexOSType_Fennix, ModuleEntry);
|
||||||
|
|
||||||
/* Ignore the warning about missing field initializers. */
|
/* Ignore the warning about missing field initializers. */
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
@ -16,9 +16,9 @@ HEAD(FexFormatType_Driver, FexOSType_Fennix, DriverEntry);
|
|||||||
|
|
||||||
/* Extended header which is used to give additional information to the kernel. */
|
/* Extended header which is used to give additional information to the kernel. */
|
||||||
__attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
__attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||||
.Driver = {
|
.Module = {
|
||||||
.Name = "Example Driver",
|
.Name = "Example Module",
|
||||||
.Type = FexDriverType_Generic,
|
.Type = FexModuleType_Generic,
|
||||||
.Callback = CallbackHandler,
|
.Callback = CallbackHandler,
|
||||||
.InterruptCallback = InterruptCallback,
|
.InterruptCallback = InterruptCallback,
|
||||||
.Bind = {
|
.Bind = {
|
||||||
@ -33,13 +33,13 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
KernelAPI KAPI{};
|
KernelAPI KAPI{};
|
||||||
|
|
||||||
/* Macro that prints a message to the kernel debugger. */
|
/* Macro that prints a message to the kernel debugger. */
|
||||||
#define print(msg) KAPI.Util.DebugPrint((char *)(msg), KAPI.Info.DriverUID)
|
#define print(msg) KAPI.Util.DebugPrint((char *)(msg), KAPI.Info.modUniqueID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Driver entry point. This is called at initialization.
|
/* Module entry point. This is called at initialization.
|
||||||
"Data" argument points to the kernel API structure. */
|
"Data" argument points to the kernel API structure. */
|
||||||
int DriverEntry(void *Data)
|
int ModuleEntry(void *Data)
|
||||||
{
|
{
|
||||||
/* Check if kernel API is valid */
|
/* Check if kernel API is valid */
|
||||||
if (!Data)
|
if (!Data)
|
||||||
@ -59,20 +59,20 @@ int DriverEntry(void *Data)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is called when the driver is bound to an interrupt, process,
|
/* This is called when the module is bound to an interrupt, process,
|
||||||
or PCI device or when the kernel wants to send a message to the driver. */
|
or PCI device or when the kernel wants to send a message to the module. */
|
||||||
int CallbackHandler(KernelCallback *Data)
|
int CallbackHandler(KernelCallback *Data)
|
||||||
{
|
{
|
||||||
switch (Data->Reason)
|
switch (Data->Reason)
|
||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
print("Kernel acknowledged the driver.");
|
print("Kernel acknowledged the module.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case StopReason:
|
case StopReason:
|
||||||
{
|
{
|
||||||
print("Driver stopped.");
|
print("Module stopped.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user