CHanged the drivers classes a bit...
parent
05af3a87fa
commit
7adcfafba1
|
@ -10,7 +10,6 @@ namespace cb {
|
|||
class CKernel;
|
||||
|
||||
typedef struct {
|
||||
const s8 *Name;
|
||||
IDriver *Driver;
|
||||
bool New;
|
||||
bool Loaded;
|
||||
|
|
|
@ -8,14 +8,6 @@
|
|||
namespace cb {
|
||||
class CDriverRamdisk : public IDriver, IDevice {
|
||||
public:
|
||||
// Driver interface
|
||||
const s8 *GetName(void);
|
||||
const s8 *GetDescription(void);
|
||||
const s8 *GetAuthor(void);
|
||||
EDriverClass GetClass(void);
|
||||
EDriverLoadMethod GetLoadMethod(void);
|
||||
bool CanUnload(void);
|
||||
|
||||
u8 Load(CKernel *Kernel);
|
||||
u8 Unload(void);
|
||||
|
||||
|
@ -23,7 +15,6 @@ namespace cb {
|
|||
u32 GetSize(void);
|
||||
const u8 *Read(u32 Offset, u32 Length);
|
||||
void Write(u32 Offset, u32 Length, const u8 *Data);
|
||||
IDeviceOperations GetSupportedOperations(void);
|
||||
private:
|
||||
CKernel *m_Kernel;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,8 @@ namespace cb {
|
|||
virtual u32 GetSize(void) = 0;
|
||||
virtual const u8 *Read(u32 Offset, u32 Length) = 0;
|
||||
virtual void Write(u32 Offset, u32 Length, const u8 *Data) = 0;
|
||||
virtual IDeviceOperations GetSupportedOperations(void) = 0;
|
||||
|
||||
IDeviceOperations m_DeviceOperations;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -19,16 +19,17 @@ namespace cb {
|
|||
EDLM_USBPRESENT = 4
|
||||
};
|
||||
class IDriver {
|
||||
public:
|
||||
virtual const s8 *GetName(void) = 0;
|
||||
virtual const s8 *GetDescription(void) = 0;
|
||||
virtual const s8 *GetAuthor(void) = 0;
|
||||
virtual EDriverClass GetClass(void) = 0;
|
||||
virtual EDriverLoadMethod GetLoadMethod(void) = 0;
|
||||
virtual bool CanUnload(void) = 0;
|
||||
|
||||
virtual u8 Load(CKernel *Kernel) = 0;
|
||||
public:virtual u8 Load(CKernel *Kernel) = 0;
|
||||
virtual u8 Unload(void) = 0;
|
||||
|
||||
const s8 *m_Name;
|
||||
const s8 *m_Description;
|
||||
const s8 *m_Author;
|
||||
|
||||
EDriverClass m_Class;
|
||||
EDriverLoadMethod m_LoadMethod;
|
||||
|
||||
bool m_Unloadable;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -8,13 +8,6 @@
|
|||
namespace cb {
|
||||
class CDriverDummy : public IDriver {
|
||||
public:
|
||||
const s8 *GetName(void);
|
||||
const s8 *GetDescription(void);
|
||||
const s8 *GetAuthor(void);
|
||||
EDriverClass GetClass(void);
|
||||
EDriverLoadMethod GetLoadMethod(void);
|
||||
bool CanUnload(void);
|
||||
|
||||
u8 Load(CKernel *Kernel);
|
||||
u8 Unload(void);
|
||||
private:
|
||||
|
|
|
@ -47,7 +47,7 @@ void CKernel::Start(void)
|
|||
|
||||
m_DriverManager->LoadNew();
|
||||
|
||||
PANIC("the programmer is an idiot");
|
||||
//PANIC("the programmer is an idiot");
|
||||
|
||||
for (;;) {}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,10 @@ void CDriverManager::AddDriver(IDriver *Driver)
|
|||
while (m_aDrivers[Index].Present)
|
||||
Index++;
|
||||
|
||||
m_aDrivers[Index].Name = Driver->GetName();
|
||||
m_aDrivers[Index].Present = true;
|
||||
m_aDrivers[Index].New = true;
|
||||
m_aDrivers[Index].Loaded = false;
|
||||
m_aDrivers[Index].Driver = Driver;
|
||||
|
||||
m_Kernel->Logger() << "Added driver " << Driver->GetName() << ".";
|
||||
m_Kernel->Logger().Flush();
|
||||
}
|
||||
|
||||
void CDriverManager::LoadNew(void)
|
||||
|
@ -42,18 +38,17 @@ void CDriverManager::LoadNew(void)
|
|||
void CDriverManager::LoadDriver(u32 Index)
|
||||
{
|
||||
IDriver *Driver = m_aDrivers[Index].Driver;
|
||||
m_Kernel->Logger() << "Loading driver " << Driver->GetName() << "...";
|
||||
|
||||
|
||||
u8 Result = Driver->Load(m_Kernel);
|
||||
if (Result == 0)
|
||||
{
|
||||
m_aDrivers[Index].Loaded = true;
|
||||
m_Kernel->Logger() << " Success.";
|
||||
m_Kernel->Logger() << "Loaded driver " << Driver->m_Name << ".";
|
||||
m_Kernel->Logger().Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Kernel->Logger() << " Failure.";
|
||||
m_Kernel->Logger() << "Could not load driver.";
|
||||
m_Kernel->Logger().Flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
#include "Tier1/Drivers/Device/CDriverRamdisk.h"
|
||||
using namespace cb;
|
||||
|
||||
const s8 *CDriverRamdisk::GetDescription(void)
|
||||
{ return "Ramdisk Driver"; }
|
||||
const s8 *CDriverRamdisk::GetName(void)
|
||||
{ return "org.q3k.drivers.ramdisk"; }
|
||||
const s8 *CDriverRamdisk::GetAuthor(void)
|
||||
{ return "Sergiusz Bazanski"; }
|
||||
EDriverClass CDriverRamdisk::GetClass(void)
|
||||
{ return EDC_DEVICE; }
|
||||
EDriverLoadMethod CDriverRamdisk::GetLoadMethod(void)
|
||||
{ return EDLM_ALWAYS; }
|
||||
bool CDriverRamdisk::CanUnload(void)
|
||||
{ return false; }
|
||||
|
||||
u8 CDriverRamdisk::Load(CKernel *Kernel)
|
||||
{
|
||||
m_Name = "org.q3k.drivers.ramdisk";
|
||||
m_Description = "Ramdisk Driver";
|
||||
m_Author = "Sergiusz Bazanski";
|
||||
m_Class = EDC_DEVICE;
|
||||
m_LoadMethod = EDLM_ALWAYS;
|
||||
m_Unloadable = false;
|
||||
|
||||
m_DeviceOperations = (IDeviceOperations)(IDO_GET_SIZE | IDO_READ);
|
||||
|
||||
m_Kernel = Kernel;
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,8 +35,3 @@ void CDriverRamdisk::Write(u32 Offset, u32 Length, const u8 *Data)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IDeviceOperations CDriverRamdisk::GetSupportedOperations(void)
|
||||
{
|
||||
return (IDeviceOperations)(IDO_GET_SIZE | IDO_READ);
|
||||
}
|
||||
|
|
|
@ -1,41 +1,16 @@
|
|||
#include "Tier1/Drivers/Misc/CDriverDummy.h"
|
||||
using namespace cb;
|
||||
|
||||
const s8 *CDriverDummy::GetDescription(void)
|
||||
{
|
||||
return "Dummy Driver";
|
||||
}
|
||||
|
||||
const s8 *CDriverDummy::GetName(void)
|
||||
{
|
||||
return "org.q3k.drivers.dummy";
|
||||
}
|
||||
|
||||
const s8 *CDriverDummy::GetAuthor(void)
|
||||
{
|
||||
return "Sergiusz Bazanski";
|
||||
}
|
||||
|
||||
EDriverClass CDriverDummy::GetClass(void)
|
||||
{
|
||||
return EDC_NONE;
|
||||
}
|
||||
|
||||
EDriverLoadMethod CDriverDummy::GetLoadMethod(void)
|
||||
{
|
||||
return EDLM_ALWAYS;
|
||||
}
|
||||
|
||||
bool CDriverDummy::CanUnload(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
u8 CDriverDummy::Load(CKernel *Kernel)
|
||||
{
|
||||
m_Name = "org.q3k.drivers.dummy";
|
||||
m_Description = "Dummy Driver";
|
||||
m_Author = "Sergiusz Bazanski";
|
||||
m_Class = EDC_NONE;
|
||||
m_LoadMethod = EDLM_ALWAYS;
|
||||
m_Unloadable = true;
|
||||
|
||||
m_Kernel = Kernel;
|
||||
//Kernel->Logger() << "Dummy driver loaded!";
|
||||
//Kernel->Logger().Flush();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue