It is accomplished ...

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2002-07-09 12:24:59 +00:00
commit 52a3801208
2025 changed files with 472889 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_SH4_CPU_H
#define _NEWOS_KERNEL_ARCH_SH4_CPU_H
#include <arch/cpu.h>
#include <arch/sh4/sh4.h>
unsigned int get_fpscr();
unsigned int get_sr();
void sh4_context_switch(unsigned int **old_sp, unsigned int *new_sp);
void sh4_function_caller();
void sh4_set_kstack(addr kstack);
void sh4_enter_uspace(addr entry, void *args, addr ustack_top);
void sh4_set_user_pgdir(addr pgdir);
void sh4_invl_page(addr va);
void sh4_switch_stack_and_call(addr stack, void (*func)(void *), void *arg);
#define PAGE_SIZE 4096
#define _BIG_ENDIAN 0
#define _LITTLE_ENDIAN 1
#endif
+36
View File
@@ -0,0 +1,36 @@
/* $Id: defs.h,v 1.1 2002/07/09 12:24:34 ejakowatz Exp $
**
** Copyright 2001 Brian J. Swetland
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions, and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions, and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEFS_H
#define _DEFS_H
typedef unsigned char u1;
typedef unsigned short u2;
typedef unsigned int u4;
#endif
+30
View File
@@ -0,0 +1,30 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_SH4_KERNEL_H
#define _NEWOS_KERNEL_ARCH_SH4_KERNEL_H
#include <arch/sh4/sh4.h>
// memory layout
#define KERNEL_BASE P3_AREA
#define KERNEL_SIZE P3_AREA_LEN
#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
/*
** User space layout is a little special:
** The user space does not completely cover the space not covered by the kernel.
** This is accomplished by starting user space at 1Mb and running to 64kb short of kernel space.
** The lower 1Mb reserved spot makes it easy to find null pointer references and guarantees a
** region wont be placed there. The 64kb region assures a user space thread cannot pass
** a buffer into the kernel as part of a syscall that would cross into kernel space.
*/
#define USER_BASE (U0_AREA + 0x100000)
#define USER_SIZE (U0_AREA_LEN - (0x10000 + 0x100000))
#define USER_TOP (USER_BASE + USER_SIZE)
#define USER_STACK_REGION (USER_BASE + USER_SIZE - USER_STACK_REGION_SIZE)
#define USER_STACK_REGION_SIZE 0x10000000
#endif
+11
View File
@@ -0,0 +1,11 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_SH4_KTYPES_H
#define _NEWOS_KERNEL_ARCH_SH4_KTYPES_H
typedef unsigned long addr;
#endif
+14
View File
@@ -0,0 +1,14 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _MMU_H
#define _MMU_H
#include <boot/stage2.h>
void mmu_init(kernel_args *ka, unsigned int *next_paddr);
void mmu_map_page(unsigned int vaddr, unsigned int paddr);
#endif
+13
View File
@@ -0,0 +1,13 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _RTL8139_PRIV_H
#define _RTL8139_PRIV_H
int rtl8139_detect();
int rtl8139_init();
void rtl8139_xmit(const char *ptr, int len);
int rtl8139_rx(char *buf, int buf_len);
#endif
+84
View File
@@ -0,0 +1,84 @@
/*
**
** Naive RealTek 8139C driver for the DC Broadband Adapter. Some
** assistance on names of things from the NetBSD-DC sources.
**
** (c)2001 Dan Potter
** License: X11
**
*/
#ifndef _RTL_8139C_H
#define _RTL_8139C_H
/* RTL8139C register definitions */
#define RT_IDR0 0x00 /* Mac address */
#define RT_MAR0 0x08 /* Multicast filter */
#define RT_TXSTATUS0 0x10 /* Transmit status (4 32bit regs) */
#define RT_TXADDR0 0x20 /* Tx descriptors (also 4 32bit) */
#define RT_RXBUF 0x30 /* Receive buffer start address */
#define RT_RXEARLYCNT 0x34 /* Early Rx byte count */
#define RT_RXEARLYSTATUS 0x36 /* Early Rx status */
#define RT_CHIPCMD 0x37 /* Command register */
#define RT_RXBUFTAIL 0x38 /* Current address of packet read (queue tail) */
#define RT_RXBUFHEAD 0x3A /* Current buffer address (queue head) */
#define RT_INTRMASK 0x3C /* Interrupt mask */
#define RT_INTRSTATUS 0x3E /* Interrupt status */
#define RT_TXCONFIG 0x40 /* Tx config */
#define RT_RXCONFIG 0x44 /* Rx config */
#define RT_TIMER 0x48 /* A general purpose counter */
#define RT_RXMISSED 0x4C /* 24 bits valid, write clears */
#define RT_CFG9346 0x50 /* 93C46 command register */
#define RT_CONFIG0 0x51 /* Configuration reg 0 */
#define RT_CONFIG1 0x52 /* Configuration reg 1 */
#define RT_TIMERINT 0x54 /* Timer interrupt register (32 bits) */
#define RT_MEDIASTATUS 0x58 /* Media status register */
#define RT_CONFIG3 0x59 /* Config register 3 */
#define RT_CONFIG4 0x5A /* Config register 4 */
#define RT_MULTIINTR 0x5C /* Multiple interrupt select */
#define RT_MII_TSAD 0x60 /* Transmit status of all descriptors (16 bits) */
#define RT_MII_BMCR 0x62 /* Basic Mode Control Register (16 bits) */
#define RT_MII_BMSR 0x64 /* Basic Mode Status Register (16 bits) */
#define RT_AS_ADVERT 0x66 /* Auto-negotiation advertisement reg (16 bits) */
#define RT_AS_LPAR 0x68 /* Auto-negotiation link partner reg (16 bits) */
#define RT_AS_EXPANSION 0x6A /* Auto-negotiation expansion reg (16 bits) */
/* RTL8193C command bits; or these together and write teh resulting value
into CHIPCMD to execute it. */
#define RT_CMD_RESET 0x10
#define RT_CMD_RX_ENABLE 0x08
#define RT_CMD_TX_ENABLE 0x04
#define RT_CMD_RX_BUF_EMPTY 0x01
/* RTL8139C interrupt status bits */
#define RT_INT_PCIERR 0x8000 /* PCI Bus error */
#define RT_INT_TIMEOUT 0x4000 /* Set when TCTR reaches TimerInt value */
#define RT_INT_RXFIFO_OVERFLOW 0x0040 /* Rx FIFO overflow */
#define RT_INT_RXFIFO_UNDERRUN 0x0020 /* Packet underrun / link change */
#define RT_INT_RXBUF_OVERFLOW 0x0010 /* Rx BUFFER overflow */
#define RT_INT_TX_ERR 0x0008
#define RT_INT_TX_OK 0x0004
#define RT_INT_RX_ERR 0x0002
#define RT_INT_RX_OK 0x0001
/* RTL8139C transmit status bits */
#define RT_TX_CARRIER_LOST 0x80000000 /* Carrier sense lost */
#define RT_TX_ABORTED 0x40000000 /* Transmission aborted */
#define RT_TX_OUT_OF_WINDOW 0x20000000 /* Out of window collision */
#define RT_TX_STATUS_OK 0x00008000 /* Status ok: a good packet was transmitted */
#define RT_TX_UNDERRUN 0x00004000 /* Transmit FIFO underrun */
#define RT_TX_HOST_OWNS 0x00002000 /* Set to 1 when DMA operation is completed */
#define RT_TX_SIZE_MASK 0x00001fff /* Descriptor size mask */
/* RTL8139C receive status bits */
#define RT_RX_MULTICAST 0x00008000 /* Multicast packet */
#define RT_RX_PAM 0x00004000 /* Physical address matched */
#define RT_RX_BROADCAST 0x00002000 /* Broadcast address matched */
#define RT_RX_BAD_SYMBOL 0x00000020 /* Invalid symbol in 100TX packet */
#define RT_RX_RUNT 0x00000010 /* Packet size is <64 bytes */
#define RT_RX_TOO_LONG 0x00000008 /* Packet size is >4K bytes */
#define RT_RX_CRC_ERR 0x00000004 /* CRC error */
#define RT_RX_FRAME_ALIGN 0x00000002 /* Frame alignment error */
#define RT_RX_STATUS_OK 0x00000001 /* Status ok: a good packet was received */
#endif
+14
View File
@@ -0,0 +1,14 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SERIAL_H
#define _SERIAL_H
int dprintf(const char *fmt, ...);
int serial_init();
char serial_putch(const char c);
void serial_puts(const char *str);
#endif
+152
View File
@@ -0,0 +1,152 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SH4_H
#define _SH4_H
#define P4_AREA 0xe0000000
#define P4_AREA_LEN 0x20000000
#define P3_AREA 0xc0000000
#define P3_AREA_LEN (P4_AREA - P3_AREA)
#define P2_AREA 0xa0000000
#define P2_AREA_LEN (P3_AREA - P2_AREA)
#define P1_AREA 0x80000000
#define P1_AREA_LEN (P2_AREA - P1_AREA)
#define P0_AREA 0
#define P0_AREA_LEN (P1_AREA - P0_AREA)
#define U0_AREA P0_AREA
#define U0_AREA_LEN P0_AREA_LEN
#define PHYS_MEM_START 0x0c000000
#define PHYS_MEM_LEN 0x01000000
#define PHYS_MEM_END (PHYS_MEM_START + PHYS_MEM_LEN)
#define P1_PHYS_MEM_START (P1_AREA + PHYS_MEM_START)
#define P1_PHYS_MEM_LEN PHYS_MEM_LEN
#define P1_PHYS_MEM_END (P1_PHYS_MEM_START + P1_PHYS_MEM_LEN)
#define PHYS_ADDR_TO_P1(x) (((unsigned int)(x)) + P1_AREA)
#define PHYS_ADDR_TO_P2(x) (((unsigned int)(x)) + P2_AREA)
#define P1_TO_PHYS_ADDR(x) (((unsigned int)(x)) - P1_AREA)
#define PHYS_ADDR_SIZE (0x1fffffff+1)
//#define PAGE_SIZE 4096
#define PAGE_SIZE_1K 0
#define PAGE_SIZE_4K 1
#define PAGE_SIZE_64K 2
#define PAGE_SIZE_1M 3
#define PTEH 0xff000000
#define PTEL 0xff000004
#define PTEA 0xff000034
#define TTB 0xff000008
#define TEA 0xff00000c
#define MMUCR 0xff000010
#define UTLB 0xf6000000
#define UTLB1 0xf7000000
#define UTLB2 0xf3800000
#define UTLB_ADDR_SHIFT 0x8
#define UTLB_COUNT 64
struct utlb_addr_array {
unsigned int asid: 8;
unsigned int valid: 1;
unsigned int dirty: 1;
unsigned int vpn: 22;
};
struct utlb_data_array_1 {
unsigned int wt: 1;
unsigned int sh: 1;
unsigned int dirty: 1;
unsigned int cacheability: 1;
unsigned int psize0: 1;
unsigned int prot_key: 2;
unsigned int psize1: 1;
unsigned int valid: 1;
unsigned int unused: 1;
unsigned int ppn: 19;
unsigned int unused2: 3;
};
struct utlb_data_array_2 {
unsigned int sa: 2;
unsigned int tc: 1;
unsigned int unused: 29;
};
struct utlb_data {
struct utlb_addr_array a;
struct utlb_data_array_1 da1;
struct utlb_data_array_2 da2;
};
#define ITLB 0xf2000000
#define ITLB1 0xf3000000
#define ITLB2 0xf3800000
#define ITLB_ADDR_SHIFT 0x8
#define ITLB_COUNT 4
struct itlb_addr_array {
unsigned int asid: 8;
unsigned int valid: 1;
unsigned int unused: 1;
unsigned int vpn: 22;
};
struct itlb_data_array_1 {
unsigned int unused1: 1;
unsigned int sh: 1;
unsigned int unused2: 1;
unsigned int cacheability: 1;
unsigned int psize0: 1;
unsigned int unused3: 1;
unsigned int prot_key: 1;
unsigned int psize1: 1;
unsigned int valid: 1;
unsigned int unused4: 1;
unsigned int ppn: 19;
unsigned int unused5: 3;
};
struct itlb_data_array_2 {
unsigned int sa: 2;
unsigned int tc: 1;
unsigned int unused: 29;
};
struct itlb_data {
struct itlb_addr_array a;
struct itlb_data_array_1 da1;
struct itlb_data_array_2 da2;
};
// timer stuff
#define TOCR 0xffd80000
#define TSTR 0xffd80004
#define TCOR0 0xffd80008
#define TCNT0 0xffd8000c
#define TCR0 0xffd80010
#define TCOR1 0xffd80014
#define TCNT1 0xffd80018
#define TCR1 0xffd8001c
#define TCOR2 0xffd80020
#define TCNT2 0xffd80024
#define TCR2 0xffd80028
#define TCPR2 0xffd8002c
// interrupt controller stuff
#define ICR 0xffd00000
#define IPRA 0xffd00004
#define IPRB 0xffd00008
#define IPRC 0xffd0000c
// cache stuff
#define CCR 0xff00001c
#define QACR0 0xff000038
#define QACR1 0xff00003c
#endif
+19
View File
@@ -0,0 +1,19 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SH4_STAGE2_H
#define _SH4_STAGE2_H
#include <boot/stage2_struct.h>
#include <arch/sh4/vcpu_struct.h>
// kernel args
typedef struct {
// architecture specific
vcpu_struct *vcpu;
} arch_kernel_args;
#endif
@@ -0,0 +1,17 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_SH4_THREAD_STRUCT_H
#define _NEWOS_KERNEL_ARCH_SH4_THREAD_STRUCT_H
// architecture specific thread info
struct arch_thread {
unsigned int *sp;
};
struct arch_proc {
};
#endif
+19
View File
@@ -0,0 +1,19 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SH4_TYPES_H
#define _SH4_TYPES_H
// XXX is this accurate?
typedef unsigned long long uint64;
typedef long long int64;
typedef unsigned int uint32;
typedef int int32;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned char uint8;
typedef char int8;
#endif
+230
View File
@@ -0,0 +1,230 @@
/* The ! __SH3E_VARG case is similar to the default gvarargs.h . */
#if (defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)) && ! defined (__HITACHI__)
#define __SH3E_VARG
#endif
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
#ifdef __SH3E_VARG
typedef long __va_greg;
typedef float __va_freg;
typedef struct {
__va_greg * __va_next_o; /* next available register */
__va_greg * __va_next_o_limit; /* past last available register */
__va_freg * __va_next_fp; /* next available fp register */
__va_freg * __va_next_fp_limit; /* last available fp register */
__va_greg * __va_next_stack; /* next extended word on stack */
} __gnuc_va_list;
#else /* ! SH3E */
typedef void *__gnuc_va_list;
#endif /* ! SH3E */
#endif /* __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
#ifdef _STDARG_H
#ifdef __SH3E_VARG
#define va_start(AP, LASTARG) \
__extension__ \
({ \
(AP).__va_next_fp = (__va_freg *) __builtin_saveregs (); \
(AP).__va_next_fp_limit = ((AP).__va_next_fp + \
(__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
(AP).__va_next_o = (__va_greg *) (AP).__va_next_fp_limit; \
(AP).__va_next_o_limit = ((AP).__va_next_o + \
(__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
(AP).__va_next_stack = (__va_greg *) __builtin_next_arg (LASTARG); \
})
#else /* ! SH3E */
#define va_start(AP, LASTARG) \
((AP) = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
#endif /* ! SH3E */
#else /* _VARARGS_H */
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist;...
#ifdef __SH3E_VARG
#define va_start(AP) \
__extension__ \
({ \
(AP).__va_next_fp = (__va_freg *) __builtin_saveregs (); \
(AP).__va_next_fp_limit = ((AP).__va_next_fp + \
(__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
(AP).__va_next_o = (__va_greg *) (AP).__va_next_fp_limit; \
(AP).__va_next_o_limit = ((AP).__va_next_o + \
(__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
(AP).__va_next_stack \
= ((__va_greg *) __builtin_next_arg (__builtin_va_alist) \
- (__builtin_args_info (0) >= 4 || __builtin_args_info (1) >= 8 \
? 1 : 0)); \
})
#else /* ! SH3E */
#define va_start(AP) ((AP) = (char *) &__builtin_va_alist)
#endif /* ! SH3E */
#endif /* _STDARG */
#ifndef va_end
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
/* Values returned by __builtin_classify_type. */
enum __va_type_classes {
__no_type_class = -1,
__void_type_class,
__integer_type_class,
__char_type_class,
__enumeral_type_class,
__boolean_type_class,
__pointer_type_class,
__reference_type_class,
__offset_type_class,
__real_type_class,
__complex_type_class,
__function_type_class,
__method_type_class,
__record_type_class,
__union_type_class,
__array_type_class,
__string_type_class,
__set_type_class,
__file_type_class,
__lang_type_class
};
#endif
#define va_end(pvar) ((void)0)
#ifdef __LITTLE_ENDIAN__
#define __LITTLE_ENDIAN_P 1
#else
#define __LITTLE_ENDIAN_P 0
#endif
#define __SCALAR_TYPE(TYPE) \
((TYPE) == __integer_type_class \
|| (TYPE) == __char_type_class \
|| (TYPE) == __enumeral_type_class)
/* RECORD_TYPE args passed using the C calling convention are
passed by invisible reference. ??? RECORD_TYPE args passed
in the stack are made to be word-aligned; for an aggregate that is
not word-aligned, we advance the pointer to the first non-reg slot. */
/* When this is a smaller-than-int integer, using
auto-increment in the promoted (SImode) is fastest;
however, there is no way to express that is C. Therefore,
we use an asm.
We want the MEM_IN_STRUCT_P bit set in the emitted RTL, therefore we
use unions even when it would otherwise be unnecessary. */
/* gcc has an extension that allows to use a casted lvalue as an lvalue,
But it doesn't work in C++ with -pedantic - even in the presence of
__extension__ . We work around this problem by using a reference type. */
#ifdef __cplusplus
#define __VA_REF &
#else
#define __VA_REF
#endif
#define __va_arg_sh1(AP, TYPE) __extension__ \
({(sizeof (TYPE) == 1 \
? ({union {TYPE t; char c;} __t; \
__asm("" \
: "=r" (__t.c) \
: "0" ((((union { int i, j; } *__VA_REF) (AP))++)->i)); \
__t.t;}) \
: sizeof (TYPE) == 2 \
? ({union {TYPE t; short s;} __t; \
__asm("" \
: "=r" (__t.s) \
: "0" ((((union { int i, j; } *__VA_REF) (AP))++)->i)); \
__t.t;}) \
: sizeof (TYPE) >= 4 || __LITTLE_ENDIAN_P \
? (((union { TYPE t; int i;} *__VA_REF) (AP))++)->t \
: ((union {TYPE t;TYPE u;}*) ((char *)++(int *__VA_REF)(AP) - sizeof (TYPE)))->t);})
#ifdef __SH3E_VARG
#define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
(TYPE_CLASS == __real_type_class && SIZE == 4)
#define __TARGET_SH4_P 0
#if defined(__SH4__) || defined(__SH4_SINGLE__)
#undef __PASS_AS_FLOAT
#define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
((TYPE_CLASS == __real_type_class && SIZE <= 8) \
|| (TYPE_CLASS == __complex_type_class && SIZE <= 16))
#undef __TARGET_SH4_P
#define __TARGET_SH4_P 1
#endif
#define va_arg(pvar,TYPE) \
__extension__ \
({int __type = __builtin_classify_type (* (TYPE *) 0); \
void * __result_p; \
if (__PASS_AS_FLOAT (__type, sizeof(TYPE))) \
{ \
if ((pvar).__va_next_fp < (pvar).__va_next_fp_limit) \
{ \
if (((__type == __real_type_class && sizeof (TYPE) > 4)\
|| sizeof (TYPE) > 8) \
&& (((int) (pvar).__va_next_fp ^ (int) (pvar).__va_next_fp_limit)\
& 4)) \
(pvar).__va_next_fp++; \
__result_p = &(pvar).__va_next_fp; \
} \
else \
__result_p = &(pvar).__va_next_stack; \
} \
else \
{ \
if ((pvar).__va_next_o + ((sizeof (TYPE) + 3) / 4) \
<= (pvar).__va_next_o_limit) \
__result_p = &(pvar).__va_next_o; \
else \
{ \
if (sizeof (TYPE) > 4) \
if (! __TARGET_SH4_P) \
(pvar).__va_next_o = (pvar).__va_next_o_limit; \
\
__result_p = &(pvar).__va_next_stack; \
} \
} \
__va_arg_sh1(*(void **)__result_p, TYPE);})
#else /* ! SH3E */
#define va_arg(AP, TYPE) __va_arg_sh1((AP), TYPE)
#endif /* SH3E */
/* Copy __gnuc_va_list into another variable of this type. */
#define __va_copy(dest, src) ((dest) = (src))
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
+103
View File
@@ -0,0 +1,103 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _VCPU_H
#define _VCPU_H
#include <boot/stage2.h>
// layout of the iframe is defined in boot/sh4/vcpu.S
struct iframe {
unsigned int page_fault_addr;
unsigned int excode;
unsigned int spc;
unsigned int ssr;
unsigned int sgr;
unsigned int pr;
unsigned int macl;
unsigned int mach;
unsigned int gbr;
unsigned int fpscr;
unsigned int fpul;
float fr15_1;
float fr14_1;
float fr13_1;
float fr12_1;
float fr11_1;
float fr10_1;
float fr9_1;
float fr8_1;
float fr7_1;
float fr6_1;
float fr5_1;
float fr4_1;
float fr3_1;
float fr2_1;
float fr1_1;
float fr0_1;
float fr15_0;
float fr14_0;
float fr13_0;
float fr12_0;
float fr11_0;
float fr10_0;
float fr9_0;
float fr8_0;
float fr7_0;
float fr6_0;
float fr5_0;
float fr4_0;
float fr3_0;
float fr2_0;
float fr1_0;
float fr0_0;
unsigned int r7;
unsigned int r6;
unsigned int r5;
unsigned int r4;
unsigned int r3;
unsigned int r2;
unsigned int r1;
unsigned int r0;
unsigned int r14;
unsigned int r13;
unsigned int r12;
unsigned int r11;
unsigned int r10;
unsigned int r9;
unsigned int r8;
};
// page table structures
struct pdent {
unsigned int v:1;
unsigned int unused0:11;
unsigned int ppn:17;
unsigned int unused1:3;
};
struct ptent {
unsigned int v:1;
unsigned int d:1;
unsigned int sh:1;
unsigned int sz:2;
unsigned int c:1;
unsigned int tlb_ent:6;
unsigned int ppn:17;
unsigned int pr:2;
unsigned int wt:1;
};
// soft faults
#define EXCEPTION_PAGE_FAULT_READ 0xfe
#define EXCEPTION_PAGE_FAULT_WRITE 0xff
// can only be used in stage2
int vcpu_init(kernel_args *ka);
#endif
@@ -0,0 +1,22 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _VCPU_STRUCT_H
#define _VCPU_STRUCT_H
struct vector {
int (*func)(void *iframe);
};
typedef struct {
unsigned int *kernel_pgdir;
unsigned int *user_pgdir;
unsigned int kernel_asid;
unsigned int user_asid;
unsigned int *kstack;
struct vector vt[256];
} vcpu_struct;
#endif