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; }