mirror of
https://github.com/Fennix-Project/Drivers.git
synced 2025-07-11 15:19:23 +00:00
Renamed "Disk" to "Storage"
This commit is contained in:
90
Storage/ATA/ATA.cpp
Normal file
90
Storage/ATA/ATA.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include <netools.h>
|
||||
#include <pci.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "../../../Kernel/DAPI.hpp"
|
||||
#include "../../../Kernel/Fex.hpp"
|
||||
|
||||
extern "C" int DriverEntry(void *Data);
|
||||
int CallbackHandler(KernelCallback *Data);
|
||||
|
||||
HEAD(FexFormatType_Driver, FexOSType_Fennix, DriverEntry);
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
|
||||
__attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
.Driver = {
|
||||
.Name = "ATA",
|
||||
.Type = FexDriverType_Storage,
|
||||
.Callback = CallbackHandler,
|
||||
.Bind = {
|
||||
.Type = BIND_INTERRUPT,
|
||||
.Interrupt = {
|
||||
.Vector = {0xE, 0xF}, // IRQ14, IRQ15
|
||||
}}}};
|
||||
|
||||
KernelAPI *KAPI;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
int DriverEntry(void *Data)
|
||||
{
|
||||
if (!Data)
|
||||
return INVALID_KERNEL_API;
|
||||
KAPI = (KernelAPI *)Data;
|
||||
if (KAPI->Version.Major < 0 || KAPI->Version.Minor < 0 || KAPI->Version.Patch < 0)
|
||||
return KERNEL_API_VERSION_NOT_SUPPORTED;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
switch (Data->Reason)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
case ConfigurationReason:
|
||||
{
|
||||
print("Kernel received configuration data.");
|
||||
break;
|
||||
}
|
||||
case FetchReason:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case InterruptReason:
|
||||
{
|
||||
if (Data->InterruptInfo.Vector == 0xE)
|
||||
{
|
||||
print("IRQ14");
|
||||
}
|
||||
else if (Data->InterruptInfo.Vector == 0xF)
|
||||
{
|
||||
print("IRQ15");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SendReason:
|
||||
case ReceiveReason:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
print("Unknown reason.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
Reference in New Issue
Block a user