[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / freeldr.c
index 04dae9b..01af41e 100644 (file)
@@ -20,6 +20,8 @@
 #include <freeldr.h>
 #include <debug.h>
 
+DBG_DEFAULT_CHANNEL(WARNING);
+
 VOID NTAPI HalpInitializePciStubs(VOID);
 VOID NTAPI HalpInitBusHandler(VOID);
 
@@ -33,18 +35,18 @@ VOID BootMain(LPSTR CmdLine)
 
        DebugInit();
 
-       DPRINTM(DPRINT_WARNING, "BootMain() called.\n");
+       TRACE("BootMain() called.\n");
 
        if (!UiInitialize(FALSE))
        {
                UiMessageBoxCritical("Unable to initialize UI.\n");
-               return;
+               goto quit;
        }
 
        if (!MmInitializeMemoryManager())
        {
                UiMessageBoxCritical("Unable to initialize memory manager");
-               return;
+               goto quit;
        }
 
 #ifdef _M_IX86
@@ -52,4 +54,31 @@ VOID BootMain(LPSTR CmdLine)
        HalpInitBusHandler();
 #endif
        RunLoader();
+
+quit:
+       /* If we reach this point, something went wrong before, therefore reboot */
+       DiskStopFloppyMotor();
+       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 iswctype(wint_t wc, wctype_t wctypeFlags)
+{
+    return _isctype((char)wc, wctypeFlags);
 }
+