Use ARC-Path to boot ReactOS

svn path=/trunk/; revision=1952
This commit is contained in:
Eric Kohl 2001-06-08 17:46:52 +00:00
parent 18b431ed17
commit 4c1911c2ca
6 changed files with 237 additions and 68 deletions

View file

@ -60,6 +60,9 @@
# [ReactOS OSType] Section Commands: # [ReactOS OSType] Section Commands:
# #
# SystemPath - sets the system root path (must be a valid ARC - Path):
# multi(0)disk(0)rdisk(0)partition(1)\reactos
# multi(0)disk(0)fdisk(0)
# Options - sets the command line options for the kernel being booted # Options - sets the command line options for the kernel being booted
# Kernel - sets the kernel filename # Kernel - sets the kernel filename
# Driver - sets the name of one or more drivers to be loaded (one entry per driver) # Driver - sets the name of one or more drivers to be loaded (one entry per driver)
@ -86,7 +89,8 @@ MenuColor=Blue
TextColor=Yellow TextColor=Yellow
SelectedTextColor=Black SelectedTextColor=Black
SelectedColor=Gray SelectedColor=Gray
#OS=ReactOS OS=ReactOS (HD)
OS=ReactOS (Floppy)
#OS=ReactOS (Debug) #OS=ReactOS (Debug)
#OS=Linux #OS=Linux
OS=3« Floppy (A:) OS=3« Floppy (A:)
@ -94,13 +98,24 @@ OS=Microsoft Windows (C:)
OS=Drive D: OS=Drive D:
#TimeOut=0 #TimeOut=0
#[ReactOS] # Load ReactOS from harddisk (drive C:)
#BootType=ReactOS # - does not work on large harddisks
#BootDrive=0 [ReactOS (HD)]
#Options=/DEBUGPORT=SCREEN BootType=ReactOS
#Kernel=\NTOSKRNL.EXE SystemPath=multi(0)disk(0)rdisk(0)partition(1)\reactos
#Driver=\DRIVERS\IDE.SYS Options=/DEBUGPORT=SCREEN
#Driver=\DRIVERS\VFATFS.SYS Kernel=NTOSKRNL.EXE
Driver=IDE.SYS
Driver=VFATFS.SYS
# Load ReactOS from floppy (drive A:)
[ReactOS (Floppy)]
BootType=ReactOS
SystemPath=multi(0)disk(0)fdisk(0)
Options=/DEBUGPORT=SCREEN
Kernel=NTOSKRNL.EXE
Driver=IDE.SYS
Driver=VFATFS.SYS
#[ReactOS (Debug)] #[ReactOS (Debug)]
#BootType=ReactOS #BootType=ReactOS

View file

@ -26,6 +26,11 @@
#include "tui.h" #include "tui.h"
#include "multiboot.h" #include "multiboot.h"
static BOOL
DissectArcPath(char *ArcPath, char *BootPath, unsigned int *BootDrive, unsigned int *BootPartition);
unsigned long next_module_load_base = 0; unsigned long next_module_load_base = 0;
void LoadAndBootReactOS(char *OperatingSystemName) void LoadAndBootReactOS(char *OperatingSystemName)
@ -34,9 +39,11 @@ void LoadAndBootReactOS(char *OperatingSystemName)
char name[1024]; char name[1024];
char value[1024]; char value[1024];
char szFileName[1024]; char szFileName[1024];
char szBootPath[256];
int i; int i;
int nNumDriverFiles=0; int nNumDriverFiles=0;
int nNumFilesLoaded=0; int nNumFilesLoaded=0;
char MsgBuffer[256];
/* /*
* Setup multiboot information structure * Setup multiboot information structure
@ -51,10 +58,47 @@ void LoadAndBootReactOS(char *OperatingSystemName)
mb_info.mmap_length = 0; mb_info.mmap_length = 0;
mb_info.mmap_addr = 0; mb_info.mmap_addr = 0;
/*
* Make sure the system path is set in the .ini file
*/
if(!ReadSectionSettingByName(OperatingSystemName, "SystemPath", name, value))
{
MessageBox("System path not specified for selected operating system.");
return;
}
/*
* Verify system path
*/
if(!DissectArcPath(value, szBootPath, &BootDrive, &BootPartition))
{
sprintf(MsgBuffer,"Invalid system path: '%s'", value);
MessageBox(MsgBuffer);
return;
}
/* set boot drive and partition */
((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
/* copy ARC path into kernel command line */
strcpy(multiboot_kernel_cmdline, value);
/* /*
* Read the optional kernel parameters (if any) * Read the optional kernel parameters (if any)
*/ */
ReadSectionSettingByName(OperatingSystemName, "Options", name, multiboot_kernel_cmdline); if (ReadSectionSettingByName(OperatingSystemName, "Options", name, value))
{
strcat(multiboot_kernel_cmdline, " ");
strcat(multiboot_kernel_cmdline, value);
}
/* append a backslash */
if ((strlen(szBootPath)==0) ||
szBootPath[strlen(szBootPath)] != '\\')
strcat(szBootPath, "\\");
/* /*
* Find the kernel image name * Find the kernel image name
@ -65,24 +109,6 @@ void LoadAndBootReactOS(char *OperatingSystemName)
return; return;
} }
/*
* Get the boot partition
*/
BootPartition = 0;
if (ReadSectionSettingByName(OperatingSystemName, "BootPartition", name, value))
{
BootPartition = atoi(value);
}
((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
/*
* Make sure the boot drive is set in the .ini file
*/
if(!ReadSectionSettingByName(OperatingSystemName, "BootDrive", name, value))
{
MessageBox("Boot drive not specified for selected operating system.");
return;
}
DrawBackdrop(); DrawBackdrop();
@ -90,10 +116,8 @@ void LoadAndBootReactOS(char *OperatingSystemName)
DrawProgressBar(0); DrawProgressBar(0);
/* /*
* Set the boot drive and try to open it * Try to open boot drive
*/ */
BootDrive = atoi(value);
((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
if (!OpenDiskDrive(BootDrive, BootPartition)) if (!OpenDiskDrive(BootDrive, BootPartition))
{ {
MessageBox("Failed to open boot drive."); MessageBox("Failed to open boot drive.");
@ -122,7 +146,8 @@ void LoadAndBootReactOS(char *OperatingSystemName)
/* /*
* Set the name and try to open the PE image * Set the name and try to open the PE image
*/ */
strcpy(szFileName, value); strcpy(szFileName, szBootPath);
strcat(szFileName, value);
if (!OpenFile(szFileName, &file)) if (!OpenFile(szFileName, &file))
{ {
strcat(value, " not found."); strcat(value, " not found.");
@ -337,3 +362,55 @@ BOOL MultiBootLoadModule(FILE *ModuleImage, char *ModuleName)
return TRUE; return TRUE;
} }
static BOOL
DissectArcPath(char *ArcPath, char *BootPath, unsigned int *BootDrive, unsigned int *BootPartition)
{
char *p;
if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
return FALSE;
p = ArcPath + 15;
if (_strnicmp(p, "fdisk(", 6) == 0)
{
/*
* floppy disk path:
* multi(0)disk(0)fdisk(x)\path
*/
p = p + 6;
*BootDrive = atoi(p);
p = strchr(p, ')');
if (p == NULL)
return FALSE;
p++;
*BootPartition = 0;
}
else if (_strnicmp(p, "rdisk(", 6) == 0)
{
/*
* hard disk path:
* multi(0)disk(0)rdisk(x)partition(y)\path
*/
p = p + 6;
*BootDrive = atoi(p) + 0x80;
p = strchr(p, ')');
if ((p == NULL) || (_strnicmp(p, ")partition(", 11) != 0))
return FALSE;
p = p + 11;
*BootPartition = atoi(p);
p = strchr(p, ')');
if ((p == NULL) || (*BootPartition == 0))
return FALSE;
p++;
}
else
{
return FALSE;
}
strcpy(BootPath, p);
return TRUE;
}

View file

@ -117,6 +117,56 @@ void printf(char *format, ... )
} }
} }
void sprintf(char *buffer, char *format, ... )
{
int *dataptr = (int *) &format;
char c, *ptr, str[16];
char *p = buffer;
dataptr++;
while ((c = *(format++)))
{
if (c != '%')
{
*p = c;
p++;
}
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
while (*ptr)
{
*p = *(ptr++);
p++;
}
break;
case 'c':
*p = (*(dataptr++))&0xff;
p++;
break;
case 's':
ptr = (char *)(*(dataptr++));
while ((c = *(ptr++)))
{
*p = c;
p++;
}
break;
}
}
*p=0;
}
int strlen(char *str) int strlen(char *str)
{ {
int len; int len;
@ -217,6 +267,20 @@ char *strcat(char *dest, char *src)
return ret; return ret;
} }
char *strchr(const char *s, int c)
{
char cc = c;
while (*s)
{
if (*s == cc)
return (char *)s;
s++;
}
if (cc == 0)
return (char *)s;
return 0;
}
int strcmp(const char *string1, const char *string2) int strcmp(const char *string1, const char *string2)
{ {
while(*string1 == *string2) while(*string1 == *string2)
@ -245,6 +309,21 @@ int stricmp(const char *string1, const char *string2)
return (int)tolower(*string1) - (int)tolower(*string2); return (int)tolower(*string1) - (int)tolower(*string2);
} }
int _strnicmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (toupper(*string1) != toupper(*string2++))
return toupper(*(unsigned const char *)string1) - toupper(*(unsigned const char *)--string2);
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}
char *fgets(char *string, int n, FILE *stream) char *fgets(char *string, int n, FILE *stream)
{ {
int i; int i;
@ -272,7 +351,6 @@ char *fgets(char *string, int n, FILE *stream)
int atoi(char *string) int atoi(char *string)
{ {
int i, j;
int base; int base;
int result = 0; int result = 0;
char *str; char *str;
@ -288,18 +366,14 @@ int atoi(char *string)
str = string; str = string;
} }
for(i=strlen(str)-1,j=1; i>=0; i--) while(1)
{ {
if((str[i] < '0') || (str[i] > '9')) if((*str < '0') || (*str > '9'))
break; break;
if(i == (strlen(str)-1)) result *= base;
result += (str[i] - '0'); result += (*str - '0');
else str++;
{
result += (str[i] - '0') * (j * base);
j *= base;
}
} }
return result; return result;

View file

@ -41,8 +41,10 @@ int wherey(void); // Implemented in asmcode.S
int strlen(char *str); int strlen(char *str);
char *strcpy(char *dest, char *src); char *strcpy(char *dest, char *src);
char *strcat(char *dest, char *src); char *strcat(char *dest, char *src);
char *strchr(const char *s, int c);
int strcmp(const char *string1, const char *string2); int strcmp(const char *string1, const char *string2);
int stricmp(const char *string1, const char *string2); int stricmp(const char *string1, const char *string2);
int _strnicmp(const char *string1, const char *string2, size_t length);
char *itoa(int value, char *string, int radix); char *itoa(int value, char *string, int radix);
int toupper(int c); int toupper(int c);
int tolower(int c); int tolower(int c);
@ -55,6 +57,7 @@ int atoi(char *string);
void print(char *str); void print(char *str);
void printf(char *fmt, ...); void printf(char *fmt, ...);
void sprintf(char *buffer, char *format, ...);
int biosdisk(int cmd, int drive, int head, int track, int sector, int nsects, void *buffer); // Implemented in asmcode.S int biosdisk(int cmd, int drive, int head, int track, int sector, int nsects, void *buffer); // Implemented in asmcode.S
void stop_floppy(void); // Implemented in asmcode.S void stop_floppy(void); // Implemented in asmcode.S

View file

@ -1,5 +1,5 @@
cd bootsect cd bootsect
call install.bat call install.bat
cd.. cd..
copy freeldr.sys a:\ copy freeldr.sys a:\FREELDR.SYS
copy freeldr.ini a:\ copy freeldr.ini a:\FREELDR.INI