annotate loader.c @ 0:7ac2a177e25d

add elilo source.
author taiki
date Thu, 14 Feb 2013 01:43:26 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
1 /*
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
4 *
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
5 * This file is part of the ELILO, the EFI Linux boot loader.
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
6 *
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
7 * ELILO is free software; you can redistribute it and/or modify
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
9 * the Free Software Foundation; either version 2, or (at your option)
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
10 * any later version.
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
11 *
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
12 * ELILO is distributed in the hope that it will be useful,
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
15 * GNU General Public License for more details.
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
16 *
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
18 * along with ELILO; see the file COPYING. If not, write to the Free
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
20 * 02111-1307, USA.
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
21 *
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
22 * Please check out the elilo.txt for complete documentation on how
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
23 * to use this program.
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
24 */
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
25
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
26 #include <efi.h>
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
27 #include <efilib.h>
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
28
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
29 #include "elilo.h"
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
30 #include "loader.h"
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
31
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
32 extern loader_ops_t plain_loader;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
33 extern loader_ops_t gzip_loader;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
34
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
35 static loader_ops_t *ldops_list;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
36
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
37 loader_ops_t *
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
38 loader_probe(CHAR16 *kname)
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
39 {
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
40 loader_ops_t *ops;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
41 UINTN n = 0;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
42
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
43 for (ops= ldops_list; ops; ops = ops->next) {
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
44 n++;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
45 VERB_PRT(3, Print(L"Probing loader: %s\n", ops->ld_name));
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
46 if (ops->ld_probe(kname) == 0) {
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
47 return ops;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
48 }
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
49 }
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
50 if (!n) {
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
51 ERR_PRT((L"No loaders registered"));
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
52 }
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
53 return NULL;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
54 }
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
55
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
56 INTN
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
57 loader_register(loader_ops_t *ldops)
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
58 {
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
59 if (ldops == NULL) return -1;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
60
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
61 /* cheap sanity check */
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
62 if (ldops->next) {
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
63 ERR_PRT((L"loader %s is already registered", ldops->ld_name));
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
64 return -1;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
65 }
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
66
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
67 ldops->next = ldops_list;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
68 ldops_list = ldops;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
69
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
70 VERB_PRT(3, Print(L"New loader registered: %s\n", ldops->ld_name));
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
71
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
72 return 0;
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
73 }
7ac2a177e25d add elilo source.
taiki
parents:
diff changeset
74