From 081ba368922ddd36f093486d40e1d9305a785ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 27 Jan 2017 14:43:41 +0000 Subject: [PATCH] [FREELDR] - Use 'DiskReadBufferSize' instead of hardcoded values in hwdisk.c - Transform reactos_arc_disk_info into a ARC_DISK_SIGNATURE_EX structure, so that its conversion into a ARC list in winldr.c becomes a bit simpler. - In winldr.c: * In case we fail to either open the SYSTEM hive or scan it, bail out with an error message, instead of trying to continue loading ROS. * Fix an old comment related to ACPI; - In memory.c/h: Do some cleanup (in particular, just use the MachXXX macros instead of also defining functions with the same names as the macros, and which just redirect into the virtual table). svn path=/trunk/; revision=73606 --- reactos/boot/freeldr/freeldr/arch/archwsup.c | 8 +- .../boot/freeldr/freeldr/arch/arm/macharm.c | 13 +- .../boot/freeldr/freeldr/arch/i386/hwdisk.c | 68 ++++---- .../boot/freeldr/freeldr/arch/i386/xboxhw.c | 21 ++- .../boot/freeldr/freeldr/include/machine.h | 163 +++++++++--------- reactos/boot/freeldr/freeldr/machine.c | 148 ---------------- reactos/boot/freeldr/freeldr/ntldr/winldr.c | 26 +-- .../boot/freeldr/freeldr/ntldr/wlregistry.c | 1 - 8 files changed, 154 insertions(+), 294 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/archwsup.c b/reactos/boot/freeldr/freeldr/arch/archwsup.c index 71fad44f459..c1ea8986f5e 100644 --- a/reactos/boot/freeldr/freeldr/arch/archwsup.c +++ b/reactos/boot/freeldr/freeldr/arch/archwsup.c @@ -17,9 +17,8 @@ PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot; // ARC Disk Information -ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; ULONG reactos_disk_count = 0; -CHAR reactos_arc_strings[32][256]; +ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[32]; /* FUNCTIONS ******************************************************************/ @@ -30,11 +29,8 @@ PVOID NTAPI FldrpHwHeapAlloc(IN SIZE_T Size) { - PVOID Buffer; - /* Allocate memory from generic bootloader heap */ - Buffer = FrLdrHeapAlloc(Size, 'pHwH'); - return Buffer; + return FrLdrHeapAlloc(Size, 'pHwH'); } static VOID diff --git a/reactos/boot/freeldr/freeldr/arch/arm/macharm.c b/reactos/boot/freeldr/freeldr/arch/arm/macharm.c index 6be0800793f..ff5f6e48814 100644 --- a/reactos/boot/freeldr/freeldr/arch/arm/macharm.c +++ b/reactos/boot/freeldr/freeldr/arch/arm/macharm.c @@ -30,8 +30,7 @@ ULONG SecondLevelIcacheSize; ULONG SecondLevelIcacheFillSize; extern ULONG reactos_disk_count; -extern ARC_DISK_SIGNATURE reactos_arc_disk_info[]; -extern CHAR reactos_arc_strings[32][256]; +extern ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]; ULONG SizeBits[] = { @@ -144,11 +143,11 @@ ArmHwDetect(VOID) RamDiskInitialize(); /* Fill out the ARC disk block */ - reactos_arc_disk_info[reactos_disk_count].Signature = 0xBADAB00F; - reactos_arc_disk_info[reactos_disk_count].CheckSum = 0xDEADBABE; - strcpy(reactos_arc_strings[reactos_disk_count], "ramdisk(0)"); - reactos_arc_disk_info[reactos_disk_count].ArcName = - reactos_arc_strings[reactos_disk_count]; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = 0xBADAB00F; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = 0xDEADBABE; + strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, "ramdisk(0)"); + reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName = + reactos_arc_disk_info[reactos_disk_count].ArcName; reactos_disk_count++; ASSERT(reactos_disk_count == 1); diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c b/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c index 0bf7d1a86fd..a5889e3f9bf 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c @@ -36,8 +36,7 @@ typedef struct tagDISKCONTEXT } DISKCONTEXT; extern ULONG reactos_disk_count; -extern ARC_DISK_SIGNATURE reactos_arc_disk_info[]; -extern CHAR reactos_arc_strings[32][256]; +extern ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]; static CHAR Hex[] = "0123456789abcdef"; UCHAR PcBiosDiskCount = 0; @@ -190,11 +189,11 @@ GetHarddiskInformation( UCHAR DriveNumber) { PMASTER_BOOT_RECORD Mbr; - ULONG *Buffer; + PULONG Buffer; ULONG i; ULONG Checksum; ULONG Signature; - CHAR ArcName[256]; + CHAR ArcName[MAX_PATH]; PARTITION_TABLE_ENTRY PartitionTableEntry; PCHAR Identifier = PcDiskIdentifier[DriveNumber - 0x80]; @@ -208,12 +207,12 @@ GetHarddiskInformation( Buffer = (ULONG*)DiskReadBuffer; Mbr = (PMASTER_BOOT_RECORD)DiskReadBuffer; - Signature = Mbr->Signature; + Signature = Mbr->Signature; TRACE("Signature: %x\n", Signature); /* Calculate the MBR checksum */ Checksum = 0; - for (i = 0; i < 128; i++) + for (i = 0; i < 512 / sizeof(ULONG); i++) { Checksum += Buffer[i]; } @@ -221,12 +220,12 @@ GetHarddiskInformation( TRACE("Checksum: %x\n", Checksum); /* Fill out the ARC disk block */ - reactos_arc_disk_info[reactos_disk_count].Signature = Signature; - reactos_arc_disk_info[reactos_disk_count].CheckSum = Checksum; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = Signature; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = Checksum; sprintf(ArcName, "multi(0)disk(0)rdisk(%lu)", reactos_disk_count); - strcpy(reactos_arc_strings[reactos_disk_count], ArcName); - reactos_arc_disk_info[reactos_disk_count].ArcName = - reactos_arc_strings[reactos_disk_count]; + strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, ArcName); + reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName = + reactos_arc_disk_info[reactos_disk_count].ArcName; reactos_disk_count++; sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - 0x80); @@ -277,36 +276,39 @@ HwInitializeBiosDisks(VOID) UCHAR DiskCount, DriveNumber; ULONG i; BOOLEAN Changed; - CHAR BootPath[512]; BOOLEAN BootDriveReported = FALSE; + CHAR BootPath[MAX_PATH]; /* Count the number of visible drives */ DiskReportError(FALSE); DiskCount = 0; DriveNumber = 0x80; - /* There are some really broken BIOSes out there. There are even BIOSes - * that happily report success when you ask them to read from non-existent - * harddisks. So, we set the buffer to known contents first, then try to - * read. If the BIOS reports success but the buffer contents haven't - * changed then we fail anyway */ - memset(DiskReadBuffer, 0xcd, 512); + /* + * There are some really broken BIOSes out there. There are even BIOSes + * that happily report success when you ask them to read from non-existent + * harddisks. So, we set the buffer to known contents first, then try to + * read. If the BIOS reports success but the buffer contents haven't + * changed then we fail anyway. + */ + memset(DiskReadBuffer, 0xcd, DiskReadBufferSize); while (MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, DiskReadBuffer)) { Changed = FALSE; - for (i = 0; ! Changed && i < 512; i++) + for (i = 0; !Changed && i < DiskReadBufferSize; i++) { Changed = ((PUCHAR)DiskReadBuffer)[i] != 0xcd; } - if (! Changed) + if (!Changed) { TRACE("BIOS reports success for disk %d but data didn't change\n", - (int)DiskCount); + (int)DiskCount); break; } GetHarddiskInformation(DriveNumber); + /* Check if we have seen the boot drive */ if (FrldrBootDrive == DriveNumber) BootDriveReported = TRUE; @@ -323,18 +325,25 @@ HwInitializeBiosDisks(VOID) if ((FrldrBootDrive >= 0x80 && !BootDriveReported) || DiskIsDriveRemovable(FrldrBootDrive)) { - /* TODO: Check if it's really a cdrom drive */ - ULONG* Buffer; + /* TODO: Check if it's really a CDROM drive */ + + PMASTER_BOOT_RECORD Mbr; + PULONG Buffer; ULONG Checksum = 0; + ULONG Signature; /* Read the MBR */ if (!MachDiskReadLogicalSectors(FrldrBootDrive, 16ULL, 1, DiskReadBuffer)) { - ERR("Reading MBR failed\n"); - return FALSE; + ERR("Reading MBR failed\n"); + return FALSE; } Buffer = (ULONG*)DiskReadBuffer; + Mbr = (PMASTER_BOOT_RECORD)DiskReadBuffer; + + Signature = Mbr->Signature; + TRACE("Signature: %x\n", Signature); /* Calculate the MBR checksum */ for (i = 0; i < 2048 / sizeof(ULONG); i++) Checksum += Buffer[i]; @@ -342,10 +351,11 @@ HwInitializeBiosDisks(VOID) TRACE("Checksum: %x\n", Checksum); /* Fill out the ARC disk block */ - reactos_arc_disk_info[reactos_disk_count].CheckSum = Checksum; - strcpy(reactos_arc_strings[reactos_disk_count], BootPath); - reactos_arc_disk_info[reactos_disk_count].ArcName = - reactos_arc_strings[reactos_disk_count]; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = Signature; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = Checksum; + strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, BootPath); + reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName = + reactos_arc_disk_info[reactos_disk_count].ArcName; reactos_disk_count++; FsRegisterDevice(BootPath, &DiskVtbl); diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c index 5b615e225f7..d5a68811e9c 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c @@ -27,8 +27,7 @@ static CHAR Hex[] = "0123456789ABCDEF"; //static unsigned int delay_count = 1; extern ULONG reactos_disk_count; -extern ARC_DISK_SIGNATURE reactos_arc_disk_info[]; -extern CHAR reactos_arc_strings[32][256]; +extern ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]; static PCM_PARTIAL_RESOURCE_LIST @@ -249,11 +248,11 @@ GetHarddiskIdentifier(PCHAR Identifier, UCHAR DriveNumber) { PMASTER_BOOT_RECORD Mbr; - ULONG *Buffer; + PULONG Buffer; ULONG i; ULONG Checksum; ULONG Signature; - CHAR ArcName[256]; + CHAR ArcName[MAX_PATH]; PARTITION_TABLE_ENTRY PartitionTableEntry; /* Read the MBR */ @@ -266,12 +265,12 @@ GetHarddiskIdentifier(PCHAR Identifier, Buffer = (ULONG*)DiskReadBuffer; Mbr = (PMASTER_BOOT_RECORD)DiskReadBuffer; - Signature = Mbr->Signature; + Signature = Mbr->Signature; TRACE("Signature: %x\n", Signature); /* Calculate the MBR checksum */ Checksum = 0; - for (i = 0; i < 128; i++) + for (i = 0; i < 512 / sizeof(ULONG); i++) { Checksum += Buffer[i]; } @@ -279,12 +278,12 @@ GetHarddiskIdentifier(PCHAR Identifier, TRACE("Checksum: %x\n", Checksum); /* Fill out the ARC disk block */ - reactos_arc_disk_info[reactos_disk_count].Signature = Signature; - reactos_arc_disk_info[reactos_disk_count].CheckSum = Checksum; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = Signature; + reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = Checksum; sprintf(ArcName, "multi(0)disk(0)rdisk(%lu)", reactos_disk_count); - strcpy(reactos_arc_strings[reactos_disk_count], ArcName); - reactos_arc_disk_info[reactos_disk_count].ArcName = - reactos_arc_strings[reactos_disk_count]; + strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, ArcName); + reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName = + reactos_arc_disk_info[reactos_disk_count].ArcName; reactos_disk_count++; sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - 0x80); diff --git a/reactos/boot/freeldr/freeldr/include/machine.h b/reactos/boot/freeldr/freeldr/include/machine.h index f56d9fe2f35..9a8a52a20d8 100644 --- a/reactos/boot/freeldr/freeldr/include/machine.h +++ b/reactos/boot/freeldr/freeldr/include/machine.h @@ -32,100 +32,103 @@ typedef enum tagVIDEODISPLAYMODE { - VideoTextMode, - VideoGraphicsMode + VideoTextMode, + VideoGraphicsMode } VIDEODISPLAYMODE, *PVIDEODISPLAYMODE; typedef struct tagMACHVTBL { - VOID (*ConsPutChar)(int Ch); - BOOLEAN (*ConsKbHit)(VOID); - int (*ConsGetCh)(VOID); + VOID (*ConsPutChar)(int Ch); + BOOLEAN (*ConsKbHit)(VOID); + int (*ConsGetCh)(VOID); - VOID (*VideoClearScreen)(UCHAR Attr); - VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init); - VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth); - ULONG (*VideoGetBufferSize)(VOID); - VOID (*VideoSetTextCursorPosition)(UCHAR X, UCHAR Y); - VOID (*VideoHideShowTextCursor)(BOOLEAN Show); - VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y); - VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer); - BOOLEAN (*VideoIsPaletteFixed)(VOID); - VOID (*VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue); - VOID (*VideoGetPaletteColor)(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue); - VOID (*VideoSync)(VOID); - VOID (*Beep)(VOID); - VOID (*PrepareForReactOS)(IN BOOLEAN Setup); + VOID (*VideoClearScreen)(UCHAR Attr); + VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init); + VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth); + ULONG (*VideoGetBufferSize)(VOID); + VOID (*VideoSetTextCursorPosition)(UCHAR X, UCHAR Y); + VOID (*VideoHideShowTextCursor)(BOOLEAN Show); + VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y); + VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer); + BOOLEAN (*VideoIsPaletteFixed)(VOID); + VOID (*VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue); + VOID (*VideoGetPaletteColor)(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue); + VOID (*VideoSync)(VOID); + VOID (*Beep)(VOID); + VOID (*PrepareForReactOS)(IN BOOLEAN Setup); - FREELDR_MEMORY_DESCRIPTOR* (*GetMemoryDescriptor)(FREELDR_MEMORY_DESCRIPTOR* Current); - PFREELDR_MEMORY_DESCRIPTOR (*GetMemoryMap)(PULONG MaxMemoryMapSize); + // NOTE: Not in the machine.c ... + FREELDR_MEMORY_DESCRIPTOR* (*GetMemoryDescriptor)(FREELDR_MEMORY_DESCRIPTOR* Current); + PFREELDR_MEMORY_DESCRIPTOR (*GetMemoryMap)(PULONG MaxMemoryMapSize); - BOOLEAN (*DiskGetBootPath)(char *BootPath, unsigned Size); - BOOLEAN (*DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); - BOOLEAN (*DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry); - ULONG (*DiskGetCacheableBlockCount)(UCHAR DriveNumber); + BOOLEAN (*DiskGetBootPath)(char *BootPath, unsigned Size); + BOOLEAN (*DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); + BOOLEAN (*DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry); + ULONG (*DiskGetCacheableBlockCount)(UCHAR DriveNumber); - TIMEINFO* (*GetTime)(VOID); - ULONG (*GetRelativeTime)(VOID); + // NOTE: In the machine.c under the name of "ArcGetXXXTime" + TIMEINFO* (*GetTime)(VOID); + ULONG (*GetRelativeTime)(VOID); - BOOLEAN (*InitializeBootDevices)(VOID); - PCONFIGURATION_COMPONENT_DATA (*HwDetect)(VOID); - VOID (*HwIdle)(VOID); + // NOTE: Not in the machine.c ... + BOOLEAN (*InitializeBootDevices)(VOID); + PCONFIGURATION_COMPONENT_DATA (*HwDetect)(VOID); + VOID (*HwIdle)(VOID); } MACHVTBL, *PMACHVTBL; -VOID MachInit(const char *CmdLine); - extern MACHVTBL MachVtbl; -VOID MachConsPutChar(int Ch); -BOOLEAN MachConsKbHit(VOID); -int MachConsGetCh(VOID); -VOID MachVideoClearScreen(UCHAR Attr); -VIDEODISPLAYMODE MachVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init); -VOID MachVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth); -ULONG MachVideoGetBufferSize(VOID); -VOID MachVideoSetTextCursorPosition(UCHAR X, UCHAR Y); -VOID MachVideoHideShowTextCursor(BOOLEAN Show); -VOID MachVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y); -VOID MachVideoCopyOffScreenBufferToVRAM(PVOID Buffer); -BOOLEAN MachVideoIsPaletteFixed(VOID); -VOID MachVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue); -VOID MachVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue); -VOID MachVideoSync(VOID); -VOID MachBeep(VOID); -BOOLEAN MachDiskGetBootPath(char *BootPath, unsigned Size); -BOOLEAN MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size); -BOOLEAN MachDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); -BOOLEAN MachDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY DriveGeometry); -ULONG MachDiskGetCacheableBlockCount(UCHAR DriveNumber); -VOID MachPrepareForReactOS(IN BOOLEAN Setup); -VOID MachHwIdle(VOID); +/* NOTE: Implemented by each architecture */ +VOID MachInit(const char *CmdLine); -#define MachConsPutChar(Ch) MachVtbl.ConsPutChar(Ch) -#define MachConsKbHit() MachVtbl.ConsKbHit() -#define MachConsGetCh() MachVtbl.ConsGetCh() -#define MachVideoClearScreen(Attr) MachVtbl.VideoClearScreen(Attr) -#define MachVideoSetDisplayMode(Mode, Init) MachVtbl.VideoSetDisplayMode((Mode), (Init)) -#define MachVideoGetDisplaySize(W, H, D) MachVtbl.VideoGetDisplaySize((W), (H), (D)) -#define MachVideoGetBufferSize() MachVtbl.VideoGetBufferSize() -#define MachVideoSetTextCursorPosition(X, Y) MachVtbl.VideoSetTextCursorPosition((X), (Y)) -#define MachVideoHideShowTextCursor(Show) MachVtbl.VideoHideShowTextCursor(Show) -#define MachVideoPutChar(Ch, Attr, X, Y) MachVtbl.VideoPutChar((Ch), (Attr), (X), (Y)) -#define MachVideoCopyOffScreenBufferToVRAM(Buf) MachVtbl.VideoCopyOffScreenBufferToVRAM(Buf) -#define MachVideoIsPaletteFixed() MachVtbl.VideoIsPaletteFixed() -#define MachVideoSetPaletteColor(Col, R, G, B) MachVtbl.VideoSetPaletteColor((Col), (R), (G), (B)) -#define MachVideoGetPaletteColor(Col, R, G, B) MachVtbl.VideoGetPaletteColor((Col), (R), (G), (B)) -#define MachVideoSync() MachVtbl.VideoSync() -#define MachBeep() MachVtbl.Beep() -#define MachPrepareForReactOS(a) MachVtbl.PrepareForReactOS(a) -#define MachDiskGetBootPath(Path, Size) MachVtbl.DiskGetBootPath((Path), (Size)) -#define MachDiskNormalizeSystemPath(Path, Size) MachVtbl.DiskNormalizeSystemPath((Path), (Size)) -#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() +#define MachConsPutChar(Ch) \ + MachVtbl.ConsPutChar(Ch) +#define MachConsKbHit() \ + MachVtbl.ConsKbHit() +#define MachConsGetCh() \ + MachVtbl.ConsGetCh() +#define MachVideoClearScreen(Attr) \ + MachVtbl.VideoClearScreen(Attr) +#define MachVideoSetDisplayMode(Mode, Init) \ + MachVtbl.VideoSetDisplayMode((Mode), (Init)) +#define MachVideoGetDisplaySize(W, H, D) \ + MachVtbl.VideoGetDisplaySize((W), (H), (D)) +#define MachVideoGetBufferSize() \ + MachVtbl.VideoGetBufferSize() +#define MachVideoSetTextCursorPosition(X, Y) \ + MachVtbl.VideoSetTextCursorPosition((X), (Y)) +#define MachVideoHideShowTextCursor(Show) \ + MachVtbl.VideoHideShowTextCursor(Show) +#define MachVideoPutChar(Ch, Attr, X, Y) \ + MachVtbl.VideoPutChar((Ch), (Attr), (X), (Y)) +#define MachVideoCopyOffScreenBufferToVRAM(Buf) \ + MachVtbl.VideoCopyOffScreenBufferToVRAM(Buf) +#define MachVideoIsPaletteFixed() \ + MachVtbl.VideoIsPaletteFixed() +#define MachVideoSetPaletteColor(Col, R, G, B) \ + MachVtbl.VideoSetPaletteColor((Col), (R), (G), (B)) +#define MachVideoGetPaletteColor(Col, R, G, B) \ + MachVtbl.VideoGetPaletteColor((Col), (R), (G), (B)) +#define MachVideoSync() \ + MachVtbl.VideoSync() +#define MachBeep() \ + MachVtbl.Beep() +#define MachPrepareForReactOS(Setup) \ + MachVtbl.PrepareForReactOS(Setup) +#define MachDiskGetBootPath(Path, Size) \ + MachVtbl.DiskGetBootPath((Path), (Size)) +#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() /* ARC FUNCTIONS **************************************************************/ diff --git a/reactos/boot/freeldr/freeldr/machine.c b/reactos/boot/freeldr/freeldr/machine.c index 25626b9b5a2..a72f492bc5d 100644 --- a/reactos/boot/freeldr/freeldr/machine.c +++ b/reactos/boot/freeldr/freeldr/machine.c @@ -18,156 +18,8 @@ #include -#undef MachConsPutChar -#undef MachConsKbHit -#undef MachConsGetCh -#undef MachVideoClearScreen -#undef MachVideoSetDisplayMode -#undef MachVideoGetDisplaySize -#undef MachVideoGetBufferSize -#undef MachVideoSetTextCursorPosition -#undef MachVideoHideShowTextCursor -#undef MachVideoPutChar -#undef MachVideoCopyOffScreenBufferToVRAM -#undef MachVideoIsPaletteFixed -#undef MachVideoSetPaletteColor -#undef MachVideoGetPaletteColor -#undef MachVideoSync -#undef MachBeep -#undef MachPrepareForReactOS -#undef MachDiskGetBootPath -#undef MachDiskReadLogicalSectors -#undef MachDiskGetDriveGeometry -#undef MachDiskGetCacheableBlockCount - MACHVTBL MachVtbl; -VOID -MachConsPutChar(int Ch) -{ - MachVtbl.ConsPutChar(Ch); -} - -BOOLEAN -MachConsKbHit(VOID) -{ - return MachVtbl.ConsKbHit(); -} - -int -MachConsGetCh(VOID) -{ - return MachVtbl.ConsGetCh(); -} - -VOID -MachVideoClearScreen(UCHAR Attr) -{ - MachVtbl.VideoClearScreen(Attr); -} - -VIDEODISPLAYMODE -MachVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init) -{ - return MachVtbl.VideoSetDisplayMode(DisplayMode, Init); -} - -VOID -MachVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth) -{ - MachVtbl.VideoGetDisplaySize(Width, Height, Depth); -} - -ULONG -MachVideoGetBufferSize(VOID) -{ - return MachVtbl.VideoGetBufferSize(); -} - -VOID -MachVideoSetTextCursorPosition(UCHAR X, UCHAR Y) -{ - MachVtbl.VideoSetTextCursorPosition(X, Y); -} - -VOID -MachVideoHideShowTextCursor(BOOLEAN Show) -{ - MachVtbl.VideoHideShowTextCursor(Show); -} - -VOID -MachVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y) -{ - MachVtbl.VideoPutChar(Ch, Attr, X, Y); -} - -VOID -MachVideoCopyOffScreenBufferToVRAM(PVOID Buffer) -{ - MachVtbl.VideoCopyOffScreenBufferToVRAM(Buffer); -} - -BOOLEAN -MachVideoIsPaletteFixed(VOID) -{ - return MachVtbl.VideoIsPaletteFixed(); -} - -VOID -MachVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue) -{ - MachVtbl.VideoSetPaletteColor(Color, Red, Green, Blue); -} - -VOID -MachVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue) -{ - MachVtbl.VideoGetPaletteColor(Color, Red, Green, Blue); -} - -VOID -MachVideoSync(VOID) -{ - MachVtbl.VideoSync(); -} - -VOID -MachBeep(VOID) -{ - MachVtbl.Beep(); -} - -VOID -MachPrepareForReactOS(IN BOOLEAN Setup) -{ - MachVtbl.PrepareForReactOS(Setup); -} - -BOOLEAN -MachDiskGetBootPath(char *BootPath, unsigned Size) -{ - return MachVtbl.DiskGetBootPath(BootPath, Size); -} - -BOOLEAN -MachDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer) -{ - return MachVtbl.DiskReadLogicalSectors(DriveNumber, SectorNumber, SectorCount, Buffer); -} - -BOOLEAN -MachDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY DriveGeometry) -{ - return MachVtbl.DiskGetDriveGeometry(DriveNumber, DriveGeometry); -} - -ULONG -MachDiskGetCacheableBlockCount(UCHAR DriveNumber) -{ - return MachVtbl.DiskGetCacheableBlockCount(DriveNumber); -} - /* ARC FUNCTIONS **************************************************************/ diff --git a/reactos/boot/freeldr/freeldr/ntldr/winldr.c b/reactos/boot/freeldr/freeldr/ntldr/winldr.c index 74687b5d70c..a49a687eff5 100644 --- a/reactos/boot/freeldr/freeldr/ntldr/winldr.c +++ b/reactos/boot/freeldr/freeldr/ntldr/winldr.c @@ -27,9 +27,9 @@ #include DBG_DEFAULT_CHANNEL(WINDOWS); -//FIXME: Find a better way to retrieve ARC disk information +// FIXME: Find a better way to retrieve ARC disk information extern ULONG reactos_disk_count; -extern ARC_DISK_SIGNATURE reactos_arc_disk_info[]; +extern ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]; extern ULONG LoaderPagesSpanned; extern BOOLEAN AcpiPresent; @@ -148,14 +148,10 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD'); /* Copy the data over */ - ArcDiskSig->DiskSignature.Signature = reactos_arc_disk_info[i].Signature; - ArcDiskSig->DiskSignature.CheckSum = reactos_arc_disk_info[i].CheckSum; + RtlCopyMemory(ArcDiskSig, &reactos_arc_disk_info[i], sizeof(ARC_DISK_SIGNATURE_EX)); - /* Copy the ARC Name */ - strncpy(ArcDiskSig->ArcName, reactos_arc_disk_info[i].ArcName, MAX_PATH); + /* Set the ARC Name pointer and mark the partition table as valid */ ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName); - - /* Mark partition table as valid */ ArcDiskSig->DiskSignature.ValidPartitionTable = TRUE; /* Insert into the list */ @@ -176,8 +172,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, /* Convert all DTE into virtual addresses */ List_PaToVa(&LoaderBlock->LoadOrderListHead); - /* this one will be converted right before switching to - virtual paging mode */ + /* This one will be converted right before switching to virtual paging mode */ //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead); /* Convert list of boot drivers */ @@ -190,11 +185,12 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, Extension->MinorVersion = VersionToBoot & 0xFF; Extension->Profile.Status = 2; - /* Check if ACPI is present */ + /* Check if FreeLdr detected a ACPI table */ if (AcpiPresent) { - /* See KiRosFrldrLpbToNtLpb for details */ + /* Set the pointer to something for compatibility */ Extension->AcpiTable = (PVOID)1; + // FIXME: Extension->AcpiTableSize; } #ifdef _M_IX86 @@ -700,10 +696,16 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem, UiDrawProgressBarCenter(15, 100, "Loading system hive..."); Success = WinLdrInitSystemHive(LoaderBlock, BootPath); TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded")); + /* Bail out if failure */ + if (!Success) + return; /* Load NLS data, OEM font, and prepare boot drivers list */ Success = WinLdrScanSystemHive(LoaderBlock, BootPath); TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned")); + /* Bail out if failure */ + if (!Success) + return; /* Finish loading */ LoadAndBootWindowsCommon(OperatingSystemVersion, diff --git a/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c b/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c index 3dc72f25b20..b280250142f 100644 --- a/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c +++ b/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c @@ -179,7 +179,6 @@ BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, /* TODO: Load OEM HAL font */ - return TRUE; }