~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to kern/powerpc/ieee1275/cmain.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2006-01-05 15:20:40 UTC
  • mto: (17.3.1 squeeze) (1.9.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060105152040-b72i5pq1a82z22yi
Tags: upstream-1.92
ImportĀ upstreamĀ versionĀ 1.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* cmain.c - Startup code for the PowerPC.  */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 */
 
20
 
 
21
#include <alloca.h>
 
22
#include <stdint.h>
 
23
#include <grub/kernel.h>
 
24
#include <grub/machine/kernel.h>
 
25
#include <grub/ieee1275/ieee1275.h>
 
26
 
 
27
/* OpenFirmware entry point passed to us from the real bootloader.  */
 
28
int (*grub_ieee1275_entry_fn) (void *);
 
29
 
 
30
grub_ieee1275_phandle_t grub_ieee1275_chosen;
 
31
 
 
32
static grub_uint32_t grub_ieee1275_flags;
 
33
 
 
34
 
 
35
 
 
36
int
 
37
grub_ieee1275_test_flag (enum grub_ieee1275_flag flag)
 
38
{
 
39
  return (grub_ieee1275_flags & (1 << flag));
 
40
}
 
41
 
 
42
void
 
43
grub_ieee1275_set_flag (enum grub_ieee1275_flag flag)
 
44
{
 
45
  grub_ieee1275_flags |= (1 << flag);
 
46
}
 
47
 
 
48
static void
 
49
grub_ieee1275_find_options (void)
 
50
{
 
51
  grub_ieee1275_phandle_t options;
 
52
  grub_ieee1275_phandle_t openprom;
 
53
  int realmode;
 
54
  int smartfw;
 
55
 
 
56
  grub_ieee1275_finddevice ("/options", &options);
 
57
  grub_ieee1275_get_property (options, "real-mode?", &realmode,
 
58
                              sizeof (realmode), 0);
 
59
  if (realmode)
 
60
    grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
 
61
 
 
62
  grub_ieee1275_finddevice ("/openprom", &openprom);
 
63
  smartfw = grub_ieee1275_get_property (openprom, "SmartFirmware-version",
 
64
                                        0, 0, 0);
 
65
  if (smartfw != -1)
 
66
    grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
 
67
}
 
68
 
 
69
void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
 
70
void
 
71
cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
 
72
{
 
73
  if (r5 == 0xdeadbeef)
 
74
    {
 
75
      /* Entered from Old World stage1.  */
 
76
      extern char _start;
 
77
      extern char _end;
 
78
 
 
79
      grub_ieee1275_entry_fn = (int (*)(void *)) r3;
 
80
 
 
81
      grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
 
82
 
 
83
      /* Old World Open Firmware may use 4M-5M without claiming it.  */
 
84
      grub_ieee1275_claim (0x00400000, 0x00100000, 0, 0);
 
85
 
 
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))
 
89
        abort();
 
90
    }
 
91
  else
 
92
    {
 
93
      /* Assume we were entered from Open Firmware.  */
 
94
      grub_ieee1275_entry_fn = (int (*)(void *)) r5;
 
95
    }
 
96
 
 
97
  grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
 
98
 
 
99
  grub_ieee1275_find_options ();
 
100
 
 
101
  /* Now invoke the main function.  */
 
102
  grub_main ();
 
103
 
 
104
  /* Never reached.  */
 
105
}