~ubuntu-branches/debian/sid/grub2/sid-200907171838

« back to all changes in this revision

Viewing changes to kern/loader.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2009-07-02 13:23:51 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702132351-tanpn0ryyijp93gu
Tags: 1.96+20090702-1
* New SVN snapshot.
* rules: Remove duplicated files in sparc64-ieee1275 port.
* rules: Comment out -DGRUB_ASSUME_LINUX_HAS_FB_SUPPORT=1 setting.  We'll
  re-evaluate using it when it's more mature.  (Closes: #535026).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  GRUB  --  GRand Unified Bootloader
3
 
 *  Copyright (C) 2002,2003,2004,2006,2007  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/loader.h>
20
 
#include <grub/misc.h>
21
 
#include <grub/mm.h>
22
 
#include <grub/err.h>
23
 
#include <grub/kernel.h>
24
 
 
25
 
static grub_err_t (*grub_loader_boot_func) (void);
26
 
static grub_err_t (*grub_loader_unload_func) (void);
27
 
static int grub_loader_noreturn;
28
 
 
29
 
static int grub_loader_loaded;
30
 
 
31
 
int
32
 
grub_loader_is_loaded (void)
33
 
{
34
 
  return grub_loader_loaded;
35
 
}
36
 
 
37
 
void
38
 
grub_loader_set (grub_err_t (*boot) (void),
39
 
                 grub_err_t (*unload) (void),
40
 
                 int noreturn)
41
 
{
42
 
  if (grub_loader_loaded && grub_loader_unload_func)
43
 
    grub_loader_unload_func ();
44
 
  
45
 
  grub_loader_boot_func = boot;
46
 
  grub_loader_unload_func = unload;
47
 
  grub_loader_noreturn = noreturn;
48
 
  
49
 
  grub_loader_loaded = 1;
50
 
}
51
 
 
52
 
void
53
 
grub_loader_unset(void)
54
 
{
55
 
  if (grub_loader_loaded && grub_loader_unload_func)
56
 
    grub_loader_unload_func ();
57
 
  
58
 
  grub_loader_boot_func = 0;
59
 
  grub_loader_unload_func = 0;
60
 
 
61
 
  grub_loader_loaded = 0;
62
 
}
63
 
 
64
 
grub_err_t
65
 
grub_loader_boot (void)
66
 
{
67
 
  if (! grub_loader_loaded)
68
 
    return grub_error (GRUB_ERR_NO_KERNEL, "no loaded kernel");
69
 
 
70
 
  if (grub_loader_noreturn)
71
 
    grub_machine_fini ();
72
 
  
73
 
  return (grub_loader_boot_func) ();
74
 
}
75