1/*
2 * Copyright 2002-2005, Axel D��rfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 *
5 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6 * Distributed under the terms of the NewOS License.
7 */
8#ifndef _FSSH_KERNEL_H
9#define _FSSH_KERNEL_H
10
11
12#include "fssh_os.h"
13
14
15/* Passed in buffers from user-space shouldn't point into the kernel */
16#if 0
17#define IS_USER_ADDRESS(x) \
18	((addr_t)(x) < KERNEL_BASE || (addr_t)(x) > KERNEL_TOP)
19
20#define IS_KERNEL_ADDRESS(x) \
21	((addr_t)(x) >= KERNEL_BASE && (addr_t)(x) <= KERNEL_TOP)
22#endif	// 0
23
24#define DEBUG_KERNEL_STACKS
25	// Note, debugging kernel stacks doesn't really work yet. Since the
26	// interrupt will also try to use the stack on a page fault, all
27	// you get is a double fault.
28	// At least, you then know that the stack overflows in this case :)
29
30/** Size of the kernel stack */
31#ifndef DEBUG_KERNEL_STACKS
32#	define KERNEL_STACK_SIZE		(B_PAGE_SIZE * 2)	// 8 kB
33#else
34#	define KERNEL_STACK_SIZE		(B_PAGE_SIZE * 3)	// 8 kB + one guard page
35#endif
36#define KERNEL_STACK_GUARD_PAGES	1
37
38/** Size of the stack given to teams in user space */
39#define USER_MAIN_THREAD_STACK_SIZE	(16 * 1024 * 1024)	// 16 MB
40#define USER_STACK_SIZE				(256 * 1024)		// 256 kB
41#define USER_STACK_GUARD_PAGES		4					// 16 kB
42
43/** Size of the environmental variables space for a process */
44#define ENV_SIZE	(B_PAGE_SIZE * 8)
45
46
47#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
48#define ROUNDDOWN(a, b) (((a) / (b)) * (b))
49
50
51#define CHECK_BIT(a, b) ((a) & (1 << (b)))
52#define SET_BIT(a, b) ((a) | (1 << (b)))
53#define CLEAR_BIT(a, b) ((a) & (~(1 << (b))))
54
55
56#endif	/* _FSSH_KERNEL_H */
57