Moved the kernel_startup variable declaration from int.h to kernel.h (it's defined in main.c).
Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12327 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,22 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2003-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
#ifndef _KERNEL_INT_H
|
#ifndef _KERNEL_INT_H
|
||||||
#define _KERNEL_INT_H
|
#define _KERNEL_INT_H
|
||||||
|
|
||||||
#include <KernelExport.h>
|
|
||||||
|
|
||||||
|
#include <KernelExport.h>
|
||||||
#include <arch/int.h>
|
#include <arch/int.h>
|
||||||
|
|
||||||
struct kernel_args;
|
struct kernel_args;
|
||||||
|
|
||||||
|
|
||||||
/* adds the handler but don't change whether or not the interrupt is currently enabled */
|
/* adds the handler but don't change whether or not the interrupt is currently enabled */
|
||||||
#define B_NO_ENABLE_COUNTER 1
|
#define B_NO_ENABLE_COUNTER 1
|
||||||
|
|
||||||
/* during kernel startup, interrupts are disabled */
|
|
||||||
extern bool kernel_startup;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -25,8 +26,8 @@ extern "C" {
|
|||||||
status_t int_init(struct kernel_args *args);
|
status_t int_init(struct kernel_args *args);
|
||||||
status_t int_init_post_vm(struct kernel_args *args);
|
status_t int_init_post_vm(struct kernel_args *args);
|
||||||
int int_io_interrupt_handler(int vector);
|
int int_io_interrupt_handler(int vector);
|
||||||
long install_interrupt_handler(long, interrupt_handler, void *);
|
status_t install_interrupt_handler(long vector, interrupt_handler, void *data);
|
||||||
long remove_interrupt_handler (long, interrupt_handler, void *);
|
status_t remove_interrupt_handler(long vector, interrupt_handler, void *data);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
enable_interrupts(void)
|
enable_interrupts(void)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2004, Axel Dörfler, [email protected].
|
* Copyright 2002-2005, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
//#define DEBUG_KERNEL_STACKS
|
//#define DEBUG_KERNEL_STACKS
|
||||||
// Note, debugging kernel stacks doesn't really work yet. Since the
|
// Note, debugging kernel stacks doesn't really work yet. Since the
|
||||||
// interrupt will also try to use the stack on a page fault, all
|
// interrupt will also try to use the stack on a page fault, all
|
||||||
// you get is a reboot.
|
// you get is a double fault.
|
||||||
// At least, you then know that the stack overflows in this case :)
|
// At least, you then know that the stack overflows in this case :)
|
||||||
|
|
||||||
/** Size of the kernel stack */
|
/** Size of the kernel stack */
|
||||||
@@ -51,6 +51,10 @@
|
|||||||
#define SET_BIT(a, b) ((a) | (1 << (b)))
|
#define SET_BIT(a, b) ((a) | (1 << (b)))
|
||||||
#define CLEAR_BIT(a, b) ((a) & (~(1 << (b))))
|
#define CLEAR_BIT(a, b) ((a) & (~(1 << (b))))
|
||||||
|
|
||||||
|
/* during kernel startup, interrupts are disabled (among other things) */
|
||||||
|
extern bool kernel_startup;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+17
-16
@@ -34,8 +34,9 @@ struct io_vector {
|
|||||||
|
|
||||||
static struct io_vector *io_vectors = NULL;
|
static struct io_vector *io_vectors = NULL;
|
||||||
|
|
||||||
|
|
||||||
cpu_status
|
cpu_status
|
||||||
disable_interrupts()
|
disable_interrupts(void)
|
||||||
{
|
{
|
||||||
return arch_int_disable_interrupts();
|
return arch_int_disable_interrupts();
|
||||||
}
|
}
|
||||||
@@ -82,11 +83,11 @@ int_init_post_vm(kernel_args *args)
|
|||||||
* arch_int_enable_io_interrupt() as it only works for IRQ values
|
* arch_int_enable_io_interrupt() as it only works for IRQ values
|
||||||
*/
|
*/
|
||||||
|
|
||||||
long
|
status_t
|
||||||
install_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
install_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
||||||
{
|
{
|
||||||
struct io_handler *io = NULL;
|
struct io_handler *io = NULL;
|
||||||
int state;
|
cpu_status state;
|
||||||
|
|
||||||
if (vector < 0 || vector >= NUM_IO_VECTORS)
|
if (vector < 0 || vector >= NUM_IO_VECTORS)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -98,7 +99,7 @@ install_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
|||||||
*/
|
*/
|
||||||
io = (struct io_handler *)malloc(sizeof(struct io_handler));
|
io = (struct io_handler *)malloc(sizeof(struct io_handler));
|
||||||
if (io == NULL)
|
if (io == NULL)
|
||||||
return ENOMEM;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
io->func = handler;
|
io->func = handler;
|
||||||
io->data = data;
|
io->data = data;
|
||||||
@@ -113,7 +114,7 @@ install_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
|||||||
release_spinlock(&io_vectors[vector].vector_lock);
|
release_spinlock(&io_vectors[vector].vector_lock);
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
|
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,11 +125,12 @@ install_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
|||||||
long
|
long
|
||||||
install_io_interrupt_handler(long irq, interrupt_handler handler, void *data, ulong flags)
|
install_io_interrupt_handler(long irq, interrupt_handler handler, void *data, ulong flags)
|
||||||
{
|
{
|
||||||
|
// ToDo: this is x86 specific
|
||||||
long vector = irq + 0x20;
|
long vector = irq + 0x20;
|
||||||
long rv = install_interrupt_handler(vector, handler, data);
|
|
||||||
|
|
||||||
if (rv != 0)
|
status_t status = install_interrupt_handler(vector, handler, data);
|
||||||
return rv;
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
/* If we were passed the bit-flag B_NO_ENABLE_COUNTER then
|
/* If we were passed the bit-flag B_NO_ENABLE_COUNTER then
|
||||||
* we're being asked to not alter whether the interrupt is set
|
* we're being asked to not alter whether the interrupt is set
|
||||||
@@ -137,7 +139,7 @@ install_io_interrupt_handler(long irq, interrupt_handler handler, void *data, ul
|
|||||||
if ((flags & B_NO_ENABLE_COUNTER) == 0)
|
if ((flags & B_NO_ENABLE_COUNTER) == 0)
|
||||||
arch_int_enable_io_interrupt(irq);
|
arch_int_enable_io_interrupt(irq);
|
||||||
|
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,11 +147,11 @@ install_io_interrupt_handler(long irq, interrupt_handler handler, void *data, ul
|
|||||||
* Read the notes for install_interrupt_handler!
|
* Read the notes for install_interrupt_handler!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
long
|
status_t
|
||||||
remove_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
remove_interrupt_handler(long vector, interrupt_handler handler, void *data)
|
||||||
{
|
{
|
||||||
struct io_handler *io = NULL;
|
struct io_handler *io = NULL;
|
||||||
long status = EINVAL;
|
status_t status = B_BAD_VALUE;
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
if (vector < 0 || vector >= NUM_IO_VECTORS)
|
if (vector < 0 || vector >= NUM_IO_VECTORS)
|
||||||
@@ -194,16 +196,15 @@ long
|
|||||||
remove_io_interrupt_handler(long irq, interrupt_handler handler, void *data)
|
remove_io_interrupt_handler(long irq, interrupt_handler handler, void *data)
|
||||||
{
|
{
|
||||||
long vector = irq + 0x20;
|
long vector = irq + 0x20;
|
||||||
long rv = remove_interrupt_handler(vector, handler, data);
|
status_t status = remove_interrupt_handler(vector, handler, data);
|
||||||
|
if (status < B_OK)
|
||||||
if (rv < 0)
|
return status;
|
||||||
return rv;
|
|
||||||
|
|
||||||
/* Check if we need to disable interrupts... */
|
/* Check if we need to disable interrupts... */
|
||||||
if (io_vectors[vector].handler_list.next != &io_vectors[vector].handler_list)
|
if (io_vectors[vector].handler_list.next != &io_vectors[vector].handler_list)
|
||||||
arch_int_disable_io_interrupt(irq);
|
arch_int_disable_io_interrupt(irq);
|
||||||
|
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
/* Mutex and recursive_lock code */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2002-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Mutex and recursive_lock code */
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include <lock.h>
|
#include <lock.h>
|
||||||
|
#include <kernel.h>
|
||||||
#include <int.h>
|
#include <int.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
# include <util/list.h>
|
# include <util/list.h>
|
||||||
# include <lock.h>
|
# include <lock.h>
|
||||||
# include <kdriver_settings.h>
|
# include <kdriver_settings.h>
|
||||||
# include <int.h>
|
# include <kernel.h>
|
||||||
# include <boot/kernel_args.h>
|
# include <boot/kernel_args.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef _BOOT_MODE
|
#ifdef _BOOT_MODE
|
||||||
|
|||||||
Reference in New Issue
Block a user