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 */
|
2004-11-18 20:49:12 +03:00
|
|
|
#ifndef DEBUG_KERNEL_STACKS
|
|
|
|
# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 2) // 8 kB
|
|
|
|
#else
|
|
|
|
# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 3) // 8 kB + one guard page
|
|
|
|
#endif
|
|
|
|
#define KERNEL_STACK_GUARD_PAGES 1
|
2002-10-29 06:31:57 +03:00
|
|
|
|
|
|
|
/** Size of the stack given to teams in user space */
|
2004-11-18 20:49:12 +03:00
|
|
|
#define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024) // 16 MB
|
|
|
|
#define USER_STACK_SIZE (256 * 1024) // 256 kB
|
|
|
|
#define USER_STACK_GUARD_PAGES 4 // 16 kB
|
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
|
|
|
|
|
|
|
#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
|
|
|
|
#define ROUNDOWN(a, b) (((a) / (b)) * (b))
|
|
|
|
|
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) */
|
|
|
|
extern bool kernel_startup;
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2004-11-19 23:13:58 +03:00
|
|
|
status_t 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 */
|