All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Pelletier <subdino2004@yahoo.fr>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] DL support on usparc & cls disabling when debugging
Date: Wed, 12 Oct 2005 19:53:21 +0200	[thread overview]
Message-ID: <434D4D91.10207@yahoo.fr> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 710 bytes --]

Hi.

Finally, I send this dl.c patch.
I'll send a separate patch for the .mk & .rmk files, because I have a
lot of dust in those files.

I also joined a patch to disable cls when setting a debug level, and
some changes to parse such arguments before any initialisation, so error
messages won't get cleaned by a cls in early boot.

2005-10-12  Vincent Pelletier  subdino2004@yahoo.fr

	* kern/sparc64/dl.c (grub_arch_dl_check_header): Use sparcv9
	ELF header values.
	grub_arch_dl_relocate_symbols) : Implement 64 bits relocations.
	* kern/term.c (grub_cls): Return without clearing screen if
	debug is set.
	* kern/sparc64/ieee1275/init.c (grub_machine_init): Read
	environment variables before anything else.

[-- Attachment #1.2: dl.diff --]
[-- Type: text/plain, Size: 3979 bytes --]

Index: kern/sparc64/dl.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/sparc64/dl.c,v
retrieving revision 1.1
diff -u -p -r1.1 dl.c
--- kern/sparc64/dl.c	21 Aug 2005 18:42:55 -0000	1.1
+++ kern/sparc64/dl.c	12 Oct 2005 17:34:00 -0000
@@ -30,9 +30,9 @@ grub_arch_dl_check_header (void *ehdr)
   Elf64_Ehdr *e = ehdr;
 
   /* Check the magic numbers.  */
-  if (e->e_ident[EI_CLASS] != ELFCLASS32
+  if (e->e_ident[EI_CLASS] != ELFCLASS64
       || e->e_ident[EI_DATA] != ELFDATA2MSB
-      || e->e_machine != EM_PPC)
+      || e->e_machine != EM_SPARCV9)
     return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
 
   return GRUB_ERR_NONE;
@@ -83,53 +83,53 @@ grub_arch_dl_relocate_symbols (grub_dl_t
 		 rel < max;
 		 rel++)
 	      {
-		Elf64_Xword *addr;
+		Elf64_Word *addr;
 		Elf64_Sym *sym;
-		grub_uint64_t value;
+		Elf64_Addr value;
 		
 		if (seg->size < rel->r_offset)
 		  return grub_error (GRUB_ERR_BAD_MODULE,
 				     "reloc offset is out of the segment");
 		
-		addr = (Elf64_Xword *) ((char *) seg->addr + rel->r_offset);
+		addr = (Elf64_Word *) ((char *) seg->addr + rel->r_offset);
 		sym = (Elf64_Sym *) ((char *) symtab
-				     + entsize * ELF32_R_SYM (rel->r_info));
-		
-		/* On the PPC the value does not have an explicit
-		   addend, add it.  */
+				     + entsize * ELF64_R_SYM (rel->r_info));
+
 		value = sym->st_value + rel->r_addend;
-		switch (ELF32_R_TYPE (rel->r_info))
+		switch (ELF64_R_TYPE (rel->r_info))
 		  {
-		  case R_PPC_ADDR16_LO:
-		    *(Elf64_Half *) addr = value;
-		    break;
-		    
-		  case R_PPC_REL24:
-		    {
-		      Elf64_Sxword delta = value - (Elf64_Xword) addr;
-		      
-		      if (delta << 6 >> 6 != delta)
-			return grub_error (GRUB_ERR_BAD_MODULE, "Relocation overflow");
-		      *addr = (*addr & 0xfc000003) | (delta & 0x3fffffc);
-		      break;
-		    }
-		    
-		  case R_PPC_ADDR16_HA:
-		    *(Elf64_Half *) addr = (value + 0x8000) >> 16;
-		    break;
-		    
-		  case R_PPC_ADDR32:
-		    *addr = value;
-		    break;
-		    
-		  case R_PPC_REL32:
-		    *addr = value - (Elf64_Xword) addr;
-		    break;
-		    
+                  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;
+                    break;
+                  case R_SPARC_WDISP30: /* 7 V-disp30 */
+                    if (((value - (Elf64_Addr) addr) & 0xFFFFFFFF00000000) &&
+                        ((value - (Elf64_Addr) addr) & 0xFFFFFFFF00000000
+                        != 0xFFFFFFFF00000000))
+                      return grub_error (GRUB_ERR_BAD_MODULE,
+                                         "Displacement out of 30 bits range");
+                    *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)
+                      return grub_error (GRUB_ERR_BAD_MODULE,
+                                         "High address out of 22 bits range");
+                    *addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF);
+                    break;
+                  case R_SPARC_LO10: /* 12 T-simm13 */
+                    *addr = (*addr & 0xFFFFFC00) | (value & 0x3FF);
+                    break;
+                  case R_SPARC_64: /* 32 V-xwords64 */
+                    *(Elf64_Xword *) addr = value;
+                    break;
 		  default:
 		    return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
 				       "This relocation (%d) is not implemented yet",
-				       ELF32_R_TYPE (rel->r_info));
+				       ELF64_R_TYPE (rel->r_info));
 		  }
 	      }
 	  }

[-- Attachment #1.3: debug_cls.diff --]
[-- Type: text/plain, Size: 1474 bytes --]

Index: kern/term.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/term.c,v
retrieving revision 1.9
diff -u -p -r1.9 term.c
--- kern/term.c	20 Aug 2005 05:26:51 -0000	1.9
+++ kern/term.c	12 Oct 2005 17:34:00 -0000
@@ -21,6 +21,7 @@
 #include <grub/err.h>
 #include <grub/mm.h>
 #include <grub/misc.h>
+#include <grub/env.h>
 
 /* The list of terminals.  */
 static grub_term_t grub_term_list;
@@ -203,6 +204,9 @@ grub_gotoxy (grub_uint8_t x, grub_uint8_
 void
 grub_cls (void)
 {
+  if (grub_env_get ("debug"))
+    return;
+
   if (grub_cur_term->flags & GRUB_TERM_DUMB)
     {
       grub_putchar ('\n');
Index: kern/sparc64/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/sparc64/ieee1275/init.c,v
retrieving revision 1.1
diff -u -p -r1.1 init.c
--- kern/sparc64/ieee1275/init.c	21 Aug 2005 18:42:55 -0000	1.1
+++ kern/sparc64/ieee1275/init.c	12 Oct 2005 17:34:00 -0000
@@ -163,10 +163,6 @@ grub_machine_init (void)
 		   grub_heap_len);
   grub_mm_init_region ((void *) grub_heap_start, grub_heap_len);
 
-  grub_set_prefix ();
-
-  grub_ofdisk_init ();
-
   /* Process commandline.  */
   if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootargs",
                                          &length) == 0 &&
@@ -205,11 +201,18 @@ grub_machine_init (void)
 	}
     }
 
+  grub_set_prefix ();
+
+  grub_ofdisk_init ();
+
 }
 
 void

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2005-10-12 18:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-12 17:53 Vincent Pelletier [this message]
2005-10-12 18:28 ` [PATCH] DL support on usparc & cls disabling when debugging Timothy Baldwin
2005-10-12 19:17   ` Vincent Pelletier
2005-10-22 12:24 ` Vincent Pelletier
2005-10-23  3:12   ` Hollis Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=434D4D91.10207@yahoo.fr \
    --to=subdino2004@yahoo.fr \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.