2004-11-18 20:49:12 +03:00
|
|
|
/*
|
2005-04-12 10:09:13 +04:00
|
|
|
* Copyright 2002-2005, Axel Dörfler, axeld@pinc-software.de.
|
2004-11-18 20:49:12 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
|
|
|
* Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _KERNEL_KERNEL_H
|
|
|
|
#define _KERNEL_KERNEL_H
|
|
|
|
|
2002-10-29 06:31:57 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <arch_kernel.h>
|
2004-11-18 20:49:12 +03:00
|
|
|
#include <arch_config.h>
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-29 06:31:57 +03:00
|
|
|
/* Passed in buffers from user-space shouldn't point into the kernel */
|
2004-02-22 17:56:50 +03:00
|
|
|
#define IS_USER_ADDRESS(x) \
|
|
|
|
((addr_t)(x) < KERNEL_BASE || (addr_t)(x) > KERNEL_TOP)
|
|
|
|
|
|
|
|
#define IS_KERNEL_ADDRESS(x) \
|
|
|
|
((addr_t)(x) >= KERNEL_BASE && (addr_t)(x) <= KERNEL_TOP)
|
2002-10-29 06:31:57 +03:00
|
|
|
|
2006-03-05 21:05:33 +03:00
|
|
|
#define DEBUG_KERNEL_STACKS
|
2004-11-19 23:13:58 +03:00
|
|
|
// Note, debugging kernel stacks doesn't really work yet. Since the
|
|
|
|
// interrupt will also try to use the stack on a page fault, all
|
2005-04-12 10:09:13 +04:00
|
|
|
// you get is a double fault.
|
2004-11-19 23:13:58 +03:00
|
|
|
// At least, you then know that the stack overflows in this case :)
|
|
|
|
|
2002-10-29 06:31:57 +03:00
|
|
|
/** Size of the kernel stack */
|
2008-08-05 21:19:46 +04:00
|
|
|
#define KERNEL_STACK_SIZE (B_PAGE_SIZE * 3) // 12 kB
|
|
|
|
|
|
|
|
#ifdef DEBUG_KERNEL_STACKS
|
|
|
|
# define KERNEL_STACK_GUARD_PAGES 1
|
2004-11-18 20:49:12 +03:00
|
|
|
#else
|
2008-08-05 21:19:46 +04:00
|
|
|
# define KERNEL_STACK_GUARD_PAGES 0
|
2004-11-18 20:49:12 +03:00
|
|
|
#endif
|
2002-10-29 06:31:57 +03:00
|
|
|
|
|
|
|
/** Size of the environmental variables space for a process */
|
2004-10-20 04:33:06 +04:00
|
|
|
#define ENV_SIZE (B_PAGE_SIZE * 8)
|
2002-10-29 06:31:57 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-03 16:39:56 +04:00
|
|
|
#define ROUNDDOWN(a, b) (((a) / (b)) * (b))
|
|
|
|
#define ROUNDUP(a, b) ROUNDDOWN((a) + (b) - 1, b)
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-10 17:17:22 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#define CHECK_BIT(a, b) ((a) & (1 << (b)))
|
|
|
|
#define SET_BIT(a, b) ((a) | (1 << (b)))
|
|
|
|
#define CLEAR_BIT(a, b) ((a) & (~(1 << (b))))
|
|
|
|
|
2005-04-12 10:09:13 +04:00
|
|
|
/* during kernel startup, interrupts are disabled (among other things) */
|
2008-08-02 19:03:03 +04:00
|
|
|
extern bool gKernelStartup;
|
2005-04-12 10:09:13 +04:00
|
|
|
|
|
|
|
|
2004-11-19 23:13:58 +03:00
|
|
|
#ifdef __cplusplus
|
2004-11-26 17:41:53 +03:00
|
|
|
extern "C" {
|
2004-11-19 23:13:58 +03:00
|
|
|
#endif
|
2004-11-26 17:41:53 +03:00
|
|
|
|
2007-05-23 23:56:40 +04:00
|
|
|
status_t system_shutdown(bool reboot);
|
2004-11-26 17:41:53 +03:00
|
|
|
status_t _user_shutdown(bool reboot);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-29 06:31:57 +03:00
|
|
|
#endif /* _KERNEL_KERNEL_H */
|