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
+11
View File
@@ -0,0 +1,11 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _ALPHA_CPU_H
#define _ALPHA_CPU_H
#define PAGE_SIZE 8192
#endif
@@ -0,0 +1,15 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _ALPHA_KERNEL_H
#define _ALPHA_KERNEL_H
// memory layout
#define KERNEL_BASE 0x80000000
#define KERNEL_SIZE 0x80000000
#define USER_BASE 0x00000000
#define USER_SIZE 0x80000000
#endif
@@ -0,0 +1,11 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _ALPHA_KTYPES_H
#define _ALPHA_KTYPES_H
typedef unsigned long addr;
#endif
@@ -0,0 +1,41 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _STAGE2_H
#define _STAGE2_H
#include <boot.h>
// must match SMP_MAX_CPUS in arch_smp.h
#define MAX_BOOT_CPUS 1
#define MAX_PHYS_MEM_ADDR_RANGE 4
#define MAX_VIRT_ALLOC_ADDR_RANGE 4
#define MAX_PHYS_ALLOC_ADDR_RANGE 4
typedef struct {
unsigned int start;
unsigned int size;
} addr_range;
// kernel args
typedef struct {
unsigned int cons_line;
char *str;
addr_range bootdir_addr;
addr_range kernel_seg0_addr;
addr_range kernel_seg1_addr;
unsigned int num_phys_mem_ranges;
addr_range phys_mem_range[MAX_PHYS_MEM_ADDR_RANGE];
unsigned int num_phys_alloc_ranges;
addr_range phys_alloc_range[MAX_PHYS_ALLOC_ADDR_RANGE];
unsigned int num_virt_alloc_ranges;
addr_range virt_alloc_range[MAX_VIRT_ALLOC_ADDR_RANGE];
unsigned int num_cpus;
addr_range cpu_kstack[MAX_BOOT_CPUS];
// architecture specific
} kernel_args;
#endif
@@ -0,0 +1,18 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _ALPHA_THREAD_STRUCT_H
#define _ALPHA_THREAD_STRUCT_H
// architecture specific thread info
struct arch_thread {
unsigned int *sp;
};
struct arch_proc {
int foo;
};
#endif
@@ -0,0 +1,129 @@
/* GNU C varargs and stdargs support for the DEC Alpha. */
/* Note: We must use the name __builtin_savregs. GCC attaches special
significance to that name. In particular, regardless of where in a
function __builtin_saveregs is called, GCC moves the call up to the
very start of the function. */
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
/* In VMS, __gnuc_va_list is simply char *; on OSF, it's a structure. */
#ifdef __VMS__
typedef char *__gnuc_va_list;
#else
typedef struct {
char *__base; /* Pointer to first integer register. */
int __offset; /* Byte offset of args so far. */
} __gnuc_va_list;
#endif
#endif /* __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if !defined(__GNUC_VA_LIST_1) && (defined (_STDARG_H) || defined (_VARARGS_H))
#define __GNUC_VA_LIST_1
#define _VA_LIST
#define _VA_LIST_
typedef __gnuc_va_list va_list;
#if !defined(_STDARG_H)
/* varargs support */
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist;...
#ifdef __VMS__
#define va_start(pvar) ((pvar) = __builtin_saveregs ())
#else
#define va_start(pvar) ((pvar) = * (__gnuc_va_list *) __builtin_saveregs ())
#endif
#else /* STDARG.H */
/* ANSI alternative. */
/* Call __builtin_next_arg even though we aren't using its value, so that
we can verify that firstarg is correct. */
#ifdef __VMS__
#define va_start(pvar, firstarg) \
(__builtin_next_arg (firstarg), \
(pvar) = __builtin_saveregs ())
#else
#define va_start(pvar, firstarg) \
(__builtin_next_arg (firstarg), \
(pvar) = *(__gnuc_va_list *) __builtin_saveregs ())
#endif
#endif /* _STDARG_H */
#define va_end(__va) ((void) 0)
/* Values returned by __builtin_classify_type. */
enum {
__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
};
/* Note that parameters are always aligned at least to a word boundary
(when passed) regardless of what GCC's __alignof__ operator says. */
/* Avoid errors if compiling GCC v2 with GCC v1. */
#if __GNUC__ == 1
#define __extension__
#endif
/* Get the size of a type in bytes, rounded up to an integral number
of words. */
#define __va_tsize(__type) \
(((sizeof (__type) + __extension__ sizeof (long long) - 1) \
/ __extension__ sizeof (long long)) * __extension__ sizeof (long long))
#ifdef __VMS__
#define va_arg(__va, __type) \
(*(((__va) += __va_tsize (__type)), \
(__type *)(void *)((__va) - __va_tsize (__type))))
#else
#define va_arg(__va, __type) \
(*(((__va).__offset += __va_tsize (__type)), \
(__type *)(void *)((__va).__base + (__va).__offset \
- (((__builtin_classify_type (* (__type *) 0) \
== __real_type_class) && (__va).__offset <= (6 * 8)) \
? (6 * 8) + 8 : __va_tsize (__type)))))
#endif
/* Copy __gnuc_va_list into another variable of this type. */
#define __va_copy(dest, src) (dest) = (src)
#endif /* __GNUC_VA_LIST_1 */
+47
View File
@@ -0,0 +1,47 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_ARCH_CPU_H
#define _KERNEL_ARCH_CPU_H
#include <kernel.h>
#include <ktypes.h>
#include <stage2.h>
#define PAGE_ALIGN(x) (((x) + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1))
#ifdef __cplusplus
extern "C" {
#endif
/*
int atomic_add(volatile int *val, int incr);
int atomic_and(volatile int *val, int incr);
int atomic_or(volatile int *val, int incr);
int atomic_set(volatile int *val, int set_to);
int test_and_set(int *val, int set_to, int test_val);
*/
bigtime_t system_time(void);
int arch_cpu_preboot_init(kernel_args *ka);
int arch_cpu_init(kernel_args *ka);
int arch_cpu_init2(kernel_args *ka);
void reboot(void);
#ifdef __cplusplus
}
#endif
void arch_cpu_invalidate_TLB_range(addr start, addr end);
void arch_cpu_invalidate_TLB_list(addr pages[], int num_pages);
void arch_cpu_global_TLB_invalidate(void);
int arch_cpu_user_memcpy(void *to, const void *from, size_t size, addr *fault_handler);
int arch_cpu_user_strcpy(char *to, const char *from, addr *fault_handler);
int arch_cpu_user_strncpy(char *to, const char *from, size_t size, addr *fault_handler);
int arch_cpu_user_memset(void *s, char c, size_t count, addr *fault_handler);
#include <arch_cpu.h>
#endif /* _KERNEL_ARCH_CPU_H */
+16
View File
@@ -0,0 +1,16 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_DBG_CONSOLE
#define _NEWOS_KERNEL_ARCH_DBG_CONSOLE
#include <stage2.h>
char arch_dbg_con_read(void);
char arch_dbg_con_putch(char c);
void arch_dbg_con_puts(const char *s);
int arch_dbg_con_init(kernel_args *ka);
#endif
+9
View File
@@ -0,0 +1,9 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_DEBUG
#define _NEWOS_KERNEL_ARCH_DEBUG
#endif
+14
View File
@@ -0,0 +1,14 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_FAULTS
#define _NEWOS_KERNEL_ARCH_FAULTS
#include <stage2.h>
int faults_init(kernel_args *ka);
int arch_faults_init(kernel_args *ka);
#endif
+22
View File
@@ -0,0 +1,22 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_INT_H
#define _NEWOS_KERNEL_ARCH_INT_H
#include <ktypes.h>
#include <stage2.h>
int arch_int_init(kernel_args *ka);
int arch_int_init2(kernel_args *ka);
void arch_int_enable_interrupts(void);
int arch_int_disable_interrupts(void);
void arch_int_restore_interrupts(int oldstate);
void arch_int_enable_io_interrupt(int irq);
void arch_int_disable_io_interrupt(int irq);
bool arch_int_is_interrupts_enabled(void);
#endif
+11
View File
@@ -0,0 +1,11 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _PPC_CPU_H
#define _PPC_CPU_H
#define PAGE_SIZE 4096
#endif
+28
View File
@@ -0,0 +1,28 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _PPC_KERNEL_H
#define _PPC_KERNEL_H
// memory layout
#define KERNEL_BASE 0x80000000
#define KERNEL_SIZE 0x80000000
#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 0x100000
#define USER_SIZE (0x80000000 - (0x10000 + 0x100000))
#define USER_TOP (USER_BASE + USER_SIZE)
#define USER_STACK_REGION 0x70000000
#define USER_STACK_REGION_SIZE (USER_BASE + (USER_SIZE - USER_STACK_REGION))
#endif
+11
View File
@@ -0,0 +1,11 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _PPC_KTYPES_H
#define _PPC_KTYPES_H
typedef unsigned long addr;
#endif
+19
View File
@@ -0,0 +1,19 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _PPC_STAGE2_H
#define _PPC_STAGE2_H
#include <boot/stage2_struct.h>
// kernel args
typedef struct {
// architecture specific
addr_range page_table; // maps where the page table is located, in physical memory
addr_range framebuffer; // maps where the framebuffer is located, in physical memory
int screen_x, screen_y, screen_depth;
} arch_kernel_args;
#endif
@@ -0,0 +1,43 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _STAGE2_PRIV_H
#define _STAGE2_PRIV_H
#define LOAD_ADDR 0x100000
#define BOOTDIR_ADDR 0x101000
int s2_text_init();
void s2_change_framebuffer_addr(unsigned int address);
void putchar(char c);
void puts(char *str);
int printf(const char *fmt, ...);
int of_init(void *of_entry);
int of_open(const char *node_name);
int of_finddevice(const char *dev);
int of_instance_to_package(int in_handle);
int of_getprop(int handle, const char *prop, void *buf, int buf_len);
int of_setprop(int handle, const char *prop, const void *buf, int buf_len);
int of_read(int handle, void *buf, int buf_len);
int of_write(int handle, void *buf, int buf_len);
int of_seek(int handle, long long pos);
int s2_mmu_init();
void mmu_map_page(unsigned int vsid, unsigned long pa, unsigned long va);;
void syncicache(void *address, int len);
void s2_faults_init(kernel_args *ka);
void getibats(int bats[8]);
void setibats(int bats[8]);
void getdbats(int bats[8]);
void setdbats(int bats[8]);
unsigned int *getsdr1();
void setsdr1(unsigned int sdr);
unsigned int getsr(int sr);
unsigned int getmsr();
void setmsr(unsigned int msr);
#endif
@@ -0,0 +1,18 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _PPC_THREAD_STRUCT_H
#define _PPC_THREAD_STRUCT_H
// architecture specific thread info
struct arch_thread {
// stack pointer
};
struct arch_proc {
// nothing here
};
#endif
+18
View File
@@ -0,0 +1,18 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _PPC_TYPES_H
#define _PPC_TYPES_H
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
+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
+19
View File
@@ -0,0 +1,19 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_SMP_H
#define _NEWOS_KERNEL_ARCH_SMP_H
#include <kernel.h>
#include <stage2.h>
// must match MAX_BOOT_CPUS in stage2.h
#define SMP_MAX_CPUS MAX_BOOT_CPUS
int arch_smp_init(kernel_args *ka);
void arch_smp_send_ici(int target_cpu);
void arch_smp_send_broadcast_ici(void);
#endif
+44
View File
@@ -0,0 +1,44 @@
/* $OpenBSD: DEFS.h,v 1.2 1997/11/07 15:57:30 niklas Exp $ */
/* $NetBSD: DEFS.h,v 1.2 1994/10/26 06:39:51 cgd Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)DEFS.h 8.1 (Berkeley) 6/4/93
*/
#include <machine/asm.h>
+11
View File
@@ -0,0 +1,11 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SPARC64_CPU_H
#define _SPARC64_CPU_H
#define PAGE_SIZE 8192
#endif
@@ -0,0 +1,15 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SPARC64_KERNEL_H
#define _SPARC64_KERNEL_H
// memory layout
#define KERNEL_BASE 0x80000000
#define KERNEL_SIZE 0x80000000
#define USER_BASE 0x00000000
#define USER_SIZE 0x80000000
#endif
@@ -0,0 +1,11 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SPARC64_KTYPES_H
#define _SPARC64_KTYPES_H
typedef unsigned long addr;
#endif
@@ -0,0 +1,86 @@
/* $OpenBSD: promdev.h,v 1.1 1997/09/17 10:46:19 downsj Exp $ */
/* $NetBSD: promdev.h,v 1.3 1995/09/18 21:31:50 pk Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Paul Kranenburg.
* 4. 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.
*/
#include <machine/bsd_openprom.h>
struct promdata {
int fd; /* Openboot descriptor */
struct saioreq *si; /* Oldmon IO request */
int devtype; /* Kind of device we're booting from */
#define DT_BLOCK 1
#define DT_NET 2
#define DT_BYTE 3
/* Hooks for netif.c */
int (*xmit) __P((struct promdata *, void *, size_t));
int (*recv) __P((struct promdata *, void *, size_t));
};
#define LOADADDR ((caddr_t)0x4000)
#define DDB_MAGIC0 ( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('0') )
#define DDB_MAGIC1 ( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('1') )
#define DDB_MAGIC DDB_MAGIC0
extern struct promvec *promvec;
extern char *prom_bootdevice;
extern char *prom_bootfile;
extern int prom_boothow;
extern int hz;
extern int cputyp, nbpg, pgofset, pgshift;
extern int debug;
extern void prom_init __P((void));
/* Note: dvma_*() routines are for "oldmon" machines only */
extern char *dvma_mapin __P((char *, size_t));
extern char *dvma_mapout __P((char *, size_t));
extern char *dvma_alloc __P((int));
/*
* duplicates from pmap.c for mapping device on "oldmon" machines.
*/
#include <sparc/asm.h>
#define getcontext() lduba(AC_CONTEXT, ASI_CONTROL)
#define setcontext(c) stba(AC_CONTEXT, ASI_CONTROL, c)
#define getsegmap(va) (cputyp == CPU_SUN4C \
? lduba(va, ASI_SEGMAP) \
: lduha(va, ASI_SEGMAP))
#define setsegmap(va, pmeg) (cputyp == CPU_SUN4C \
? stba(va, ASI_SEGMAP, pmeg) \
: stha(va, ASI_SEGMAP, pmeg))
#define getregmap(va) ((unsigned)lduha(va+2, ASI_REGMAP) >> 8)
#define setregmap(va, smeg) stha(va+2, ASI_REGMAP, (smeg << 8))
#define getpte(va) lda(va, ASI_PTE)
#define setpte(va, pte) sta(va, ASI_PTE, pte)
@@ -0,0 +1,59 @@
/* $OpenBSD: saerrno.h,v 1.4 1996/10/29 08:00:58 mickey Exp $ */
/* $NetBSD: saerrno.h,v 1.6 1995/09/18 21:19:45 pk Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)saerrno.h 8.1 (Berkeley) 6/11/93
*/
#include <sys/errno.h>
extern int errno;
/* special stand error codes */
#define EADAPT (ELAST+1) /* bad adaptor */
#define ECTLR (ELAST+2) /* bad controller */
#define EUNIT (ELAST+3) /* bad drive */
#define EPART (ELAST+4) /* bad partition */
#define ERDLAB (ELAST+5) /* can't read disk label */
#define EUNLAB (ELAST+6) /* unlabeled disk */
#define EOFFSET (ELAST+7) /* relative seek not supported */
#define ECMD (ELAST+8) /* undefined driver command */
#define EBSE (ELAST+9) /* bad sector error */
#define EWCK (ELAST+10) /* write check error */
#define EECC (ELAST+11) /* uncorrectable ecc error */
#define EHER (ELAST+12) /* hard error */
#define ESALAST (ELAST+12) /* */
char *strerror __P((int err));
@@ -0,0 +1,54 @@
/* $OpenBSD: saioctl.h,v 1.2 1996/09/23 14:19:04 mickey Exp $ */
/* $NetBSD: saioctl.h,v 1.2 1994/10/26 05:45:04 cgd Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)saioctl.h 8.1 (Berkeley) 6/11/93
*/
/* ioctl's -- for disks just now */
#define SAIOHDR (('d'<<8)|1) /* next i/o includes header */
#define SAIOCHECK (('d'<<8)|2) /* next i/o checks data */
#define SAIOHCHECK (('d'<<8)|3) /* next i/o checks header & data */
#define SAIONOBAD (('d'<<8)|4) /* inhibit bad sector forwarding */
#define SAIODOBAD (('d'<<8)|5) /* enable bad sector forwarding */
#define SAIOECCLIM (('d'<<8)|6) /* set limit to ecc correction, bits */
#define SAIOECCUNL (('d'<<8)|7) /* use standard ecc procedures */
#define SAIORETRIES (('d'<<8)|8) /* set retry count for unit */
#define SAIODEVDATA (('d'<<8)|9) /* get pointer to pack label */
#define SAIOSSI (('d'<<8)|10) /* set skip sector inhibit */
#define SAIONOSSI (('d'<<8)|11) /* inhibit skip sector handling */
#define SAIOSSDEV (('d'<<8)|12) /* is device skip sector type? */
#define SAIODEBUG (('d'<<8)|13) /* enable/disable debugging */
#define SAIOGBADINFO (('d'<<8)|14) /* get bad-sector table */
+12
View File
@@ -0,0 +1,12 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SPARC_H
#define _SPARC_H
#define PAGE_SIZE 4096
#define PAGE_ALIGN(x) (((x) + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1))
#endif
@@ -0,0 +1,13 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
unsigned char sparcbootblock[] = {
1,3,1,7,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,60,0,56,0,0,0,0,0,0,0,0,0,0,3,0,
14,4,130,16,98,120,129,192,64,0,1,0,0,0,0,0,0,4,5,0,0,0,0,56,0,0,0,0,0,
10,5,0,0,0,0,56,0,16,0,0,0,17,7,0,0,0,0,56,0,16,0,0,0,24,9,0,0,0,0,56,0,
16,0,0,0,29,31,0,0,0,0,56,0,0,0,0,0,46,115,116,97,114,116,0,95,101,116,
101,120,116,0,95,101,100,97,116,97,0,95,101,110,100,0,115,112,97,114,99,
98,111,111,116,98,108,111,99,107,46,111,0
};
@@ -0,0 +1,31 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _STAGE2_H
#define _STAGE2_H
#include <boot.h>
// kernel args
struct kernel_args {
unsigned int cons_line;
unsigned int mem_size;
char *str;
const boot_entry *bootdir;
unsigned int bootdir_size;
unsigned int kernel_seg0_base;
unsigned int kernel_seg0_size;
unsigned int kernel_seg1_base;
unsigned int kernel_seg1_size;
unsigned int phys_alloc_range_low;
unsigned int phys_alloc_range_high;
unsigned int virt_alloc_range_low;
unsigned int virt_alloc_range_high;
unsigned int stack_start;
unsigned int stack_end;
// architecture specific
};
#endif
+215
View File
@@ -0,0 +1,215 @@
/* $OpenBSD: stand.h,v 1.35 1998/07/29 00:38:36 mickey Exp $ */
/* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)stand.h 8.1 (Berkeley) 6/11/93
*/
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/stat.h>
#ifdef __STDC__
#include <machine/stdarg.h>
#else
#include <machine/varargs.h>
#endif
#include "saioctl.h"
#include "saerrno.h"
#ifndef NULL
#define NULL 0
#endif
struct open_file;
/*
* Useful macros
*/
#define NENTS(x) sizeof(x)/sizeof(x[0])
/* don't define if libkern included */
#ifndef LIBKERN_INLINE
#define max(a,b) (((a)>(b))? (a) : (b))
#define min(a,b) (((a)>(b))? (b) : (a))
#endif
/*
* This structure is used to define file system operations in a file system
* independent way.
*/
struct fs_ops {
int (*open) __P((char *path, struct open_file *f));
int (*close) __P((struct open_file *f));
int (*read) __P((struct open_file *f, void *buf,
size_t size, size_t *resid));
int (*write) __P((struct open_file *f, void *buf,
size_t size, size_t *resid));
off_t (*seek) __P((struct open_file *f, off_t offset, int where));
int (*stat) __P((struct open_file *f, struct stat *sb));
int (*readdir) __P((struct open_file *f, char *));
};
extern struct fs_ops file_system[];
extern int nfsys;
/* where values for lseek(2) */
#define SEEK_SET 0 /* set file offset to offset */
#define SEEK_CUR 1 /* set file offset to current plus offset */
#define SEEK_END 2 /* set file offset to EOF plus offset */
/* Device switch */
struct devsw {
char *dv_name;
int (*dv_strategy) __P((void *devdata, int rw,
daddr_t blk, size_t size,
void *buf, size_t *rsize));
int (*dv_open) __P((struct open_file *f, ...));
int (*dv_close) __P((struct open_file *f));
int (*dv_ioctl) __P((struct open_file *f, u_long cmd, void *data));
};
extern struct devsw devsw[]; /* device array */
extern int ndevs; /* number of elements in devsw[] */
extern struct consdev constab[];
extern struct consdev *cn_tab;
struct open_file {
int f_flags; /* see F_* below */
struct devsw *f_dev; /* pointer to device operations */
void *f_devdata; /* device specific data */
struct fs_ops *f_ops; /* pointer to file system operations */
void *f_fsdata; /* file system specific data */
off_t f_offset; /* current file offset (F_RAW) */
};
#define SOPEN_MAX 4
extern struct open_file files[];
/* f_flags values */
#define F_READ 0x0001 /* file opened for reading */
#define F_WRITE 0x0002 /* file opened for writing */
#define F_RAW 0x0004 /* raw device open - no file system */
#define F_NODEV 0x0008 /* network open - no device */
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#define islower(c) ((c) >= 'a' && (c) <= 'z')
#define isalpha(c) (isupper(c)||islower(c))
#define tolower(c) (isupper(c)?((c) - 'A' + 'a'):(c))
#define toupper(c) (islower(c)?((c) - 'a' + 'A'):(c))
#define isspace(c) ((c) == ' ' || (c) == '\t')
#define isdigit(c) ((c) >= '0' && (c) <= '9')
#define btochs(b,c,h,s,nh,ns) \
c = (b) / ((nh) * (ns)); \
h = ((b) % ((nh) * (ns))) / (ns); \
s = ((b) % ((nh) * (ns))) % (ns);
void *alloc __P((u_int));
void *alloca __P((size_t));
void free __P((void *, u_int));
struct disklabel;
char *getdisklabel __P((const char *, struct disklabel *));
u_int dkcksum __P((struct disklabel *));
void printf __P((const char *, ...));
void sprintf __P((char *, const char *, ...));
void vprintf __P((const char *, _BSD_VA_LIST_));
void twiddle __P((void));
void gets __P((char *));
__dead void panic __P((const char *, ...)) __attribute__((noreturn));
__dead void _rtt __P((void)) __attribute__((noreturn));
#define bzero(s,n) ((void)memset((s),0,(n)))
#define bcmp(s1,s2,n) (memcmp((s2),(s1),(n)))
#define bcopy(s1,s2,n) ((void)memcpy((s2),(s1),(n)))
void *memcpy __P((void *, const void *, size_t));
int memcmp __P((const void *, const void*, size_t));
char *strncpy __P((char *, const char *, size_t));
char *strcpy __P((char *, const char *));
int strncmp __P((const char *, const char *, size_t));
size_t strlen __P((const char *));
long strtol __P((const char *, char **, int));
char *strchr __P((const char *, int));
void *memset __P((void *, int, size_t));
void exec __P((char *, void *, int));
void exit __P((void));
int open __P((const char *, int));
int close __P((int));
void closeall __P((void));
ssize_t read __P((int, void *, size_t));
ssize_t write __P((int, void *, size_t));
int stat __P((const char *path, struct stat *sb));
int fstat __P((int fd, struct stat *sb));
int opendir __P((char *));
int readdir __P((int, char *));
void closedir __P((int));
int nodev __P((void));
int noioctl __P((struct open_file *, u_long, void *));
void nullsys __P((void));
int null_open __P((char *path, struct open_file *f));
int null_close __P((struct open_file *f));
ssize_t null_read __P((struct open_file *f, void *buf,
size_t size, size_t *resid));
ssize_t null_write __P((struct open_file *f, void *buf,
size_t size, size_t *resid));
off_t null_seek __P((struct open_file *f, off_t offset, int where));
int null_stat __P((struct open_file *f, struct stat *sb));
int null_readdir __P((struct open_file *f, char *name));
char *ttyname __P((int)); /* match userland decl, but ignore !0 */
dev_t ttydev __P((char *));
void cninit __P((void));
int cnset __P((dev_t));
void cnputc __P((int));
int cngetc __P((void));
int cnischar __P((void));
int cnspeed __P((dev_t, int));
u_int sleep __P((u_int));
void usleep __P((u_int));
char *ctime __P((const time_t *));
void putchar __P((int));
int getchar __P((void));
#ifdef __INTERNAL_LIBSA_CREAD
int oopen __P((const char *, int));
int oclose __P((int));
ssize_t oread __P((int, void *, size_t));
off_t olseek __P((int, off_t, int));
#endif
/* Machine dependent functions */
int devopen __P((struct open_file *, const char *, char **));
void machdep_start __P((char *, int, char *, char *, char *));
time_t getsecs __P((void));
@@ -0,0 +1,18 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _SPARC64_THREAD_STRUCT_H
#define _SPARC64_THREAD_STRUCT_H
// architecture specific thread info
struct arch_thread {
addr sp;
};
struct arch_proc {
int foo;
};
#endif
+18
View File
@@ -0,0 +1,18 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _ALPHA_TYPES_H
#define _ALPHA_TYPES_H
typedef unsigned long uint64;
typedef long int64;
typedef unsigned int uint32;
typedef int int32;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned char uint8;
typedef char int8;
#endif
@@ -0,0 +1,166 @@
/* This is just like the default gvarargs.h
except for differences described below. */
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
#if ! defined (__svr4__) && ! defined (__linux__) && ! defined (__arch64__)
/* This has to be a char * to be compatible with Sun.
i.e., we have to pass a `va_list' to vsprintf. */
typedef char * __gnuc_va_list;
#else
/* This has to be a void * to be compatible with Sun svr4.
i.e., we have to pass a `va_list' to vsprintf. */
typedef void * __gnuc_va_list;
#endif
#endif /* not __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
/* Call __builtin_next_arg even though we aren't using its value, so that
we can verify that LASTARG is correct. */
#if defined (__GCC_NEW_VARARGS__) || defined (__arch64__)
#define va_start(AP, LASTARG) \
(__builtin_next_arg (LASTARG), AP = (char *) __builtin_saveregs ())
#else
#define va_start(AP, LASTARG) \
(__builtin_saveregs (), AP = ((char *) __builtin_next_arg (LASTARG)))
#endif
#else
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist;...
#if defined (__GCC_NEW_VARARGS__) || defined (__arch64__)
#define va_start(AP) ((AP) = (char *) __builtin_saveregs ())
#else
#define va_start(AP) \
(__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
#endif
#endif
#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)
/* Avoid errors if compiling GCC v2 with GCC v1. */
#if __GNUC__ == 1
#define __extension__
#endif
/* 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. */
#ifdef __arch64__
typedef unsigned int __ptrint __attribute__ ((__mode__ (__DI__)));
/* ??? TODO: little endian support */
#define va_arg(pvar, TYPE) \
__extension__ \
(*({int __type = __builtin_classify_type (* (TYPE *) 0); \
char * __result; \
if (__type == __real_type_class) /* float? */ \
{ \
if (__alignof__ (TYPE) == 16) \
(pvar) = (void *) (((__ptrint) (pvar) + 15) & -16); \
__result = (pvar); \
(pvar) = (char *) (pvar) + sizeof (TYPE); \
} \
else if (__type < __record_type_class) /* integer? */ \
{ \
(pvar) = (char *) (pvar) + 8; \
__result = (char *) (pvar) - sizeof (TYPE); \
} \
else /* aggregate object */ \
{ \
if (sizeof (TYPE) <= 8) \
{ \
__result = (pvar); \
(pvar) = (char *) (pvar) + 8; \
} \
else if (sizeof (TYPE) <= 16) \
{ \
if (__alignof__ (TYPE) == 16) \
(pvar) = (void *) (((__ptrint) (pvar) + 15) & -16); \
__result = (pvar); \
(pvar) = (char *) (pvar) + 16; \
} \
else \
{ \
__result = * (void **) (pvar); \
(pvar) = (char *) (pvar) + 8; \
} \
} \
(TYPE *) __result;}))
#else /* not __arch64__ */
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
/* We don't declare the union member `d' to have type TYPE
because that would lose in C++ if TYPE has a constructor. */
/* We cast to void * and then to TYPE * because this avoids
a warning about increasing the alignment requirement.
The casts to char * avoid warnings about invalid pointer arithmetic. */
#define va_arg(pvar,TYPE) \
__extension__ \
(*({((__builtin_classify_type (*(TYPE*) 0) >= __record_type_class \
|| (__builtin_classify_type (*(TYPE*) 0) == __real_type_class \
&& sizeof (TYPE) == 16)) \
? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \
*(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
: __va_rounded_size (TYPE) == 8 \
? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \
__u.__i[0] = ((int *) (void *) (pvar))[0]; \
__u.__i[1] = ((int *) (void *) (pvar))[1]; \
(pvar) = (char *)(pvar) + 8; \
(TYPE *) (void *) __u.__d; }) \
: ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \
((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));}))
#endif /* not __arch64__ */
/* Copy __gnuc_va_list into another variable of this type. */
#define __va_copy(dest, src) (dest) = (src)
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
+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_THREAD_H
#define _NEWOS_KERNEL_ARCH_THREAD_H
#include <thread.h>
int arch_proc_init_proc_struct(struct proc *p, bool kernel);
int arch_thread_init_thread_struct(struct thread *t);
void arch_thread_context_switch(struct thread *t_from, struct thread *t_to);
int arch_thread_initialize_kthread_stack(struct thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void));
void arch_thread_dump_info(void *info);
void arch_thread_enter_uspace(addr entry, void *args, addr ustack_top);
void arch_thread_switch_kstack_and_call(struct thread *t, addr new_kstack, void (*func)(void *), void *arg);
struct thread *arch_thread_get_current_thread(void);
void arch_thread_set_current_thread(struct thread *t);
// for any inline overrides
#include <arch_thread.h>
#endif
@@ -0,0 +1,31 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_THREAD_STRUCT_H
#define _NEWOS_KERNEL_ARCH_THREAD_STRUCT_H
#ifdef ARCH_x86
#include <arch/x86/thread_struct.h>
#endif
#ifdef ARCH_sh4
#include <arch/sh4/thread_struct.h>
#endif
#ifdef ARCH_alpha
#include <arch/alpha/thread_struct.h>
#endif
#ifdef ARCH_sparc64
#include <arch/sparc64/thread_struct.h>
#endif
#ifdef ARCH_mips
#include <arch/mips/thread_struct.h>
#endif
#ifdef ARCH_ppc
#include <arch/ppc/thread_struct.h>
#endif
#ifdef ARCH_m68k
#include <arch/m68k/thread_struct.h>
#endif
#endif
+15
View File
@@ -0,0 +1,15 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_TIMER_H
#define _NEWOS_KERNEL_ARCH_TIMER_H
#include <stage2.h>
void arch_timer_set_hardware_timer(bigtime_t timeout);
void arch_timer_clear_hardware_timer(void);
int arch_init_timer(kernel_args *ka);
#endif
+17
View File
@@ -0,0 +1,17 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_VM_H
#define _NEWOS_KERNEL_ARCH_VM_H
#include <stage2.h>
#include <vm.h>
int arch_vm_init(kernel_args *ka);
int arch_vm_init2(kernel_args *ka);
int arch_vm_init_endvm(kernel_args *ka);
void arch_vm_aspace_swap(vm_address_space *aspace);
#endif
@@ -0,0 +1,48 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_VM_TRANSLATION_MAP_H
#define _NEWOS_KERNEL_ARCH_VM_TRANSLATION_MAP_H
#include <kernel.h>
#include <stage2.h>
#include <lock.h>
typedef struct vm_translation_map_struct {
struct vm_translation_map_struct *next;
struct vm_translation_map_ops_struct *ops;
recursive_lock lock;
int map_count;
struct vm_translation_map_arch_info_struct *arch_data;
} vm_translation_map;
// table of operations the vm may want to do to this mapping
typedef struct vm_translation_map_ops_struct {
void (*destroy)(vm_translation_map *);
int (*lock)(vm_translation_map*);
int (*unlock)(vm_translation_map*);
int (*map)(vm_translation_map *map, addr va, addr pa, unsigned int attributes);
int (*unmap)(vm_translation_map *map, addr start, addr end);
int (*query)(vm_translation_map *map, addr va, addr *out_physical, unsigned int *out_flags);
addr (*get_mapped_size)(vm_translation_map*);
int (*protect)(vm_translation_map *map, addr base, addr top, unsigned int attributes);
int (*clear_flags)(vm_translation_map *map, addr va, unsigned int flags);
void (*flush)(vm_translation_map *map);
int (*get_physical_page)(addr physical_address, addr *out_virtual_address, int flags);
int (*put_physical_page)(addr virtual_address);
} vm_translation_map_ops;
int vm_translation_map_create(vm_translation_map *new_map, bool kernel);
int vm_translation_map_module_init(kernel_args *ka);
int vm_translation_map_module_init2(kernel_args *ka);
void vm_translation_map_module_init_post_sem(kernel_args *ka);
// quick function to map a page in regardless of map context. Used in VM initialization,
// before most vm data structures exist
int vm_translation_map_quick_map(kernel_args *ka, addr va, addr pa, unsigned int attributes, addr (*get_free_page)(kernel_args *));
// quick function to return the physical pgdir of a mapping, needed for a context switch
addr vm_translation_map_get_pgdir(vm_translation_map *map);
#endif
+151
View File
@@ -0,0 +1,151 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_ARCH_x86_CPU_H
#define _KERNEL_ARCH_x86_CPU_H
/* ??? why include this as we're normally included from that file! */
#include <arch/cpu.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
#define _LITTLE_ENDIAN 1
typedef struct desc_struct {
unsigned int a,b;
} desc_table;
struct tss {
uint16 prev_task;
uint16 unused0;
uint32 sp0;
uint32 ss0;
uint32 sp1;
uint32 ss1;
uint32 sp2;
uint32 ss2;
uint32 sp3;
uint32 ss3;
uint32 cr3;
uint32 eip, eflags, eax, ecx, edx, ebx, esp, ebp, esi, edi;
uint32 es, cs, ss, ds, fs, gs;
uint32 ldt_seg_selector;
uint16 unused1;
uint16 io_map_base;
};
struct tss_descriptor {
uint16 limit_00_15;
uint16 base_00_15;
uint32 base_23_16 : 8;
uint32 type : 4;
uint32 zero : 1;
uint32 dpl : 2;
uint32 present : 1;
uint32 limit_19_16 : 4;
uint32 avail : 1;
uint32 zero1 : 1;
uint32 zero2 : 1;
uint32 granularity : 1;
uint32 base_31_24 : 8;
};
typedef struct ptentry {
unsigned int present:1;
unsigned int rw:1;
unsigned int user:1;
unsigned int write_through:1;
unsigned int cache_disabled:1;
unsigned int accessed:1;
unsigned int dirty:1;
unsigned int reserved:1;
unsigned int global:1;
unsigned int avail:3;
unsigned int addr:20;
} ptentry;
typedef struct pdentry {
unsigned int present:1;
unsigned int rw:1;
unsigned int user:1;
unsigned int write_through:1;
unsigned int cache_disabled:1;
unsigned int accessed:1;
unsigned int reserved:1;
unsigned int page_size:1;
unsigned int global:1;
unsigned int avail:3;
unsigned int addr:20;
} 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_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);
void i386_swap_pgdir(addr new_pgdir);
void i386_fsave_swap(void *old_fpu_state, void *new_fpu_state);
void i386_fxsave_swap(void *old_fpu_state, void *new_fpu_state);
#define read_dr3(value) \
__asm__("movl %%dr3,%0" : "=r" (value))
#define write_dr3(value) \
__asm__("movl %0,%%dr3" :: "r" (value))
#define invalidate_TLB(va) \
__asm__("invlpg (%0)" : : "r" (va))
#define out8(value,port) \
__asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
#define out16(value,port) \
__asm__ ("outw %%ax,%%dx"::"a" (value),"d" (port))
#define out32(value,port) \
__asm__ ("outl %%eax,%%dx"::"a" (value),"d" (port))
#define in8(port) ({ \
unsigned char _v; \
__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
_v; \
})
#define in16(port) ({ \
unsigned short _v; \
__asm__ volatile ("inw %%dx,%%ax":"=a" (_v):"d" (port)); \
_v; \
})
#define in32(port) ({ \
unsigned int _v; \
__asm__ volatile ("inl %%dx,%%eax":"=a" (_v):"d" (port)); \
_v; \
})
#define out8_p(value,port) \
__asm__ ("outb %%al,%%dx\n" \
"\tjmp 1f\n" \
"1:\tjmp 1f\n" \
"1:"::"a" (value),"d" (port))
#define in8_p(port) ({ \
unsigned char _v; \
__asm__ volatile ("inb %%dx,%%al\n" \
"\tjmp 1f\n" \
"1:\tjmp 1f\n" \
"1:":"=a" (_v):"d" (port)); \
_v; \
})
#endif
@@ -0,0 +1,30 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_ARCH_x86_KERNEL_H
#define _KERNEL_ARCH_x86_KERNEL_H
#include <arch/cpu.h>
// memory layout
#define KERNEL_BASE 0x80000000
#define KERNEL_SIZE 0x80000000
#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 0x100000
#define USER_SIZE (0x80000000 - (0x10000 + 0x100000))
#define USER_TOP (USER_BASE + USER_SIZE)
#define USER_STACK_REGION 0x70000000
#define USER_STACK_REGION_SIZE (USER_BASE + (USER_SIZE - USER_STACK_REGION))
#endif /* _KERNEL_ARCH_x86_KERNEL_H */
@@ -0,0 +1,38 @@
/*
** 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
#include <stage2_struct.h>
#define MAX_BOOT_PTABLES 4
// kernel args
typedef struct {
// architecture specific
unsigned int system_time_cv_factor;
unsigned int phys_pgdir;
unsigned int vir_pgdir;
unsigned int num_pgtables;
unsigned int pgtables[MAX_BOOT_PTABLES];
unsigned int phys_idt;
unsigned int vir_idt;
unsigned int phys_gdt;
unsigned int vir_gdt;
unsigned int page_hole;
// smp stuff
unsigned int apic_time_cv_factor; // apic ticks per second
unsigned int apic_phys;
unsigned int *apic;
unsigned int ioapic_phys;
unsigned int *ioapic;
unsigned int cpu_apic_id[MAX_BOOT_CPUS];
unsigned int cpu_os_id[MAX_BOOT_CPUS];
unsigned int cpu_apic_version[MAX_BOOT_CPUS];
} arch_kernel_args;
#endif
@@ -0,0 +1,29 @@
/*
** Copyright 2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_ARCH_x86_THREAD_H
#define _KERNEL_ARCH_x86_THREAD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <arch/cpu.h>
extern inline struct thread *arch_thread_get_current_thread(void) {
struct thread *t;
read_dr3(t);
return t;
}
extern inline void arch_thread_set_current_thread(struct thread *t) {
write_dr3(t);
}
#ifdef __cplusplus
}
#endif
#endif /* _KERNEL_ARCH_x86_THREAD_H */
+16
View File
@@ -0,0 +1,16 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _CONSOLE_DEV_H
#define _CONSOLE_DEV_H
#include <stage2.h>
int console_dev_init(kernel_args *ka);
enum {
CONSOLE_OP_WRITEXY = 2376
};
#endif
+12
View File
@@ -0,0 +1,12 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_I386_FAULTS
#define _NEWOS_KERNEL_ARCH_I386_FAULTS
int i386_general_protection_fault(int errorcode);
int i386_double_fault(int errorcode);
#endif
+9
View File
@@ -0,0 +1,9 @@
#ifndef _IDE_BUS_H
#define _IDE_BUS_H
#include <stage2.h>
int ide_bus_init(kernel_args *ka);
#endif
+100
View File
@@ -0,0 +1,100 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Modified Sep 2001 by Rob Judd <[email protected]>
** Distributed under the terms of the NewOS License.
*/
#ifndef __IDE_PRIVATE_H__
#define __IDE_PRIVATE_H__
#include <types.h>
#include "partition.h"
typedef struct
{
unsigned short config; /* obsolete stuff */
unsigned short cyls; /* logical cylinders */
unsigned short _reserved_2;
unsigned short heads; /* logical heads */
unsigned short _vendor_4; /* bytes per track unformatted */
unsigned short _vendor_5; /* sectors per track unformatted */
unsigned short sectors; /* logical sectors */
unsigned short _vendor_7;
unsigned short _vendor_8;
unsigned short _vendor_9;
char serial[20]; //40 /* serial number */
unsigned short _vendor_20;
unsigned short _vendor_21;
unsigned short vend_bytes_long; /* number of ECC bytes on long cmd */
char firmware[8]; /* firmware revision */
char model[40]; //94 /* model name */
unsigned short mult_support; /* vendor stuff and multiple cmds */
unsigned short _reserved_48; /* bit 0: double word i/o possible */
unsigned short capabilities; /* bit 9: LBA; bit 8: DMA support */
unsigned short _reserved_50;
unsigned short pio; /* bit 15-8: timing mode for PIO */
unsigned short dma; /* bit 15-8: timing mode for DMA */
unsigned short _reserved_53;
unsigned short curr_cyls; /* current logical cylinders */
unsigned short curr_heads; /* current logical heads */
unsigned short curr_sectors; /* current logical sectors */
unsigned long capacity; //118 /* apparent capacity in sectors */
unsigned short _pad[511-59]; /* don't need this stuff for now */
} ide_hw_id_t;
#define IDE_MAGIC_COOKIE 0xABCDEF10
#define IDE_MAGIC_COOKIE2 0x12345678
#define NO_DEVICE -1
#define UNKNOWN_DEVICE 0
#define ATA_DEVICE 1
#define ATAPI_DEVICE 2
#define IDE_NAME 40
typedef struct s_ide_device
{
uint32 magic;
ide_hw_id_t hardware_device;
uint32 magic2;
int iobase;
int bus;
int device;
int device_type;
uint32 sector_count;
int bytes_per_sector;
int lba_supported;
int start_block;
int end_block;
tPartition partitions[8]; // 4 Primary + 4 Extended
} ide_device;
#define MAX_IDE_BUSES 2
#define MAX_DEVICES 4
extern ide_device devices[MAX_DEVICES];
#define DISK_GET_GEOMETRY 1
#define DISK_USE_DMA 2
#define DISK_USE_BUS_MASTERING 3
#define DISK_USE_PIO 4
#define DISK_GET_ACCOUSTIC_LEVEL 5
#define DISK_SET_ACCOUSTIC_LEVEL 6
typedef struct s_drive_geometry
{
uint32 blocks;
uint32 heads;
uint32 cylinders;
uint32 sectors;
int removable;
uint32 bytes_per_sector;
int read_only;
char model[40];
char serial[20];
char firmware[8];
} drive_geometry;
#endif
+31
View File
@@ -0,0 +1,31 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Modified Sep 2001 by Rob Judd <[email protected]>
** Distributed under the terms of the NewOS License.
*/
#ifndef __IDE_RAW_H__
#define __IDE_RAW_H__
#include "ide_private.h"
#define NO_ERR 0
#define ERR_TIMEOUT 1
#define ERR_HARDWARE_ERROR 2
#define ERR_DRQ_NOT_SET 3
#define ERR_DISK_BUSY 4
#define ERR_DEVICE_FAULT 5
#define ERR_BUFFER_NOT_EMPTY 6
int ide_read_block(ide_device *device, char *buffer, uint32 block, uint8 numSectors);
int ide_write_block(ide_device *device, const char *buffer, uint32 block, uint8 numSectors);
int ide_base (int bus);
void ide_string_conv (char *str, int len);
int ide_reset (int bus, int device);
bool ide_identify_device (int bus, int device);
void ide_raw_init(int base1, int base2);
bool ide_get_partitions(ide_device *device);
int ide_get_accoustic(ide_device *device, int8* level_ptr);
int ide_set_accoustic(ide_device *device, int8 level);
#endif
+19
View File
@@ -0,0 +1,19 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_I386_INTERRUPTS_H
#define _NEWOS_KERNEL_ARCH_I386_INTERRUPTS_H
void trap0();void trap1();void trap2();void trap3();void trap4();void trap5();
void trap6();void trap7();void trap8();void trap9();void trap10();void trap11();
void trap12();void trap13();void trap14();void trap16();void trap17();void trap18();
void trap32();void trap33();void trap34();void trap35();void trap36();void trap37();
void trap38();void trap39();void trap40();void trap41();void trap42();void trap43();
void trap44();void trap45();void trap46();void trap47();
void trap99();
void trap251();void trap252();void trap253();void trap254();void trap255();
#endif
+9
View File
@@ -0,0 +1,9 @@
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
#include <stage2.h>
int keyboard_dev_init(kernel_args *ka);
#endif
+84
View File
@@ -0,0 +1,84 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef __PARTITION_H
#define __PARTITION_H
#define PARTITION_MAGIC1 0x55
#define PARTITION_MAGIC2 0xaa
#define PART_MAGIC_OFFSET 0x01fe
#define PARTITION_OFFSET 0x01be
#define NUM_PARTITIONS 4
#define PTCHSToLBA(c, h, s, scnt, hcnt) ((s) & 0x3f) + \
(scnt) * ( (h) + (hcnt) * ((c) | (((s) & 0xc0) << 2)))
#define PTLBAToCHS(lba, c, h, s, scnt, hcnt) ( \
(s) = (lba) % (scnt) + 1, \
(lba) /= (scnt), \
(h) = (lba) % (hcnt), \
(lba) /= (heads), \
(c) = (lba) & 0xff, \
(s) |= ((lba) >> 2) & 0xc0)
/* taken from linux fdisk src */
typedef enum PartitionTypes
{
PTEmpty = 0,
PTDOS3xPrimary, /* 1 */
PTXENIXRoot, /* 2 */
PTXENIXUsr, /* 3 */
PTOLDDOS16Bit, /* 4 */
PTDosExtended, /* 5 */
PTDos5xPrimary, /* 6 */
PTOS2HPFS, /* 7 */
PTAIX, /* 8 */
PTAIXBootable, /* 9 */
PTOS2BootMgr, /* 10 */
PTWin95FAT32,
PTWin95FAT32LBA,
PTWin95FAT16LBA,
PTWin95ExtendedLBA,
PTVenix286 = 0x40,
PTNovell = 0x51,
PTMicroport = 0x52,
PTGnuHurd = 0x63,
PTNetware286 = 0x64,
PTNetware386 = 0x65,
PTPCIX = 0x75,
PTOldMinix = 0x80,
PTMinix = 0x81,
PTLinuxSwap = 0x82,
PTLinuxExt2 = 0x83,
PTAmoeba = 0x93,
PTAmoebaBBT = 0x94,
PTBSD = 0xa5,
PTBSDIFS = 0xb7,
PTBSDISwap = 0xb8,
PTSyrinx = 0xc7,
PTCPM = 0xdb,
PTDOSAccess = 0xe1,
PTDOSRO = 0xe3,
PTDOSSecondary = 0xf2,
PTBBT = 0xff
} partitionTypes;
#define PartitionIsExtended(P) ((P)->PartitionType == PTDosExtended)
typedef struct sPartition
{
unsigned char boot_flags;
unsigned char starting_head;
unsigned char starting_sector;
unsigned char starting_cylinder;
unsigned char partition_type;
unsigned char ending_head;
unsigned char ending_sector;
unsigned char ending_cylinder;
unsigned int starting_block;
unsigned int sector_count;
} tPartition;
#endif
+106
View File
@@ -0,0 +1,106 @@
/*
* ps2mouse.c:
* PS/2 mouse device driver for NewOS and OpenBeOS.
* Author: Elad Lahav ([email protected])
* Created: 21.12.2001
* Modified: 11.1.2002
*/
/*
* A PS/2 mouse is connected to the IBM 8042 controller, and gets its
* name from the IBM PS/2 personal computer, which was the first to
* use this device. All resources are shared between the keyboard, and
* the mouse, referred to as the "Auxiliary Device".
* I/O:
* ~~~
* The controller has 3 I/O registers:
* 1. Status (input), mapped to port 64h
* 2. Control (output), mapped to port 64h
* 3. Data (input/output), mapped to port 60h
* Data:
* ~~~~
* Since a mouse is an input only device, data can only be read, and
* not written. A packet read from the mouse data port is composed of
* three bytes:
* byte 0: status byte, where
* - bit 0: Y overflow (1 = true)
* - bit 1: X overflow (1 = true)
* - bit 2: MSB of Y offset
* - bit 3: MSB of X offset
* - bit 4: Syncronization bit (always 1)
* - bit 5: Middle button (1 = down)
* - bit 6: Right button (1 = down)
* - bit 7: Left button (1 = down)
* byte 1: X position change, since last probed (-127 to +127)
* byte 2: Y position change, since last probed (-127 to +127)
* Interrupts:
* ~~~~~~~~~~
* The PS/2 mouse device is connected to interrupt 12, which means that
* it uses the second interrupt controller (handles INT8 to INT15). In
* order for this interrupt to be enabled, both the 5th interrupt of
* the second controller AND the 3rd interrupt of the first controller
* (cascade mode) should be unmasked.
* The controller uses 3 consecutive interrupts to inform the computer
* that it has new data. On the first the data register holds the status
* byte, on the second the X offset, and on the 3rd the Y offset.
*/
#ifndef _KERNEL_ARCH_x86_PS2MOUSE_H
#define _KERNEL_ARCH_x86_PS2MOUSE_H
#include <kernel.h>
#include <memheap.h>
#include <int.h>
#include <debug.h>
#include <devfs.h>
#include <arch/int.h>
#include <OS.h>
#include <string.h>
/////////////////////////////////////////////////////////////////////////
// definitions
// I/O addresses
#define PS2_PORT_DATA 0x60
#define PS2_PORT_CTRL 0x64
// control words
#define PS2_CTRL_WRITE_CMD 0x60
#define PS2_CTRL_WRITE_AUX 0xD4
// data words
#define PS2_CMD_DEV_INIT 0x43
#define PS2_CMD_ENABLE_MOUSE 0xF4
#define PS2_CMD_DISABLE_MOUSE 0xF5
#define PS2_CMD_RESET_MOUSE 0xFF
#define PS2_RES_ACK 0xFA
#define PS2_RES_RESEND 0xFE
// interrupts
#define INT_BASE 0x20
#define INT_PS2_MOUSE 0x0C
#define INT_CASCADE 0x02
#define PACKET_SIZE 3
/*
* mouse_data:
* Holds the data read from the PS/2 auxiliary device.
*/
typedef struct {
char status;
char delta_x;
char delta_y;
} mouse_data; // mouse_data
#ifdef _PS2MOUSE_
static mouse_data md_int;
static mouse_data md_read;
static sem_id mouse_sem;
static bool in_read;
#endif
int mouse_dev_init(kernel_args *ka);
#endif /* _KERNEL_ARCH_x86_PS2MOUSE_H */
+96
View File
@@ -0,0 +1,96 @@
/*
**
** 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_TXSTATUS1 0x14 /* Transmit status (4 32bit regs) */
#define RT_TXSTATUS2 0x18 /* Transmit status (4 32bit regs) */
#define RT_TXSTATUS3 0x1c /* Transmit status (4 32bit regs) */
#define RT_TXADDR0 0x20 /* Tx descriptors (also 4 32bit) */
#define RT_TXADDR1 0x24 /* Tx descriptors (also 4 32bit) */
#define RT_TXADDR2 0x28 /* Tx descriptors (also 4 32bit) */
#define RT_TXADDR3 0x2c /* 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 */
/* Realtek PCI vendor ID */
#define RT_VENDORID 0x10EC
/* Realtek Device ID */
#define RT_DEVICEID_8139 0x8139
#endif
+37
View File
@@ -0,0 +1,37 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _RTL8139_PRIV_H
#define _RTL8139_PRIV_H
#include <kernel.h>
#include <vm.h>
#include <smp.h>
typedef struct rtl8139 {
int irq;
addr phys_base;
addr phys_size;
addr virt_base;
uint16 io_port;
region_id region;
uint8 mac_addr[6];
int txbn;
int last_txbn;
region_id rxbuf_region;
addr rxbuf;
sem_id rx_sem;
region_id txbuf_region;
addr txbuf;
sem_id tx_sem;
mutex lock;
spinlock_t reg_spinlock;
} rtl8139;
int rtl8139_detect(rtl8139 **rtl);
int rtl8139_init(rtl8139 *rtl);
void rtl8139_xmit(rtl8139 *rtl, const char *ptr, ssize_t len);
ssize_t rtl8139_rx(rtl8139 *rtl, char *buf, ssize_t buf_len);
#endif
+161
View File
@@ -0,0 +1,161 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_I386_SMP_PRIV_H
#define _NEWOS_KERNEL_ARCH_I386_SMP_PRIV_H
int i386_smp_interrupt(int vector);
void arch_smp_ack_interrupt(void);
int arch_smp_set_apic_timer(bigtime_t relative_timeout);
int arch_smp_clear_apic_timer(void);
int smp_intercpu_int_handler(void);
#define MP_FLT_SIGNATURE '_PM_'
#define MP_CTH_SIGNATURE 'PCMP'
#define APIC_DM_INIT (5 << 8)
#define APIC_DM_STARTUP (6 << 8)
#define APIC_LEVEL_TRIG (1 << 14)
#define APIC_ASSERT (1 << 13)
#define APIC_ENABLE 0x100
#define APIC_FOCUS (~(1 << 9))
#define APIC_SIV (0xff)
#define APIC_ID ((unsigned int *) ((unsigned int) apic + 0x020))
#define APIC_VERSION ((unsigned int *) ((unsigned int) apic + 0x030))
#define APIC_TPRI ((unsigned int *) ((unsigned int) apic + 0x080))
#define APIC_EOI ((unsigned int *) ((unsigned int) apic + 0x0b0))
#define APIC_SIVR ((unsigned int *) ((unsigned int) apic + 0x0f0))
#define APIC_ESR ((unsigned int *) ((unsigned int) apic + 0x280))
#define APIC_ICR1 ((unsigned int *) ((unsigned int) apic + 0x300))
#define APIC_ICR2 ((unsigned int *) ((unsigned int) apic + 0x310))
#define APIC_LVTT ((unsigned int *) ((unsigned int) apic + 0x320))
#define APIC_LINT0 ((unsigned int *) ((unsigned int) apic + 0x350))
#define APIC_LVT3 ((unsigned int *) ((unsigned int) apic + 0x370))
#define APIC_ICRT ((unsigned int *) ((unsigned int) apic + 0x380))
#define APIC_CCRT ((unsigned int *) ((unsigned int) apic + 0x390))
#define APIC_TDCR ((unsigned int *) ((unsigned int) apic + 0x3e0))
#define APIC_ICR1_WRITE_MASK 0xfff3f000
#define APIC_ICR1_DELMODE_FIXED 0
#define APIC_ICR1_DELMODE_LOWESTPRI (1 << 8)
#define APIC_ICR1_DESTMODE_LOG (1 << 11)
#define APIC_ICR1_DESTMODE_PHYS 0
#define APIC_ICR1_READ_MASK 0xfff32000
#define APIC_ICR1_DELSTATUS (1 << 12)
#define APIC_ICR1_DEST_FIELD (0)
#define APIC_ICR1_DEST_SELF (1 << 18)
#define APIC_ICR1_DEST_ALL (2 << 18)
#define APIC_ICR1_DEST_ALL_BUT_SELF (3 << 18)
#define APIC_ICR2_MASK 0x00ffffff
#define APIC_TDCR_2 0x00
#define APIC_TDCR_4 0x01
#define APIC_TDCR_8 0x02
#define APIC_TDCR_16 0x03
#define APIC_TDCR_32 0x08
#define APIC_TDCR_64 0x09
#define APIC_TDCR_128 0x0a
#define APIC_TDCR_1 0x0b
#define APIC_LVTT_MASK 0x000310ff
#define APIC_LVTT_VECTOR 0x000000ff
#define APIC_LVTT_DS 0x00001000
#define APIC_LVTT_M 0x00010000
#define APIC_LVTT_TM 0x00020000
#define APIC_LVT_DM 0x00000700
#define APIC_LVT_IIPP 0x00002000
#define APIC_LVT_TM 0x00008000
#define APIC_LVT_M 0x00010000
#define APIC_LVT_OS 0x00020000
#define APIC_TPR_PRIO 0x000000ff
#define APIC_TPR_INT 0x000000f0
#define APIC_TPR_SUB 0x0000000f
#define APIC_SVR_SWEN 0x00000100
#define APIC_SVR_FOCUS 0x00000200
#define APIC_DEST_STARTUP 0x00600
#define LOPRIO_LEVEL 0x00000010
#define IOAPIC_ID 0x0
#define IOAPIC_VERSION 0x1
#define IOAPIC_ARB 0x2
#define IOAPIC_REDIR_TABLE 0x10
#define IPI_CACHE_FLUSH 0x40
#define IPI_INV_TLB 0x41
#define IPI_INV_PTE 0x42
#define IPI_INV_RESCHED 0x43
#define IPI_STOP 0x44
#define MP_EXT_PE 0
#define MP_EXT_BUS 1
#define MP_EXT_IO_APIC 2
#define MP_EXT_IO_INT 3
#define MP_EXT_LOCAL_INT 4
#define MP_EXT_PE_LEN 20
#define MP_EXT_BUS_LEN 8
#define MP_EXT_IO_APIC_LEN 8
#define MP_EXT_IO_INT_LEN 8
#define MP_EXT_LOCAL_INT_LEN 8
struct mp_config_table {
unsigned int signature; /* "PCMP" */
unsigned short table_len; /* length of this structure */
unsigned char mp_rev; /* spec supported, 1 for 1.1 or 4 for 1.4 */
unsigned char checksum; /* checksum, all bytes add up to zero */
char oem[8]; /* oem identification, not null-terminated */
char product[12]; /* product name, not null-terminated */
void *oem_table_ptr; /* addr of oem-defined table, zero if none */
unsigned short oem_len; /* length of oem table */
unsigned short num_entries; /* number of entries in base table */
unsigned int apic; /* address of apic */
unsigned short ext_len; /* length of extended section */
unsigned char ext_checksum; /* checksum of extended table entries */
};
struct mp_flt_struct {
unsigned int signature; /* "_MP_" */
struct mp_config_table *mpc; /* address of mp configuration table */
unsigned char mpc_len; /* length of this structure in 16-byte units */
unsigned char mp_rev; /* spec supported, 1 for 1.1 or 4 for 1.4 */
unsigned char checksum; /* checksum, all bytes add up to zero */
unsigned char mp_feature_1; /* mp system configuration type if no mpc */
unsigned char mp_feature_2; /* imcrp */
unsigned char mp_feature_3, mp_feature_4, mp_feature_5; /* reserved */
};
struct mp_ext_pe
{
unsigned char type;
unsigned char apic_id;
unsigned char apic_version;
unsigned char cpu_flags;
unsigned int signature; /* stepping, model, family, each four bits */
unsigned int feature_flags;
unsigned int res1, res2;
};
struct mp_ext_ioapic
{
unsigned char type;
unsigned char ioapic_id;
unsigned char ioapic_version;
unsigned char ioapic_flags;
unsigned int *addr;
};
#endif
+200
View File
@@ -0,0 +1,200 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _STAGE2_PRIV_H
#define _STAGE2_PRIV_H
#include <stage2.h>
extern void _start(unsigned int mem, int in_vesa, unsigned int vesa_ptr);
extern void clearscreen(void);
extern void kputs(const char *str);
extern int dprintf(const char *fmt, ...);
extern void sleep(long long time);
extern long long system_time(void);
extern void execute_n_instructions(int count);
void system_time_setup(long a);
long long rdtsc();
unsigned int get_eflags(void);
void set_eflags(unsigned int val);
void cpuid(unsigned int selector, unsigned int *data);
//void put_uint_dec(unsigned int a);
//void put_uint_hex(unsigned int a);
//void nmessage(const char *str1, unsigned int a, const char *str2);
//void nmessage2(const char *str1, unsigned int a, const char *str2, unsigned int b, const char *str3);
#define ROUNDUP(a, b) (((a) + ((b) - 1)) & (~((b) - 1)))
#define ROUNDOWN(a, b) (((a) / (b)) * (b))
#define PAGE_SIZE 0x1000
#define KERNEL_BASE 0x80000000
#define KERNEL_ENTRY 0x80000080
#define STACK_SIZE 2
#define DEFAULT_PAGE_FLAGS (1 | 2) // present/rw
#define SCREEN_WIDTH 80
#define SCREEN_HEIGHT 24
#define ADDR_MASK 0xfffff000
#define NULL ((void *)0)
#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);
extern void smp_trampoline_end(void);
#define MP_FLT_SIGNATURE '_PM_'
#define MP_CTH_SIGNATURE 'PCMP'
#define APIC_DM_INIT (5 << 8)
#define APIC_DM_STARTUP (6 << 8)
#define APIC_LEVEL_TRIG (1 << 14)
#define APIC_ASSERT (1 << 13)
#define APIC_ENABLE 0x100
#define APIC_FOCUS (~(1 << 9))
#define APIC_SIV (0xff)
#define APIC_ID ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x020))
#define APIC_VERSION ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x030))
#define APIC_TPRI ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x080))
#define APIC_EOI ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x0b0))
#define APIC_LDR ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x0d0))
#define APIC_SIVR ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x0f0))
#define APIC_ESR ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x280))
#define APIC_ICR1 ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x300))
#define APIC_ICR2 ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x310))
#define APIC_LVTT ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x320))
#define APIC_LINT0 ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x350))
#define APIC_LINT1 ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x360))
#define APIC_LVT3 ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x370))
#define APIC_ICRT ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x380))
#define APIC_CCRT ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x390))
#define APIC_TDCR ((unsigned int *) ((unsigned int) ka->arch_args.apic + 0x3e0))
#define APIC_TDCR_2 0x00
#define APIC_TDCR_4 0x01
#define APIC_TDCR_8 0x02
#define APIC_TDCR_16 0x03
#define APIC_TDCR_32 0x08
#define APIC_TDCR_64 0x09
#define APIC_TDCR_128 0x0a
#define APIC_TDCR_1 0x0b
#define APIC_LVTT_MASK 0x000310ff
#define APIC_LVTT_VECTOR 0x000000ff
#define APIC_LVTT_DS 0x00001000
#define APIC_LVTT_M 0x00010000
#define APIC_LVTT_TM 0x00020000
#define APIC_LVT_DM_ExtINT 0x00000700
#define APIC_LVT_DM_NMI 0x00000400
#define APIC_LVT_IIPP 0x00002000
#define APIC_LVT_TM 0x00008000
#define APIC_LVT_M 0x00010000
#define APIC_LVT_OS 0x00020000
#define APIC_TPR_PRIO 0x000000ff
#define APIC_TPR_INT 0x000000f0
#define APIC_TPR_SUB 0x0000000f
#define APIC_SVR_SWEN 0x00000100
#define APIC_SVR_FOCUS 0x00000200
#define APIC_DEST_STARTUP 0x00600
#define LOPRIO_LEVEL 0x00000010
#define APIC_DEST_FIELD (0)
#define APIC_DEST_SELF (1 << 18)
#define APIC_DEST_ALL (2 << 18)
#define APIC_DEST_ALL_BUT_SELF (3 << 18)
#define IOAPIC_ID 0x0
#define IOAPIC_VERSION 0x1
#define IOAPIC_ARB 0x2
#define IOAPIC_REDIR_TABLE 0x10
#define IPI_CACHE_FLUSH 0x40
#define IPI_INV_TLB 0x41
#define IPI_INV_PTE 0x42
#define IPI_INV_RESCHED 0x43
#define IPI_STOP 0x44
#define MP_EXT_PE 0
#define MP_EXT_BUS 1
#define MP_EXT_IO_APIC 2
#define MP_EXT_IO_INT 3
#define MP_EXT_LOCAL_INT 4
#define MP_EXT_PE_LEN 20
#define MP_EXT_BUS_LEN 8
#define MP_EXT_IO_APIC_LEN 8
#define MP_EXT_IO_INT_LEN 8
#define MP_EXT_LOCAL_INT_LEN 8
struct mp_config_table {
unsigned int signature; /* "PCMP" */
unsigned short table_len; /* length of this structure */
unsigned char mp_rev; /* spec supported, 1 for 1.1 or 4 for 1.4 */
unsigned char checksum; /* checksum, all bytes add up to zero */
char oem[8]; /* oem identification, not null-terminated */
char product[12]; /* product name, not null-terminated */
void *oem_table_ptr; /* addr of oem-defined table, zero if none */
unsigned short oem_len; /* length of oem table */
unsigned short num_entries; /* number of entries in base table */
unsigned int apic; /* address of apic */
unsigned short ext_len; /* length of extended section */
unsigned char ext_checksum; /* checksum of extended table entries */
};
struct mp_flt_struct {
unsigned int signature; /* "_MP_" */
struct mp_config_table *mpc; /* address of mp configuration table */
unsigned char mpc_len; /* length of this structure in 16-byte units */
unsigned char mp_rev; /* spec supported, 1 for 1.1 or 4 for 1.4 */
unsigned char checksum; /* checksum, all bytes add up to zero */
unsigned char mp_feature_1; /* mp system configuration type if no mpc */
unsigned char mp_feature_2; /* imcrp */
unsigned char mp_feature_3, mp_feature_4, mp_feature_5; /* reserved */
};
struct mp_ext_pe
{
unsigned char type;
unsigned char apic_id;
unsigned char apic_version;
unsigned char cpu_flags;
unsigned int signature; /* stepping, model, family, each four bits */
unsigned int feature_flags;
unsigned int res1, res2;
};
struct mp_ext_ioapic
{
unsigned char type;
unsigned char ioapic_id;
unsigned char ioapic_version;
unsigned char ioapic_flags;
unsigned int *addr;
};
struct mp_ext_bus
{
unsigned char type;
unsigned char bus_id;
char name[6];
};
#endif
+20
View File
@@ -0,0 +1,20 @@
/*
** 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
// architecture specific thread info
struct arch_thread {
unsigned int *esp;
// 512 byte floating point save point
uint8 fpu_state[512];
};
struct arch_proc {
// nothing here
};
#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_I386_TIMER
#define _NEWOS_KERNEL_ARCH_I386_TIMER
int apic_timer_interrupt(void);
#endif
+31
View File
@@ -0,0 +1,31 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _ARCH_x86_TYPES_H
#define _ARCH_x86_TYPES_H
#ifndef WIN32
typedef unsigned long long uint64;
typedef long long int64;
#else /* WIN32 */
typedef unsigned __int64 uint64;
typedef __int64 int64;
#endif
typedef unsigned int uint32;
typedef int int32;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned char uint8;
typedef char int8;
typedef unsigned long addr;
#define _OBOS_TIME_T_ int /* basic time_t type */
/* define this as not all platforms have it set, but we'll make sure as
* some conditional checks need it
*/
#define __INTEL__ 1
#endif /* _ARCH_x86_TYPES_H */
+66
View File
@@ -0,0 +1,66 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _STAGE2_VESA_H
#define _STAGE2_VESA_H
#include <ktypes.h>
struct VBEInfoBlock {
char signature[4]; // should be 'VESA'
uint16 version;
uint32 oem_ptr;
uint32 capabilities;
uint32 video_ptr;
uint16 total_memory;
// VESA 2.x stuff
uint16 oem_software_rev;
uint32 oem_vendor_name_ptr;
uint32 oem_product_name_ptr;
uint32 oem_product_rev_ptr;
uint8 reserved[222];
uint8 oem_data[256];
} _PACKED;
struct VBEModeInfoBlock {
uint16 attributes;
uint8 wina_attributes;
uint8 winb_attributes;
uint16 win_granulatiry;
uint16 win_size;
uint16 wina_segment;
uint16 winb_segment;
uint32 win_function_ptr;
uint16 bytes_per_scanline;
uint16 x_resolution;
uint16 y_resolution;
uint8 x_charsize;
uint8 y_charsize;
uint8 num_planes;
uint8 bits_per_pixel;
uint8 num_banks;
uint8 memory_model;
uint8 bank_size;
uint8 num_image_pages;
uint8 _reserved;
uint8 red_mask_size;
uint8 red_field_position;
uint8 green_mask_size;
uint8 green_field_position;
uint8 blue_mask_size;
uint8 blue_field_position;
uint8 reserved_mask_size;
uint8 reserved_field_position;
uint8 direct_color_mode_info;
uint32 phys_base_ptr;
uint32 offscreen_mem_offset;
uint16 offscreen_mem_size;
uint8 _reserved2[206];
} _PACKED;
#endif
+10
View File
@@ -0,0 +1,10 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _NEWOS_KERNEL_ARCH_I386_VM_H
#define _NEWOS_KERNEL_ARCH_I386_VM_H
#endif