boot headers have been moved, some cleanups, dbg_save_registers() renamed.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3162 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2003-05-03 16:20:38 +00:00
parent c182223b6e
commit b2704e693c
10 changed files with 79 additions and 52 deletions
+44 -24
View File
@@ -4,11 +4,17 @@
** Copyright 2002, Travis Geiselbrecht. All rights reserved. ** Copyright 2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
// ToDo: fix the atomic_*() functions and possibly move them elsewhere;
// they are exported in libroot.so anyway, so the best place would
// probably there.
#include <kernel.h> #include <kernel.h>
#include <cpu.h> #include <cpu.h>
#include <vm.h> #include <vm.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <stage2.h> #include <boot/stage2.h>
#include <atomic.h> #include <atomic.h>
#include <string.h> #include <string.h>
@@ -16,7 +22,9 @@
/* global per-cpu structure */ /* global per-cpu structure */
cpu_ent cpu[MAX_BOOT_CPUS]; cpu_ent cpu[MAX_BOOT_CPUS];
int cpu_init(kernel_args *ka)
int
cpu_init(kernel_args *ka)
{ {
int i; int i;
@@ -28,20 +36,24 @@ int cpu_init(kernel_args *ka)
return arch_cpu_init(ka); return arch_cpu_init(ka);
} }
int cpu_preboot_init(kernel_args *ka)
int
cpu_preboot_init(kernel_args *ka)
{ {
return arch_cpu_preboot_init(ka); return arch_cpu_preboot_init(ka);
} }
int32 user_atomic_add(vint32 *uval, int32 incr)
int32
user_atomic_add(vint32 *uval, int32 incr)
{ {
int32 val; int32 val;
int32 ret; int32 ret;
if((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP) if ((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP)
goto error; goto error;
if(user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0) if (user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0)
goto error; goto error;
// XXX broken on non SH4-systems, or when interrupts are enabled // XXX broken on non SH4-systems, or when interrupts are enabled
@@ -49,7 +61,7 @@ int32 user_atomic_add(vint32 *uval, int32 incr)
ret = val; ret = val;
val += incr; val += incr;
if(user_memcpy((int32 *)uval, &val, sizeof(val)) < 0) if (user_memcpy((int32 *)uval, &val, sizeof(val)) < 0)
goto error; goto error;
return ret; return ret;
@@ -59,15 +71,17 @@ error:
return -1; return -1;
} }
int32 user_atomic_and(vint32 *uval, int32 incr)
int32
user_atomic_and(vint32 *uval, int32 incr)
{ {
int val; int val;
int ret; int ret;
if((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP) if ((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP)
goto error; goto error;
if(user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0) if (user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0)
goto error; goto error;
// XXX broken on non SH4-systems, or when interrupts are enabled // XXX broken on non SH4-systems, or when interrupts are enabled
@@ -75,7 +89,7 @@ int32 user_atomic_and(vint32 *uval, int32 incr)
ret = val; ret = val;
val &= incr; val &= incr;
if(user_memcpy((int32 *)uval, &val, sizeof(val)) < 0) if (user_memcpy((int32 *)uval, &val, sizeof(val)) < 0)
goto error; goto error;
return ret; return ret;
@@ -85,15 +99,17 @@ error:
return -1; return -1;
} }
int32 user_atomic_or(vint32 *uval, int32 incr)
int32
user_atomic_or(vint32 *uval, int32 incr)
{ {
int val; int val;
int ret; int ret;
if((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP) if ((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP)
goto error; goto error;
if(user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0) if (user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0)
goto error; goto error;
// XXX broken on non SH4-systems, or when interrupts are enabled // XXX broken on non SH4-systems, or when interrupts are enabled
@@ -101,7 +117,7 @@ int32 user_atomic_or(vint32 *uval, int32 incr)
ret = val; ret = val;
val |= incr; val |= incr;
if(user_memcpy((int32 *)uval, &val, sizeof(val)) < 0) if (user_memcpy((int32 *)uval, &val, sizeof(val)) < 0)
goto error; goto error;
return ret; return ret;
@@ -111,15 +127,17 @@ error:
return -1; return -1;
} }
int32 user_atomic_set(vint32 *uval, int32 set_to)
int32
user_atomic_set(vint32 *uval, int32 set_to)
{ {
int val; int val;
int ret; int ret;
if((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP) if ((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP)
goto error; goto error;
if(user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0) if (user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0)
goto error; goto error;
// XXX broken on non SH4-systems, or when interrupts are enabled // XXX broken on non SH4-systems, or when interrupts are enabled
@@ -127,7 +145,7 @@ int32 user_atomic_set(vint32 *uval, int32 set_to)
ret = val; ret = val;
val = set_to; val = set_to;
if(user_memcpy((int32 *)uval, &val, sizeof(val)) < 0) if (user_memcpy((int32 *)uval, &val, sizeof(val)) < 0)
goto error; goto error;
return ret; return ret;
@@ -137,23 +155,25 @@ error:
return -1; return -1;
} }
int32 user_test_and_set(vint32 *uval, int32 set_to, int32 test_val)
int32
user_test_and_set(vint32 *uval, int32 set_to, int32 test_val)
{ {
int val; int val;
int ret; int ret;
if((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP) if ((addr)uval >= KERNEL_BASE && (addr)uval <= KERNEL_TOP)
goto error; goto error;
if(user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0) if (user_memcpy(&val, (int32 *)uval, sizeof(val)) < 0)
goto error; goto error;
// XXX broken on non SH4-systems, or when interrupts are enabled // XXX broken on non SH4-systems, or when interrupts are enabled
// XXX x86 must use the assembly functions directly in userspace and not this ones // XXX x86 must use the assembly functions directly in userspace and not this ones
ret = val; ret = val;
if(val == test_val) { if (val == test_val) {
val = set_to; val = set_to;
if(user_memcpy((int32 *)uval, &val, sizeof(val)) < 0) if (user_memcpy((int32 *)uval, &val, sizeof(val)) < 0)
goto error; goto error;
} }
+1 -1
View File
@@ -260,7 +260,7 @@ kernel_debugger_loop()
void void
kernel_debugger(const char * message) kernel_debugger(const char * message)
{ {
dbg_save_registers(&(dbg_register_file[smp_get_current_cpu()][0])); arch_dbg_save_registers(&(dbg_register_file[smp_get_current_cpu()][0]));
if (message) { if (message) {
dprintf(message); dprintf(message);
+18 -8
View File
@@ -4,34 +4,40 @@
** Copyright 2001, Travis Geiselbrecht. All rights reserved. ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#include <kernel.h> #include <kernel.h>
#include <faults.h>
#include <faults_priv.h> #include <faults_priv.h>
#include <debug.h> #include <debug.h>
#include <arch/int.h> #include <arch/int.h>
#include <int.h> #include <int.h>
#include <arch/faults.h> #include <arch/faults.h>
#include <stage2.h> #include <boot/stage2.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
int faults_init(kernel_args *ka)
int
faults_init(kernel_args *ka)
{ {
dprintf("init_fault_handlers: entry\n"); dprintf("init_fault_handlers: entry\n");
return arch_faults_init(ka); return arch_faults_init(ka);
} }
int general_protection_fault(int errorcode) int
general_protection_fault(int errorcode)
{ {
panic("GENERAL PROTECTION FAULT: errcode 0x%x. Killing system.\n", errorcode); panic("GENERAL PROTECTION FAULT: errcode 0x%x. Killing system.\n", errorcode);
return B_HANDLED_INTERRUPT; return B_HANDLED_INTERRUPT;
} }
static const char *fpu_fault_to_str(enum fpu_faults fpu_fault)
static const char *
fpu_fault_to_str(enum fpu_faults fpu_fault)
{ {
switch(fpu_fault) { switch (fpu_fault) {
default: default:
case FPU_FAULT_CODE_UNKNOWN: case FPU_FAULT_CODE_UNKNOWN:
return "unknown"; return "unknown";
@@ -48,14 +54,18 @@ static const char *fpu_fault_to_str(enum fpu_faults fpu_fault)
} }
} }
int fpu_fault(int fpu_fault)
int
fpu_fault(int fpu_fault)
{ {
panic("FPU FAULT: errcode 0x%x (%s), Killing system.\n", fpu_fault, fpu_fault_to_str(fpu_fault)); panic("FPU FAULT: errcode 0x%x (%s), Killing system.\n", fpu_fault, fpu_fault_to_str(fpu_fault));
return B_HANDLED_INTERRUPT; return B_HANDLED_INTERRUPT;
} }
int fpu_disable_fault(void)
int
fpu_disable_fault(void)
{ {
panic("FPU DISABLE FAULT: Killing system.\n"); panic("FPU DISABLE FAULT: Killing system.\n");
+1 -3
View File
@@ -11,10 +11,8 @@
#include <memheap.h> #include <memheap.h>
#include <malloc.h> #include <malloc.h>
#include <debug.h> #include <debug.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <boot/stage2.h>
#include <stage2.h>
#include <string.h> #include <string.h>
+1 -1
View File
@@ -10,7 +10,7 @@
#include <smp.h> #include <smp.h>
#include <arch/int.h> #include <arch/int.h>
#include <errno.h> #include <errno.h>
#include <stage2.h> #include <boot/stage2.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <kqueue.h> #include <kqueue.h>
+4 -6
View File
@@ -5,13 +5,14 @@
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#include <stage2.h> #include <boot/stage2.h>
#include <Errors.h> #include <Errors.h>
#include <kernel.h> #include <kernel.h>
#include <console.h> #include <console.h>
#include <debug.h> #include <debug.h>
#include <faults.h> #include <arch/faults.h>
#include <arch/int.h> #include <arch/int.h>
#include <arch/cpu.h>
#include <vm.h> #include <vm.h>
#include <timer.h> #include <timer.h>
#include <smp.h> #include <smp.h>
@@ -31,9 +32,6 @@
#include <string.h> #include <string.h>
#include <arch/cpu.h>
#include <arch/faults.h>
#define TRACE_BOOT 1 #define TRACE_BOOT 1
#if TRACE_BOOT #if TRACE_BOOT
@@ -47,9 +45,9 @@ bool kernel_startup;
static kernel_args ka; static kernel_args ka;
static int32 main2(void *); static int32 main2(void *);
int _start(kernel_args *oldka, int cpu); /* keep compiler happy */ int _start(kernel_args *oldka, int cpu); /* keep compiler happy */
int int
_start(kernel_args *oldka, int cpu_num) _start(kernel_args *oldka, int cpu_num)
{ {
+1 -1
View File
@@ -18,7 +18,7 @@
#include <Errors.h> #include <Errors.h>
#include <kerrors.h> #include <kerrors.h>
#include <stage2.h> #include <boot/stage2.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
-2
View File
@@ -11,7 +11,6 @@
#include <debug.h> #include <debug.h>
#include <int.h> #include <int.h>
#include <arch/int.h> #include <arch/int.h>
#include <smp_priv.h>
#include <smp.h> #include <smp.h>
#include <malloc.h> #include <malloc.h>
#include <Errors.h> #include <Errors.h>
@@ -20,7 +19,6 @@
#include <cpu.h> #include <cpu.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <arch/smp.h> #include <arch/smp.h>
//#include <arch/pmap.h>
#include <string.h> #include <string.h>
+4 -3
View File
@@ -5,6 +5,9 @@
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#include <OS.h>
#include <Errors.h>
#include <kernel.h> #include <kernel.h>
#include <debug.h> #include <debug.h>
#include <console.h> #include <console.h>
@@ -18,15 +21,13 @@
#include <arch/int.h> #include <arch/int.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <arch/vm.h> #include <arch/vm.h>
#include <OS.h>
#include <sem.h> #include <sem.h>
#include <port.h> #include <port.h>
#include <vfs.h> #include <vfs.h>
#include <elf.h> #include <elf.h>
#include <malloc.h> #include <malloc.h>
#include <user_runtime.h> #include <user_runtime.h>
#include <Errors.h> #include <boot/stage2.h>
#include <stage2.h>
#include <string.h> #include <string.h>
#include <kimage.h> #include <kimage.h>
#include <stdio.h> #include <stdio.h>
+5 -3
View File
@@ -3,6 +3,9 @@
** Copyright 2001, Travis Geiselbrecht. All rights reserved. ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#include <OS.h>
#include <kernel.h> #include <kernel.h>
#include <console.h> #include <console.h>
#include <debug.h> #include <debug.h>
@@ -12,9 +15,7 @@
#include <vm.h> #include <vm.h>
#include <int.h> #include <int.h>
#include <timer.h> #include <timer.h>
#include <Errors.h> #include <boot/stage2.h>
#include <stage2.h>
#include <OS.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <arch/timer.h> #include <arch/timer.h>
@@ -23,6 +24,7 @@
static timer * volatile events[SMP_MAX_CPUS] = { NULL, }; static timer * volatile events[SMP_MAX_CPUS] = { NULL, };
static spinlock 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)
{ {
dprintf("init_timer: entry\n"); dprintf("init_timer: entry\n");