AppleRAIDGlobals.cpp [plain text]
#include "AppleRAID.h"
#include "AppleRAIDGlobals.h"
AppleRAIDGlobals gAppleRAIDGlobals;
AppleRAIDGlobals::AppleRAIDGlobals()
{
_raidSets = OSDictionary::withCapacity(1);
_raidSetsLock = IOLockAlloc();
}
AppleRAIDGlobals::~AppleRAIDGlobals()
{
if (_raidSets) {
_raidSets->release();
_raidSets = 0;
}
if (_raidSetsLock) {
IOLockFree(_raidSetsLock);
_raidSetsLock = 0;
}
}
bool AppleRAIDGlobals::isValid(void)
{
return _raidSets && _raidSetsLock;
}
void AppleRAIDGlobals::lock(void)
{
IOLockLock(_raidSetsLock);
}
void AppleRAIDGlobals::unlock(void)
{
IOLockUnlock(_raidSetsLock);
}
AppleRAID *AppleRAIDGlobals::getAppleRAIDSet(const OSSymbol *raidSetName)
{
return OSDynamicCast(AppleRAID, _raidSets->getObject(raidSetName));
}
void AppleRAIDGlobals::setAppleRAIDSet(const OSSymbol *raidSetName, AppleRAID *appleRAID)
{
_raidSets->setObject(raidSetName, appleRAID);
}
void AppleRAIDGlobals::removeAppleRAIDSet(const OSSymbol *raidSetName)
{
_raidSets->removeObject(raidSetName);
}
AppleRAIDController *AppleRAIDGlobals::getAppleRAIDController(void)
{
if (_raidController == 0) {
_raidController = AppleRAIDController::createAppleRAIDController();
if (_raidController != 0) _raidController->retain();
}
return _raidController;
}
void AppleRAIDGlobals::removeAppleRAIDController(void)
{
_raidController->release();
_raidController = 0;
}