2008-02-19 Bean <bean123ch@gmail.com>

* conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod _bsd.mod and bsd.mod.
	(aout_mod_SOURCES): New variable.
	(aout_mod_CFLAGS): Likewise.
	(aout_mod_LDFLAGS): Likewise.
	(_bsd_mod_SOURCES): New variable.
	(_bsd_mod_CFLAGS): Likewise.
	(_bsd_mod_LDFLAGS): Likewise.
	(bsd_mod_SOURCES): New variable.
	(bsd_mod_CFLAGS): Likewise.
	(bsd_mod_LDFLAGS): Likewise.

	* include/grub/aout.h: New file.

	* include/grub/i386/loader.h (grub_unix_real_boot): New function.

	* include/grub/i386/bsd.h: New file.

	* include/grub/i386/pc/init.h (grub_get_mmap_entry): Use EXPORT_FUNC
	to make it public.

	* kern/elf.c (grub_elf32_load): Get the physical address after the hook
	function is called, so that it's possible to change it inside the hook.
	(grub_elf64_load): Likewise.
	(grub_elf_file): Don't close the file if elf header is not found.
	(grub_elf_close): Close the file if grub_elf_file fails (The new
	grub_elf_file won't close it).
	(grub_elf32_size): Use NESTED_FUNC_ATTR for nested function calcsize.
	(grub_elf64_size): Likewise.

	* kern/i386/loader.S (grub_unix_real_boot): New function.

	* loader/aout.c: New file.

	* loader/i386/bsd.c: New file.

	* loader/i386/bsd_normal.c: New file.

	* loader/i386/pc/multiboot.c (grub_multiboot): Handle a.out format.

	* loader/multiboot2.c (grub_multiboot2): Reset grub_errno so that it
	can test othe formats.
This commit is contained in:
bean 2008-02-19 16:40:45 +00:00
parent 865bede901
commit d38e24c285
14 changed files with 1571 additions and 50 deletions

View file

@ -21,7 +21,7 @@
* Note: These functions defined in this file may be called from C.
* Be careful of that you must not modify some registers. Quote
* from gcc-2.95.2/gcc/config/i386/i386.h:
1 for registers not available across function calls.
These must include the FIXED_REGISTERS and also any
registers that can be used without being saved.
@ -46,7 +46,7 @@
*/
.p2align 2 /* force 4-byte alignment */
/*
* void grub_linux_boot_zimage (void)
*/
@ -58,7 +58,7 @@ VARIABLE(grub_linux_real_addr)
.long 0
VARIABLE(grub_linux_is_bzimage)
.long 0
FUNCTION(grub_linux_boot)
/* Must be done before zImage copy. */
call EXT_C(grub_dl_unload_all)
@ -118,7 +118,7 @@ linux_setup_seg:
.word 0
.code32
/*
* This starts the multiboot kernel.
*/
@ -128,14 +128,14 @@ FUNCTION(grub_multiboot_real_boot)
pushl %eax
/* Move the address of the multiboot information structure to ebx. */
movl %edx,%ebx
/* Unload all modules and stop the floppy driver. */
call EXT_C(grub_dl_unload_all)
call EXT_C(grub_stop_floppy)
/* Interrupts should be disabled. */
cli
/* Move the magic value into eax and jump to the kernel. */
movl $MULTIBOOT_MAGIC2,%eax
popl %ecx
@ -159,6 +159,30 @@ FUNCTION(grub_multiboot2_real_boot)
cli
/* Move the magic value into eax and jump to the kernel. */
movl $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
movl $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
popl %ecx
jmp *%ecx
/*
* Use cdecl calling convention for *BSD kernels.
*/
FUNCTION(grub_unix_real_boot)
call EXT_C(grub_dl_unload_all)
call EXT_C(grub_stop_floppy)
/* Interrupts should be disabled. */
cli
/* Discard `grub_unix_real_boot' return address. */
popl %eax
/* Fetch `entry' address ... */
popl %eax
/*
* ... and put our return address in its place. The kernel will
* ignore it, but it expects %esp to point to it.
*/
call *%eax