1 /* $NetBSD: kloader.h,v 1.6 2008/04/28 20:23:46 martin Exp $ */
4 * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
29 #ifndef _DEV_KLOADER_H_
30 #define _DEV_KLOADER_H_
32 #ifdef KLOADER_NO_BOOTINFO
37 #include <machine/bootinfo.h>
41 struct kloader_page_tag
;
42 struct kloader_bootinfo
;
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.
49 typedef void kloader_bootfunc_t(struct kloader_bootinfo
*,
50 struct kloader_page_tag
*);
52 * koader_jumpfunc_t jump to boot loader described abobe.
54 typedef void kloader_jumpfunc_t(kloader_bootfunc_t
*, vaddr_t
,
55 struct kloader_bootinfo
*, struct kloader_page_tag
*);
57 * reset func is optional. may be called when kloader reboot is failed.
60 kloader_jumpfunc_t
*jump
;
61 kloader_bootfunc_t
*boot
;
66 * new kernel is primary loaded into discrete pages.
68 struct kloader_page_tag
{
73 } __packed
__aligned(4);
75 #define KLOADER_KERNELARGS_MAX 256
77 struct kloader_bootinfo
{
78 /* kernel entry point */
81 /* argc, argv type boot argument */
85 /* struct type boot argument */
86 struct bootinfo bootinfo
;
89 char _argbuf
[KLOADER_KERNELARGS_MAX
];
90 } __packed
__aligned(4);
93 * kloader_reboot_setup sets machine dependent kloader_ops to
94 * kloader. (call __kloader_reboot_setup here.) and load new kernel.
96 void kloader_reboot_setup(const char *);
97 void __kloader_reboot_setup(struct kloader_ops
*, const char *);
100 * kloader_reboot jumps to 2nd boot loader.
101 * call after all shutdown hooks done.
103 void kloader_reboot(void) __dead
;
106 * kloader_bootinfo_set sets arguments of new kernel to boot. this is optional.
107 * theses parameter is passed to kloader_bootfunc_t.
109 void kloader_bootinfo_set(struct kloader_bootinfo
*, int, char *[],
110 struct bootinfo
*, int);
112 #endif /* _DEV_KLOADER_H_ */