nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0352-Enable-mipsel-arc.patch

f96e0b
From 4e07feae1975db4c63edc00734287d53d3a5fc72 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Thu, 25 Apr 2013 22:42:35 +0200
f96e0b
Subject: [PATCH 352/482] 	Enable mipsel-arc.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                      |  4 ++++
f96e0b
 configure.ac                   | 20 +++++++++++++++++++-
f96e0b
 grub-core/Makefile.core.def    | 10 +++-------
f96e0b
 grub-core/disk/arc/arcdisk.c   |  4 ++++
f96e0b
 include/grub/mips/arc/memory.h |  4 ++++
f96e0b
 include/grub/offsets.h         |  6 +++++-
f96e0b
 tests/grub_cmd_date.in         |  3 ++-
f96e0b
 tests/partmap_test.in          |  4 ++++
f96e0b
 tests/util/grub-shell.in       |  9 +++++++++
f96e0b
 util/grub-mkimage.c            | 30 ++++++++++++++++++++++++++++--
f96e0b
 util/grub-mkrescue.in          |  8 ++++++++
f96e0b
 11 files changed, 90 insertions(+), 12 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 7f2c4dd..0bc5cc4 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,9 @@
f96e0b
 2013-04-25  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	Enable mipsel-arc.
f96e0b
+
f96e0b
+2013-04-25  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	Add serial on ARC platform.
f96e0b
 
f96e0b
 2013-04-25  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
diff --git a/configure.ac b/configure.ac
f96e0b
index ca180c6..4af1a03 100644
f96e0b
--- a/configure.ac
f96e0b
+++ b/configure.ac
f96e0b
@@ -145,6 +145,7 @@ case "$target_cpu"-"$platform" in
f96e0b
   mips-qemu_mips) ;;
f96e0b
   mips-qemu-mips) platform=qemu_mips;;
f96e0b
   mips-arc) ;;
f96e0b
+  mipsel-arc) ;;
f96e0b
   mipsel-qemu_mips) ;;
f96e0b
   mipsel-qemu-mips) platform=qemu_mips;;
f96e0b
   mipsel-yeeloong) platform=loongson ;;
f96e0b
@@ -198,6 +199,23 @@ else
f96e0b
    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
f96e0b
 fi
f96e0b
 
f96e0b
+case "${target_cpu}-$platform" in
f96e0b
+     mips-arc)
f96e0b
+        TARGET_LINK_ADDR=0x88200000
f96e0b
+        TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
f96e0b
+	;;
f96e0b
+     mipsel-arc)
f96e0b
+        TARGET_LINK_ADDR=0x80700000
f96e0b
+	TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
f96e0b
+	;;
f96e0b
+     mips*-qemu_mips | mips-loongson)
f96e0b
+        TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
f96e0b
+	;;
f96e0b
+esac
f96e0b
+
f96e0b
+AC_SUBST(TARGET_LINK_ADDR)
f96e0b
+AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
f96e0b
+
f96e0b
 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
f96e0b
 
f96e0b
 AC_SUBST(host_cpu)
f96e0b
@@ -1146,7 +1164,7 @@ AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform =
f96e0b
 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
f96e0b
 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
f96e0b
 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")"  -a x$platform = xqemu_mips])
f96e0b
-AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
f96e0b
+AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")"  -a x$platform = xarc])
f96e0b
 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
f96e0b
 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
f96e0b
 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
f96e0b
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
f96e0b
index cdef5b4..ad912a6 100644
f96e0b
--- a/grub-core/Makefile.core.def
f96e0b
+++ b/grub-core/Makefile.core.def
f96e0b
@@ -73,7 +73,7 @@ kernel = {
f96e0b
   mips_loongson_ldflags    = '-Wl,-Ttext,0x80200000';
f96e0b
   powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
f96e0b
   sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
f96e0b
-  mips_arc_ldflags    = '-Wl,-Ttext,0x88200000';
f96e0b
+  mips_arc_ldflags    = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
f96e0b
   mips_qemu_mips_ldflags    = '-Wl,-Ttext,0x80200000';
f96e0b
 
f96e0b
   mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK';
f96e0b
@@ -370,9 +370,7 @@ image = {
f96e0b
   cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
f96e0b
 
f96e0b
   objcopyflags = '-O binary';
f96e0b
-  mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
f96e0b
-  mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
f96e0b
-  mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x88100000';
f96e0b
+  mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
f96e0b
   ldadd = '-lgcc';
f96e0b
   cflags = '-Wno-unreachable-code -static-libgcc';
f96e0b
   enable = mips;
f96e0b
@@ -386,9 +384,7 @@ image = {
f96e0b
   cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
f96e0b
 
f96e0b
   objcopyflags = '-O binary';
f96e0b
-  mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
f96e0b
-  mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
f96e0b
-  mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x88100000';
f96e0b
+  mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
f96e0b
   ldadd = '-lgcc';
f96e0b
   cflags = '-static-libgcc';
f96e0b
   enable = mips;
f96e0b
diff --git a/grub-core/disk/arc/arcdisk.c b/grub-core/disk/arc/arcdisk.c
f96e0b
index 9aefb7c..0cc1993 100644
f96e0b
--- a/grub-core/disk/arc/arcdisk.c
f96e0b
+++ b/grub-core/disk/arc/arcdisk.c
f96e0b
@@ -113,7 +113,11 @@ grub_arcdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
f96e0b
   return grub_arc_iterate_devs (grub_arcdisk_iterate_iter, &ctx, 1);
f96e0b
 }
f96e0b
 
f96e0b
+#ifdef GRUB_CPU_MIPSEL
f96e0b
+#define RAW_SUFFIX "partition(0)"
f96e0b
+#else
f96e0b
 #define RAW_SUFFIX "partition(10)"
f96e0b
+#endif
f96e0b
 
f96e0b
 static grub_err_t
f96e0b
 reopen (const char *name, int writable)
f96e0b
diff --git a/include/grub/mips/arc/memory.h b/include/grub/mips/arc/memory.h
f96e0b
index 68b425f..77bb03d 100644
f96e0b
--- a/include/grub/mips/arc/memory.h
f96e0b
+++ b/include/grub/mips/arc/memory.h
f96e0b
@@ -19,7 +19,11 @@
f96e0b
 #ifndef GRUB_MEMORY_MACHINE_HEADER
f96e0b
 #define GRUB_MEMORY_MACHINE_HEADER	1
f96e0b
 
f96e0b
+#ifdef GRUB_CPU_MIPSEL
f96e0b
+#define GRUB_MACHINE_MEMORY_STACK_HIGH       0x806ffff0
f96e0b
+#else
f96e0b
 #define GRUB_MACHINE_MEMORY_STACK_HIGH       0x881ffff0
f96e0b
+#endif
f96e0b
 
f96e0b
 #ifndef ASM_FILE
f96e0b
 
f96e0b
diff --git a/include/grub/offsets.h b/include/grub/offsets.h
f96e0b
index 1e673d5..c5ef79f 100644
f96e0b
--- a/include/grub/offsets.h
f96e0b
+++ b/include/grub/offsets.h
f96e0b
@@ -81,7 +81,7 @@
f96e0b
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE	0x08
f96e0b
 
f96e0b
 #define GRUB_KERNEL_MIPS_ARC_LINK_ADDR         0x88200000
f96e0b
-
f96e0b
+#define GRUB_KERNEL_MIPSEL_ARC_LINK_ADDR         0x80700000
f96e0b
 #define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN  32
f96e0b
 
f96e0b
 #define GRUB_DECOMPRESSOR_MIPS_ARC_COMPRESSED_SIZE          0x8
f96e0b
@@ -125,7 +125,11 @@
f96e0b
 
f96e0b
 #define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, GRUB_MACHINE, _KERNEL_SEG)
f96e0b
 #define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, GRUB_MACHINE, _UPPER)
f96e0b
+#if defined (GRUB_MACHINE_ARC) && defined (GRUB_CPU_MIPSEL)
f96e0b
+#define GRUB_MACHINE_LINK_ADDR GRUB_KERNEL_MIPSEL_ARC_LINK_ADDR
f96e0b
+#else
f96e0b
 #define GRUB_MACHINE_LINK_ADDR GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _LINK_ADDR)
f96e0b
+#endif
f96e0b
 
f96e0b
 #define GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_DECOMPRESSOR_, GRUB_MACHINE, _COMPRESSED_SIZE)
f96e0b
 #define GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_DECOMPRESSOR_, GRUB_MACHINE, _UNCOMPRESSED_SIZE)
f96e0b
diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in
f96e0b
index 76436a0..effc82a 100644
f96e0b
--- a/tests/grub_cmd_date.in
f96e0b
+++ b/tests/grub_cmd_date.in
f96e0b
@@ -4,7 +4,8 @@ set -e
f96e0b
 . "@builddir@/grub-core/modinfo.sh"
f96e0b
 
f96e0b
 # OpenBIOS on sparc64 doesn't implement RTC
f96e0b
-if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
f96e0b
+# mipsel-arc QEMU emulated RTC doesn't play well with firmware
f96e0b
+if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mipsel-arc ]; then
f96e0b
     exit 0
f96e0b
 fi
f96e0b
 
f96e0b
diff --git a/tests/partmap_test.in b/tests/partmap_test.in
f96e0b
index 0dea98a..ee23f7f 100644
f96e0b
--- a/tests/partmap_test.in
f96e0b
+++ b/tests/partmap_test.in
f96e0b
@@ -81,6 +81,10 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
     mips-arc)
f96e0b
 	# ARC firmware has bugs which prevent it from accessing hard disk w/o dvh disklabel.
f96e0b
 	exit 0 ;;
f96e0b
+    mipsel-arc)
f96e0b
+	disk=arc/scsi0/disk0/rdisk0
f96e0b
+	qemudisk=hda
f96e0b
+	;;
f96e0b
     *)
f96e0b
 	disk=hd0
f96e0b
 	qemudisk=hda
f96e0b
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
f96e0b
index b051669..ccea332 100644
f96e0b
--- a/tests/util/grub-shell.in
f96e0b
+++ b/tests/util/grub-shell.in
f96e0b
@@ -92,6 +92,15 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
 	console=console
f96e0b
 	trim=1
f96e0b
 	;;
f96e0b
+    mipsel-arc)
f96e0b
+	boot=cd
f96e0b
+	qemu=qemu-system-mips64el
f96e0b
+	qemuopts="$qemuopts -M magnum -no-reboot"
f96e0b
+	serial_port=arc/multi0/serial0
f96e0b
+	console=console
f96e0b
+	halt_cmd=reboot
f96e0b
+	trim=1
f96e0b
+	;;
f96e0b
     mipsel-qemu_mips)
f96e0b
 	boot=mipsel_qemu
f96e0b
 	qemu=qemu-system-mipsel
f96e0b
diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c
f96e0b
index 41f795a..7edf77a 100644
f96e0b
--- a/util/grub-mkimage.c
f96e0b
+++ b/util/grub-mkimage.c
f96e0b
@@ -400,6 +400,24 @@ struct image_target_desc image_targets[] =
f96e0b
       .default_compression = COMPRESSION_NONE
f96e0b
     },
f96e0b
     {
f96e0b
+      .dirname = "mipsel-arc",
f96e0b
+      .names = {"mipsel-arc", NULL},
f96e0b
+      .voidp_sizeof = 4,
f96e0b
+      .bigendian = 0,
f96e0b
+      .id = IMAGE_MIPS_ARC, 
f96e0b
+      .flags = PLATFORM_FLAGS_DECOMPRESSORS,
f96e0b
+      .total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
f96e0b
+      .decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
f96e0b
+      .decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
f96e0b
+      .decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
f96e0b
+      .section_align = 1,
f96e0b
+      .vaddr_offset = 0,
f96e0b
+      .link_addr = GRUB_KERNEL_MIPSEL_ARC_LINK_ADDR,
f96e0b
+      .elf_target = EM_MIPS,
f96e0b
+      .link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
f96e0b
+      .default_compression = COMPRESSION_NONE
f96e0b
+    },
f96e0b
+    {
f96e0b
       .dirname = "mipsel-qemu_mips",
f96e0b
       .names = { "mipsel-qemu_mips-elf", NULL },
f96e0b
       .voidp_sizeof = 4,
f96e0b
@@ -1530,11 +1548,14 @@ generate_image (const char *dir, const char *prefix,
f96e0b
 	grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section));
f96e0b
 	head = (void *) ecoff_img;
f96e0b
 	section = (void *) (head + 1);
f96e0b
-	head->magic = grub_host_to_target16 (0x160);
f96e0b
+	head->magic = image_target->bigendian ? grub_host_to_target16 (0x160)
f96e0b
+	  : grub_host_to_target16 (0x166);
f96e0b
 	head->nsec = grub_host_to_target16 (1);
f96e0b
 	head->time = grub_host_to_target32 (0);
f96e0b
 	head->opt = grub_host_to_target16 (0x38);
f96e0b
-	head->flags = grub_host_to_target16 (0x207);
f96e0b
+	head->flags = image_target->bigendian
f96e0b
+	  ? grub_host_to_target16 (0x207)
f96e0b
+	  : grub_host_to_target16 (0x103);
f96e0b
 	head->magic2 = grub_host_to_target16 (0x107);
f96e0b
 	head->textsize = grub_host_to_target32 (program_size);
f96e0b
 	head->entry = grub_host_to_target32 (target_addr);
f96e0b
@@ -1544,6 +1565,11 @@ generate_image (const char *dir, const char *prefix,
f96e0b
 	section->vaddr = grub_host_to_target32 (target_addr);
f96e0b
 	section->size = grub_host_to_target32 (program_size);
f96e0b
 	section->file_offset = grub_host_to_target32 (sizeof (*head) + sizeof (*section));
f96e0b
+	if (!image_target->bigendian)
f96e0b
+	  {
f96e0b
+	    section->paddr = grub_host_to_target32 (0xaa60);
f96e0b
+	    section->flags = grub_host_to_target32 (0x20);
f96e0b
+	  }
f96e0b
 	memcpy (section + 1, core_img, core_size);
f96e0b
 	free (core_img);
f96e0b
 	core_img = ecoff_img;
f96e0b
diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in
f96e0b
index 78d4bec..51e75e8 100644
f96e0b
--- a/util/grub-mkrescue.in
f96e0b
+++ b/util/grub-mkrescue.in
f96e0b
@@ -46,6 +46,7 @@ efi64_dir="${libdir}/@PACKAGE@/x86_64-efi"
f96e0b
 ia64_dir="${libdir}/@PACKAGE@/ia64-efi"
f96e0b
 sparc64_dir="${libdir}/@PACKAGE@/sparc64-ieee1275"
f96e0b
 arcs_dir="${libdir}/@PACKAGE@/mips-arc"
f96e0b
+arc_dir="${libdir}/@PACKAGE@/mipsel-arc"
f96e0b
 ppc_dir="${libdir}/@PACKAGE@/powerpc-ieee1275"
f96e0b
 rom_directory=
f96e0b
 override_dir=
f96e0b
@@ -325,6 +326,9 @@ if [ "${override_dir}" = "" ] ; then
f96e0b
     if test -e "${arcs_dir}" ; then
f96e0b
         process_input_dir "${arcs_dir}" mips-arc
f96e0b
     fi
f96e0b
+    if test -e "${arc_dir}" ; then
f96e0b
+        process_input_dir "${arc_dir}" mipsel-arc
f96e0b
+    fi
f96e0b
 else
f96e0b
     . "${override_dir}"/modinfo.sh
f96e0b
     process_input_dir "${override_dir}" ${grub_modinfo_target_cpu}-${grub_modinfo_platform}
f96e0b
@@ -342,6 +346,7 @@ else
f96e0b
     i386_ieee1275_dir=
f96e0b
     sparc64_dir=
f96e0b
     arcs_dir=
f96e0b
+    arc_dir=
f96e0b
     case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
         i386-multiboot) multiboot_dir="${override_dir}" ;;
f96e0b
         i386-coreboot) coreboot_dir="${override_dir}" ;;
f96e0b
@@ -356,6 +361,7 @@ else
f96e0b
 	powerpc-ieee1275) ppc_dir="${override_dir}"; system_area=common ;;
f96e0b
 	sparc64-ieee1275) sparc64_dir="${override_dir}"; system_area=sparc64 ;;
f96e0b
 	mips-arc) arcs_dir="${override_dir}"; system_area=arcs ;;
f96e0b
+	mipsel-arc) arc_dir="${override_dir}" ;;
f96e0b
 	i386-ieee1275) i386_ieee1275_dir="${override_dir}" ;;
f96e0b
     esac
f96e0b
 fi
f96e0b
@@ -491,6 +497,8 @@ if [ -e "${iso9660_dir}/boot/grub/mips-arc/core.img" ] && [ "$system_area" = arc
f96e0b
    grub_mkisofs_arguments="${grub_mkisofs_arguments} -mips-boot /boot/grub/mips-arc/sashARCS -mips-boot /boot/grub/mips-arc/sash -mips-boot /boot/grub/mips-arc/grub"
f96e0b
 fi
f96e0b
 
f96e0b
+make_image "${arc_dir}" mipsel-arc "${iso9660_dir}/boot/grub/arc.exe" ""
f96e0b
+
f96e0b
 make_image "${mipsel_qemu_dir}" mipsel-qemu_mips-elf "${iso9660_dir}/boot/grub/roms/mipsel-qemu_mips.elf" "pata"
f96e0b
 if [ -e "${iso9660_dir}/boot/grub/roms/mipsel-qemu_mips.elf" ] && [ -d "${rom_directory}" ]; then
f96e0b
     cp "${iso9660_dir}/boot/grub/roms/mipsel-qemu_mips.elf" "${rom_directory}/mipsel-qemu_mips.elf"
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b