Our new KernelExport.h header.
Typedefs for debugger and kernel daemon hooks, cleaned up. Added a ToDo item about the "abuse" of the quent structure. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2581 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+106
-154
@@ -1,104 +1,75 @@
|
|||||||
/* ++++++++++
|
/* Kernel only exports for kernel add-ons
|
||||||
KernelExport.h
|
**
|
||||||
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
Functions exported from the kernel for driver use that are not already
|
*/
|
||||||
prototyped elsewhere.
|
|
||||||
|
|
||||||
Copyright 1996-98, Be Incorporated.
|
|
||||||
+++++ */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _KERNEL_EXPORT_H
|
#ifndef _KERNEL_EXPORT_H
|
||||||
#define _KERNEL_EXPORT_H
|
#define _KERNEL_EXPORT_H
|
||||||
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------*/
|
||||||
|
|
||||||
/* ---
|
/* disable/restore interrupts on the current CPU */
|
||||||
kernel threads
|
|
||||||
--- */
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL thread_id spawn_kernel_thread (
|
|
||||||
thread_func function,
|
|
||||||
const char *thread_name,
|
|
||||||
long priority,
|
|
||||||
void *arg
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
|
||||||
disable/restore interrupt enable flag on current cpu
|
|
||||||
--- */
|
|
||||||
|
|
||||||
typedef ulong cpu_status;
|
typedef ulong cpu_status;
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL cpu_status disable_interrupts(void);
|
extern cpu_status disable_interrupts(void);
|
||||||
extern _IMPEXP_KERNEL void restore_interrupts(cpu_status status);
|
extern void restore_interrupts(cpu_status status);
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
/* spinlocks. Note that acquire/release should be called with
|
||||||
spinlocks. Note that acquire/release should be called with
|
* interrupts disabled.
|
||||||
interrupts disabled.
|
*/
|
||||||
--- */
|
|
||||||
|
|
||||||
typedef vint32 spinlock;
|
typedef vint32 spinlock;
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL void acquire_spinlock (spinlock *lock);
|
extern void acquire_spinlock(spinlock *lock);
|
||||||
extern _IMPEXP_KERNEL void release_spinlock (spinlock *lock);
|
extern void release_spinlock(spinlock *lock);
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
/* interrupt handling support for device drivers */
|
||||||
An interrupt handler returns one of the following values:
|
|
||||||
--- */
|
|
||||||
|
|
||||||
|
/* Values returned by interrupt handlers */
|
||||||
#define B_UNHANDLED_INTERRUPT 0 /* pass to next handler */
|
#define B_UNHANDLED_INTERRUPT 0 /* pass to next handler */
|
||||||
#define B_HANDLED_INTERRUPT 1 /* don't pass on */
|
#define B_HANDLED_INTERRUPT 1 /* don't pass on */
|
||||||
#define B_INVOKE_SCHEDULER 2 /* don't pass on; invoke the scheduler */
|
#define B_INVOKE_SCHEDULER 2 /* don't pass on; invoke the scheduler */
|
||||||
|
|
||||||
typedef int32 (*interrupt_handler)(void *data);
|
typedef int32 (*interrupt_handler)(void *data);
|
||||||
|
|
||||||
/* interrupt handling support for device drivers */
|
extern long install_io_interrupt_handler(long interrupt_number,
|
||||||
|
interrupt_handler handler, void *data, ulong flags);
|
||||||
|
extern long remove_io_interrupt_handler(long interrupt_number,
|
||||||
|
interrupt_handler handler, void *data);
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL long install_io_interrupt_handler (
|
|
||||||
long interrupt_number,
|
|
||||||
interrupt_handler handler,
|
|
||||||
void *data,
|
|
||||||
ulong flags
|
|
||||||
);
|
|
||||||
extern _IMPEXP_KERNEL long remove_io_interrupt_handler (
|
|
||||||
long interrupt_number,
|
|
||||||
interrupt_handler handler,
|
|
||||||
void *data
|
|
||||||
);
|
|
||||||
|
|
||||||
/* ---
|
/*-------------------------------------------------------------*/
|
||||||
timer interrupts services
|
/* timer interrupts services */
|
||||||
--- */
|
|
||||||
|
|
||||||
typedef struct timer timer;
|
/* The BeOS qent structure is probably part of a general double linked list
|
||||||
typedef struct qent qent;
|
|
||||||
typedef int32 (*timer_hook)(timer *);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The BeOS qent structure is probably part of a general double linked list
|
|
||||||
* interface used all over the kernel; a struct is required to have a qent
|
* interface used all over the kernel; a struct is required to have a qent
|
||||||
* entry struct as first element, so it can be linked to other elements
|
* entry struct as first element, so it can be linked to other elements
|
||||||
* easily. The key field is probably just an id, eventually used to order
|
* easily. The key field is probably just an id, eventually used to order
|
||||||
* the list.
|
* the list.
|
||||||
* Since we don't use this kind of interface, but we have to provide it
|
* Since we don't use this kind of interface, but we have to provide it
|
||||||
* to keep compatibility, we can use the qent struct for other purposes...
|
* to keep compatibility, we can use the qent struct for other purposes...
|
||||||
|
*
|
||||||
|
* ToDo: don't do this! Drop source compatibility, but don't overdefine those values!
|
||||||
*/
|
*/
|
||||||
struct qent {
|
typedef struct qent {
|
||||||
int64 key; /* We use this as the sched time */
|
int64 key; /* We use this as the sched time */
|
||||||
qent *next; /* This is used as a pointer to next timer */
|
struct qent *next; /* This is used as a pointer to next timer */
|
||||||
qent *prev; /* This can be used for callback args */
|
struct qent *prev; /* This can be used for callback args */
|
||||||
};
|
} qent;
|
||||||
|
|
||||||
|
typedef struct timer timer;
|
||||||
|
typedef int32 (*timer_hook)(timer *);
|
||||||
|
|
||||||
struct timer {
|
struct timer {
|
||||||
qent entry;
|
qent entry;
|
||||||
@@ -108,31 +79,36 @@ struct timer {
|
|||||||
bigtime_t period;
|
bigtime_t period;
|
||||||
};
|
};
|
||||||
|
|
||||||
status_t add_timer(timer *t, timer_hook h, bigtime_t, int32 f);
|
|
||||||
bool cancel_timer(timer *t);
|
|
||||||
|
|
||||||
#define B_ONE_SHOT_ABSOLUTE_TIMER 1
|
#define B_ONE_SHOT_ABSOLUTE_TIMER 1
|
||||||
#define B_ONE_SHOT_RELATIVE_TIMER 2
|
#define B_ONE_SHOT_RELATIVE_TIMER 2
|
||||||
#define B_PERIODIC_TIMER 3
|
#define B_PERIODIC_TIMER 3
|
||||||
|
|
||||||
/* ---
|
extern status_t add_timer(timer *t, timer_hook hook, bigtime_t period, int32 flags);
|
||||||
signal functions
|
extern bool cancel_timer(timer *t);
|
||||||
--- */
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL int send_signal_etc(pid_t thid, uint sig, uint32 flags);
|
|
||||||
extern _IMPEXP_KERNEL int has_signals_pending(void *thr);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
/*-------------------------------------------------------------*/
|
||||||
snooze functions
|
/* kernel threads */
|
||||||
--- */
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL status_t snooze_etc(bigtime_t usecs, int timebase, uint32 flags);
|
extern thread_id spawn_kernel_thread(thread_func function, const char *threadName,
|
||||||
|
long priority, void *arg);
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
/*-------------------------------------------------------------*/
|
||||||
virtual memory buffer functions
|
/* signal functions */
|
||||||
--- */
|
|
||||||
|
extern int send_signal_etc(pid_t thread, uint sig, uint32 flags);
|
||||||
|
extern int has_signals_pending(void *_thread);
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------*/
|
||||||
|
/* snooze functions */
|
||||||
|
|
||||||
|
extern status_t snooze_etc(bigtime_t usecs, int timebase, uint32 flags);
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------*/
|
||||||
|
/* virtual memory buffer functions */
|
||||||
|
|
||||||
#define B_DMA_IO 0x00000001
|
#define B_DMA_IO 0x00000001
|
||||||
#define B_READ_DEVICE 0x00000002
|
#define B_READ_DEVICE 0x00000002
|
||||||
@@ -142,36 +118,22 @@ typedef struct {
|
|||||||
ulong size; /* size of block */
|
ulong size; /* size of block */
|
||||||
} physical_entry;
|
} physical_entry;
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL long lock_memory (
|
extern long lock_memory(void *buffer, ulong numBytes, ulong flags);
|
||||||
void *buf, /* -> virtual buffer to lock (make resident) */
|
extern long unlock_memory(void *buffer, ulong numBytes, ulong flags);
|
||||||
ulong num_bytes, /* size of virtual buffer */
|
extern long get_memory_map(const void *buffer, ulong size,
|
||||||
ulong flags
|
physical_entry *table, long numEntries);
|
||||||
);
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL long unlock_memory (
|
/* address specifications for mapping physical memory */
|
||||||
void *buf, /* -> virtual buffer to unlock */
|
#define B_ANY_KERNEL_BLOCK_ADDRESS (B_ANY_KERNEL_ADDRESS + 1)
|
||||||
ulong num_bytes, /* size of virtual buffer */
|
|
||||||
ulong flags
|
|
||||||
);
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL long get_memory_map (
|
/* call to map physical memory - typically used for memory-mapped i/o */
|
||||||
const void *address, /* -> virtual buffer to translate */
|
|
||||||
ulong size, /* size of virtual buffer */
|
extern area_id map_physical_memory(const char *areaName, void *physicalAddress,
|
||||||
physical_entry *table, /* -> caller supplied table */
|
size_t size, uint32 flags, uint32 protection, void **mappedAddress);
|
||||||
long num_entries /* # entries in table */
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* -----
|
/* MTR attributes for mapping physical memory (Intel Architecture only) */
|
||||||
address specifications for mapping physical memory
|
// ToDo: what have those to do here?
|
||||||
----- */
|
|
||||||
|
|
||||||
#define B_ANY_KERNEL_BLOCK_ADDRESS ((B_ANY_KERNEL_ADDRESS)+1)
|
|
||||||
|
|
||||||
/* -----
|
|
||||||
MTR attributes for mapping physical memory (Intel Architecture only)
|
|
||||||
----- */
|
|
||||||
|
|
||||||
#define B_MTR_UC 0x10000000
|
#define B_MTR_UC 0x10000000
|
||||||
#define B_MTR_WC 0x20000000
|
#define B_MTR_WC 0x20000000
|
||||||
#define B_MTR_WT 0x30000000
|
#define B_MTR_WT 0x30000000
|
||||||
@@ -179,82 +141,72 @@ extern _IMPEXP_KERNEL long get_memory_map (
|
|||||||
#define B_MTR_WB 0x50000000
|
#define B_MTR_WB 0x50000000
|
||||||
#define B_MTR_MASK 0xf0000000
|
#define B_MTR_MASK 0xf0000000
|
||||||
|
|
||||||
/* -----
|
|
||||||
call to map physical memory - typically used for memory-mapped i/o
|
|
||||||
----- */
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL area_id map_physical_memory (
|
/*-------------------------------------------------------------*/
|
||||||
const char *area_name,
|
/* hardware inquiry */
|
||||||
void *physical_address,
|
|
||||||
size_t size,
|
|
||||||
uint32 flags,
|
|
||||||
uint32 protection,
|
|
||||||
void **mapped_address
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* -----
|
|
||||||
hardware inquiry
|
|
||||||
----- */
|
|
||||||
|
|
||||||
/* platform_type return value is defined in OS.h */
|
/* platform_type return value is defined in OS.h */
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL platform_type platform();
|
extern platform_type platform();
|
||||||
|
|
||||||
#if __POWERPC__
|
#if __POWERPC__
|
||||||
extern _IMPEXP_KERNEL long motherboard_version (void);
|
extern long motherboard_version(void);
|
||||||
extern _IMPEXP_KERNEL long io_card_version (void);
|
extern long io_card_version(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------*/
|
||||||
|
/* primitive kernel debugging facilities */
|
||||||
|
|
||||||
/* ---
|
/* Standard debug output is on...
|
||||||
primitive kernel debugging facilities. Debug output is on...
|
* mac: modem port
|
||||||
|
* pc: com1
|
||||||
bebox: serial port 4
|
* ...at 19.2 kbaud, no parity, 8 bit, 1 stop bit.
|
||||||
mac: modem port
|
*
|
||||||
pc: com1
|
* Note: the kernel settings file can override these defaults
|
||||||
|
*/
|
||||||
...at 19.2 kbaud, no parity, 8 bit, 1 stop bit.
|
|
||||||
--- */
|
|
||||||
|
|
||||||
#if __GNUC__
|
#if __GNUC__
|
||||||
extern _IMPEXP_KERNEL void dprintf (const char *format, ...) /* just like printf */
|
extern void dprintf(const char *format, ...) /* just like printf */
|
||||||
__attribute__ ((format (__printf__, 1, 2)));
|
__attribute__ ((format (__printf__, 1, 2)));
|
||||||
extern _IMPEXP_KERNEL void kprintf (const char *fmt, ...) /* only for debugger cmds */
|
extern void kprintf(const char *fmt, ...) /* only for debugger cmds */
|
||||||
__attribute__ ((format (__printf__, 1, 2)));
|
__attribute__ ((format (__printf__, 1, 2)));
|
||||||
#else
|
#else
|
||||||
extern _IMPEXP_KERNEL void dprintf (const char *format, ...); /* just like printf */
|
extern void dprintf(const char *format, ...); /* just like printf */
|
||||||
extern _IMPEXP_KERNEL void kprintf (const char *fmt, ...); /* only for debugger cmds */
|
extern void kprintf(const char *fmt, ...); /* only for debugger cmds */
|
||||||
#endif
|
#endif
|
||||||
extern _IMPEXP_KERNEL bool set_dprintf_enabled (bool new_state); /* returns old state */
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL void panic(const char *format, ...);
|
extern bool set_dprintf_enabled(bool new_state); /* returns old state */
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL void kernel_debugger (const char *message); /* enter kernel debugger */
|
extern void panic(const char *format, ...);
|
||||||
extern _IMPEXP_KERNEL ulong parse_expression (char *str); /* util for debugger cmds */
|
|
||||||
|
extern void kernel_debugger(const char *message); /* enter kernel debugger */
|
||||||
|
extern ulong parse_expression(char *str); /* utility for debugger cmds */
|
||||||
|
|
||||||
/* special return codes for kernel debugger */
|
/* special return codes for kernel debugger */
|
||||||
#define B_KDEBUG_CONT 2
|
#define B_KDEBUG_CONT 2
|
||||||
#define B_KDEBUG_QUIT 3
|
#define B_KDEBUG_QUIT 3
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL int add_debugger_command (char *name, /* add a cmd to debugger */
|
typedef int (*debugger_command_hook)(int argc, char **argv);
|
||||||
int (*func)(int argc, char **argv),
|
|
||||||
char *help);
|
|
||||||
extern _IMPEXP_KERNEL int remove_debugger_command (char *name, /* remove a cmd from debugger */
|
|
||||||
int (*func)(int argc, char **argv));
|
|
||||||
|
|
||||||
/* -----
|
extern int add_debugger_command(char *name, debugger_command_hook hook, char *help);
|
||||||
misc
|
extern int remove_debugger_command(char *name, debugger_command_hook hook);
|
||||||
----- */
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL void spin (bigtime_t num_microseconds);
|
|
||||||
extern _IMPEXP_KERNEL int register_kernel_daemon(void (*func)(void *, int), void *arg, int freq);
|
|
||||||
extern _IMPEXP_KERNEL int unregister_kernel_daemon(void (*func)(void *, int), void *arg);
|
|
||||||
extern _IMPEXP_KERNEL void call_all_cpus(void (*f)(void*, int), void* cookie);
|
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL int load_driver_symbols(const char *driver_name);
|
/*-------------------------------------------------------------*/
|
||||||
|
/* misc */
|
||||||
|
|
||||||
|
extern void spin(bigtime_t microseconds);
|
||||||
|
/* does a busy delay loop for at least "microseconds" */
|
||||||
|
|
||||||
|
typedef int (*daemon_hook)(void *arg, int iteration);
|
||||||
|
|
||||||
|
extern status_t register_kernel_daemon(daemon_hook hook, void *arg, int frequency);
|
||||||
|
extern status_t unregister_kernel_daemon(daemon_hook hook, void *arg);
|
||||||
|
|
||||||
|
extern void call_all_cpus(void (*f)(void *, int), void *cookie);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* _KERNEL_EXPORT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user