*LOTS* of small changes to make the kernel compatible with Be's KernelExport.h
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1683 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -38,7 +38,7 @@ extern _IMPEXP_KERNEL thread_id spawn_kernel_thread (
|
|||||||
|
|
||||||
typedef ulong cpu_status;
|
typedef ulong cpu_status;
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL cpu_status disable_interrupts();
|
extern _IMPEXP_KERNEL cpu_status disable_interrupts(void);
|
||||||
extern _IMPEXP_KERNEL void restore_interrupts(cpu_status status);
|
extern _IMPEXP_KERNEL void restore_interrupts(cpu_status status);
|
||||||
|
|
||||||
|
|
||||||
@@ -85,10 +85,19 @@ typedef struct timer timer;
|
|||||||
typedef struct qent qent;
|
typedef struct qent qent;
|
||||||
typedef int32 (*timer_hook)(timer *);
|
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
|
||||||
|
* 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
|
||||||
|
* the list.
|
||||||
|
* 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...
|
||||||
|
*/
|
||||||
struct qent {
|
struct qent {
|
||||||
int64 key;
|
int64 key; /* We use this as the sched time */
|
||||||
qent *next;
|
qent *next; /* This is used as a pointer to next timer */
|
||||||
qent *prev;
|
qent *prev; /* This can be used for callback args */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct timer {
|
struct timer {
|
||||||
@@ -111,6 +120,7 @@ bool cancel_timer(timer *t);
|
|||||||
--- */
|
--- */
|
||||||
|
|
||||||
extern _IMPEXP_KERNEL int send_signal_etc(pid_t thid, uint sig, uint32 flags);
|
extern _IMPEXP_KERNEL int send_signal_etc(pid_t thid, uint sig, uint32 flags);
|
||||||
|
extern _IMPEXP_KERNEL int has_signals_pending(void *thr);
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
/* ---
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ extern "C" {
|
|||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
#include <arch/thread_struct.h>
|
#include <arch/thread_struct.h>
|
||||||
|
|
||||||
extern spinlock_t thread_spinlock;
|
extern spinlock thread_spinlock;
|
||||||
#define GRAB_THREAD_LOCK() acquire_spinlock(&thread_spinlock)
|
#define GRAB_THREAD_LOCK() acquire_spinlock(&thread_spinlock)
|
||||||
#define RELEASE_THREAD_LOCK() release_spinlock(&thread_spinlock)
|
#define RELEASE_THREAD_LOCK() release_spinlock(&thread_spinlock)
|
||||||
|
|
||||||
extern struct thread_queue dead_q;
|
extern struct thread_queue dead_q;
|
||||||
|
|
||||||
extern spinlock_t team_spinlock;
|
extern spinlock team_spinlock;
|
||||||
// NOTE: TEAM lock can be held over a THREAD lock acquisition,
|
// NOTE: TEAM lock can be held over a THREAD lock acquisition,
|
||||||
// but not the other way (to avoid deadlock)
|
// but not the other way (to avoid deadlock)
|
||||||
#define GRAB_TEAM_LOCK() acquire_spinlock(&team_spinlock)
|
#define GRAB_TEAM_LOCK() acquire_spinlock(&team_spinlock)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <cdefs.h>
|
#include <cdefs.h>
|
||||||
|
|
||||||
int con_init(kernel_args *ka);
|
int con_init(kernel_args *ka);
|
||||||
int kprintf(const char *fmt, ...) __PRINTFLIKE(1,2);
|
void kprintf(const char *fmt, ...) __PRINTFLIKE(1,2);
|
||||||
int kprintf_xy(int x, int y, const char *fmt, ...) __PRINTFLIKE(3,4);
|
void kprintf_xy(int x, int y, const char *fmt, ...) __PRINTFLIKE(3,4);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,17 +17,11 @@ char dbg_putch(char c);
|
|||||||
void dbg_puts(const char *s);
|
void dbg_puts(const char *s);
|
||||||
bool dbg_set_serial_debug(bool new_val);
|
bool dbg_set_serial_debug(bool new_val);
|
||||||
bool dbg_get_serial_debug(void);
|
bool dbg_get_serial_debug(void);
|
||||||
int dprintf(const char *fmt, ...) __PRINTFLIKE(1,2);
|
|
||||||
int panic(const char *fmt, ...) __PRINTFLIKE(1,2);
|
|
||||||
void kernel_debugger(const char *);
|
|
||||||
|
|
||||||
/* special return codes for kernel debugger command function*/
|
/* special return codes for kernel debugger command function*/
|
||||||
#define B_KDEBUG_CONT 2
|
#define B_KDEBUG_CONT 2
|
||||||
#define B_KDEBUG_QUIT 3
|
#define B_KDEBUG_QUIT 3
|
||||||
|
|
||||||
int add_debugger_command(const char * name, int (*func)(int, char **), const char *desc);
|
|
||||||
int remove_debugger_command(const char * name, int (*func)(int, char **));
|
|
||||||
|
|
||||||
extern void dbg_save_registers(int *); /* arch provided */
|
extern void dbg_save_registers(int *); /* arch provided */
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <stage2.h>
|
#include <stage2.h>
|
||||||
#include <arch/int.h>
|
#include <arch/int.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup kernelint Interrupts
|
* @defgroup kernelint Interrupts
|
||||||
@@ -35,17 +36,13 @@
|
|||||||
*/
|
*/
|
||||||
#define B_NO_ENABLE_COUNTER 1
|
#define B_NO_ENABLE_COUNTER 1
|
||||||
|
|
||||||
typedef int32 (*interrupt_handler) (void *data);
|
|
||||||
|
|
||||||
int int_init(kernel_args *ka);
|
int int_init(kernel_args *ka);
|
||||||
int int_init2(kernel_args *ka);
|
int int_init2(kernel_args *ka);
|
||||||
int int_io_interrupt_handler(int vector);
|
int int_io_interrupt_handler(int vector);
|
||||||
long install_interrupt_handler(long, interrupt_handler, void *);
|
long install_interrupt_handler(long, interrupt_handler, void *);
|
||||||
long remove_interrupt_handler (long, interrupt_handler, void *);
|
long remove_interrupt_handler (long, interrupt_handler, void *);
|
||||||
|
|
||||||
#define enable_interrupts arch_int_enable_interrupts
|
#define enable_interrupts arch_int_enable_interrupts
|
||||||
#define disable_interrupts arch_int_disable_interrupts
|
|
||||||
#define restore_interrupts arch_int_restore_interrupts
|
|
||||||
#define are_interrupts_enabled arch_int_is_interrupts_enabled
|
#define are_interrupts_enabled arch_int_is_interrupts_enabled
|
||||||
|
|
||||||
/** @fn long install_io_interrupt_handler(long interrupt, interrupt_handler handler, void *data, ulong flags);
|
/** @fn long install_io_interrupt_handler(long interrupt, interrupt_handler handler, void *data, ulong flags);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define _KERNEL_SMP_H
|
#define _KERNEL_SMP_H
|
||||||
|
|
||||||
#include <stage2.h>
|
#include <stage2.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
// intercpu messages
|
// intercpu messages
|
||||||
enum {
|
enum {
|
||||||
@@ -35,10 +36,5 @@ int smp_get_num_cpus(void);
|
|||||||
void smp_set_num_cpus(int num_cpus);
|
void smp_set_num_cpus(int num_cpus);
|
||||||
int smp_get_current_cpu(void);
|
int smp_get_current_cpu(void);
|
||||||
|
|
||||||
// spinlock functions
|
|
||||||
typedef volatile int spinlock_t;
|
|
||||||
void acquire_spinlock(spinlock_t *lock);
|
|
||||||
void release_spinlock(spinlock_t *lock);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stage2.h>
|
#include <stage2.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup Timer Timer structures (not architecture specific)
|
* @defgroup Timer Timer structures (not architecture specific)
|
||||||
@@ -18,66 +19,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
typedef struct timer timer;
|
|
||||||
typedef struct qent qent;
|
|
||||||
typedef int32 (*timer_hook)(timer *);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qent structure
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* 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
|
|
||||||
* the list.
|
|
||||||
* 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...
|
|
||||||
*/
|
|
||||||
struct qent {
|
|
||||||
int64 key; /* We use this as the sched time */
|
|
||||||
qent *next; /* This is used as a pointer to next timer */
|
|
||||||
qent *prev; /* This can be used for callback args */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timer event data structure
|
|
||||||
*/
|
|
||||||
struct timer {
|
|
||||||
/** qent entry for this timer event */
|
|
||||||
qent entry;
|
|
||||||
/** This just holds the timer operating mode (relative/absolute/periodic) */
|
|
||||||
uint16 flags;
|
|
||||||
/** Number of the CPU associated to this timer event */
|
|
||||||
uint16 cpu;
|
|
||||||
/** Hook function to be called on timer expiration */
|
|
||||||
timer_hook hook;
|
|
||||||
/** Expiration time in microseconds */
|
|
||||||
bigtime_t period;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @defgroup timermodes Timer operating modes
|
|
||||||
* @ingroup Timer
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** @def B_ONE_SHOT_ABSOLUTE_TIMER the timer will fire once at the system
|
|
||||||
* time specified by period
|
|
||||||
*/
|
|
||||||
/** @def B_ONE_SHOT_RELATIVE_TIMER the timer will fire once in approximately
|
|
||||||
* period microseconds
|
|
||||||
*/
|
|
||||||
/** @def B_PERIODIC_TIMER the timer will fire every period microseconds,
|
|
||||||
* starting in period microseconds
|
|
||||||
*/
|
|
||||||
#define B_ONE_SHOT_ABSOLUTE_TIMER 1
|
|
||||||
#define B_ONE_SHOT_RELATIVE_TIMER 2
|
|
||||||
#define B_PERIODIC_TIMER 3
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
status_t add_timer(timer *event, timer_hook hook, bigtime_t period, int32 flags);
|
|
||||||
bool cancel_timer(timer *event);
|
|
||||||
void spin(bigtime_t microseconds);
|
|
||||||
|
|
||||||
/** kernel functions */
|
/** kernel functions */
|
||||||
int timer_init(kernel_args *);
|
int timer_init(kernel_args *);
|
||||||
int timer_interrupt(void);
|
int timer_interrupt(void);
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int parse_expression(scan_info *info,shell_value **out)
|
static int parse_expr(scan_info *info,shell_value **out)
|
||||||
{
|
{
|
||||||
(*out) = NULL;
|
(*out) = NULL;
|
||||||
return parse_oper(info,out,MAX_LEVEL);
|
return parse_oper(info,out,MAX_LEVEL);
|
||||||
@@ -288,7 +288,7 @@ static int handle_exit(scan_info *info)
|
|||||||
|
|
||||||
if(scan(info)) return SHE_SCAN_ERROR;
|
if(scan(info)) return SHE_SCAN_ERROR;
|
||||||
|
|
||||||
err = parse_expression(info,&expr);
|
err = parse_expr(info,&expr);
|
||||||
if(err != SHE_NO_ERROR) return err;
|
if(err != SHE_NO_ERROR) return err;
|
||||||
|
|
||||||
if(!(expr->isnumber)){
|
if(!(expr->isnumber)){
|
||||||
@@ -322,7 +322,7 @@ static int parse_rvl_expr(scan_info *info,shell_value **out)
|
|||||||
|
|
||||||
if(expect(info,SVO_PARENL)) return SVO_PARENL;
|
if(expect(info,SVO_PARENL)) return SVO_PARENL;
|
||||||
|
|
||||||
err = parse_expression(info,out);
|
err = parse_expr(info,out);
|
||||||
|
|
||||||
if(err != SHE_NO_ERROR) return err;
|
if(err != SHE_NO_ERROR) return err;
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ static int handle_load(scan_info *info)
|
|||||||
|
|
||||||
if(expect(info,SVO_LOAD)) return SVO_LOAD;
|
if(expect(info,SVO_LOAD)) return SVO_LOAD;
|
||||||
|
|
||||||
err = parse_expression(info,&value);
|
err = parse_expr(info,&value);
|
||||||
if(err != SHE_NO_ERROR) return err;
|
if(err != SHE_NO_ERROR) return err;
|
||||||
|
|
||||||
set_shell_var_with_value(var_name,value);
|
set_shell_var_with_value(var_name,value);
|
||||||
@@ -446,7 +446,7 @@ static int handle_echo(scan_info *info)
|
|||||||
|
|
||||||
while(info->sym_code != SVO_END){
|
while(info->sym_code != SVO_END){
|
||||||
|
|
||||||
err = parse_expression(info,&value);
|
err = parse_expr(info,&value);
|
||||||
|
|
||||||
if(err != SHE_NO_ERROR) return err;
|
if(err != SHE_NO_ERROR) return err;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <bus.h>
|
#include <bus.h>
|
||||||
#include <config_manager.h>
|
#include <config_manager.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
|
|
||||||
int bus_init(kernel_args *ka)
|
int bus_init(kernel_args *ka)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memheap.h>
|
#include <memheap.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
static pci_module_info *pcim = NULL;
|
static pci_module_info *pcim = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <ISA.h>
|
#include <ISA.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
static status_t isa_rescan(void)
|
static status_t isa_rescan(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ enum {
|
|||||||
static struct pci_device *pci_devices = NULL;
|
static struct pci_device *pci_devices = NULL;
|
||||||
static struct pci_bus *pci_busses = NULL;
|
static struct pci_bus *pci_busses = NULL;
|
||||||
|
|
||||||
static spinlock_t pci_config_lock = 0; /* lock for config space access */
|
static spinlock pci_config_lock = 0; /* lock for config space access */
|
||||||
static int pci_mode = 1; /* The pci config mechanism we're using.
|
static int pci_mode = 1; /* The pci config mechanism we're using.
|
||||||
* NB defaults to 1 as this is more common, but
|
* NB defaults to 1 as this is more common, but
|
||||||
* checked at runtime
|
* checked at runtime
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void i386_selector_init( void *gdt )
|
|||||||
// 0 on error
|
// 0 on error
|
||||||
selector_id i386_selector_add( selector_type type )
|
selector_id i386_selector_add( selector_type type )
|
||||||
{
|
{
|
||||||
static int spinlock;
|
static spinlock spinlock;
|
||||||
int state;
|
int state;
|
||||||
uint32 mask;
|
uint32 mask;
|
||||||
selector_id id = 0;
|
selector_id id = 0;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <arch/vm.h>
|
#include <arch/vm.h>
|
||||||
#include <arch/int.h>
|
#include <arch/int.h>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ static pdentry *kernel_pgdir_phys = NULL;
|
|||||||
static pdentry *kernel_pgdir_virt = NULL;
|
static pdentry *kernel_pgdir_virt = NULL;
|
||||||
|
|
||||||
static vm_translation_map *tmap_list;
|
static vm_translation_map *tmap_list;
|
||||||
static spinlock_t tmap_list_lock;
|
static spinlock tmap_list_lock;
|
||||||
|
|
||||||
#define CHATTY_TMAP 0
|
#define CHATTY_TMAP 0
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
static cbuf *cbuf_free_list;
|
static cbuf *cbuf_free_list;
|
||||||
static sem_id free_list_sem;
|
static sem_id free_list_sem;
|
||||||
static cbuf *cbuf_free_noblock_list;
|
static cbuf *cbuf_free_noblock_list;
|
||||||
static spinlock_t noblock_spin;
|
static spinlock noblock_spin;
|
||||||
|
|
||||||
static spinlock_t cbuf_lowlevel_spinlock;
|
static spinlock cbuf_lowlevel_spinlock;
|
||||||
static region_id cbuf_region_id;
|
static region_id cbuf_region_id;
|
||||||
static cbuf *cbuf_region;
|
static cbuf *cbuf_region;
|
||||||
static region_id cbuf_bitmap_region_id;
|
static region_id cbuf_bitmap_region_id;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct console_op_xy_struct {
|
|||||||
static int console_fd = -1;
|
static int console_fd = -1;
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
kprintf(const char *fmt, ...)
|
kprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -45,11 +45,10 @@ kprintf(const char *fmt, ...)
|
|||||||
|
|
||||||
sys_write(console_fd, 0, temp, ret);
|
sys_write(console_fd, 0, temp, ret);
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
kprintf_xy(int x, int y, const char *fmt, ...)
|
kprintf_xy(int x, int y, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -65,7 +64,6 @@ kprintf_xy(int x, int y, const char *fmt, ...)
|
|||||||
buf.y = y;
|
buf.y = y;
|
||||||
sys_ioctl(console_fd, CONSOLE_OP_WRITEXY, &buf, ret + sizeof(buf.x) + sizeof(buf.y));
|
sys_ioctl(console_fd, CONSOLE_OP_WRITEXY, &buf, ret + sizeof(buf.x) + sizeof(buf.y));
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ int dbg_register_file[2][14]; /* XXXmpetit -- must be made generic */
|
|||||||
|
|
||||||
|
|
||||||
static bool serial_debug_on = false;
|
static bool serial_debug_on = false;
|
||||||
static spinlock_t dbg_spinlock = 0;
|
static spinlock dbg_spinlock = 0;
|
||||||
static int debugger_on_cpu = -1;
|
static int debugger_on_cpu = -1;
|
||||||
|
|
||||||
struct debugger_command
|
struct debugger_command
|
||||||
@@ -250,7 +250,7 @@ kernel_debugger(const char * message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
panic(const char *fmt, ...)
|
panic(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -279,25 +279,22 @@ panic(const char *fmt, ...)
|
|||||||
kernel_debugger(NULL);
|
kernel_debugger(NULL);
|
||||||
|
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
dprintf(const char *fmt, ...)
|
dprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char temp[512];
|
char temp[512];
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (serial_debug_on) {
|
if (serial_debug_on) {
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
ret = vsprintf(temp, fmt, args);
|
vsprintf(temp, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
dbg_puts(temp);
|
dbg_puts(temp);
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -335,7 +332,7 @@ dbg_puts(const char *s)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
add_debugger_command(const char *name, int (*func)(int, char **), const char *desc)
|
add_debugger_command(char *name, int (*func)(int, char **), char *desc)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
struct debugger_command *cmd;
|
struct debugger_command *cmd;
|
||||||
@@ -362,7 +359,7 @@ add_debugger_command(const char *name, int (*func)(int, char **), const char *de
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
remove_debugger_command(const char * name, int (*func)(int, char **))
|
remove_debugger_command(char * name, int (*func)(int, char **))
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
struct debugger_command *cmd;
|
struct debugger_command *cmd;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <bootdir.h>
|
#include <bootdir.h>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
#include <devfs.h>
|
#include <devfs.h>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
** Distributed under the terms of the NewOS License.
|
** Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <KernelExport.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <lock.h>
|
#include <lock.h>
|
||||||
|
|||||||
+15
-1
@@ -25,12 +25,26 @@ struct io_handler {
|
|||||||
|
|
||||||
struct io_vector {
|
struct io_vector {
|
||||||
struct io_handler handler_list;
|
struct io_handler handler_list;
|
||||||
spinlock_t vector_lock;
|
spinlock vector_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct io_vector *io_vectors = NULL;
|
static struct io_vector *io_vectors = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
cpu_status
|
||||||
|
disable_interrupts()
|
||||||
|
{
|
||||||
|
return arch_int_disable_interrupts();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
restore_interrupts(cpu_status status)
|
||||||
|
{
|
||||||
|
arch_int_restore_interrupts(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
int_init(kernel_args *ka)
|
int_init(kernel_args *ka)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
/* XXX - add documentation to this file! */
|
/* XXX - add documentation to this file! */
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
#include <pools.h>
|
#include <pools.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <memheap.h>
|
#include <memheap.h>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct port_entry {
|
|||||||
port_id id;
|
port_id id;
|
||||||
team_id owner;
|
team_id owner;
|
||||||
int32 capacity;
|
int32 capacity;
|
||||||
int lock;
|
spinlock lock;
|
||||||
char *name;
|
char *name;
|
||||||
sem_id read_sem;
|
sem_id read_sem;
|
||||||
sem_id write_sem;
|
sem_id write_sem;
|
||||||
@@ -57,7 +57,7 @@ static bool ports_active = false;
|
|||||||
|
|
||||||
static port_id next_port = 0;
|
static port_id next_port = 0;
|
||||||
|
|
||||||
static int port_spinlock = 0;
|
static spinlock port_spinlock = 0;
|
||||||
#define GRAB_PORT_LIST_LOCK() acquire_spinlock(&port_spinlock)
|
#define GRAB_PORT_LIST_LOCK() acquire_spinlock(&port_spinlock)
|
||||||
#define RELEASE_PORT_LIST_LOCK() release_spinlock(&port_spinlock)
|
#define RELEASE_PORT_LIST_LOCK() release_spinlock(&port_spinlock)
|
||||||
#define GRAB_PORT_LOCK(s) acquire_spinlock(&(s).lock)
|
#define GRAB_PORT_LOCK(s) acquire_spinlock(&(s).lock)
|
||||||
|
|||||||
@@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
|
|
||||||
struct sem_entry {
|
struct sem_entry {
|
||||||
sem_id id;
|
sem_id id;
|
||||||
int count;
|
int count;
|
||||||
struct thread_queue q;
|
struct thread_queue q;
|
||||||
char *name;
|
char *name;
|
||||||
int lock;
|
spinlock lock;
|
||||||
team_id owner; // if set to -1, means owned by a port
|
team_id owner; // if set to -1, means owned by a port
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_SEMS 4096
|
#define MAX_SEMS 4096
|
||||||
@@ -48,7 +48,7 @@ static region_id gSemRegion = 0;
|
|||||||
static bool gSemsActive = false;
|
static bool gSemsActive = false;
|
||||||
static sem_id gNextSemID = 0;
|
static sem_id gNextSemID = 0;
|
||||||
|
|
||||||
static int sem_spinlock = 0;
|
static spinlock sem_spinlock = 0;
|
||||||
#define GRAB_SEM_LIST_LOCK() acquire_spinlock(&sem_spinlock)
|
#define GRAB_SEM_LIST_LOCK() acquire_spinlock(&sem_spinlock)
|
||||||
#define RELEASE_SEM_LIST_LOCK() release_spinlock(&sem_spinlock)
|
#define RELEASE_SEM_LIST_LOCK() release_spinlock(&sem_spinlock)
|
||||||
#define GRAB_SEM_LOCK(s) acquire_spinlock(&(s).lock)
|
#define GRAB_SEM_LOCK(s) acquire_spinlock(&(s).lock)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
@@ -177,8 +178,9 @@ send_signal_etc(pid_t tid, uint sig, uint32 flags)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
has_signals_pending(struct thread *t)
|
has_signals_pending(void *thr)
|
||||||
{
|
{
|
||||||
|
struct thread *t = (struct thread *)thr;
|
||||||
if (!t)
|
if (!t)
|
||||||
t = thread_get_current_thread();
|
t = thread_get_current_thread();
|
||||||
return (t->sig_pending & ~t->sig_block_mask);
|
return (t->sig_pending & ~t->sig_block_mask);
|
||||||
|
|||||||
@@ -42,17 +42,17 @@ struct smp_msg {
|
|||||||
#define MAILBOX_LOCAL 1
|
#define MAILBOX_LOCAL 1
|
||||||
#define MAILBOX_BCAST 2
|
#define MAILBOX_BCAST 2
|
||||||
|
|
||||||
static spinlock_t boot_cpu_spin[SMP_MAX_CPUS] = { 0, };
|
static spinlock boot_cpu_spin[SMP_MAX_CPUS] = { 0, };
|
||||||
|
|
||||||
static struct smp_msg *free_msgs = NULL;
|
static struct smp_msg *free_msgs = NULL;
|
||||||
static volatile int free_msg_count = 0;
|
static volatile int free_msg_count = 0;
|
||||||
static spinlock_t free_msg_spinlock = 0;
|
static spinlock free_msg_spinlock = 0;
|
||||||
|
|
||||||
static struct smp_msg *smp_msgs[SMP_MAX_CPUS] = { NULL, };
|
static struct smp_msg *smp_msgs[SMP_MAX_CPUS] = { NULL, };
|
||||||
static spinlock_t cpu_msg_spinlock[SMP_MAX_CPUS] = { 0, };
|
static spinlock cpu_msg_spinlock[SMP_MAX_CPUS] = { 0, };
|
||||||
|
|
||||||
static struct smp_msg *smp_broadcast_msgs = NULL;
|
static struct smp_msg *smp_broadcast_msgs = NULL;
|
||||||
static spinlock_t broadcast_msg_spinlock = 0;
|
static spinlock broadcast_msg_spinlock = 0;
|
||||||
|
|
||||||
static bool ici_enabled = false;
|
static bool ici_enabled = false;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ static int smp_num_cpus = 1;
|
|||||||
static int smp_process_pending_ici(int curr_cpu);
|
static int smp_process_pending_ici(int curr_cpu);
|
||||||
|
|
||||||
void
|
void
|
||||||
acquire_spinlock(spinlock_t *lock)
|
acquire_spinlock(spinlock *lock)
|
||||||
{
|
{
|
||||||
if (smp_num_cpus > 1) {
|
if (smp_num_cpus > 1) {
|
||||||
int curr_cpu = smp_get_current_cpu();
|
int curr_cpu = smp_get_current_cpu();
|
||||||
@@ -78,7 +78,7 @@ acquire_spinlock(spinlock_t *lock)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
acquire_spinlock_nocheck(spinlock_t *lock)
|
acquire_spinlock_nocheck(spinlock *lock)
|
||||||
{
|
{
|
||||||
if (smp_num_cpus > 1) {
|
if (smp_num_cpus > 1) {
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -92,7 +92,7 @@ acquire_spinlock_nocheck(spinlock_t *lock)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
release_spinlock(spinlock_t *lock)
|
release_spinlock(spinlock *lock)
|
||||||
{
|
{
|
||||||
*lock = 0;
|
*lock = 0;
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ smp_finish_message_processing(int curr_cpu, struct smp_msg *msg, int source_mail
|
|||||||
// we were the last one to decrement the ref_count
|
// we were the last one to decrement the ref_count
|
||||||
// it's our job to remove it from the list & possibly clean it up
|
// it's our job to remove it from the list & possibly clean it up
|
||||||
struct smp_msg **mbox = NULL;
|
struct smp_msg **mbox = NULL;
|
||||||
spinlock_t *spinlock = NULL;
|
spinlock *spinlock = NULL;
|
||||||
|
|
||||||
// clean up the message from one of the mailboxes
|
// clean up the message from one of the mailboxes
|
||||||
switch(source_mailbox) {
|
switch(source_mailbox) {
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re
|
|||||||
*call_ret = user_sigaction((int)arg0, (const struct sigaction *)arg1, (struct sigaction *)arg2);
|
*call_ret = user_sigaction((int)arg0, (const struct sigaction *)arg1, (struct sigaction *)arg2);
|
||||||
break;
|
break;
|
||||||
case SYSCALL_SEND_SIGNAL:
|
case SYSCALL_SEND_SIGNAL:
|
||||||
*call_ret = send_signal_etc((pid_t)arg0, (uint)arg1);
|
*call_ret = send_signal_etc((pid_t)arg0, (uint)arg1, B_DO_NOT_RESCHEDULE);
|
||||||
break;
|
break;
|
||||||
case SYSCALL_SET_ALARM:
|
case SYSCALL_SET_ALARM:
|
||||||
*call_ret = sys_set_alarm((bigtime_t)INT32TOINT64(arg0, arg1), (uint32)arg2);
|
*call_ret = sys_set_alarm((bigtime_t)INT32TOINT64(arg0, arg1), (uint32)arg2);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <memheap.h>
|
#include <memheap.h>
|
||||||
#include <sysctl.h>
|
#include <sysctl.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
|
|
||||||
/* Not sure where to put this definition yet (sys/param.h?),
|
/* Not sure where to put this definition yet (sys/param.h?),
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static void *team_hash = NULL;
|
|||||||
static team_id next_team_id = 1;
|
static team_id next_team_id = 1;
|
||||||
static struct team *kernel_team = NULL;
|
static struct team *kernel_team = NULL;
|
||||||
|
|
||||||
spinlock_t team_spinlock = 0;
|
spinlock team_spinlock = 0;
|
||||||
|
|
||||||
static struct team *create_team_struct(const char *name, bool kernel);
|
static struct team *create_team_struct(const char *name, bool kernel);
|
||||||
static void delete_team_struct(struct team *p);
|
static void delete_team_struct(struct team *p);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ struct thread_key {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// global
|
// global
|
||||||
spinlock_t thread_spinlock = 0;
|
spinlock thread_spinlock = 0;
|
||||||
|
|
||||||
// thread list
|
// thread list
|
||||||
static struct thread *idle_threads[MAX_BOOT_CPUS];
|
static struct thread *idle_threads[MAX_BOOT_CPUS];
|
||||||
@@ -1085,15 +1085,9 @@ void
|
|||||||
sys_exit_thread(status_t return_value)
|
sys_exit_thread(status_t return_value)
|
||||||
{
|
{
|
||||||
struct thread *t = thread_get_current_thread();
|
struct thread *t = thread_get_current_thread();
|
||||||
int state;
|
|
||||||
|
|
||||||
state = disable_interrupts();
|
|
||||||
GRAB_THREAD_LOCK();
|
|
||||||
t->return_code = return_value;
|
t->return_code = return_value;
|
||||||
t->return_flags = THREAD_RETURN_EXIT;
|
t->return_flags = THREAD_RETURN_EXIT;
|
||||||
RELEASE_THREAD_LOCK();
|
|
||||||
restore_interrupts(state);
|
|
||||||
|
|
||||||
send_signal_etc(t->id, SIGKILLTHR, B_DO_NOT_RESCHEDULE);
|
send_signal_etc(t->id, SIGKILLTHR, B_DO_NOT_RESCHEDULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include <arch/smp.h>
|
#include <arch/smp.h>
|
||||||
|
|
||||||
static timer * volatile events[SMP_MAX_CPUS] = { NULL, };
|
static timer * volatile events[SMP_MAX_CPUS] = { NULL, };
|
||||||
static spinlock_t timer_spinlock[SMP_MAX_CPUS] = { 0, };
|
static spinlock timer_spinlock[SMP_MAX_CPUS] = { 0, };
|
||||||
|
|
||||||
int timer_init(kernel_args *ka)
|
int timer_init(kernel_args *ka)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ int timer_interrupt()
|
|||||||
{
|
{
|
||||||
bigtime_t sched_time;
|
bigtime_t sched_time;
|
||||||
timer *event;
|
timer *event;
|
||||||
spinlock_t *spinlock;
|
spinlock *spinlock;
|
||||||
int curr_cpu = smp_get_current_cpu();
|
int curr_cpu = smp_get_current_cpu();
|
||||||
int rc = B_HANDLED_INTERRUPT;
|
int rc = B_HANDLED_INTERRUPT;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ static void *aspace_table;
|
|||||||
static sem_id aspace_hash_sem;
|
static sem_id aspace_hash_sem;
|
||||||
|
|
||||||
static int max_commit;
|
static int max_commit;
|
||||||
static spinlock_t max_commit_lock;
|
static spinlock max_commit_lock;
|
||||||
|
|
||||||
// function declarations
|
// function declarations
|
||||||
static vm_region *_vm_create_region_struct(vm_address_space *aspace, const char *name, int wiring, int lock);
|
static vm_region *_vm_create_region_struct(vm_address_space *aspace, const char *name, int wiring, int lock);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
/* hash table of pages keyed by cache they're in and offset */
|
/* hash table of pages keyed by cache they're in and offset */
|
||||||
#define PAGE_TABLE_SIZE 1024 /* make this dynamic */
|
#define PAGE_TABLE_SIZE 1024 /* make this dynamic */
|
||||||
static void *page_cache_table;
|
static void *page_cache_table;
|
||||||
static spinlock_t page_cache_table_lock;
|
static spinlock page_cache_table_lock;
|
||||||
|
|
||||||
struct page_lookup_key {
|
struct page_lookup_key {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static vm_page *all_pages;
|
|||||||
static addr physical_page_offset;
|
static addr physical_page_offset;
|
||||||
static unsigned int num_pages;
|
static unsigned int num_pages;
|
||||||
|
|
||||||
static spinlock_t page_lock;
|
static spinlock page_lock;
|
||||||
|
|
||||||
static sem_id modified_pages_available;
|
static sem_id modified_pages_available;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <vm_store_anonymous_noswap.h>
|
#include <vm_store_anonymous_noswap.h>
|
||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
static void anonymous_destroy(struct vm_store *store)
|
static void anonymous_destroy(struct vm_store *store)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <vm_store_device.h>
|
#include <vm_store_device.h>
|
||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
struct device_store_data {
|
struct device_store_data {
|
||||||
addr base_addr;
|
addr base_addr;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user