Skip to content

Commit 2f9dde0

Browse files
committed
[FREELDR] Replace some macros/inline functions and global variables with functions
This allows to easily import them from a 2nd stage loader without having to bother about _declspec(dllimport)
1 parent aa46e0f commit 2f9dde0

File tree

27 files changed

+216
-90
lines changed

27 files changed

+216
-90
lines changed

boot/freeldr/freeldr/arch/arcemul.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,25 @@ ArcGetRelativeTime(VOID)
4040
return ret;
4141
}
4242

43+
PCONFIGURATION_COMPONENT_DATA
44+
MachHwDetect(_In_opt_ PCSTR Options)
45+
{
46+
return MachVtbl.HwDetect(Options);
47+
}
48+
49+
VOID MachPrepareForReactOS(VOID)
50+
{
51+
MachVtbl.PrepareForReactOS();
52+
}
53+
54+
VOID MachGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
55+
{
56+
MachVtbl.GetExtendedBIOSData(ExtendedBIOSDataArea, ExtendedBIOSDataSize);
57+
}
58+
59+
VOID MachVideoGetFontsFromFirmware(PULONG RomFontPointers)
60+
{
61+
MachVtbl.VideoGetFontsFromFirmware(RomFontPointers);
62+
}
63+
4364
/* EOF */

boot/freeldr/freeldr/arch/archwsup.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,18 @@ FldrCreateComponentKey(
243243
/* Return the child */
244244
*ComponentKey = ComponentData;
245245
}
246+
247+
ULONG ArcGetDiskCount(VOID)
248+
{
249+
return reactos_disk_count;
250+
}
251+
252+
PARC_DISK_SIGNATURE_EX ArcGetDiskInfo(ULONG Index)
253+
{
254+
if (Index >= reactos_disk_count)
255+
{
256+
return NULL;
257+
}
258+
259+
return &reactos_arc_disk_info[Index];
260+
}

boot/freeldr/freeldr/arch/i386/hwacpi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
2525

2626
BOOLEAN AcpiPresent = FALSE;
2727

28+
BOOLEAN IsAcpiPresent(VOID)
29+
{
30+
return AcpiPresent;
31+
}
32+
2833
static PRSDP_DESCRIPTOR
2934
FindAcpiBios(VOID)
3035
{

boot/freeldr/freeldr/arch/uefi/uefihw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ BOOLEAN AcpiPresent = FALSE;
2424

2525
/* FUNCTIONS *****************************************************************/
2626

27+
BOOLEAN IsAcpiPresent(VOID)
28+
{
29+
return AcpiPresent;
30+
}
31+
2732
static
2833
PRSDP_DESCRIPTOR
2934
FindAcpiBios(VOID)

boot/freeldr/freeldr/bootmgr.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ WarnDeprecated(
8585
CHAR msgString[300];
8686

8787
/* If the user didn't cancel the timeout, don't display the warning */
88-
if (BootMgrInfo.TimeOut >= 0)
88+
if (GetBootMgrInfo()->TimeOut >= 0)
8989
return;
9090

9191
va_start(ap, MsgFmt);
@@ -183,6 +183,7 @@ BuildArgvForOsLoader(
183183
PCHAR* Argv;
184184
PCHAR* Args;
185185
PCHAR SettingName, SettingValue;
186+
PCCHAR BootPath = FrLdrGetBootPath();
186187

187188
*pArgc = 0;
188189

@@ -208,7 +209,7 @@ BuildArgvForOsLoader(
208209
/* i == 0: Program name */
209210
// TODO: Provide one in the future...
210211
/* i == 1: SystemPartition : from where FreeLdr has been started */
211-
Size += (strlen("SystemPartition=") + strlen(FrLdrBootPath) + 1) * sizeof(CHAR);
212+
Size += (strlen("SystemPartition=") + strlen(BootPath) + 1) * sizeof(CHAR);
212213
/* i == 2: LoadIdentifier : ASCII string that may be used
213214
* to associate an identifier with a set of load parameters */
214215
if (LoadIdentifier)
@@ -236,7 +237,7 @@ BuildArgvForOsLoader(
236237
/* i == 1: SystemPartition */
237238
{
238239
strcpy(SettingName, "SystemPartition=");
239-
strcat(SettingName, FrLdrBootPath);
240+
strcat(SettingName, BootPath);
240241

241242
*Args++ = SettingName;
242243
SettingName += (strlen(SettingName) + 1);
@@ -333,7 +334,7 @@ MainBootMenuKeyPressFilter(
333334
IN PVOID Context OPTIONAL)
334335
{
335336
/* Any key-press cancels the global timeout */
336-
BootMgrInfo.TimeOut = -1;
337+
GetBootMgrInfo()->TimeOut = -1;
337338

338339
switch (KeyPress)
339340
{
@@ -394,7 +395,7 @@ VOID RunLoader(VOID)
394395
#endif
395396

396397
/* Debugger main initialization */
397-
DebugInit(BootMgrInfo.DebugString);
398+
DebugInit(GetBootMgrInfo()->DebugString);
398399

399400
/* UI main initialization */
400401
if (!UiInitialize(TRUE))
@@ -427,7 +428,7 @@ VOID RunLoader(VOID)
427428
}
428429

429430
/* Find all the message box settings and run them */
430-
UiShowMessageBoxesInSection(BootMgrInfo.FrLdrSection);
431+
UiShowMessageBoxesInSection(GetBootMgrInfo()->FrLdrSection);
431432

432433
for (;;)
433434
{
@@ -442,7 +443,7 @@ VOID RunLoader(VOID)
442443
OperatingSystemDisplayNames,
443444
OperatingSystemCount,
444445
DefaultOperatingSystem,
445-
BootMgrInfo.TimeOut,
446+
GetBootMgrInfo()->TimeOut,
446447
&SelectedOperatingSystem,
447448
FALSE,
448449
MainBootMenuKeyPressFilter,
@@ -455,12 +456,12 @@ VOID RunLoader(VOID)
455456
/* Load the chosen operating system */
456457
LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
457458

458-
BootMgrInfo.TimeOut = -1;
459+
GetBootMgrInfo()->TimeOut = -1;
459460

460461
/* If we get there, the OS loader failed. As it may have
461462
* messed up the display, re-initialize the UI. */
462463
#ifndef _M_ARM
463-
UiVtbl.UnInitialize();
464+
UiUnInitialize("");
464465
#endif
465466
UiInitialize(TRUE);
466467
}

boot/freeldr/freeldr/disk/scsiport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ LoadBootDeviceDriver(VOID)
16471647
#endif
16481648

16491649
/* Create full ntbootdd.sys path */
1650-
strcpy(NtBootDdPath, FrLdrBootPath);
1650+
strcpy(NtBootDdPath, FrLdrGetBootPath());
16511651
strcat(NtBootDdPath, "\\NTBOOTDD.SYS");
16521652

16531653
/* Load ntbootdd.sys */

boot/freeldr/freeldr/freeldr.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,18 @@ double log10(double x)
124124
__debugbreak();
125125
return 0.0;
126126
}
127+
128+
PCCHAR FrLdrGetBootPath(VOID)
129+
{
130+
return FrLdrBootPath;
131+
}
132+
133+
UCHAR FrldrGetBootDrive(VOID)
134+
{
135+
return FrldrBootDrive;
136+
}
137+
138+
ULONG FrldrGetBootPartition(VOID)
139+
{
140+
return FrldrBootPartition;
141+
}

boot/freeldr/freeldr/include/disk.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,7 @@ DiskGetPartitionEntry(
153153
* SCSI support (disk/scsiport.c)
154154
*/
155155
ULONG LoadBootDeviceDriver(VOID);
156+
157+
PCCHAR FrLdrGetBootPath(VOID);
158+
UCHAR FrldrGetBootDrive(VOID);
159+
ULONG FrldrGetBootPartition(VOID);

boot/freeldr/freeldr/include/inifile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId);
8383
BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue);
8484
BOOLEAN IniModifySettingValue(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue);
8585
VOID IniCleanup(VOID);
86+
PLIST_ENTRY IniGetFileSectionListHead(VOID);

boot/freeldr/freeldr/include/machine.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ VOID MachInit(const char *CmdLine);
9797
MachVtbl.VideoGetDisplaySize((W), (H), (D))
9898
#define MachVideoGetBufferSize() \
9999
MachVtbl.VideoGetBufferSize()
100-
#define MachVideoGetFontsFromFirmware(RomFontPointers) \
101-
MachVtbl.VideoGetFontsFromFirmware((RomFontPointers))
102100
#define MachVideoSetTextCursorPosition(X, Y) \
103101
MachVtbl.VideoSetTextCursorPosition((X), (Y))
104102
#define MachVideoHideShowTextCursor(Show) \
@@ -117,10 +115,6 @@ VOID MachInit(const char *CmdLine);
117115
MachVtbl.VideoSync()
118116
#define MachBeep() \
119117
MachVtbl.Beep()
120-
#define MachPrepareForReactOS() \
121-
MachVtbl.PrepareForReactOS()
122-
#define MachGetExtendedBIOSData(ExtendedBIOSDataArea, ExtendedBIOSDataSize) \
123-
MachVtbl.GetExtendedBIOSData((ExtendedBIOSDataArea), (ExtendedBIOSDataSize))
124118
#define MachGetFloppyCount() \
125119
MachVtbl.GetFloppyCount()
126120
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) \
@@ -133,9 +127,6 @@ VOID MachInit(const char *CmdLine);
133127
#define MachInitializeBootDevices() \
134128
MachVtbl.InitializeBootDevices()
135129

136-
#define MachHwDetect(Options) \
137-
MachVtbl.HwDetect(Options)
138-
139130
#define MachHwIdle() \
140131
MachVtbl.HwIdle()
141132

@@ -144,4 +135,9 @@ VOID MachInit(const char *CmdLine);
144135
TIMEINFO* ArcGetTime(VOID);
145136
ULONG ArcGetRelativeTime(VOID);
146137

138+
PCONFIGURATION_COMPONENT_DATA MachHwDetect(_In_opt_ PCSTR Options);
139+
VOID MachPrepareForReactOS(VOID);
140+
VOID MachGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize);
141+
VOID MachVideoGetFontsFromFirmware(PULONG RomFontPointers);
142+
147143
/* EOF */

0 commit comments

Comments
 (0)