ReactOS 0.4.15-dev-6662-g1b3eed5
freeldr.c
Go to the documentation of this file.
1/*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20/* INCLUDES *******************************************************************/
21
22#include <freeldr.h>
23
24#include <debug.h>
26
27/* GLOBALS ********************************************************************/
28
29#define TOSTRING_(X) #X
30#define TOSTRING(X) TOSTRING_(X)
31
33#if (FREELOADER_PATCH_VERSION == 0)
35#else
37#endif
38
40
41/* FUNCTIONS ******************************************************************/
42
44{
46
47 /* Debugger pre-initialization */
48 DebugInit(0);
49
51
52 TRACE("BootMain() called.\n");
53
54#ifndef UEFIBOOT
55 /* Check if the CPU is new enough */
56 FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
57#endif
58
59 /* UI pre-initialization */
60 if (!UiInitialize(FALSE))
61 {
62 UiMessageBoxCritical("Unable to initialize UI.");
63 goto Quit;
64 }
65
66 /* Initialize memory manager */
68 {
69 UiMessageBoxCritical("Unable to initialize memory manager.");
70 goto Quit;
71 }
72
73 /* Initialize I/O subsystem */
74 FsInit();
75
76 RunLoader();
77
78Quit:
79 /* If we reach this point, something went wrong before, therefore reboot */
80 Reboot();
81}
82
83// We need to emulate these, because the original ones don't work in freeldr
84// These functions are here, because they need to be in the main compilation unit
85// and cannot be in a library.
86int __cdecl wctomb(char *mbchar, wchar_t wchar)
87{
88 *mbchar = (char)wchar;
89 return 1;
90}
91
92int __cdecl mbtowc(wchar_t *wchar, const char *mbchar, size_t count)
93{
94 *wchar = (wchar_t)*mbchar;
95 return 1;
96}
97
98// The wctype table is 144 KB, too much for poor freeldr
99int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
100{
101 return _isctype((char)wc, wctypeFlags);
102}
103
104#ifdef _MSC_VER
105#pragma warning(disable:4164)
106#pragma function(pow)
107#pragma function(log)
108#pragma function(log10)
109#endif
110
111// Stubs to avoid pulling in data from CRT
112double pow(double x, double y)
113{
114 __debugbreak();
115 return 0.0;
116}
117
118double log(double x)
119{
120 __debugbreak();
121 return 0.0;
122}
123
124double log10(double x)
125{
126 __debugbreak();
127 return 0.0;
128}
#define WARNING
Definition: BusLogic958.h:56
int wint_t
Definition: _apple.h:38
#define __cdecl
Definition: accygwin.h:79
@ Reboot
Definition: bl.h:891
#define DebugInit(FrLdrSectionId)
Definition: debug.h:117
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
VOID FsInit(VOID)
Definition: fs.c:432
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:315
VOID CmdLineParse(IN PCSTR CmdLine)
Definition: cmdline.c:29
unsigned short wctype_t
Definition: crtdefs.h:352
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
static const WCHAR CmdLine[]
Definition: install.c:48
unsigned char
Definition: typeof.h:29
VOID RunLoader(VOID)
Definition: bootmgr.c:303
VOID __cdecl BootMain(IN PCCH CmdLine)
Definition: freeldr.c:43
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:39
#define TOSTRING(X)
Definition: freeldr.c:30
double log10(double x)
Definition: freeldr.c:124
double pow(double x, double y)
Definition: freeldr.c:112
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
Definition: freeldr.c:99
const PCSTR FrLdrVersionString
Definition: freeldr.c:32
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
_Check_return_ _CRTIMP int __cdecl _isctype(_In_ int _C, _In_ int _Type)
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
VOID FrLdrCheckCpuCompatibility(VOID)
Definition: macharm.c:65
VOID MachInit(IN PCCH CommandLine)
Definition: macharm.c:181
CONST CHAR * PCCH
Definition: ntbasedef.h:392
#define log(outFile, fmt,...)
Definition: util.h:15
#define TRACE(s)
Definition: solgame.cpp:4
#define wctomb(cp, wc)
Definition: wchar.h:161
#define wchar_t
Definition: wchar.h:102
#define mbtowc(wp, cp, len)
Definition: wchar.h:155
const char * PCSTR
Definition: typedefs.h:52
#define IN
Definition: typedefs.h:39
char CCHAR
Definition: typedefs.h:51
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:368
BOOLEAN UiInitialize(BOOLEAN ShowUi)
Definition: ui.c:92
#define FREELOADER_MINOR_VERSION
Definition: ver.h:36
#define FREELOADER_PATCH_VERSION
Definition: ver.h:37
#define FREELOADER_MAJOR_VERSION
Definition: ver.h:35