* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: main.c,v 1.97 2001/06/04 11:27:54 chorns Exp $
+/* $Id: main.c,v 1.98 2001/06/29 20:43:55 ekohl Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
#include <internal/ke.h>
#include <internal/io.h>
#include <internal/po.h>
+#include <internal/se.h>
#include <napi/shared_data.h>
#include <internal/v86m.h>
#include <internal/kd.h>
/* FUNCTIONS ****************************************************************/
+static BOOLEAN
+RtlpCheckFileNameExtension(PCHAR FileName,
+ PCHAR Extension)
+{
+ PCHAR Ext;
+
+ Ext = strrchr(FileName, '.');
+ if ((Extension == NULL) || (*Extension == 0))
+ {
+ if (Ext == NULL)
+ return TRUE;
+ else
+ return FALSE;
+ }
+ if (*Extension != '.')
+ Ext++;
+
+ if (_stricmp(Ext, Extension) == 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
static VOID
CreateSystemRootLink (PCSZ ParameterLine)
{
assert(FIELD_OFFSET(KPCR, CurrentThread) == KPCR_CURRENT_THREAD);
LdrInit1();
-
+
KeLowerIrql(DISPATCH_LEVEL);
NtEarlyInitVdm();
KeInit2();
KeLowerIrql(PASSIVE_LEVEL);
-
+
ObInit();
PiInitProcessManager();
HalDisplayString("are welcome to change it and/or distribute copies of it "
"under certain\n");
HalDisplayString("conditions. There is absolutely no warranty for "
- "ReactOS.\n");
+ "ReactOS.\n\n");
/* Initialize all processors */
KeNumberProcessors = 0;
if (KeNumberProcessors > 1)
{
- sprintf(str, "Found %d system processors.\n",
- KeNumberProcessors);
+ sprintf(str,
+ "Found %d system processors. [%lu MB Memory]\n",
+ KeNumberProcessors,
+ (KeLoaderBlock.MemHigher + 1088)/ 1024);
}
else
{
- strcpy(str, "Found 1 system processor.\n");
+ sprintf(str,
+ "Found 1 system processor. [%lu MB Memory]\n",
+ (KeLoaderBlock.MemHigher + 1088)/ 1024);
}
HalDisplayString(str);
/*
* Initialize various critical subsystems
*/
- HalInitSystem (1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+ HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
ExInit();
IoInit();
MmInit3();
/* Report all resources used by hal */
- HalReportResourceUsage ();
-
- /*
- * Enter the kernel debugger before starting up the boot drivers
- */
-#ifdef KDBG
- KdbEnter();
-#endif /* KDBG */
-
+ HalReportResourceUsage();
+
+// DumpBIOSMemoryMap();
+
/*
* Initalize services loaded at boot time
*/
DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount);
for (i=0; i < KeLoaderBlock.ModsCount; i++)
{
- CPRINT("Module: %s\n", KeLoaderModules[i].String);
+ CPRINT("Module: '%s' at %08lx, length 0x%08lx\n",
+ KeLoaderModules[i].String,
+ KeLoaderModules[i].ModStart,
+ KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart);
+ }
+
+ /* Pass 1: load nls files */
+ for (i = 1; i < KeLoaderBlock.ModsCount; i++)
+ {
+ name = (PCHAR)KeLoaderModules[i].String;
+ if (RtlpCheckFileNameExtension(name, ".nls"))
+ {
+ ULONG Mod2Start = 0;
+ ULONG Mod2End = 0;
+ ULONG Mod3Start = 0;
+ ULONG Mod3End = 0;
+
+ name = (PCHAR)KeLoaderModules[i+1].String;
+ if (RtlpCheckFileNameExtension(name, ".nls"))
+ {
+ Mod2Start = (ULONG)KeLoaderModules[i+1].ModStart;
+ Mod2End = (ULONG)KeLoaderModules[i+1].ModEnd;
+
+ name = (PCHAR)KeLoaderModules[i+2].String;
+ if (RtlpCheckFileNameExtension(name, ".nls"))
+ {
+ Mod3Start = (ULONG)KeLoaderModules[i+2].ModStart;
+ Mod3End = (ULONG)KeLoaderModules[i+2].ModEnd;
+ }
+ }
+
+ /* Initialize nls sections */
+ RtlpInitNlsSections((ULONG)KeLoaderModules[i].ModStart,
+ (ULONG)KeLoaderModules[i].ModEnd,
+ Mod2Start,
+ Mod2End,
+ Mod3Start,
+ Mod3End);
+ break;
+ }
}
- /* Pass 1: load registry chunks passed in */
+ /* Pass 2: load registry chunks passed in */
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
- if (strcmp ((PCHAR) start, "REGEDIT4") == 0)
+ name = (PCHAR)KeLoaderModules[i].String;
+ if (RtlpCheckFileNameExtension(name, "") ||
+ RtlpCheckFileNameExtension(name, ".hiv"))
{
CPRINT("Process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start);
}
}
- /* Pass 2: process boot loaded drivers */
+ /*
+ * Enter the kernel debugger before starting up the boot drivers
+ */
+#ifdef KDBG
+ KdbEnter();
+#endif /* KDBG */
+
+ /* Pass 3: process boot loaded drivers */
for (i=1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
length = KeLoaderModules[i].ModEnd - start;
name = (PCHAR)KeLoaderModules[i].String;
- if (strcmp ((PCHAR) start, "REGEDIT4") != 0)
+ if (RtlpCheckFileNameExtension(name, ".sys") ||
+ RtlpCheckFileNameExtension(name, ".sym"))
{
CPRINT("Processing module '%s' at %08lx, length 0x%08lx\n",
- name, start, length);
+ name, start, length);
LdrProcessDriver((PVOID)start, name, length);
}
}
/*
* Start the motherboard enumerator (the HAL)
*/
- HalInitSystem (2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+ HalInitSystem(2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/*
* Load boot start drivers
-/* $Id: nls.c,v 1.4 2000/05/13 01:45:40 ekohl Exp $
+/* $Id: nls.c,v 1.5 2001/06/29 20:42:47 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <ddk/ntddk.h>
//#include <internal/nls.h>
+#define NDEBUG
+#include <internal/debug.h>
-BOOLEAN
-NlsMbCodePageTag = FALSE;
+/* GLOBALS *******************************************************************/
-BOOLEAN
-NlsMbOemCodePageTag = FALSE;
+BOOLEAN NlsMbCodePageTag = FALSE;
+BOOLEAN NlsMbOemCodePageTag = FALSE;
-BYTE
-NlsLeadByteInfo = 0; /* ? */
+BYTE NlsLeadByteInfo = 0; /* ? */
-USHORT
-NlsOemLeadByteInfo = 0;
+USHORT NlsOemLeadByteInfo = 0;
-USHORT
-NlsAnsiCodePage = 0;
-
-USHORT
-NlsOemCodePage = 0; /* not exported */
+USHORT NlsAnsiCodePage = 0;
+USHORT NlsOemCodePage = 0; /* not exported */
#if 0
/* FUNCTIONS *****************************************************************/
NTSTATUS
-STDCALL
-RtlCustomCPToUnicodeN (
- PRTL_NLS_DATA NlsData,
- PWCHAR UnicodeString,
- ULONG UnicodeSize,
- PULONG ResultSize,
- PCHAR CustomString,
- ULONG CustomSize)
+RtlpInitNlsSections(ULONG Mod1Start,
+ ULONG Mod1End,
+ ULONG Mod2Start,
+ ULONG Mod2End,
+ ULONG Mod3Start,
+ ULONG Mod3End)
{
- ULONG Size = 0;
- ULONG i;
-
- if (NlsData->DbcsFlag == FALSE)
- {
- /* single-byte code page */
- if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
- Size = UnicodeSize / sizeof(WCHAR);
- else
- Size = CustomSize;
+ UNICODE_STRING UnicodeString;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ HANDLE DirectoryHandle;
+ HANDLE SectionHandle;
+ NTSTATUS Status;
+ LARGE_INTEGER SectionSize;
+
+ DPRINT("Ansi section start: 0x%08lX\n", Mod1Start);
+ DPRINT("Ansi section end: 0x%08lX\n", Mod1End);
+ DPRINT("Oem section start: 0x%08lX\n", Mod2Start);
+ DPRINT("Oem section end: 0x%08lX\n", Mod2End);
+ DPRINT("Upcase section start: 0x%08lX\n", Mod3Start);
+ DPRINT("Upcase section end: 0x%08lX\n", Mod3End);
+
+ /* Create the '\NLS' directory */
+ RtlInitUnicodeString(&UnicodeString,
+ L"\\NLS");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &UnicodeString,
+ OBJ_PERMANENT,
+ NULL,
+ NULL);
+ Status = NtCreateDirectoryObject(&DirectoryHandle,
+ 0,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ /* Create the 'NlsSectionUnicode' section */
+ RtlInitUnicodeString(&UnicodeString,
+ L"NlsSectionUnicode");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &UnicodeString,
+ OBJ_PERMANENT,
+ DirectoryHandle,
+ NULL);
+ SectionSize.QuadPart = (Mod1End - Mod1Start) +
+ (Mod2End - Mod2Start) + (Mod3End - Mod3Start);
+ DPRINT("NlsSectionUnicode size: 0x%I64X\n", SectionSize.QuadPart);
+
+ Status = NtCreateSection(&SectionHandle,
+ SECTION_ALL_ACCESS,
+ &ObjectAttributes,
+ &SectionSize,
+ PAGE_READWRITE,
+ 0,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+
+ /* create and initialize code page table */
+
+ /* map the nls table into the 'NlsSectionUnicode' section */
+
+
+ NtClose(SectionHandle);
+ NtClose(DirectoryHandle);
+
+ return(STATUS_SUCCESS);
+}
- if (ResultSize != NULL)
- *ResultSize = Size * sizeof(WCHAR);
- for (i = 0; i < Size; i++)
- {
- *UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString];
- UnicodeString++;
- CustomString++;
- }
- }
+NTSTATUS STDCALL
+RtlCustomCPToUnicodeN(PRTL_NLS_DATA NlsData,
+ PWCHAR UnicodeString,
+ ULONG UnicodeSize,
+ PULONG ResultSize,
+ PCHAR CustomString,
+ ULONG CustomSize)
+{
+ ULONG Size = 0;
+ ULONG i;
+
+ if (NlsData->DbcsFlag == FALSE)
+ {
+ /* single-byte code page */
+ if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
+ Size = UnicodeSize / sizeof(WCHAR);
else
- {
- /* multi-byte code page */
- /* FIXME */
-
- }
-
- return STATUS_SUCCESS;
+ Size = CustomSize;
+
+ if (ResultSize != NULL)
+ *ResultSize = Size * sizeof(WCHAR);
+
+ for (i = 0; i < Size; i++)
+ {
+ *UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString];
+ UnicodeString++;
+ CustomString++;
+ }
+ }
+ else
+ {
+ /* multi-byte code page */
+ /* FIXME */
+
+ }
+
+ return STATUS_SUCCESS;
}
-VOID
-STDCALL
-RtlGetDefaultCodePage (
- PUSHORT AnsiCodePage,
- PUSHORT OemCodePage
- )
+VOID STDCALL
+RtlGetDefaultCodePage(PUSHORT AnsiCodePage,
+ PUSHORT OemCodePage)
{
- *AnsiCodePage = NlsAnsiCodePage;
- *OemCodePage = NlsOemCodePage;
+ *AnsiCodePage = NlsAnsiCodePage;
+ *OemCodePage = NlsOemCodePage;
}
-NTSTATUS
-STDCALL
-RtlMultiByteToUnicodeN (
- PWCHAR UnicodeString,
- ULONG UnicodeSize,
- PULONG ResultSize,
- PCHAR MbString,
- ULONG MbSize
- )
+NTSTATUS STDCALL
+RtlMultiByteToUnicodeN(PWCHAR UnicodeString,
+ ULONG UnicodeSize,
+ PULONG ResultSize,
+ PCHAR MbString,
+ ULONG MbSize)
{
ULONG Size = 0;
ULONG i;
}
-NTSTATUS
-STDCALL
-RtlMultiByteToUnicodeSize (
- PULONG UnicodeSize,
- PCHAR MbString,
- ULONG MbSize
- )
+NTSTATUS STDCALL
+RtlMultiByteToUnicodeSize(PULONG UnicodeSize,
+ PCHAR MbString,
+ ULONG MbSize)
{
if (NlsMbCodePageTag == FALSE)
{
}
-NTSTATUS
-STDCALL
-RtlUnicodeToMultiByteSize (
- PULONG MbSize,
- PWCHAR UnicodeString,
- ULONG UnicodeSize)
+NTSTATUS STDCALL
+RtlUnicodeToMultiByteSize(PULONG MbSize,
+ PWCHAR UnicodeString,
+ ULONG UnicodeSize)
{
if (NlsMbCodePageTag == FALSE)
{
}
-NTSTATUS
-STDCALL
+NTSTATUS STDCALL
RtlUnicodeToOemN (
PCHAR OemString,
ULONG OemSize,
}
-NTSTATUS
-STDCALL
+NTSTATUS STDCALL
RtlUpcaseUnicodeToCustomCPN (
PRTL_NLS_DATA NlsData,
PCHAR CustomString,
}
-NTSTATUS
-STDCALL
-RtlUpcaseUnicodeToMultiByteN (
- PCHAR MbString,
- ULONG MbSize,
- PULONG ResultSize,
- PWCHAR UnicodeString,
- ULONG UnicodeSize
- )
+NTSTATUS STDCALL
+RtlUpcaseUnicodeToMultiByteN(PCHAR MbString,
+ ULONG MbSize,
+ PULONG ResultSize,
+ PWCHAR UnicodeString,
+ ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
}
-NTSTATUS
-STDCALL
-RtlUpcaseUnicodeToOemN (
- PCHAR OemString,
- ULONG OemSize,
- PULONG ResultSize,
- PWCHAR UnicodeString,
- ULONG UnicodeSize
- )
+NTSTATUS STDCALL
+RtlUpcaseUnicodeToOemN(PCHAR OemString,
+ ULONG OemSize,
+ PULONG ResultSize,
+ PWCHAR UnicodeString,
+ ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;