mirror of
https://github.com/reactos/reactos.git
synced 2024-10-03 16:05:37 +00:00
Giannis Adamopoulos <johnyadams@hotmail.com>
- Removes duplicated implementation of FrLdrLoadKernel, LoadDriver and LoadNlsFile from setupldr.c, use FrLdrLoadImage, FrLdrLoadNlsFile and FrLdrLoadDriver from reactos.c. - Also remove the call to RegInitializeRegistry as setupldr doesn't need the registry. - Make setupldr load the fastfat and ext2 drivers via txtsetup.sif, instead of hardcoding them in setupldr.c svn path=/trunk/; revision=35285
This commit is contained in:
parent
2afb238075
commit
e03a9212c0
|
@ -32,8 +32,8 @@ ntfs.sys=,,,,,,,,,,,,4
|
||||||
pci.sys=,,,,,,,,,,,,4
|
pci.sys=,,,,,,,,,,,,4
|
||||||
scsiport.sys=,,,,,,x,,,,,,4
|
scsiport.sys=,,,,,,x,,,,,,4
|
||||||
uniata.sys=,,,,,,,,,,,,4
|
uniata.sys=,,,,,,,,,,,,4
|
||||||
fastfat.sys=,,,,,,,,,,,,4
|
fastfat.sys=,,,,,,x,,,,,,4
|
||||||
ext2.sys=,,,,,,,,,,,,4
|
ext2.sys=,,,,,,x,,,,,,4
|
||||||
|
|
||||||
[HardwareIdsDatabase]
|
[HardwareIdsDatabase]
|
||||||
*PNP0C08 = acpi
|
*PNP0C08 = acpi
|
||||||
|
|
|
@ -189,7 +189,7 @@ FrLdrLoadImage(IN PCHAR szFileName,
|
||||||
return LoadBase;
|
return LoadBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN
|
BOOLEAN
|
||||||
FrLdrLoadNlsFile(PCSTR szFileName,
|
FrLdrLoadNlsFile(PCSTR szFileName,
|
||||||
PCSTR szModuleName)
|
PCSTR szModuleName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,133 +38,16 @@ extern ULONG_PTR KernelBase;
|
||||||
extern ROS_KERNEL_ENTRY_POINT KernelEntryPoint;
|
extern ROS_KERNEL_ENTRY_POINT KernelEntryPoint;
|
||||||
|
|
||||||
extern BOOLEAN FrLdrLoadDriver(PCHAR szFileName, INT nPos);
|
extern BOOLEAN FrLdrLoadDriver(PCHAR szFileName, INT nPos);
|
||||||
|
extern BOOLEAN FrLdrLoadNlsFile(PCSTR szFileName, PCSTR szModuleName);
|
||||||
|
|
||||||
#define USE_UI
|
#define USE_UI
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
static FrLdrLoadKernel(IN PCHAR szFileName,
|
|
||||||
IN INT nPos)
|
|
||||||
{
|
|
||||||
PFILE FilePointer;
|
|
||||||
PCHAR szShortName;
|
|
||||||
CHAR szBuffer[256];
|
|
||||||
PVOID LoadBase;
|
|
||||||
PIMAGE_NT_HEADERS NtHeader;
|
|
||||||
|
|
||||||
/* Extract Kernel filename without path */
|
|
||||||
szShortName = strrchr(szFileName, '\\');
|
|
||||||
if (!szShortName)
|
|
||||||
{
|
|
||||||
/* No path, leave it alone */
|
|
||||||
szShortName = szFileName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Skip the path */
|
|
||||||
szShortName = szShortName + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open the Kernel */
|
|
||||||
FilePointer = FsOpenFile(szFileName);
|
|
||||||
if (!FilePointer)
|
|
||||||
{
|
|
||||||
/* Return failure on the short name */
|
|
||||||
strcpy(szBuffer, szShortName);
|
|
||||||
strcat(szBuffer, " not found.");
|
|
||||||
UiMessageBox(szBuffer);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update the status bar with the current file */
|
|
||||||
strcpy(szBuffer, "Reading ");
|
|
||||||
strcat(szBuffer, szShortName);
|
|
||||||
UiDrawStatusText(szBuffer);
|
|
||||||
|
|
||||||
/* Do the actual loading */
|
|
||||||
LoadBase = FrLdrReadAndMapImage(FilePointer, szShortName, 1);
|
|
||||||
|
|
||||||
/* Get the NT header, kernel base and kernel entry */
|
|
||||||
NtHeader = RtlImageNtHeader(LoadBase);
|
|
||||||
KernelBase = NtHeader->OptionalHeader.ImageBase;
|
|
||||||
KernelEntryPoint = (ROS_KERNEL_ENTRY_POINT)(KernelBase + NtHeader->OptionalHeader.AddressOfEntryPoint);
|
|
||||||
LoaderBlock.KernelBase = KernelBase;
|
|
||||||
|
|
||||||
/* Update Processbar and return success */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOLEAN
|
|
||||||
LoadDriver(PCSTR szSourcePath, PCSTR szFileName)
|
|
||||||
{
|
|
||||||
return FrLdrLoadDriver((PCHAR)szFileName, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static BOOLEAN
|
|
||||||
LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName)
|
|
||||||
{
|
|
||||||
CHAR szFullName[256];
|
|
||||||
CHAR szBuffer[80];
|
|
||||||
PFILE FilePointer;
|
|
||||||
PCSTR szShortName;
|
|
||||||
|
|
||||||
if (szSourcePath[0] != '\\')
|
|
||||||
{
|
|
||||||
strcpy(szFullName, "\\");
|
|
||||||
strcat(szFullName, szSourcePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(szFullName, szSourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (szFullName[strlen(szFullName)] != '\\')
|
|
||||||
{
|
|
||||||
strcat(szFullName, "\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (szFileName[0] != '\\')
|
|
||||||
{
|
|
||||||
strcat(szFullName, szFileName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat(szFullName, szFileName + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
szShortName = strrchr(szFileName, '\\');
|
|
||||||
if (szShortName == NULL)
|
|
||||||
szShortName = szFileName;
|
|
||||||
else
|
|
||||||
szShortName = szShortName + 1;
|
|
||||||
|
|
||||||
|
|
||||||
FilePointer = FsOpenFile(szFullName);
|
|
||||||
if (FilePointer == NULL)
|
|
||||||
{
|
|
||||||
printf("Could not find %s\n", szFileName);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Update the status bar with the current file
|
|
||||||
*/
|
|
||||||
sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
|
|
||||||
UiDrawStatusText(szBuffer);
|
|
||||||
|
|
||||||
/* Load the driver */
|
|
||||||
FrLdrLoadModule(FilePointer, szModuleName, NULL);
|
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID RunLoader(VOID)
|
VOID RunLoader(VOID)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
const char *SourcePath;
|
LPCSTR SourcePath;
|
||||||
const char *LoadOptions = "", *DbgLoadOptions = "";
|
LPCSTR LoadOptions, DbgLoadOptions;
|
||||||
const char *sourcePaths[] = {
|
LPCSTR sourcePaths[] = {
|
||||||
"", /* Only for floppy boot */
|
"", /* Only for floppy boot */
|
||||||
#if defined(_M_IX86)
|
#if defined(_M_IX86)
|
||||||
"\\I386",
|
"\\I386",
|
||||||
|
@ -175,11 +58,13 @@ VOID RunLoader(VOID)
|
||||||
#endif
|
#endif
|
||||||
"\\reactos",
|
"\\reactos",
|
||||||
NULL };
|
NULL };
|
||||||
char szKernelName[256];
|
CHAR FileName[256];
|
||||||
|
|
||||||
HINF InfHandle;
|
HINF InfHandle;
|
||||||
ULONG ErrorLine;
|
ULONG ErrorLine;
|
||||||
INFCONTEXT InfContext;
|
INFCONTEXT InfContext;
|
||||||
|
PIMAGE_NT_HEADERS NtHeader;
|
||||||
|
PVOID LoadBase;
|
||||||
|
|
||||||
/* Setup multiboot information structure */
|
/* Setup multiboot information structure */
|
||||||
LoaderBlock.CommandLine = reactos_kernel_cmdline;
|
LoaderBlock.CommandLine = reactos_kernel_cmdline;
|
||||||
|
@ -226,9 +111,6 @@ VOID RunLoader(VOID)
|
||||||
extern BOOLEAN FrLdrBootType;
|
extern BOOLEAN FrLdrBootType;
|
||||||
FrLdrBootType = TRUE;
|
FrLdrBootType = TRUE;
|
||||||
|
|
||||||
/* Initialize registry */
|
|
||||||
RegInitializeRegistry();
|
|
||||||
|
|
||||||
/* Detect hardware */
|
/* Detect hardware */
|
||||||
UiDrawStatusText("Detecting hardware...");
|
UiDrawStatusText("Detecting hardware...");
|
||||||
LoaderBlock.ArchExtra = (ULONG)MachHwDetect();
|
LoaderBlock.ArchExtra = (ULONG)MachHwDetect();
|
||||||
|
@ -244,6 +126,7 @@ VOID RunLoader(VOID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UiDrawStatusText("Loading txtsetup.sif...");
|
||||||
/* Open 'txtsetup.sif' */
|
/* Open 'txtsetup.sif' */
|
||||||
for (i = MachDiskBootingFromFloppy() ? 0 : 1; ; i++)
|
for (i = MachDiskBootingFromFloppy() ? 0 : 1; ; i++)
|
||||||
{
|
{
|
||||||
|
@ -253,9 +136,8 @@ VOID RunLoader(VOID)
|
||||||
printf("Failed to open 'txtsetup.sif'\n");
|
printf("Failed to open 'txtsetup.sif'\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(szKernelName, SourcePath);
|
sprintf(FileName,"%s\\txtsetup.sif", SourcePath);
|
||||||
strcat(szKernelName, "\\txtsetup.sif");
|
if (InfOpenFile (&InfHandle, FileName, &ErrorLine))
|
||||||
if (InfOpenFile (&InfHandle, szKernelName, &ErrorLine))
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!*SourcePath)
|
if (!*SourcePath)
|
||||||
|
@ -294,20 +176,22 @@ VOID RunLoader(VOID)
|
||||||
strcat(strcat(strcat(strcat(reactos_kernel_cmdline, SourcePath), " "),
|
strcat(strcat(strcat(strcat(reactos_kernel_cmdline, SourcePath), " "),
|
||||||
LoadOptions), DbgLoadOptions);
|
LoadOptions), DbgLoadOptions);
|
||||||
|
|
||||||
strcpy(SystemRoot, SourcePath);
|
|
||||||
strcat(SystemRoot, "\\");
|
|
||||||
|
|
||||||
/* Setup the boot path and kernel path */
|
/* Setup the boot path and kernel path */
|
||||||
strcpy(szBootPath, SourcePath);
|
strcpy(szBootPath, SourcePath);
|
||||||
strcpy(szKernelName, szBootPath);
|
|
||||||
strcat(szKernelName, "\\ntoskrnl.exe");
|
|
||||||
|
|
||||||
/* Setup the HAL path */
|
sprintf(SystemRoot,"%s\\", SourcePath);
|
||||||
strcpy(szHalName, szBootPath);
|
sprintf(FileName,"%s\\ntoskrnl.exe", SourcePath);
|
||||||
strcat(szHalName, "\\hal.dll");
|
sprintf(szHalName,"%s\\hal.dll", SourcePath);
|
||||||
|
|
||||||
/* Load the kernel */
|
/* Load the kernel */
|
||||||
if (!FrLdrLoadKernel(szKernelName, 5)) return;
|
LoadBase = FrLdrLoadImage(FileName, 5, 1);
|
||||||
|
if (!LoadBase) return;
|
||||||
|
|
||||||
|
/* Get the NT header, kernel base and kernel entry */
|
||||||
|
NtHeader = RtlImageNtHeader(LoadBase);
|
||||||
|
KernelBase = SWAPD(NtHeader->OptionalHeader.ImageBase);
|
||||||
|
KernelEntryPoint = (ROS_KERNEL_ENTRY_POINT)(KernelBase + SWAPD(NtHeader->OptionalHeader.AddressOfEntryPoint));
|
||||||
|
LoaderBlock.KernelBase = KernelBase;
|
||||||
|
|
||||||
/* Insert boot disk 2 */
|
/* Insert boot disk 2 */
|
||||||
if (MachDiskBootingFromFloppy())
|
if (MachDiskBootingFromFloppy())
|
||||||
|
@ -343,8 +227,9 @@ VOID RunLoader(VOID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(FileName,"%s\\%s", SourcePath,LoadOptions);
|
||||||
/* Load ANSI codepage file */
|
/* Load ANSI codepage file */
|
||||||
if (!LoadNlsFile(SourcePath, LoadOptions, "ansi.nls"))
|
if (!FrLdrLoadNlsFile(FileName, "ansi.nls"))
|
||||||
{
|
{
|
||||||
UiMessageBox("Failed to load the ANSI codepage file.");
|
UiMessageBox("Failed to load the ANSI codepage file.");
|
||||||
return;
|
return;
|
||||||
|
@ -368,8 +253,9 @@ VOID RunLoader(VOID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(FileName,"%s\\%s", SourcePath,LoadOptions);
|
||||||
/* Load OEM codepage file */
|
/* Load OEM codepage file */
|
||||||
if (!LoadNlsFile(SourcePath, LoadOptions, "oem.nls"))
|
if (!FrLdrLoadNlsFile(FileName, "oem.nls"))
|
||||||
{
|
{
|
||||||
UiMessageBox("Failed to load the OEM codepage file.");
|
UiMessageBox("Failed to load the OEM codepage file.");
|
||||||
return;
|
return;
|
||||||
|
@ -393,21 +279,14 @@ VOID RunLoader(VOID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(FileName,"%s\\%s", SourcePath,LoadOptions);
|
||||||
/* Load Unicode casemap file */
|
/* Load Unicode casemap file */
|
||||||
if (!LoadNlsFile(SourcePath, LoadOptions, "casemap.nls"))
|
if (!FrLdrLoadNlsFile(FileName, "casemap.nls"))
|
||||||
{
|
{
|
||||||
UiMessageBox("Failed to load the Unicode casemap file.");
|
UiMessageBox("Failed to load the Unicode casemap file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load fastfat.sys (could be loaded by the setup prog!) */
|
|
||||||
if (!LoadDriver(SourcePath, "fastfat.sys"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Load ext2.sys (could be loaded by the setup prog!) */
|
|
||||||
if (!LoadDriver(SourcePath, "ext2.sys"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Load additional files specified in txtsetup.inf */
|
/* Load additional files specified in txtsetup.inf */
|
||||||
if (InfFindFirstLine(InfHandle,
|
if (InfFindFirstLine(InfHandle,
|
||||||
"SourceDisksFiles",
|
"SourceDisksFiles",
|
||||||
|
@ -422,7 +301,7 @@ VOID RunLoader(VOID)
|
||||||
{
|
{
|
||||||
if (strcmp(Media, "x") == 0)
|
if (strcmp(Media, "x") == 0)
|
||||||
{
|
{
|
||||||
if (!LoadDriver(SourcePath, DriverName))
|
if (!FrLdrLoadDriver((PCHAR)DriverName,0))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue