]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Move mips-arc link address. Previous link address was chosen
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 24 Apr 2013 11:54:17 +0000 (13:54 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 24 Apr 2013 11:54:17 +0000 (13:54 +0200)
in belief that RAM on SGI platforms grows down while in fact it
grows up from an unusual base.

ChangeLog
grub-core/Makefile.core.def
grub-core/kern/mips/arc/init.c
grub-core/kern/mips/startup.S
include/grub/mips/arc/memory.h
include/grub/offsets.h
util/grub-mkimage.c

index 2150d3da5ac5fe96f16a02d06ffdc5af9bd64b29..39bb8279b478220515ff9f78f6593a9cef83a54e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-24  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Move mips-arc link address. Previous link address was chosen
+       in belief that RAM on SGI platforms grows down while in fact it
+       grows up from an unusual base.
+
 2013-04-21  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/disk/arc/arcdisk.c (grub_arcdisk_iterate_iter):
index 7269609f9c71810991bd33b89b7b472426b13c45..8f36ea0f24c9e8f1729868d8f01b7fb3723bbb89 100644 (file)
@@ -73,7 +73,7 @@ kernel = {
   mips_loongson_ldflags    = '-Wl,-Ttext,0x80200000';
   powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
   sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
-  mips_arc_ldflags    = '-Wl,-Ttext,0x8bd00000';
+  mips_arc_ldflags    = '-Wl,-Ttext,0x88200000';
   mips_qemu_mips_ldflags    = '-Wl,-Ttext,0x80200000';
 
   mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK';
@@ -372,7 +372,7 @@ image = {
   objcopyflags = '-O binary';
   mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
   mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
-  mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x8bc00000';
+  mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x88100000';
   ldadd = '-lgcc';
   cflags = '-Wno-unreachable-code -static-libgcc';
   enable = mips;
@@ -388,7 +388,7 @@ image = {
   objcopyflags = '-O binary';
   mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
   mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
-  mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x8bc00000';
+  mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x88100000';
   ldadd = '-lgcc';
   cflags = '-static-libgcc';
   enable = mips;
index f63ac6d47ad7c1b94df6048b6a7da76c3b97abfb..011c63fe09834a23291fcf1cf1936117a720cdc8 100644 (file)
@@ -128,12 +128,16 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
 extern grub_uint32_t grub_total_modules_size __attribute__ ((section(".text")));
 grub_addr_t grub_modbase;
 
+extern char _end[];
+
 void
 grub_machine_init (void)
 {
   struct grub_arc_memory_descriptor *cur = NULL;
+  grub_addr_t modend;
 
-  grub_modbase = GRUB_KERNEL_MIPS_ARC_LINK_ADDR - grub_total_modules_size;
+  grub_modbase = ALIGN_UP ((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
+  modend = grub_modbase + grub_total_modules_size;
   grub_console_init_early ();
 
   /* FIXME: measure this.  */
@@ -153,10 +157,10 @@ grub_machine_init (void)
       start = ((grub_uint64_t) cur->start_page) << 12;
       end = ((grub_uint64_t) cur->num_pages)  << 12;
       end += start;
-      if ((grub_uint64_t) end > ((GRUB_KERNEL_MIPS_ARC_LINK_ADDR
-                                 - grub_total_modules_size) & 0x1fffffff))
-       end = ((GRUB_KERNEL_MIPS_ARC_LINK_ADDR - grub_total_modules_size)
-              & 0x1fffffff);
+      if ((grub_uint64_t) start < (modend & 0x1fffffff))
+       start = (modend & 0x1fffffff);
+      if ((grub_uint64_t) end > 0x20000000)
+       end = 0x20000000;
       if (end > start)
        grub_mm_init_region ((void *) (grub_addr_t) (start | 0x80000000),
                             end - start);
index 2476038bc0478b6504a07ea7d94d2fdaa57e0270..35a11bcf8d8bf81c45c73a33b1899118845fea29 100644 (file)
@@ -73,7 +73,6 @@ cont:
 #endif
 
        /* Move the modules out of BSS.  */
-#ifndef GRUB_MACHINE_ARC
        lui $t2, %hi(__bss_start)
        addiu $t2, %lo(__bss_start)
        
@@ -103,7 +102,6 @@ modulesmovcont:
        b modulesmovcont
         addiu $t3, $t3, -1
 modulesmovdone:
-#endif
 
        /* Clean BSS.  */
        
index b960d2a37e94ef8c3c99f551eeb85dc2eaba6bcb..68b425f75af9c0f537bb3e47dc85f0f78e9da909 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef GRUB_MEMORY_MACHINE_HEADER
 #define GRUB_MEMORY_MACHINE_HEADER     1
 
-#define GRUB_MACHINE_MEMORY_STACK_HIGH       0x8bfffff0
+#define GRUB_MACHINE_MEMORY_STACK_HIGH       0x881ffff0
 
 #ifndef ASM_FILE
 
index bce755d985eaf2795de5a571f5f8f529c1caed7c..1e673d522746de1b27939f8e0343f18f7308ca02 100644 (file)
@@ -80,7 +80,7 @@
 #define GRUB_DECOMPRESSOR_MIPS_QEMU_MIPS_UNCOMPRESSED_ADDR        0x10
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE   0x08
 
-#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR         0x8bd00000
+#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR         0x88200000
 
 #define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN  32
 
index 0acc61ee4d6be9d0a10680348338481864d46b4a..41f795aabadc7d38c3d2760198fbff2b1d64d211 100644 (file)
@@ -387,8 +387,7 @@ struct image_target_desc image_targets[] =
       .voidp_sizeof = 4,
       .bigendian = 1,
       .id = IMAGE_MIPS_ARC, 
-      .flags = (PLATFORM_FLAGS_DECOMPRESSORS
-               | PLATFORM_FLAGS_MODULES_BEFORE_KERNEL),
+      .flags = PLATFORM_FLAGS_DECOMPRESSORS,
       .total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
       .decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
       .decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
@@ -1522,12 +1521,10 @@ generate_image (const char *dir, const char *prefix,
 
        program_size = ALIGN_ADDR (core_size);
        if (comp == COMPRESSION_NONE)
-         target_addr = (image_target->link_addr 
-                        - total_module_size - decompress_size);
+         target_addr = (image_target->link_addr - decompress_size);
        else
-         target_addr = (image_target->link_addr 
-                        - ALIGN_UP(total_module_size + core_size, 1048576)
-                        - (1 << 20));
+         target_addr = ALIGN_UP (image_target->link_addr
+                                 + kernel_size + total_module_size, 32);
 
        ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section));
        grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section));