FreeBSD/Linux Kernel Cross Reference
sys/dev/kloader.h
1 /* $NetBSD: kloader.h,v 1.7 2008/09/08 23:36:54 gmcgarry Exp $ */
2
3 /*-
4 * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef _DEV_KLOADER_H_
30 #define _DEV_KLOADER_H_
31
32 #ifdef KLOADER_NO_BOOTINFO
33 struct bootinfo {
34 int dummy;
35 };
36 #else
37 #include <machine/bootinfo.h>
38 #endif
39
40 struct kloader_ops;
41 struct kloader_page_tag;
42 struct kloader_bootinfo;
43
44 /*
45 * kloader_bootfunc_t load new kernel into existing kernel area from
46 * lined list of new kernel pieces. and then, jump to kernel
47 * entry. This function must be PIC.
48 */
49 typedef void kloader_bootfunc_t(struct kloader_bootinfo *,
50 struct kloader_page_tag *);
51 /*
52 * koader_jumpfunc_t jump to boot loader described abobe.
53 */
54 typedef void kloader_jumpfunc_t(kloader_bootfunc_t *, vaddr_t,
55 struct kloader_bootinfo *, struct kloader_page_tag *);
56 /*
57 * reset func is optional. may be called when kloader reboot is failed.
58 */
59 struct kloader_ops {
60 kloader_jumpfunc_t *jump;
61 kloader_bootfunc_t *boot;
62 void (*reset)(void);
63 };
64
65 /*
66 * new kernel is primary loaded into discrete pages.
67 */
68 struct kloader_page_tag {
69 uint32_t next;
70 uint32_t src;
71 uint32_t dst;
72 uint32_t sz;
73 } __packed __aligned(4);
74
75 #define KLOADER_KERNELARGS_MAX 256
76
77 struct kloader_bootinfo {
78 /* kernel entry point */
79 vaddr_t entry;
80
81 /* argc, argv type boot argument */
82 int argc;
83 char **argv;
84
85 /* struct type boot argument */
86 struct bootinfo bootinfo;
87
88 /* argv buffer */
89 char _argbuf[KLOADER_KERNELARGS_MAX];
90 } __packed __aligned(4);
91
92 /*
93 * kloader_reboot_setup sets machine dependent kloader_ops to
94 * kloader. (call __kloader_reboot_setup here.) and load new kernel.
95 */
96 void kloader_reboot_setup(const char *);
97 void __kloader_reboot_setup(struct kloader_ops *, const char *);
98
99 /*
100 * kloader_reboot jumps to 2nd boot loader.
101 * call after all shutdown hooks done.
102 */
103 void kloader_reboot(void) __dead;
104
105 /*
106 * kloader_bootinfo_set sets arguments of new kernel to boot. this is optional.
107 * theses parameter is passed to kloader_bootfunc_t.
108 */
109 void kloader_bootinfo_set(struct kloader_bootinfo *, int, char *[],
110 struct bootinfo *, int);
111
112 #endif /* _DEV_KLOADER_H_ */
Cache object: 6b8f3a966eb321c79d72a92fba621ad7
|