https://git.reactos.org/?p=reactos.git;a=commitdiff;h=571407c7d2bafa1051505…
commit 571407c7d2bafa1051505f8bb03426c34588b7fe
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Fri Dec 27 23:02:38 2019 +0300
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Feb 14 16:02:04 2020 +0100
[FREELDR] Separate PC and Xbox platform-specific code (#2185)
CORE-16216
---
boot/freeldr/freeldr/CMakeLists.txt | 41 ++++++++++++---------
boot/freeldr/freeldr/arch/i386/archmach.c | 44 -----------------------
boot/freeldr/freeldr/arch/i386/pc/machpc.c | 12 ++++++-
boot/freeldr/freeldr/arch/i386/xbox/machxbox.c | 23 +++++++++++-
boot/freeldr/freeldr/include/arch/amd64/amd64.h | 1 -
boot/freeldr/freeldr/include/arch/i386/machxbox.h | 2 --
boot/freeldr/freeldr/include/arch/pc/machpc.h | 2 --
7 files changed, 58 insertions(+), 67 deletions(-)
diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt
index 2573130ad02..5b32b2e74eb 100644
--- a/boot/freeldr/freeldr/CMakeLists.txt
+++ b/boot/freeldr/freeldr/CMakeLists.txt
@@ -113,7 +113,6 @@ if(ARCH STREQUAL "i386")
lib/fs/pxe.c
arch/i386/halstub.c
arch/i386/ntoskrnl.c
- arch/i386/archmach.c
arch/i386/drivemap.c
arch/i386/hardware.c
arch/i386/hwacpi.c
@@ -124,22 +123,32 @@ if(ARCH STREQUAL "i386")
arch/i386/i386idt.c
arch/i386/i386rtl.c
arch/i386/i386vid.c
- arch/i386/pc/machpc.c
- arch/i386/pc/pccons.c
- arch/i386/pc/pcdisk.c
- arch/i386/pc/pcmem.c
- arch/i386/pc/pcrtc.c
- arch/i386/pc/pcvideo.c
- arch/i386/xbox/machxbox.c
- arch/i386/xbox/xboxcons.c
- arch/i386/xbox/xboxdisk.c
- arch/i386/xbox/xboxfont.c
- arch/i386/xbox/xboxi2c.c
- arch/i386/xbox/xboxmem.c
- arch/i386/xbox/xboxrtc.c
- arch/i386/xbox/xboxvideo.c
disk/scsiport.c)
+ if(SARCH STREQUAL "xbox")
+ list(APPEND FREELDR_ARC_SOURCE
+ # FIXME: Abstract things better so we don't need to include /pc/* here
+ arch/i386/pc/machpc.c # machxbox.c depends on it
+ arch/i386/pc/pcdisk.c # hwdisk.c depends on it
+ arch/i386/pc/pcmem.c # hwacpi.c/xboxmem.c depends on it
+ arch/i386/xbox/machxbox.c
+ arch/i386/xbox/xboxcons.c
+ arch/i386/xbox/xboxdisk.c
+ arch/i386/xbox/xboxfont.c
+ arch/i386/xbox/xboxi2c.c
+ arch/i386/xbox/xboxmem.c
+ arch/i386/xbox/xboxrtc.c
+ arch/i386/xbox/xboxvideo.c)
+ else()
+ list(APPEND FREELDR_ARC_SOURCE
+ arch/i386/pc/machpc.c
+ arch/i386/pc/pccons.c
+ arch/i386/pc/pcdisk.c
+ arch/i386/pc/pcmem.c
+ arch/i386/pc/pcrtc.c
+ arch/i386/pc/pcvideo.c)
+ endif()
+
elseif(ARCH STREQUAL "amd64")
list(APPEND FREELDR_COMMON_ASM_SOURCE
arch/amd64/entry.S
@@ -196,7 +205,7 @@ if(USE_CLANG_CL)
# We need to reduce the binary size
add_target_compile_flags(freeldr_common "/Os")
endif()
-if(NOT MSVC AND ARCH STREQUAL "i386")
+if(NOT MSVC AND ARCH STREQUAL "i386" AND SARCH STREQUAL "xbox")
# Prevent a warning when doing a memcmp with address 0
set_source_files_properties(arch/i386/xbox/xboxmem.c PROPERTIES COMPILE_FLAGS
"-Wno-nonnull")
endif()
diff --git a/boot/freeldr/freeldr/arch/i386/archmach.c
b/boot/freeldr/freeldr/arch/i386/archmach.c
deleted file mode 100644
index 293f9481529..00000000000
--- a/boot/freeldr/freeldr/arch/i386/archmach.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * FreeLoader
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <freeldr.h>
-
-VOID
-MachInit(const char *CmdLine)
-{
- ULONG PciId;
-
- memset(&MachVtbl, 0, sizeof(MACHVTBL));
-
- /* Check for Xbox by identifying device at PCI 0:0:0, if it's
- * 0x10de/0x02a5 then we're running on an Xbox */
- WRITE_PORT_ULONG((ULONG*)0xcf8, CONFIG_CMD(0, 0, 0));
- PciId = READ_PORT_ULONG((ULONG*)0xcfc);
- if (PciId == 0x02a510de)
- {
- XboxMachInit(CmdLine);
- }
- else
- {
- PcMachInit(CmdLine);
- }
-
- HalpCalibrateStallExecution();
-}
-
-/* EOF */
diff --git a/boot/freeldr/freeldr/arch/i386/pc/machpc.c
b/boot/freeldr/freeldr/arch/i386/pc/machpc.c
index 3ca5578aa4b..b0b1ee9694b 100644
--- a/boot/freeldr/freeldr/arch/i386/pc/machpc.c
+++ b/boot/freeldr/freeldr/arch/i386/pc/machpc.c
@@ -1348,6 +1348,8 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG
*BusNumber)
/* FIXME: Detect more ISA devices */
}
+/* FIXME: Abstract things better so we don't need to place define here */
+#if !defined(SARCH_XBOX)
static
UCHAR
PcGetFloppyCount(VOID)
@@ -1359,6 +1361,7 @@ PcGetFloppyCount(VOID)
return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
}
+#endif
PCONFIGURATION_COMPONENT_DATA
PcHwDetect(VOID)
@@ -1416,9 +1419,13 @@ PcHwIdle(VOID)
/******************************************************************************/
+/* FIXME: Abstract things better so we don't need to place define here */
+#if !defined(SARCH_XBOX)
VOID
-PcMachInit(const char *CmdLine)
+MachInit(const char *CmdLine)
{
+ memset(&MachVtbl, 0, sizeof(MACHVTBL));
+
/* Setup vtbl */
MachVtbl.ConsPutChar = PcConsPutChar;
MachVtbl.ConsKbHit = PcConsKbHit;
@@ -1448,6 +1455,8 @@ PcMachInit(const char *CmdLine)
MachVtbl.InitializeBootDevices = PcInitializeBootDevices;
MachVtbl.HwDetect = PcHwDetect;
MachVtbl.HwIdle = PcHwIdle;
+
+ HalpCalibrateStallExecution();
}
VOID
@@ -1457,5 +1466,6 @@ PcPrepareForReactOS(VOID)
PcVideoPrepareForReactOS();
DiskStopFloppyMotor();
}
+#endif
/* EOF */
diff --git a/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
b/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
index ed99abbb72a..4d84089b9fb 100644
--- a/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
+++ b/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
@@ -253,8 +253,27 @@ VOID XboxHwIdle(VOID)
/******************************************************************************/
VOID
-XboxMachInit(const char *CmdLine)
+MachInit(const char *CmdLine)
{
+ ULONG PciId;
+
+ memset(&MachVtbl, 0, sizeof(MACHVTBL));
+
+ /* Check for Xbox by identifying device at PCI 0:0:0, if it's
+ * 0x10DE/0x02A5 then we're running on an Xbox */
+ WRITE_PORT_ULONG((ULONG *)0xCF8, CONFIG_CMD(0, 0, 0));
+ PciId = READ_PORT_ULONG((ULONG *)0xCFC);
+ if (PciId != 0x02A510DE)
+ {
+ ERR("This is not original Xbox!\n");
+
+ /* Disable and halt the CPU */
+ _disable();
+ __halt();
+
+ while (TRUE);
+ }
+
/* Set LEDs to red before anything is initialized */
XboxSetLED("rrrr");
@@ -294,6 +313,8 @@ XboxMachInit(const char *CmdLine)
/* Set LEDs to orange after init */
XboxSetLED("oooo");
+
+ HalpCalibrateStallExecution();
}
VOID
diff --git a/boot/freeldr/freeldr/include/arch/amd64/amd64.h
b/boot/freeldr/freeldr/include/arch/amd64/amd64.h
index 8a5ccddecca..17d6214c1a8 100644
--- a/boot/freeldr/freeldr/include/arch/amd64/amd64.h
+++ b/boot/freeldr/freeldr/include/arch/amd64/amd64.h
@@ -39,7 +39,6 @@
#ifndef ASM
VOID FrLdrSetupGdtIdt(VOID);
-#define MachInit PcMachInit
#endif
/* EOF */
diff --git a/boot/freeldr/freeldr/include/arch/i386/machxbox.h
b/boot/freeldr/freeldr/include/arch/i386/machxbox.h
index 4b85e9b59d3..062d74ff85b 100644
--- a/boot/freeldr/freeldr/include/arch/i386/machxbox.h
+++ b/boot/freeldr/freeldr/include/arch/i386/machxbox.h
@@ -48,8 +48,6 @@
extern UCHAR XboxFont8x16[256 * 16];
-VOID XboxMachInit(const char *CmdLine);
-
VOID XboxConsPutChar(int Ch);
BOOLEAN XboxConsKbHit(VOID);
int XboxConsGetCh(VOID);
diff --git a/boot/freeldr/freeldr/include/arch/pc/machpc.h
b/boot/freeldr/freeldr/include/arch/pc/machpc.h
index b76e55e776a..35bf0e904c8 100644
--- a/boot/freeldr/freeldr/include/arch/pc/machpc.h
+++ b/boot/freeldr/freeldr/include/arch/pc/machpc.h
@@ -24,8 +24,6 @@
#include "mm.h"
#endif
-VOID PcMachInit(const char *CmdLine);
-
VOID PcBeep(VOID);
VOID PcConsPutChar(int Ch);