Index: grub-2.02~beta2/configure.ac =================================================================== --- grub-2.02~beta2.orig/configure.ac +++ grub-2.02~beta2/configure.ac @@ -1014,7 +1014,7 @@ else CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then +if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test x$target_cpu = xpowerpc || test "x$grub_cv_cc_target_clang" = xyes ; then TARGET_LIBGCC= else TARGET_LIBGCC=-lgcc Index: grub-2.02~beta2/grub-core/kern/powerpc/crtsavres.S =================================================================== --- /dev/null +++ grub-2.02~beta2/grub-core/kern/powerpc/crtsavres.S @@ -0,0 +1,125 @@ +/* + * Special support for eabi and SVR4 + * + * Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc. + * Written By Michael Meissner + * 64-bit support written by David Edelsohn + * + * This file 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, or (at your option) any + * later version. + * + * In addition to the permissions in the GNU General Public License, the + * Free Software Foundation gives you unlimited permission to link the + * compiled version of this file with other programs, and to distribute + * those programs without any restriction coming from the use of this + * file. (The General Public License restrictions do apply in other + * respects; for example, they cover modification of the file, and + * distribution when not linked into another program.) + * + * This file 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; see the file COPYING. If not, write to + * the Free Software Foundation, 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * As a special exception, if you link this library with files + * compiled with GCC to produce an executable, this does not cause + * the resulting executable to be covered by the GNU General Public License. + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + */ + +/* Do any initializations needed for the eabi environment */ + + .file "crtsavres.S" + .section ".text" + +/* On PowerPC64 Linux, these functions are provided by the linker. */ +#ifndef __powerpc64__ + +#define FUNC_START(name) \ + .type name,@function; \ + .globl name; \ +name: + +/* Routines for saving integer registers, called by the compiler. */ +/* Called with r11 pointing to the stack header word of the caller of the */ +/* function, just beyond the end of the integer save area. */ + +FUNC_START(_savegpr_14) stw 14,-72(11) /* save gp registers */ +FUNC_START(_savegpr_15) stw 15,-68(11) +FUNC_START(_savegpr_16) stw 16,-64(11) +FUNC_START(_savegpr_17) stw 17,-60(11) +FUNC_START(_savegpr_18) stw 18,-56(11) +FUNC_START(_savegpr_19) stw 19,-52(11) +FUNC_START(_savegpr_20) stw 20,-48(11) +FUNC_START(_savegpr_21) stw 21,-44(11) +FUNC_START(_savegpr_22) stw 22,-40(11) +FUNC_START(_savegpr_23) stw 23,-36(11) +FUNC_START(_savegpr_24) stw 24,-32(11) +FUNC_START(_savegpr_25) stw 25,-28(11) +FUNC_START(_savegpr_26) stw 26,-24(11) +FUNC_START(_savegpr_27) stw 27,-20(11) +FUNC_START(_savegpr_28) stw 28,-16(11) +FUNC_START(_savegpr_29) stw 29,-12(11) +FUNC_START(_savegpr_30) stw 30,-8(11) +FUNC_START(_savegpr_31) stw 31,-4(11) + blr + +/* Routines for restoring integer registers, called by the compiler. */ +/* Called with r11 pointing to the stack header word of the caller of the */ +/* function, just beyond the end of the integer restore area. */ + +FUNC_START(_restgpr_14) lwz 14,-72(11) /* restore gp registers */ +FUNC_START(_restgpr_15) lwz 15,-68(11) +FUNC_START(_restgpr_16) lwz 16,-64(11) +FUNC_START(_restgpr_17) lwz 17,-60(11) +FUNC_START(_restgpr_18) lwz 18,-56(11) +FUNC_START(_restgpr_19) lwz 19,-52(11) +FUNC_START(_restgpr_20) lwz 20,-48(11) +FUNC_START(_restgpr_21) lwz 21,-44(11) +FUNC_START(_restgpr_22) lwz 22,-40(11) +FUNC_START(_restgpr_23) lwz 23,-36(11) +FUNC_START(_restgpr_24) lwz 24,-32(11) +FUNC_START(_restgpr_25) lwz 25,-28(11) +FUNC_START(_restgpr_26) lwz 26,-24(11) +FUNC_START(_restgpr_27) lwz 27,-20(11) +FUNC_START(_restgpr_28) lwz 28,-16(11) +FUNC_START(_restgpr_29) lwz 29,-12(11) +FUNC_START(_restgpr_30) lwz 30,-8(11) +FUNC_START(_restgpr_31) lwz 31,-4(11) + blr + +/* Routines for restoring integer registers, called by the compiler. */ +/* Called with r11 pointing to the stack header word of the caller of the */ +/* function, just beyond the end of the integer restore area. */ + +FUNC_START(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */ +FUNC_START(_restgpr_15_x) lwz 15,-68(11) +FUNC_START(_restgpr_16_x) lwz 16,-64(11) +FUNC_START(_restgpr_17_x) lwz 17,-60(11) +FUNC_START(_restgpr_18_x) lwz 18,-56(11) +FUNC_START(_restgpr_19_x) lwz 19,-52(11) +FUNC_START(_restgpr_20_x) lwz 20,-48(11) +FUNC_START(_restgpr_21_x) lwz 21,-44(11) +FUNC_START(_restgpr_22_x) lwz 22,-40(11) +FUNC_START(_restgpr_23_x) lwz 23,-36(11) +FUNC_START(_restgpr_24_x) lwz 24,-32(11) +FUNC_START(_restgpr_25_x) lwz 25,-28(11) +FUNC_START(_restgpr_26_x) lwz 26,-24(11) +FUNC_START(_restgpr_27_x) lwz 27,-20(11) +FUNC_START(_restgpr_28_x) lwz 28,-16(11) +FUNC_START(_restgpr_29_x) lwz 29,-12(11) +FUNC_START(_restgpr_30_x) lwz 30,-8(11) +FUNC_START(_restgpr_31_x) lwz 0,4(11) + lwz 31,-4(11) + mtlr 0 + mr 1,11 + blr +#endif Index: grub-2.02~beta2/grub-core/Makefile.core.def =================================================================== --- grub-2.02~beta2.orig/grub-core/Makefile.core.def +++ grub-2.02~beta2/grub-core/Makefile.core.def @@ -250,6 +250,8 @@ kernel = { extra_dist = video/sis315_init.c; mips_loongson = commands/keylayouts.c; + powerpc_ieee1275 = kern/powerpc/crtsavres.S; + powerpc_ieee1275 = disk/ieee1275/libgcc.c; powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; Index: grub-2.02~beta2/grub-core/disk/ieee1275/libgcc.c =================================================================== --- /dev/null +++ grub-2.02~beta2/grub-core/disk/ieee1275/libgcc.c @@ -0,0 +1,106 @@ + +typedef int int32 __attribute__ ((mode (SI))); +typedef unsigned int uint32 __attribute__ ((mode (SI))); +typedef int int64 __attribute__ ((mode (DI))); +typedef unsigned uint64 __attribute__ ((mode (DI))); + +typedef union { + int64 ll; + struct { + int32 low, high; + } u; +} DWunion; +extern int64 __ashldi3 (int64, int32); +int64 __ashldi3(int64 x, int32 count) +{ + if (!count) + return x; + + const DWunion uu = {.ll = x}; + const int32 bm = 4 * sizeof (int64) - count; /* 8 * size (int64) / 2 */ + DWunion w; + + if (bm <= 0) + { + w.u.low = 0; + w.u.high = (uint32) uu.u.low << -bm; + } + else + { + const uint32 carries = (uint32) uu.u.low >> bm; + + w.u.low = (uint32) uu.u.low << count; + w.u.high = ((uint32) uu.u.high << count) | carries; + } + + return w.ll; +} +extern int64 __lshrdi3 (int64 , int32); +int64 __lshrdi3(int64 x, int32 count) +{ + if (!count) + return x; + + const DWunion uu = {.ll = x}; + const int32 bm = 4 * sizeof (int64) - count; + DWunion w; + + if (bm <= 0) + { + w.u.high = 0; + w.u.low = (uint32) uu.u.high >> -bm; + } + else + { + const uint32 carries = (uint32) uu.u.high << bm; + + w.u.high = (uint32) uu.u.high >> count; + w.u.low = ((uint32) uu.u.low >> count) | carries; + } + + return w.ll; +} + +extern int64 __ashrdi3 (int64, int32); +int64 __ashrdi3(int64 x, int32 count) +{ + if (!count) + return x; + + const DWunion uu = {.ll = x}; + const int32 bm = 4 * sizeof (int64) - count; /* 8 * size (int64) / 2 */ + DWunion w; + + if (bm <= 0) + { + w.u.high = + uu.u.high >> 31; + w.u.low = uu.u.high >> -bm; + } + else + { + const uint32 carries = (uint32) uu.u.high << bm; + + w.u.high = (uint32) uu.u.high >> count; + w.u.low = ((uint32) uu.u.low >> count) | carries; + } + + return w.ll; +} +extern int64 __ucmpdi2 (int64, int64); +int64 __ucmpdi2(int64 a, int64 b) +{ + const DWunion au = {.ll = a}; + const DWunion bu = {.ll = b}; + + if ((unsigned int) au.u.high < (unsigned int) bu.u.high) + return 0; + else if ((unsigned int) au.u.high > (unsigned int) bu.u.high) + return 2; + if ((unsigned int) au.u.low < (unsigned int) bu.u.low) + return 0; + else if ((unsigned int) au.u.low > (unsigned int) bu.u.low) + return 2; + return 1; +} + Index: grub-2.02~beta2/include/grub/libgcc.h =================================================================== --- grub-2.02~beta2.orig/include/grub/libgcc.h +++ grub-2.02~beta2/include/grub/libgcc.h @@ -24,16 +24,16 @@ /* On x86 these functions aren't really needed. Save some space. */ #if !defined (__i386__) && !defined (__x86_64__) -# ifdef HAVE___ASHLDI3 +# if defined (HAVE___ASHLDI3) || defined (__powerpc__) void EXPORT_FUNC (__ashldi3) (void); # endif -# ifdef HAVE___ASHRDI3 +# if defined (HAVE___ASHRDI3) || defined (__powerpc__) void EXPORT_FUNC (__ashrdi3) (void); # endif -# ifdef HAVE___LSHRDI3 +# if defined (HAVE___LSHRDI3) || defined (__powerpc__) void EXPORT_FUNC (__lshrdi3) (void); # endif -# ifdef HAVE___UCMPDI2 +# if defined (HAVE___UCMPDI2) || defined (__powerpc__) void EXPORT_FUNC (__ucmpdi2) (void); # endif # ifdef HAVE___BSWAPSI2 @@ -50,7 +50,7 @@ void EXPORT_FUNC (__ctzsi2) (void); # endif #endif -#ifdef HAVE__RESTGPR_14_X +#if defined (HAVE__RESTGPR_14_X) || defined (__powerpc__) void EXPORT_FUNC (_restgpr_14_x) (void); void EXPORT_FUNC (_restgpr_15_x) (void); void EXPORT_FUNC (_restgpr_16_x) (void);