1
/* cmain.c - Startup code for the PowerPC. */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
#include <grub/kernel.h>
24
#include <grub/machine/kernel.h>
25
#include <grub/ieee1275/ieee1275.h>
27
/* OpenFirmware entry point passed to us from the real bootloader. */
28
int (*grub_ieee1275_entry_fn) (void *);
30
grub_ieee1275_phandle_t grub_ieee1275_chosen;
32
static grub_uint32_t grub_ieee1275_flags;
37
grub_ieee1275_test_flag (enum grub_ieee1275_flag flag)
39
return (grub_ieee1275_flags & (1 << flag));
43
grub_ieee1275_set_flag (enum grub_ieee1275_flag flag)
45
grub_ieee1275_flags |= (1 << flag);
49
grub_ieee1275_find_options (void)
51
grub_ieee1275_phandle_t options;
52
grub_ieee1275_phandle_t openprom;
56
grub_ieee1275_finddevice ("/options", &options);
57
grub_ieee1275_get_property (options, "real-mode?", &realmode,
58
sizeof (realmode), 0);
60
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
62
grub_ieee1275_finddevice ("/openprom", &openprom);
63
smartfw = grub_ieee1275_get_property (openprom, "SmartFirmware-version",
66
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
69
void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
71
cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
75
/* Entered from Old World stage1. */
79
grub_ieee1275_entry_fn = (int (*)(void *)) r3;
81
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
83
/* Old World Open Firmware may use 4M-5M without claiming it. */
84
grub_ieee1275_claim (0x00400000, 0x00100000, 0, 0);
86
/* Need to claim ourselves so we don't cannibalize our memory later. */
87
if (grub_ieee1275_claim ((grub_addr_t) &_start, (grub_addr_t) &_end
88
- (grub_addr_t) &_start, 0, 0))
93
/* Assume we were entered from Open Firmware. */
94
grub_ieee1275_entry_fn = (int (*)(void *)) r5;
97
grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
99
grub_ieee1275_find_options ();
101
/* Now invoke the main function. */