mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Fixed broken driver unloading on shutdown/crash
This commit is contained in:
parent
d33a812703
commit
ed49b3ab7c
@ -670,23 +670,7 @@ namespace CrashHandler
|
||||
ExceptionOccurred = true;
|
||||
|
||||
if (DriverManager)
|
||||
{
|
||||
KernelCallback callback;
|
||||
foreach (Driver::DriverFile *drv in DriverManager->GetDrivers())
|
||||
{
|
||||
memset(&callback, 0, sizeof(KernelCallback));
|
||||
callback.Reason = StopReason;
|
||||
debug("Stopping driver %ld...", drv->DriverUID);
|
||||
DriverManager->IOCB(drv->DriverUID, (void *)&callback);
|
||||
|
||||
for (size_t i = 0; i < sizeof(drv->InterruptHook) / sizeof(drv->InterruptHook[0]); i++)
|
||||
{
|
||||
if (!drv->InterruptHook[i])
|
||||
continue;
|
||||
delete drv->InterruptHook[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
DriverManager->UnloadAllDrivers();
|
||||
|
||||
debug("Reading control registers...");
|
||||
crashdata.Frame = Frame;
|
||||
|
@ -28,6 +28,26 @@ namespace Driver
|
||||
"Input",
|
||||
"Audio"};
|
||||
|
||||
void Driver::UnloadAllDrivers()
|
||||
{
|
||||
KernelCallback callback;
|
||||
debug("%ld drivers loaded, [DUIDs: %ld]", DriverManager->GetDrivers().size(), DriverUIDs);
|
||||
foreach (DriverFile *drv in DriverManager->GetDrivers())
|
||||
{
|
||||
memset(&callback, 0, sizeof(KernelCallback));
|
||||
callback.Reason = StopReason;
|
||||
debug("Stopping & unloading driver %ld [%#lx]", drv->DriverUID, drv->Address);
|
||||
DriverManager->IOCB(drv->DriverUID, (void *)&callback);
|
||||
|
||||
for (size_t i = 0; i < sizeof(drv->InterruptHook) / sizeof(drv->InterruptHook[0]); i++)
|
||||
{
|
||||
if (!drv->InterruptHook[i])
|
||||
continue;
|
||||
delete drv->InterruptHook[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Driver::IOCB(unsigned long DUID, void *KCB)
|
||||
{
|
||||
foreach (auto var in Drivers)
|
||||
|
@ -64,7 +64,7 @@ namespace Driver
|
||||
KernelAllocator.FreePages(KCallback, TO_PAGES(sizeof(KernelCallback)));
|
||||
|
||||
DriverFile *DrvFile = new DriverFile;
|
||||
DrvFile->DriverUID = KAPI.Info.DriverUID;
|
||||
DrvFile->DriverUID = this->DriverUIDs - 1;
|
||||
DrvFile->Address = (void *)fex;
|
||||
DrvFile->InterruptHook[0] = nullptr;
|
||||
Drivers.push_back(DrvFile);
|
||||
|
@ -42,7 +42,7 @@ namespace Driver
|
||||
{
|
||||
fixme("Generic driver: %s", fexExtended->Driver.Name);
|
||||
DriverFile *DrvFile = new DriverFile;
|
||||
DrvFile->DriverUID = KAPI.Info.DriverUID;
|
||||
DrvFile->DriverUID = this->DriverUIDs - 1;
|
||||
DrvFile->Address = (void *)fex;
|
||||
Drivers.push_back(DrvFile);
|
||||
break;
|
||||
@ -142,7 +142,7 @@ namespace Driver
|
||||
KCallback->Reason = CallbackReason::InterruptReason;
|
||||
|
||||
DriverFile *DrvFile = new DriverFile;
|
||||
DrvFile->DriverUID = KAPI.Info.DriverUID;
|
||||
DrvFile->DriverUID = this->DriverUIDs - 1;
|
||||
DrvFile->Address = (void *)fex;
|
||||
DrvFile->InterruptHook[0] = InterruptHook;
|
||||
Drivers.push_back(DrvFile);
|
||||
|
@ -121,7 +121,7 @@ namespace Driver
|
||||
KCallback->Reason = CallbackReason::InterruptReason;
|
||||
|
||||
DriverFile *DrvFile = new DriverFile;
|
||||
DrvFile->DriverUID = KAPI.Info.DriverUID;
|
||||
DrvFile->DriverUID = this->DriverUIDs - 1;
|
||||
DrvFile->Address = (void *)fex;
|
||||
DrvFile->InterruptHook[0] = InterruptHook;
|
||||
Drivers.push_back(DrvFile);
|
||||
@ -150,7 +150,7 @@ namespace Driver
|
||||
}
|
||||
|
||||
DriverFile *DrvFile = new DriverFile;
|
||||
DrvFile->DriverUID = KAPI.Info.DriverUID;
|
||||
DrvFile->DriverUID = this->DriverUIDs - 1;
|
||||
DrvFile->Address = (void *)fex;
|
||||
DrvFile->InterruptHook[0] = nullptr;
|
||||
Drivers.push_back(DrvFile);
|
||||
|
17
KThread.cpp
17
KThread.cpp
@ -83,23 +83,8 @@ Exit:
|
||||
void KernelShutdownThread(bool Reboot)
|
||||
{
|
||||
if (DriverManager)
|
||||
{
|
||||
KernelCallback callback;
|
||||
foreach (Driver::DriverFile *drv in DriverManager->GetDrivers())
|
||||
{
|
||||
memset(&callback, 0, sizeof(KernelCallback));
|
||||
callback.Reason = StopReason;
|
||||
debug("Stopping driver %ld...", drv->DriverUID);
|
||||
DriverManager->IOCB(drv->DriverUID, (void *)&callback);
|
||||
DriverManager->UnloadAllDrivers();
|
||||
|
||||
for (size_t i = 0; i < sizeof(drv->InterruptHook) / sizeof(drv->InterruptHook[0]); i++)
|
||||
{
|
||||
if (!drv->InterruptHook[i])
|
||||
continue;
|
||||
delete drv->InterruptHook[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
trace("Shutting Down/Rebooting...");
|
||||
if (Reboot)
|
||||
PowerManager->Reboot();
|
||||
|
@ -63,6 +63,7 @@ namespace Driver
|
||||
|
||||
public:
|
||||
Vector<DriverFile *> GetDrivers() { return Drivers; }
|
||||
void UnloadAllDrivers();
|
||||
int IOCB(unsigned long DUID, /* KernelCallback */ void *KCB);
|
||||
DriverCode LoadDriver(uint64_t DriverAddress, uint64_t Size);
|
||||
DriverCode StartDrivers();
|
||||
|
Loading…
x
Reference in New Issue
Block a user