From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1DsQ5n-00082g-4w for mharc-grub-devel@gnu.org; Tue, 12 Jul 2005 15:06:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DsQ5j-000817-RD for grub-devel@gnu.org; Tue, 12 Jul 2005 15:06:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DsQ5f-0007zM-SL for grub-devel@gnu.org; Tue, 12 Jul 2005 15:06:50 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DsQ1v-00073v-N8 for grub-devel@gnu.org; Tue, 12 Jul 2005 15:02:55 -0400 Received: from [217.12.11.35] (helo=smtp004.mail.ukl.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.34) id 1DsPtr-00072V-Ch for grub-devel@gnu.org; Tue, 12 Jul 2005 14:54:36 -0400 Received: (qmail 15211 invoked from network); 12 Jul 2005 18:46:40 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:Message-ID:Date:From:User-Agent:X-Accept-Language:MIME-Version:To:Subject:References:In-Reply-To:X-Enigmail-Version:Content-Type; b=fjFPQDwVf6AfA/GS74w3oYK9Vxn5d1Zv/FDB8e9TUPmSlucM9yz8JEnIdpR9FFtRs9hge7gqcL+rF2KiKYhBMaks87JIXyR6MJ/c0/jI2w6Rly0KciNKyO2IniSvqUwM6WRr7Xr0LX1R/1nLqncouvUJ+Gd1BUpNNfk5wvFt0Qs= ; Received: from unknown (HELO ?192.168.0.2?) (subdino2004@83.194.179.151 with plain) by smtp004.mail.ukl.yahoo.com with SMTP; 12 Jul 2005 18:46:35 -0000 Message-ID: <42D41013.4040601@yahoo.fr> Date: Tue, 12 Jul 2005 20:46:43 +0200 From: Vincent Pelletier User-Agent: Debian Thunderbird 1.0.2 (X11/20050602) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <42D26452.3010706@yahoo.fr> <200507121258.40668.okuji@enbug.org> <42D3B827.4090103@yahoo.fr> <87hdf0p4jy.fsf@student.han.nl> <42D3C877.3040607@yahoo.fr> <5b8d0feefaf6717dc015cc834de2da1b@penguinppc.org> <877jfwowlo.fsf@student.han.nl> In-Reply-To: <877jfwowlo.fsf@student.han.nl> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/mixed; boundary="------------020901090700060205070403" Subject: sparc64 port : diffs to powerpc branches X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2005 19:06:52 -0000 This is a multi-part message in MIME format. --------------020901090700060205070403 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. Here are the diffs powerpc -> usparc, with some comments below. To be used to know which files can be made common. boot: cmain renamed in _start (no asm). Special ppc options removed. All the ieee1275 functions use the grub_intn_t type (see includes). Add explicit casts where needed. Make "exit" call a "no return". disk: Special ppc test removed. Types changed. include: ieee1275 functions prototypes updated. Add explicit casts where needed. Special ppc structs removed. multiboot.h, libgcc removed (weren't modified). Types length modified. kern: New dummy function (no asm). dl updated to 64 bits ELF, but I'm not sure where it is used... grub_heap_start at 0x40000 to start after the ELF image in memory (when net loaded) Changed "abort" to use "enter" OF standard function : now it *does* return when the user types "go" at the OF prompt. Changed "stop" to use "exit" OF standard function : doesn't return, but fall back to OF prompt. Changed some suspicious "&string" to just "string". Added malloc calls when size can be known. Removed "XXX" when documentation answers. Added dprintf calls. Disabled (#if 0) unused function. Remove ppc specific partition numbering thing. Use OB command to shut-down. loader: (nothing) normal: New dummy function (no asm). term: Type changes. Added an environment variable to disable cls (useful to see early messages). util: Brute changes... Like dl, I don't know when it is used, so... Vincent Pelletier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC1BATFEQoKRQyjtURAgZeAJ9yjTdxcQ20gTAJ7w1QGwXc+mM3ZQCgqD1w qYxuopRVuv+dKC5CKql/lQw= =09bV -----END PGP SIGNATURE----- --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_boot.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_boot.f.diff" diff -rupN powerpc/ieee1275/cmain.c sparc64/ieee1275/cmain.c --- powerpc/ieee1275/cmain.c 2005-06-21 05:12:15.000000000 +0200 +++ sparc64/ieee1275/cmain.c 2005-07-12 20:06:59.000000000 +0200 @@ -1,4 +1,4 @@ -/* cmain.c - Startup code for the PowerPC. */ +/* cmain.c - Startup code for the UltraSparc. */ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. @@ -24,80 +24,30 @@ #include #include -/* OpenFirmware entry point passed to us from the real bootloader. */ +/* OpenBoot entry point. */ intptr_t (*grub_ieee1275_entry_fn) (void *); grub_ieee1275_phandle_t grub_ieee1275_chosen; -static grub_uint32_t grub_ieee1275_flags; - - - -int -grub_ieee1275_test_flag (enum grub_ieee1275_flag flag) -{ - return (grub_ieee1275_flags & (1 << flag)); -} - void -grub_ieee1275_set_flag (enum grub_ieee1275_flag flag) -{ - grub_ieee1275_flags |= (1 << flag); -} - -static void -grub_ieee1275_find_options (void) -{ - grub_ieee1275_phandle_t options; - grub_ieee1275_phandle_t openprom; - int realmode; - int smartfw; - - grub_ieee1275_finddevice ("/options", &options); - grub_ieee1275_get_property (options, "real-mode?", &realmode, - sizeof (realmode), 0); - if (realmode) - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE); - - grub_ieee1275_finddevice ("/openprom", &openprom); - smartfw = grub_ieee1275_get_property (openprom, "SmartFirmware-version", - 0, 0, 0); - if (smartfw != -1) - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); -} - -void cmain (uint32_t r3, uint32_t r4, uint32_t r5); +_start (uint64_t r0 __attribute__((unused)), + uint64_t r1 __attribute__((unused)), + uint64_t r2 __attribute__((unused)), + uint64_t r3 __attribute__((unused)), + uint64_t r4, + uint64_t r5 __attribute__((unused))); void -cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5) +_start (uint64_t r0 __attribute__((unused)), + uint64_t r1 __attribute__((unused)), + uint64_t r2 __attribute__((unused)), + uint64_t r3 __attribute__((unused)), + uint64_t r4, + uint64_t r5 __attribute__((unused))) { - if (r5 == 0xdeadbeef) - { - /* Entered from Old World stage1. */ - extern char _start; - extern char _end; - - grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3; - - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); - - /* Old World Open Firmware may use 4M-5M without claiming it. */ - grub_ieee1275_claim (0x00400000, 0x00100000, 0, 0); - - /* Need to claim ourselves so we don't cannibalize our memory later. */ - if (grub_ieee1275_claim ((grub_addr_t) &_start, (grub_addr_t) &_end - - (grub_addr_t) &_start, 0, 0)) - abort(); - } - else - { - /* Assume we were entered from Open Firmware. */ - grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5; - } + grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r4; grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen); - grub_ieee1275_find_options (); - /* Now invoke the main function. */ grub_main (); diff -rupN powerpc/ieee1275/crt0.S sparc64/ieee1275/crt0.S --- powerpc/ieee1275/crt0.S 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/crt0.S 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -/* crt0.S - Startup code for the PowerPC. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 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. - */ - -.extern __bss_start -.extern _end - - .text - .align 2 - .globl _start -_start: - li 2, 0 - li 13, 0 - - /* Stage1 won't zero BSS for us. In other cases, why not do it again? */ - lis 6, (__bss_start - 4)@h - ori 6, 6, (__bss_start - 4)@l - lis 7, (_end - 4)@h - ori 7, 7, (_end - 4)@l - subf 7, 6, 7 - srwi 7, 7, 2 /* We store 4 bytes at a time. */ - mtctr 7 -2: stwu 2, 4(6) /* We know r2 is already 0 from above. */ - bdnz 2b - - bl cmain -1: b 1b diff -rupN powerpc/ieee1275/ieee1275.c sparc64/ieee1275/ieee1275.c --- powerpc/ieee1275/ieee1275.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/ieee1275.c 2005-07-12 20:05:49.000000000 +0200 @@ -20,7 +20,6 @@ #include - #define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0) #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1) @@ -42,43 +41,43 @@ grub_ieee1275_finddevice (char *name, gr { struct find_device_args { struct grub_ieee1275_common_hdr common; - char *device; - grub_ieee1275_phandle_t phandle; + grub_intn_t device; + grub_intn_t phandle; } args; INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); - args.device = name; + args.device = (grub_intn_t) name; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *phandlep = args.phandle; + *phandlep = (grub_ieee1275_phandle_t) args.phandle; return 0; } int grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, const char *property, void *buf, - grub_size_t size, grub_size_t *actual) + grub_size_t size, grub_ssize_t *actual) { struct get_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - void *buf; - int buflen; - int size; + grub_intn_t phandle; + grub_intn_t prop; + grub_intn_t buf; + grub_intn_t buflen; + grub_intn_t size; } args; INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); - args.phandle = phandle; - args.prop = property; - args.buf = buf; - args.buflen = size; + args.phandle = (grub_intn_t) phandle; + args.prop = (grub_intn_t) property; + args.buf = (grub_intn_t) buf; + args.buflen = (grub_intn_t) size; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.size; + *actual = (grub_ssize_t) args.size; if (args.size == -1) return -1; return 0; @@ -86,48 +85,47 @@ grub_ieee1275_get_property (grub_ieee127 int grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - char *prop, int *flags) + char *prop, grub_intn_t *flag) { struct get_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *prev_prop; - char *next_prop; - int flags; + grub_intn_t phandle; + grub_intn_t prev_prop; + grub_intn_t next_prop; + grub_intn_t flag; } args; INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); - args.phandle = phandle; - args.prev_prop = prev_prop; - args.next_prop = prop; - args.flags = -1; + args.phandle = (grub_intn_t) phandle; + args.prev_prop = (grub_intn_t) prev_prop; + args.next_prop = (grub_intn_t) prop; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - if (flags) - *flags = args.flags; + if (flag) + *flag = args.flag; return 0; } int grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - const char *prop, grub_size_t *length) + const char *prop, grub_ssize_t *length) { struct get_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *prop; - grub_size_t length; + grub_intn_t phandle; + grub_intn_t prop; + grub_intn_t length; } args; INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); - args.phandle = phandle; - args.prop = prop; - args.length = -1; + args.phandle = (grub_intn_t) phandle; + args.prop = (grub_intn_t) prop; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *length = args.length; + if (length) + *length = (grub_ssize_t) args.length; return 0; } @@ -137,40 +135,41 @@ grub_ieee1275_instance_to_package (grub_ { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - grub_ieee1275_phandle_t phandle; + grub_intn_t ihandle; + grub_intn_t phandle; } args; INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); - args.ihandle = ihandle; + args.ihandle = (grub_intn_t) ihandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *phandlep = args.phandle; + *phandlep = (grub_ieee1275_phandle_t) args.phandle; return 0; } int grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - char *path, grub_size_t len, grub_size_t *actual) + char *path, grub_size_t len, + grub_ssize_t *actual) { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - char *buf; - int buflen; - int actual; + grub_intn_t phandle; + grub_intn_t buf; + grub_intn_t buflen; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); - args.phandle = phandle; - args.buf = path; - args.buflen = len; + args.phandle = (grub_intn_t) phandle; + args.buf = (grub_intn_t) path; + args.buflen = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.actual; + *actual = (grub_ssize_t) args.actual; return 0; } @@ -181,94 +180,94 @@ grub_ieee1275_instance_to_path (grub_iee { struct instance_to_package_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - char *buf; - int buflen; - int actual; + grub_intn_t ihandle; + grub_intn_t buf; + grub_intn_t buflen; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); - args.ihandle = ihandle; - args.buf = path; - args.buflen = len; + args.ihandle = (grub_intn_t) ihandle; + args.buf = (grub_intn_t) path; + args.buflen = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actual) - *actual = args.actual; + *actual = (grub_size_t) args.actual; return 0; } int grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) + grub_size_t len, grub_ssize_t *actualp) { struct write_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; + grub_intn_t ihandle; + grub_intn_t buf; + grub_intn_t len; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; + args.ihandle = (grub_intn_t) ihandle; + args.buf = (grub_intn_t) buffer; + args.len = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actualp) - *actualp = args.actual; + *actualp = (grub_size_t) args.actual; return 0; } int grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - grub_size_t len, grub_size_t *actualp) + grub_size_t len, grub_ssize_t *actualp) { struct write_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - void *buf; - grub_size_t len; - grub_size_t actual; + grub_intn_t ihandle; + grub_intn_t buf; + grub_intn_t len; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); - args.ihandle = ihandle; - args.buf = buffer; - args.len = len; + args.ihandle = (grub_intn_t) ihandle; + args.buf = (grub_intn_t) buffer; + args.len = (grub_intn_t) len; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (actualp) - *actualp = args.actual; + *actualp = (grub_size_t) args.actual; return 0; } int grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi, - int pos_lo, int *result) + int pos_lo, grub_ssize_t *result) { struct write_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; - int pos_hi; - int pos_lo; - int result; + grub_intn_t ihandle; + grub_intn_t pos_hi; + grub_intn_t pos_lo; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); - args.ihandle = ihandle; - args.pos_hi = pos_hi; - args.pos_lo = pos_lo; + args.ihandle = (grub_intn_t) ihandle; + args.pos_hi = (grub_intn_t) pos_hi; + args.pos_lo = (grub_intn_t) pos_lo; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; if (result) - *result = args.result; + *result = (grub_size_t) args.result; return 0; } @@ -278,16 +277,16 @@ grub_ieee1275_peer (grub_ieee1275_phandl { struct peer_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; + grub_intn_t node; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); - args.node = node; + args.node = (grub_intn_t) node; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_phandle_t) args.result; return 0; } @@ -297,17 +296,16 @@ grub_ieee1275_child (grub_ieee1275_phand { struct child_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; + grub_intn_t node; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); - args.node = node; - args.result = IEEE1275_PHANDLE_INVALID; + args.node = (grub_intn_t) node; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_phandle_t) args.result; return 0; } @@ -317,31 +315,31 @@ grub_ieee1275_parent (grub_ieee1275_phan { struct parent_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t node; - grub_ieee1275_phandle_t result; + grub_intn_t node; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); - args.node = node; + args.node = (grub_intn_t) node; args.result = IEEE1275_PHANDLE_INVALID; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_phandle_t) args.result; return 0; } int -grub_ieee1275_interpret (const char *command, int *catch) +grub_ieee1275_interpret (const char *command, grub_intn_t *catch) { struct enter_args { struct grub_ieee1275_common_hdr common; - const char *command; - int catch; + grub_intn_t command; + grub_intn_t catch; } args; INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); - args.command = command; + args.command = (grub_intn_t) command; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; @@ -373,9 +371,8 @@ grub_ieee1275_exit (void) INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - return 0; + IEEE1275_CALL_ENTRY_FN (&args); + for (;;); } int @@ -383,16 +380,16 @@ grub_ieee1275_open (char *node, grub_iee { struct open_args { struct grub_ieee1275_common_hdr common; - char *cstr; - grub_ieee1275_ihandle_t result; + grub_intn_t cstr; + grub_intn_t result; } args; INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); - args.cstr = node; + args.cstr = (grub_intn_t) node; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *result = args.result; + *result = (grub_ieee1275_ihandle_t) args.result; return 0; } @@ -401,15 +398,14 @@ grub_ieee1275_close (grub_ieee1275_ihand { struct close_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_ihandle_t ihandle; + grub_intn_t ihandle; } args; INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); - args.ihandle = ihandle; + args.ihandle = (grub_intn_t) ihandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - return 0; } @@ -419,26 +415,23 @@ grub_ieee1275_claim (grub_addr_t addr, g { struct claim_args { struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; - unsigned int align; - grub_addr_t base; + grub_intn_t addr; + grub_intn_t size; + grub_intn_t align; + grub_intn_t base; } args; INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); - args.addr = addr; - args.size = size; - args.align = align; + args.addr = (grub_intn_t) addr; + args.size = (grub_intn_t) size; + args.align = (grub_intn_t) align; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - if (result) - *result = args.base; - - if (args.base == (grub_addr_t)-1) + *result = (grub_addr_t) args.base; + if ((grub_addr_t) args.base == (grub_addr_t) -1) return -1; - return 0; } @@ -447,17 +440,16 @@ grub_ieee1275_release (grub_addr_t addr, { struct release_args { struct grub_ieee1275_common_hdr common; - grub_addr_t addr; - grub_size_t size; + grub_intn_t addr; + grub_intn_t size; } args; INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); - args.addr = addr; - args.size = size; + args.addr = (grub_intn_t) addr; + args.size = (grub_intn_t) size; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - return 0; } @@ -468,38 +460,43 @@ grub_ieee1275_set_property (grub_ieee127 { struct set_property_args { struct grub_ieee1275_common_hdr common; - grub_ieee1275_phandle_t phandle; - const char *propname; - void *buf; - grub_size_t size; - grub_size_t actual; + grub_intn_t phandle; + grub_intn_t propname; + grub_intn_t buf; + grub_intn_t size; + grub_intn_t actual; } args; INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); - args.size = size; - args.buf = buf; - args.propname = propname; - args.phandle = phandle; + args.size = (grub_intn_t) size; + args.buf = (grub_intn_t) buf; + args.propname = (grub_intn_t) propname; + args.phandle = (grub_intn_t) phandle; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *actual = args.actual; + if(actual) + *actual = (grub_size_t) args.actual; return 0; } int -grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b) +grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle __attribute__((unused)), + int index __attribute__((unused)), + int r __attribute__((unused)), + int g __attribute__((unused)), + int b __attribute__((unused))) { +#if 0 struct set_color_args { struct grub_ieee1275_common_hdr common; - char *method; - grub_ieee1275_ihandle_t ihandle; - int index; - int b; - int g; - int r; - int result; + char *method; //char * + grub_ieee1275_ihandle_t ihandle; // + int index; //int + int b; //int + int g; //int + int r; //int + int result; //int } args; INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); @@ -512,22 +509,22 @@ grub_ieee1275_set_color (grub_ieee1275_i if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - +#endif return 0; } int -grub_ieee1275_milliseconds (grub_uint32_t *msecs) +grub_ieee1275_milliseconds (grub_uintn_t *msecs) { struct milliseconds_args { struct grub_ieee1275_common_hdr common; - grub_uint32_t msecs; + grub_intn_t msecs; } args; INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1); if (IEEE1275_CALL_ENTRY_FN (&args) == -1) return -1; - *msecs = args.msecs; + *msecs = (grub_uintn_t) args.msecs; return 0; } --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_disk.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_disk.f.diff" diff -rupN powerpc/ieee1275/ofdisk.c sparc64/ieee1275/ofdisk.c --- powerpc/ieee1275/ofdisk.c 2005-05-01 05:45:35.000000000 +0200 +++ sparc64/ieee1275/ofdisk.c 2005-07-12 20:11:06.000000000 +0200 @@ -53,15 +53,14 @@ grub_ofdisk_open (const char *name, grub char *devpath; /* XXX: This should be large enough for any possible case. */ char prop[64]; - int actual; + grub_ssize_t actual; devpath = grub_strndup (name, grub_strlen (name) + 2); if (! devpath) return grub_errno; /* To access the complete disk add `:0'. */ - if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0)) - grub_strcat (devpath, ":0"); + grub_strcat (devpath, ":0"); grub_ieee1275_open (devpath, &dev_ihandle); if (! dev_ihandle) @@ -119,8 +118,8 @@ static grub_err_t grub_ofdisk_read (grub_disk_t disk, unsigned long sector, unsigned long size, char *buf) { - int status; - int actual; + grub_ssize_t status; + grub_ssize_t actual; unsigned long long pos; pos = (unsigned long long) sector * 512UL; --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_include.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_include.f.diff" diff -rupN powerpc/ieee1275/ieee1275.h sparc64/ieee1275/ieee1275.h --- powerpc/ieee1275/ieee1275.h 2005-07-09 01:52:26.000000000 +0200 +++ sparc64/ieee1275/ieee1275.h 2005-07-12 20:16:23.000000000 +0200 @@ -50,13 +50,15 @@ struct grub_ieee1275_mem_region passed arguments and the expected number of return values, resp. */ struct grub_ieee1275_common_hdr { - char *name; - int nr_ins; - int nr_outs; + grub_intn_t name; + grub_intn_t nr_ins; + grub_intn_t nr_outs; }; #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ - (p)->name = xname; (p)->nr_ins = xins; (p)->nr_outs = xouts + (p)->name = (grub_intn_t)xname; \ + (p)->nr_ins = (grub_intn_t)xins; \ + (p)->nr_outs = (grub_intn_t)xouts /* FIXME jrydberg: is this correct cell types? */ typedef intptr_t grub_ieee1275_ihandle_t; @@ -67,24 +69,6 @@ extern grub_ieee1275_phandle_t EXPORT_VA extern intptr_t (*grub_ieee1275_entry_fn) (void *); extern intptr_t (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); -enum grub_ieee1275_flag -{ - /* Old World firmware fails seek when "dev:0" is opened. */ - GRUB_IEEE1275_FLAG_NO_PARTITION_0, - - /* Apple firmware runs in translated mode and requires use of the "map" - method. Other firmware runs in untranslated mode and doesn't like "map" - calls. */ - GRUB_IEEE1275_FLAG_REAL_MODE, - - /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the - whole disk). However, CodeGen firmware numbers partitions from 0. */ - GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS, -}; - -extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); -extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag); - uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p); @@ -93,36 +77,39 @@ int EXPORT_FUNC(grub_ieee1275_finddevice int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t handle, const char *property, void *buf, grub_size_t size, - grub_size_t *actual); -int EXPORT_FUNC(grub_ieee1275_next_property) (int handle, char *prev_prop, - char *prop, int *flags); + grub_ssize_t *actual); +int EXPORT_FUNC(grub_ieee1275_next_property) (grub_ieee1275_phandle_t handle, + char *prev_prop, + char *prop, + grub_intn_t *flag); int EXPORT_FUNC(grub_ieee1275_get_property_length) - (grub_ieee1275_phandle_t handle, const char *prop, grub_size_t *length); + (grub_ieee1275_phandle_t handle, const char *prop, grub_ssize_t *length); int EXPORT_FUNC(grub_ieee1275_instance_to_package) (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep); int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle, char *path, grub_size_t len, - grub_size_t *actual); + grub_ssize_t *actual); int EXPORT_FUNC(grub_ieee1275_instance_to_path) (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len, grub_size_t *actual); int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle, void *buffer, grub_size_t len, - grub_size_t *actualp); + grub_ssize_t *actualp); int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle, void *buffer, grub_size_t len, - grub_size_t *actualp); + grub_ssize_t *actualp); int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle, - int pos_hi, int pos_lo, int *result); + int pos_hi, int pos_lo, + grub_ssize_t *result); int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node, grub_ieee1275_phandle_t *result); int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node, grub_ieee1275_phandle_t *result); int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node, grub_ieee1275_phandle_t *result); -int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, int *catch); +int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, grub_intn_t *catch); int EXPORT_FUNC(grub_ieee1275_enter) (void); -int EXPORT_FUNC(grub_ieee1275_exit) (void); +int EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn)); int EXPORT_FUNC(grub_ieee1275_open) (char *node, grub_ieee1275_ihandle_t *result); int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle); @@ -135,7 +122,7 @@ int EXPORT_FUNC(grub_ieee1275_set_proper grub_size_t *actual); int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, int index, int r, int g, int b); -int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); +int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uintn_t *msecs); grub_err_t EXPORT_FUNC(grub_devalias_iterate) diff -rupN powerpc/ieee1275/multiboot.h sparc64/ieee1275/multiboot.h --- powerpc/ieee1275/multiboot.h 2004-04-04 15:46:01.000000000 +0200 +++ sparc64/ieee1275/multiboot.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,184 +0,0 @@ -/* multiboot.h - multiboot header file. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 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_MULTIBOOT_MACHINE_HEADER -#define GRUB_MULTIBOOT_MACHINE_HEADER 1 - -/* How many bytes from the start of the file we search for the header. */ -#define GRUB_MB_SEARCH 8192 - -/* The magic field should contain this. */ -#define GRUB_MB_MAGIC 0x1BADB002 - -/* This should be in %eax. */ -#define GRUB_MB_MAGIC2 0x2BADB002 - -/* The bits in the required part of flags field we don't support. */ -#define GRUB_MB_UNSUPPORTED 0x0000fffc - -/* Alignment of multiboot modules. */ -#define GRUB_MB_MOD_ALIGN 0x00001000 - -/* - * Flags set in the 'flags' member of the multiboot header. - */ - -/* Align all boot modules on i386 page (4KB) boundaries. */ -#define GRUB_MB_PAGE_ALIGN 0x00000001 - -/* Must pass memory information to OS. */ -#define GRUB_MB_MEMORY_INFO 0x00000002 - -/* Must pass video information to OS. */ -#define GRUB_MB_VIDEO_MODE 0x00000004 - -/* This flag indicates the use of the address fields in the header. */ -#define GRUB_MB_AOUT_KLUDGE 0x00010000 - -/* - * Flags to be set in the 'flags' member of the multiboot info structure. - */ - -/* is there basic lower/upper memory information? */ -#define GRUB_MB_INFO_MEMORY 0x00000001 -/* is there a boot device set? */ -#define GRUB_MB_INFO_BOOTDEV 0x00000002 -/* is the command-line defined? */ -#define GRUB_MB_INFO_CMDLINE 0x00000004 -/* are there modules to do something with? */ -#define GRUB_MB_INFO_MODS 0x00000008 - -/* These next two are mutually exclusive */ - -/* is there a symbol table loaded? */ -#define GRUB_MB_INFO_AOUT_SYMS 0x00000010 -/* is there an ELF section header table? */ -#define GRUB_MB_INFO_ELF_SHDR 0x00000020 - -/* is there a full memory map? */ -#define GRUB_MB_INFO_MEM_MAP 0x00000040 - -/* Is there drive info? */ -#define GRUB_MB_INFO_DRIVE_INFO 0x00000080 - -/* Is there a config table? */ -#define GRUB_MB_INFO_CONFIG_TABLE 0x00000100 - -/* Is there a boot loader name? */ -#define GRUB_MB_INFO_BOOT_LOADER_NAME 0x00000200 - -/* Is there a APM table? */ -#define GRUB_MB_INFO_APM_TABLE 0x00000400 - -/* Is there video information? */ -#define GRUB_MB_INFO_VIDEO_INFO 0x00000800 - -#ifndef ASM_FILE - -#include - -struct grub_multiboot_header -{ - /* Must be GRUB_MB_MAGIC - see above. */ - grub_uint32_t magic; - - /* Feature flags. */ - grub_uint32_t flags; - - /* The above fields plus this one must equal 0 mod 2^32. */ - grub_uint32_t checksum; - - /* These are only valid if GRUB_MB_AOUT_KLUDGE is set. */ - grub_uint32_t header_addr; - grub_uint32_t load_addr; - grub_uint32_t load_end_addr; - grub_uint32_t bss_end_addr; - grub_uint32_t entry_addr; - - /* These are only valid if GRUB_MB_VIDEO_MODE is set. */ - grub_uint32_t mode_type; - grub_uint32_t width; - grub_uint32_t height; - grub_uint32_t depth; -}; - -struct grub_multiboot_info -{ - /* MultiBoot info version number */ - grub_uint32_t flags; - - /* Available memory from BIOS */ - grub_uint32_t mem_lower; - grub_uint32_t mem_upper; - - /* "root" partition */ - grub_uint32_t boot_device; - - /* Kernel command line */ - grub_uint32_t cmdline; - - /* Boot-Module list */ - grub_uint32_t mods_count; - grub_uint32_t mods_addr; - - grub_uint32_t syms[4]; - - /* Memory Mapping buffer */ - grub_uint32_t mmap_length; - grub_uint32_t mmap_addr; - - /* Drive Info buffer */ - grub_uint32_t drives_length; - grub_uint32_t drives_addr; - - /* ROM configuration table */ - grub_uint32_t config_table; - - /* Boot Loader Name */ - grub_uint32_t boot_loader_name; - - /* APM table */ - grub_uint32_t apm_table; - - /* Video */ - grub_uint32_t vbe_control_info; - grub_uint32_t vbe_mode_info; - grub_uint16_t vbe_mode; - grub_uint16_t vbe_interface_seg; - grub_uint16_t vbe_interface_off; - grub_uint16_t vbe_interface_len; -}; - -struct grub_mod_list -{ - /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ - grub_uint32_t mod_start; - grub_uint32_t mod_end; - - /* Module command line */ - grub_uint32_t cmdline; - - /* padding to take it to 16 bytes (must be zero) */ - grub_uint32_t pad; -}; - -#endif /* ! ASM_FILE */ - -#endif /* ! GRUB_MULTIBOOT_MACHINE_HEADER */ diff -rupN powerpc/ieee1275/time.h sparc64/ieee1275/time.h --- powerpc/ieee1275/time.h 2005-02-27 22:19:05.000000000 +0100 +++ sparc64/ieee1275/time.h 2005-07-12 19:14:58.000000000 +0200 @@ -25,6 +25,6 @@ #define GRUB_TICKS_PER_SECOND 1000 /* Return the real time in ticks. */ -grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void); +grub_uintn_t EXPORT_FUNC (grub_get_rtc) (void); #endif /* ! KERNEL_TIME_HEADER */ diff -rupN powerpc/libgcc.h sparc64/libgcc.h --- powerpc/libgcc.h 2005-02-13 19:54:57.000000000 +0100 +++ sparc64/libgcc.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004 Free Software Foundation, Inc. - * - * GRUB 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 GRUB; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -void EXPORT_FUNC (memset) (void); -void EXPORT_FUNC (__adddf3) (void); -void EXPORT_FUNC (__addsf3) (void); -void EXPORT_FUNC (__ashldi3) (void); -void EXPORT_FUNC (__bss_start) (void); -void EXPORT_FUNC (__extendsfdf2) (void); -void EXPORT_FUNC (__fixunsdfsi) (void); -void EXPORT_FUNC (__floatsidf) (void); -void EXPORT_FUNC (__floatsisf) (void); -void EXPORT_FUNC (__lshrdi3) (void); -void EXPORT_FUNC (__make_dp) (void); -void EXPORT_FUNC (__make_fp) (void); -void EXPORT_FUNC (__muldf3) (void); -void EXPORT_FUNC (__mulsf3) (void); -void EXPORT_FUNC (__pack_d) (void); -void EXPORT_FUNC (__pack_f) (void); -void EXPORT_FUNC (__subdf3) (void); -void EXPORT_FUNC (__subsf3) (void); -void EXPORT_FUNC (__thenan_df) (void); -void EXPORT_FUNC (__thenan_sf) (void); -void EXPORT_FUNC (__trampoline_setup) (void); -void EXPORT_FUNC (__truncdfsf2) (void); -void EXPORT_FUNC (__unpack_d) (void); -void EXPORT_FUNC (__unpack_f) (void); diff -rupN powerpc/types.h sparc64/types.h --- powerpc/types.h 2004-12-27 14:46:20.000000000 +0100 +++ sparc64/types.h 2005-07-12 19:14:58.000000000 +0200 @@ -21,12 +21,12 @@ #define GRUB_TYPES_CPU_HEADER 1 /* The size of void *. */ -#define GRUB_HOST_SIZEOF_VOID_P 4 +#define GRUB_HOST_SIZEOF_VOID_P 8 /* The size of long. */ -#define GRUB_HOST_SIZEOF_LONG 4 +#define GRUB_HOST_SIZEOF_LONG 8 -/* powerpc is big-endian. */ +/* sparc64 is big-endian. */ #define GRUB_HOST_WORDS_BIGENDIAN 1 --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_kern.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_kern.f.diff" diff -rupN powerpc/cache.c sparc64/cache.c --- powerpc/cache.c 1970-01-01 01:00:00.000000000 +0100 +++ sparc64/cache.c 2005-07-12 19:14:58.000000000 +0200 @@ -0,0 +1,9 @@ +#include + +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; +} diff -rupN powerpc/cache.S sparc64/cache.S --- powerpc/cache.S 2004-12-27 14:46:20.000000000 +0100 +++ sparc64/cache.S 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ -/* cache.S - Flush the processor cache for a specific region. */ -/* - * 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. - */ - -#define CACHE_LINE_BYTES 32 - - .text - - .align 2 - .globl grub_arch_sync_caches -grub_arch_sync_caches: - /* Force the dcache lines to memory. */ - li 5, 0 -1: dcbst 5, 3 - addi 5, 5, CACHE_LINE_BYTES - cmpw 5, 4 - blt 1b - sync /* Force all dcbsts to complete. */ - - /* Invalidate the icache lines. */ - li 5, 0 -1: icbi 5, 3 - addi 5, 5, CACHE_LINE_BYTES - cmpw 5, 4 - blt 1b - sync /* Force all icbis to complete. */ - isync /* Discard partially executed instructions that were - loaded from the invalid icache. */ - blr diff -rupN powerpc/dl.c sparc64/dl.c --- powerpc/dl.c 2005-02-14 19:41:33.000000000 +0100 +++ sparc64/dl.c 2005-07-12 19:14:58.000000000 +0200 @@ -27,7 +27,7 @@ grub_err_t grub_arch_dl_check_header (void *ehdr) { - Elf32_Ehdr *e = ehdr; + Elf64_Ehdr *e = ehdr; /* Check the magic numbers. */ if (e->e_ident[EI_CLASS] != ELFCLASS32 @@ -43,28 +43,28 @@ grub_arch_dl_check_header (void *ehdr) grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) { - Elf32_Ehdr *e = ehdr; - Elf32_Shdr *s; - Elf32_Sym *symtab; - Elf32_Word entsize; + Elf64_Ehdr *e = ehdr; + Elf64_Shdr *s; + Elf64_Sym *symtab; + Elf64_Word entsize; unsigned i; /* Find a symbol table. */ - for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff); + for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff); i < e->e_shnum; - i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize)) + i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize)) if (s->sh_type == SHT_SYMTAB) break; if (i == e->e_shnum) return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found"); - symtab = (Elf32_Sym *) ((char *) e + s->sh_offset); + symtab = (Elf64_Sym *) ((char *) e + s->sh_offset); entsize = s->sh_entsize; - for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff); + for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff); i < e->e_shnum; - i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize)) + i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize)) if (s->sh_type == SHT_RELA) { grub_dl_segment_t seg; @@ -76,23 +76,23 @@ grub_arch_dl_relocate_symbols (grub_dl_t if (seg) { - Elf32_Rela *rel, *max; + Elf64_Rela *rel, *max; - for (rel = (Elf32_Rela *) ((char *) e + s->sh_offset), + for (rel = (Elf64_Rela *) ((char *) e + s->sh_offset), max = rel + s->sh_size / s->sh_entsize; rel < max; rel++) { - Elf32_Word *addr; - Elf32_Sym *sym; - grub_uint32_t value; + Elf64_Xword *addr; + Elf64_Sym *sym; + grub_intn_t value; if (seg->size < rel->r_offset) return grub_error (GRUB_ERR_BAD_MODULE, "reloc offset is out of the segment"); - addr = (Elf32_Word *) ((char *) seg->addr + rel->r_offset); - sym = (Elf32_Sym *) ((char *) symtab + addr = (Elf64_Xword *) ((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 @@ -101,12 +101,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t switch (ELF32_R_TYPE (rel->r_info)) { case R_PPC_ADDR16_LO: - *(Elf32_Half *) addr = value; + *(Elf64_Half *) addr = value; break; case R_PPC_REL24: { - Elf32_Sword delta = value - (Elf32_Word) addr; + Elf64_Sxword delta = value - (Elf64_Xword) addr; if (delta << 6 >> 6 != delta) return grub_error (GRUB_ERR_BAD_MODULE, "Relocation overflow"); @@ -115,7 +115,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t } case R_PPC_ADDR16_HA: - *(Elf32_Half *) addr = (value + 0x8000) >> 16; + *(Elf64_Half *) addr = (value + 0x8000) >> 16; break; case R_PPC_ADDR32: @@ -123,7 +123,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t break; case R_PPC_REL32: - *addr = value - (Elf32_Word) addr; + *addr = value - (Elf64_Xword) addr; break; default: diff -rupN powerpc/ieee1275/init.c sparc64/ieee1275/init.c --- powerpc/ieee1275/init.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/init.c 2005-07-12 20:27:15.000000000 +0200 @@ -35,16 +35,14 @@ #include /* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers. */ -static const grub_addr_t grub_heap_start = 0x4000; +static const grub_addr_t grub_heap_start = 0x40000; static grub_addr_t grub_heap_len; void abort (void) { /* Trap to Open Firmware. */ - asm ("trap"); - - for (;;); + grub_ieee1275_enter (); } /* Translate an OF filesystem path (separated by backslashes), into a GRUB @@ -69,7 +67,7 @@ grub_set_prefix (void) char *filename; char *prefix; - if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath, + if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, sizeof (bootpath), 0)) { /* Should never happen. */ @@ -111,9 +109,8 @@ grub_set_prefix (void) void grub_machine_init (void) { - char args[256]; - grub_ieee1275_phandle_t chosen; - int actual; + char *args; + grub_ssize_t length; extern char _start; grub_console_init (); @@ -123,11 +120,8 @@ grub_machine_init (void) grub_heap_len = (grub_addr_t) &_start - 0x1000 - grub_heap_start; if (grub_ieee1275_claim (grub_heap_start, grub_heap_len, 0, 0)) - { - grub_printf ("Failed to claim heap at 0x%x, len 0x%x\n", grub_heap_start, + grub_fatal ("Failed to claim heap at %p, len 0x%x\n", grub_heap_start, grub_heap_len); - abort (); - } grub_mm_init_region ((void *) grub_heap_start, grub_heap_len); grub_set_prefix (); @@ -135,14 +129,17 @@ grub_machine_init (void) grub_ofdisk_init (); /* Process commandline. */ - grub_ieee1275_finddevice ("/chosen", &chosen); - if (grub_ieee1275_get_property (chosen, "bootargs", &args, - sizeof args, &actual) == 0 - && actual > 1) + if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootargs", + &length) == 0 && + length > 0) { - int i = 0; + grub_ssize_t i = 0; - while (i < actual) + args = grub_malloc (length); + grub_ieee1275_get_property (grub_ieee1275_chosen, "bootargs", args, + length, 0); + + while (i < length) { char *command = &args[i]; char *end; @@ -150,7 +147,7 @@ grub_machine_init (void) end = grub_strchr (command, ';'); if (end == 0) - i = actual; /* No more commands after this one. */ + i = length; /* No more commands after this one. */ else { *end = '\0'; @@ -168,6 +165,7 @@ grub_machine_init (void) } } } + } void @@ -180,13 +178,13 @@ grub_machine_fini (void) void grub_stop (void) { - for (;;); + grub_ieee1275_exit (); } -grub_uint32_t +grub_uintn_t grub_get_rtc (void) { - grub_uint32_t msecs; + grub_intn_t msecs; if (grub_ieee1275_milliseconds (&msecs)) return 0; diff -rupN powerpc/ieee1275/openfw.c sparc64/ieee1275/openfw.c --- powerpc/ieee1275/openfw.c 2005-06-21 04:33:51.000000000 +0200 +++ sparc64/ieee1275/openfw.c 2005-07-12 20:40:04.000000000 +0200 @@ -53,9 +53,9 @@ grub_children_iterate (char *devpath, char childname[64]; char fullname[64]; struct grub_ieee1275_devalias alias; - int actual; + grub_ssize_t actual; - grub_ieee1275_get_property (child, "device_type", &childtype, + grub_ieee1275_get_property (child, "device_type", childtype, sizeof childtype, &actual); if (actual == -1) continue; @@ -65,7 +65,7 @@ grub_children_iterate (char *devpath, if (actual == -1) continue; - grub_ieee1275_get_property (child, "name", &childname, + grub_ieee1275_get_property (child, "name", childname, sizeof childname, &actual); if (actual == -1) continue; @@ -89,31 +89,29 @@ grub_devalias_iterate (int (*hook) (stru { grub_ieee1275_phandle_t devalias; char aliasname[32]; - int actual; + grub_ssize_t actual; + grub_intn_t flag; struct grub_ieee1275_devalias alias; if (grub_ieee1275_finddevice ("/aliases", &devalias)) return -1; - /* XXX: Is this the right way to find the first property? */ aliasname[0] = '\0'; - /* XXX: Are the while conditions correct? */ - while (grub_ieee1275_next_property (devalias, aliasname, aliasname, &actual) - || actual) + while (grub_ieee1275_next_property (devalias, aliasname, aliasname, &flag) != -1 + && flag != -1 ) { grub_ieee1275_phandle_t dev; - grub_size_t pathlen; - char *devpath; - /* XXX: This should be large enough for any possible case. */ - char devtype[64]; - - grub_ieee1275_get_property_length (devalias, aliasname, &pathlen); + grub_ssize_t pathlen, typelen; + char *devpath, *devtype; + grub_dprintf ("devalias", "devalias name = %s\n", aliasname); + /* The property `name' is a special case we should skip. */ if (!grub_strcmp (aliasname, "name")) continue; + grub_ieee1275_get_property_length (devalias, aliasname, &pathlen); devpath = grub_malloc (pathlen); if (! devpath) return grub_errno; @@ -121,19 +119,29 @@ grub_devalias_iterate (int (*hook) (stru if (grub_ieee1275_get_property (devalias, aliasname, devpath, pathlen, &actual)) { + grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname); grub_free (devpath); continue; } if (grub_ieee1275_finddevice (devpath, &dev) || dev == -1) { + grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath); grub_free (devpath); continue; } - if (grub_ieee1275_get_property (dev, "device_type", devtype, sizeof devtype, - &actual)) + grub_ieee1275_get_property_length (dev, "device_type", &typelen); + devtype = grub_malloc (typelen); + if (! devtype) + { + grub_free (devpath); + return grub_errno; + } + if (grub_ieee1275_get_property (dev, "device_type", devtype, typelen, &actual)) { + grub_dprintf ("devalias", "get device type failed\n"); + grub_free (devtype); grub_free (devpath); continue; } @@ -141,14 +149,21 @@ grub_devalias_iterate (int (*hook) (stru alias.name = aliasname; alias.path= devpath; alias.type = devtype; - hook (&alias); - + if((*hook) (&alias)) + { + grub_free (devtype); + grub_free (devpath); + break; + } + + grub_free (devtype); grub_free (devpath); } return 0; } +#if 0 /* Call the "map" method of /chosen/mmu. */ static int grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size, @@ -165,7 +180,7 @@ grub_map (grub_addr_t phys, grub_addr_t int catch_result; } args; grub_ieee1275_ihandle_t mmu; - int len; + grub_ssize_t len; grub_ieee1275_get_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu, &len); @@ -185,21 +200,13 @@ grub_map (grub_addr_t phys, grub_addr_t return args.catch_result; } +#endif int grub_claimmap (grub_addr_t addr, grub_size_t size) { if (grub_ieee1275_claim (addr, size, 0, 0)) return -1; - - if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE) - && grub_map (addr, addr, size, 0x00)) - { - grub_printf ("map failed: address 0x%x, size 0x%x\n", addr, size); - grub_ieee1275_release (addr, size); - return -1; - } - return 0; } @@ -268,7 +275,7 @@ grub_ieee1275_parse_args (const char *pa grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Device %s not found\n", device); goto fail; } - if (grub_ieee1275_get_property (dev, "device_type", &type, sizeof type, 0)) + if (grub_ieee1275_get_property (dev, "device_type", type, sizeof type, 0)) { grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Device %s lacks a device_type property\n", device); @@ -336,10 +343,6 @@ grub_ieee1275_encode_devname (const char { unsigned int partno = grub_strtoul (partition, 0, 0); - /* GRUB partition numbering is 0-based. */ - if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS)) - partno--; - /* Assume partno will require less than five bytes to encode. */ encoding = grub_malloc (grub_strlen (device) + 3 + 5); grub_sprintf (encoding, "(%s,%d)", device, partno); @@ -365,5 +368,5 @@ grub_reboot (void) void grub_halt (void) { - grub_ieee1275_interpret ("shut-down", 0); + grub_ieee1275_interpret ("power-off", 0); } --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_normal.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_normal.f.diff" diff -rupN powerpc/setjmp.c sparc64/setjmp.c --- powerpc/setjmp.c 1970-01-01 01:00:00.000000000 +0100 +++ sparc64/setjmp.c 2005-07-12 19:14:58.000000000 +0200 @@ -0,0 +1,35 @@ +/* + * 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. + */ + +/* + * int grub_setjmp (grub_jmp_buf env) + */ +int grub_setjmp (grub_jmp_buf env) +{ + return 0; +} + +/* + * int grub_longjmp (grub_jmp_buf env, int val) + */ +int grub_longjmp (grub_jmp_buf env, int val) +{ + return 0; +} + diff -rupN powerpc/setjmp.S sparc64/setjmp.S --- powerpc/setjmp.S 2004-11-17 00:34:45.000000000 +0100 +++ sparc64/setjmp.S 1970-01-01 01:00:00.000000000 +0100 @@ -1,85 +0,0 @@ -/* - * 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. - */ - -#include - - .file "setjmp.S" - - .text - -/* - * int grub_setjmp (grub_jmp_buf env) - */ -FUNCTION(grub_setjmp) - stw 1, 0(3) - stw 14, 4(3) - stw 15, 8(3) - stw 16, 12(3) - stw 17, 16(3) - stw 18, 20(3) - stw 19, 24(3) - stw 20, 28(3) - stw 21, 32(3) - stw 22, 36(3) - stw 23, 40(3) - stw 24, 44(3) - stw 25, 48(3) - stw 26, 52(3) - stw 27, 56(3) - stw 28, 60(3) - stw 29, 64(3) - stw 30, 68(3) - mflr 4 - stw 4, 72(3) - mfcr 4 - stw 4, 76(3) - li 3, 0 - blr - -/* - * int grub_longjmp (grub_jmp_buf env, int val) - */ -FUNCTION(grub_longjmp) - lwz 1, 0(3) - lwz 14, 4(3) - lwz 15, 8(3) - lwz 16, 12(3) - lwz 17, 16(3) - lwz 18, 20(3) - lwz 19, 24(3) - lwz 20, 28(3) - lwz 21, 32(3) - lwz 22, 36(3) - lwz 23, 40(3) - lwz 24, 44(3) - lwz 25, 48(3) - lwz 26, 52(3) - lwz 27, 56(3) - lwz 28, 60(3) - lwz 29, 64(3) - lwz 30, 68(3) - lwz 5, 72(3) - mtlr 5 - lwz 5, 76(3) - mtcr 5 - mr. 3, 4 - bne 1f - li 3, 1 -1: blr - --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_term.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_term.f.diff" diff -rupN powerpc/ieee1275/ofconsole.c sparc64/ieee1275/ofconsole.c --- powerpc/ieee1275/ofconsole.c 2005-06-21 04:33:52.000000000 +0200 +++ sparc64/ieee1275/ofconsole.c 2005-07-12 19:14:58.000000000 +0200 @@ -120,7 +120,7 @@ static int grub_ofconsole_readkey (int *key) { char c; - int actual = 0; + grub_ssize_t actual = 0; grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); @@ -222,6 +222,8 @@ static void grub_ofconsole_cls (void) { /* Clear the screen. */ + if (grub_env_get ("nocls")) + return; grub_ofconsole_writeesc ("\e[2J"); grub_gotoxy (0, 0); } @@ -241,8 +243,8 @@ grub_ofconsole_refresh (void) static grub_err_t grub_ofconsole_init (void) { - char data[4]; - grub_size_t actual; + unsigned char data[4]; + grub_ssize_t actual; int col; if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data, --------------020901090700060205070403 Content-Type: text/plain; name="ppc_usp_util.f.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ppc_usp_util.f.diff" diff -rupN powerpc/ieee1275/grub-mkimage.c sparc64/ieee1275/grub-mkimage.c --- powerpc/ieee1275/grub-mkimage.c 2005-07-03 11:34:45.000000000 +0200 +++ sparc64/ieee1275/grub-mkimage.c 2005-07-12 19:14:58.000000000 +0200 @@ -34,7 +34,7 @@ static char *kernel_path = "grubof"; -#define GRUB_IEEE1275_NOTE_NAME "PowerPC" +#define GRUB_IEEE1275_NOTE_NAME "Sparc64" #define GRUB_IEEE1275_NOTE_TYPE 0x1275 /* These structures are defined according to the CHRP binding to IEEE1275, @@ -42,20 +42,20 @@ static char *kernel_path = "grubof"; struct grub_ieee1275_note_hdr { - grub_uint32_t namesz; - grub_uint32_t descsz; - grub_uint32_t type; + grub_uint64_t namesz; + grub_uint64_t descsz; + grub_uint64_t type; char name[sizeof (GRUB_IEEE1275_NOTE_NAME)]; }; struct grub_ieee1275_note_desc { - grub_uint32_t real_mode; - grub_uint32_t real_base; - grub_uint32_t real_size; - grub_uint32_t virt_base; - grub_uint32_t virt_size; - grub_uint32_t load_base; + grub_uint64_t real_mode; + grub_uint64_t real_base; + grub_uint64_t real_size; + grub_uint64_t virt_base; + grub_uint64_t virt_size; + grub_uint64_t load_base; }; struct grub_ieee1275_note @@ -65,40 +65,40 @@ struct grub_ieee1275_note }; void -load_note (Elf32_Phdr *phdr, FILE *out) +load_note (Elf64_Phdr *phdr, FILE *out) { struct grub_ieee1275_note note; int note_size = sizeof (struct grub_ieee1275_note); grub_util_info ("adding CHRP NOTE segment"); - note.header.namesz = grub_cpu_to_be32 (sizeof (GRUB_IEEE1275_NOTE_NAME)); - note.header.descsz = grub_cpu_to_be32 (note_size); - note.header.type = grub_cpu_to_be32 (GRUB_IEEE1275_NOTE_TYPE); + note.header.namesz = grub_cpu_to_be64 (sizeof (GRUB_IEEE1275_NOTE_NAME)); + note.header.descsz = grub_cpu_to_be64 (note_size); + note.header.type = grub_cpu_to_be64 (GRUB_IEEE1275_NOTE_TYPE); strcpy (note.header.name, GRUB_IEEE1275_NOTE_NAME); - note.descriptor.real_mode = grub_cpu_to_be32 (0xffffffff); - note.descriptor.real_base = grub_cpu_to_be32 (0x00c00000); - note.descriptor.real_size = grub_cpu_to_be32 (0xffffffff); - note.descriptor.virt_base = grub_cpu_to_be32 (0xffffffff); - note.descriptor.virt_size = grub_cpu_to_be32 (0xffffffff); - note.descriptor.load_base = grub_cpu_to_be32 (0x00004000); + note.descriptor.real_mode = grub_cpu_to_be64 (0xffffffff); + note.descriptor.real_base = grub_cpu_to_be64 (0x00c00000); + note.descriptor.real_size = grub_cpu_to_be64 (0xffffffff); + note.descriptor.virt_base = grub_cpu_to_be64 (0xffffffff); + note.descriptor.virt_size = grub_cpu_to_be64 (0xffffffff); + note.descriptor.load_base = grub_cpu_to_be64 (0x00004000); /* Write the note data to the new segment. */ grub_util_write_image_at (¬e, note_size, - grub_be_to_cpu32 (phdr->p_offset), out); + grub_be_to_cpu64 (phdr->p_offset), out); /* Fill in the rest of the segment header. */ - phdr->p_type = grub_cpu_to_be32 (PT_NOTE); - phdr->p_flags = grub_cpu_to_be32 (PF_R); - phdr->p_align = grub_cpu_to_be32 (sizeof (long)); + phdr->p_type = grub_cpu_to_be64 (PT_NOTE); + phdr->p_flags = grub_cpu_to_be64 (PF_R); + phdr->p_align = grub_cpu_to_be64 (sizeof (long)); phdr->p_vaddr = 0; phdr->p_paddr = 0; - phdr->p_filesz = grub_cpu_to_be32 (note_size); + phdr->p_filesz = grub_cpu_to_be64 (note_size); phdr->p_memsz = 0; } void -load_modules (Elf32_Phdr *phdr, const char *dir, char *mods[], FILE *out) +load_modules (Elf64_Phdr *phdr, const char *dir, char *mods[], FILE *out) { char *module_img; struct grub_util_path_list *path_list; @@ -121,9 +121,9 @@ load_modules (Elf32_Phdr *phdr, const ch module_img = xmalloc (total_module_size); modinfo = (struct grub_module_info *) module_img; - modinfo->magic = grub_cpu_to_be32 (GRUB_MODULE_MAGIC); - modinfo->offset = grub_cpu_to_be32 (sizeof (struct grub_module_info)); - modinfo->size = grub_cpu_to_be32 (total_module_size); + modinfo->magic = grub_cpu_to_be64 (GRUB_MODULE_MAGIC); + modinfo->offset = grub_cpu_to_be64 (sizeof (struct grub_module_info)); + modinfo->size = grub_cpu_to_be64 (total_module_size); /* Load all the modules, with headers, into module_img. */ for (p = path_list; p; p = p->next) @@ -136,8 +136,8 @@ load_modules (Elf32_Phdr *phdr, const ch mod_size = grub_util_get_image_size (p->name); header = (struct grub_module_header *) (module_img + offset); - header->offset = grub_cpu_to_be32 (sizeof (*header)); - header->size = grub_cpu_to_be32 (mod_size + sizeof (*header)); + header->offset = grub_cpu_to_be64 (sizeof (*header)); + header->size = grub_cpu_to_be64 (mod_size + sizeof (*header)); grub_util_load_image (p->name, module_img + offset + sizeof (*header)); @@ -146,24 +146,24 @@ load_modules (Elf32_Phdr *phdr, const ch /* Write the module data to the new segment. */ grub_util_write_image_at (module_img, total_module_size, - grub_cpu_to_be32 (phdr->p_offset), out); + grub_cpu_to_be64 (phdr->p_offset), out); /* Fill in the rest of the segment header. */ - phdr->p_type = grub_cpu_to_be32 (PT_LOAD); - phdr->p_flags = grub_cpu_to_be32 (PF_R | PF_W | PF_X); - phdr->p_align = grub_cpu_to_be32 (sizeof (long)); - phdr->p_vaddr = grub_cpu_to_be32 (GRUB_IEEE1275_MODULE_BASE); - phdr->p_paddr = grub_cpu_to_be32 (GRUB_IEEE1275_MODULE_BASE); - phdr->p_filesz = grub_cpu_to_be32 (total_module_size); - phdr->p_memsz = grub_cpu_to_be32 (total_module_size); + phdr->p_type = grub_cpu_to_be64 (PT_LOAD); + phdr->p_flags = grub_cpu_to_be64 (PF_R | PF_W | PF_X); + phdr->p_align = grub_cpu_to_be64 (sizeof (long)); + phdr->p_vaddr = grub_cpu_to_be64 (GRUB_IEEE1275_MODULE_BASE); + phdr->p_paddr = grub_cpu_to_be64 (GRUB_IEEE1275_MODULE_BASE); + phdr->p_filesz = grub_cpu_to_be64 (total_module_size); + phdr->p_memsz = grub_cpu_to_be64 (total_module_size); } void add_segments (char *dir, FILE *out, int chrp, char *mods[]) { - Elf32_Ehdr ehdr; - Elf32_Phdr *phdrs = NULL; - Elf32_Phdr *phdr; + Elf64_Ehdr ehdr; + Elf64_Phdr *phdrs = NULL; + Elf64_Phdr *phdr; FILE *in; off_t phdroff; int i; @@ -185,20 +185,20 @@ add_segments (char *dir, FILE *out, int phdr = phdrs + i; /* Read segment header. */ - grub_util_read_at (phdr, sizeof (Elf32_Phdr), - (grub_be_to_cpu32 (ehdr.e_phoff) + grub_util_read_at (phdr, sizeof (Elf64_Phdr), + (grub_be_to_cpu64 (ehdr.e_phoff) + (i * grub_be_to_cpu16 (ehdr.e_phentsize))), in); grub_util_info ("copying segment %d, type %d", i, - grub_be_to_cpu32 (phdr->p_type)); + grub_be_to_cpu64 (phdr->p_type)); /* Read segment data and write it to new file. */ - segment_img = xmalloc (grub_be_to_cpu32 (phdr->p_filesz)); + segment_img = xmalloc (grub_be_to_cpu64 (phdr->p_filesz)); - grub_util_read_at (segment_img, grub_be_to_cpu32 (phdr->p_filesz), - grub_be_to_cpu32 (phdr->p_offset), in); - grub_util_write_image_at (segment_img, grub_be_to_cpu32 (phdr->p_filesz), - grub_be_to_cpu32 (phdr->p_offset), out); + grub_util_read_at (segment_img, grub_be_to_cpu64 (phdr->p_filesz), + grub_be_to_cpu64 (phdr->p_offset), in); + grub_util_write_image_at (segment_img, grub_be_to_cpu64 (phdr->p_filesz), + grub_be_to_cpu64 (phdr->p_offset), out); free (segment_img); } @@ -210,7 +210,7 @@ add_segments (char *dir, FILE *out, int ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1); /* Fill in p_offset so the callees know where to write. */ - phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out), + phdr->p_offset = grub_cpu_to_be64 (ALIGN_UP (grub_util_get_fp_size (out), sizeof (long))); load_modules (phdr, dir, mods, out); @@ -223,7 +223,7 @@ add_segments (char *dir, FILE *out, int ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1); /* Fill in p_offset so the callees know where to write. */ - phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out), + phdr->p_offset = grub_cpu_to_be64 (ALIGN_UP (grub_util_get_fp_size (out), sizeof (long))); load_note (phdr, out); @@ -241,7 +241,7 @@ add_segments (char *dir, FILE *out, int out); /* Write ELF header. */ - ehdr.e_phoff = grub_cpu_to_be32 (phdroff); + ehdr.e_phoff = grub_cpu_to_be64 (phdroff); grub_util_write_image_at (&ehdr, sizeof (ehdr), 0, out); free (phdrs); --------------020901090700060205070403-- ___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com