Hi.

Here is a (mostly) maintainance patch for sparc64 port.
It only fixes the build and implements setjmp/longjmp so that one can jump to 
rescue mode.

It also builds the linux loader module, but the boot is known to fail on my 
box (some disk access error at OF level when reading the linux kernel image).

I prefer to post the patch for validation before commiting, it's been too long 
I haven't post to go on my own :) . (changelog is in the diff :p ).

-- 
Vincent Pelletier
? include/grub/sparc64/ieee1275/loader.h
Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.341
diff -u -p -r1.341 ChangeLog
--- ChangeLog	21 Feb 2007 23:25:09 -0000	1.341
+++ ChangeLog	4 Mar 2007 12:32:07 -0000
@@ -1,3 +1,70 @@
+2007-03-01  Vincent Pelletier  <[EMAIL PROTECTED]>
+
+	* THANKS: Update my mail address.
+	* conf/sparc64-ieee1275.rmk: Include conf/common.mk.
+	(COMMON_ASFLAGS): Build sparc64 binary.
+	(COMMON_LDFLAGS): Updated to gcc-style flags.
+	(grub_mkimage_SOURCES): Commented out.
+	(pkgdata_MODULES): Removed fat.mod, ufs.mod, ext2.mod, minix.mod,
+	hfs.mod, jfs.mod, hello.mod, font.mod, ls.mod, boot.mod, cmp.mod,
+	cat.mod, terminal.mod, fshelp.mod, amiga.mod, apple.mod, pc.mod,
+	loopback.mod, help.mod, sun.mod, configfile.mod, search.mod,
+	gzio.mod, xfs.mod, affs.mod, sfs.mod, acorn.mod.  Added _linux.mod
+	and linux.mod.
+	(kernel_elf_LDFLAGS): Prepend common flags.  Updated to gcc-style
+	flags.
+	(_linux_mod_SOURCES, _linux_mod_CFLAGS, _linux_mod_LDFLAGS)
+	(linux_mod_SOURCES, linux_mod_CFLAGS, linux_mod_LDFLAGS): Uncomment.
+	(grub_script.tab.c, grub_script.tab.h, grub_modules_init.lst)
+	(fshelp_mod_SOURCES, fshelp_mod_CFLAGS, fshelp_mod_LDFLAGS)
+	(fat_mod_SOURCES, fat_mod_CFLAGS, fat_mod_LDFLAGS)
+	(ext2_mod_SOURCES, ext2_mod_CFLAGS, ext2_mod_LDFLAGS)
+	(ufs_mod_SOURCES, ufs_mod_CFLAGS, ufs_mod_LDFLAGS)
+	(minix_mod_SOURCES, minix_mod_CFLAGS, minix_mod_LDFLAGS)
+	(hfs_mod_SOURCES, hfs_mod_CFLAGS, hfs_mod_LDFLAGS, jfs_mod_SOURCES)
+	(jfs_mod_CFLAGS, jfs_mod_LDFLAGS, iso9660_mod_SOURCES)
+	(iso9660_mod_CFLAGS, iso9660_mod_LDFLAGS, xfs_mod_SOURCES)
+	(xfs_mod_CFLAGS, xfs_mod_LDFLAGS, affs_mod_SOURCES)
+	(affs_mod_CFLAGS, affs_mod_LDFLAGS, sfs_mod_SOURCES)
+	(sfs_mod_CFLAGS, sfs_mod_LDFLAGS, hello_mod_SOURCES)
+	(hello_mod_CFLAGS, hello_mod_LDFLAGS, boot_mod_SOURCES)
+	(boot_mod_CFLAGS, boot_mod_LDFLAGS, terminal_mod_SOURCES)
+	(terminal_mod_CFLAGS, terminal_mod_LDFLAGS, ls_mod_SOURCES)
+	(ls_mod_CFLAGS, ls_mod_LDFLAGS, cmp_mod_SOURCES, cmp_mod_CFLAGS)
+	(cmp_mod_LDFLAGS, cat_mod_SOURCES, cat_mod_CFLAGS, cat_mod_LDFLAGS)
+	(help_mod_SOURCES, help_mod_CFLAGS, help_mod_LDFLAGS)
+	(font_mod_SOURCES, font_mod_CFLAGS, font_mod_LDFLAGS)
+	(terminfo_mod_SOURCES, terminfo_mod_CFLAGS, terminfo_mod_LDFLAGS)
+	(amiga_mod_SOURCES, amiga_mod_CFLAGS, amiga_mod_LDFLAGS)
+	(apple_mod_SOURCES, apple_mod_CFLAGS, apple_mod_LDFLAG)
+	(pc_mod_SOURCES, pc_mod_CFLAGS, pc_mod_LDFLAGS, sun_mod_SOURCES)
+	(sun_mod_CFLAGS, sun_mod_LDFLAGS, acorn_mod_SOURCES, acorn_mod_CFLAGS)
+	(loopback_mod_SOURCES, loopback_mod_CFLAGS, loopback_mod_LDFLAGS)
+	(default_mod_SOURCES, default_mod_CFLAGS, default_mod_LDFLAGS)
+	(timeout_mod_SOURCES, timeout_mod_CFLAGS, timeout_mod_LDFLAGS)
+	(configfile_mod_SOURCES, configfile_mod_CFLAGS)
+	(configfile_mod_LDFLAGS, search_mod_SOURCES, search_mod_CFLAGS)
+	(search_mod_LDFLAGS, gzio_mod_SOURCES, gzio_mod_CFLAGS)
+	(gzio_mod_LDFLAGS, test_mod_SOURCES, test_mod_CFLAGS)
+	(test_mod_LDFLAGS): Removed.
+	* conf/sparc64-ieee1275.mk: Regenerate.
+	* include/grub/elf.h (ELF64_R_TYPE_DATA, ELF64_R_TYPE_ID)
+	(ELF64_R_TYPE_INFO): New macros.
+	* include/grub/sparc64/setjmp.h: Include grub/types.h.
+	(grub_jmp_buf): Update definition.
+	* kern/sparc64/dl.c (grub_arch_dl_relocate_symbols): Use
+	ELF64_R_TYPE_ID macro.  Explicited bitmasks and casts.  Fixed
+	R_SPARC_WDISP30 relocation checks and updated its error message.
+	Added support for R_SPARC_13 and R_SPARC_OLO10 relocations.
+	* kern/sparc64/ieee1275/init.c (grub_claim_heap): New function.
+	(grub_machine_fini): Call `grub_ieee1275_exit'.
+	* kern/sparc64/ieee1275/openfw.c (grub_devalias_iterate): Update call
+	to `grub_ieee1275_next_property'.  Remove uneeded variable.
+	(grub_available_iterate): New function.
+	* normal/main.c: Explicit grub_exit_env alignment.
+	* normal/sparc64/setjmp.S (grub_setjmp, grub_longjmp): Implement.
+	* include/grub/sparc64/ieee1275/loader.h: New file.
+
 2007-02-21  Hollis Blanchard  <[EMAIL PROTECTED]>
 
 	* kern/powerpc/ieee1275/init.c (HEAP_SIZE): Removed.
Index: THANKS
===================================================================
RCS file: /sources/grub/grub2/THANKS,v
retrieving revision 1.18
diff -u -p -r1.18 THANKS
--- THANKS	25 Nov 2006 03:21:29 -0000	1.18
+++ THANKS	4 Mar 2007 12:32:07 -0000
@@ -26,7 +26,7 @@ Tristan Gingold  <[EMAIL PROTECTED]
 Tsuneyoshi Yasuo <[EMAIL PROTECTED]>
 Vesa Jaaskelainen  <[EMAIL PROTECTED]>
 Vincent Guffens <[EMAIL PROTECTED]>
-Vincent Pelletier <[EMAIL PROTECTED]>
+Vincent Pelletier <[EMAIL PROTECTED]>
 Vladimir Serbinenko <[EMAIL PROTECTED]>
 
 Also, we thank the projects GNU Automake and LZO. Some code
Index: conf/sparc64-ieee1275.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/sparc64-ieee1275.rmk,v
retrieving revision 1.16
diff -u -p -r1.16 sparc64-ieee1275.rmk
--- conf/sparc64-ieee1275.rmk	13 Dec 2006 22:30:19 -0000	1.16
+++ conf/sparc64-ieee1275.rmk	4 Mar 2007 12:32:07 -0000
@@ -1,9 +1,9 @@
 
 # -*- makefile -*-
 
-COMMON_ASFLAGS = -nostdinc
+COMMON_ASFLAGS = -nostdinc -m64 -mno-app-regs
 COMMON_CFLAGS = -ggdb -ffreestanding -m64 -mno-app-regs
-COMMON_LDFLAGS = -melf64_sparc -nostdlib
+COMMON_LDFLAGS = -melf64_sparc -nostdlib -mno-relax -m64
 
 # Images.
 
@@ -18,10 +18,6 @@ kernel_elf_HEADERS = arg.h boot.h cache.
 kernel_elf_symlist.c: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h gensymlist.sh
 	/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
-# For the parser.
-grub_script.tab.c grub_script.tab.h: normal/parser.y
-	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/normal/parser.y
-
 kernel_syms.lst: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h genkernsyms.sh
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
@@ -35,8 +31,8 @@ pkgdata_PROGRAMS = kernel.elf
 #endif
 
 # For grub-mkimage.
-grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
-        util/resolve.c 
+#grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
+#        util/resolve.c 
 
 # For grub-emu
 #grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c 	\
@@ -74,81 +70,25 @@ kernel_elf_SOURCES = kern/sparc64/ieee12
 kernel_elf_HEADERS = grub/sparc64/ieee1275/ieee1275.h
 kernel_elf_CFLAGS = $(COMMON_CFLAGS)
 kernel_elf_ASFLAGS = $(COMMON_ASFLAGS)
-kernel_elf_LDFLAGS = -mno-app-regs -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc
+kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -mno-app-regs -Wl,-N,-Ttext,0x200000,-Bstatic -m64
 
 # Modules.
-#_linux.mod linux.mod
-pkgdata_MODULES = fat.mod ufs.mod ext2.mod minix.mod \
-	hfs.mod jfs.mod normal.mod hello.mod font.mod ls.mod \
-	boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
-	pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \
-	configfile.mod search.mod gzio.mod xfs.mod \
-	affs.mod sfs.mod acorn.mod
-
-# For fshelp.mod.
-fshelp_mod_SOURCES = fs/fshelp.c
-fshelp_mod_CFLAGS = $(COMMON_CFLAGS)
-fshelp_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For fat.mod.
-fat_mod_SOURCES = fs/fat.c
-fat_mod_CFLAGS = $(COMMON_CFLAGS)
-fat_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For ext2.mod.
-ext2_mod_SOURCES = fs/ext2.c
-ext2_mod_CFLAGS = $(COMMON_CFLAGS)
-ext2_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For ufs.mod.
-ufs_mod_SOURCES = fs/ufs.c
-ufs_mod_CFLAGS = $(COMMON_CFLAGS)
-ufs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For minix.mod.
-minix_mod_SOURCES = fs/minix.c
-minix_mod_CFLAGS = $(COMMON_CFLAGS)
-minix_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For hfs.mod.
-hfs_mod_SOURCES = fs/hfs.c
-hfs_mod_CFLAGS = $(COMMON_CFLAGS)
-hfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For jfs.mod.
-jfs_mod_SOURCES = fs/jfs.c
-jfs_mod_CFLAGS = $(COMMON_CFLAGS)
-jfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For iso9660.mod.
-iso9660_mod_SOURCES = fs/iso9660.c
-iso9660_mod_CFLAGS = $(COMMON_CFLAGS)
-iso9660_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For xfs.mod.
-xfs_mod_SOURCES = fs/xfs.c
-xfs_mod_CFLAGS = $(COMMON_CFLAGS)
-xfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For affs.mod.
-affs_mod_SOURCES = fs/affs.c
-affs_mod_CFLAGS = $(COMMON_CFLAGS)
-affs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For sfs.mod.
-sfs_mod_SOURCES = fs/sfs.c
-sfs_mod_CFLAGS = $(COMMON_CFLAGS)
-sfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
+pkgdata_MODULES = halt.mod \
+	normal.mod \
+	reboot.mod \
+	suspend.mod \
+	_linux.mod \
+	linux.mod \
 
 # For _linux.mod.
-#_linux_mod_SOURCES = loader/sparc64/ieee1275/linux.c
-#_linux_mod_CFLAGS = $(COMMON_CFLAGS)
-#_linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_linux_mod_SOURCES = loader/sparc64/ieee1275/linux.c
+_linux_mod_CFLAGS = $(COMMON_CFLAGS)
+_linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
  
 # For linux.mod.
-#linux_mod_SOURCES = loader/sparc64/ieee1275/linux_normal.c
-#linux_mod_CFLAGS = $(COMMON_CFLAGS)
-#linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
+linux_mod_SOURCES = loader/sparc64/ieee1275/linux_normal.c
+linux_mod_CFLAGS = $(COMMON_CFLAGS)
+linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For normal.mod.
 normal_mod_DEPENDENCIES = grub_script.tab.c grub_script.tab.h
@@ -162,70 +102,6 @@ normal_mod_CFLAGS = $(COMMON_CFLAGS)
 normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
 normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-# For hello.mod.
-hello_mod_SOURCES = hello/hello.c
-hello_mod_CFLAGS = $(COMMON_CFLAGS)
-hello_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For boot.mod.
-boot_mod_SOURCES = commands/boot.c
-boot_mod_CFLAGS = $(COMMON_CFLAGS)
-boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For terminal.mod.
-terminal_mod_SOURCES = commands/terminal.c
-terminal_mod_CFLAGS = $(COMMON_CFLAGS)
-terminal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For ls.mod.
-ls_mod_SOURCES = commands/ls.c
-ls_mod_CFLAGS = $(COMMON_CFLAGS)
-ls_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For cmp.mod.
-cmp_mod_SOURCES = commands/cmp.c
-cmp_mod_CFLAGS = $(COMMON_CFLAGS)
-cmp_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For cat.mod.
-cat_mod_SOURCES = commands/cat.c
-cat_mod_CFLAGS = $(COMMON_CFLAGS)
-cat_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For font.mod.
-font_mod_SOURCES = font/manager.c
-font_mod_CFLAGS = $(COMMON_CFLAGS)
-font_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For amiga.mod
-amiga_mod_SOURCES = partmap/amiga.c
-amiga_mod_CFLAGS = $(COMMON_CFLAGS)
-amiga_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For apple.mod
-apple_mod_SOURCES = partmap/apple.c
-apple_mod_CFLAGS = $(COMMON_CFLAGS)
-apple_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For pc.mod
-pc_mod_SOURCES = partmap/pc.c
-pc_mod_CFLAGS = $(COMMON_CFLAGS)
-pc_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For sun.mod
-sun_mod_SOURCES = partmap/sun.c
-sun_mod_CFLAGS = $(COMMON_CFLAGS)
-sun_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For acorn.mod
-acorn_mod_SOURCES = partmap/acorn.c
-acorn_mod_CFLAGS = $(COMMON_CFLAGS)
-
-# For loopback.mod
-loopback_mod_SOURCES = disk/loopback.c
-loopback_mod_CFLAGS = $(COMMON_CFLAGS)
-loopback_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For suspend.mod
 suspend_mod_SOURCES = commands/ieee1275/suspend.c
 suspend_mod_CFLAGS = $(COMMON_CFLAGS)
@@ -241,37 +117,4 @@ halt_mod_SOURCES = commands/ieee1275/hal
 halt_mod_CFLAGS = $(COMMON_CFLAGS)
 halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-# For help.mod.
-help_mod_SOURCES = commands/help.c
-help_mod_CFLAGS = $(COMMON_CFLAGS)
-help_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For default.mod
-default_mod_SOURCES = commands/default.c
-default_mod_CFLAGS =  $(COMMON_CFLAGS)
-default_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For timeout.mod
-timeout_mod_SOURCES = commands/timeout.c
-timeout_mod_CFLAGS =  $(COMMON_CFLAGS)
-timeout_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For configfile.mod
-configfile_mod_SOURCES = commands/configfile.c
-configfile_mod_CFLAGS = $(COMMON_CFLAGS)
-configfile_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For search.mod.
-search_mod_SOURCES = commands/search.c
-search_mod_CFLAGS = $(COMMON_CFLAGS)
-search_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For gzio.mod.
-gzio_mod_SOURCES = io/gzio.c
-gzio_mod_CFLAGS = $(COMMON_CFLAGS)
-gzio_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For test.mod.
-test_mod_SOURCES = commands/test.c
-test_mod_CFLAGS = $(COMMON_CFLAGS)
-test_mod_LDFLAGS = $(COMMON_LDFLAGS)
+include $(srcdir)/conf/common.mk
Index: include/grub/elf.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/elf.h,v
retrieving revision 1.3
diff -u -p -r1.3 elf.h
--- include/grub/elf.h	4 Apr 2004 13:46:00 -0000	1.3
+++ include/grub/elf.h	4 Mar 2007 12:32:08 -0000
@@ -514,6 +514,10 @@ typedef struct
 #define ELF64_R_SYM(i)			((i) >> 32)
 #define ELF64_R_TYPE(i)			((i) & 0xffffffff)
 #define ELF64_R_INFO(sym,type)		((((Elf64_Xword) (sym)) << 32) + (type))
+#define ELF64_R_TYPE_DATA(info)		(((Elf64_Xword)(info) << 32) >> 40)
+#define ELF64_R_TYPE_ID(info)		(((Elf64_Xword)(info) << 56) >> 56)
+#define ELF64_R_TYPE_INFO(data, type)	(((Elf64_Xword)(sym) << 8) + \
+					 (Elf64_Xword)(type))
 
 /* Program segment header.  */
 
Index: include/grub/sparc64/setjmp.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/sparc64/setjmp.h,v
retrieving revision 1.2
diff -u -p -r1.2 setjmp.h
--- include/grub/sparc64/setjmp.h	4 Aug 2006 19:23:28 -0000	1.2
+++ include/grub/sparc64/setjmp.h	4 Mar 2007 12:32:08 -0000
@@ -20,8 +20,9 @@
 #ifndef GRUB_SETJMP_CPU_HEADER
 #define GRUB_SETJMP_CPU_HEADER	1
 
-/* FIXME (sparc64).  */
-typedef unsigned long grub_jmp_buf[20];
+#include <grub/types.h>
+
+typedef grub_uint64_t grub_jmp_buf[10];
 
 int grub_setjmp (grub_jmp_buf env);
 void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
Index: kern/sparc64/dl.c
===================================================================
RCS file: /sources/grub/grub2/kern/sparc64/dl.c,v
retrieving revision 1.2
diff -u -p -r1.2 dl.c
--- kern/sparc64/dl.c	23 Oct 2005 19:28:28 -0000	1.2
+++ kern/sparc64/dl.c	4 Mar 2007 12:32:08 -0000
@@ -96,40 +96,57 @@ grub_arch_dl_relocate_symbols (grub_dl_t
 				     + entsize * ELF64_R_SYM (rel->r_info));
 
 		value = sym->st_value + rel->r_addend;
-		switch (ELF64_R_TYPE (rel->r_info))
+		switch (ELF64_R_TYPE_ID (ELF64_R_TYPE (rel->r_info)))
 		  {
                   case R_SPARC_32: /* 3 V-word32 */
                     if (value & 0xFFFFFFFF00000000)
                       return grub_error (GRUB_ERR_BAD_MODULE,
                                          "Address out of 32 bits range");
-                    *addr = value;
+                    *addr = (grub_uint32_t) (value & 0xFFFFFFFF);
                     break;
                   case R_SPARC_WDISP30: /* 7 V-disp30 */
-                    if (((value - (Elf64_Addr) addr) & 0xFFFFFFFF00000000) &&
-                        ((value - (Elf64_Addr) addr) & 0xFFFFFFFF00000000
-                        != 0xFFFFFFFF00000000))
+                    if ((value - (Elf64_Addr) addr) & 0x3)
                       return grub_error (GRUB_ERR_BAD_MODULE,
-                                         "Displacement out of 30 bits range");
+                              "30 bits displacement is not 4-bytes alligned");
                     *addr = (*addr & 0xC0000000) |
                       (((grub_int32_t) ((value - (Elf64_Addr) addr) >> 2)) &
                        0x3FFFFFFF);
                     break;
                   case R_SPARC_HI22: /* 9 V-imm22 */
-                    if (((grub_int32_t) value) & 0xFF00000000)
+                    if (value & 0xFFFFFFFF00000000)
                       return grub_error (GRUB_ERR_BAD_MODULE,
                                          "High address out of 22 bits range");
-                    *addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF);
+                    *addr = ((*addr) & 0xFFC00000) |
+                            ((((grub_uint32_t) value) >> 10) & 0x3FFFFF);
+                    break;
+                  case R_SPARC_13: /* 11 V-simm13 */
+                    if (value & 0xFFFFFFFFFFFFE000)
+                      return grub_error(GRUB_ERR_BAD_MODULE,
+                                         "Address out of 13 bits range");
+                    *addr = ((*addr) & 0xFFFFE000) |
+                            (((grub_uint32_t) value) & 0x1FFF);
                     break;
                   case R_SPARC_LO10: /* 12 T-simm13 */
-                    *addr = (*addr & 0xFFFFFC00) | (value & 0x3FF);
+                    *addr = ((*addr) & 0xFFFFFC00) |
+                            (((grub_uint32_t) value) & 0x3FF);
                     break;
                   case R_SPARC_64: /* 32 V-xwords64 */
                     *(Elf64_Xword *) addr = value;
                     break;
+                  case R_SPARC_OLO10: /* 33 V-simm13 */
+                    {
+                      grub_uint32_t delta = ((grub_uint32_t) value & 0x3FF) +
+                               ELF64_R_TYPE_DATA (ELF64_R_TYPE (rel->r_info));
+                      if (delta & 0xFFFFE000)
+                        return grub_error(GRUB_ERR_BAD_MODULE,
+                                           "Address out of 13 bits range");
+                      *addr = ((*addr) & 0xFFFFFE000) | delta;
+                      break;
+                    }
 		  default:
 		    return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
 				       "This relocation (%d) is not implemented yet",
-				       ELF64_R_TYPE (rel->r_info));
+				       ELF64_R_TYPE_ID (ELF64_R_TYPE (rel->r_info)));
 		  }
 	      }
 	  }
Index: kern/sparc64/ieee1275/init.c
===================================================================
RCS file: /sources/grub/grub2/kern/sparc64/ieee1275/init.c,v
retrieving revision 1.2
diff -u -p -r1.2 init.c
--- kern/sparc64/ieee1275/init.c	25 Apr 2006 20:08:31 -0000	1.2
+++ kern/sparc64/ieee1275/init.c	4 Mar 2007 12:32:08 -0000
@@ -140,6 +140,34 @@ grub_machine_set_prefix (void)
   grub_free (prefix);
 }
 
+/* Claim some available memory in the first /memory node. */
+static void grub_claim_heap (unsigned long heaplimit)
+{
+  auto int heap_init (grub_uint64_t addr, grub_uint64_t len);
+  int heap_init (grub_uint64_t addr, grub_uint64_t len)
+  {
+    len -= 1; /* Required for some firmware.  */
+
+    /* Don't claim anything above `heaplimit'.  */
+    if (addr + len > heaplimit)
+      len = heaplimit - addr;
+
+    if (len)
+      {
+        /* Claim and use it.  */
+        if (grub_claimmap (addr, len) < 0)
+          return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+                             "Failed to claim heap at 0x%llx, len 0x%llx\n",
+                             addr, len);
+        grub_mm_init_region ((void *) (grub_addr_t) addr, len);
+      }
+
+    return 0;
+  }
+
+  grub_available_iterate (heap_init);
+}
+
 void
 grub_machine_init (void)
 {
@@ -208,7 +236,7 @@ grub_machine_fini (void)
 void
 grub_exit (void)
 {
-  grub_ieee1275_enter ();
+  grub_ieee1275_exit ();
 }
 
 grub_uint32_t
Index: kern/sparc64/ieee1275/openfw.c
===================================================================
RCS file: /sources/grub/grub2/kern/sparc64/ieee1275/openfw.c,v
retrieving revision 1.1
diff -u -p -r1.1 openfw.c
--- kern/sparc64/ieee1275/openfw.c	21 Aug 2005 18:42:55 -0000	1.1
+++ kern/sparc64/ieee1275/openfw.c	4 Mar 2007 12:32:08 -0000
@@ -91,7 +91,6 @@ grub_devalias_iterate (int (*hook) (stru
   grub_ieee1275_phandle_t devalias;
   char aliasname[32];
   grub_ssize_t actual;
-  grub_ieee1275_cell_t flags;
   struct grub_ieee1275_devalias alias;
 
   if (grub_ieee1275_finddevice ("/aliases", &devalias))
@@ -99,8 +98,7 @@ grub_devalias_iterate (int (*hook) (stru
 
   aliasname[0] = '\0';
 
-  while (grub_ieee1275_next_property (devalias, aliasname, aliasname, &flags) != -1
-	 && ((signed) flags) != -1 )
+  while (grub_ieee1275_next_property (devalias, aliasname, aliasname) != -1)
     {
       grub_ieee1275_phandle_t dev;
       grub_ssize_t pathlen, typelen;
@@ -164,6 +162,53 @@ grub_devalias_iterate (int (*hook) (stru
   return 0;
 }
 
+grub_err_t grub_available_iterate (int (*hook) (grub_uint64_t, grub_uint64_t))
+{
+  grub_ieee1275_phandle_t root;
+  grub_ieee1275_phandle_t memory;
+  grub_uint32_t available[32];
+  int address_cells = 1;
+  int size_cells = 1;
+  unsigned int i;
+
+  /* Determine the format of each entry in `available'.  */
+  grub_ieee1275_finddevice ("/", &root);
+  grub_ieee1275_get_property (root, "#address-cells", &address_cells,
+        sizeof address_cells, 0);
+  grub_ieee1275_get_property (root, "#size-cells", &size_cells,
+        sizeof size_cells, 0);
+
+  /* Load `/memory/available'.  */
+  if (grub_ieee1275_finddevice ("/memory", &memory))
+    return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+                       "Couldn't find /memory node");
+  if (grub_ieee1275_get_property (memory, "available", available,
+                                  sizeof available, 0))
+    return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+                       "Couldn't examine /memory/available propery");
+
+  /* Decode each entry and call `hook'.  */
+  i = 0;
+  while (i < sizeof (available))
+    {
+      grub_uint64_t address;
+      grub_uint64_t size;
+
+      address = available[i++];
+      if (address_cells == 2)
+        address = (address << 32) | available[i++];
+
+      size = available[i++];
+      if (size_cells == 2)
+        size = (size << 32) | available[i++];
+
+      if (hook (address, size))
+        break;
+    }
+
+  return grub_errno;
+}
+
 /* FIXME (sparc64) */
 #if 0
 /* Call the "map" method of /chosen/mmu.  */
Index: normal/main.c
===================================================================
RCS file: /sources/grub/grub2/normal/main.c,v
retrieving revision 1.19
diff -u -p -r1.19 main.c
--- normal/main.c	12 Dec 2006 00:13:55 -0000	1.19
+++ normal/main.c	4 Mar 2007 12:32:09 -0000
@@ -30,7 +30,7 @@
 #include <grub/parser.h>
 #include <grub/script.h>
 
-grub_jmp_buf grub_exit_env;
+grub_jmp_buf grub_exit_env __attribute__ ((__aligned__(8)));
 
 static grub_fs_module_list_t fs_module_list = 0;
 
Index: normal/sparc64/setjmp.S
===================================================================
RCS file: /sources/grub/grub2/normal/sparc64/setjmp.S,v
retrieving revision 1.1
diff -u -p -r1.1 setjmp.S
--- normal/sparc64/setjmp.S	23 Oct 2005 21:38:12 -0000	1.1
+++ normal/sparc64/setjmp.S	4 Mar 2007 12:32:09 -0000
@@ -27,13 +27,56 @@
  * int grub_setjmp (grub_jmp_buf env)
  */
 FUNCTION(grub_setjmp)
-        ret
-         nop
+	save	%sp, -192, %sp
+	/* Save global registers.  */
+	/* Don't save %g0, it' always 0.  */
+	stx	%g1, [%i0 +  0]
+/*	stx	%g2, [%i0 +  8]
+	stx	%g3, [%i0 + 16]*/
+	stx	%g4, [%i0 + 24]
+	stx	%g5, [%i0 + 32]
+	stx	%g6, [%i0 + 40]
+	stx	%g7, [%i0 + 48]
+	/* Save stack pointer.  */
+	stx	%sp, [%i0 + 56]
+	/* Save frame pointer.  */
+	stx	%fp, [%i0 + 64]
+	/* Save return address.  */
+	stx	%i7, [%i0 + 72]
+	/* Return 0.  */
+	mov    0, %i0
+	ret
+	 restore
 
 /*
  * int grub_longjmp (grub_jmp_buf env, int val)
  */
 FUNCTION(grub_longjmp)
-        ret
-         nop
+	save	%sp, -192, %sp
+	/* Flush all windows to stack to make sure the window ring is empty
+	and we can safely return.  */
+	flushw
+	/* Restore global registers.  */
+	ldx	[%i0 +  0], %g1
+/*	ldx	[%i0 +  8], %g2
+	ldx	[%i0 + 16], %g3*/
+	ldx	[%i0 + 24], %g4
+	ldx	[%i0 + 32], %g5
+	ldx	[%i0 + 40], %g6
+	ldx	[%i0 + 48], %g7
+	/* Restore stack pointer.  */
+	ldx	[%i0 + 56], %sp
+	/* Restore frame pointer.  */
+	ldx	[%i0 + 64], %fp
+	/* Restore return address.  */
+	ldx	[%i0 + 72], %i7
+	/* Return the 2nd parameter value.  */
+        /* If the value to return is 0, return 1 instead. */
+        cmp     %i1, %g0
+        bne,a,pt %icc, return
+         mov    %i1, %i0
+        mov     1, %i0
+return:
+	ret
+	 restore
 
/*
 *  GRUB  --  GRand Unified Bootloader
 *  Copyright (C) 2004  Free Software Foundation, Inc.
 *
 *  This program 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 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef GRUB_LOADER_MACHINE_HEADER
#define GRUB_LOADER_MACHINE_HEADER	1

/* The symbol shared between the normal mode and rescue mode
   loader.  */
void grub_rescue_cmd_linux (int argc, char *argv[]);
void grub_rescue_cmd_initrd (int argc, char *argv[]);

void grub_linux_init (void);
void grub_linux_fini (void);
void grub_linux_normal_init (void);
void grub_linux_normal_fini (void);

#endif /* ! GRUB_LOADER_MACHINE_HEADER */

Attachment: pgphewaB38UJY.pgp
Description: PGP signature

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to