312 lines
9.8 KiB
Diff
312 lines
9.8 KiB
Diff
|
From f38ada424e7d991a0121253ba1abc430b86a990b Mon Sep 17 00:00:00 2001
|
||
|
From: John Jolly <jjolly@suse.de>
|
||
|
Date: Wed, 22 Jan 2014 01:18:10 -0700
|
||
|
Subject: [PATCH 1/3] - Changes made and files added in order to allow s390x
|
||
|
build
|
||
|
|
||
|
---
|
||
|
grub-core/kern/emu/cache_s.S | 1 +
|
||
|
grub-core/kern/emu/lite.c | 2 ++
|
||
|
grub-core/kern/s390x/dl.c | 37 +++++++++++++++++++++++++++++++++++
|
||
|
grub-core/lib/s390x/setjmp.S | 46 ++++++++++++++++++++++++++++++++++++++++++++
|
||
|
grub-core/lib/setjmp.S | 2 ++
|
||
|
include/grub/cache.h | 2 +-
|
||
|
include/grub/s390x/setjmp.h | 29 ++++++++++++++++++++++++++++
|
||
|
include/grub/s390x/time.h | 27 ++++++++++++++++++++++++++
|
||
|
include/grub/s390x/types.h | 32 ++++++++++++++++++++++++++++++
|
||
|
9 files changed, 177 insertions(+), 1 deletion(-)
|
||
|
create mode 100644 grub-core/kern/s390x/dl.c
|
||
|
create mode 100644 grub-core/lib/s390x/setjmp.S
|
||
|
create mode 100644 include/grub/s390x/setjmp.h
|
||
|
create mode 100644 include/grub/s390x/time.h
|
||
|
create mode 100644 include/grub/s390x/types.h
|
||
|
|
||
|
diff --git a/grub-core/kern/emu/cache_s.S b/grub-core/kern/emu/cache_s.S
|
||
|
index 8ca695c..83e52d6 100644
|
||
|
--- a/grub-core/kern/emu/cache_s.S
|
||
|
+++ b/grub-core/kern/emu/cache_s.S
|
||
|
@@ -24,6 +24,7 @@ FUNCTION (grub_arch_sync_caches)
|
||
|
#elif defined(__powerpc__)
|
||
|
#include "../powerpc/cache.S"
|
||
|
#elif defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__)
|
||
|
+#elif defined(__s390x__)
|
||
|
#else
|
||
|
#error "No target cpu type is defined"
|
||
|
#endif
|
||
|
diff --git a/grub-core/kern/emu/lite.c b/grub-core/kern/emu/lite.c
|
||
|
index 947c669..4e15872 100644
|
||
|
--- a/grub-core/kern/emu/lite.c
|
||
|
+++ b/grub-core/kern/emu/lite.c
|
||
|
@@ -17,6 +17,8 @@
|
||
|
#elif defined(__aarch64__)
|
||
|
#include "../arm64/dl_helper.c"
|
||
|
#include "../arm64/dl.c"
|
||
|
+#elif defined(__s390x__)
|
||
|
+#include "../s390x/dl.c"
|
||
|
#else
|
||
|
#error "No target cpu type is defined"
|
||
|
#endif
|
||
|
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
|
||
|
--- a/grub-core/kern/dl.c
|
||
|
+++ b/grub-core/kern/dl.c
|
||
|
@@ -229,7 +229,7 @@
|
||
|
unsigned i;
|
||
|
const Elf_Shdr *s;
|
||
|
grub_size_t tsize = 0, talign = 1;
|
||
|
-#if !defined (__i386__) && !defined (__x86_64__)
|
||
|
+#if !defined (__i386__) && !defined (__x86_64__) && !defined (__s390x__)
|
||
|
grub_size_t tramp;
|
||
|
grub_size_t got;
|
||
|
grub_err_t err;
|
||
|
@@ -245,7 +245,7 @@
|
||
|
talign = s->sh_addralign;
|
||
|
}
|
||
|
|
||
|
-#if !defined (__i386__) && !defined (__x86_64__)
|
||
|
+#if !defined (__i386__) && !defined (__x86_64__) && !defined (__s390x__)
|
||
|
err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
|
||
|
if (err)
|
||
|
return err;
|
||
|
@@ -308,7 +308,7 @@
|
||
|
mod->segment = seg;
|
||
|
}
|
||
|
}
|
||
|
-#if !defined (__i386__) && !defined (__x86_64__)
|
||
|
+#if !defined (__i386__) && !defined (__x86_64__) && !defined (__s390x__)
|
||
|
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||
|
mod->tramp = ptr;
|
||
|
mod->trampptr = ptr;
|
||
|
diff --git a/grub-core/kern/s390x/dl.c b/grub-core/kern/s390x/dl.c
|
||
|
new file mode 100644
|
||
|
index 0000000..9be5a9e
|
||
|
--- /dev/null
|
||
|
+++ b/grub-core/kern/s390x/dl.c
|
||
|
@@ -0,0 +1,40 @@
|
||
|
+/* dl.c - arch-dependent part of loadable module support */
|
||
|
+/*
|
||
|
+ * GRUB -- GRand Unified Bootloader
|
||
|
+ * Copyright (C) 2002,2004,2005,2007,2009 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/dl.h>
|
||
|
+
|
||
|
+/* Check if EHDR is a valid ELF header. */
|
||
|
+grub_err_t
|
||
|
+grub_arch_dl_check_header (void *ehdr)
|
||
|
+{
|
||
|
+ (void)(ehdr);
|
||
|
+ return GRUB_ERR_BUG;
|
||
|
+}
|
||
|
+
|
||
|
+/* Relocate symbols. */
|
||
|
+grub_err_t
|
||
|
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||
|
+ Elf_Shdr *s, grub_dl_segment_t seg)
|
||
|
+{
|
||
|
+ (void)(mod);
|
||
|
+ (void)(ehdr);
|
||
|
+ (void)(s);
|
||
|
+ (void)(seg);
|
||
|
+ return GRUB_ERR_BUG;
|
||
|
+}
|
||
|
diff --git a/grub-core/lib/s390x/setjmp.S b/grub-core/lib/s390x/setjmp.S
|
||
|
new file mode 100644
|
||
|
index 0000000..a3ae29b
|
||
|
--- /dev/null
|
||
|
+++ b/grub-core/lib/s390x/setjmp.S
|
||
|
@@ -0,0 +1,46 @@
|
||
|
+/*
|
||
|
+ * GRUB -- GRand Unified Bootloader
|
||
|
+ * Copyright (C) 2005,2007,2009 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>
|
||
|
+#include <grub/dl.h>
|
||
|
+
|
||
|
+ .file "setjmp.S"
|
||
|
+
|
||
|
+GRUB_MOD_LICENSE "GPLv3+"
|
||
|
+
|
||
|
+ .text
|
||
|
+
|
||
|
+/*
|
||
|
+ * int grub_setjmp (grub_jmp_buf env)
|
||
|
+ */
|
||
|
+FUNCTION(grub_setjmp)
|
||
|
+ stmg %r11,%r15,0(%r2)
|
||
|
+ lghi %r2,0
|
||
|
+ br %r14
|
||
|
+
|
||
|
+/*
|
||
|
+ * int grub_longjmp (grub_jmp_buf env, int val)
|
||
|
+ */
|
||
|
+FUNCTION(grub_longjmp)
|
||
|
+ chi %r3,0
|
||
|
+ jne .L2
|
||
|
+ lghi %r3,1
|
||
|
+.L2:
|
||
|
+ lmg %r11,%r15,0(%r2)
|
||
|
+ lgr %r2,%r3
|
||
|
+ br %r14
|
||
|
diff --git a/grub-core/lib/setjmp.S b/grub-core/lib/setjmp.S
|
||
|
index 2e49742..0b6fb93 100644
|
||
|
--- a/grub-core/lib/setjmp.S
|
||
|
+++ b/grub-core/lib/setjmp.S
|
||
|
@@ -11,6 +11,8 @@
|
||
|
#include "./arm/setjmp.S"
|
||
|
#elif defined(__aarch64__)
|
||
|
#include "./arm64/setjmp.S"
|
||
|
+#elif defined(__s390x__)
|
||
|
+#include "./s390x/setjmp.S"
|
||
|
#else
|
||
|
#error "Unknown target cpu type"
|
||
|
#endif
|
||
|
diff --git a/include/grub/cache.h b/include/grub/cache.h
|
||
|
index 2928305..9f8e42b 100644
|
||
|
--- a/include/grub/cache.h
|
||
|
+++ b/include/grub/cache.h
|
||
|
@@ -27,7 +27,7 @@
|
||
|
#include <grub/symbol.h>
|
||
|
#include <grub/types.h>
|
||
|
|
||
|
-#if defined (__i386__) || defined (__x86_64__)
|
||
|
+#if defined (__i386__) || defined (__x86_64__) || defined (__s390x__)
|
||
|
static inline void
|
||
|
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||
|
grub_size_t len __attribute__ ((unused)))
|
||
|
diff --git a/include/grub/s390x/setjmp.h b/include/grub/s390x/setjmp.h
|
||
|
new file mode 100644
|
||
|
index 0000000..5ed87ed
|
||
|
--- /dev/null
|
||
|
+++ b/include/grub/s390x/setjmp.h
|
||
|
@@ -0,0 +1,29 @@
|
||
|
+/*
|
||
|
+ * GRUB -- GRand Unified Bootloader
|
||
|
+ * Copyright (C) 2002,2004,2006,2007,2009 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
|
||
|
+
|
||
|
+#include <grub/types.h>
|
||
|
+
|
||
|
+typedef grub_uint64_t grub_jmp_buf[5];
|
||
|
+
|
||
|
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((returns_twice));
|
||
|
+void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
|
||
|
+
|
||
|
+#endif /* ! GRUB_SETJMP_CPU_HEADER */
|
||
|
diff --git a/include/grub/s390x/time.h b/include/grub/s390x/time.h
|
||
|
new file mode 100644
|
||
|
index 0000000..1af9274
|
||
|
--- /dev/null
|
||
|
+++ b/include/grub/s390x/time.h
|
||
|
@@ -0,0 +1,27 @@
|
||
|
+/*
|
||
|
+ * GRUB -- GRand Unified Bootloader
|
||
|
+ * Copyright (C) 2007 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
|
||
|
+
|
||
|
+static __inline void
|
||
|
+grub_cpu_idle (void)
|
||
|
+{
|
||
|
+}
|
||
|
+
|
||
|
+#endif /* ! KERNEL_CPU_TIME_HEADER */
|
||
|
diff --git a/include/grub/s390x/types.h b/include/grub/s390x/types.h
|
||
|
new file mode 100644
|
||
|
index 0000000..249ca8a
|
||
|
--- /dev/null
|
||
|
+++ b/include/grub/s390x/types.h
|
||
|
@@ -0,0 +1,32 @@
|
||
|
+/*
|
||
|
+ * GRUB -- GRand Unified Bootloader
|
||
|
+ * Copyright (C) 2002,2004,2006,2007 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
|
||
|
+
|
||
|
+/* s390x is big-endian. */
|
||
|
+#define GRUB_TARGET_WORDS_BIGENDIAN 1
|
||
|
+
|
||
|
+
|
||
|
+#endif /* ! GRUB_TYPES_CPU_HEADER */
|
||
|
--
|
||
|
1.7.12.4
|
||
|
|