Reenable qemu-mips port.

* configure.ac: Handle --target=qemu-mips and --target=qemu_mips.
	Fix small arc bug while on it.
	* gentpl.py: Handle qemu_mips.
	* grub-core/Makefile.am: Likewise.
	* grub-core/Makefile.core.def: Likewise.
	* grub-core/disk/ata.c [GRUB_MACHINE_MIPS_QEMU_MIPS]: Remove
	inappropriate includes.
	(grub_ata_pciinit) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Removed.
	(grub_ata_initialize): [GRUB_MACHINE_MIPS_QEMU_MIPS]: Rewritten.
	* grub-core/kern/main.c (grub_modules_get_end)
	[GRUB_MACHINE_MIPS_QEMU_MIPS]: Enable.
	* grub-core/kern/mips/qemu-mips: Moved to ..
	* grub-core/kern/mips/qemu_mips: ... this.
	* grub-core/kern/mips/qemu_mips/init.c (grub_get_rtc): Removed.
	(grub_machine_init): Call terminfo_init and serial_init.
	* grub-core/kern/mips/startup.S: Change MIPS_LOONGSON to MACHINE.
	* grub-core/loader/mips/linux.c (params) [GRUB_MACHINE_MIPS_QEMU_MIPS]:
	New variable.
	(grub_linux_boot) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Handle the qemu-mips
	parameter passing.
	(grub_linux_unload) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Free params.
	(grub_cmd_linux) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Handle params.
	(grub_cmd_initrd) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Likewise.
	* include/grub/mips/qemu_mips/cmos.h: New file.
	* include/grub/mips/qemu-mips/kernel.h: Don't include cpu/kernel.h.
	* include/grub/mips/qemu-mips/memory.h (grub_machine_mmap_iterate):
	Removed.
	* include/grub/mips/qemu-mips/serial.h (GRUB_MACHINE_SERIAL_PORTS):
	Use correct mips-style address.
	* include/grub/mips/qemu-mips/time.h: Include cpu/time.h.
	(GRUB_TICKS_PER_SECOND): Removed.
	(grub_get_rtc): Likewise.
	(grub_cpu_idle): Likewise.
	* include/grub/offsets.h (GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR):
	New definition.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN): Likewise.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_COMPRESSED_SIZE): Likewise.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE): Likewise.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE): Likewise.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX): Likewise.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END): Likewise.
	(GRUB_KERNEL_MIPS_QEMU_MIPS_MOD_ALIGN): Likewise.
	* util/grub-mkimage.c (image_targets): Add mipsel-qemu_mips-elf.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-05-17 16:07:17 +02:00
commit 8d4a51785a
18 changed files with 242 additions and 38 deletions

View file

@ -1,3 +1,51 @@
2011-05-17 Vladimir Serbinenko <phcoder@gmail.com>
Reenable qemu-mips port.
* configure.ac: Handle --target=qemu-mips and --target=qemu_mips.
Fix small arc bug while on it.
* gentpl.py: Handle qemu_mips.
* grub-core/Makefile.am: Likewise.
* grub-core/Makefile.core.def: Likewise.
* grub-core/disk/ata.c [GRUB_MACHINE_MIPS_QEMU_MIPS]: Remove
inappropriate includes.
(grub_ata_pciinit) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Removed.
(grub_ata_initialize): [GRUB_MACHINE_MIPS_QEMU_MIPS]: Rewritten.
* grub-core/kern/main.c (grub_modules_get_end)
[GRUB_MACHINE_MIPS_QEMU_MIPS]: Enable.
* grub-core/kern/mips/qemu-mips: Moved to ..
* grub-core/kern/mips/qemu_mips: ... this.
* grub-core/kern/mips/qemu_mips/init.c (grub_get_rtc): Removed.
(grub_machine_init): Call terminfo_init and serial_init.
* grub-core/kern/mips/startup.S: Change MIPS_LOONGSON to MACHINE.
* grub-core/loader/mips/linux.c (params) [GRUB_MACHINE_MIPS_QEMU_MIPS]:
New variable.
(grub_linux_boot) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Handle the qemu-mips
parameter passing.
(grub_linux_unload) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Free params.
(grub_cmd_linux) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Handle params.
(grub_cmd_initrd) [GRUB_MACHINE_MIPS_QEMU_MIPS]: Likewise.
* include/grub/mips/qemu_mips/cmos.h: New file.
* include/grub/mips/qemu-mips/kernel.h: Don't include cpu/kernel.h.
* include/grub/mips/qemu-mips/memory.h (grub_machine_mmap_iterate):
Removed.
* include/grub/mips/qemu-mips/serial.h (GRUB_MACHINE_SERIAL_PORTS):
Use correct mips-style address.
* include/grub/mips/qemu-mips/time.h: Include cpu/time.h.
(GRUB_TICKS_PER_SECOND): Removed.
(grub_get_rtc): Likewise.
(grub_cpu_idle): Likewise.
* include/grub/offsets.h (GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR):
New definition.
(GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_COMPRESSED_SIZE): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_MOD_ALIGN): Likewise.
* util/grub-mkimage.c (image_targets): Add mipsel-qemu_mips-elf.
2011-05-17 Vladimir Serbinenko <phcoder@gmail.com> 2011-05-17 Vladimir Serbinenko <phcoder@gmail.com>
SGI ARCS port. SGI ARCS port.

View file

@ -124,7 +124,8 @@ case "$target_cpu"-"$platform" in
powerpc-ieee1275) ;; powerpc-ieee1275) ;;
sparc64-ieee1275) ;; sparc64-ieee1275) ;;
ia64-efi) ;; ia64-efi) ;;
mips-qemu-mips) ;; mips-qemu_mips) ;;
mips-qemu-mips) platform=qemu_mips;;
mips-yeeloong) platform=loongson ;; mips-yeeloong) platform=loongson ;;
mips-fuloong) platform=loongson ;; mips-fuloong) platform=loongson ;;
mips-loongson) ;; mips-loongson) ;;
@ -162,8 +163,8 @@ case "$platform" in
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;; pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;; emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
qemu-mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
mips-arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_ARC=1 -DGRUB_MACHINE_ARC=1" ;; arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
esac esac
case "$target_cpu" in case "$target_cpu" in
mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;; mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;

View file

@ -7,7 +7,8 @@
GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
"i386_multiboot", "i386_ieee1275", "x86_64_efi", "i386_multiboot", "i386_ieee1275", "x86_64_efi",
"mips_loongson", "sparc64_ieee1275", "mips_loongson", "sparc64_ieee1275",
"powerpc_ieee1275", "mips_arc", "ia64_efi" ] "powerpc_ieee1275", "mips_arc", "ia64_efi",
"mips_qemu_mips" ]
GROUPS = {} GROUPS = {}
@ -17,7 +18,7 @@ GROUPS["common"] = GRUB_PLATFORMS[:]
GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ] GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ]
GROUPS["x86_64"] = [ "x86_64_efi" ] GROUPS["x86_64"] = [ "x86_64_efi" ]
GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"]
GROUPS["mips"] = [ "mips_loongson", "mips_arc" ] GROUPS["mips"] = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ]
GROUPS["sparc64"] = [ "sparc64_ieee1275" ] GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
GROUPS["powerpc"] = [ "powerpc_ieee1275" ] GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
@ -29,7 +30,7 @@ GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275"
GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu") GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
# Groups based on hardware features # Groups based on hardware features
GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi") GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson", "mips_qemu_mips"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi")
GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"] GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"]
GROUPS["usb"] = GROUPS["pci"] GROUPS["usb"] = GROUPS["pci"]
@ -39,7 +40,7 @@ GROUPS["videomodules"] = GRUB_PLATFORMS[:];
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i) for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
# Similar for terminfo # Similar for terminfo
GROUPS["terminfoinkernel"] = ["mips_loongson", "mips_arc"] + GROUPS["ieee1275"]; GROUPS["terminfoinkernel"] = ["mips_loongson", "mips_arc", "mips_qemu_mips" ] + GROUPS["ieee1275"];
GROUPS["terminfomodule"] = GRUB_PLATFORMS[:]; GROUPS["terminfomodule"] = GRUB_PLATFORMS[:];
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i) for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)

View file

@ -140,6 +140,10 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
endif endif
if COND_mips_qemu_mips
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
endif
if COND_mips_loongson if COND_mips_loongson
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
@ -160,6 +164,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
endif endif
if COND_mips_qemu_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
endif
if COND_powerpc_ieee1275 if COND_powerpc_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h

View file

@ -42,6 +42,7 @@ kernel = {
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000'; powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400'; sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
mips_arc_ldflags = '-Wl,-Ttext,0x8a000000'; mips_arc_ldflags = '-Wl,-Ttext,0x8a000000';
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK'; mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK';
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
@ -152,6 +153,10 @@ kernel = {
mips = kern/mips/dl.c; mips = kern/mips/dl.c;
mips = kern/mips/init.c; mips = kern/mips/init.c;
mips_qemu_mips = kern/mips/qemu_mips/init.c;
mips_qemu_mips = term/ns8250.c;
mips_qemu_mips = term/serial.c;
mips_arc = kern/mips/arc/init.c; mips_arc = kern/mips/arc/init.c;
mips_arc = term/arc/console.c; mips_arc = term/arc/console.c;
mips_arc = disk/arc/arcdisk.c; mips_arc = disk/arc/arcdisk.c;
@ -318,6 +323,7 @@ image = {
objcopyflags = '-O binary'; objcopyflags = '-O binary';
mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000'; mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000'; mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000';
ldadd = '-lgcc'; ldadd = '-lgcc';
cflags = '-static-libgcc'; cflags = '-static-libgcc';
@ -333,6 +339,7 @@ image = {
objcopyflags = '-O binary'; objcopyflags = '-O binary';
mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000'; mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000'; mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000';
ldadd = '-lgcc'; ldadd = '-lgcc';
cflags = '-static-libgcc'; cflags = '-static-libgcc';
@ -849,12 +856,14 @@ module = {
name = ata; name = ata;
common = disk/ata.c; common = disk/ata.c;
enable = pci; enable = pci;
enable = mips_qemu_mips;
}; };
module = { module = {
name = ata_pthru; name = ata_pthru;
common = disk/ata_pthru.c; common = disk/ata_pthru.c;
enable = pci; enable = pci;
enable = mips_qemu_mips;
}; };
module = { module = {

View file

@ -22,9 +22,13 @@
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/time.h> #include <grub/time.h>
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
#include <grub/pci.h> #include <grub/pci.h>
#include <grub/scsi.h>
#include <grub/cs5536.h> #include <grub/cs5536.h>
#else
#define GRUB_MACHINE_PCI_IO_BASE 0xb4000000
#endif
#include <grub/scsi.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -409,6 +413,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
return 0; return 0;
} }
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
static int NESTED_FUNC_ATTR static int NESTED_FUNC_ATTR
grub_ata_pciinit (grub_pci_device_t dev, grub_ata_pciinit (grub_pci_device_t dev,
grub_pci_id_t pciid) grub_pci_id_t pciid)
@ -524,6 +529,21 @@ grub_ata_initialize (void)
grub_pci_iterate (grub_ata_pciinit); grub_pci_iterate (grub_ata_pciinit);
return 0; return 0;
} }
#else
static grub_err_t
grub_ata_initialize (void)
{
int i;
for (i = 0; i < 2; i++)
{
grub_ata_device_initialize (i, 0, grub_ata_ioaddress[i],
grub_ata_ioaddress2[i]);
grub_ata_device_initialize (i, 1, grub_ata_ioaddress[i],
grub_ata_ioaddress2[i]);
}
return 0;
}
#endif
static void static void
grub_ata_setlba (struct grub_ata_device *dev, grub_disk_addr_t sector, grub_ata_setlba (struct grub_ata_device *dev, grub_disk_addr_t sector,

View file

@ -54,7 +54,7 @@ grub_module_iterate (int (*hook) (struct grub_module_header *header))
} }
/* This is actualy platform-independant but used only on loongson and sparc. */ /* This is actualy platform-independant but used only on loongson and sparc. */
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_SPARC64) #if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_SPARC64)
grub_addr_t grub_addr_t
grub_modules_get_end (void) grub_modules_get_end (void)
{ {

View file

@ -6,25 +6,31 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/time.h> #include <grub/time.h>
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h> #include <grub/machine/memory.h>
#include <grub/cpu/kernel.h> #include <grub/cpu/memory.h>
#include <grub/memory.h>
#define RAMSIZE (*(grub_uint32_t *) ((16 << 20) - 264)) #define RAMSIZE (*(grub_uint32_t *) ((16 << 20) - 264))
grub_uint32_t extern void grub_serial_init (void);
grub_get_rtc (void) extern void grub_terminfo_init (void);
{
static int calln = 0;
return calln++;
}
void void
grub_machine_init (void) grub_machine_init (void)
{ {
grub_mm_init_region ((void *) GRUB_MACHINE_MEMORY_USABLE, grub_addr_t modend;
RAMSIZE - (GRUB_MACHINE_MEMORY_USABLE & 0x7fffffff));
/* FIXME: measure this. */
grub_arch_cpuclock = 64000000;
modend = grub_modules_get_end ();
grub_mm_init_region ((void *) modend, RAMSIZE
- (modend - GRUB_ARCH_LOWMEMVSTART));
grub_install_get_time_ms (grub_rtc_get_time_ms); grub_install_get_time_ms (grub_rtc_get_time_ms);
grub_terminfo_init ();
grub_serial_init ();
} }
void void

View file

@ -36,7 +36,7 @@ start:
bal cont bal cont
nop nop
. = _start + GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE . = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
total_module_size: total_module_size:
.long 0 .long 0

View file

@ -27,6 +27,7 @@
#include <grub/mips/relocator.h> #include <grub/mips/relocator.h>
#include <grub/memory.h> #include <grub/memory.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/lib/cmdline.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -53,12 +54,16 @@ static grub_size_t linux_size;
static struct grub_relocator *relocator; static struct grub_relocator *relocator;
static grub_uint8_t *playground; static grub_uint8_t *playground;
static grub_addr_t target_addr, entry_addr; static grub_addr_t target_addr, entry_addr;
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
static char *params;
#else
static int linux_argc; static int linux_argc;
static grub_off_t argv_off; static grub_off_t argv_off;
#ifdef GRUB_MACHINE_MIPS_LOONGSON #ifdef GRUB_MACHINE_MIPS_LOONGSON
static grub_off_t envp_off; static grub_off_t envp_off;
#endif #endif
static grub_off_t rd_addr_arg_off, rd_size_arg_off; static grub_off_t rd_addr_arg_off, rd_size_arg_off;
#endif
static int initrd_loaded = 0; static int initrd_loaded = 0;
static grub_err_t static grub_err_t
@ -66,8 +71,26 @@ grub_linux_boot (void)
{ {
struct grub_relocator32_state state; struct grub_relocator32_state state;
grub_memset (&state, 0, sizeof (state));
/* Boot the kernel. */ /* Boot the kernel. */
state.gpr[1] = entry_addr; state.gpr[1] = entry_addr;
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
{
grub_err_t err;
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
((16 << 20) - 256),
grub_strlen (params) + 1);
if (err)
return err;
grub_strcpy (get_virtual_current_address (ch), params);
}
#endif
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
state.gpr[4] = linux_argc; state.gpr[4] = linux_argc;
state.gpr[5] = target_addr + argv_off; state.gpr[5] = target_addr + argv_off;
#ifdef GRUB_MACHINE_MIPS_LOONGSON #ifdef GRUB_MACHINE_MIPS_LOONGSON
@ -76,6 +99,7 @@ grub_linux_boot (void)
state.gpr[6] = 0; state.gpr[6] = 0;
#endif #endif
state.gpr[7] = 0; state.gpr[7] = 0;
#endif
state.jumpreg = 1; state.jumpreg = 1;
grub_relocator32_boot (relocator, state); grub_relocator32_boot (relocator, state);
@ -88,6 +112,11 @@ grub_linux_unload (void)
grub_relocator_unload (relocator); grub_relocator_unload (relocator);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
grub_free (params);
params = 0;
#endif
loaded = 0; loaded = 0;
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@ -207,11 +236,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[]) int argc, char *argv[])
{ {
grub_elf_t elf = 0; grub_elf_t elf = 0;
int i;
int size; int size;
void *extra = NULL; void *extra = NULL;
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
int i;
grub_uint32_t *linux_argv; grub_uint32_t *linux_argv;
char *linux_args; char *linux_args;
#endif
grub_err_t err; grub_err_t err;
#ifdef GRUB_MACHINE_MIPS_LOONGSON #ifdef GRUB_MACHINE_MIPS_LOONGSON
char *linux_envs; char *linux_envs;
@ -236,6 +267,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_loader_unset (); grub_loader_unset ();
loaded = 0; loaded = 0;
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
size = 0;
#else
/* For arguments. */ /* For arguments. */
linux_argc = argc; linux_argc = argc;
#ifdef GRUB_MACHINE_MIPS_LOONGSON #ifdef GRUB_MACHINE_MIPS_LOONGSON
@ -268,6 +302,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ ALIGN_UP (sizeof ("highmemsize=XXXXXXXXXXXXXXXXXXXX"), 4) + ALIGN_UP (sizeof ("highmemsize=XXXXXXXXXXXXXXXXXXXX"), 4)
+ ALIGN_UP (sizeof ("busclock=XXXXXXXXXX"), 4) + ALIGN_UP (sizeof ("busclock=XXXXXXXXXX"), 4)
+ ALIGN_UP (sizeof ("cpuclock=XXXXXXXXXX"), 4); + ALIGN_UP (sizeof ("cpuclock=XXXXXXXXXX"), 4);
#endif
if (grub_elf_is_elf32 (elf)) if (grub_elf_is_elf32 (elf))
err = grub_linux_load32 (elf, &extra, size); err = grub_linux_load32 (elf, &extra, size);
@ -282,6 +317,20 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
if (err) if (err)
return err; return err;
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
/* Create kernel command line. */
size = grub_loader_cmdline_size(argc, argv);
params = grub_malloc (size + sizeof (LINUX_IMAGE));
if (! params)
{
grub_linux_unload ();
return grub_errno;
}
grub_memcpy (params, LINUX_IMAGE, sizeof (LINUX_IMAGE));
grub_create_loader_cmdline (argc, argv, params + sizeof (LINUX_IMAGE) - 1,
size);
#else
linux_argv = extra; linux_argv = extra;
argv_off = (grub_uint8_t *) linux_argv - (grub_uint8_t *) playground; argv_off = (grub_uint8_t *) linux_argv - (grub_uint8_t *) playground;
extra = linux_argv + (linux_argc + 1 + 2); extra = linux_argv + (linux_argc + 1 + 2);
@ -362,6 +411,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4); linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
linux_envp[4] = 0; linux_envp[4] = 0;
#endif
#endif #endif
grub_loader_set (grub_linux_boot, grub_linux_unload, 1); grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
@ -425,6 +475,21 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
return grub_errno; return grub_errno;
} }
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
{
char *tmp;
tmp = grub_xasprintf ("%s rd_start=0x%" PRIxGRUB_ADDR
" rd_size=0x%" PRIxGRUB_ADDR, params,
initrd_dest, size);
if (!tmp)
{
grub_file_close (file);
return grub_errno;
}
grub_free (params);
params = tmp;
}
#else
grub_snprintf ((char *) playground + rd_addr_arg_off, grub_snprintf ((char *) playground + rd_addr_arg_off,
sizeof ("rd_start=0xXXXXXXXXXXXXXXXX"), "rd_start=0x%llx", sizeof ("rd_start=0xXXXXXXXXXXXXXXXX"), "rd_start=0x%llx",
(unsigned long long) initrd_dest); (unsigned long long) initrd_dest);
@ -438,6 +503,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
((grub_uint32_t *) (playground + argv_off))[linux_argc] ((grub_uint32_t *) (playground + argv_off))[linux_argc]
= target_addr + rd_size_arg_off; = target_addr + rd_size_arg_off;
linux_argc++; linux_argc++;
#endif
initrd_loaded = 1; initrd_loaded = 1;

View file

@ -0,0 +1,28 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_CPU_CMOS_H
#define GRUB_CPU_CMOS_H 1
#include <grub/types.h>
#include <grub/cpu/io.h>
#define GRUB_CMOS_ADDR_REG 0xb4000070
#define GRUB_CMOS_DATA_REG 0xb4000071
#endif /* GRUB_CPU_CMOS_H */

View file

@ -20,7 +20,6 @@
#define GRUB_KERNEL_MACHINE_HEADER 1 #define GRUB_KERNEL_MACHINE_HEADER 1
#include <grub/symbol.h> #include <grub/symbol.h>
#include <grub/cpu/kernel.h>
#ifndef ASM_FILE #ifndef ASM_FILE

View file

@ -29,11 +29,6 @@
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000 #define GRUB_MACHINE_MEMORY_USABLE 0x81000000
#ifndef ASM_FILE #ifndef ASM_FILE
grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
static inline grub_err_t static inline grub_err_t
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)), grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
grub_uint64_t size __attribute__ ((unused)), grub_uint64_t size __attribute__ ((unused)),

View file

@ -19,6 +19,6 @@
#ifndef GRUB_MACHINE_SERIAL_HEADER #ifndef GRUB_MACHINE_SERIAL_HEADER
#define GRUB_MACHINE_SERIAL_HEADER 1 #define GRUB_MACHINE_SERIAL_HEADER 1
#define GRUB_MACHINE_SERIAL_PORTS { 0x140003f8 } #define GRUB_MACHINE_SERIAL_PORTS { 0xb40003f8 }
#endif #endif

View file

@ -20,15 +20,6 @@
#define KERNEL_MACHINE_TIME_HEADER 1 #define KERNEL_MACHINE_TIME_HEADER 1
#include <grub/symbol.h> #include <grub/symbol.h>
#include <grub/cpu/time.h>
#define GRUB_TICKS_PER_SECOND 1000
/* Return the real time in ticks. */
grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
static inline void
grub_cpu_idle(void)
{
}
#endif /* ! KERNEL_MACHINE_TIME_HEADER */ #endif /* ! KERNEL_MACHINE_TIME_HEADER */

View file

@ -111,6 +111,14 @@
#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX 0x0c #define GRUB_KERNEL_MIPS_LOONGSON_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END 0x54 #define GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END 0x54
#define GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR 0x80200000
#define GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN 32
#define GRUB_KERNEL_MIPS_QEMU_MIPS_COMPRESSED_SIZE 0x8
#define GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE 0xc
#define GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE 0x08
#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END 0x54
#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR 0x8a000000 #define GRUB_KERNEL_MIPS_ARC_LINK_ADDR 0x8a000000
#define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN 32 #define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN 32
@ -163,6 +171,7 @@
#define GRUB_KERNEL_MIPS_LOONGSON_MOD_ALIGN 0x1 #define GRUB_KERNEL_MIPS_LOONGSON_MOD_ALIGN 0x1
#define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1 #define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1
#define GRUB_KERNEL_MIPS_QEMU_MIPS_MOD_ALIGN 0x1
/* Minimal gap between _end and the start of the modules. It's a hack /* Minimal gap between _end and the start of the modules. It's a hack
for PowerMac to prevent "CLAIM failed" error. The real fix is to for PowerMac to prevent "CLAIM failed" error. The real fix is to

View file

@ -442,6 +442,28 @@ struct image_target_desc image_targets[] =
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN, .link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
.default_compression = COMPRESSION_NONE .default_compression = COMPRESSION_NONE
}, },
{
.dirname = "mips-qemu_mips",
.names = { "mipsel-qemu_mips-elf", NULL },
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_LOONGSON_ELF,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
.default_compression = COMPRESSION_NONE
},
}; };
#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x))) #define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))