Skip to content

Commit 9e64fa8

Browse files
committed
[FREELDR:XBOX] Fix compilation dependencies and linking for the XBOX build (reactos#8510)
CORE-16216 machpc.c: - Surround more PC-specific routines in `#if !defined(SARCH_XBOX)`, so that they aren't compiled for XBOX. - In particular since commit 246f2d2 (PR reactos#8418), the PC-specific `DiskGetConfigType()` was compiled at the same time as the XBOX one. This is now fixed. machxbox.c - Add a dummy `ChainLoadBiosBootSectorCode()` to make freeldr exports working. xboxdisk.c - Minimal Disk I/O error support routines. - Add a dummy `DiskResetController()`, invoked in pchw.c - Add a dummy `DiskStopFloppyMotor()`, needed for entry.S/linux.S miscboot.c - Still compile `LoadAndBootSector()` (avoids lots of changes elsewhere), but display an error message if it's run, and directly return with an error. pcat.cmake - Remove unnecessary dependencies on pcdisk.c and pcvesa.c
1 parent f7aa250 commit 9e64fa8

File tree

5 files changed

+91
-11
lines changed

5 files changed

+91
-11
lines changed

boot/freeldr/freeldr/arch/i386/pc/machpc.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ typedef struct _PNP_DOCK_INFO
100100
} PNP_DOCK_INFO, *PPNP_DOCK_INFO;
101101
#include <poppack.h>
102102

103+
/* FIXME: Abstract things better so we don't need to place define here */
104+
#if !defined(SARCH_XBOX)
105+
103106
VOID
104107
PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
105108
{
@@ -385,6 +388,8 @@ DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
385388
(*BusNumber)++;
386389
}
387390

391+
#endif // !SARCH_XBOX
392+
388393
static
389394
VOID
390395
InitializeSerialPort(PUCHAR Port,
@@ -711,6 +716,8 @@ DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey,
711716
}
712717
}
713718

719+
/* FIXME: Abstract things better so we don't need to place define here */
720+
#if !defined(SARCH_XBOX)
714721
static
715722
ULONG
716723
PcGetSerialPort(ULONG Index, PULONG Irq)
@@ -728,6 +735,7 @@ PcGetSerialPort(ULONG Index, PULONG Irq)
728735

729736
return (ULONG) *(BasePtr + Index);
730737
}
738+
#endif // !SARCH_XBOX
731739

732740
/*
733741
* Parse the serial mouse detection options.
@@ -880,6 +888,9 @@ DetectSerialPorts(
880888
}
881889
}
882890

891+
/* FIXME: Abstract things better so we don't need to place define here */
892+
#if !defined(SARCH_XBOX)
893+
883894
static VOID
884895
DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
885896
{
@@ -971,6 +982,8 @@ DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
971982
TRACE("DetectParallelPorts() done\n");
972983
}
973984

985+
#endif // !SARCH_XBOX
986+
974987
// static
975988
BOOLEAN
976989
DetectKeyboardDevice(VOID)
@@ -1172,6 +1185,9 @@ DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
11721185
DetectKeyboardPeripheral(ControllerKey);
11731186
}
11741187

1188+
/* FIXME: Abstract things better so we don't need to place define here */
1189+
#if !defined(SARCH_XBOX)
1190+
11751191
static
11761192
VOID
11771193
PS2ControllerWait(VOID)
@@ -1672,8 +1688,6 @@ DetectIsaBios(
16721688
/* FIXME: Detect more ISA devices */
16731689
}
16741690

1675-
/* FIXME: Abstract things better so we don't need to place define here */
1676-
#if !defined(SARCH_XBOX)
16771691
static
16781692
UCHAR
16791693
PcGetFloppyCount(VOID)
@@ -1685,7 +1699,6 @@ PcGetFloppyCount(VOID)
16851699

16861700
return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
16871701
}
1688-
#endif
16891702

16901703
PCONFIGURATION_COMPONENT_DATA
16911704
PcHwDetect(
@@ -1768,6 +1781,9 @@ VOID __cdecl ChainLoadBiosBootSectorCode(
17681781
0x0000, 0x7C00);
17691782
}
17701783

1784+
#endif // !SARCH_XBOX
1785+
1786+
17711787
/******************************************************************************/
17721788

17731789
/* FIXME: Abstract things better so we don't need to place define here */
@@ -1813,7 +1829,7 @@ MachInit(const char *CmdLine)
18131829
VOID
18141830
PcPrepareForReactOS(VOID)
18151831
{
1816-
/* On PC, prepare video and turn off the floppy motor */
1832+
/* Prepare video and turn off the floppy motor */
18171833
PcVideoPrepareForReactOS();
18181834
DiskStopFloppyMotor();
18191835
}

boot/freeldr/freeldr/arch/i386/xbox/machxbox.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ VOID XboxHwIdle(VOID)
290290
/* UNIMPLEMENTED */
291291
}
292292

293+
// FIXME: Dummy to make freeldr exports working.
294+
VOID __cdecl ChainLoadBiosBootSectorCode(
295+
IN UCHAR BootDrive OPTIONAL,
296+
IN ULONG BootPartition OPTIONAL)
297+
{
298+
/* No-op on XBOX */
299+
}
293300

294301
/******************************************************************************/
295302

@@ -372,11 +379,8 @@ MachInit(const char *CmdLine)
372379
VOID
373380
XboxPrepareForReactOS(VOID)
374381
{
375-
/* On Xbox, prepare video and disk support */
382+
/* Prepare video and turn off debug messages to screen */
376383
XboxVideoPrepareForReactOS();
377-
DiskStopFloppyMotor();
378-
379-
/* Turn off debug messages to screen */
380384
DebugDisableScreenPort();
381385
}
382386

boot/freeldr/freeldr/arch/i386/xbox/xboxdisk.c

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,47 @@ static PDEVICE_UNIT HardDrive = NULL;
2020
static PDEVICE_UNIT CdDrive = NULL;
2121
static BOOLEAN AtaInitialized = FALSE;
2222

23+
/* DISK IO ERROR SUPPORT *****************************************************/
24+
25+
static LONG lReportError = 0; // >= 0: display errors; < 0: hide errors.
26+
27+
LONG DiskReportError(BOOLEAN bShowError)
28+
{
29+
/* Set the reference count */
30+
if (bShowError) ++lReportError;
31+
else --lReportError;
32+
return lReportError;
33+
}
34+
35+
#if 0 // TODO: ATA/IDE error code descriptions.
36+
static PCSTR DiskGetErrorCodeString(ULONG ErrorCode)
37+
{
38+
switch (ErrorCode)
39+
{
40+
default: return "unknown error code";
41+
}
42+
}
43+
#endif
44+
45+
static VOID DiskError(PCSTR ErrorString, ULONG ErrorCode)
46+
{
47+
CHAR ErrorCodeString[200];
48+
49+
if (lReportError < 0)
50+
return;
51+
52+
#if 0 // TODO: ATA/IDE error code descriptions.
53+
sprintf(ErrorCodeString, "%s\n\nError Code: 0x%lx\nError: %s",
54+
ErrorString, ErrorCode, DiskGetErrorCodeString(ErrorCode));
55+
#else
56+
UNREFERENCED_PARAMETER(ErrorCode);
57+
sprintf(ErrorCodeString, "%s", ErrorString);
58+
#endif
59+
60+
ERR("%s\n", ErrorCodeString);
61+
UiMessageBox(ErrorCodeString);
62+
}
63+
2364
/* FUNCTIONS ******************************************************************/
2465

2566
static
@@ -77,6 +118,13 @@ XboxDiskDriveNumberToDeviceUnit(UCHAR DriveNumber)
77118
return NULL;
78119
}
79120

121+
BOOLEAN DiskResetController(UCHAR DriveNumber)
122+
{
123+
WARN("DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n", DriveNumber);
124+
/* No-op on XBOX */
125+
return TRUE;
126+
}
127+
80128
CONFIGURATION_TYPE
81129
DiskGetConfigType(
82130
_In_ UCHAR DriveNumber)
@@ -93,6 +141,12 @@ DiskGetConfigType(
93141
return DiskPeripheral;
94142
}
95143

144+
// FIXME: Dummy for entry.S/linux.S
145+
VOID __cdecl DiskStopFloppyMotor(VOID)
146+
{
147+
/* No-op on XBOX */
148+
}
149+
96150
BOOLEAN
97151
XboxDiskReadLogicalSectors(
98152
IN UCHAR DriveNumber,
@@ -101,6 +155,7 @@ XboxDiskReadLogicalSectors(
101155
OUT PVOID Buffer)
102156
{
103157
PDEVICE_UNIT DeviceUnit;
158+
BOOLEAN Success;
104159

105160
TRACE("XboxDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u Buffer: 0x%x\n",
106161
DriveNumber, SectorNumber, SectorCount, Buffer);
@@ -109,7 +164,10 @@ XboxDiskReadLogicalSectors(
109164
if (!DeviceUnit)
110165
return FALSE;
111166

112-
return AtaReadLogicalSectors(DeviceUnit, SectorNumber, SectorCount, Buffer);
167+
Success = AtaReadLogicalSectors(DeviceUnit, SectorNumber, SectorCount, Buffer);
168+
if (!Success)
169+
DiskError("Disk Read Failed", -1);
170+
return Success;
113171
}
114172

115173
BOOLEAN

boot/freeldr/freeldr/miscboot.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ LoadAndBootSector(
3838
_In_ PCHAR Argv[],
3939
_In_ PCHAR Envp[])
4040
{
41+
#if defined(SARCH_XBOX)
42+
UiMessageBox("Boot sector booting is not supported on XBOX.");
43+
return ENOEXEC;
44+
#endif
4145
ARC_STATUS Status;
4246
PCSTR ArgValue;
4347
PCSTR BootPath;

boot/freeldr/freeldr/pcat.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ if(ARCH STREQUAL "i386")
6969
# FIXME: Abstract things better so we don't need to include /pc/* here
7070
arch/i386/pc/machpc.c # machxbox.c depends on it
7171
arch/i386/pc/pcbeep.c # machxbox.c depends on it
72-
arch/i386/pc/pcdisk.c # hwdisk.c depends on it
7372
arch/i386/pc/pchw.c # Many files depends on it
7473
arch/i386/pc/pcmem.c # hwacpi.c/xboxmem.c depends on it
75-
arch/i386/pc/pcvesa.c # machpc.c depends on it
7674
arch/i386/xbox/machxbox.c
7775
arch/i386/xbox/xboxcons.c
7876
arch/i386/xbox/xboxdisk.c

0 commit comments

Comments
 (0)