It is accomplished ...
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef _PORTLINK_H_
|
||||
#define _PORTLINK_H_
|
||||
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <Rect.h>
|
||||
|
||||
#ifndef _PORTLINK_BUFFERSIZE
|
||||
#define _PORTLINK_MAX_ATTACHMENTS 50
|
||||
#endif
|
||||
|
||||
class PortLinkData;
|
||||
|
||||
class PortLink
|
||||
{
|
||||
public:
|
||||
PortLink(port_id port);
|
||||
~PortLink(void);
|
||||
void SetOpCode(int32 code);
|
||||
void SetPort(port_id port);
|
||||
port_id GetPort(void);
|
||||
void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT);
|
||||
int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize,
|
||||
bigtime_t timeout=B_INFINITE_TIMEOUT);
|
||||
void Attach(void *data, size_t size);
|
||||
void Attach(int32 data);
|
||||
void Attach(int16 data);
|
||||
void Attach(int8 data);
|
||||
void Attach(float data);
|
||||
void Attach(bool data);
|
||||
void Attach(BRect data);
|
||||
void Attach(BPoint data);
|
||||
void MakeEmpty(void);
|
||||
protected:
|
||||
void FlattenData(int8 **buffer,int32 *size);
|
||||
port_id target, replyport;
|
||||
int32 opcode, bufferlength;
|
||||
int num_attachments;
|
||||
PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// TokenSpace.h
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef TOKENSPACE_H
|
||||
#define TOKENSPACE_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <map>
|
||||
#include <stack>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <BeBuild.h>
|
||||
#include <Locker.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
#define B_NULL_TOKEN -1
|
||||
#define B_ANY_TOKEN 0
|
||||
#define B_HANDLER_TOKEN 1
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
typedef void (*new_token_callback)(int16, void*);
|
||||
typedef void (*remove_token_callback)(int16, void*);
|
||||
typedef bool (*get_token_callback)(int16, void*);
|
||||
|
||||
class BTokenSpace
|
||||
{
|
||||
public:
|
||||
BTokenSpace();
|
||||
~BTokenSpace();
|
||||
|
||||
int32 NewToken(int16 type, void* object,
|
||||
new_token_callback callback= NULL);
|
||||
bool RemoveToken(int32 token, remove_token_callback callback = NULL);
|
||||
bool CheckToken(int32, int16) const;
|
||||
status_t GetToken(int32, int16, void**,
|
||||
get_token_callback callback = NULL) const;
|
||||
|
||||
// Possible expansion
|
||||
// void Dump(BDataIO&, bool) const;
|
||||
// int32 NewToken(void*, BDirectMessageTarget*, void (*)(short, void*));
|
||||
// bool SetTokenTarget(uint32, BDirectMessageTarget*);
|
||||
// BDirectMessageTarget* TokenTarget(uint32 token, int16 type);
|
||||
|
||||
private:
|
||||
struct TTokenInfo
|
||||
{
|
||||
int16 type;
|
||||
void* object;
|
||||
};
|
||||
|
||||
typedef std::map<int32, TTokenInfo> TTokenMap;
|
||||
|
||||
TTokenMap fTokenMap;
|
||||
std::stack<int32> fTokenBin;
|
||||
int32 fTokenCount;
|
||||
BLocker fLocker;
|
||||
};
|
||||
|
||||
// Possible expansion
|
||||
//_delete_tokens_();
|
||||
//_init_tokens_();
|
||||
//get_handler_token(short, void*);
|
||||
//get_token_list(long, long*);
|
||||
//new_handler_token(short, void*);
|
||||
//remove_handler_token(short, void*);
|
||||
|
||||
extern _IMPEXP_BE BTokenSpace gDefaultTokens;
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif //TOKENSPACE_H
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
//
|
||||
// kb_mouse_driver.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef _KB_MOUSE_DRIVER_H
|
||||
#define _KB_MOUSE_DRIVER_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <Drivers.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Be key numbers for various cool keys
|
||||
|
||||
#define KEY_Scroll 0x0f
|
||||
#define KEY_Pause 0x10
|
||||
#define KEY_Num 0x22
|
||||
#define KEY_CapsLock 0x3b
|
||||
#define KEY_ShiftL 0x4b
|
||||
#define KEY_ShiftR 0x56
|
||||
#define KEY_ControlL 0x5c
|
||||
#define KEY_CmdL 0x5d
|
||||
#define KEY_AltL 0x5d
|
||||
#define KEY_CmdR 0x5f
|
||||
#define KEY_AltR 0x5f
|
||||
#define KEY_ControlR 0x60
|
||||
#define KEY_OptL 0x66
|
||||
#define KEY_WinL 0x66
|
||||
#define KEY_OptR 0x67
|
||||
#define KEY_WinR 0x67
|
||||
#define KEY_Menu 0x68
|
||||
#define KEY_NumEqual 0x6a
|
||||
#define KEY_Power 0x6b
|
||||
#define KEY_SysRq 0x7e
|
||||
#define KEY_Break 0x7f
|
||||
|
||||
#define KB_DEFAULT_CONTROL_ALT_DEL_TIMEOUT 4000000
|
||||
|
||||
|
||||
// ioctl codes
|
||||
|
||||
enum {
|
||||
KB_READ = B_DEVICE_OP_CODES_END,
|
||||
KB_GET_KEYBOARD_ID,
|
||||
KB_SET_LEDS,
|
||||
KB_SET_KEY_REPEATING,
|
||||
KB_SET_KEY_NONREPEATING,
|
||||
KB_SET_KEY_REPEAT_RATE,
|
||||
KB_GET_KEY_REPEAT_RATE,
|
||||
KB_SET_KEY_REPEAT_DELAY,
|
||||
KB_GET_KEY_REPEAT_DELAY,
|
||||
KB_SET_CONTROL_ALT_DEL_TIMEOUT,
|
||||
KB_RESERVED_1, // was KB_ACKNOWLEDGE_CONTROL_ALT_DEL,
|
||||
KB_CANCEL_CONTROL_ALT_DEL,
|
||||
KB_DELAY_CONTROL_ALT_DEL,
|
||||
|
||||
MS_READ = B_DEVICE_OP_CODES_END + 100,
|
||||
MS_NUM_EVENTS,
|
||||
MS_GETA,
|
||||
MS_SETA,
|
||||
MS_GETTYPE,
|
||||
MS_SETTYPE,
|
||||
MS_GETMAP,
|
||||
MS_SETMAP,
|
||||
MS_GETCLICK,
|
||||
MS_SETCLICK,
|
||||
MS_NUM_SERIAL_MICE,
|
||||
|
||||
IIC_WRITE = B_DEVICE_OP_CODES_END + 200,
|
||||
RESTART_SYSTEM,
|
||||
SHUTDOWN_SYSTEM
|
||||
};
|
||||
|
||||
|
||||
// keyboard settings info, as kept in settings file
|
||||
|
||||
|
||||
typedef struct {
|
||||
bigtime_t key_repeat_delay;
|
||||
int32 key_repeat_rate;
|
||||
} kb_settings;
|
||||
|
||||
#define kb_settings_file "Keyboard_settings"
|
||||
|
||||
|
||||
// structure passed to KB_READ
|
||||
|
||||
typedef struct { // USB, ADB keyboards
|
||||
bigtime_t timestamp;
|
||||
uint32 be_keycode;
|
||||
bool is_keydown;
|
||||
} raw_key_info;
|
||||
|
||||
typedef struct { // AT keyboards
|
||||
bigtime_t timestamp;
|
||||
uint8 scancode; // high bit set for extended scancodes
|
||||
bool is_keydown;
|
||||
} at_kbd_io;
|
||||
|
||||
|
||||
// structure passed to KB_SET_LEDS
|
||||
|
||||
typedef struct {
|
||||
bool num_lock;
|
||||
bool caps_lock;
|
||||
bool scroll_lock;
|
||||
} led_info;
|
||||
|
||||
|
||||
|
||||
// mouse settings info
|
||||
|
||||
typedef enum {
|
||||
MOUSE_1_BUTTON = 1,
|
||||
MOUSE_2_BUTTON,
|
||||
MOUSE_3_BUTTON
|
||||
} mouse_type;
|
||||
|
||||
typedef struct {
|
||||
int32 left;
|
||||
int32 right;
|
||||
int32 middle;
|
||||
} map_mouse;
|
||||
|
||||
typedef struct {
|
||||
bool enabled; // Acceleration on / off
|
||||
int32 accel_factor; // accel factor: 256 = step by 1, 128 = step by 1/2
|
||||
int32 speed; // speed accelerator (1=1X, 2 = 2x)...
|
||||
} mouse_accel;
|
||||
|
||||
typedef struct {
|
||||
mouse_type type;
|
||||
map_mouse map;
|
||||
mouse_accel accel;
|
||||
bigtime_t click_speed;
|
||||
} mouse_settings;
|
||||
|
||||
#define mouse_settings_file "Mouse_settings"
|
||||
|
||||
typedef struct {
|
||||
int serial_cookie;
|
||||
int buttons;
|
||||
int xdelta;
|
||||
int ydelta;
|
||||
int32 clicks;
|
||||
int32 modifiers;
|
||||
bigtime_t time;
|
||||
int wheel_delta;
|
||||
} mouse_pos;
|
||||
|
||||
|
||||
// On the Mac, the I-squared C bus is controlled by the Cuda microcontroller,
|
||||
// which also runs ADB. Since we have not yet partitioned the driver into
|
||||
// a separate Cuda driver and a kb/mouse driver, the iic is controlled with
|
||||
// control calls to the kb_mouse driver. Yuck.
|
||||
|
||||
typedef struct {
|
||||
char device;
|
||||
char reg;
|
||||
char value;
|
||||
} iic_write;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endid
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: TextInput.h
|
||||
// Author: Frans van Nispen ([email protected])
|
||||
// Description: The BTextView derivative owned by an instance of
|
||||
// BTextControl.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _TEXT_CONTROLI_H
|
||||
#define _TEXT_CONTROLI_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <TextView.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class BTextControl;
|
||||
|
||||
// _BTextInput_ class ----------------------------------------------------------
|
||||
class _BTextInput_ : public BTextView {
|
||||
public:
|
||||
_BTextInput_(BTextControl* parent, BRect frame,
|
||||
const char* name, BRect rect,
|
||||
uint32 mask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
~_BTextInput_();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void SetViewColor(rgb_color);
|
||||
rgb_color ViewColor();
|
||||
virtual bool CanEndLine(int32);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
virtual void Draw(BRect);
|
||||
virtual void SetEnabled(bool state);
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
||||
private:
|
||||
rgb_color fViewColor;
|
||||
bool fEnabled;
|
||||
bool fChanged;
|
||||
BTextControl* fParent;
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif // _TEXT_CONTROLI_H
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*****************************************************************************/
|
||||
// print_server Background Application.
|
||||
//
|
||||
// Version: 1.0.0d1
|
||||
//
|
||||
// The print_server manages the communication between applications and the
|
||||
// printer and transport drivers.
|
||||
//
|
||||
//
|
||||
// This application and all source files used in its construction, except
|
||||
// where noted, are licensed under the MIT License, and have been written
|
||||
// and are:
|
||||
//
|
||||
// Copyright (c) 2001 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _PR_SERVER_H_
|
||||
#define _PR_SERVER_H_
|
||||
|
||||
// signature mime types
|
||||
#define PSRV_SIGNATURE_TYPE "application/x-vnd.Be-PSRV"
|
||||
#define PRNT_SIGNATURE_TYPE "application/x-vnd.Be-PRNT"
|
||||
|
||||
// messages understood by print_server
|
||||
#define PSRV_GET_ACTIVE_PRINTER 'pgcp'
|
||||
#define PSRV_MAKE_PRINTER_ACTIVE_QUIETLY 'pmaq'
|
||||
#define PSRV_MAKE_PRINTER_ACTIVE 'pmac'
|
||||
#define PSRV_MAKE_PRINTER 'selp'
|
||||
#define PSRV_SHOW_PAGE_SETUP 'pgst'
|
||||
#define PSRV_SHOW_PRINT_SETUP 'ppst'
|
||||
#define PSRV_PRINT_SPOOLED_JOB 'psns'
|
||||
|
||||
// mime file types
|
||||
#define PSRV_PRINTER_FILETYPE "application/x-vnd.Be.printer"
|
||||
#define PSRV_SPOOL_FILETYPE "application/x-vnd.Be.printer-spool"
|
||||
|
||||
// spool Attributes
|
||||
#define PSRV_SPOOL_ATTR_MIMETYPE "_spool/MimeType"
|
||||
#define PSRV_SPOOL_ATTR_PAGECOUNT "_spool/Page Count"
|
||||
#define PSRV_SPOOL_ATTR_DESCRIPTION "_spool/Description"
|
||||
#define PSRV_SPOOL_ATTR_PRINTER "_spool/Printer"
|
||||
#define PSRV_SPOOL_ATTR_STATUS "_spool/Status"
|
||||
#define PSRV_SPOOL_ATTR_ERRCODE "_spool/_errorcode"
|
||||
|
||||
// printer attributes
|
||||
#define PSRV_PRINTER_ATTR_DRV_NAME "Driver Name"
|
||||
#define PSRV_PRINTER_ATTR_PRT_NAME "Printer Name"
|
||||
#define PSRV_PRINTER_ATTR_COMMENTS "Comments"
|
||||
#define PSRV_PRINTER_ATTR_STATE "state"
|
||||
#define PSRV_PRINTER_ATTR_TRANSPORT "transport"
|
||||
#define PSRV_PRINTER_ATTR_TRANSPORT_ADDR "transport_address"
|
||||
#define PSRV_PRINTER_ATTR_CNX "connection"
|
||||
#define PSRV_PRINTER_ATTR_PNP "_PNP"
|
||||
#define PSRV_PRINTER_ATTR_MDL "_MDL"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,261 @@
|
||||
/* Errors.h
|
||||
*
|
||||
* Error codes used by OpenBeOS.
|
||||
*
|
||||
* NB Where the codes can be directly mapped to a POSIX
|
||||
* error value they have been.
|
||||
*
|
||||
* XXX - should be installed as support/Errors.h to keep
|
||||
* compatibility with beos source code
|
||||
*/
|
||||
|
||||
/* The codes shown here are the ones that Be defined. If new
|
||||
* error codes are needed they should be added AT THE END of the
|
||||
* enums to make sure we don't damage our compatibility.
|
||||
*/
|
||||
|
||||
#ifndef _ERRORS_H
|
||||
#define _ERRORS_H
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* XXX - paranoid...should be in limits.h */
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN (-2147483647L-1)
|
||||
#endif
|
||||
|
||||
/* These are the start points for the various categories of
|
||||
* error.
|
||||
* These are identical to the Be codes so we have compatibility
|
||||
* with them.
|
||||
*/
|
||||
#define B_GENERAL_ERROR_BASE LONG_MIN
|
||||
#define B_OS_ERROR_BASE B_GENERAL_ERROR_BASE + 0x1000
|
||||
#define B_APP_ERROR_BASE B_GENERAL_ERROR_BASE + 0x2000
|
||||
#define B_INTERFACE_ERROR_BASE B_GENERAL_ERROR_BASE + 0x3000
|
||||
#define B_MEDIA_ERROR_BASE B_GENERAL_ERROR_BASE + 0x4000
|
||||
#define B_TRANSLATION_ERROR_BASE B_GENERAL_ERROR_BASE + 0x4800
|
||||
#define B_MIDI_ERROR_BASE B_GENERAL_ERROR_BASE + 0x5000
|
||||
#define B_STORAGE_ERROR_BASE B_GENERAL_ERROR_BASE + 0x6000
|
||||
#define B_POSIX_ERROR_BASE B_GENERAL_ERROR_BASE + 0x7000
|
||||
#define B_MAIL_ERROR_BASE B_GENERAL_ERROR_BASE + 0x8000
|
||||
#define B_PRINT_ERROR_BASE B_GENERAL_ERROR_BASE + 0x9000
|
||||
#define B_DEVICE_ERROR_BASE B_GENERAL_ERROR_BASE + 0xa000
|
||||
|
||||
/* This can be used to add user-defined errors, use the
|
||||
* value B_ERRORS_END +1 as the first value.
|
||||
*/
|
||||
#define B_ERRORS_END (B_GENERAL_ERROR_BASE + 0xffff)
|
||||
|
||||
#define B_NO_ERROR 0
|
||||
#define B_OK 0
|
||||
#define B_ERROR -1
|
||||
|
||||
enum {
|
||||
B_NO_MEMORY = B_GENERAL_ERROR_BASE, /* ENOMEM */
|
||||
B_IO_ERROR, /* EIO */
|
||||
B_PERMISSION_DENIED, /* EACCES */
|
||||
B_BAD_INDEX,
|
||||
B_BAD_TYPE,
|
||||
B_BAD_VALUE, /* EINVAL */
|
||||
B_MISMATCHED_VALUES,
|
||||
B_NAME_NOT_FOUND,
|
||||
B_NAME_IN_USE,
|
||||
B_TIMED_OUT, /* ETIMEDOUT */
|
||||
B_INTERRUPTED, /* EINTR */
|
||||
B_WOULD_BLOCK, /* EWOULDBLOCK == EAGAIN */
|
||||
B_CANCELED,
|
||||
B_NO_INIT,
|
||||
B_BUSY, /* EBUSY */
|
||||
B_NOT_ALLOWED, /* EPERM */
|
||||
};
|
||||
|
||||
/* Kernel Kit Errors */
|
||||
enum {
|
||||
B_BAD_SEM_ID = B_OS_ERROR_BASE,
|
||||
B_NO_MORE_SEMS,
|
||||
|
||||
B_BAD_THREAD_ID = B_OS_ERROR_BASE + 0x100,
|
||||
B_NO_MORE_THREADS,
|
||||
B_BAD_THREAD_STATE,
|
||||
B_BAD_TEAM_ID,
|
||||
B_NO_MORE_TEAMS,
|
||||
|
||||
B_BAD_PORT_ID = B_OS_ERROR_BASE + 0x200,
|
||||
B_NO_MORE_PORTS,
|
||||
|
||||
B_BAD_IMAGE_ID = B_OS_ERROR_BASE + 0x300,
|
||||
B_BAD_ADDRESS,
|
||||
B_NOT_AN_EXECUTABLE,
|
||||
B_MISSING_LIBRARY,
|
||||
B_MISSING_SYMBOL,
|
||||
|
||||
B_DEBUGGER_ALREADY_INSTALLED = B_OS_ERROR_BASE + 0x400
|
||||
};
|
||||
|
||||
/* Application Kit Errors */
|
||||
enum
|
||||
{
|
||||
B_BAD_REPLY = B_APP_ERROR_BASE,
|
||||
B_DUPLICATE_REPLY,
|
||||
B_MESSAGE_TO_SELF,
|
||||
B_BAD_HANDLER,
|
||||
B_ALREADY_RUNNING,
|
||||
B_LAUNCH_FAILED,
|
||||
B_AMBIGUOUS_APP_LAUNCH,
|
||||
B_UNKNOWN_MIME_TYPE,
|
||||
B_BAD_SCRIPT_SYNTAX,
|
||||
B_LAUNCH_FAILED_NO_RESOLVE_LINK,
|
||||
B_LAUNCH_FAILED_EXECUTABLE,
|
||||
B_LAUNCH_FAILED_APP_NOT_FOUND,
|
||||
B_LAUNCH_FAILED_APP_IN_TRASH,
|
||||
B_LAUNCH_FAILED_NO_PREFERRED_APP,
|
||||
B_LAUNCH_FAILED_FILES_APP_NOT_FOUND,
|
||||
B_BAD_MIME_SNIFFER_RULE
|
||||
};
|
||||
|
||||
|
||||
/* Storage Kit & File System Errors */
|
||||
enum {
|
||||
B_FILE_ERROR = B_STORAGE_ERROR_BASE, /* EBADF */
|
||||
B_FILE_NOT_FOUND, /* discouraged; use B_ENTRY_NOT_FOUND in new code*/
|
||||
B_FILE_EXISTS, /* EEXIST */
|
||||
B_ENTRY_NOT_FOUND, /* ENOENT */
|
||||
B_NAME_TOO_LONG, /* ENAMETOOLONG */
|
||||
B_NOT_A_DIRECTORY, /* ENOTDIR */
|
||||
B_DIRECTORY_NOT_EMPTY, /* ENOTEMPTY */
|
||||
B_DEVICE_FULL, /* ENOSPC */
|
||||
B_READ_ONLY_DEVICE, /* EROFS */
|
||||
B_IS_A_DIRECTORY,
|
||||
B_NO_MORE_FDS,
|
||||
B_CROSS_DEVICE_LINK,
|
||||
B_LINK_LIMIT,
|
||||
B_BUSTED_PIPE,
|
||||
B_UNSUPPORTED,
|
||||
B_PARTITION_TOO_SMALL
|
||||
};
|
||||
|
||||
/* Media Kit Errors */
|
||||
enum {
|
||||
B_STREAM_NOT_FOUND = B_MEDIA_ERROR_BASE,
|
||||
B_SERVER_NOT_FOUND,
|
||||
B_RESOURCE_NOT_FOUND,
|
||||
B_RESOURCE_UNAVAILABLE,
|
||||
B_BAD_SUBSCRIBER,
|
||||
B_SUBSCRIBER_NOT_ENTERED,
|
||||
B_BUFFER_NOT_AVAILABLE,
|
||||
B_LAST_BUFFER_ERROR
|
||||
};
|
||||
|
||||
/* Mail Kit Errors */
|
||||
enum
|
||||
{
|
||||
B_MAIL_NO_DAEMON = B_MAIL_ERROR_BASE,
|
||||
B_MAIL_UNKNOWN_USER,
|
||||
B_MAIL_WRONG_PASSWORD,
|
||||
B_MAIL_UNKNOWN_HOST,
|
||||
B_MAIL_ACCESS_ERROR,
|
||||
B_MAIL_UNKNOWN_FIELD,
|
||||
B_MAIL_NO_RECIPIENT,
|
||||
B_MAIL_INVALID_MAIL
|
||||
};
|
||||
|
||||
/* Printing Errors */
|
||||
enum
|
||||
{
|
||||
B_NO_PRINT_SERVER = B_PRINT_ERROR_BASE
|
||||
};
|
||||
|
||||
/* Device Kit Errors */
|
||||
enum
|
||||
{
|
||||
B_DEV_INVALID_IOCTL = B_DEVICE_ERROR_BASE,
|
||||
B_DEV_NO_MEMORY,
|
||||
B_DEV_BAD_DRIVE_NUM,
|
||||
B_DEV_NO_MEDIA,
|
||||
B_DEV_UNREADABLE,
|
||||
B_DEV_FORMAT_ERROR,
|
||||
B_DEV_TIMEOUT,
|
||||
B_DEV_RECALIBRATE_ERROR,
|
||||
B_DEV_SEEK_ERROR,
|
||||
B_DEV_ID_ERROR,
|
||||
B_DEV_READ_ERROR,
|
||||
B_DEV_WRITE_ERROR,
|
||||
B_DEV_NOT_READY,
|
||||
B_DEV_MEDIA_CHANGED,
|
||||
B_DEV_MEDIA_CHANGE_REQUESTED,
|
||||
B_DEV_RESOURCE_CONFLICT,
|
||||
B_DEV_CONFIGURATION_ERROR,
|
||||
B_DEV_DISABLED_BY_USER,
|
||||
B_DEV_DOOR_OPEN
|
||||
};
|
||||
|
||||
/* These are the old newos errors - we should be trying to remove these
|
||||
* in favour of the error codes above!!!
|
||||
*/
|
||||
|
||||
/* General errors */
|
||||
#define ERR_GENERAL -1
|
||||
#define ERR_NO_MEMORY ENOMEM
|
||||
#define ERR_IO_ERROR EIO
|
||||
#define ERR_INVALID_ARGS EINVAL
|
||||
#define ERR_TIMED_OUT ETIMEDOUT
|
||||
#define ERR_NOT_ALLOWED EPERM
|
||||
#define ERR_PERMISSION_DENIED EACCES
|
||||
#define ERR_INVALID_BINARY ERR_GENERAL-7
|
||||
#define ERR_INVALID_HANDLE ERR_GENERAL-8
|
||||
#define ERR_NO_MORE_HANDLES ERR_GENERAL-9
|
||||
#define ERR_UNIMPLEMENTED ENOSYS
|
||||
#define ERR_TOO_BIG EDOM
|
||||
#define ERR_NOT_FOUND ERR_GENERAL-12
|
||||
#define ERR_NOT_IMPLEMENTED_YET ERR_GENERAL-13
|
||||
|
||||
/* Semaphore errors */
|
||||
#define ERR_SEM_GENERAL -1024
|
||||
#define ERR_SEM_DELETED ERR_SEM_GENERAL-1
|
||||
#define ERR_SEM_TIMED_OUT ERR_SEM_GENERAL-2
|
||||
#define ERR_SEM_OUT_OF_SLOTS ERR_SEM_GENERAL-3
|
||||
#define ERR_SEM_NOT_ACTIVE ERR_SEM_GENERAL-4
|
||||
#define ERR_SEM_INTERRUPTED ERR_SEM_GENERAL-5
|
||||
#define ERR_SEM_NOT_INTERRUPTABLE ERR_SEM_GENERAL-6
|
||||
#define ERR_SEM_NOT_FOUND ERR_SEM_GENERAL-7
|
||||
|
||||
|
||||
/* Tasker errors */
|
||||
#define ERR_TASK_GENERAL -2048
|
||||
#define ERR_TASK_PROC_DELETED ERR_TASK_GENERAL-1
|
||||
|
||||
/* VFS errors */
|
||||
#define ERR_VFS_GENERAL -3072
|
||||
#define ERR_VFS_INVALID_FS ERR_VFS_GENERAL-1
|
||||
#define ERR_VFS_NOT_MOUNTPOINT ERR_VFS_GENERAL-2
|
||||
#define ERR_VFS_PATH_NOT_FOUND ERR_VFS_GENERAL-3
|
||||
#define ERR_VFS_INSUFFICIENT_BUF ENOBUFS
|
||||
#define ERR_VFS_READONLY_FS EROFS
|
||||
#define ERR_VFS_ALREADY_EXISTS EEXIST
|
||||
#define ERR_VFS_FS_BUSY ERR_VFS_GENERAL-7
|
||||
#define ERR_VFS_FD_TABLE_FULL ERR_VFS_GENERAL-8
|
||||
#define ERR_VFS_CROSS_FS_RENAME ERR_VFS_GENERAL-9
|
||||
#define ERR_VFS_DIR_NOT_EMPTY ERR_VFS_GENERAL-10
|
||||
#define ERR_VFS_NOT_DIR ENOTDIR
|
||||
#define ERR_VFS_WRONG_STREAM_TYPE ERR_VFS_GENERAL-12
|
||||
#define ERR_VFS_ALREADY_MOUNTPOINT ERR_VFS_GENERAL-13
|
||||
|
||||
/* VM errors */
|
||||
#define ERR_VM_GENERAL -4096
|
||||
#define ERR_VM_INVALID_ASPACE ERR_VM_GENERAL-1
|
||||
#define ERR_VM_INVALID_REGION ERR_VM_GENERAL-2
|
||||
#define ERR_VM_BAD_ADDRESS ERR_VM_GENERAL-3
|
||||
#define ERR_VM_PF_FATAL ERR_VM_GENERAL-4
|
||||
#define ERR_VM_PF_BAD_ADDRESS ERR_VM_GENERAL-5
|
||||
#define ERR_VM_PF_BAD_PERM ERR_VM_GENERAL-6
|
||||
#define ERR_VM_PAGE_NOT_PRESENT ERR_VM_GENERAL-7
|
||||
#define ERR_VM_NO_REGION_SLOT ERR_VM_GENERAL-8
|
||||
#define ERR_VM_WOULD_OVERCOMMIT ERR_VM_GENERAL-9
|
||||
#define ERR_VM_BAD_USER_MEMORY ERR_VM_GENERAL-10
|
||||
|
||||
/* Elf errors */
|
||||
#define ERR_ELF_GENERAL -5120
|
||||
#define ERR_ELF_RESOLVING_SYMBOL ERR_ELF_GENERAL -1
|
||||
|
||||
#endif /* _ERRORS_H */
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Executable
+36
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
Executable
+84
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Executable
+12
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
Executable
+12
@@ -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
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#ifndef _IDE_BUS_H
|
||||
#define _IDE_BUS_H
|
||||
|
||||
#include <stage2.h>
|
||||
|
||||
int ide_bus_init(kernel_args *ka);
|
||||
|
||||
#endif
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Modified Sep 2001 by Rob Judd <judd@ob-wan.com>
|
||||
** 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
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Modified Sep 2001 by Rob Judd <judd@ob-wan.com>
|
||||
** 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
|
||||
Executable
+19
@@ -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
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#ifndef _KEYBOARD_H
|
||||
#define _KEYBOARD_H
|
||||
|
||||
#include <stage2.h>
|
||||
|
||||
int keyboard_dev_init(kernel_args *ka);
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+84
@@ -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
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* ps2mouse.c:
|
||||
* PS/2 mouse device driver for NewOS and OpenBeOS.
|
||||
* Author: Elad Lahav (elad@eldarshany.com)
|
||||
* 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
@@ -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
@@ -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
|
||||
Executable
+161
@@ -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
@@ -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
@@ -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
|
||||
|
||||
Executable
+11
@@ -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
|
||||
|
||||
Executable
+31
@@ -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 */
|
||||
Executable
+66
@@ -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
|
||||
|
||||
Executable
+10
@@ -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
|
||||
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
** Copyright 2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Copyright 2002, Manuel J. Petit. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
|
||||
#ifndef __newos__nulibc_assert__hh__
|
||||
#define __newos__nulibc_assert__hh__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
void _assert(char const *, int, char const *);
|
||||
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define assert(x)
|
||||
#else
|
||||
# define assert(x) ( (x) ? (void)0 : _assert(__FILE__, __LINE__, #x) )
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#ifndef _KERNEL_ATOMIC_H
|
||||
#define _KERNEL_ATOMIC_H
|
||||
|
||||
/**
|
||||
* @file kernel/atomic.h
|
||||
* @brief Prototypes for kernel and user versions of atomic
|
||||
* functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Kernel_Atomic Atomic Operations
|
||||
* @ingroup OpenBeOS_Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* XXX - atomic_set is defined as using a volatile as this stops a
|
||||
* compiler warning, but is there any reason why they shouldn't all
|
||||
* be so defined? They were in arch/cpu.h...
|
||||
*/
|
||||
/**
|
||||
* Perform an atomic addition.
|
||||
* @param val Pointer to an integer
|
||||
* @param incr The increment to add (may be -ve)
|
||||
* @note Returns value of val before addition
|
||||
*/
|
||||
int atomic_add(int *val, int incr);
|
||||
/**
|
||||
* Atomic and operation
|
||||
* @param val Pointer to an integer
|
||||
* @param incr The increment to add (may be -ve)
|
||||
* @note Returns value of val before addition
|
||||
*/
|
||||
int atomic_and(int *val, int incr);
|
||||
/**
|
||||
* Atomic or operation
|
||||
* @param val Pointer to an integer
|
||||
* @param incr The increment to add (may be -ve)
|
||||
* @note Returns value of val before addition
|
||||
*/
|
||||
int atomic_or(int *val, int incr);
|
||||
int atomic_set(volatile int *val, int set_to);
|
||||
/* Compare the value of val with test_val. If they
|
||||
* are equal then set the value of 'val' to
|
||||
* 'set_to'
|
||||
*/
|
||||
int test_and_set(int *val, int set_to, int test_val);
|
||||
|
||||
/**
|
||||
* Atomic add (user version)
|
||||
* @param val Pointer to an integer
|
||||
* @param incr The increment to add (may be -ve)
|
||||
* @note Returns value of val before addition
|
||||
*/
|
||||
int user_atomic_add(int *val, int incr);
|
||||
/**
|
||||
* Atomic and (user version)
|
||||
* @param val Pointer to an integer
|
||||
* @param incr The increment to add (may be -ve)
|
||||
* @note Returns value of val before addition
|
||||
*/
|
||||
int user_atomic_and(int *val, int incr);
|
||||
/**
|
||||
* Atomic or (user version)
|
||||
* @param val Pointer to an integer
|
||||
* @param incr The increment to add (may be -ve)
|
||||
* @note Returns value of val before addition
|
||||
*/
|
||||
int user_atomic_or(int *val, int incr);
|
||||
int user_atomic_set(int *val, int set_to);
|
||||
/* Compare the value of val with test_val. If they
|
||||
* are equal then set the value of 'val' to
|
||||
* 'set_to'
|
||||
* @note This is the user version and should not be used within
|
||||
* the kernel.
|
||||
*/
|
||||
int user_test_and_set(int *val, int set_to, int test_val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#endif /* _KERNEL_ATOMIC_H */
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#ifndef _KERNEL_DEV_BEOS
|
||||
#define _KERNEL_DEV_BEOS
|
||||
|
||||
int beos_layer_init(void);
|
||||
int beos_load_beos_driver(const char *name);
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+192
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _BEOS_PRIV_H
|
||||
#define _BEOS_PRIV_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <types.h>
|
||||
#include <ktypes.h>
|
||||
|
||||
typedef int status_t;
|
||||
typedef unsigned short ushort;
|
||||
|
||||
/*
|
||||
** NOTE:
|
||||
** Contains stuff taken from beos headers.
|
||||
** Please dont sue me. I'll clean it up when I get the chance.
|
||||
*/
|
||||
|
||||
/* beos driver interface */
|
||||
struct selectsync;
|
||||
typedef struct selectsync selectsync;
|
||||
|
||||
typedef status_t (*device_open_hook) (const char *name, uint32 flags, void **cookie);
|
||||
typedef status_t (*device_close_hook) (void *cookie);
|
||||
typedef status_t (*device_free_hook) (void *cookie);
|
||||
typedef status_t (*device_control_hook) (void *cookie, uint32 op, void *data, size_t len);
|
||||
typedef status_t (*device_read_hook) (void *cookie, off_t position, void *data, size_t *numBytes);
|
||||
typedef status_t (*device_write_hook) (void *cookie, off_t position, const void *data, size_t *numBytes);
|
||||
typedef status_t (*device_select_hook) (void *cookie, uint8 event, uint32 ref, selectsync *sync);
|
||||
typedef status_t (*device_deselect_hook) (void *cookie, uint8 event, selectsync *sync);
|
||||
typedef status_t (*device_readv_hook) (void *cookie, off_t position, const iovec *vec, size_t count, size_t *numBytes);
|
||||
typedef status_t (*device_writev_hook) (void *cookie, off_t position, const iovec *vec, size_t count, size_t *numBytes);
|
||||
|
||||
#define B_CUR_DRIVER_API_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
device_open_hook open;
|
||||
device_close_hook close;
|
||||
device_free_hook free;
|
||||
device_control_hook control;
|
||||
device_read_hook read;
|
||||
device_write_hook write;
|
||||
device_select_hook select;
|
||||
device_deselect_hook deselect;
|
||||
device_readv_hook readv;
|
||||
device_writev_hook writev;
|
||||
} beos_device_hooks;
|
||||
|
||||
/* sem stuff */
|
||||
#define B_CAN_INTERRUPT 1
|
||||
#define B_DO_NOT_RESCHEDULE 2
|
||||
#define B_CHECK_PERMISSION 4
|
||||
#define B_TIMEOUT 8
|
||||
#define B_RELATIVE_TIMEOUT 8
|
||||
#define B_ABSOLUTE_TIMEOUT 16
|
||||
|
||||
/* module stuff */
|
||||
struct module_info {
|
||||
const char *name;
|
||||
uint32 flags;
|
||||
int (*std_ops)(int32, ...);
|
||||
};
|
||||
typedef struct module_info module_info;
|
||||
|
||||
struct bus_manager_info {
|
||||
module_info minfo;
|
||||
status_t (*rescan)(void);
|
||||
};
|
||||
typedef struct bus_manager_info bus_manager_info;
|
||||
|
||||
/* isa module */
|
||||
typedef struct {
|
||||
ulong address; /* memory address (little endian!) 4 bytes */
|
||||
ushort transfer_count; /* # transfers minus one (little endian!) 2 bytes*/
|
||||
uchar reserved; /* filler, 1byte*/
|
||||
uchar flag; /* end of link flag, 1byte */
|
||||
} isa_dma_entry;
|
||||
|
||||
struct isa_module_info {
|
||||
bus_manager_info binfo;
|
||||
|
||||
uint8 (*read_io_8) (int mapped_io_addr);
|
||||
void (*write_io_8) (int mapped_io_addr, uint8 value);
|
||||
uint16 (*read_io_16) (int mapped_io_addr);
|
||||
void (*write_io_16) (int mapped_io_addr, uint16 value);
|
||||
uint32 (*read_io_32) (int mapped_io_addr);
|
||||
void (*write_io_32) (int mapped_io_addr, uint32 value);
|
||||
|
||||
void * (*ram_address) (const void *physical_address_in_system_memory);
|
||||
|
||||
long (*make_isa_dma_table) (
|
||||
const void *buffer, /* buffer to make a table for */
|
||||
long buffer_size, /* buffer size */
|
||||
ulong num_bits, /* dma transfer size that will be used */
|
||||
isa_dma_entry *table, /* -> caller-supplied scatter/gather table */
|
||||
long num_entries /* max # entries in table */
|
||||
);
|
||||
long (*start_isa_dma) (
|
||||
long channel, /* dma channel to use */
|
||||
void *buf, /* buffer to transfer */
|
||||
long transfer_count, /* # transfers */
|
||||
uchar mode, /* mode flags */
|
||||
uchar e_mode /* extended mode flags */
|
||||
);
|
||||
long (*start_scattered_isa_dma) (
|
||||
long channel, /* channel # to use */
|
||||
const isa_dma_entry *table, /* physical address of scatter/gather table */
|
||||
uchar mode, /* mode flags */
|
||||
uchar emode /* extended mode flags */
|
||||
);
|
||||
long (*lock_isa_dma_channel) (long channel);
|
||||
long (*unlock_isa_dma_channel) (long channel);
|
||||
};
|
||||
typedef struct isa_module_info isa_module_info;
|
||||
#define B_ISA_MODULE_NAME "bus_managers/isa/v1"
|
||||
|
||||
/* beos error codes */
|
||||
|
||||
#define LONG_MIN (-2147483647L-1)
|
||||
|
||||
#define B_GENERAL_ERROR_BASE LONG_MIN
|
||||
#define B_OS_ERROR_BASE B_GENERAL_ERROR_BASE + 0x1000
|
||||
|
||||
enum {
|
||||
B_NO_MEMORY = B_GENERAL_ERROR_BASE,
|
||||
B_IO_ERROR,
|
||||
B_PERMISSION_DENIED,
|
||||
B_BAD_INDEX,
|
||||
B_BAD_TYPE,
|
||||
B_BAD_VALUE,
|
||||
B_MISMATCHED_VALUES,
|
||||
B_NAME_NOT_FOUND,
|
||||
B_NAME_IN_USE,
|
||||
B_TIMED_OUT,
|
||||
B_INTERRUPTED,
|
||||
B_WOULD_BLOCK,
|
||||
B_CANCELED,
|
||||
B_NO_INIT,
|
||||
B_BUSY,
|
||||
B_NOT_ALLOWED,
|
||||
B_BAD_DATA,
|
||||
|
||||
B_ERROR = -1,
|
||||
B_OK = 0,
|
||||
B_NO_ERROR = 0
|
||||
};
|
||||
enum {
|
||||
B_BAD_SEM_ID = B_OS_ERROR_BASE,
|
||||
B_NO_MORE_SEMS,
|
||||
|
||||
B_BAD_THREAD_ID = B_OS_ERROR_BASE + 0x100,
|
||||
B_NO_MORE_THREADS,
|
||||
B_BAD_THREAD_STATE,
|
||||
B_BAD_TEAM_ID,
|
||||
B_NO_MORE_TEAMS,
|
||||
|
||||
B_BAD_PORT_ID = B_OS_ERROR_BASE + 0x200,
|
||||
B_NO_MORE_PORTS,
|
||||
|
||||
B_BAD_IMAGE_ID = B_OS_ERROR_BASE + 0x300,
|
||||
B_BAD_ADDRESS,
|
||||
B_NOT_AN_EXECUTABLE,
|
||||
B_MISSING_LIBRARY,
|
||||
B_MISSING_SYMBOL,
|
||||
|
||||
B_DEBUGGER_ALREADY_INSTALLED = B_OS_ERROR_BASE + 0x400
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* BeOS functions protypes, same functions as BeOS but with
|
||||
* '_beos_' prepended to the names, the kernel loader
|
||||
* handles the magick of matching the names
|
||||
*/
|
||||
int _beos_atomic_add(volatile int *val, int incr);
|
||||
int _beos_atomic_and(volatile int *val, int incr);
|
||||
int _beos_atomic_or(volatile int *val, int incr);
|
||||
int _beos_acquire_sem(sem_id id);
|
||||
int _beos_acquire_sem_etc(sem_id id, uint32 count, uint32 flags, bigtime_t timeout);
|
||||
sem_id _beos_create_sem(uint32 count, const char *name);
|
||||
int _beos_delete_sem(sem_id id);
|
||||
int _beos_get_sem_count(sem_id id, int32 *count);
|
||||
int _beos_release_sem(sem_id id);
|
||||
int _beos_release_sem_etc(sem_id id, int32 count, uint32 flags);
|
||||
int _beos_strcmp(const char *cs, const char *ct);
|
||||
void _beos_spin(bigtime_t microseconds);
|
||||
int _beos_get_module(const char *path, module_info **vec);
|
||||
int _beos_put_module(const char *path);
|
||||
|
||||
#endif
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
/* $Id: bootdir.h,v 1.1 2002/07/09 12:24:34 ejakowatz Exp $
|
||||
**
|
||||
** Copyright 1998 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 _NEWOS_BOOT_H_
|
||||
#define _NEWOS_BOOT_H_
|
||||
|
||||
#define BOOTDIR_NAMELEN 32
|
||||
#define BOOTDIR_MAX_ENTRIES 64
|
||||
#define BOOTDIR_DIRECTORY "SBBB/Directory"
|
||||
|
||||
typedef struct {
|
||||
char be_name[BOOTDIR_NAMELEN]; /* name of loaded object, zero terminated */
|
||||
int be_offset; /* offset of object relative to the start of boot_dir */
|
||||
int be_type; /* object type designator */
|
||||
int be_size; /* size of loaded object (pages) */
|
||||
int be_vsize; /* size loaded object should occupy when mapped in */
|
||||
int be_extra0;
|
||||
int be_extra1;
|
||||
int be_extra2;
|
||||
int be_extra3;
|
||||
} boot_entry;
|
||||
|
||||
typedef struct {
|
||||
boot_entry bd_entry[BOOTDIR_MAX_ENTRIES];
|
||||
} boot_dir;
|
||||
|
||||
/* void _start(uint32 mem, char *params, boot_dir *bd); */
|
||||
|
||||
#define BE_TYPE_NONE 0 /* empty entry */
|
||||
#define BE_TYPE_DIRECTORY 1 /* directory (entry 0) */
|
||||
#define BE_TYPE_BOOTSTRAP 2 /* bootstrap code object (entry 1) */
|
||||
#define BE_TYPE_CODE 3 /* executable code object */
|
||||
#define BE_TYPE_DATA 4 /* raw data object */
|
||||
#define BE_TYPE_ELF32 5 /* 32bit ELF object */
|
||||
|
||||
/* for BE_TYPE_CODE */
|
||||
#define be_code_vaddr be_extra0 /* virtual address (rel offset 0) */
|
||||
#define be_code_ventr be_extra1 /* virtual entry point (rel offset 0) */
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _NEWOS_KERNEL_FS_BOOTFS_H
|
||||
#define _NEWOS_KERNEL_FS_BOOTFS_H
|
||||
|
||||
int bootstrap_bootfs(void);
|
||||
|
||||
#endif
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _BUS_H
|
||||
#define _BUS_H
|
||||
|
||||
#include <stage2.h>
|
||||
#include <module.h>
|
||||
|
||||
int bus_init(kernel_args *ka);
|
||||
int bus_man_init(kernel_args *ka);
|
||||
|
||||
int bus_register_bus(const char *path);
|
||||
|
||||
typedef struct {
|
||||
module_info minfo;
|
||||
status_t (*rescan)(void);
|
||||
} bus_manager_info;
|
||||
|
||||
typedef struct id_list {
|
||||
uint32 num_ids;
|
||||
uint32 id[0];
|
||||
} id_list;
|
||||
|
||||
#define MAX_DEV_IO_RANGES 8
|
||||
|
||||
typedef struct device {
|
||||
uint32 vendor_id;
|
||||
uint32 device_id;
|
||||
|
||||
uint32 irq;
|
||||
addr base[MAX_DEV_IO_RANGES];
|
||||
addr size[MAX_DEV_IO_RANGES];
|
||||
|
||||
char dev_path[256];
|
||||
} device;
|
||||
|
||||
int bus_find_device(int n, id_list *vendor_ids, id_list *device_ids, device *dev);
|
||||
|
||||
#endif
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_CBUF_H
|
||||
#define _KERNEL_CBUF_H
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#define CBUF_LEN 2048
|
||||
|
||||
#define CBUF_FLAG_CHAIN_HEAD 1
|
||||
#define CBUF_FLAG_CHAIN_TAIL 2
|
||||
|
||||
typedef struct cbuf {
|
||||
struct cbuf *next;
|
||||
size_t len;
|
||||
size_t total_len;
|
||||
void *data;
|
||||
int flags;
|
||||
char dat[CBUF_LEN - sizeof(struct cbuf *) - 2*sizeof(int) - sizeof(void *) - sizeof(int)];
|
||||
} cbuf;
|
||||
|
||||
int cbuf_init(void);
|
||||
cbuf *cbuf_get_chain(size_t len);
|
||||
cbuf *cbuf_get_chain_noblock(size_t len);
|
||||
void cbuf_free_chain_noblock(cbuf *buf);
|
||||
void cbuf_free_chain(cbuf *buf);
|
||||
|
||||
size_t cbuf_get_len(cbuf *buf);
|
||||
void *cbuf_get_ptr(cbuf *buf, size_t offset);
|
||||
int cbuf_is_contig_region(cbuf *buf, size_t start, size_t end);
|
||||
|
||||
int cbuf_memcpy_to_chain(cbuf *chain, size_t offset, const void *_src, size_t len);
|
||||
int cbuf_memcpy_from_chain(void *dest, cbuf *chain, size_t offset, size_t len);
|
||||
|
||||
int cbuf_user_memcpy_to_chain(cbuf *chain, size_t offset, const void *_src, size_t len);
|
||||
int cbuf_user_memcpy_from_chain(void *dest, cbuf *chain, size_t offset, size_t len);
|
||||
|
||||
uint16 cbuf_ones_cksum16(cbuf *chain, size_t offset, size_t len);
|
||||
|
||||
cbuf *cbuf_merge_chains(cbuf *chain1, cbuf *chain2);
|
||||
cbuf *cbuf_duplicate_chain(cbuf *chain, size_t offset, size_t len);
|
||||
|
||||
int cbuf_truncate_head(cbuf *chain, size_t trunc_bytes);
|
||||
int cbuf_truncate_tail(cbuf *chain, size_t trunc_bytes);
|
||||
|
||||
void cbuf_test(void);
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _CDEFS_H
|
||||
#define _CDEFS_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define __PRINTFLIKE(__fmt,__varargs) __attribute__((__format__ (__printf__, __fmt, __varargs)))
|
||||
# define __SCANFLIKE(__fmt,__varargs) __attribute__((__format__ (__scanf__, __fmt, __varargs)))
|
||||
# define __PURE __attribute__((__const__))
|
||||
#else
|
||||
# define __PRINTFLIKE(__fmt,__varargs)
|
||||
# define __SCANFLIKE(__fmt,__varargs)
|
||||
# define __PURE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_CONSOLE_H
|
||||
#define _KERNEL_CONSOLE_H
|
||||
|
||||
#include <stage2.h>
|
||||
#include <cdefs.h>
|
||||
|
||||
int con_init(kernel_args *ka);
|
||||
int kprintf(const char *fmt, ...) __PRINTFLIKE(1,2);
|
||||
int kprintf_xy(int x, int y, const char *fmt, ...) __PRINTFLIKE(3,4);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef _KERNEL_CPU_H
|
||||
#define _KERNEL_CPU_H
|
||||
|
||||
/**
|
||||
* @file kernel/cpu.h
|
||||
* @brief CPU Local per-CPU data structure
|
||||
*/
|
||||
|
||||
#include <stage2.h>
|
||||
#include <smp.h>
|
||||
#include <timer.h>
|
||||
|
||||
/**
|
||||
* @defgroup CPU CPU Structures (not architecture specific)
|
||||
* @ingroup OpenBeOS_Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* CPU local data structure
|
||||
*/
|
||||
/**
|
||||
* One structure per cpu.
|
||||
* The structure contains data that is local to the CPU,
|
||||
* helping reduce the amount of cache thrashing.
|
||||
*/
|
||||
typedef union cpu_ent {
|
||||
/** The information structure, followed by alignment bytes to make it ?? bytes */
|
||||
struct {
|
||||
/** Number of this CPU, starting from 0 */
|
||||
int cpu_num;
|
||||
/** If set this will force a reschedule when the quantum timer expires */
|
||||
int preempted;
|
||||
/** Quantum timer */
|
||||
struct timer_event quantum_timer;
|
||||
} info;
|
||||
/** Alignment bytes */
|
||||
uint32 align[16];
|
||||
} cpu_ent;
|
||||
|
||||
/**
|
||||
* Defined in core/cpu.c
|
||||
*/
|
||||
extern cpu_ent cpu[MAX_BOOT_CPUS];
|
||||
|
||||
/**
|
||||
* Perform pre-boot initialisation
|
||||
* @param ka The kernel_args structure
|
||||
*/
|
||||
int cpu_preboot_init(kernel_args *ka);
|
||||
/**
|
||||
* Initialise a CPU
|
||||
* @param ka The kernel_args structure
|
||||
*/
|
||||
int cpu_init(kernel_args *ka);
|
||||
|
||||
/**
|
||||
* Get a pointer to the CPU's local data structure
|
||||
*/
|
||||
/**
|
||||
* This is declared as an inline function in this header
|
||||
*/
|
||||
cpu_ent *get_cpu_struct(void);
|
||||
|
||||
/**
|
||||
* Inline declaration of get_cpu_struct(void)
|
||||
*/
|
||||
extern inline cpu_ent *get_cpu_struct(void) { return &cpu[smp_get_current_cpu()]; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#endif /* _KERNEL_CPU_H */
|
||||
Executable
+383
@@ -0,0 +1,383 @@
|
||||
/* $OpenBSD: ctlreg.h,v 1.6 2000/02/18 16:12:26 art Exp $ */
|
||||
/* $NetBSD: ctlreg.h,v 1.15 1997/07/20 18:55:03 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
* The President and Fellows of Harvard College. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Harvard University.
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratory.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ctlreg.h 8.1 (Berkeley) 6/11/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Sun4m support by Aaron Brown, Harvard University.
|
||||
* Changes Copyright (c) 1995 The President and Fellows of Harvard College.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Sun 4, 4c, and 4m control registers. (includes address space definitions
|
||||
* and some registers in control space).
|
||||
*/
|
||||
|
||||
/*
|
||||
* The Alternate address spaces.
|
||||
*/
|
||||
|
||||
/* 0x00 unused */
|
||||
/* 0x01 unused */
|
||||
#define ASI_CONTROL 0x02 /* cache enable, context reg, etc */
|
||||
#define ASI_SEGMAP 0x03 /* [4/4c] segment maps */
|
||||
#define ASI_SRMMUFP 0x03 /* [4m] ref mmu flush/probe */
|
||||
#define ASI_PTE 0x04 /* [4/4c] PTE space (pmegs) */
|
||||
#define ASI_SRMMU 0x04 /* [4m] ref mmu registers */
|
||||
#define ASI_REGMAP 0x06 /* [4/3-level MMU ] region maps */
|
||||
#define ASI_HWFLUSHSEG 0x05 /* [4/4c] hardware assisted version of FLUSHSEG */
|
||||
#define ASI_HWFLUSHPG 0x06 /* [4/4c] hardware assisted version of FLUSHPG */
|
||||
#define ASI_SRMMUDIAG 0x06 /* [4m] */
|
||||
#define ASI_HWFLUSHCTX 0x07 /* [4/4c] hardware assisted version of FLUSHCTX */
|
||||
|
||||
#define ASI_USERI 0x08 /* I-space (user) */
|
||||
#define ASI_KERNELI 0x09 /* I-space (kernel) */
|
||||
#define ASI_USERD 0x0a /* D-space (user) */
|
||||
#define ASI_KERNELD 0x0b /* D-space (kernel) */
|
||||
|
||||
#define ASI_FLUSHREG 0x7 /* [4/4c] flush cache by region */
|
||||
#define ASI_FLUSHSEG 0x0c /* [4/4c] flush cache by segment */
|
||||
#define ASI_FLUSHPG 0x0d /* [4/4c] flush cache by page */
|
||||
#define ASI_FLUSHCTX 0x0e /* [4/4c] flush cache by context */
|
||||
|
||||
#define ASI_DCACHE 0x0f /* [4] flush data cache */
|
||||
|
||||
#define ASI_ICACHETAG 0x0c /* [4m] instruction cache tag */
|
||||
#define ASI_ICACHEDATA 0x0d /* [4m] instruction cache data */
|
||||
#define ASI_DCACHETAG 0x0e /* [4m] data cache tag */
|
||||
#define ASI_DCACHEDATA 0x0f /* [4m] data cache data */
|
||||
#define ASI_IDCACHELFP 0x10 /* [4m] flush i&d cache line (page) */
|
||||
#define ASI_IDCACHELFS 0x11 /* [4m] flush i&d cache line (seg) */
|
||||
#define ASI_IDCACHELFR 0x12 /* [4m] flush i&d cache line (reg) */
|
||||
#define ASI_IDCACHELFC 0x13 /* [4m] flush i&d cache line (ctxt) */
|
||||
#define ASI_IDCACHELFU 0x14 /* [4m] flush i&d cache line (user) */
|
||||
#define ASI_BYPASS 0x20 /* [4m] sun ref mmu bypass,
|
||||
ie. direct phys access */
|
||||
#define ASI_HICACHECLR 0x31 /* [4m] hypersparc only: I-cache flash clear */
|
||||
#define ASI_ICACHECLR 0x36 /* [4m] ms1 only: I-cache flash clear */
|
||||
#define ASI_DCACHECLR 0x37 /* [4m] ms1 only: D-cache flash clear */
|
||||
#define ASI_DCACHEDIAG 0x39 /* [4m] data cache diagnostic register access */
|
||||
|
||||
/*
|
||||
* [4/4c] Registers in the control space (ASI_CONTROL).
|
||||
*/
|
||||
#define AC_IDPROM 0x00000000 /* [4] ID PROM */
|
||||
#define AC_CONTEXT 0x30000000 /* [4/4c] context register (byte) */
|
||||
#define AC_SYSENABLE 0x40000000 /* [4/4c] system enable register (byte) */
|
||||
#define AC_DVMA_ENABLE 0x50000000 /* [4] enable user dvma */
|
||||
#define AC_BUS_ERR 0x60000000 /* [4] bus error register */
|
||||
#define AC_SYNC_ERR 0x60000000 /* [4c] sync (memory) error reg */
|
||||
#define AC_SYNC_VA 0x60000004 /* [4c] sync error virtual addr */
|
||||
#define AC_ASYNC_ERR 0x60000008 /* [4c] async error reg */
|
||||
#define AC_ASYNC_VA 0x6000000c /* [4c] async error virtual addr */
|
||||
#define AC_DIAG_REG 0x70000000 /* [4] diagnostic reg */
|
||||
#define AC_CACHETAGS 0x80000000 /* [4/4c?] cache tag base address */
|
||||
#define AC_CACHEDATA 0x90000000 /* [4] cached data [sun4/400?] */
|
||||
#define AC_DVMA_MAP 0xd0000000 /* [4] user dvma map entries */
|
||||
#define AC_VMEINTVEC 0xe0000000 /* [4] vme interrupt vector */
|
||||
#define AC_SERIAL 0xf0000000 /* [4/4c] special serial port sneakiness */
|
||||
/* AC_SERIAL is not used in the kernel (it is for the PROM) */
|
||||
|
||||
/* XXX: does not belong here */
|
||||
#define ME_REG_IERR 0x80 /* memory err ctrl reg error intr pending bit */
|
||||
|
||||
/*
|
||||
* [4/4c]
|
||||
* Bits in sync error register. Reading the register clears these;
|
||||
* otherwise they accumulate. The error(s) occurred at the virtual
|
||||
* address stored in the sync error address register, and may have
|
||||
* been due to, e.g., what would usually be called a page fault.
|
||||
* Worse, the bits accumulate during instruction prefetch, so
|
||||
* various bits can be on that should be off.
|
||||
*/
|
||||
#define SER_WRITE 0x8000 /* error occurred during write */
|
||||
#define SER_INVAL 0x80 /* PTE had PG_V off */
|
||||
#define SER_PROT 0x40 /* operation violated PTE prot */
|
||||
#define SER_TIMEOUT 0x20 /* bus timeout (non-existent mem) */
|
||||
#define SER_SBUSERR 0x10 /* S-Bus bus error */
|
||||
#define SER_MEMERR 0x08 /* memory ecc/parity error */
|
||||
#define SER_SZERR 0x02 /* [4/vme?] size error, whatever that is */
|
||||
#define SER_WATCHDOG 0x01 /* watchdog reset (never see this) */
|
||||
|
||||
#define SER_BITS \
|
||||
"\20\20WRITE\10INVAL\7PROT\6TIMEOUT\5SBUSERR\4MEMERR\2SZERR\1WATCHDOG"
|
||||
|
||||
/*
|
||||
* [4/4c]
|
||||
* Bits in async error register (errors from DVMA or Sun-4 cache
|
||||
* writeback). The corresponding bit is also set in the sync error reg.
|
||||
*
|
||||
* A writeback invalid error means there is a bug in the PTE manager.
|
||||
*
|
||||
* The word is that the async error register does not work right.
|
||||
*/
|
||||
#define AER_WBINVAL 0x80 /* writeback found PTE without PG_V */
|
||||
#define AER_TIMEOUT 0x20 /* bus timeout */
|
||||
#define AER_DVMAERR 0x10 /* bus error during DVMA */
|
||||
|
||||
#define AER_BITS "\20\10WBINVAL\6TIMEOUT\5DVMAERR"
|
||||
|
||||
/*
|
||||
* [4/4c] Bits in system enable register.
|
||||
*/
|
||||
#define SYSEN_DVMA 0x20 /* Enable dvma */
|
||||
#define SYSEN_CACHE 0x10 /* Enable cache */
|
||||
#define SYSEN_IOCACHE 0x40 /* Enable IO cache */
|
||||
#define SYSEN_VIDEO 0x08 /* Enable on-board video */
|
||||
#define SYSEN_RESET 0x04 /* Reset the hardware */
|
||||
#define SYSEN_RESETVME 0x02 /* Reset the VME bus */
|
||||
|
||||
|
||||
/*
|
||||
* [4m] Bits in ASI_CONTROL? space, sun4m only.
|
||||
*/
|
||||
#define MXCC_ENABLE_ADDR 0x1c00a00 /* Enable register for MXCC */
|
||||
#define MXCC_ENABLE_BIT 0x4 /* Enable bit for MXCC */
|
||||
|
||||
/*
|
||||
* Bits in ASI_SRMMUFP space.
|
||||
* Bits 8-11 determine the type of flush/probe.
|
||||
* Address bits 12-31 hold the page frame.
|
||||
*/
|
||||
#define ASI_SRMMUFP_L3 (0<<8) /* probe L3 | flush L3 PTE */
|
||||
#define ASI_SRMMUFP_L2 (1<<8) /* probe L2 | flush L2/L3 PTE/PTD's */
|
||||
#define ASI_SRMMUFP_L1 (2<<8) /* probe L1 | flush L1/L2/L3 PTE/PTD's*/
|
||||
#define ASI_SRMMUFP_L0 (3<<8) /* probe L0 | flush L0/L1/L2/L3 PTE/PTD's */
|
||||
#define ASI_SRMMUFP_LN (4<<8) /* probe all | flush all levels */
|
||||
|
||||
/*
|
||||
* [4m] Registers and bits in the SPARC Reference MMU (ASI_SRMMU).
|
||||
*/
|
||||
#define SRMMU_PCR 0x00000000 /* Processor control register */
|
||||
#define SRMMU_CXTPTR 0x00000100 /* Context table pointer register */
|
||||
#define SRMMU_CXR 0x00000200 /* Context register */
|
||||
#define SRMMU_SFSR 0x00000300 /* Synchronous fault status reg */
|
||||
#define SRMMU_SFAR 0x00000400 /* Synchronous fault address reg */
|
||||
#define SRMMU_AFSR 0x00000500 /* Asynchronous fault status reg (HS)*/
|
||||
#define SRMMU_AFAR 0x00000600 /* Asynchronous fault address reg (HS)*/
|
||||
#define SRMMU_PCFG 0x00000600 /* Processor configuration reg (TURBO)*/
|
||||
#define SRMMU_TLBCTRL 0x00001000 /* TLB replacement control reg */
|
||||
|
||||
|
||||
/*
|
||||
* [4m] Bits in SRMMU control register. One set per module.
|
||||
*/
|
||||
#define VIKING_PCR_ME 0x00000001 /* MMU Enable */
|
||||
#define VIKING_PCR_NF 0x00000002 /* Fault inhibit bit */
|
||||
#define VIKING_PCR_PSO 0x00000080 /* Partial Store Ordering enable */
|
||||
#define VIKING_PCR_DCE 0x00000100 /* Data cache enable bit */
|
||||
#define VIKING_PCR_ICE 0x00000200 /* SuperSPARC instr. cache enable */
|
||||
#define VIKING_PCR_SB 0x00000400 /* Store buffer enable bit */
|
||||
#define VIKING_PCR_MB 0x00000800 /* MBus mode: 0=MXCC, 1=no MXCC */
|
||||
#define VIKING_PCR_PE 0x00001000 /* Enable memory parity checking */
|
||||
#define VIKING_PCR_BM 0x00002000 /* 1 iff booting */
|
||||
#define VIKING_PCR_SE 0x00004000 /* Coherent bus snoop enable */
|
||||
#define VIKING_PCR_AC 0x00008000 /* 1=cache non-MMU accesses */
|
||||
#define VIKING_PCR_TC 0x00010000 /* 1=cache table walks */
|
||||
|
||||
#define HYPERSPARC_PCR_ME 0x00000001 /* MMU Enable */
|
||||
#define HYPERSPARC_PCR_NF 0x00000002 /* Fault inhibit bit */
|
||||
#define HYPERSPARC_PCR_CE 0x00000100 /* Cache enable bit */
|
||||
#define HYPERSPARC_PCR_CM 0x00000400 /* Cache mode: 1=write-back */
|
||||
#define HYPERSPARC_PCR_MR 0x00000800 /* Memory reflection: 1 = on */
|
||||
#define HYPERSPARC_PCR_CS 0x00001000 /* cache size: 1=256k, 0=128k */
|
||||
#define HYPERSPARC_PCR_C 0x00002000 /* enable cache when MMU off */
|
||||
#define HYPERSPARC_PCR_BM 0x00004000 /* 1 iff booting */
|
||||
#define HYPERSPARC_PCR_MID 0x00078000 /* MBus module ID MID<3:0> */
|
||||
#define HYPERSPARC_PCR_WBE 0x00080000 /* Write buffer enable */
|
||||
#define HYPERSPARC_PCR_SE 0x00100000 /* Coherent bus snoop enable */
|
||||
#define HYPERSPARC_PCR_CWR 0x00200000 /* Cache wrap enable */
|
||||
|
||||
#define CYPRESS_PCR_ME 0x00000001 /* MMU Enable */
|
||||
#define CYPRESS_PCR_NF 0x00000002 /* Fault inhibit bit */
|
||||
#define CYPRESS_PCR_CE 0x00000100 /* Cache enable bit */
|
||||
#define CYPRESS_PCR_CL 0x00000200 /* Cache Lock (604 only) */
|
||||
#define CYPRESS_PCR_CM 0x00000400 /* Cache mode: 1=write-back */
|
||||
#define CYPRESS_PCR_MR 0x00000800 /* Memory reflection: 1=on (605 only) */
|
||||
#define CYPRESS_PCR_C 0x00002000 /* enable cache when MMU off */
|
||||
#define CYPRESS_PCR_BM 0x00004000 /* 1 iff booting */
|
||||
#define CYPRESS_PCR_MID 0x00078000 /* MBus module ID MID<3:0> (605 only) */
|
||||
#define CYPRESS_PCR_MV 0x00080000 /* Multichip Valid */
|
||||
#define CYPRESS_PCR_MCM 0x00300000 /* Multichip Mask */
|
||||
#define CYPRESS_PCR_MCA 0x00c00000 /* Multichip Address */
|
||||
|
||||
#define MS1_PCR_ME 0x00000001 /* MMU Enable */
|
||||
#define MS1_PCR_NF 0x00000002 /* Fault inhibit bit */
|
||||
#define MS1_PCR_DCE 0x00000100 /* Data cache enable */
|
||||
#define MS1_PCR_ICE 0x00000200 /* Instruction cache enable */
|
||||
#define MS1_PCR_RC 0x00000c00 /* DRAM Refresh control */
|
||||
#define MS1_PCR_PE 0x00001000 /* Enable memory parity checking */
|
||||
#define MS1_PCR_BM 0x00004000 /* 1 iff booting */
|
||||
#define MS1_PCR_AC 0x00008000 /* 1=cache if ME==0 (and [ID]CE on) */
|
||||
#define MS1_PCR_ID 0x00010000 /* 1=disable ITBR */
|
||||
#define MS1_PCR_PC 0x00020000 /* Parity control: 0=even,1=odd */
|
||||
#define MS1_PCR_MV 0x00100000 /* Memory data View (diag) */
|
||||
#define MS1_PCR_DV 0x00200000 /* Data View (diag) */
|
||||
#define MS1_PCR_AV 0x00400000 /* Address View (diag) */
|
||||
#define MS1_PCR_STW 0x00800000 /* Software Tablewalk enable */
|
||||
|
||||
#define SWIFT_PCR_ME 0x00000001 /* MMU Enable */
|
||||
#define SWIFT_PCR_NF 0x00000002 /* Fault inhibit bit */
|
||||
#define SWIFT_PCR_DCE 0x00000100 /* Data cache enable */
|
||||
#define SWIFT_PCR_ICE 0x00000200 /* Instruction cache enable */
|
||||
#define SWIFT_PCR_RC 0x00003c00 /* DRAM Refresh control */
|
||||
#define SWIFT_PCR_BM 0x00004000 /* 1 iff booting */
|
||||
#define SWIFT_PCR_AC 0x00008000 /* 1=cache if ME=0 (and [ID]CE on) */
|
||||
#define SWIFT_PCR_PA 0x00010000 /* TCX/SX control */
|
||||
#define SWIFT_PCR_PC 0x00020000 /* Parity control: 0=even,1=odd */
|
||||
#define SWIFT_PCR_PE 0x00040000 /* Enable memory parity checking */
|
||||
#define SWIFT_PCR_PMC 0x00180000 /* Page mode control */
|
||||
#define SWIFT_PCR_BF 0x00200000 /* Branch Folding */
|
||||
#define SWIFT_PCR_WP 0x00400000 /* Watch point enable */
|
||||
#define SWIFT_PCR_STW 0x00800000 /* Software Tablewalk enable */
|
||||
|
||||
#define TURBOSPARC_PCR_ME 0x00000001 /* MMU Enable */
|
||||
#define TURBOSPARC_PCR_NF 0x00000002 /* Fault inhibit bit */
|
||||
#define TURBOSPARC_PCR_ICS 0x00000004 /* I-cache snoop enable */
|
||||
#define TURBOSPARC_PCR_PSO 0x00000008 /* Partial Store order (ro!) */
|
||||
#define TURBOSPARC_PCR_DCE 0x00000100 /* Data cache enable */
|
||||
#define TURBOSPARC_PCR_ICE 0x00000200 /* Instruction cache enable */
|
||||
#define TURBOSPARC_PCR_RC 0x00003c00 /* DRAM Refresh control */
|
||||
#define TURBOSPARC_PCR_BM 0x00004000 /* 1 iff booting */
|
||||
#define TURBOSPARC_PCR_PC 0x00020000 /* Parity ctrl: 0=even,1=odd */
|
||||
#define TURBOSPARC_PCR_PE 0x00040000 /* Enable parity checking */
|
||||
#define TURBOSPARC_PCR_PMC 0x00180000 /* Page mode control */
|
||||
|
||||
/* The Turbosparc's Processor Configuration Register */
|
||||
#define TURBOSPARC_PCFG_SCC 0x00000007 /* e-cache config */
|
||||
#define TURBOSPARC_PCFG_SE 0x00000008 /* e-cache enable */
|
||||
#define TURBOSPARC_PCFG_US2 0x00000010 /* microsparc II compat */
|
||||
#define TURBOSPARC_PCFG_WT 0x00000020 /* write-through enable */
|
||||
#define TURBOSPARC_PCFG_SBC 0x000000c0 /* SBus Clock */
|
||||
#define TURBOSPARC_PCFG_WS 0x03800000 /* DRAM wait states */
|
||||
#define TURBOSPARC_PCFG_RAH 0x0c000000 /* DRAM Row Address Hold */
|
||||
#define TURBOSPARC_PCFG_AXC 0x30000000 /* AFX Clock */
|
||||
#define TURBOSPARC_PCFG_SNP 0x40000000 /* DVMA Snoop enable */
|
||||
#define TURBOSPARC_PCFG_IOCLK 0x80000000 /* I/O clock ratio */
|
||||
|
||||
|
||||
/* Implementation and Version fields are common to all modules */
|
||||
#define SRMMU_PCR_VER 0x0f000000 /* Version of MMU implementation */
|
||||
#define SRMMU_PCR_IMPL 0xf0000000 /* Implementation number of MMU */
|
||||
|
||||
|
||||
/* [4m] Bits in the Synchronous Fault Status Register */
|
||||
#define SFSR_EM 0x00020000 /* Error mode watchdog reset occurred */
|
||||
#define SFSR_CS 0x00010000 /* Control Space error */
|
||||
#define SFSR_PERR 0x00006000 /* Parity error code */
|
||||
#define SFSR_SB 0x00008000 /* SS: Store Buffer Error */
|
||||
#define SFSR_P 0x00004000 /* SS: Parity error */
|
||||
#define SFSR_UC 0x00001000 /* Uncorrectable error */
|
||||
#define SFSR_TO 0x00000800 /* S-Bus timeout */
|
||||
#define SFSR_BE 0x00000400 /* S-Bus bus error */
|
||||
#define SFSR_LVL 0x00000300 /* Pagetable level causing the fault */
|
||||
#define SFSR_AT 0x000000e0 /* Access type */
|
||||
#define SFSR_FT 0x0000001c /* Fault type */
|
||||
#define SFSR_FAV 0x00000002 /* Fault Address is valid */
|
||||
#define SFSR_OW 0x00000001 /* Overwritten with new fault */
|
||||
|
||||
#define SFSR_BITS \
|
||||
"\20\21CSERR\17PARITY\16SYSERR\15UNCORR\14TIMEOUT\13BUSERR\2FAV\1OW"
|
||||
|
||||
/* [4m] Synchronous Fault Types */
|
||||
#define SFSR_FT_NONE (0 << 2) /* no fault */
|
||||
#define SFSR_FT_INVADDR (1 << 2) /* invalid address fault */
|
||||
#define SFSR_FT_PROTERR (2 << 2) /* protection fault */
|
||||
#define SFSR_FT_PRIVERR (3 << 2) /* privelege violation */
|
||||
#define SFSR_FT_TRANSERR (4 << 2) /* translation fault */
|
||||
#define SFSR_FT_BUSERR (5 << 2) /* access bus error */
|
||||
#define SFSR_FT_INTERR (6 << 2) /* internal error */
|
||||
#define SFSR_FT_RESERVED (7 << 2) /* reserved */
|
||||
|
||||
/* [4m] Synchronous Fault Access Types */
|
||||
#define SFSR_AT_LDUDATA (0 << 5) /* Load user data */
|
||||
#define SFSR_AT_LDSDATA (1 << 5) /* Load supervisor data */
|
||||
#define SFSR_AT_LDUTEXT (2 << 5) /* Load user text */
|
||||
#define SFSR_AT_LDSTEXT (3 << 5) /* Load supervisor text */
|
||||
#define SFSR_AT_STUDATA (4 << 5) /* Store user data */
|
||||
#define SFSR_AT_STSDATA (5 << 5) /* Store supervisor data */
|
||||
#define SFSR_AT_STUTEXT (6 << 5) /* Store user text */
|
||||
#define SFSR_AT_STSTEXT (7 << 5) /* Store supervisor text */
|
||||
#define SFSR_AT_SUPERVISOR (1 << 5) /* Set iff supervisor */
|
||||
#define SFSR_AT_TEXT (2 << 5) /* Set iff text */
|
||||
#define SFSR_AT_STORE (4 << 5) /* Set iff store */
|
||||
|
||||
/* [4m] Synchronous Fault PT Levels */
|
||||
#define SFSR_LVL_0 (0 << 8) /* Context table entry */
|
||||
#define SFSR_LVL_1 (1 << 8) /* Region table entry */
|
||||
#define SFSR_LVL_2 (2 << 8) /* Segment table entry */
|
||||
#define SFSR_LVL_3 (3 << 8) /* Page table entry */
|
||||
|
||||
/* [4m] Asynchronous Fault Status Register bits */
|
||||
#define AFSR_AFO 0x00000001 /* Async. fault occurred */
|
||||
#define AFSR_AFA 0x000000f0 /* Bits <35:32> of faulting phys addr */
|
||||
#define AFSR_AFA_RSHIFT 4 /* Shift to get AFA to bit 0 */
|
||||
#define AFSR_AFA_LSHIFT 28 /* Shift to get AFA to bit 32 */
|
||||
#define AFSR_BE 0x00000400 /* Bus error */
|
||||
#define AFSR_TO 0x00000800 /* Bus timeout */
|
||||
#define AFSR_UC 0x00001000 /* Uncorrectable error */
|
||||
#define AFSR_SE 0x00002000 /* System error */
|
||||
|
||||
#define AFSR_BITS "\20\16SYSERR\15UNCORR\14TIMEOUT\13BUSERR\1AFO"
|
||||
|
||||
/* [4m] TLB Replacement Control Register bits */
|
||||
#define TLBC_DISABLE 0x00000020 /* Disable replacement counter */
|
||||
#define TLBC_RCNTMASK 0x0000001f /* Replacement counter (0-31) */
|
||||
|
||||
/*
|
||||
* The Ross Hypersparc has an Instruction Cache Control Register (ICCR)
|
||||
* It contains an enable bit for the on-chip instruction cache and a bit
|
||||
* that controls whether a FLUSH instruction causes an Unimplemented
|
||||
* Flush Trap or just flushes the appropriate instruction cache line.
|
||||
* The ICCR register is implemented as Ancillary State register number 31.
|
||||
*/
|
||||
#define HYPERSPARC_ICCR_ICE 1 /* Instruction cache enable */
|
||||
#define HYPERSPARC_ICCR_FTD 2 /* Unimpl. flush trap disable */
|
||||
#define HYPERSPARC_ASRNUM_ICCR 31 /* ICCR == ASR#31 */
|
||||
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _CTYPE_H
|
||||
#define _CTYPE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
int isalnum(int c);
|
||||
int isalpha(int c);
|
||||
int iscntrl(int c);
|
||||
int isdigit(int c);
|
||||
int isgraph(int c);
|
||||
int islower(int c);
|
||||
int isprint(int c);
|
||||
int ispunct(int c);
|
||||
int isspace(int c);
|
||||
int isupper(int c);
|
||||
int isxdigit(int c);
|
||||
int isascii(int c);
|
||||
int toascii(int c);
|
||||
|
||||
unsigned char tolower(unsigned char c);
|
||||
unsigned char toupper(unsigned char c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+16
@@ -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 <boot/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
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_DEBUG_H
|
||||
#define _KERNEL_DEBUG_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <stage2.h>
|
||||
#include <cdefs.h>
|
||||
|
||||
extern int dbg_register_file[2][14]; /* XXXmpetit -- must be made generic */
|
||||
|
||||
int dbg_init(kernel_args *ka);
|
||||
int dbg_init2(kernel_args *ka);
|
||||
char dbg_putch(char c);
|
||||
void dbg_puts(const char *s);
|
||||
bool dbg_set_serial_debug(bool new_val);
|
||||
bool dbg_get_serial_debug(void);
|
||||
int dprintf(const char *fmt, ...) __PRINTFLIKE(1,2);
|
||||
int panic(const char *fmt, ...) __PRINTFLIKE(1,2);
|
||||
void kernel_debugger(void);
|
||||
int dbg_add_command(void (*func)(int, char **), const char *cmd, const char *desc);
|
||||
|
||||
extern void dbg_save_registers(int *); /* arch provided */
|
||||
|
||||
#endif
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _SYS_DEFINES_H
|
||||
#define _SYS_DEFINES_H
|
||||
|
||||
/* the following two are for filesystem paths and names */
|
||||
#define SYS_MAX_NAME_LEN 128
|
||||
#define SYS_MAX_PATH_LEN 512
|
||||
|
||||
/* the following is for OS object names: semaphores, threads, regions, etc.. */
|
||||
#define SYS_MAX_OS_NAME_LEN 32
|
||||
|
||||
#define SYS_THREAD_ARG_LENGTH_MAX 255
|
||||
|
||||
#endif
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_DEV_H
|
||||
#define _KERNEL_DEV_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <stage2.h>
|
||||
|
||||
int dev_init(kernel_args *ka);
|
||||
image_id dev_load_dev_module(const char *name, const char *directory);
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _DEVFS_H
|
||||
#define _DEVFS_H
|
||||
|
||||
#include <vfs.h>
|
||||
#include <drivers.h>
|
||||
|
||||
int bootstrap_devfs(void);
|
||||
|
||||
/* api drivers will use to publish devices */
|
||||
int devfs_publish_device(const char *path, void *ident, device_hooks *calls);
|
||||
|
||||
#endif /* _DEVFS_H */
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _NEWOS_KERNEL_ARCH_DEVS_H
|
||||
#define _NEWOS_KERNEL_ARCH_DEVS_H
|
||||
|
||||
#include <stage2.h>
|
||||
|
||||
int devs_init(kernel_args *ka);
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user