reactos/boot/freeldr/freeldr/freeldr.c
Hermès Bélusca-Maïto fc29a6c41c
[FREELDR] Minor code improvements + 1 bug-fix.
- "FrldrBootPath" -> "FrLdrBootPath";
- Get rid of GetFreeLoaderVersionString() and use FrLdrVersionString
  directly instead;
- Rephrase some comments;
- Use RTL_NUMBER_OF();
- Reduce indent level in LoadOperatingSystem() and EditOperatingSystemEntry().

Bug fix:
- Fix DissectArcPath() for "ramdisk(0)" case.
2019-09-17 23:24:51 +02:00

101 lines
2.8 KiB
C

/*
* FreeLoader
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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.
*/
/* INCLUDES *******************************************************************/
#include <freeldr.h>
#include <debug.h>
DBG_DEFAULT_CHANNEL(WARNING);
/* GLOBALS ********************************************************************/
#define TOSTRING_(X) #X
#define TOSTRING(X) TOSTRING_(X)
const PCSTR FrLdrVersionString =
#if (FREELOADER_PATCH_VERSION == 0)
"FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION);
#else
"FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION) "." TOSTRING(FREELOADER_PATCH_VERSION);
#endif
CCHAR FrLdrBootPath[MAX_PATH] = "";
/* FUNCTIONS ******************************************************************/
VOID __cdecl BootMain(IN PCCH CmdLine)
{
CmdLineParse(CmdLine);
/* Debugger pre-initialization */
DebugInit(0);
TRACE("BootMain() called.\n");
MachInit(CmdLine);
/* Check if the CPU is new enough */
FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
/* UI pre-initialization */
if (!UiInitialize(FALSE))
{
UiMessageBoxCritical("Unable to initialize UI.");
goto Quit;
}
/* Initialize memory manager */
if (!MmInitializeMemoryManager())
{
UiMessageBoxCritical("Unable to initialize memory manager.");
goto Quit;
}
/* Initialize I/O subsystem */
FsInit();
RunLoader();
Quit:
/* If we reach this point, something went wrong before, therefore reboot */
Reboot();
}
// We need to emulate these, because the original ones don't work in freeldr
// These functions are here, because they need to be in the main compilation unit
// and cannot be in a library.
int __cdecl wctomb(char *mbchar, wchar_t wchar)
{
*mbchar = (char)wchar;
return 1;
}
int __cdecl mbtowc(wchar_t *wchar, const char *mbchar, size_t count)
{
*wchar = (wchar_t)*mbchar;
return 1;
}
// The wctype table is 144 KB, too much for poor freeldr
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
{
return _isctype((char)wc, wctypeFlags);
}