/* init.c -- Initialize GRUB on the newworld mac (PPC). */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB 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, see <http://www.gnu.org/licenses/>.
*/
#include <grub/partition.h>
#ifdef __sparc__
#endif
/* The minimal heap size we can live with. */
/* The maximum heap size we're going to claim */
/* If possible, we will avoid claiming heap above this address, because it
seems to cause relocation problems with OSes that link at 4 MiB */
extern char _start[];
extern char _end[];
#ifdef __sparc__
#endif
void
grub_exit (void)
{
}
/* Translate an OF filesystem path (separated by backslashes), into a GRUB
path (separated by forward slashes). */
static void
{
char *backslash;
while (backslash != 0)
{
*backslash = '/';
}
}
char **device,
char **path);
void
{
char *filename;
char *type;
sizeof (bootpath), 0))
{
/* Should never happen. */
grub_printf ("/chosen/bootpath property missing!\n");
return;
}
/* Transform an OF device path to a GRUB path. */
{
char *ptr;
ptr--;
ptr++;
*ptr = 0;
}
else
if (filename)
{
/* Truncate at last directory. */
if (lastslash)
{
*lastslash = '\0';
}
}
}
/* Claim some available memory in the first /memory node. */
#ifdef __sparc__
static void
grub_claim_heap (void)
{
grub_mm_init_region ((void *) (grub_modules_get_end ()
+ GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000);
}
#else
static void
grub_claim_heap (void)
{
unsigned long total = 0;
{
if (type != 1)
return 0;
{
return 0;
if (addr < 0x180000)
{
addr = 0x180000;
}
}
/* Never exceed HEAP_MAX_SIZE */
/* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */
/* In theory, firmware should already prevent this from happening by not
as a safeguard in case that doesn't happen. However, it doesn't protect
us from corrupting our module area, which extends up to a
yet-undetermined region above _end. */
{
grub_printf ("Warning: attempt to claim over our own code!\n");
len = 0;
}
if (len)
{
/* Claim and use it. */
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"failed to claim heap at 0x%llx, len 0x%llx",
}
if (total >= HEAP_MAX_SIZE)
return 1;
return 0;
}
else
}
#endif
static void
grub_parse_cmdline (void)
{
&& actual > 1)
{
int i = 0;
while (i < actual)
{
char *end;
char *val;
if (end == 0)
i = actual; /* No more commands after this one. */
else
{
*end = '\0';
while (grub_isspace(args[i]))
i++;
}
/* Process command. */
if (val)
{
*val = '\0';
}
}
}
}
static grub_uint64_t ieee1275_get_time_ms (void);
void
grub_machine_init (void)
{
grub_claim_heap ();
grub_ofdisk_init ();
}
void
grub_machine_fini (void)
{
grub_ofdisk_fini ();
}
static grub_uint64_t
ieee1275_get_time_ms (void)
{
return msecs;
}
grub_get_rtc (void)
{
return ieee1275_get_time_ms ();
}