[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] memdisk plus lnxboot extension
From: |
Bean |
Subject: |
Re: [PATCH] memdisk plus lnxboot extension |
Date: |
Thu, 24 Jan 2008 03:01:33 +0800 |
On Jan 24, 2008 12:18 AM, Bean <address@hidden> wrote:
> On Jan 23, 2008 4:54 PM, Marco Gerards <address@hidden> wrote:
> > When is this feature useful? Can you give an example? More features
> > can mean more bugs, more maintainance work, etc. If the feature is
> > not worthwhile for more than one person, I am not sure if it should be
> > included. Perhaps a better explaination of the problem to solve,
> > instead of what the patch does might help here.
>
> the most important usage of external initrd is to overcome the size
> limit of core.img.
this is the new patch, now no need to modify grub-mkimage, use cat
just as before.
* boot/i386/pc/lnxboot.S (data_start) : Simplify code.
(real_code_2) : Set grub_memdisk_image_addr using initrd address.
* include/grub/i386/pc/kernel.h : New constant
GRUB_KENRL_MACHINE_MEMDISK_IMAGE_ADDR.
New variable grub_memdisk_image_addr.
* kern/i386/pc/init.c (grub_arch_memdisk_addr) : Use
grub_memdisk_image_addr if it isn't zero.
* kern/i386/pc/startup.S : New variable grub_memdisk_image_addr.
diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S
index f1a4ded..25554d7 100644
--- a/boot/i386/pc/lnxboot.S
+++ b/boot/i386/pc/lnxboot.S
@@ -36,22 +36,7 @@
.globl start, _start
data_start:
- pushw %cs
- popw %ds
- xorl %eax, %eax
- xorl %ebx, %ebx
- call data_next
-
-data_next:
- popw %bx
- movw %cs, %ax
- shll $4, %eax
- leal 0x200 + data_start - data_next(%ebx,%eax), %eax
- movzbl setup_sects - data_next(%bx), %ecx
- shll $9, %ecx
- addl %ecx, %eax
- movl %eax, code32_start - data_next(%bx)
-
+ xorl %ebp, %ebp
jmp linux_next
. = data_start + 0x1F1
@@ -76,7 +61,7 @@ boot_flag:
start:
_start:
- jmp linux_code
+ jmp linux_init
.ascii "HdrS" // Header signature
.word 0x0203 // Header version number
@@ -134,9 +119,10 @@ reg_edx:
data_leng:
.long 0
-linux_code:
+linux_init:
movw %cs:(reg_edx - start), %dx
+ movl %cs:(code32_start - start), %ebp
linux_next:
@@ -164,9 +150,6 @@ real_code:
movw %si, %ss
movw $(CODE_ADDR), %sp
- pushl %esi
- pushl %edi
-
// Move itself to 0:CODE_ADDR
cld
@@ -183,34 +166,53 @@ real_code:
real_code_2:
- pushw %es
- popw %ds
-
- movl (ramdisk_image - start), %esi
- or %esi, %esi
+ xchgl %ebp, %esi
+ orl %esi, %esi
jnz 1f
- movl (code32_start - start), %esi
+ movw %ds, %si
+ shll $4, %esi
+ addl %ebp, %esi
1:
+ pushw %es
+ popw %ds
+
movl $0x200, %ecx
addl %ecx, %esi
movl $DATA_ADDR, %edi
call move_memory
- movsbl %dh, %eax
- movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
+ // Check for the multiboot signature
+ cmpl $0x1badb002, %ss:(DATA_ADDR + 0x50)
+ jz 1f
- movsbl (reg_edx + 2 - start), %eax
- movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
+ movl (ramdisk_image - start), %esi
+ movl (ramdisk_size - start), %ecx
+ movl $(DATA_ADDR - 0x200), %edi
+ jmp 2f
+
+1:
+ movl (ramdisk_size - start), %eax
+ or %eax, %eax
+ jz 1f
+
+ movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE)
+ movl (ramdisk_image - start), %eax
+ movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_ADDR)
+1:
movl %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx
addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx
+2:
call move_memory
- popl %edi
- popl %esi
+ movsbl %dh, %eax
+ movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
+
+ movsbl (reg_edx + 2 - start), %eax
+ movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
ljmp $(DATA_ADDR >> 4), $0
@@ -261,8 +263,8 @@ move_memory:
2:
- leal (%esi, %eax), %esi
- leal (%edi, %eax), %edi
+ addl %eax, %esi
+ addl %eax, %edi
subl %eax, %ecx
jnz 1b
diff --git a/include/grub/i386/pc/kernel.h b/include/grub/i386/pc/kernel.h
index ca16df7..f5d8438 100644
--- a/include/grub/i386/pc/kernel.h
+++ b/include/grub/i386/pc/kernel.h
@@ -37,8 +37,11 @@
/* The offset of GRUB_MEMDISK_IMAGE_SIZE. */
#define GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE 0x1c
+/* The offset of GRUB_MEMDISK_IMAGE_ADDR. */
+#define GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_ADDR 0x20
+
/* The offset of GRUB_PREFIX. */
-#define GRUB_KERNEL_MACHINE_PREFIX 0x20
+#define GRUB_KERNEL_MACHINE_PREFIX 0x24
/* End of the data section. */
#define GRUB_KERNEL_MACHINE_DATA_END 0x50
@@ -66,6 +69,9 @@ extern grub_int32_t grub_install_bsd_part;
/* The size of memory disk image, if present. */
extern grub_int32_t grub_memdisk_image_size;
+/* The address of memory disk image, if present. */
+extern grub_int32_t grub_memdisk_image_addr;
+
/* The prefix which points to the directory where GRUB modules and its
configuration file are located. */
extern char grub_prefix[];
diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c
index 0cf81d7..af6deda 100644
--- a/kern/i386/pc/init.c
+++ b/kern/i386/pc/init.c
@@ -253,9 +253,10 @@ grub_arch_modules_addr (void)
grub_addr_t
grub_arch_memdisk_addr (void)
{
- return GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR
+ return (grub_memdisk_image_addr) ? grub_memdisk_image_addr :
+ (GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR
+ (grub_kernel_image_size - GRUB_KERNEL_MACHINE_RAW_SIZE)
- + grub_total_module_size;
+ + grub_total_module_size);
}
/* Return the size of the memdisk image. */
diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S
index e4101a6..5dd2e67 100644
--- a/kern/i386/pc/startup.S
+++ b/kern/i386/pc/startup.S
@@ -97,6 +97,8 @@ VARIABLE(grub_install_bsd_part)
.long 0xFFFFFFFF
VARIABLE(grub_memdisk_image_size)
.long 0
+VARIABLE(grub_memdisk_image_addr)
+ .long 0
VARIABLE(grub_prefix)
/* to be filled by grub-mkimage */
--
Bean
- Re: [PATCH] memdisk plus lnxboot extension, Robert Millan, 2008/01/20
- Re: [PATCH] memdisk plus lnxboot extension, Marco Gerards, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Bean, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension,
Bean <=
- Re: [PATCH] memdisk plus lnxboot extension, Robert Millan, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Bean, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Robert Millan, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Bean, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Robert Millan, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Bean, 2008/01/23
- Re: [PATCH] memdisk plus lnxboot extension, Robert Millan, 2008/01/24
- Re: [PATCH] memdisk plus lnxboot extension, Bean, 2008/01/24
- Re: [PATCH] memdisk plus lnxboot extension, Robert Millan, 2008/01/24
- Re: [PATCH] memdisk plus lnxboot extension, Bean, 2008/01/24