From f440c33fd2669b06a0c84cbbe1912054d5d39314 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 14 Jan 2011 17:37:11 +0100 Subject: [PATCH] Make qemu-mips compile again. Still no grub-mkimage support --- configure.ac | 4 +-- gentpl.py | 8 ++--- grub-core/Makefile.am | 5 +++ grub-core/Makefile.core.def | 12 ++++--- grub-core/kern/mips/cache_flush.S | 4 +++ grub-core/kern/mips/qemu-mips/init.c | 3 +- grub-core/loader/mips/linux.c | 7 ++++- grub-core/loader/multiboot_mbi2.c | 2 ++ include/grub/mips/qemu_mips/cmos.h | 28 +++++++++++++++++ .../mips/{qemu-mips => qemu_mips}/kernel.h | 1 - .../mips/{qemu-mips => qemu_mips}/loader.h | 0 .../mips/{qemu-mips => qemu_mips}/memory.h | 31 +++++++++++++++++-- .../mips/{qemu-mips => qemu_mips}/serial.h | 0 .../grub/mips/{qemu-mips => qemu_mips}/time.h | 0 include/grub/offsets.h | 28 +++++++++++++---- 15 files changed, 110 insertions(+), 23 deletions(-) create mode 100644 include/grub/mips/qemu_mips/cmos.h rename include/grub/mips/{qemu-mips => qemu_mips}/kernel.h (97%) rename include/grub/mips/{qemu-mips => qemu_mips}/loader.h (100%) rename include/grub/mips/{qemu-mips => qemu_mips}/memory.h (69%) rename include/grub/mips/{qemu-mips => qemu_mips}/serial.h (100%) rename include/grub/mips/{qemu-mips => qemu_mips}/time.h (100%) diff --git a/configure.ac b/configure.ac index 0b9207ea2..aac93fba2 100644 --- a/configure.ac +++ b/configure.ac @@ -122,7 +122,7 @@ case "$target_cpu"-"$platform" in i386-qemu) ;; powerpc-ieee1275) ;; sparc64-ieee1275) ;; - mips-qemu-mips) ;; + mips-qemu_mips) ;; mips-yeeloong) ;; *-emu) ;; *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; @@ -157,7 +157,7 @@ case "$platform" in pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;; emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;; yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=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" ;; esac case "$target_cpu" in mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;; diff --git a/gentpl.py b/gentpl.py index a42a60667..97eff9f57 100644 --- a/gentpl.py +++ b/gentpl.py @@ -6,7 +6,7 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275", "x86_64_efi", - "mips_yeeloong", "sparc64_ieee1275", + "mips_yeeloong", "mips_qemu_mips", "sparc64_ieee1275", "powerpc_ieee1275" ] GROUPS = {} @@ -17,7 +17,7 @@ GROUPS["common"] = GRUB_PLATFORMS[:] GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ] GROUPS["x86_64"] = [ "x86_64_efi" ] GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] -GROUPS["mips"] = [ "mips_yeeloong" ] +GROUPS["mips"] = [ "mips_yeeloong", "mips_qemu_mips" ] GROUPS["sparc64"] = [ "sparc64_ieee1275" ] GROUPS["powerpc"] = [ "powerpc_ieee1275" ] @@ -29,8 +29,8 @@ GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu") # Groups based on hardware features -GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_yeeloong"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi") -GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"] +GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_yeeloong", "mips_qemu_mips" ]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi") +GROUPS["pci"] = GROUPS["x86"] + ["mips_yeeloong"] GROUPS["usb"] = GROUPS["pci"] # If gfxterm is main output console integrate it into kernel diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 94f7f3ffe..65f638745 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -145,6 +145,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h 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 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2cca4fa95..1cc832892 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -48,7 +48,7 @@ kernel = { i386_ieee1275_startup = kern/i386/ieee1275/startup.S; i386_coreboot_startup = kern/i386/coreboot/startup.S; i386_multiboot_startup = kern/i386/coreboot/startup.S; - mips_yeeloong_startup = kern/mips/startup.S; + mips_startup = kern/mips/startup.S; sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S; powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S; @@ -82,6 +82,7 @@ kernel = { i386_coreboot = kern/generic/rtc_get_time_ms.c; i386_multiboot = kern/generic/rtc_get_time_ms.c; mips_yeeloong = kern/generic/rtc_get_time_ms.c; + mips_qemu_mips = kern/generic/rtc_get_time_ms.c; ieee1275 = disk/ieee1275/ofdisk.c; ieee1275 = kern/ieee1275/cmain.c; @@ -140,10 +141,11 @@ kernel = { mips_yeeloong = bus/bonito.c; mips_yeeloong = bus/cs5536.c; mips_yeeloong = bus/pci.c; - mips_yeeloong = kern/mips/cache.S; - mips_yeeloong = kern/mips/dl.c; - mips_yeeloong = kern/mips/init.c; + mips = kern/mips/cache.S; + mips = kern/mips/dl.c; + mips = kern/mips/init.c; mips_yeeloong = kern/mips/yeeloong/init.c; + mips_qemu_mips = kern/mips/qemu-mips/init.c; mips_yeeloong = term/at_keyboard.c; mips_yeeloong = term/serial.c; mips_yeeloong = video/sm712.c; @@ -1229,7 +1231,7 @@ module = { mips_yeeloong = mmap/mips/yeeloong/uppermem.c; enable = x86; - enable = mips_yeeloong; + enable = mips; }; module = { diff --git a/grub-core/kern/mips/cache_flush.S b/grub-core/kern/mips/cache_flush.S index 11096c035..87a738caa 100644 --- a/grub-core/kern/mips/cache_flush.S +++ b/grub-core/kern/mips/cache_flush.S @@ -1,3 +1,6 @@ + + /* Qemu doesn't emulate caches. Oh boy. */ +#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS move $t2, $a0 addu $t3, $a0, $a1 srl $t2, $t2, 5 @@ -21,3 +24,4 @@ bne $t1, $zero, 2b addiu $t0, $t0, 0x1 sync +#endif \ No newline at end of file diff --git a/grub-core/kern/mips/qemu-mips/init.c b/grub-core/kern/mips/qemu-mips/init.c index f2bb652a8..1690b5451 100644 --- a/grub-core/kern/mips/qemu-mips/init.c +++ b/grub-core/kern/mips/qemu-mips/init.c @@ -6,9 +6,8 @@ #include #include #include -#include #include -#include +#include #define RAMSIZE (*(grub_uint32_t *) ((16 << 20) - 264)) diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 6ae2a9321..8520609ed 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -29,8 +29,10 @@ #include /* For frequencies. */ +#ifdef GRUB_MACHINE_MIPS_YEELOONG #include #include +#endif #ifdef GRUB_MACHINE_MIPS_YEELOONG /* This can be detected on runtime from PMON, but: @@ -314,6 +316,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), linux_envp = extra; envp_off = (grub_uint8_t *) linux_envp - (grub_uint8_t *) playground; linux_envs = (char *) (linux_envp + 5); +#ifdef GRUB_MACHINE_MIPS_YEELOONG grub_snprintf (linux_envs, sizeof ("memsize=XXXXXXXXXXXXXXXXXXXX"), "memsize=%lld", (unsigned long long) grub_mmap_get_lower () >> 20); @@ -338,8 +341,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + target_addr; linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4); - linux_envp[4] = 0; +#else + linux_envp[0] = 0; +#endif grub_loader_set (grub_linux_boot, grub_linux_unload, 1); initrd_loaded = 0; diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 3141f0028..e4a630d03 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -671,6 +671,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN); } +#if defined (__i386) || defined (__x86_64__) || defined (GRUB_MACHINE_MIPS_YEELOONG) { struct multiboot_tag_basic_meminfo *tag = (struct multiboot_tag_basic_meminfo *) ptrorig; @@ -682,6 +683,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) tag->mem_upper = grub_mmap_get_upper () / 1024; ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN); } +#endif if (bootdev_set) { diff --git a/include/grub/mips/qemu_mips/cmos.h b/include/grub/mips/qemu_mips/cmos.h new file mode 100644 index 000000000..4aef40e81 --- /dev/null +++ b/include/grub/mips/qemu_mips/cmos.h @@ -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 . + */ + +#ifndef GRUB_CPU_CMOS_H +#define GRUB_CPU_CMOS_H 1 + +#include +#include + +#define GRUB_CMOS_ADDR_REG 0xb4000070 +#define GRUB_CMOS_DATA_REG 0xb4000071 + +#endif /* GRUB_CPU_CMOS_H */ diff --git a/include/grub/mips/qemu-mips/kernel.h b/include/grub/mips/qemu_mips/kernel.h similarity index 97% rename from include/grub/mips/qemu-mips/kernel.h rename to include/grub/mips/qemu_mips/kernel.h index 230455dbf..c08405e83 100644 --- a/include/grub/mips/qemu-mips/kernel.h +++ b/include/grub/mips/qemu_mips/kernel.h @@ -20,7 +20,6 @@ #define GRUB_KERNEL_MACHINE_HEADER 1 #include -#include #ifndef ASM_FILE diff --git a/include/grub/mips/qemu-mips/loader.h b/include/grub/mips/qemu_mips/loader.h similarity index 100% rename from include/grub/mips/qemu-mips/loader.h rename to include/grub/mips/qemu_mips/loader.h diff --git a/include/grub/mips/qemu-mips/memory.h b/include/grub/mips/qemu_mips/memory.h similarity index 69% rename from include/grub/mips/qemu-mips/memory.h rename to include/grub/mips/qemu_mips/memory.h index 99d9ef2be..57220a1e2 100644 --- a/include/grub/mips/qemu-mips/memory.h +++ b/include/grub/mips/qemu_mips/memory.h @@ -28,11 +28,37 @@ #define GRUB_MACHINE_MEMORY_STACK_HIGH 0x80f00000 #define GRUB_MACHINE_MEMORY_USABLE 0x81000000 +#define GRUB_MACHINE_MEMORY_AVAILABLE 1 +#define GRUB_MACHINE_MEMORY_MAX_TYPE 1 + /* This one is special: it's used internally but is never reported + by firmware. */ +#define GRUB_MACHINE_MEMORY_HOLE 2 +#define GRUB_MACHINE_MEMORY_RESERVED GRUB_MACHINE_MEMORY_HOLE + #ifndef ASM_FILE + +typedef grub_addr_t grub_phys_addr_t; + +static inline grub_phys_addr_t +grub_vtop (void *a) +{ + return ((grub_phys_addr_t) a) & 0x1fffffff; +} + +static inline void * +grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused))) +{ + return (void *) (a | 0x80000000); +} + +static inline void +grub_unmap_memory (void *a __attribute__ ((unused)), + grub_size_t size __attribute__ ((unused))) +{ +} + 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 grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)), @@ -47,6 +73,7 @@ grub_machine_mmap_unregister (int handle __attribute__ ((unused))) { return GRUB_ERR_NONE; } + #endif #endif diff --git a/include/grub/mips/qemu-mips/serial.h b/include/grub/mips/qemu_mips/serial.h similarity index 100% rename from include/grub/mips/qemu-mips/serial.h rename to include/grub/mips/qemu_mips/serial.h diff --git a/include/grub/mips/qemu-mips/time.h b/include/grub/mips/qemu_mips/time.h similarity index 100% rename from include/grub/mips/qemu-mips/time.h rename to include/grub/mips/qemu_mips/time.h diff --git a/include/grub/offsets.h b/include/grub/offsets.h index 817372b69..fa609b16f 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -104,12 +104,26 @@ #define GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN 32 -#define GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE 0x8 -#define GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE 0xc +#define GRUB_KERNEL_MIPS_COMPRESSED_SIZE 0x8 +#define GRUB_KERNEL_MIPS_UNCOMPRESSED_SIZE 0xc -#define GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE 0x08 -#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX 0x0c -#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END 0x54 +#define GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE GRUB_KERNEL_MIPS_COMPRESSED_SIZE +#define GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE GRUB_KERNEL_MIPS_UNCOMPRESSED_SIZE + +#define GRUB_KERNEL_MIPS_QEMU_MIPS_COMPRESSED_SIZE GRUB_KERNEL_MIPS_COMPRESSED_SIZE +#define GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE GRUB_KERNEL_MIPS_UNCOMPRESSED_SIZE + +#define GRUB_KERNEL_MIPS_TOTAL_MODULE_SIZE 0x08 +#define GRUB_KERNEL_MIPS_PREFIX 0x0c +#define GRUB_KERNEL_MIPS_PREFIX_END 0x54 + +#define GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE GRUB_KERNEL_MIPS_TOTAL_MODULE_SIZE +#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX GRUB_KERNEL_MIPS_PREFIX +#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END GRUB_KERNEL_MIPS_PREFIX_END + +#define GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE GRUB_KERNEL_MIPS_TOTAL_MODULE_SIZE +#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX GRUB_KERNEL_MIPS_PREFIX +#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END GRUB_KERNEL_MIPS_PREFIX_END /* The offset of GRUB_PREFIX. */ #define GRUB_KERNEL_I386_EFI_PREFIX 0x8 @@ -144,7 +158,9 @@ #define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000 -#define GRUB_KERNEL_MIPS_YEELOONG_MOD_ALIGN 0x1 +#define GRUB_KERNEL_MIPS_MOD_ALIGN 0x1 +#define GRUB_KERNEL_MIPS_YEELOONG_MOD_ALIGN GRUB_KERNEL_MIPS_MOD_ALIGN +#define GRUB_KERNEL_MIPS_QEMU_MIPS_MOD_ALIGN GRUB_KERNEL_MIPS_MOD_ALIGN /* 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