[FREELDR]

Split HwDetect() into 2 functions. InitializeBootDevices() and HwDetect(). This way we don't do the stuff twice.

svn path=/trunk/; revision=58334
This commit is contained in:
Timo Kreuzer 2013-02-17 14:46:42 +00:00
parent a7931f3d82
commit 8701c51946
10 changed files with 51 additions and 27 deletions

View file

@ -28,7 +28,7 @@ ULONG SecondLevelDcacheSize;
ULONG SecondLevelDcacheFillSize;
ULONG SecondLevelIcacheSize;
ULONG SecondLevelIcacheFillSize;
ARC_DISK_SIGNATURE reactos_arc_disk_info;
ULONG reactos_disk_count;
CHAR reactos_arc_hardware_data[256];
@ -66,11 +66,11 @@ ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
{
/* Remember the pointer */
ArmBoardBlock = BootContext;
/* Let's make sure we understand the LLB */
ASSERT(ArmBoardBlock->MajorVersion == ARM_BOARD_CONFIGURATION_MAJOR_VERSION);
ASSERT(ArmBoardBlock->MinorVersion == ARM_BOARD_CONFIGURATION_MINOR_VERSION);
/* This should probably go away once we support more boards */
ASSERT((ArmBoardBlock->BoardType == MACH_TYPE_FEROCEON) ||
(ArmBoardBlock->BoardType == MACH_TYPE_VERSATILE_PB) ||
@ -92,33 +92,40 @@ ArmDiskGetBootPath(OUT PCHAR BootPath,
IN unsigned Size)
{
PCCH Path = "ramdisk(0)";
/* Make sure enough space exists */
if (Size < sizeof(Path)) return FALSE;
/* On ARM platforms, the loader is always in RAM */
strcpy(BootPath, Path);
return TRUE;
}
BOOLEAN
ArmInitializeBootDevices(VOID)
{
/* Emulate old behavior */
return ArmHwDetect != NULL;
}
PCONFIGURATION_COMPONENT_DATA
ArmHwDetect(VOID)
{
ARM_CACHE_REGISTER CacheReg;
/* Create the root node */
if (ArmHwDetectRan++) return RootNode;
FldrCreateSystemKey(&RootNode);
/*
* TODO:
* There's no such thing as "PnP" on embedded hardware.
* The boot loader will send us a device tree, similar to ACPI
* or OpenFirmware device trees, and we will convert it to ARC.
*/
/* Get cache information */
CacheReg = KeArmCacheRegisterGet();
CacheReg = KeArmCacheRegisterGet();
FirstLevelDcacheSize = SizeBits[CacheReg.DSize];
FirstLevelDcacheFillSize = LenBits[CacheReg.DLength];
FirstLevelDcacheFillSize <<= 2;
@ -129,16 +136,16 @@ ArmHwDetect(VOID)
SecondLevelDcacheFillSize =
SecondLevelIcacheSize =
SecondLevelIcacheFillSize = 0;
/* Register RAMDISK Device */
RamDiskInitialize();
/* Fill out the ARC disk block */
reactos_arc_disk_info.Signature = 0xBADAB00F;
reactos_arc_disk_info.CheckSum = 0xDEADBABE;
reactos_arc_disk_info.ArcName = "ramdisk(0)";
reactos_disk_count = 1;
/* Return the root node */
return RootNode;
}
@ -182,7 +189,7 @@ MachInit(IN PCCH CommandLine)
MachVtbl.VideoGetDisplaySize = ArmBoardBlock->VideoGetDisplaySize;
MachVtbl.VideoPutChar = ArmBoardBlock->VideoPutChar;
MachVtbl.GetTime = ArmBoardBlock->GetTime;
/* Setup board-specific ARM routines */
switch (ArmBoardBlock->BoardType)
{
@ -194,33 +201,34 @@ MachInit(IN PCCH CommandLine)
/* Check for TI OMAP3 ZOOM-II MDK */
case MACH_TYPE_OMAP_ZOOM2:
/* Setup the disk and file system buffers */
gDiskReadBuffer = 0x81094000;
gFileSysBuffer = 0x81094000;
break;
/* Check for ARM Versatile PB boards */
case MACH_TYPE_VERSATILE_PB:
/* Setup the disk and file system buffers */
gDiskReadBuffer = 0x00090000;
gFileSysBuffer = 0x00090000;
break;
/* Check for TI OMAP3 Beagleboard */
case MACH_TYPE_OMAP3_BEAGLE:
TuiPrintf("Not implemented\n");
while (TRUE);
break;
default:
ASSERT(FALSE);
}
/* Setup generic ARM routines for all boards */
MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
MachVtbl.InitializeBootDevices = ArmInitializeBootDevices;
MachVtbl.HwDetect = ArmHwDetect;
MachVtbl.DiskGetBootPath = ArmDiskGetBootPath;
MachVtbl.HwIdle = ArmHwIdle;

View file

@ -95,7 +95,7 @@ PCHAR
GetHarddiskIdentifier(
UCHAR DriveNumber);
VOID
BOOLEAN
HwInitializeBiosDisks(VOID);
/* FUNCTIONS ****************************************************************/
@ -1721,6 +1721,11 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
/* FIXME: Detect more ISA devices */
}
BOOLEAN
PcInitializeBootDevices(VOID)
{
return HwInitializeBiosDisks();
}
PCONFIGURATION_COMPONENT_DATA
PcHwDetect(VOID)
@ -1730,8 +1735,6 @@ PcHwDetect(VOID)
TRACE("DetectHardware()\n");
HwInitializeBiosDisks();
/* Create the 'System' key */
SystemKey = DetectSystem();

View file

@ -269,7 +269,7 @@ GetHarddiskInformation(
}
VOID
BOOLEAN
HwInitializeBiosDisks(VOID)
{
UCHAR DiskCount, DriveNumber;
@ -331,7 +331,7 @@ HwInitializeBiosDisks(VOID)
if (!MachDiskReadLogicalSectors(FrldrBootDrive, 16ULL, 1, (PVOID)DISKREADBUFFER))
{
ERR("Reading MBR failed\n");
return;
return FALSE;
}
Buffer = (ULONG*)DISKREADBUFFER;
@ -352,4 +352,5 @@ HwInitializeBiosDisks(VOID)
}
PcBiosDiskCount = DiskCount;
return DiskCount != 0;
}

View file

@ -45,6 +45,7 @@ PcMachInit(const char *CmdLine)
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
MachVtbl.GetTime = PcGetTime;
MachVtbl.InitializeBootDevices = PcInitializeBootDevices;
MachVtbl.HwDetect = PcHwDetect;
MachVtbl.HwIdle = PcHwIdle;
}

View file

@ -51,6 +51,7 @@ XboxMachInit(const char *CmdLine)
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;
MachVtbl.GetTime = XboxGetTime;
MachVtbl.InitializeBootDevices = XboxInitializeBootDevices;
MachVtbl.HwDetect = XboxHwDetect;
MachVtbl.HwIdle = XboxHwIdle;

View file

@ -509,6 +509,13 @@ XboxHwDetect(VOID)
return SystemKey;
}
BOOLEAN
XboxInitializeBootDevices(VOID)
{
// Emulate old behavior
return XboxHwDetect() != NULL;
}
VOID XboxHwIdle(VOID)
{
/* UNIMPLEMENTED */

View file

@ -197,8 +197,7 @@ VOID RunLoader(VOID)
ULONG SelectedOperatingSystem;
ULONG i;
// FIXME: if possible, only detect and register ARC devices...
if (!MachHwDetect())
if (!MachInitializeBootDevices())
{
UiMessageBoxCritical("Error when detecting hardware");
return;

View file

@ -57,6 +57,7 @@ ULONG XboxDiskGetCacheableBlockCount(UCHAR DriveNumber);
TIMEINFO* XboxGetTime(VOID);
BOOLEAN XboxInitializeBootDevices(VOID);
PCONFIGURATION_COMPONENT_DATA XboxHwDetect(VOID);
VOID XboxHwIdle(VOID);

View file

@ -57,6 +57,7 @@ ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber);
TIMEINFO* PcGetTime(VOID);
BOOLEAN PcInitializeBootDevices(VOID);
PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID);
VOID PcHwIdle(VOID);

View file

@ -1,4 +1,4 @@
/*
/*
* FreeLoader
*
* This program is free software; you can redistribute it and/or modify
@ -68,6 +68,7 @@ typedef struct tagMACHVTBL
TIMEINFO* (*GetTime)(VOID);
ULONG (*GetRelativeTime)(VOID);
BOOLEAN (*InitializeBootDevices)(VOID);
PCONFIGURATION_COMPONENT_DATA (*HwDetect)(VOID);
VOID (*HwIdle)(VOID);
} MACHVTBL, *PMACHVTBL;
@ -122,6 +123,7 @@ VOID MachHwIdle(VOID);
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf))
#define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
#define MachDiskGetCacheableBlockCount(Drive) MachVtbl.DiskGetCacheableBlockCount(Drive)
#define MachInitializeBootDevices() MachVtbl.InitializeBootDevices()
#define MachHwDetect() MachVtbl.HwDetect()
#define MachHwIdle() MachVtbl.HwIdle()