# [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
# Kernel - sets the kernel filename
# Driver - sets the name of one or more drivers to be loaded (one entry per driver)
TextColor=Yellow
SelectedTextColor=Black
SelectedColor=Gray
-#OS=ReactOS
+OS=ReactOS (HD)
+OS=ReactOS (Floppy)
#OS=ReactOS (Debug)
#OS=Linux
OS=3« Floppy (A:)
OS=Drive D:
#TimeOut=0
-#[ReactOS]
-#BootType=ReactOS
-#BootDrive=0
-#Options=/DEBUGPORT=SCREEN
-#Kernel=\NTOSKRNL.EXE
-#Driver=\DRIVERS\IDE.SYS
-#Driver=\DRIVERS\VFATFS.SYS
+# Load ReactOS from harddisk (drive C:)
+# - does not work on large harddisks
+[ReactOS (HD)]
+BootType=ReactOS
+SystemPath=multi(0)disk(0)rdisk(0)partition(1)\reactos
+Options=/DEBUGPORT=SCREEN
+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)]
#BootType=ReactOS
#endif /* ! ASM */
-multiboot_header_t mb_header; // Multiboot header structure defined in kernel image file
-multiboot_info_t mb_info; // Multiboot info structure passed to kernel
-char multiboot_kernel_cmdline[255]; // Command line passed to kernel
-module_t multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
-char multiboot_module_strings[64][256]; // Array to hold module names
+multiboot_header_t mb_header; // Multiboot header structure defined in kernel image file
+multiboot_info_t mb_info; // Multiboot info structure passed to kernel
+char multiboot_kernel_cmdline[255]; // Command line passed to kernel
+module_t multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
+char multiboot_module_strings[64][256]; // Array to hold module names
#endif // defined __MULTIBOOT_H
\ No newline at end of file
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include "freeldr.h"
#include "asmcode.h"
#include "rosboot.h"
#include "tui.h"
#include "multiboot.h"
+
+static BOOL
+DissectArcPath(char *ArcPath, char *BootPath, unsigned int *BootDrive, unsigned int *BootPartition);
+
+
unsigned long next_module_load_base = 0;
void LoadAndBootReactOS(char *OperatingSystemName)
{
- FILE file;
- char name[1024];
- char value[1024];
- char szFileName[1024];
+ FILE file;
+ char name[1024];
+ char value[1024];
+ char szFileName[1024];
+ char szBootPath[256];
int i;
int nNumDriverFiles=0;
int nNumFilesLoaded=0;
+ char MsgBuffer[256];
/*
* Setup multiboot information structure
mb_info.mmap_length = 0;
mb_info.mmap_addr = 0;
+
/*
- * Read the optional kernel parameters (if any)
+ * Make sure the system path is set in the .ini file
*/
- ReadSectionSettingByName(OperatingSystemName, "Options", name, multiboot_kernel_cmdline);
+ if(!ReadSectionSettingByName(OperatingSystemName, "SystemPath", name, value))
+ {
+ MessageBox("System path not specified for selected operating system.");
+ return;
+ }
/*
- * Find the kernel image name
+ * Verify system path
*/
- if(!ReadSectionSettingByName(OperatingSystemName, "Kernel", name, value))
+ if(!DissectArcPath(value, szBootPath, &BootDrive, &BootPartition))
{
- MessageBox("Kernel image file not specified for selected operating system.");
+ 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);
+
/*
- * Get the boot partition
+ * Read the optional kernel parameters (if any)
*/
- BootPartition = 0;
- if (ReadSectionSettingByName(OperatingSystemName, "BootPartition", name, value))
+ if (ReadSectionSettingByName(OperatingSystemName, "Options", name, value))
{
- BootPartition = atoi(value);
+ strcat(multiboot_kernel_cmdline, " ");
+ strcat(multiboot_kernel_cmdline, value);
}
- ((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
-
+
+ /* append a backslash */
+ if ((strlen(szBootPath)==0) ||
+ szBootPath[strlen(szBootPath)] != '\\')
+ strcat(szBootPath, "\\");
+
/*
- * Make sure the boot drive is set in the .ini file
+ * Find the kernel image name
*/
- if(!ReadSectionSettingByName(OperatingSystemName, "BootDrive", name, value))
+ if(!ReadSectionSettingByName(OperatingSystemName, "Kernel", name, value))
{
- MessageBox("Boot drive not specified for selected operating system.");
+ MessageBox("Kernel image file not specified for selected operating system.");
return;
}
+
DrawBackdrop();
DrawStatusText(" Loading...");
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))
{
MessageBox("Failed to open boot drive.");
/*
* Set the name and try to open the PE image
*/
- strcpy(szFileName, value);
+ strcpy(szFileName, szBootPath);
+ strcat(szFileName, value);
if (!OpenFile(szFileName, &file))
{
strcat(value, " not found.");
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;
+}
}
}
}
-
+
+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 len;
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)
{
while(*string1 == *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)
{
int i;
int atoi(char *string)
{
- int i, j;
- int base;
- int result = 0;
+ int base;
+ int result = 0;
char *str;
if((string[0] == '0') && (string[1] == 'x'))
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;
- if(i == (strlen(str)-1))
- result += (str[i] - '0');
- else
- {
- result += (str[i] - '0') * (j * base);
- j *= base;
- }
+ result *= base;
+ result += (*str - '0');
+ str++;
}
return result;
int wherex(void); // Implemented in asmcode.S
int wherey(void); // Implemented in asmcode.S
-int strlen(char *str);
+int strlen(char *str);
char *strcpy(char *dest, char *src);
char *strcat(char *dest, char *src);
-int strcmp(const char *string1, const char *string2);
-int stricmp(const char *string1, const char *string2);
+char *strchr(const char *s, int c);
+int strcmp(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);
-int toupper(int c);
-int tolower(int c);
-int memcmp(const void *buf1, const void *buf2, size_t count);
+int toupper(int c);
+int tolower(int c);
+int memcmp(const void *buf1, const void *buf2, size_t count);
void *memcpy(void *dest, const void *src, size_t count);
void *memset(void *dest, int c, size_t count);
char *fgets(char *string, int n, FILE *stream);
-int atoi(char *string);
+int atoi(char *string);
void print(char *str);
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
-void stop_floppy(void); // Implemented in asmcode.S
-int get_heads(int drive); // Implemented in asmcode.S
-int get_cylinders(int drive); // Implemented in asmcode.S
-int get_sectors(int drive); // 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
+int get_heads(int drive); // Implemented in asmcode.S
+int get_cylinders(int drive); // Implemented in asmcode.S
+int get_sectors(int drive); // Implemented in asmcode.S
/* Values for biosdisk() */
#define _DISK_RESET 0 // Unimplemented
cd bootsect
call install.bat
cd..
-copy freeldr.sys a:\
-copy freeldr.ini a:\
\ No newline at end of file
+copy freeldr.sys a:\FREELDR.SYS
+copy freeldr.ini a:\FREELDR.INI
\ No newline at end of file