Cleaned up kernel.h; the insque(), remque() functions are now in a separate
header kqueue.h - together with their implementation which was in module.c Added a new CHECK_USER_ADDRESS() macro that can be used to check if a user address points into the kernel. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1742 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
03360f3bb7
commit
8f3a4e7dd4
@ -5,59 +5,30 @@
|
||||
#ifndef _KERNEL_KERNEL_H
|
||||
#define _KERNEL_KERNEL_H
|
||||
|
||||
/**
|
||||
* @file kernel/kernel.h
|
||||
* @brief Kernel Definitions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup OpenBeOS_Kernel OpenBeOS Kernel
|
||||
* @brief The OpenBeOS Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* david - same fiddle as stage2.h. Renamed the arch specific
|
||||
* kernel.h file into arch_kernel.h and then just include
|
||||
* it here as the arch specific directories are included on the
|
||||
* include paths for the build.
|
||||
*/
|
||||
|
||||
#include <arch_kernel.h>
|
||||
|
||||
/**
|
||||
* Size of the kernel stack
|
||||
*/
|
||||
#define KSTACK_SIZE (PAGE_SIZE*2)
|
||||
/**
|
||||
* Size of the stack given to processes
|
||||
*/
|
||||
#define STACK_SIZE (PAGE_SIZE*16)
|
||||
/**
|
||||
* Size of the environmental variables space for a process
|
||||
*/
|
||||
#define ENV_SIZE (PAGE_SIZE*8)
|
||||
/* Passed in buffers from user-space shouldn't point into the kernel */
|
||||
#define CHECK_USER_ADDRESS(x) \
|
||||
((addr)(x) < KERNEL_BASE || (addr)(x) > KERNEL_TOP)
|
||||
|
||||
/** Size of the kernel stack */
|
||||
#define KSTACK_SIZE (PAGE_SIZE * 2)
|
||||
|
||||
/** Size of the stack given to teams in user space */
|
||||
#define STACK_SIZE (PAGE_SIZE * 16)
|
||||
|
||||
/** Size of the environmental variables space for a process */
|
||||
#define ENV_SIZE (PAGE_SIZE * 8)
|
||||
|
||||
|
||||
#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
|
||||
#define ROUNDOWN(a, b) (((a) / (b)) * (b))
|
||||
|
||||
|
||||
/** Is bit 'b' set in 'a' */
|
||||
#define CHECK_BIT(a, b) ((a) & (1 << (b)))
|
||||
/** Set bit 'b' in 'a' */
|
||||
#define SET_BIT(a, b) ((a) | (1 << (b)))
|
||||
/** Unset bit 'b' in 'a' */
|
||||
#define CLEAR_BIT(a, b) ((a) & (~(1 << (b))))
|
||||
|
||||
__inline void insque(void *, void*);
|
||||
__inline void remque(void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#endif /* _KERNEL_KERNEL_H */
|
||||
#endif /* _KERNEL_KERNEL_H */
|
||||
|
45
headers/private/kernel/kqueue.h
Normal file
45
headers/private/kernel/kqueue.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
** Copyright 2002, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
#ifndef KQUEUE_H
|
||||
#define KQUEUE_H
|
||||
|
||||
|
||||
/* The object that is put into a queue must begin with these
|
||||
* fields, but it doesn't have to be this structure.
|
||||
*/
|
||||
struct quehead {
|
||||
struct quehead *next;
|
||||
struct quehead *prev;
|
||||
};
|
||||
|
||||
|
||||
/** Inserts an element (a) to the queue (b) */
|
||||
|
||||
static inline void
|
||||
insque(void *a, void *b)
|
||||
{
|
||||
struct quehead *element = (struct quehead *)a,
|
||||
*head = (struct quehead *)b;
|
||||
|
||||
element->next = head->next;
|
||||
element->prev = head;
|
||||
head->next = element;
|
||||
element->next->prev = element;
|
||||
}
|
||||
|
||||
|
||||
/** removes an element from the queue it's currently in */
|
||||
|
||||
static inline void
|
||||
remque(void *a)
|
||||
{
|
||||
struct quehead *element = (struct quehead *)a;
|
||||
|
||||
element->next->prev = element->prev;
|
||||
element->prev->next = element->next;
|
||||
element->prev = 0;
|
||||
}
|
||||
|
||||
#endif /* KQUEUE_H */
|
Loading…
x
Reference in New Issue
Block a user