Ported my NewOS changes to OpenBeOS.

A couple of changes in various interrupt and thread functions and structures.
These make it now possible to change the stack at any time without making the kernel crash. This is needed for calling VESA 3.0 VBE functions through the protected mode interface.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@422 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
notion
2002-07-24 20:59:25 +00:00
parent 94782cf761
commit fde77afb37
12 changed files with 277 additions and 57 deletions
+3 -6
View File
@@ -7,12 +7,9 @@
/* ??? why include this as we're normally included from that file! */
#include <arch/cpu.h>
#include <arch/x86/thread_struct.h>
#include <arch/x86/descriptors.h>
#define KERNEL_CODE_SEG 0x8
#define KERNEL_DATA_SEG 0x10
#define USER_CODE_SEG 0x1b
#define USER_DATA_SEG 0x23
#define TSS 0x28
#define PAGE_SIZE 4096
#define _BIG_ENDIAN 0
@@ -88,7 +85,7 @@ typedef struct pdentry {
#define nop() __asm__ ("nop"::)
void setup_system_time(unsigned int cv_factor);
void i386_context_switch(unsigned int **old_esp, unsigned int *new_esp, addr new_pgdir);
void i386_context_switch(struct arch_thread *old_state, struct arch_thread *new_state, addr new_pgdir);
void i386_enter_uspace(addr entry, void *args, addr ustack_top);
void i386_set_kstack(addr kstack);
void i386_switch_stack_and_call(addr stack, void (*func)(void *), void *arg);
+14 -3
View File
@@ -1,15 +1,26 @@
/*
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_BOOT_ARCH_I386_STAGE2_H
#define _NEWOS_KERNEL_BOOT_ARCH_I386_STAGE2_H
#ifndef _KERNEL_ARCH_x86_STAGE2_H
#define _KERNEL_ARCH_x86_STAGE2_H
#include <stage2_struct.h>
#define MAX_BOOT_PTABLES 4
#define _PACKED __attribute__((packed))
#define IDT_LIMIT 0x800
#define GDT_LIMIT 0x800
struct gdt_idt_descr {
unsigned short a;
unsigned int *b;
} _PACKED;
// kernel args
typedef struct {
// architecture specific
@@ -0,0 +1,14 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_ARCH_x86_DESCRIPTORS_H
#define _KERNEL_ARCH_x86_DESCRIPTORS_H
#define KERNEL_CODE_SEG 0x8
#define KERNEL_DATA_SEG 0x10
#define USER_CODE_SEG 0x1b
#define USER_DATA_SEG 0x23
#define TSS 0x28
#endif
@@ -0,0 +1,34 @@
/*
** Copyright 2002, Michael Noisternig. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_ARCH_x86_SELECTOR_H
#define _KERNEL_ARCH_x86_SELECTOR_H
#include <arch/x86/types.h>
typedef uint32 selector_id;
typedef uint64 selector_type;
// DATA segments are read-only
// CODE segments are execute-only
// both can be modified by using the suffixed enum versions
// legend: w = writable
// d = expand down
// r = readable
// c = conforming
enum segment_type {
DATA = 0x8, DATA_w, DATA_d, DATA_wd, CODE, CODE_r, CODE_c, CODE_rc
};
#define SELECTOR(base,limit,type,mode32) \
(((uint64)(((((uint32)base)>>16)&0xff) | (((uint32)base)&0xff000000) | ((type)<<9) | ((mode32)<<22) | (1<<15))<<32) \
| ( (limit) >= (1<<20) ? (((limit)>>12)&0xffff) | ((uint64)(((limit)>>12)&0xf0000)<<32) | ((uint64)1<<(23+32)) : ((limit)&0xffff) | ((uint64)((limit)&0xf0000)<<32) ) \
| ((((uint32)base)&0xffff)<<16))
void i386_selector_init( void *gdt );
selector_id i386_selector_add( selector_type selector );
void i386_selector_remove( selector_id id );
selector_type i386_selector_get( selector_id id );
#endif
@@ -39,16 +39,6 @@ void cpuid(unsigned int selector, unsigned int *data);
#define SCREEN_HEIGHT 24
#define ADDR_MASK 0xfffff000
#define _PACKED __attribute__((packed))
#define IDT_LIMIT 0x800
#define GDT_LIMIT 0x800
struct gdt_idt_descr {
unsigned short a;
unsigned int *b;
} _PACKED;
// SMP stuff
extern int smp_boot(kernel_args *ka, unsigned int kernel_entry);
extern void smp_trampoline(void);
@@ -2,12 +2,18 @@
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_I386_THREAD_STRUCT_H
#define _NEWOS_KERNEL_ARCH_I386_THREAD_STRUCT_H
#ifndef _KERNEL_ARCH_x86_THREAD_STRUCT_H
#define _KERNEL_ARCH_x86_THREAD_STRUCT_H
struct farcall {
unsigned int *esp;
unsigned int *ss;
};
// architecture specific thread info
struct arch_thread {
unsigned int *esp;
struct farcall current_stack;
struct farcall interrupt_stack;
// 512 byte floating point save point
uint8 fpu_state[512];
};