BOOL BlockStorageList::UnInitializeDevices() { BOOL success = TRUE; BlockStorageDevice* block = s_deviceList.FirstNode(); BlockStorageDevice* curBlock; if(s_primaryDevice != NULL) { while(block->Next()) { success = block->UninitializeDevice() && success; // even if success == FALSE, UninitalizeDevice() will still get called curBlock = block; block = block->Next(); // unlink the devices and it will addback curBlock ->Unlink(); } s_primaryDevice = NULL; } return success; }
// walk through list of devices and calls Init() function BOOL BlockStorageList::InitializeDevices() { UINT32 regionIndex, rangeIndex; ByteAddress Address; BlockStorageDevice* block = s_deviceList.FirstNode(); if(block == NULL) { #if defined(PLATFORM_ARM) debug_printf( "There are no block storage devices to initialize" ); #endif return FALSE; } UINT32 BlockUsage = BlockUsage::CONFIG; BOOL success = TRUE; if(s_primaryDevice == NULL) { // initialize all the "Static" block storage // that is all the non-removeable block storage. while(block->Next()) { success = block->InitializeDevice() && success; // even if success == FALSE, InitalizeDevice() will still get called if (block->FindForBlockUsage( BlockUsage, Address, regionIndex, rangeIndex )) { if (s_primaryDevice == NULL) { s_primaryDevice = block; } else { // there must be one and only one primary device return FALSE; } } block = block->Next(); } if (s_primaryDevice == NULL) return FALSE; } else { return FALSE; } return success; }
BlockStorageDevice* BlockStorageList::GetNextDevice( BlockStorageDevice& device ) { if(!s_Initialized) return NULL; BlockStorageDevice* nextDevice = device.Next(); if(nextDevice && nextDevice->Next()) { return nextDevice; } return NULL; }
BOOL BlockStorageList::FindDeviceForPhysicalAddress( BlockStorageDevice** pBSD, UINT32 PhysicalAddress, ByteAddress &BlockAddress) { *pBSD = NULL; if(!s_Initialized) return FALSE; BlockStorageDevice* block = s_deviceList.FirstNode(); // this has to add to make metadataprocessor happy if(!block) return FALSE; while(block->Next()) { const BlockDeviceInfo* pDeviceInfo = block->GetDeviceInfo(); for(UINT32 i=0; i < pDeviceInfo->NumRegions; i++) { const BlockRegionInfo* pRegion = &pDeviceInfo->Regions[i]; if(pRegion->Start <= PhysicalAddress && PhysicalAddress < (pRegion->Start + pRegion->NumBlocks * pRegion->BytesPerBlock)) { *pBSD = block; // get block start address BlockAddress = (ByteAddress)((PhysicalAddress - pRegion->Start) / pRegion->BytesPerBlock); BlockAddress *= pRegion->BytesPerBlock; BlockAddress += pRegion->Start; return TRUE; } } block = block->Next(); } return FALSE; }