2006-01-20 05:47:30 +03:00
|
|
|
/* $NetBSD: kloader.h,v 1.4 2006/01/20 02:47:30 uwe Exp $ */
|
2002-01-27 08:14:33 +03:00
|
|
|
|
|
|
|
/*-
|
2004-07-06 17:09:18 +04:00
|
|
|
* Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
|
2002-01-27 08:14:33 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2004-07-06 17:09:18 +04:00
|
|
|
#ifndef _DEV_KLOADER_H_
|
|
|
|
#define _DEV_KLOADER_H_
|
|
|
|
|
|
|
|
#ifdef KLOADER_NO_BOOTINFO
|
|
|
|
struct bootinfo {
|
|
|
|
int dummy;
|
|
|
|
};
|
|
|
|
#else
|
2002-01-29 21:44:22 +03:00
|
|
|
#include <machine/bootinfo.h>
|
2004-07-06 17:09:18 +04:00
|
|
|
#endif
|
2002-01-29 21:44:22 +03:00
|
|
|
|
|
|
|
struct kloader_ops;
|
|
|
|
struct kloader_page_tag;
|
|
|
|
struct kloader_bootinfo;
|
|
|
|
|
2004-07-06 17:09:18 +04:00
|
|
|
/*
|
|
|
|
* kloader_bootfunc_t load new kernel into existing kernel area from
|
|
|
|
* lined list of new kernel pieces. and then, jump to kernel
|
|
|
|
* entry. This function must be PIC.
|
|
|
|
*/
|
2002-01-29 21:44:22 +03:00
|
|
|
typedef void kloader_bootfunc_t(struct kloader_bootinfo *,
|
|
|
|
struct kloader_page_tag *);
|
2004-07-06 17:09:18 +04:00
|
|
|
/*
|
|
|
|
* koader_jumpfunc_t jump to boot loader described abobe.
|
|
|
|
*/
|
|
|
|
typedef void kloader_jumpfunc_t(kloader_bootfunc_t *, vaddr_t,
|
|
|
|
struct kloader_bootinfo *, struct kloader_page_tag *);
|
|
|
|
/*
|
|
|
|
* reset func is optional. may be called when kloader reboot is failed.
|
|
|
|
*/
|
2002-01-29 21:44:22 +03:00
|
|
|
struct kloader_ops {
|
2004-07-06 17:09:18 +04:00
|
|
|
kloader_jumpfunc_t *jump;
|
2002-01-29 21:44:22 +03:00
|
|
|
kloader_bootfunc_t *boot;
|
2002-02-11 20:13:28 +03:00
|
|
|
void (*reset)(void);
|
2002-01-29 21:44:22 +03:00
|
|
|
};
|
|
|
|
|
2004-07-06 17:09:18 +04:00
|
|
|
/*
|
|
|
|
* new kernel is primary loaded into discrete pages.
|
|
|
|
*/
|
2002-01-29 21:44:22 +03:00
|
|
|
struct kloader_page_tag {
|
2006-01-20 05:47:30 +03:00
|
|
|
uint32_t next;
|
|
|
|
uint32_t src;
|
|
|
|
uint32_t dst;
|
|
|
|
uint32_t sz;
|
2002-01-29 21:44:22 +03:00
|
|
|
} __attribute__((__packed__, __aligned__(4)));
|
|
|
|
|
2002-01-27 08:14:33 +03:00
|
|
|
#define KLOADER_KERNELARGS_MAX 256
|
|
|
|
|
|
|
|
struct kloader_bootinfo {
|
2004-07-06 17:09:18 +04:00
|
|
|
/* kernel entry point */
|
2002-01-27 08:14:33 +03:00
|
|
|
vaddr_t entry;
|
2004-07-06 17:09:18 +04:00
|
|
|
|
|
|
|
/* argc, argv type boot argument */
|
2002-01-27 08:14:33 +03:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
2004-07-06 17:09:18 +04:00
|
|
|
|
|
|
|
/* struct type boot argument */
|
2005-02-27 03:26:58 +03:00
|
|
|
struct bootinfo bootinfo;
|
2002-01-29 21:44:22 +03:00
|
|
|
|
2004-07-06 17:09:18 +04:00
|
|
|
/* argv buffer */
|
2002-01-29 21:44:22 +03:00
|
|
|
char _argbuf[KLOADER_KERNELARGS_MAX];
|
|
|
|
} __attribute__((__packed__, __aligned__(4)));
|
2002-01-27 08:14:33 +03:00
|
|
|
|
2004-07-06 17:09:18 +04:00
|
|
|
/*
|
|
|
|
* kloader_reboot_setup sets machine dependent kloader_ops to
|
|
|
|
* kloader. (call __kloader_reboot_setup here.) and load new kernel.
|
|
|
|
*/
|
|
|
|
void kloader_reboot_setup(const char *);
|
2002-01-29 21:44:22 +03:00
|
|
|
void __kloader_reboot_setup(struct kloader_ops *, const char *);
|
2004-07-06 17:09:18 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* kloader_reboot jumps to 2nd boot loader.
|
|
|
|
* call after all shutdown hooks done.
|
|
|
|
*/
|
|
|
|
void kloader_reboot(void) __attribute__((__noreturn__));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* kloader_bootinfo_set sets arguments of new kernel to boot. this is optional.
|
|
|
|
* theses parameter is passed to kloader_bootfunc_t.
|
|
|
|
*/
|
2002-01-27 08:14:33 +03:00
|
|
|
void kloader_bootinfo_set(struct kloader_bootinfo *, int, char *[],
|
2002-01-29 21:44:22 +03:00
|
|
|
struct bootinfo *, int);
|
2004-07-06 17:09:18 +04:00
|
|
|
|
|
|
|
#endif /* _DEV_KLOADER_H_ */
|