4 * Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <multiboot.h>
34 BOOL IsSetupLdr
= TRUE
;
37 LoadKernel(PCHAR szFileName
)
42 szShortName
= strrchr(szFileName
, '\\');
43 if (szShortName
== NULL
)
44 szShortName
= szFileName
;
46 szShortName
= szShortName
+ 1;
48 FilePointer
= FsOpenFile(szFileName
);
49 if (FilePointer
== NULL
)
51 printf("Could not find %s\n", szShortName
);
56 * Update the status bar with the current file
58 printf("Reading %s\n", szShortName
);
63 MultiBootLoadKernel(FilePointer
);
70 LoadDriver(PCHAR szFileName
)
75 szShortName
= strrchr(szFileName
, '\\');
76 if (szShortName
== NULL
)
77 szShortName
= szFileName
;
79 szShortName
= szShortName
+ 1;
82 FilePointer
= FsOpenFile(szFileName
);
83 if (FilePointer
== NULL
)
85 printf("Could not find %s\n", szFileName
);
90 * Update the status bar with the current file
92 printf("Reading %s\n", szShortName
);
95 MultiBootLoadModule(FilePointer
, szFileName
, NULL
);
104 /* Setup multiboot information structure */
105 mb_info
.flags
= MB_INFO_FLAG_MEM_SIZE
| MB_INFO_FLAG_BOOT_DEVICE
| MB_INFO_FLAG_COMMAND_LINE
| MB_INFO_FLAG_MODULES
;
106 mb_info
.mem_lower
= GetConventionalMemorySize();
107 mb_info
.mem_upper
= GetExtendedMemorySize();
108 mb_info
.boot_device
= 0xffffffff;
109 mb_info
.cmdline
= (unsigned long)multiboot_kernel_cmdline
;
110 mb_info
.mods_count
= 0;
111 mb_info
.mods_addr
= (unsigned long)multiboot_modules
;
112 mb_info
.mmap_length
= (unsigned long)GetBiosMemoryMap((PBIOS_MEMORY_MAP
)&multiboot_memory_map
) * sizeof(memory_map_t
);
113 if (mb_info
.mmap_length
)
115 mb_info
.mmap_addr
= (unsigned long)&multiboot_memory_map
;
116 mb_info
.flags
|= MB_INFO_FLAG_MEMORY_MAP
;
117 multiboot_memory_map_descriptor_size
= sizeof(memory_map_t
); // GetBiosMemoryMap uses a fixed value of 24
121 printf("memory map length: %d\n", mb_info
.mmap_length
);
122 printf("dumping memory map:\n");
123 for (i
=0; i
<(mb_info
.mmap_length
/ sizeof(memory_map_t
)); i
++)
125 printf("start: %x\t size: %x\t type %d\n",
126 multiboot_memory_map
[i
].base_addr_low
,
127 multiboot_memory_map
[i
].length_low
,
128 multiboot_memory_map
[i
].type
);
135 printf("low_mem = %d\n", mb_info
.mem_lower
);
136 printf("high_mem = %d\n", mb_info
.mem_upper
);
140 /* Initialize registry */
141 RegInitializeRegistry();
143 /* Detect hardware */
144 printf("Detecting hardware...\n\n");
147 /* set boot drive and partition */
148 ((char *)(&mb_info
.boot_device
))[0] = (char)BootDrive
;
149 ((char *)(&mb_info
.boot_device
))[1] = (char)BootPartition
;
151 /* Copy ARC path into kernel command line */
152 sprintf(multiboot_kernel_cmdline
,
153 "multi(0)disk(0)cdrom(%u)\\reactos /DEBUGPORT=COM1",
154 (unsigned int)BootDrive
);
156 /* Open boot drive */
157 if (!FsOpenVolume(BootDrive
, BootPartition
))
159 printf("Failed to open boot drive.");
163 /* Load ntoskrnl.exe */
164 if (!LoadKernel("\\reactos\\ntoskrnl.exe"))
169 if (!LoadDriver("\\reactos\\hal.dll"))
173 /* Export the system and hardware hives */
174 // Base = MultiBootCreateModule(SYSTEM.HIV);
175 // RegExportHive("\\Registry\\Machine\\SYSTEM", Base, &Size);
176 // MultiBootCloseModule(Base, Size);
178 // Base = MultiBootCreateModule(HARDWARE.HIV);
179 // RegExportHive("\\Registry\\Machine\\HARDWARE", Base, &Size);
180 // MultiBootCloseModule(Base, Size);
187 if (!LoadNlsFiles(szBootPath
))
189 MessageBox("Failed to load NLS files\n");
198 if (!LoadDriver("\\reactos\\scsiport.sys"))
202 * Load atapi.sys (depends on hardware detection)
204 if (!LoadDriver("\\reactos\\atapi.sys"))
210 if (!LoadDriver("\\reactos\\class2.sys"))
216 if (!LoadDriver("\\reactos\\cdrom.sys"))
222 if (!LoadDriver("\\reactos\\cdfs.sys"))
226 * Load floppy.sys (only in case of a floppy disk setup!)
228 // if (!LoadDriver("\\reactos\\floppy.sys"))
234 if (!LoadDriver("\\reactos\\disk.sys"))
238 * Load vfatfs.sys (could be loaded by the setup prog!)
240 if (!LoadDriver("\\reactos\\vfatfs.sys"))
244 * Load keyboard driver
246 if (!LoadDriver("\\reactos\\keyboard.sys"))
252 if (!LoadDriver("\\reactos\\blue.sys"))
256 * Now boot the kernel
258 DiskStopFloppyMotor();
262 // printf("*** System stopped ***\n");