2005-04-30 Hollis Blanchard <hollis@penguinppc.org>
* boot/powerpc/ieee1275/cmain.c: Don't include grub/machine/init.h. (roundup): Remove macro. (grub_ieee1275_flags): Make static. (grub_ieee1275_realmode): Remove. (grub_ieee1275_test_flag): New function. (grub_ieee1275_set_flag): Likewise. (find_options): Rename to `grub_ieee1275_find_options'; update callers. Set GRUB_IEEE1275_FLAG_REAL_MODE and GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS. (cmain): New prototype. (cmain): Use `grub_ieee1275_set_flag' instead of accessing `grub_ieee1275_flags' directly. * conf/powerpc-ieee1275.rmk (grubof_HEADERS): Remove machine/biosdisk.h. * disk/powerpc/ieee1275/ofdisk.c: Include grub/machine/ofdisk.h. Don't include grub/machine/init.h. (grub_ofdisk_open): Call `grub_ieee1275_test_flag'. * include/grub/powerpc/ieee1275/ieee1275.h (grub_ieee1275_flags): Remove prototype. (grub_ieee1275_realmode): Likewise. (grub_ieee1275_flag): New enum. (grub_ieee1275_test_flag): New prototype. (grub_ieee1275_set_flag): New prototype. * include/grub/powerpc/ieee1275/init.h: Remove file. * include/grub/powerpc/ieee1275/ofdisk.h: New file. * kern/powerpc/ieee1275/init.c: Don't include grub/machine/init.h. Include grub/machine/console.h. Include grub/machine/ofdisk.h. (grub_machine_fini): Don't call `grub_ieee1275_release'. Remove comment. * kern/powerpc/ieee1275/openfw.c (grub_claimmap): Call `grub_ieee1275_test_flag'. (grub_ieee1275_encode_devname): Likewise.
This commit is contained in:
parent
ed16607e13
commit
f4c5e67ca4
9 changed files with 105 additions and 36 deletions
35
ChangeLog
35
ChangeLog
|
@ -1,3 +1,38 @@
|
|||
2005-04-30 Hollis Blanchard <hollis@penguinppc.org>
|
||||
|
||||
* boot/powerpc/ieee1275/cmain.c: Don't include grub/machine/init.h.
|
||||
(roundup): Remove macro.
|
||||
(grub_ieee1275_flags): Make static.
|
||||
(grub_ieee1275_realmode): Remove.
|
||||
(grub_ieee1275_test_flag): New function.
|
||||
(grub_ieee1275_set_flag): Likewise.
|
||||
(find_options): Rename to `grub_ieee1275_find_options'; update
|
||||
callers. Set GRUB_IEEE1275_FLAG_REAL_MODE and
|
||||
GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS.
|
||||
(cmain): New prototype.
|
||||
(cmain): Use `grub_ieee1275_set_flag' instead of accessing
|
||||
`grub_ieee1275_flags' directly.
|
||||
* conf/powerpc-ieee1275.rmk (grubof_HEADERS): Remove
|
||||
machine/biosdisk.h.
|
||||
* disk/powerpc/ieee1275/ofdisk.c: Include grub/machine/ofdisk.h.
|
||||
Don't include grub/machine/init.h.
|
||||
(grub_ofdisk_open): Call `grub_ieee1275_test_flag'.
|
||||
* include/grub/powerpc/ieee1275/ieee1275.h (grub_ieee1275_flags):
|
||||
Remove prototype.
|
||||
(grub_ieee1275_realmode): Likewise.
|
||||
(grub_ieee1275_flag): New enum.
|
||||
(grub_ieee1275_test_flag): New prototype.
|
||||
(grub_ieee1275_set_flag): New prototype.
|
||||
* include/grub/powerpc/ieee1275/init.h: Remove file.
|
||||
* include/grub/powerpc/ieee1275/ofdisk.h: New file.
|
||||
* kern/powerpc/ieee1275/init.c: Don't include grub/machine/init.h.
|
||||
Include grub/machine/console.h. Include grub/machine/ofdisk.h.
|
||||
(grub_machine_fini): Don't call `grub_ieee1275_release'. Remove
|
||||
comment.
|
||||
* kern/powerpc/ieee1275/openfw.c (grub_claimmap): Call
|
||||
`grub_ieee1275_test_flag'.
|
||||
(grub_ieee1275_encode_devname): Likewise.
|
||||
|
||||
2005-04-21 Hollis Blanchard <hollis@penguinppc.org>
|
||||
|
||||
* include/grub/powerpc/ieee1275/ieee1275.h
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <grub/machine/ieee1275.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/machine/init.h>
|
||||
|
||||
struct module_info
|
||||
{
|
||||
|
@ -31,26 +30,47 @@ struct module_info
|
|||
uint32_t end;
|
||||
};
|
||||
|
||||
#define roundup(a, s) (((a) + ((s) - 1)) & ~((s) - 1))
|
||||
|
||||
/* OpenFirmware entry point passed to us from the real bootloader. */
|
||||
intptr_t (*grub_ieee1275_entry_fn) (void *);
|
||||
|
||||
grub_uint32_t grub_ieee1275_flags;
|
||||
int grub_ieee1275_realmode;
|
||||
static grub_uint32_t grub_ieee1275_flags;
|
||||
|
||||
|
||||
|
||||
static void
|
||||
find_options (void)
|
||||
int
|
||||
grub_ieee1275_test_flag (enum grub_ieee1275_flag flag)
|
||||
{
|
||||
grub_ieee1275_phandle_t options;
|
||||
|
||||
grub_ieee1275_finddevice ("/options", &options);
|
||||
grub_ieee1275_get_property (options, "real-mode?", &grub_ieee1275_realmode,
|
||||
sizeof (grub_ieee1275_realmode), 0);
|
||||
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);
|
||||
/* Setup the argument vector and pass control over to the main
|
||||
function. */
|
||||
void
|
||||
|
@ -68,7 +88,7 @@ cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
|
|||
|
||||
grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
|
||||
|
||||
grub_ieee1275_flags = GRUB_IEEE1275_NO_PARTITION_0;
|
||||
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);
|
||||
|
@ -84,7 +104,7 @@ cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
|
|||
grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5;
|
||||
}
|
||||
|
||||
find_options ();
|
||||
grub_ieee1275_find_options ();
|
||||
|
||||
/* If any argument was passed to the kernel (us), they are
|
||||
put in the bootargs property of /chosen. The string can
|
||||
|
|
|
@ -11,7 +11,7 @@ DEFSYMFILES += kernel_syms.lst
|
|||
|
||||
grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
|
||||
file.h fs.h kernel.h misc.h mm.h net.h rescue.h symbol.h \
|
||||
term.h types.h machine/biosdisk.h powerpc/libgcc.h loader.h \
|
||||
term.h types.h powerpc/libgcc.h loader.h \
|
||||
partition.h pc_partition.h machine/time.h machine/ieee1275.h
|
||||
|
||||
grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
|
||||
|
|
|
@ -11,7 +11,7 @@ DEFSYMFILES += kernel_syms.lst
|
|||
|
||||
grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
|
||||
file.h fs.h kernel.h misc.h mm.h net.h rescue.h symbol.h \
|
||||
term.h types.h machine/biosdisk.h powerpc/libgcc.h loader.h \
|
||||
term.h types.h powerpc/libgcc.h loader.h \
|
||||
partition.h pc_partition.h machine/time.h machine/ieee1275.h
|
||||
|
||||
grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/machine/ieee1275.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/ofdisk.h>
|
||||
|
||||
static int
|
||||
grub_ofdisk_iterate (int (*hook) (const char *name))
|
||||
|
@ -60,7 +60,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
return grub_errno;
|
||||
|
||||
/* To access the complete disk add `:0'. */
|
||||
if (! (grub_ieee1275_flags & GRUB_IEEE1275_NO_PARTITION_0))
|
||||
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
|
||||
grub_strcat (devpath, ":0");
|
||||
|
||||
grub_ieee1275_open (devpath, &dev_ihandle);
|
||||
|
|
|
@ -65,11 +65,24 @@ typedef intptr_t grub_ieee1275_ihandle_t;
|
|||
typedef intptr_t grub_ieee1275_phandle_t;
|
||||
|
||||
extern intptr_t (*grub_ieee1275_entry_fn) (void *);
|
||||
extern grub_uint32_t grub_ieee1275_flags;
|
||||
extern int grub_ieee1275_realmode;
|
||||
|
||||
/* Old World firmware fails seek when "dev:0" is opened. */
|
||||
#define GRUB_IEEE1275_NO_PARTITION_0 0x1
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
* Copyright (C) 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
|
||||
|
@ -17,11 +17,10 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_INIT_MACHINE_HEADER
|
||||
#define GRUB_INIT_MACHINE_HEADER 1
|
||||
#ifndef GRUB_OFDISK_MACHINE_HEADER
|
||||
#define GRUB_OFDISK_MACHINE_HEADER 1
|
||||
|
||||
void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
|
||||
void grub_ofdisk_init (void);
|
||||
void grub_console_init (void);
|
||||
extern void grub_ofdisk_init (void);
|
||||
extern void grub_ofdisk_fini (void);
|
||||
|
||||
#endif /* ! GRUB_INIT_MACHINE_HEADER */
|
|
@ -29,9 +29,10 @@
|
|||
#include <grub/setjmp.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/time.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/machine/ofdisk.h>
|
||||
|
||||
/* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers. */
|
||||
static const grub_addr_t grub_heap_start = 0x4000;
|
||||
|
@ -42,7 +43,7 @@ abort (void)
|
|||
{
|
||||
/* Trap to Open Firmware. */
|
||||
asm ("trap");
|
||||
|
||||
|
||||
for (;;);
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ grub_set_prefix (void)
|
|||
grub_ieee1275_finddevice ("/chosen", &chosen);
|
||||
if (grub_ieee1275_get_property (chosen, "bootpath", &bootpath,
|
||||
sizeof (bootpath), 0))
|
||||
{
|
||||
{
|
||||
/* Should never happen. */
|
||||
grub_printf ("/chosen/bootpath property missing!\n");
|
||||
grub_env_set ("prefix", "");
|
||||
|
@ -138,9 +139,6 @@ grub_machine_fini (void)
|
|||
{
|
||||
grub_ofdisk_fini ();
|
||||
grub_console_fini ();
|
||||
|
||||
grub_ieee1275_release (grub_heap_start, grub_heap_len);
|
||||
/* XXX Release memory claimed for Old World firmware. */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -196,7 +196,8 @@ grub_claimmap (grub_addr_t addr, grub_size_t size)
|
|||
if (grub_ieee1275_claim (addr, size, 0, 0))
|
||||
return -1;
|
||||
|
||||
if ((! grub_ieee1275_realmode) && grub_map (addr, addr, size, 0x00))
|
||||
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);
|
||||
|
@ -338,7 +339,10 @@ grub_ieee1275_encode_devname (const char *path)
|
|||
if (partition)
|
||||
{
|
||||
unsigned int partno = grub_strtoul (partition, 0, 0);
|
||||
partno--; /* GRUB partition numbering is 0-based. */
|
||||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in a new issue