- Protect multiboot info from being overwritten - Pass command line to MachInit() funcs
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/arch.S Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/archmach.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.h Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h Modified: trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c Modified: trunk/reactos/boot/freeldr/freeldr/freeldr.c Modified: trunk/reactos/boot/freeldr/freeldr/include/machine.h
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/arch.S 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/arch.S 2005-04-21 09:29:02 UTC (rev 14725) @@ -275,9 +275,11 @@
* other boot loaders like Grub */
+#define MB_INFO_SIZE 90
#define MB_INFO_FLAGS_OFFSET 0 #define MB_INFO_BOOT_DEVICE_OFFSET 12 #define MB_INFO_COMMAND_LINE_OFFSET 16
+#define CMDLINE_SIZE 256
/* * We want to execute at 0x8000 (to be compatible with bootsector @@ -285,7 +287,6 @@
* above 1MB. So we let Grub load us there and then relocate * ourself to 0x8000 */
-#define CMDLINE_BASE 0x7000
#define FREELDR_BASE 0x8000 #define INITIAL_BASE 0x200000 @@ -328,6 +329,31 @@
movw %dx,%ds movw %dx,%es
+ /* Check for valid multiboot signature */ + cmpl $MULTIBOOT_BOOTLOADER_MAGIC,%eax + jne mbfail + + /* Store multiboot info in a safe place */ + movl %ebx,%esi + movl $(mb_info + INITIAL_BASE - FREELDR_BASE),%edi + movl $MB_INFO_SIZE,%ecx + rep movsb + + /* Save commandline */ + movl MB_INFO_FLAGS_OFFSET(%ebx),%edx + testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx) + jz mb3 + movl MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi + movl $(cmdline + INITIAL_BASE - FREELDR_BASE),%edi + movl $CMDLINE_SIZE,%ecx +mb2: lodsb + stosb + testb %al,%al + jz mb3 + dec %ecx + jnz mb2 +mb3: +
/* Copy to low mem */ movl $INITIAL_BASE,%esi movl $FREELDR_BASE,%edi @@ -342,8 +368,8 @@
/* Clear prefetch queue & correct CS, * jump to low mem */
- ljmp $PMODE_CS, $mb2 -mb2:
+ ljmp $PMODE_CS, $mb4 +mb4:
/* Reload segment selectors */ movw $PMODE_DS,%dx movw %dx,%ds @@ -353,39 +379,28 @@
movw %dx,%ss movl $STACK32ADDR,%esp
- /* Check for valid multiboot signature */ - cmpl $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne mbfail -
+ movl $mb_info,%ebx
/* See if the boot device was passed in */ movl MB_INFO_FLAGS_OFFSET(%ebx),%edx testl $MB_INFO_FLAG_BOOT_DEVICE,%edx
- jz mb3
+ jz mb5
/* Retrieve boot device info */ movl MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax shrl $16,%eax incb %al movb %al,_i386BootPartition movb %ah,_i386BootDrive
- jmp mb4 -mb3: /* No boot device known, assume first partition of first harddisk */
+ jmp mb6 +mb5: /* No boot device known, assume first partition of first harddisk */
movb $0x80,_i386BootDrive movb $1,_i386BootPartition
-mb4: - - /* Check for a command line */
+mb6: + /* Check for command line */ + mov $cmdline,%eax + testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx) + jnz mb7
xorl %eax,%eax
- testl $MB_INFO_FLAG_COMMAND_LINE,%edx
- jz mb6
- /* Copy command line to low mem*/
- movl MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi
- movl $CMDLINE_BASE,%edi
-mb5: lodsb
- stosb
- testb %al,%al
- jnz mb5
- movl $CMDLINE_BASE,%eax
-mb6:
+mb7:
/* GO! */ pushl %eax @@ -467,3 +482,10 @@
EXTERN(_i386BootPartition) .long 0
+ +.bss +mb_info: + .fill MB_INFO_SIZE, 1, 0 + +cmdline: + .fill CMDLINE_SIZE, 1, 0
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/archmach.c 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/archmach.c 2005-04-21 09:29:02 UTC (rev 14725) @@ -27,7 +27,7 @@
#include "rtl.h" VOID
-MachInit(VOID)
+MachInit(char *CmdLine)
{ ULONG PciId; @@ -39,11 +39,11 @@
PciId = READ_PORT_ULONG((ULONG*) 0xcfc); if (0x02a510de == PciId) {
- XboxMachInit();
+ XboxMachInit(CmdLine);
} else {
- PcMachInit();
+ PcMachInit(CmdLine);
} HalpCalibrateStallExecution();
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c 2005-04-21 09:29:02 UTC (rev 14725) @@ -26,7 +26,7 @@
#include "i386.h" VOID
-PcMachInit(VOID)
+PcMachInit(char *CmdLine)
{ EnableA20();
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.h 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.h 2005-04-21 09:29:02 UTC (rev 14725) @@ -26,7 +26,7 @@
#include "mm.h" #endif
-VOID PcMachInit(VOID);
+VOID PcMachInit(char *CmdLine);
VOID PcConsPutChar(int Ch); BOOL PcConsKbHit();
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c 2005-04-21 09:29:02 UTC (rev 14725) @@ -24,7 +24,7 @@
#include "i386.h" VOID
-XboxMachInit(VOID)
+XboxMachInit(char *CmdLine)
{ /* Initialize our stuff */ XboxMemInit();
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h 2005-04-21 09:29:02 UTC (rev 14725) @@ -26,7 +26,7 @@
UCHAR XboxFont8x16[256 * 16];
-VOID XboxMachInit(VOID);
+VOID XboxMachInit(char *CmdLine);
VOID XboxConsPutChar(int Ch); BOOL XboxConsKbHit();
--- trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c 2005-04-21 09:29:02 UTC (rev 14725) @@ -279,7 +279,7 @@
BootMain("freeldr-ppc"); }
-void MachInit() {
+void MachInit(char *CmdLine) {
int len; printf( "Determining boot device:\n" ); len = ofw_getprop(chosen_package, "bootpath",
--- trunk/reactos/boot/freeldr/freeldr/freeldr.c 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/freeldr.c 2005-04-21 09:29:02 UTC (rev 14725) @@ -31,7 +31,7 @@
{ CmdLineParse(CmdLine);
- MachInit();
+ MachInit(CmdLine);
DebugInit();
--- trunk/reactos/boot/freeldr/freeldr/include/machine.h 2005-04-20 22:05:23 UTC (rev 14724) +++ trunk/reactos/boot/freeldr/freeldr/include/machine.h 2005-04-21 09:29:02 UTC (rev 14725) @@ -71,7 +71,7 @@
VOID (*HwDetect)(VOID); } MACHVTBL, *PMACHVTBL;
-VOID MachInit(VOID);
+VOID MachInit(char *CmdLine);
extern MACHVTBL MachVtbl;