mips64: Add support for 64-bit MIPS.
PATCH v2 1/1 mips64: Add support for 64-bit MIPS.
From: Heiher <[email protected]>
--- configure.ac | 21 ++- gentpl.py | 5 +- grub-core/Makefile.am | 6 + grub-core/Makefile.core.def | 13 ++ grub-core/kern/mips64/cache.S | 23 ++++ grub-core/kern/mips64/dl.c | 150 +++++++++++++++++++++ grub-core/kern/mips64/efi/init.c | 44 ++++++ grub-core/kern/mips64/efi/startup.S | 47 +++++++ grub-core/kern/mips64/init.c | 47 +++++++ grub-core/lib/efi/halt.c | 2 +- grub-core/lib/mips64/setjmp.S | 69 ++++++++++ grub-core/lib/setjmp.S | 4 + grub-core/term/serial.c | 8 +- include/grub/cache.h | 2 +- include/grub/dl.h | 8 +- include/grub/efi/api.h | 2 +- include/grub/efi/pe32.h | 5 + include/grub/mips64/asm.h | 10 ++ include/grub/mips64/efi/boot.h | 0 include/grub/mips64/efi/loader.h | 25 ++++ include/grub/mips64/efi/memory.h | 6 + include/grub/mips64/efi/time.h | 0 include/grub/mips64/io.h | 62 +++++++++ include/grub/mips64/kernel.h | 24 ++++ include/grub/mips64/memory.h | 56 ++++++++ include/grub/mips64/mips.h | 30 +++++ include/grub/mips64/setjmp.h | 27 ++++ include/grub/mips64/time.h | 39 ++++++ include/grub/mips64/types.h | 38 ++++++ include/grub/misc.h | 2 +- include/grub/serial.h | 6 +- include/grub/util/install.h | 1 + util/grub-install-common.c | 1 + util/grub-install.c | 18 +++ util/grub-mkimagexx.c | 259 ++++++++++++++++++++++++++++++++++-- util/grub-mknetdir.c | 3 +- util/grub-mkrescue.c | 9 +- util/grub-module-verifier.c | 13 ++ util/grub-module-verifierXX.c | 11 +- util/mkimage.c | 16 +++ 40 files changed, 1078 insertions(+), 34 deletions(-) create mode 100644 grub-core/kern/mips64/cache.S create mode 100644 grub-core/kern/mips64/dl.c create mode 100644 grub-core/kern/mips64/efi/init.c create mode 100644 grub-core/kern/mips64/efi/startup.S create mode 100644 grub-core/kern/mips64/init.c create mode 100644 grub-core/lib/mips64/setjmp.S create mode 100644 include/grub/mips64/asm.h create mode 100644 include/grub/mips64/efi/boot.h create mode 100644 include/grub/mips64/efi/loader.h create mode 100644 include/grub/mips64/efi/memory.h create mode 100644 include/grub/mips64/efi/time.h create mode 100644 include/grub/mips64/io.h create mode 100644 include/grub/mips64/kernel.h create mode 100644 include/grub/mips64/memory.h create mode 100644 include/grub/mips64/mips.h create mode 100644 include/grub/mips64/setjmp.h create mode 100644 include/grub/mips64/time.h create mode 100644 include/grub/mips64/types.h
configure.ac +18 -3
@@ -86,7 +86,11 @@ case "$target_cpu" in i[[3456]]86) target_cpu=i386 ;; amd64) target_cpu=x86_64 ;; sparc) target_cpu=sparc64 ;; - mipsel|mips64el) + mips64el) + target_cpu=mips64el + machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS64EL=1" + ;; + mipsel) target_cpu=mipsel machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1" ;;
@@ -118,6 +122,7 @@ if test "x$with_platform" = x; then powerpc64-*) platform=ieee1275 ;; powerpc64le-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;; + mips64el-*) platform=efi;; mipsel-*) platform=loongson ;; mips-*) platform=arc ;; ia64-*) platform=efi ;;
@@ -166,6 +171,7 @@ case "$target_cpu"-"$platform" in mipsel-yeeloong) platform=loongson ;; mipsel-fuloong) platform=loongson ;; mipsel-loongson) ;; + mips64el-efi) ;; arm-uboot) ;; arm-efi) ;; arm64-efi) ;;
@@ -1234,10 +1240,15 @@ grub_CHECK_PIC # movk's which aren't representable. # Since default varies across dictributions use either -fPIC or -fno-PIC # explicitly. -if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 ) && test "x$grub_cv_cc_target_clang" = xyes ; then +if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 || test x$target_cpu = xmips64el ) && test "x$grub_cv_cc_target_clang" = xyes ; then TARGET_CFLAGS="$TARGET_CFLAGS -fPIC" elif [ x"$pic_possible" = xyes ]; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC" +fi +# Don't generate SVR4-style position-independent code for MIPS64. +if test x$target_cpu = xmips64el ; then + TARGET_CFLAGS="$TARGET_CFLAGS -mno-abicalls" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mno-abicalls" fi] CFLAGS="$TARGET_CFLAGS"
@@ -1894,12 +1905,14 @@ AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen]) AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen]) +AM_CONDITIONAL([COND_mips64_efi], [test x$target_cpu = xmips64el -a x$platform = xefi]) AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson]) AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips]) AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc]) AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) +AM_CONDITIONAL([COND_mips64el], [test x$target_cpu = xmips64el]) AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
@@ -1956,7 +1969,9 @@ AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir]) # Output files. if test "$platform" != none; then cpudir="${target_cpu}" - if test x${cpudir} = xmipsel; then + if test x${cpudir} = xmips64el; then + cpudir=mips64; + elif test x${cpudir} = xmipsel; then cpudir=mips; fi grub_CHECK_LINK_DIR
gentpl.py +3 -2
@@ -29,7 +29,7 @@ import re GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275", "x86_64_efi", "i386_xen", "x86_64_xen", - "mips_loongson", "sparc64_ieee1275", + "mips_loongson", "mips64_efi", "sparc64_ieee1275", "powerpc_ieee1275", "mips_arc", "ia64_efi", "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi" ]
@@ -42,13 +42,14 @@ GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i38 GROUPS["x86_64"] = [ "x86_64_efi" ] GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] GROUPS["mips"] = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ] +GROUPS["mips64"] = [ "mips64_efi" ] GROUPS["sparc64"] = [ "sparc64_ieee1275" ] GROUPS["powerpc"] = [ "powerpc_ieee1275" ] GROUPS["arm"] = [ "arm_uboot", "arm_efi" ] GROUPS["arm64"] = [ "arm64_efi" ] # Groups based on firmware -GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" ] +GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi", "mips64_efi" ] GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] GROUPS["uboot"] = [ "arm_uboot" ] GROUPS["xen"] = [ "i386_xen", "x86_64_xen" ]
grub-core/Makefile.am +6 -0
@@ -216,6 +216,12 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h endif +if COND_mips64_efi +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.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
grub-core/Makefile.core.def +13 -0
@@ -93,6 +93,9 @@ kernel = { arm_uboot_ldflags = '-Wl,-r,-d'; arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; + mips64_efi_ldflags = '-Wl,-r,-d'; + mips64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame -R .MIPS.abiflags'; + i386_pc_startup = kern/i386/pc/startup.S; i386_efi_startup = kern/i386/efi/startup.S; x86_64_efi_startup = kern/x86_64/efi/startup.S;
@@ -103,6 +106,7 @@ kernel = { i386_coreboot_startup = kern/i386/coreboot/startup.S; i386_multiboot_startup = kern/i386/coreboot/startup.S; mips_startup = kern/mips/startup.S; + mips64_efi_startup = kern/mips64/efi/startup.S; sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S; powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S; arm_uboot_startup = kern/arm/uboot/startup.S;
@@ -263,6 +267,12 @@ kernel = { extra_dist = video/sis315_init.c; mips_loongson = commands/keylayouts.c; + mips64 = kern/mips64/init.c; + mips64 = kern/mips64/dl.c; + mips64 = kern/mips64/cache.S; + mips64 = kern/generic/rtc_get_time_ms.c; + mips64_efi = kern/mips64/efi/init.c; + powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
@@ -750,6 +760,7 @@ module = { enable = sparc64_ieee1275; enable = powerpc_ieee1275; enable = mips_arc; + enable = mips64_efi; enable = ia64_efi; enable = arm_efi; enable = arm64_efi;
@@ -853,6 +864,7 @@ module = { mips_arc = lib/mips/arc/reboot.c; mips_loongson = lib/mips/loongson/reboot.c; mips_qemu_mips = lib/mips/qemu_mips/reboot.c; + mips64_efi = lib/efi/reboot.c; xen = lib/xen/reboot.c; uboot = lib/uboot/reboot.c; common = commands/reboot.c;
@@ -1762,6 +1774,7 @@ module = { enable = arm_efi; enable = arm64_efi; enable = mips; + enable = mips64_efi; }; module = {
grub-core/kern/mips64/cache.S new file +23 -0
@@ -0,0 +1,23 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009,2017 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/>. + */ + +#include <grub/symbol.h> + +FUNCTION (grub_arch_sync_caches) + jr.hb $ra +
grub-core/kern/mips64/dl.c new file +150 -0
150 lines not on this page · raw message
grub-core/kern/mips64/efi/init.c new file +44 -0
44 lines not on this page · raw message
grub-core/kern/mips64/efi/startup.S new file +47 -0
47 lines not on this page · raw message
grub-core/kern/mips64/init.c new file +47 -0
47 lines not on this page · raw message
grub-core/lib/efi/halt.c +1 -1
@@ -29,7 +29,7 @@ voidgrub_halt (void) {grub_machine_fini (GRUB_LOADER_FLAG_NORETURN ); -#if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) +#if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__mips__)grub_acpi_halt ();#endif efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
grub-core/lib/mips64/setjmp.S new file +69 -0
69 lines not on this page · raw message
grub-core/lib/setjmp.S +4 -0
@@ -5,7 +5,11 @@ #elif defined(__sparc__) #include "./sparc64/setjmp.S" #elif defined(__mips__) +#if _MIPS_SIM == _ABI64 +#include "./mips64/setjmp.S" +#else #include "./mips/setjmp.S" +#endif #elif defined(__powerpc__) || defined(__PPC__) #include "./powerpc/setjmp.S" #elif defined(__ia64__)
grub-core/term/serial.c +4 -4
@@ -22,7 +22,7 @@#include <grub/dl.h> #include <grub/misc.h> #include <grub/terminfo.h> -#if !defined (GRUB_MACHINE_EMU ) && (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) +#if !defined (GRUB_MACHINE_EMU ) && ((defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__))#include <grub/cpu/io.h> #endif #include <grub/extcmd.h>
@@ -151,7 +151,7 @@ grub_serial_find (const char *name)if (grub_strcmp (port->name, name) ==0 )break ; -#if (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) && !defined(GRUB_MACHINE_EMU ) && !defined(GRUB_MACHINE_ARC ) +#if ((defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)) && !defined(GRUB_MACHINE_EMU ) && !defined(GRUB_MACHINE_ARC )if (!port &&grub_memcmp (name,"port" ,sizeof ("port" ) -1 ) ==0 &&grub_isxdigit (name [sizeof ("port" ) -1 ])) {
@@ -286,7 +286,7 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) err = port->driver->configure (port, &config);if (err)return err; -#if !defined (GRUB_MACHINE_EMU ) && !defined(GRUB_MACHINE_ARC ) && (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) +#if !defined (GRUB_MACHINE_EMU ) && !defined(GRUB_MACHINE_ARC ) && ((defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__))/* Compatibility kludge. */ if (port->driver == &grub_ns8250_driver)
@@ -436,7 +436,7 @@ GRUB_MOD_INIT(serial) &grub_serial_terminfo_input_template, sizeof (grub_serial_terminfo_input)); -#if !defined (GRUB_MACHINE_EMU ) && !defined(GRUB_MACHINE_ARC ) && (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) +#if !defined (GRUB_MACHINE_EMU ) && !defined(GRUB_MACHINE_ARC ) && ((defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__))grub_ns8250_init ();#endif #ifdef GRUB_MACHINE_IEEE1275
include/grub/cache.h +1 -1
@@ -34,7 +34,7 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);#endif #ifndef GRUB_MACHINE_EMU -#ifdef _mips +#if defined(__mips__) && (_MIPS_SIM != _ABI64)void EXPORT_FUNC (grub_arch_sync_dma_caches ) (volatile void *address,grub_size_t len);#else
include/grub/dl.h +4 -4
@@ -187,7 +187,7 @@ struct grub_dlvoid *tramp;void *trampptr;#endif -#ifdef __mips__ +#if defined(__mips__) && (_MIPS_SIM != _ABI64)grub_uint32_t *reginfo;#endif void *base;
@@ -252,7 +252,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, Elf_Shdr *s, grub_dl_segment_t seg);#endif -#if defined (_mips) +#if defined (__mips__) && (_MIPS_SIM != _ABI64)#define GRUB_LINKER_HAVE_INIT 1void grub_arch_dl_init_linker (void );#endif
@@ -279,12 +279,12 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, grub_size_t *got);#endif -#if defined (__powerpc__) || defined (__mips__) || defined (__arm__) +#if defined (__powerpc__) || (defined (__mips__) && (_MIPS_SIM != _ABI64)) || defined (__arm__)#define GRUB_ARCH_DL_TRAMP_ALIGN 4#define GRUB_ARCH_DL_GOT_ALIGN 4#endif -#if defined (__aarch64__) || defined (__sparc__) +#if defined (__aarch64__) || defined (__sparc__) || (defined (__mips__) && (_MIPS_SIM == _ABI64))#define GRUB_ARCH_DL_TRAMP_ALIGN 8#define GRUB_ARCH_DL_GOT_ALIGN 8#endif
include/grub/efi/api.h +1 -1
@@ -1686,7 +1686,7 @@ struct grub_efi_block_iotypedef struct grub_efi_block_io grub_efi_block_io_t ;#if (GRUB_TARGET_SIZEOF_VOID_P ==4 ) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) + || defined (__aarch64__) || defined(__mips__) || defined (__MINGW64__) || defined (__CYGWIN__)#define efi_call_0 (func) func()#define efi_call_1 (func, a) func(a)
include/grub/efi/pe32.h +5 -0
@@ -64,6 +64,7 @@ struct grub_pe32_coff_header };#define GRUB_PE32_MACHINE_I386 0x14c +#define GRUB_PE32_MACHINE_MIPS 0x166#define GRUB_PE32_MACHINE_IA64 0x200#define GRUB_PE32_MACHINE_X86_64 0x8664#define GRUB_PE32_MACHINE_ARMTHUMB_MIXED 0x01c2
@@ -278,6 +279,10 @@ struct grub_pe32_fixup_block#define GRUB_PE32_REL_BASED_HIGHLOW 3#define GRUB_PE32_REL_BASED_HIGHADJ 4#define GRUB_PE32_REL_BASED_MIPS_JMPADDR 5 +#define GRUB_PE32_REL_BASED_MIPS_LOW 6 +#define GRUB_PE32_REL_BASED_MIPS_HIGH 4 +#define GRUB_PE32_REL_BASED_MIPS_HIGHER 7 +#define GRUB_PE32_REL_BASED_MIPS_HIGHEST 8#define GRUB_PE32_REL_BASED_ARM_MOV32A 5#define GRUB_PE32_REL_BASED_SECTION 6#define GRUB_PE32_REL_BASED_REL 7
include/grub/mips64/asm.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef GRUB_MIPS64_ASM_HEADER +#define GRUB_MIPS64_ASM_HEADER 1 + +#define GRUB_ASM_T4 $a4 +#define GRUB_ASM_T5 $a5 +#define GRUB_ASM_SZREG 8 +#define GRUB_ASM_REG_S sd +#define GRUB_ASM_REG_L ld + +#endif
include/grub/mips64/efi/boot.h new file +0 -0
include/grub/mips64/efi/loader.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2003,2004,2006,2007,2017 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_LOADER_MACHINE_HEADER +#define GRUB_LOADER_MACHINE_HEADER 1 + +#include <grub/types.h> +#include <grub/symbol.h> + +#endif /* ! GRUB_LOADER_MACHINE_HEADER */
include/grub/mips64/efi/memory.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER +#include <grub/efi/memory.h> + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0x980000000fffffffUL + +#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/mips64/efi/time.h new file +0 -0
include/grub/mips64/io.h new file +62 -0
62 lines not on this page · raw message
include/grub/mips64/kernel.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2005,2006,2007,2008,2009,2017 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_KERNEL_CPU_HEADER +#define GRUB_KERNEL_CPU_HEADER 1 + +#include <grub/symbol.h> + +#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
include/grub/mips64/memory.h new file +56 -0
56 lines not on this page · raw message
include/grub/mips64/mips.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2010,2017 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_REGISTERS_CPU_HEADER +#define GRUB_REGISTERS_CPU_HEADER 1 + +#ifdef ASM_FILE +#define GRUB_CPU_REGISTER_WRAP (x) x +#else +#define GRUB_CPU_REGISTER_WRAP (x) #x +#endif + +#define GRUB_CPU_MIPS_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9) + +#endif
include/grub/mips64/setjmp.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2004,2006,2007,2009,2017 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_SETJMP_CPU_HEADER +#define GRUB_SETJMP_CPU_HEADER 1 + +typedef grub_uint64_t grub_jmp_buf [12 ]; + +int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE; +void grub_longjmp (grub_jmp_buf env,int val) __attribute__ ((noreturn)); + +#endif /* ! GRUB_SETJMP_CPU_HEADER */
include/grub/mips64/time.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2003,2004,2005,2007,2017 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 KERNEL_CPU_TIME_HEADER +#define KERNEL_CPU_TIME_HEADER 1 + +#ifndef GRUB_UTIL + +#define GRUB_TICKS_PER_SECOND (grub_arch_cpuclock / 2) + +void grub_timer_init (grub_uint32_t cpuclock); + +/* Return the real time in ticks. */ +grub_uint64_t grub_get_rtc (void ); + +extern grub_uint32_t grub_arch_cpuclock; +#endif + +static inline void +grub_cpu_idle (void ) +{ +} + +#endif
include/grub/mips64/types.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2006,2007,2009,2017 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_TYPES_CPU_HEADER +#define GRUB_TYPES_CPU_HEADER 1 + +/* The size of void *. */ +#define GRUB_TARGET_SIZEOF_VOID_P 8 + +/* The size of long. */ +#define GRUB_TARGET_SIZEOF_LONG 8 + +#ifdef GRUB_CPU_MIPS64EL +/* mips64EL is little-endian. */ +#undef GRUB_TARGET_WORDS_BIGENDIAN +#elif defined (GRUB_CPU_MIPS64 ) +/* mips64 is big-endian. */ +#define GRUB_TARGET_WORDS_BIGENDIAN +#elif !defined (GRUB_SYMBOL_GENERATOR ) +#error Neither GRUB_CPU_MIPS64 nor GRUB_CPU_MIPS64EL is defined +#endif + +#endif /* ! GRUB_TYPES_CPU_HEADER */
include/grub/misc.h +1 -1
@@ -410,7 +410,7 @@ void __attribute__ ((noreturn)) EXPORT_FUNC (abort) (void);/* Halt the system, using APM if possible. If NO_APM is true, don't * use APM even if it is available. */ void grub_halt (int no_apm) __attribute__ ((noreturn)); -#elif defined (__mips__) && !defined (GRUB_MACHINE_EMU ) +#elif (defined (__mips__) && (_MIPS_SIM != _ABI64)) && !defined (GRUB_MACHINE_EMU )void EXPORT_FUNC (grub_halt ) (void ) __attribute__ ((noreturn));#else void grub_halt (void ) __attribute__ ((noreturn));
include/grub/serial.h +3 -3
@@ -21,7 +21,7 @@#define GRUB_SERIAL_HEADER 1#include <grub/types.h> -#if defined(__mips__) || defined (__i386__) || defined (__x86_64__) +#if (defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)#include <grub/cpu/io.h> #endif #include <grub/usb.h>
@@ -86,7 +86,7 @@ struct grub_serial_port*/ union { -#if defined(__mips__) || defined (__i386__) || defined (__x86_64__) +#if (defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)grub_port_t port;#endif struct
@@ -175,7 +175,7 @@ grub_serial_config_defaults (struct grub_serial_port *port)return port->driver->configure (port, &config); } -#if defined(__mips__) || defined (__i386__) || defined (__x86_64__) +#if (defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)void grub_ns8250_init (void );char *grub_serial_ns8250_add_port (grub_port_t port);#endif
include/grub/util/install.h +1 -0
@@ -99,6 +99,7 @@ enum grub_install_platGRUB_INSTALL_PLATFORM_I386_XEN ,GRUB_INSTALL_PLATFORM_X86_64_XEN ,GRUB_INSTALL_PLATFORM_ARM64_EFI , +GRUB_INSTALL_PLATFORM_MIPS64EL_EFI , GRUB_INSTALL_PLATFORM_MAX };
util/grub-install-common.c +1 -0
@@ -665,6 +665,7 @@ static struct [GRUB_INSTALL_PLATFORM_IA64_EFI] = { "ia64", "efi" }, [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm", "efi" }, [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64", "efi" }, + [GRUB_INSTALL_PLATFORM_MIPS64EL_EFI] = { "mips64el","efi" }, [GRUB_INSTALL_PLATFORM_ARM_UBOOT] = { "arm", "uboot" }, };
util/grub-install.c +18 -0
@@ -313,7 +313,11 @@ get_default_platform (void)#elif defined (__sparc__) || defined (__sparc64__)return "sparc64-ieee1275" ;#elif defined (__MIPSEL__) +#if _MIPS_SIM == _ABI64 +return "mips64el-efi" ; +#else return "mipsel-loongson" ; +#endif #elif defined (__MIPSEB__)return "mips-arc" ;#elif defined (__ia64__)
@@ -477,6 +481,7 @@ have_bootdev (enum grub_install_plat pl)case GRUB_INSTALL_PLATFORM_IA64_EFI :case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_I386_IEEE1275 :case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275 :case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275 :
@@ -898,6 +903,7 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_X86_64_EFI :case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI :case GRUB_INSTALL_PLATFORM_I386_IEEE1275 :case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275 :
@@ -941,6 +947,7 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_X86_64_EFI :case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI :case GRUB_INSTALL_PLATFORM_I386_IEEE1275 :case GRUB_INSTALL_PLATFORM_ARM_UBOOT :
@@ -992,6 +999,7 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_X86_64_EFI :case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI : is_efi =1 ;break ;
@@ -1105,6 +1113,9 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_ARM64_EFI : efi_file ="BOOTAA64.EFI" ;break ; +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI : + efi_file ="BOOTMIPS64EL.EFI" ; +break ;default :grub_util_error ("%s" ,_ ("You've found a bug" ));break ;
@@ -1132,6 +1143,9 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_ARM64_EFI : efi_file ="grubaa64.efi" ;break ; +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI : + efi_file ="grubmips64el.efi" ; +break ;default : efi_file ="grub.efi" ;break ;
@@ -1434,6 +1448,7 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_X86_64_EFI :case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI : g =grub_util_guess_efi_drive (*curdev);break ;
@@ -1524,6 +1539,7 @@ main (int argc, char *argv[])case GRUB_INSTALL_PLATFORM_X86_64_EFI :case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI : core_name ="core.efi" ; snprintf (mkimage_target, sizeof (mkimage_target),
@@ -1625,6 +1641,7 @@ main (int argc, char *argv[])break ;case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI :case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS :case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS :
@@ -1853,6 +1870,7 @@ main (int argc, char *argv[]) }case GRUB_INSTALL_PLATFORM_ARM_EFI :case GRUB_INSTALL_PLATFORM_ARM64_EFI : +case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI :case GRUB_INSTALL_PLATFORM_IA64_EFI : {char *dst =grub_util_path_concat (2 , efidir, efi_file);
util/grub-mkimagexx.c +249 -10
338 lines not on this page · raw message
util/grub-mknetdir.c +2 -1
@@ -107,7 +107,8 @@ static const struct [GRUB_INSTALL_PLATFORM_X86_64_EFI] = { "x86_64-efi", "efinet", ".efi" }, [GRUB_INSTALL_PLATFORM_IA64_EFI] = { "ia64-efi", "efinet", ".efi" }, [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm-efi", "efinet", ".efi" }, - [GRUB_INSTALL_PLATFORM_ARM64_EFI ] = {"arm64-efi" ,"efinet" ,".efi" } + [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64-efi", "efinet", ".efi" }, + [GRUB_INSTALL_PLATFORM_MIPS64EL_EFI ] = {"mips64el-efi" ,"efinet" ,".efi" } }; static void
util/grub-mkrescue.c +8 -1
@@ -530,6 +530,7 @@ main (int argc, char *argv[]) || source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI] + || source_dirs[GRUB_INSTALL_PLATFORM_MIPS64EL_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI]) system_area =SYS_AREA_COMMON ; else if (source_dirs[GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275])
@@ -727,7 +728,8 @@ main (int argc, char *argv[]) || source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI] - || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI]) + || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI] + || source_dirs[GRUB_INSTALL_PLATFORM_MIPS64EL_EFI]) {char *efidir =grub_util_make_temporary_dir ();char *efidir_efi =grub_util_path_concat (2 , efidir,"efi" );
@@ -762,6 +764,11 @@ main (int argc, char *argv[]) imgname);free (imgname); + imgname =grub_util_path_concat (2 , efidir_efi_boot,"bootmips64el.efi" ); +make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_MIPS64EL_EFI ,"mips64el-efi" , + imgname); +free (imgname); +if (source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI ]) { imgname =grub_util_path_concat (2 , efidir_efi_boot,"boot.efi" );
util/grub-module-verifier.c +13 -0
@@ -118,6 +118,19 @@ struct grub_module_verifier_arch archs[] = { -1 } }, + {"mips64el" ,8 ,0 ,EM_MIPS ,GRUB_MODULE_VERIFY_SUPPORTS_REL |GRUB_MODULE_VERIFY_SUPPORTS_RELA , (int []){ +R_MIPS_64 , +R_MIPS_32 , +R_MIPS_26 , +R_MIPS_LO16 , +R_MIPS_HI16 , +R_MIPS_HIGHER , +R_MIPS_HIGHEST , +-1 + }, (int []){ +-1 + } + }, }; struct platform_whitelist {
util/grub-module-verifierXX.c +9 -2
@@ -296,7 +296,14 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *eif (target_seg_size <grub_target_to_host (rel->r_offset))grub_util_error ("reloc offset is out of the segment" ); -grub_uint32_t type =ELF_R_TYPE (grub_target_to_host (rel->r_info)); +grub_size_t r_info; +if (arch->machine ==EM_MIPS && arch->voidp_sizeof ==8 ) + r_info = ((grub_uint64_t ) rel->r_info <<32 ) | + (grub_uint32_t )grub_be_to_cpu64 (rel->r_info); +else + r_info =grub_target_to_host (rel->r_info); + +grub_uint32_t type =ELF_R_TYPE (r_info);if (arch->machine ==EM_SPARCV9 ) type &=0xff ;
@@ -313,7 +320,7 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *ebreak ;if (arch->short_relocations[i] ==-1 )grub_util_error ("unsupported relocation 0x%x" , type); - sym = (Elf_Sym *) ((char *) symtab + symtabentsize *ELF_R_SYM (grub_target_to_host (rel->r_info))); + sym = (Elf_Sym *) ((char *) symtab + symtabentsize *ELF_R_SYM (r_info));if (is_symbol_local (sym))continue ;
util/mkimage.c +16 -0
@@ -570,6 +570,22 @@ static const struct grub_install_image_target_desc image_targets[] = .pe_target = GRUB_PE32_MACHINE_ARM64, .elf_target = EM_AARCH64, }, + { + .dirname = "mips64el-efi", + .names = { "mips64el-efi", NULL }, + .voidp_sizeof = 8, + .bigendian = 0, + .id = IMAGE_EFI, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = TARGET_NO_FIELD, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .section_align = GRUB_PE32_SECTION_ALIGNMENT, + .vaddr_offset = EFI64_HEADER_SIZE, + .pe_target = GRUB_PE32_MACHINE_MIPS, + .elf_target = EM_MIPS, + }, }; #include <grub/lib/LzmaEnc.h>
Signature · 1 line
2.11.1
13.02.2017 18:57, [email protected] пишет:
Quoted 2 lines
From: Heiher <[email protected]>
Before going in more depth for review, could you give more details which platforms are using it, what ABI is targeted (n64? something else?) Is MIPS going to be included in official UEFI spec?
Quoted 8 lines · On Mon, 13 Feb 2017, 20:05 Andrei Borzenkov <[email protected]> wrote:
13.02.2017 18:57, [email protected] пишет:
Quoted 2 lines
From: Heiher <[email protected]>
Before going in more depth for review, could you give more details which platforms are using it, what ABI is targeted (n64? something else?) Is MIPS going to be included in official UEFI spec?
Also it seems that it targets yeeloong's and fuloong's we already support. I'd like a good justification for this port over existing ones as it will surely need maintenance, so we need a benefit to justify maintenance.
Quoted 6 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 8 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines · On Mon, 13 Feb 2017, 20:05 Andrei Borzenkov <[email protected]> wrote:
13.02.2017 18:57, [email protected] пишет:
Quoted 2 lines
From: Heiher <[email protected]>
Quoted 7 lines
Quoted 3 lines
Before going in more depth for review, could you give more details which platforms are using it, what ABI is targeted (n64? something else?) Is MIPS going to be included in official UEFI spec?
Also it seems that it targets yeeloong's and fuloong's we already support. I'd like a good justification for this port over existing ones as it will surely need maintenance, so we need a benefit to justify maintenance.
The yeeloong and fuloong are based on Loongson-2 cpu platforms, They have been discontinued. In future, The new products will switch to full 64-bit softwares
(from firmware to operating system).
The exist mips port is mips o32 ABI and for non UEFI platforms in GRUB, This port is
for MIPS n64 ABI and UEFI platform. I think using a new cpu type mips64 is better.
The code is clear for maintenance. ;)
Quoted 6 lines
Quoted 6 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 3 lines
Best regards! Heiher http://hev.cc
Hello,
What do you think about this patch set? thanks!
Quoted 44 lines · Heiher
Quoted 5 lines · Vladimir 'phcoder' Serbinenko
Quoted 2 lines · On Mon, 13 Feb 2017, 20:05 Andrei Borzenkov <[email protected]> wrote:
13.02.2017 18:57, [email protected] пишет:
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
From: Heiher <[email protected]>
Before going in more depth for review, could you give more details which platforms are using it, what ABI is targeted (n64? something else?) Is MIPS going to be included in official UEFI spec?
Also it seems that it targets yeeloong's and fuloong's we already
support.
Quoted 2 lines
I'd like a good justification for this port over existing ones as it will surely need maintenance, so we need a benefit to justify maintenance.
The yeeloong and fuloong are based on Loongson-2 cpu platforms, They have been discontinued. In future, The new products will switch to full 64-bit softwares
(from firmware to operating system).The exist mips port is mips o32 ABI and for non UEFI platforms in GRUB, This port is
for MIPS n64 ABI and UEFI platform. I think using a new cpu type mips64 is better.
The code is clear for maintenance. ;)Quoted 6 lines
Quoted 6 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel--
Best regards!
Heiher
http://hev.cc
Quoted 7 lines · Andrei Borzenkov
13.02.2017 18:57, [email protected] пишет:
Quoted 2 lines
From: Heiher <[email protected]>
Before going in more depth for review, could you give more details which platforms are using it, what ABI is targeted (n64? something else?) Is MIPS going to be included in official UEFI spec?
Right. This port is used for MIPS64-based UEFI platforms and Loongson-3's linux boot interface are supported.
The target ABI is standard mips n64, no-abicalls is enabled and long-jumps is disabled for kernel and modules.
Currently, The MIPS is not included in official UEFI spec, but Lemote will do it. Looks many MIPS cpus are used
for embedded platforms, so i think they are more use of lightweight firmware (e.g. u-boot, pmon ...)
The Lemote (http://www.lemote.com) is a MIPS OEM, It is porting UEFI (EDK) for MIPS-based desktop and
high-performance server.
Signature · 3 lines
Best regards! Heiher http://hev.cc