patch grub EFI setjmp in IA32

2006-08-02 Thread bibo,mao

hi,
  In IA32 application function  parameter is passed on stack but not register,
on grub_setjmp funciton, env is pushed on stack, but not eax register.Caller is
responsible to push parameter on the stack and after function call pop the 
stack.

Here is the patch for setjmp.S in IA32 EFI, any suggestion is welcome.

Thanks
bibo,mao

--- grub-1.94.org/normal/i386/setjmp.S  2004-04-04 21:46:03.0 +0800
+++ grub-1.94/normal/i386/setjmp.S  2006-08-03 11:00:02.0 +0800
@@ -27,11 +27,13 @@
 * int grub_setjmp (grub_jmp_buf env)
 */
FUNCTION(grub_setjmp)
+   popl%ecx
+   popl%eax
+   pushl   %eax
movl%ebx, 0(%eax)   /* EBX */
movl%esi, 4(%eax)   /* ESI */
movl%edi, 8(%eax)   /* EDI */
movl%ebp, 12(%eax)  /* EBP */
-   popl%ecx
movl%esp, 16(%eax)  /* ESP */
movl%ecx, 20(%eax)  /* EIP */
xorl%eax, %eax
@@ -42,6 +44,11 @@ FUNCTION(grub_setjmp)
 * int grub_longjmp (grub_jmp_buf env, int val)
 */
FUNCTION(grub_longjmp)
+   popl%eax/* skip return address */
+   popl%edx
+   popl%eax
+   pushl   %eax
+   pushl   %edx
movl0(%eax), %ebx
movl4(%eax), %esi
movl8(%eax), %edi


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[RFC][PATCH] vmlinux/vmlinux.bin loading capability

2006-08-02 Thread Maciek Nowacki
Hi,

Here is an attempt at a patch to load and execute a vmlinux kernel image,
only tested with QEMU for x86_64. It is very preliminary, excludes a large
amount of planned functionality, and so far only boots the raw vmlinux.bin
file found in arch/[x86_64,i386]/boot/vmlinux.bin after compiling Linux with
the 'make vmlinux' target (and 'make bzImage' as well). This means that the
user must supply the entry point of the kernel on the GRUB command line. This
nastiness will be easily removed once vmlinux is used in place of
vmlinux.bin.

vmlinux.bin is a derivative of the vmlinux kernel executable that is produced
by:

objcopy -O binary linux-2.6.xx/vmlinux vmlinux.bin

My reasons for doing this are:
- eliminating real-mode code from the kernel image (and ultimately 32-bit
  code, in x86-64)
- allowing GRUB to have more control over the boot process
- removing the decompression code from the kernel image - instead delegating
  decompression to the bootloader, as an optional feature
- simplying Linux compilation by making all targets aside from
  vmlinux/modules redundant (indeed, even System.map is redundant with a full
  vmlinux present).

If vmlinux is too large, it is always possible to strip(1). With compression,
it becomes very close to the size of a bzImage:

$ gzip -9c vmlinux > vmlinux.gz
$ bzip2 -9c vmlinux > vmlinux.bz2
$ strip -o vmlinux_str vmlinux
$ gzip -9c vmlinux_str > vmlinux_str.gz
$ bzip2 -9c vmlinux_str > vmlinux_str.bz2
$ ls -ltcr vmlinux*
-rwxrwxr-x 1 maciek maciek 47308143 Jul 30 21:53 vmlinux*
-rw-rw-r-- 1 maciek maciek 19453585 Aug  3 00:47 vmlinux.gz
-rw-rw-r-- 1 maciek maciek 16795427 Aug  3 00:47 vmlinux.bz2
-rwxrwxr-x 1 maciek maciek  7140752 Aug  3 00:47 vmlinux_str*
-rw-rw-r-- 1 maciek maciek  1856381 Aug  3 00:48 vmlinux_str.gz
-rw-rw-r-- 1 maciek maciek  1757941 Aug  3 00:48 vmlinux_str.bz2
$ ls -l arch/x86_64/boot/bzImage
-rw-rw-r-- 1 maciek maciek 1832285 Jul  9 18:51 arch/x86_64/boot/bzImage
$

(bzImage and vmlinux are not representative of the same .config - but it is
very close. Admittedly the vmlinux .config defines a slightly smaller
kernel image.)

Of course I am aware that GRUB does not currently support bzip2
decompression. However, should it gain this feature, the kernel on-disk size
would decrease compared to bzImage.

Please let me know what you think. I have included an updated version of my
run-grub.sh bash script which includes an example invocation of the vmlinux
loader (however, it seems that GRUB truncates the command line...? I have not
yet investigated this).

Maciek
diff -Nur -x autom4te.cache grub2_cvspull.bak/conf/i386-pc.rmk 
grub2_cvspull/conf/i386-pc.rmk
--- grub2_cvspull.bak/conf/i386-pc.rmk  2006-07-31 08:21:35.0 -0600
+++ grub2_cvspull/conf/i386-pc.rmk  2006-08-03 00:18:02.0 -0600
@@ -112,7 +112,7 @@
 pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod  \
vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
-   videotest.mod play.mod bitmap.mod tga.mod
+   videotest.mod play.mod bitmap.mod tga.mod vmlinux.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -164,6 +164,11 @@
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For vmlinux.mod.
+vmlinux_mod_SOURCES = loader/i386/pc/vmlinux.c
+vmlinux_mod_CFLAGS = $(COMMON_CFLAGS)
+vmlinux_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c
 multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
diff -Nur -x autom4te.cache grub2_cvspull.bak/include/grub/i386/pc/init.h 
grub2_cvspull/include/grub/i386/pc/init.h
--- grub2_cvspull.bak/include/grub/i386/pc/init.h   2005-01-31 
14:40:25.0 -0700
+++ grub2_cvspull/include/grub/i386/pc/init.h   2006-08-03 00:21:47.0 
-0600
@@ -48,8 +48,11 @@
 
 /* Get a memory map entry. Return next continuation value. Zero means
the end.  */
-grub_uint32_t grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
-  grub_uint32_t cont);
+/*grub_uint32_t grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
+  grub_uint32_t cont);*/
+/* exporting for loader/i386/pc/vmlinux.c */
+grub_uint32_t EXPORT_FUNC (grub_get_mmap_entry)
+   (struct grub_machine_mmap_entry *entry, grub_uint32_t cont);
 
 /* Turn on/off Gate A20.  */
 void grub_gate_a20 (int on);
diff -Nur -x autom4te.cache grub2_cvspull.bak/loader/i386/pc/vmlinux.c 
grub2_cvspull/loader/i386/pc/vmlinux.c
--- grub2_cvspull.bak/loader/i386/pc/vmlinux.c  1969-12-31 17:00:00.0 
-0700
+++ grub2_cvspull/loader/i386/pc/vmlinux.c  2006-08-03 00:08:10.0 
-0600
@@ -0,0 +1,416 @@
+/* vmlinux.c - load a Linux i386/x86_64 vmlinux.bin kernel image */
+/* August 3 2006, Maciek Nowacki <[EMAIL PROTECTED]> */
+
+/*
+ * notes:
+ *
+ * grub leaks memory. This is apparent even with the stock L