DL support on usparc & cls disabling when debugging
PATCH 1/1 DL support on usparc & cls disabling when debugging
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 [email protected]
* 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.
Index: kern/sparc64/dl.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/sparc64/dl.c,v
retrieving revision 1.1
sparc64/dl.c +37 -37
@@ -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)); } } }
Index: kern/term.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/term.c,v
retrieving revision 1.9
term.c +4 -0
@@ -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
sparc64/ieee1275/init.c +4 -4
@@ -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
Quoted 3 lines · Vincent Pelletier
Hi.
Finally, I send this
dl.cpatch.
With a bad gnupg signature here.
Signature · 2 lines
Member AFFS, WYLUG, SWP (UK), UAF, RESPECT, StWC No to software patents! Victory to the iraqi resistance!
Quoted 1 line · Timothy Baldwin
With a bad gnupg signature here.
Probably because of the mailing list signature...
Quoted 2 lines · Vincent Pelletier
I'll send a separate patch for the .mk & .rmk files, because I have a lot of dust in those files.
Here they are, along with cache.S
I'll commit those tomorrow if nothing is wrong with those (conf/sparc64-ieee1275.rmk, conf/sparc64-ieee1275.mk and kern/sparc64/dl.c, kern/sparc64/cache.S, -kern/sparc64/cache.c).
2005-10-22 Vincent Pelletier <[email protected]>
* kern/sparc64/cache.S : New file (for sparc64 port). Replaces kern/sparc64/cache.c.
* conf/sparc64-ieee1275.rmk (COMMON_ASFLAGS):
(COMMON_CFLAGS): Don't use registers for globals as it' not implemented in dynamic loader.
(COMMON_LDFLAGS): Link as elf64.
(grubof_HEADERS): Sync with grub progression. (normal_mod_SOURCES): Likewise.
(grubof_SOURCES): Revert to ASM file for cache flushing, as it's now implemented.
(grubof_LDFLAGS): Don't use register for globals, use the correct parameter to tell linker which model to use (thanks Jeff Bailey).
(pkgdata_MODULES): Enable module build - except linux.mod and _linux.mod.
(_linux_mod_SOURCES): Commented because module isn't built. (_linux_mod_CFLAGS, linux_mod_SOURCES, linux_mod_CFLAGS):
Likewise.
(_linux_mod_LDFLAGS): New macro, commented out because module isn't built.
(linux_mod_LDFLAGS): Likewise.
(fshelp_mod_LDFLAGS): New macro.
(fat_mod_LDFLAGS, ext2_mod_LDFLAGS, ufs_mod_LDFLAGS, minix_mod_LDFLAGS, hfs_mod_LDFLAGS, jfs_mod_LDFLAGS, iso9660_mod_LDFLAGS, normal_mod_LDFLAGS, hello_mod_LDFLAGS, boot_mod_LDFLAGS, terminal_mod_LDFLAGS, ls_mod_LDFLAGS, cmp_mod_LDFLAGS, cat_mod_LDFLAGS, font_mod_LDFLAGS, amiga_mod_LDFLAGS, apple_mod_LDFLAGS, pc_mod_LDFLAGS, sun_mod_LDFLAGS, loopback_mod_LDFLAGS, suspend_mod_LDFLAGS, reboot_mod_LDFLAGS, halt_mod_LDFLAGS, help_mod_LDFLAGS, default_mod_LDFLAGS, timeout_mod_LDFLAGS,
configfile_mod_LDFLAGS, search_mod_LDFLAGS): Likewise.
* conf/sparc64-ieee1275.mk: Generated from sparc64-ieee1275.rmk.
Index: cache.S
===================================================================
RCS file: cache.S
cache.S new file +44 -0
@@ -0,0 +1,44 @@ +/* cache.S - Flush the processor cache for a specific region. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 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. + */ + +#include <grub/symbol.h> + + .file "cache.S" + + .text + +/* + * void grub_arch_sync_caches (void *address, grub_size_t len) + */ +FUNCTION(grub_arch_sync_caches) + save %o6, -0xC, %o6 ! Get a new register window, + ! reserve space on stack for + ! %i0, %i1, %i2 + brz,pn %i0, return ! Return if address == 0. + nop + brz,pn %i1, return ! Return if len == 0. + clr %i2 ! index = 0. +loop: flush %i0 + %i2 ! Flush address + index. + cmp %i1, %i2 ! Compare len & index . + bpos,a,pt %xcc, loop ! If len > index, loop. + add %i2, 8, %i2 ! Go to next doubleword. +return: ret ! Restore caller's register + restore ! window and return. +
Index: cache.c
===================================================================
RCS file: cache.c
cache.c deleted +0 -9
@@ -1,9 +0,0 @@ -#include <grub/types.h> - -void grub_arch_sync_caches (void *address __attribute__((unused)), -grub_size_t len __attribute__((unused))); -void grub_arch_sync_caches (void *address __attribute__((unused)), -grub_size_t len __attribute__((unused))) -{ -return ; -}
Index: sparc64-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.2
sparc64-ieee1275.rmk +51 -17
213 lines not on this page · raw message
Index: sparc64-ieee1275.mk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/sparc64-ieee1275.mk,v retrieving revision 1.2
sparc64-ieee1275.mk +1544 -21
1,727 lines not on this page · raw message
Quoted 8 lines · Vincent Pelletier
Quoted 2 lines · Vincent Pelletier
I'll send a separate patch for the .mk & .rmk files, because I have a lot of dust in those files.
Here they are, along with
cache.S
I'll commit those tomorrow if nothing is wrong with those (conf/sparc64-ieee1275.rmk,conf/sparc64-ieee1275.mkandkern/sparc64/dl.c,kern/sparc64/cache.S,-kern/sparc64/cache.c).
Especially since your patch affects only sparc64 files, I'd say go right ahead and commit. :)
Quoted 3 lines
2005-10-22 Vincent Pelletier <[email protected]>
...
*conf/sparc64-ieee1275.mk: Generated from sparc64-ieee1275.rmk.
We've been in the habit of simply not mentioning the .mk files: not in the changelog, and not in patches to the list. The diffs are simply too large and not meaningful.
However, when you commit, please do commit the .mk file in addition to the real changes.
Warning: this particular patch you sent has a lot of CVS conflicts in the .mk file. In general please do a build/boot test before sending out a patch... even for "trivial" changes. I've been embarrassed by that a few times myself. :)
-Hollis