~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to kern/i386/coreboot/init.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-02-08 11:39:26 UTC
  • mfrom: (17.6.26 experimental)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 104.
  • Revision ID: james.westby@ubuntu.com-20110208113926-clfs90haboyk9zip
Tags: 1.99~rc1-2
* Merge 1.98+20100804-13 and 1.98+20100804-14, updating translations:
  - Kazakh (Baurzhan Muftakhidinov / Timur Birsh).
* mkconfig_skip_dmcrypt.patch: Refer to GRUB_PRELOAD_MODULES rather than
  suggesting people write a /etc/grub.d/01_modules script (thanks, Jordan
  Uggla).
* Handle empty dir passed to grub_find_root_device_from_mountinfo; fixes
  grub-mkrelpath on btrfs subvolumes (LP: #712029).
* Add rootflags=subvol=<name> if / is on a btrfs subvolume (LP: #712029).
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  GRUB  --  GRand Unified Bootloader
3
 
 *  Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Free Software Foundation, Inc.
4
 
 *
5
 
 *  GRUB is free software: you can redistribute it and/or modify
6
 
 *  it under the terms of the GNU General Public License as published by
7
 
 *  the Free Software Foundation, either version 3 of the License, or
8
 
 *  (at your option) any later version.
9
 
 *
10
 
 *  GRUB is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
#include <grub/kernel.h>
20
 
#include <grub/mm.h>
21
 
#include <grub/machine/time.h>
22
 
#include <grub/machine/init.h>
23
 
#include <grub/machine/memory.h>
24
 
#include <grub/machine/console.h>
25
 
#include <grub/types.h>
26
 
#include <grub/err.h>
27
 
#include <grub/dl.h>
28
 
#include <grub/misc.h>
29
 
#include <grub/loader.h>
30
 
#include <grub/env.h>
31
 
#include <grub/cache.h>
32
 
#include <grub/time.h>
33
 
#include <grub/symbol.h>
34
 
#include <grub/cpu/io.h>
35
 
#include <grub/cpu/tsc.h>
36
 
#ifdef GRUB_MACHINE_QEMU
37
 
#include <grub/machine/kernel.h>
38
 
#endif
39
 
 
40
 
#define GRUB_FLOPPY_REG_DIGITAL_OUTPUT          0x3f2
41
 
 
42
 
extern char _start[];
43
 
extern char _end[];
44
 
 
45
 
grub_addr_t grub_os_area_addr;
46
 
grub_size_t grub_os_area_size;
47
 
 
48
 
grub_uint32_t
49
 
grub_get_rtc (void)
50
 
{
51
 
  grub_fatal ("grub_get_rtc() is not implemented.\n");
52
 
}
53
 
 
54
 
/* Stop the floppy drive from spinning, so that other software is
55
 
   jumped to with a known state.  */
56
 
void
57
 
grub_stop_floppy (void)
58
 
{
59
 
  grub_outb (0, GRUB_FLOPPY_REG_DIGITAL_OUTPUT);
60
 
}
61
 
 
62
 
void
63
 
grub_exit (void)
64
 
{
65
 
  /* We can't use grub_fatal() in this function.  This would create an infinite
66
 
     loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit().  */
67
 
  while (1)
68
 
    grub_cpu_idle ();
69
 
}
70
 
 
71
 
void
72
 
grub_machine_init (void)
73
 
{
74
 
#ifdef GRUB_MACHINE_QEMU
75
 
  grub_qemu_init_cirrus ();
76
 
#endif
77
 
  /* Initialize the console as early as possible.  */
78
 
  grub_vga_text_init ();
79
 
 
80
 
  auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t, grub_uint32_t);
81
 
  int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
82
 
  {
83
 
#if GRUB_CPU_SIZEOF_VOID_P == 4
84
 
    /* Restrict ourselves to 32-bit memory space.  */
85
 
    if (addr > GRUB_ULONG_MAX)
86
 
      return 0;
87
 
    if (addr + size > GRUB_ULONG_MAX)
88
 
      size = GRUB_ULONG_MAX - addr;
89
 
#endif
90
 
 
91
 
    if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
92
 
      return 0;
93
 
 
94
 
    /* Avoid the lower memory.  */
95
 
    if (addr < GRUB_MEMORY_MACHINE_LOWER_SIZE)
96
 
      {
97
 
        if (addr + size <= GRUB_MEMORY_MACHINE_LOWER_SIZE)
98
 
          return 0;
99
 
        else
100
 
          {
101
 
            size -= GRUB_MEMORY_MACHINE_LOWER_SIZE - addr;
102
 
            addr = GRUB_MEMORY_MACHINE_LOWER_SIZE;
103
 
          }
104
 
      }
105
 
 
106
 
    if (addr == GRUB_MEMORY_MACHINE_UPPER_START
107
 
        || (addr >= GRUB_MEMORY_MACHINE_LOWER_SIZE
108
 
            && addr <= GRUB_MEMORY_MACHINE_UPPER_START
109
 
            && (addr + size > GRUB_MEMORY_MACHINE_UPPER_START)))
110
 
      {
111
 
        grub_size_t quarter = size >> 2;
112
 
 
113
 
        grub_os_area_addr = addr;
114
 
        grub_os_area_size = size - quarter;
115
 
        grub_mm_init_region ((void *) (grub_os_area_addr + grub_os_area_size),
116
 
                             quarter);
117
 
      }
118
 
    else
119
 
      grub_mm_init_region ((void *) (grub_addr_t) addr, (grub_size_t) size);
120
 
 
121
 
    return 0;
122
 
  }
123
 
 
124
 
#if defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
125
 
  grub_machine_mmap_init ();
126
 
#endif
127
 
  grub_machine_mmap_iterate (heap_init);
128
 
 
129
 
  grub_tsc_init ();
130
 
}
131
 
 
132
 
void
133
 
grub_machine_set_prefix (void)
134
 
{
135
 
  /* Initialize the prefix.  */
136
 
  grub_env_set ("prefix", grub_prefix);
137
 
}
138
 
 
139
 
void
140
 
grub_machine_fini (void)
141
 
{
142
 
  grub_vga_text_fini ();
143
 
  grub_stop_floppy ();
144
 
}
145
 
 
146
 
/* Return the end of the core image.  */
147
 
grub_addr_t
148
 
grub_arch_modules_addr (void)
149
 
{
150
 
#ifdef GRUB_MACHINE_QEMU
151
 
  return grub_core_entry_addr + grub_kernel_image_size;
152
 
#else
153
 
  return ALIGN_UP((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
154
 
#endif
155
 
}