]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Some work for S390 phcoder/newports/s390
authorVladimir Serbinenko <phcoder@gmail.com>
Sun, 27 Oct 2013 00:11:29 +0000 (02:11 +0200)
committerVladimir Serbinenko <phcoder@gmail.com>
Sun, 27 Oct 2013 00:11:29 +0000 (02:11 +0200)
Makefile.util.def
configure.ac
gentpl.py
grub-core/Makefile.core.def
grub-core/partmap/dasd.c [new file with mode: 0644]

index 193bc4531d69ec04951bf448841fed95805b5261..4d2798d979cf91744f6c3a6c78256b5da3b4878a 100644 (file)
@@ -146,6 +146,7 @@ library = {
   common = grub-core/partmap/sunpc.c;
   common = grub-core/partmap/bsdlabel.c;
   common = grub-core/partmap/dfly.c;
+  common = grub-core/partmap/dasd.c;
   common = grub-core/script/function.c;
   common = grub-core/script/lexer.c;
   common = grub-core/script/main.c;
index e08aecb6c0e8da9419cdcb51a0014516db805eb1..43d230d270761c7651c69f6394d95b4dcf577ad1 100644 (file)
@@ -90,6 +90,7 @@ case "$target_cpu" in
   i[[3456]]86) target_cpu=i386 ;;
   amd64)       target_cpu=x86_64 ;;
   sparc)       target_cpu=sparc64 ;;
+  s390x)       target_cpu=s390 ;;
   mipsel|mips64el)
                 target_cpu=mipsel;
                machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
@@ -122,6 +123,7 @@ if test "x$with_platform" = x; then
     mips-*) platform=arc ;;
     ia64-*) platform=efi ;;
     arm-*) platform=uboot ;;
+    s390-* | s390x-*) platform=mainframe ;;
     *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
   esac
 else
@@ -159,6 +161,7 @@ case "$target_cpu"-"$platform" in
   mipsel-loongson) ;;
   arm-uboot) ;;
   arm-efi) ;;
+  s390-mainframe) ;;
   *-emu) ;;
   *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
 esac
@@ -1331,6 +1334,7 @@ AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target
 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_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
+AM_CONDITIONAL([COND_s390_mainframe], [test x$target_cpu = xs390 -a x$platform = xmainframe])
 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])
index 05f3f969bef3d1d6f9e77b1bd9e72f135764fdba..6052e46615bbdf157d9c53ffe19e0be4669cc639 100644 (file)
--- a/gentpl.py
+++ b/gentpl.py
@@ -23,7 +23,7 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
                    "i386_multiboot", "i386_ieee1275", "x86_64_efi",
                    "mips_loongson", "sparc64_ieee1275",
                    "powerpc_ieee1275", "mips_arc", "ia64_efi",
-                   "mips_qemu_mips", "arm_uboot", "arm_efi" ]
+                   "mips_qemu_mips", "arm_uboot", "arm_efi", "s390_mainframe" ]
 
 GROUPS = {}
 
@@ -37,6 +37,7 @@ GROUPS["mips"]     = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ]
 GROUPS["sparc64"]  = [ "sparc64_ieee1275" ]
 GROUPS["powerpc"]  = [ "powerpc_ieee1275" ]
 GROUPS["arm"]      = [ "arm_uboot", "arm_efi" ]
+GROUPS["s390"]     = [ "s390_mainframe" ]
 
 # Groups based on firmware
 GROUPS["efi"]  = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi" ]
index abd54bae4e09f013139447606bf6dcdd2b49d53d..12b4816ead7701b709f0abadaf0d55e7c2fc4f55 100644 (file)
@@ -78,6 +78,7 @@ kernel = {
   sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
   mips_arc_ldflags    = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
   mips_qemu_mips_ldflags    = '-Wl,-Ttext,0x80200000';
+  s390_mainframe_ldflags    = '-Wl,-Ttext,0x8000';
 
   mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
   mips_loongson_cppflags = '-DUSE_ASCII_FALLBACK';
@@ -1737,6 +1738,11 @@ module = {
   common = partmap/dfly.c;
 };
 
+module = {
+  name = part_dasd;
+  common = partmap/dasd.c;
+};
+
 module = {
   name = msdospart;
   common = parttool/msdospart.c;
diff --git a/grub-core/partmap/dasd.c b/grub-core/partmap/dasd.c
new file mode 100644 (file)
index 0000000..5159b54
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2012  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/partition.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_partition_map grub_dasd_partition_map;
+
+struct addr
+{
+  grub_uint16_t cyl;
+  grub_uint16_t head;
+  grub_uint8_t sec;
+} __attribute__ ((packed));
+
+struct anchor
+{
+  grub_uint8_t unused1[4];
+  grub_uint8_t magic[4];
+  grub_uint8_t unused2[7];
+  struct addr vtoc_addr;
+} __attribute__ ((packed));
+
+/* VOL1 in EBCDIC.  */
+#define ANCHOR_MAGIC "\xe5\xd6\xd3\xf1"
+
+struct grub_disk_addr_t
+address_to_block (const struct addr *a)
+{
+  return a->cyl * + a->head *  + a->sec;
+}
+
+static grub_err_t
+dasd_partition_map_iterate (grub_disk_t disk,
+                           int (*hook) (grub_disk_t disk,
+                                        const grub_partition_t partition))
+{
+  grub_err_t err;
+  grub_partition_t p;
+  struct anchor anchor;
+
+  err = grub_disk_read (disk, 2 * 8, 0, sizeof (anchor), &anchor);
+  if (err)
+    return err;
+  if (grub_memcmp (anchor.magic, ANCHOR_MAGIC, sizeof (ANCHOR_MAGIC) - 1) != 0)
+    return grub_error (GRUB_ERR_BAD_PART_TABLE, 
+                      "not a dasd partition table");
+
+  p = (grub_partition_t) grub_zalloc (sizeof (struct grub_partition));
+  if (! p)
+    return grub_errno;
+  p->partmap = &grub_dasd_partition_map;
+
+  p->start = 0x18 << 3;
+  p->len = disk->total_sectors - p->start;
+  p->number = 0;
+  if (hook (disk, p))
+    {
+      grub_free (p);
+      return GRUB_ERR_NONE;
+    }
+
+  grub_free (p);
+  return GRUB_ERR_NONE;
+}
+
+/* Partition map type.  */
+static struct grub_partition_map grub_dasd_partition_map =
+  {
+    .name = "dasd",
+    .iterate = dasd_partition_map_iterate,
+  };
+
+GRUB_MOD_INIT(part_dasd)
+{
+  grub_partition_map_register (&grub_dasd_partition_map);
+}
+
+GRUB_MOD_FINI(part_dasd)
+{
+  grub_partition_map_unregister (&grub_dasd_partition_map);
+}
+