CTAOS v3
This commit is contained in:
30
SysCore/include/_null.h
Normal file
30
SysCore/include/_null.h
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#ifndef __NULL_H
|
||||
#define __NULL_H
|
||||
|
||||
/******************************
|
||||
* _null.h *
|
||||
* - NULL declaration *
|
||||
******************************/
|
||||
|
||||
#if defined (_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#ifdef NULL
|
||||
#undef NULL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
/* standard NULL declaration */
|
||||
#define NULL 0
|
||||
}
|
||||
#else
|
||||
/* standard NULL declaration */
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
39
SysCore/include/bootinfo.h
Normal file
39
SysCore/include/bootinfo.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef _BOOTINFO_H
|
||||
#define _BOOTINFO_H
|
||||
//****************************************************************************
|
||||
//** bootinfo.h
|
||||
//****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//! multiboot info structure passed from boot loader
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint32_t m_flags;
|
||||
uint32_t m_memoryLo;
|
||||
uint32_t m_memoryHi;
|
||||
uint32_t m_bootDevice;
|
||||
uint32_t m_cmdLine;
|
||||
uint32_t m_modsCount;
|
||||
uint32_t m_modsAddr;
|
||||
uint32_t m_syms0;
|
||||
uint32_t m_syms1;
|
||||
uint32_t m_syms2;
|
||||
uint32_t m_mmap_length;
|
||||
uint32_t m_mmap_addr;
|
||||
uint32_t m_drives_length;
|
||||
uint32_t m_drives_addr;
|
||||
uint32_t m_config_table;
|
||||
uint32_t m_bootloader_name;
|
||||
uint32_t m_apm_table;
|
||||
uint32_t m_vbe_control_info;
|
||||
uint32_t m_vbe_mode_info;
|
||||
uint16_t m_vbe_mode;
|
||||
uint32_t m_vbe_interface_addr;
|
||||
uint16_t m_vbe_interface_len;
|
||||
} multiboot_info ;
|
||||
|
||||
|
||||
#endif
|
||||
|
9
SysCore/include/cctype
Normal file
9
SysCore/include/cctype
Normal file
@ -0,0 +1,9 @@
|
||||
// cerrno standard header
|
||||
|
||||
#ifndef _CSTDCTYPE_
|
||||
#define _CSTDCTYPE_
|
||||
#include <ctype.h>
|
||||
|
||||
#endif /* _CSTDCTYPE_ */
|
||||
|
||||
|
30
SysCore/include/conio.h
Normal file
30
SysCore/include/conio.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __CONIO_H
|
||||
#define __CONIO_H
|
||||
#define _ATTRIB 0x0F
|
||||
|
||||
extern byte default_background, default_foreground;
|
||||
extern char hex[16];
|
||||
|
||||
extern void itoa (int value, char *string, unsigned int radix);
|
||||
extern int printf(const char* str, ...);
|
||||
extern int abs(int x);
|
||||
extern void graphics_init();
|
||||
extern void text_mode_cursor(int x, int y);
|
||||
extern void set_default_colors(byte back, byte fore);
|
||||
extern void clrscr();
|
||||
extern void scroll(int n);
|
||||
extern void prev_line();
|
||||
extern void next_line();
|
||||
extern void putc_pos_font(int x, int y, char c, byte back, byte fore);
|
||||
extern void putc_pos(int x, int y, char c);
|
||||
extern void putc_font(char c, byte back, byte fore);
|
||||
extern void putc(char c);
|
||||
extern void puts_pos_font(int x, int y, const char *str, byte back, byte fore);
|
||||
extern void puts_pos(int x, int y, const char *str);
|
||||
extern void puts(const char *str);
|
||||
extern void puts_font(const char *str, byte back, byte fore);
|
||||
extern void put_hex(unsigned int alpha);
|
||||
extern void put_hex_pos(int x, int y, unsigned int alpha);
|
||||
extern void put_bin (int x, int y, byte xz);
|
||||
|
||||
#endif
|
50
SysCore/include/crtdefs.h
Normal file
50
SysCore/include/crtdefs.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef _CRTDEFS_H
|
||||
#define _CRTDEFS_H
|
||||
|
||||
/******************************
|
||||
* crtdefs.h *
|
||||
* - basic definitions *
|
||||
******************************/
|
||||
|
||||
#if !defined (CRT_EXPORTS) && !defined (CRT_IMPORTS)
|
||||
#define CRT_EXPORTS
|
||||
#endif
|
||||
|
||||
#undef far
|
||||
#undef near
|
||||
#undef pascal
|
||||
|
||||
#define far
|
||||
#define near
|
||||
|
||||
#ifdef _WIN32
|
||||
#if (!defined(_MAC)) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
|
||||
#define pascal __stdcall
|
||||
#else
|
||||
#define pascal
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MAC
|
||||
#ifndef _CRTLIB
|
||||
#define _CRTLIB __cdecl
|
||||
#endif
|
||||
#ifdef _68K_
|
||||
#ifndef __pascal
|
||||
#define __pascal
|
||||
#endif
|
||||
#endif
|
||||
#elif defined( _WIN32)
|
||||
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
|
||||
#ifndef _CRTLIB
|
||||
#define _CRTLIB __stdcall
|
||||
#endif
|
||||
#else
|
||||
#ifndef _CRTLIB
|
||||
#define _CRTLIB
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
7
SysCore/include/cstdarg
Normal file
7
SysCore/include/cstdarg
Normal file
@ -0,0 +1,7 @@
|
||||
// cerrno standard header
|
||||
|
||||
#ifndef _CSTDARG_
|
||||
#define _CSTDARG_
|
||||
#include <stdarg.h>
|
||||
|
||||
#endif /* _CSTDARG_ */
|
9
SysCore/include/cstdint
Normal file
9
SysCore/include/cstdint
Normal file
@ -0,0 +1,9 @@
|
||||
// cerrno standard header
|
||||
|
||||
#ifndef _CSTDINT_
|
||||
#define _CSTDINT_
|
||||
#include <stdint.h>
|
||||
|
||||
#endif /* _CSTDINT_ */
|
||||
|
||||
|
9
SysCore/include/cstring
Normal file
9
SysCore/include/cstring
Normal file
@ -0,0 +1,9 @@
|
||||
// cstring standard header
|
||||
|
||||
#ifndef _CSTDSTRING_
|
||||
#define _CSTDSTRING_
|
||||
#include <string.h>
|
||||
|
||||
#endif /* _CSTDINT_ */
|
||||
|
||||
|
55
SysCore/include/ctype.h
Normal file
55
SysCore/include/ctype.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef __CTYPE_H
|
||||
#define __CTYPE_H
|
||||
|
||||
/******************************
|
||||
* ctype.h *
|
||||
* - character macros *
|
||||
******************************/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Get rid of conversion warnings
|
||||
#pragma warning (disable:4244)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern char _ctype[];
|
||||
|
||||
/* Constants */
|
||||
|
||||
#define CT_UP 0x01 /* upper case */
|
||||
#define CT_LOW 0x02 /* lower case */
|
||||
#define CT_DIG 0x04 /* digit */
|
||||
#define CT_CTL 0x08 /* control */
|
||||
#define CT_PUN 0x10 /* punctuation */
|
||||
#define CT_WHT 0x20 /* white space (space/cr/lf/tab) */
|
||||
#define CT_HEX 0x40 /* hex digit */
|
||||
#define CT_SP 0x80 /* hard space (0x20) */
|
||||
|
||||
/* Basic macros */
|
||||
|
||||
#define isalnum(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG))
|
||||
#define isalpha(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW))
|
||||
#define iscntrl(c) ((_ctype + 1)[(unsigned)(c)] & (CT_CTL))
|
||||
#define isdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG))
|
||||
#define isgraph(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG))
|
||||
#define islower(c) ((_ctype + 1)[(unsigned)(c)] & (CT_LOW))
|
||||
#define isprint(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP))
|
||||
#define ispunct(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN))
|
||||
#define isspace(c) ((_ctype + 1)[(unsigned)(c)] & (CT_WHT))
|
||||
#define isupper(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP))
|
||||
#define isxdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX))
|
||||
#define isascii(c) ((unsigned)(c) <= 0x7F)
|
||||
#define toascii(c) ((unsigned)(c) & 0x7F)
|
||||
#define tolower(c) (isupper(c) ? c + 'a' - 'A' : c)
|
||||
#define toupper(c) (islower(c) ? c + 'A' - 'a' : c)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
180
SysCore/include/hal.h
Normal file
180
SysCore/include/hal.h
Normal file
@ -0,0 +1,180 @@
|
||||
#ifndef _HAL_H
|
||||
#define _HAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#define far
|
||||
#define near
|
||||
|
||||
#define i86_start_interrupts() __asm__ __volatile__ ("sti");
|
||||
#define i86_clear_interrupts() __asm__ __volatile__ ("cli");
|
||||
|
||||
extern volatile TIME _internal_clock;
|
||||
|
||||
// initialize hardware abstraction layer
|
||||
extern void i86_hal_initialize ();
|
||||
|
||||
// shutdown hardware abstraction layer
|
||||
extern int i86_hal_shutdown ();
|
||||
|
||||
//! notifies hal interrupt is done
|
||||
//extern void interruptdone (unsigned int intno);
|
||||
|
||||
//! output sound to speaker
|
||||
extern void sound (unsigned frequency);
|
||||
|
||||
//! read byte from device using port mapped io
|
||||
//extern unsigned char inportb (unsigned short _port);
|
||||
|
||||
//! write byte to device through port mapped io
|
||||
//extern void outportb (unsigned short _port, unsigned char _data);
|
||||
|
||||
//! sets new interrupt vector
|
||||
//extern void setvect (int intno, void ( far &vect) ( ) );
|
||||
|
||||
//! returns current interrupt vector
|
||||
//extern void ( far * getvect (int intno)) ( );
|
||||
|
||||
//! returns cpu vender
|
||||
extern const char* get_cpu_vender ();
|
||||
|
||||
extern void reboot();
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* KEYBOARD STUFF *
|
||||
**********************************************************************/
|
||||
#define KB_KEY_LSHIFT 0x81 // 1000 0001
|
||||
#define KB_KEY_RSHIFT 0X82 // 1000 0010
|
||||
#define KB_KEY_LALT 0X84 // 1000 0100
|
||||
#define KB_KEY_RALT 0x88 // 1000 1000
|
||||
#define KB_KEY_LCTRL 0x90 // 1001 0000
|
||||
#define KB_KEY_RCTRL 0xA0 // 1010 0000
|
||||
#define KB_KEY_FSHIFT 0xC0 // 1100 0000
|
||||
extern volatile byte kb_modifier_status;
|
||||
|
||||
#define KB_PREFIX_GRAY 0x01 // Gray
|
||||
#define KB_PREFIX_BREAK 0x02 // Break code
|
||||
#define KB_PREFIX_PAUSE 0x04 // Pause/break key
|
||||
#define KB_PREFIX_PAUSE1 0x08 // Recieved first byte from pause/break
|
||||
extern volatile byte kb_prefix;
|
||||
|
||||
#define KB_KEY_SCROLL 0xF1 // 1111 0001
|
||||
#define KB_KEY_NUM 0xF2 // 1111 0010
|
||||
#define KB_KEY_CAPS 0xF4 // 1111 0100
|
||||
extern volatile byte kb_lights_status;
|
||||
|
||||
extern byte kb_scancode_set;
|
||||
#define KB_KEY_PAUSE 0x00
|
||||
#define KB_KEY_F9 0x01
|
||||
#define KB_KEY_F7 0x02
|
||||
#define KB_KEY_F5 0X03
|
||||
#define KB_KEY_F3 0x04
|
||||
#define KB_KEY_F1 0x05
|
||||
#define KB_KEY_F2 0x06
|
||||
#define KB_KEY_F12 0x07
|
||||
#define KB_KEY_PRINTSCRN 0x08
|
||||
#define KB_KEY_F10 0x09
|
||||
#define KB_KEY_F8 0x0A
|
||||
#define KB_KEY_F6 0x0B
|
||||
#define KB_KEY_F4 0x0C
|
||||
#define KB_KEY_TAB 0x0D
|
||||
#define KB_KEY_TILDA 0x0E
|
||||
#define KB_KEY_Q 0x15
|
||||
#define KB_KEY_1 0x16
|
||||
#define KB_KEY_Z 0x1A
|
||||
#define KB_KEY_S 0x1B
|
||||
#define KB_KEY_A 0x1C
|
||||
#define KB_KEY_W 0x1D
|
||||
#define KB_KEY_2 0x1E
|
||||
#define KB_KEY_LWIN 0x1F
|
||||
#define KB_KEY_C 0x21
|
||||
#define KB_KEY_X 0x22
|
||||
#define KB_KEY_D 0x23
|
||||
#define KB_KEY_E 0x24
|
||||
#define KB_KEY_4 0x25
|
||||
#define KB_KEY_3 0x26
|
||||
#define KB_KEY_RWIN 0x27
|
||||
#define KB_KEY_SPACE 0x29
|
||||
#define KB_KEY_V 0x2A
|
||||
#define KB_KEY_F 0x2B
|
||||
#define KB_KEY_T 0x2C
|
||||
#define KB_KEY_R 0x2D
|
||||
#define KB_KEY_5 0x2E
|
||||
#define KB_KEY_MENU 0x2F
|
||||
#define KB_KEY_N 0x31
|
||||
#define KB_KEY_B 0x32
|
||||
#define KB_KEY_H 0x33
|
||||
#define KB_KEY_G 0x34
|
||||
#define KB_KEY_Y 0x35
|
||||
#define KB_KEY_6 0x36
|
||||
#define KB_KEY_M 0x3A
|
||||
#define KB_KEY_J 0x3B
|
||||
#define KB_KEY_U 0x3C
|
||||
#define KB_KEY_7 0x3D
|
||||
#define KB_KEY_8 0x3E
|
||||
#define KB_KEY_COMMA 0x41
|
||||
#define KB_KEY_K 0x42
|
||||
#define KB_KEY_I 0x43
|
||||
#define KB_KEY_O 0x44
|
||||
#define KB_KEY_0 0x45
|
||||
#define KB_KEY_9 0x46
|
||||
#define KB_KEY_PERIOD 0x49
|
||||
#define KB_KEY_SLASH 0x4A
|
||||
#define KB_KEY_L 0x4B
|
||||
#define KB_KEY_SEMICOLON 0x4C
|
||||
#define KB_KEY_P 0x4D
|
||||
#define KB_KEY_DASH 0x4E
|
||||
#define KB_KEY_APOSTROPHE 0x52
|
||||
#define KB_KEY_LBRACKET 0x54
|
||||
#define KB_KEY_EQUAL 0x55
|
||||
#define KB_KEY_NUMPAD_ENTER 0x59
|
||||
#define KB_KEY_ENTER 0x5A
|
||||
#define KB_KEY_RBRACKET 0x5B
|
||||
#define KB_KEY_BACKSLASH 0x5D
|
||||
#define KB_KEY_END 0x5E
|
||||
#define KB_KEY_LEFT 0x5F
|
||||
#define KB_KEY_HOME 0x60
|
||||
#define KB_KEY_INSERT 0x61
|
||||
#define KB_KEY_DELETE 0x62
|
||||
#define KB_KEY_DOWN 0x63
|
||||
#define KB_KEY_RIGHT 0x64
|
||||
#define KB_KEY_UP 0x65
|
||||
#define KB_KEY_BACKSPACE 0x66
|
||||
#define KB_KEY_PGDOWN 0x67
|
||||
#define KB_KEY_PGUP 0x68
|
||||
#define KB_KEY_NUMPAD_1 0x69
|
||||
#define KB_KEY_NUMPAD_SLASH 0x6A
|
||||
#define KB_KEY_NUMPAD_4 0x6B
|
||||
#define KB_KEY_NUMPAD_7 0x6C
|
||||
#define KB_KEY_NUMPAD_0 0x70
|
||||
#define KB_KEY_NUMPAD_COLON 0x71
|
||||
#define KB_KEY_NUMPAD_2 0x72
|
||||
#define KB_KEY_NUMPAD_5 0x73
|
||||
#define KB_KEY_NUMPAD_6 0x74
|
||||
#define KB_KEY_NUMPAD_8 0x75
|
||||
#define KB_KEY_ESC 0x76
|
||||
#define KB_KEY_F11 0x78
|
||||
#define KB_KEY_NUMPAD_PLUS 0x79
|
||||
#define KB_KEY_NUMPAD_3 0x7A
|
||||
#define KB_KEY_NUMPAD_MINUS 0x7B
|
||||
#define KB_KEY_NUMPAD_ASTERISK 0x7C
|
||||
#define KB_KEY_NUMPAD_9 0x7D
|
||||
|
||||
|
||||
typedef struct {
|
||||
byte status;
|
||||
byte lights;
|
||||
byte scancode;
|
||||
byte character;
|
||||
} kb_key;
|
||||
|
||||
|
||||
extern char getch();
|
||||
extern kb_key getkey();
|
||||
extern char scancode_to_ascii(byte scancode, byte status);
|
||||
extern byte get_key_status(byte scancode);
|
||||
extern void kb_set_repeat(float rate, int delay);
|
||||
extern void kb_set_LEDs(byte status);
|
||||
|
||||
#endif
|
100
SysCore/include/regs.h
Normal file
100
SysCore/include/regs.h
Normal file
@ -0,0 +1,100 @@
|
||||
#ifndef _REGS_H_INCLUDED
|
||||
#define _REGS_H_INCLUDED
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** regs.h
|
||||
//**
|
||||
//** processor register structures and declarations. This interface abstracts
|
||||
//** register names behind a common, portable interface
|
||||
//**
|
||||
//****************************************************************************
|
||||
|
||||
//============================================================================
|
||||
// INTERFACE REQUIRED HEADERS
|
||||
//============================================================================
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//============================================================================
|
||||
// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE STRUCTURES / UTILITY CLASSES
|
||||
//============================================================================
|
||||
|
||||
//! 32 bit registers
|
||||
typedef struct {
|
||||
uint32_t eax, ebx, ecx, edx, esi, edi, ebp, esp, eflags;
|
||||
uint8_t cflag;
|
||||
} _R32BIT;
|
||||
|
||||
//! 16 bit registers
|
||||
typedef struct {
|
||||
uint16_t ax, bx, cx, dx, si, di, bp, sp, es, cs, ss, ds, flags;
|
||||
uint8_t cflag;
|
||||
} _R16BIT ;
|
||||
|
||||
//! 16 bit registers expressed in 32 bit registers
|
||||
typedef struct {
|
||||
uint16_t ax, axh, bx, bxh, cx, cxh, dx, dxh;
|
||||
uint16_t si, di, bp, sp, es, cs, ss, ds, flags;
|
||||
uint8_t cflags;
|
||||
} _R16BIT32 ;
|
||||
|
||||
//! 8 bit registers
|
||||
typedef struct {
|
||||
uint8_t al, ah, bl, bh, cl, ch, dl, dh;
|
||||
} _R8BIT;
|
||||
|
||||
//! 8 bit registers expressed in 32 bit registers
|
||||
typedef struct {
|
||||
uint8_t al, ah; uint16_t axh;
|
||||
uint8_t bl, bh; uint16_t bxh;
|
||||
uint8_t cl, ch; uint16_t cxh;
|
||||
uint8_t dl, dh; uint16_t dxh;
|
||||
} _R8BIT32;
|
||||
|
||||
//! 8 and 16 bit registers union
|
||||
typedef union {
|
||||
_R16BIT x;
|
||||
_R8BIT h;
|
||||
}_INTR16;
|
||||
|
||||
//! 32 bit, 16 bit and 8 bit registers union
|
||||
typedef union {
|
||||
_R32BIT x;
|
||||
_R16BIT32 l;
|
||||
_R8BIT32 h;
|
||||
} _INTR32;
|
||||
|
||||
/* This defines what the stack looks like after an ISR was running */
|
||||
typedef struct
|
||||
{
|
||||
unsigned int gs, fs, es, ds; /* pushed the segs last */
|
||||
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
|
||||
unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */
|
||||
unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
|
||||
} ISR_stack_regs;
|
||||
|
||||
|
||||
//============================================================================
|
||||
// INTERFACE DATA DECLARATIONS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE FUNCTION PROTOTYPES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE OBJECT CLASS DEFINITIONS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE TRAILING HEADERS
|
||||
//============================================================================
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** END regs.h
|
||||
//**
|
||||
//****************************************************************************
|
||||
#endif
|
23
SysCore/include/size_t.h
Normal file
23
SysCore/include/size_t.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __SIZE_T_H
|
||||
#define __SIZE_T_H
|
||||
|
||||
/************************************
|
||||
* size_t.h *
|
||||
* - Standard C/C++ size_t type *
|
||||
************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* standard size_t type */
|
||||
typedef unsigned size_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
46
SysCore/include/stdarg.h
Normal file
46
SysCore/include/stdarg.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef __STDARG_H
|
||||
#define __STDARG_H
|
||||
|
||||
|
||||
/******************************
|
||||
* [filename] *
|
||||
* - [description] *
|
||||
******************************/
|
||||
|
||||
// INTERFACE REQUIRED HEADERS
|
||||
#include <va_list.h>
|
||||
|
||||
|
||||
// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* width of stack == width of int */
|
||||
#define STACKITEM int
|
||||
|
||||
/* round up width of objects pushed on stack. The expression before the
|
||||
& ensures that we get 0 for objects of size 0. */
|
||||
#define VA_SIZE(TYPE) \
|
||||
((sizeof(TYPE) + sizeof(STACKITEM) - 1) \
|
||||
& ~(sizeof(STACKITEM) - 1))
|
||||
|
||||
/* &(LASTARG) points to the LEFTMOST argument of the function call
|
||||
(before the ...) */
|
||||
#define va_start(AP, LASTARG) \
|
||||
(AP=((va_list)&(LASTARG) + VA_SIZE(LASTARG)))
|
||||
|
||||
/* nothing for va_end */
|
||||
#define va_end(AP)
|
||||
|
||||
#define va_arg(AP, TYPE) \
|
||||
(AP += VA_SIZE(TYPE), *((TYPE *)(AP - VA_SIZE(TYPE))))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
163
SysCore/include/stdint.h
Normal file
163
SysCore/include/stdint.h
Normal file
@ -0,0 +1,163 @@
|
||||
|
||||
#ifndef _STDINT_H
|
||||
#define _STDINT_H
|
||||
|
||||
#define __need_wint_t
|
||||
#define __need_wchar_t
|
||||
|
||||
|
||||
/***************************************
|
||||
* stdint.h *
|
||||
* - Standard C++ integral types *
|
||||
***************************************/
|
||||
|
||||
/* 7.18.1.1 Exact-width integer types */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned uint32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
/* 7.18.1.2 Minimum-width integer types */
|
||||
typedef signed char int_least8_t;
|
||||
typedef unsigned char uint_least8_t;
|
||||
typedef short int_least16_t;
|
||||
typedef unsigned short uint_least16_t;
|
||||
typedef int int_least32_t;
|
||||
typedef unsigned uint_least32_t;
|
||||
typedef long long int_least64_t;
|
||||
typedef unsigned long long uint_least64_t;
|
||||
|
||||
/* 7.18.1.3 Fastest minimum-width integer types
|
||||
* Not actually guaranteed to be fastest for all purposes
|
||||
* Here we use the exact-width types for 8 and 16-bit ints.
|
||||
*/
|
||||
typedef char int_fast8_t;
|
||||
typedef unsigned char uint_fast8_t;
|
||||
typedef short int_fast16_t;
|
||||
typedef unsigned short uint_fast16_t;
|
||||
typedef int int_fast32_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
typedef long long int_fast64_t;
|
||||
typedef unsigned long long uint_fast64_t;
|
||||
|
||||
/* 7.18.1.4 Integer types capable of holding object pointers */
|
||||
typedef int intptr_t;
|
||||
typedef unsigned uintptr_t;
|
||||
|
||||
/* 7.18.1.5 Greatest-width integer types */
|
||||
typedef long long intmax_t;
|
||||
typedef unsigned long long uintmax_t;
|
||||
|
||||
/* 7.18.2 Limits of specified-width integer types */
|
||||
#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
|
||||
|
||||
/* 7.18.2.1 Limits of exact-width integer types */
|
||||
#define INT8_MIN (-128)
|
||||
#define INT16_MIN (-32768)
|
||||
#define INT32_MIN (-2147483647 - 1)
|
||||
#define INT64_MIN (-9223372036854775807LL - 1)
|
||||
|
||||
#define INT8_MAX 127
|
||||
#define INT16_MAX 32767
|
||||
#define INT32_MAX 2147483647
|
||||
#define INT64_MAX 9223372036854775807LL
|
||||
|
||||
#define UINT8_MAX 0xff /* 255U */
|
||||
#define UINT16_MAX 0xffff /* 65535U */
|
||||
#define UINT32_MAX 0xffffffff /* 4294967295U */
|
||||
#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
|
||||
|
||||
/* 7.18.2.2 Limits of minimum-width integer types */
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
/* 7.18.2.3 Limits of fastest minimum-width integer types */
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
/* 7.18.2.4 Limits of integer types capable of holding
|
||||
object pointers */
|
||||
#define INTPTR_MIN INT32_MIN
|
||||
#define INTPTR_MAX INT32_MAX
|
||||
#define UINTPTR_MAX UINT32_MAX
|
||||
|
||||
/* 7.18.2.5 Limits of greatest-width integer types */
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
/* 7.18.3 Limits of other integer types */
|
||||
#define PTRDIFF_MIN INT32_MIN
|
||||
#define PTRDIFF_MAX INT32_MAX
|
||||
|
||||
#define SIG_ATOMIC_MIN INT32_MIN
|
||||
#define SIG_ATOMIC_MAX INT32_MAX
|
||||
|
||||
#define SIZE_MAX UINT32_MAX
|
||||
|
||||
#ifndef WCHAR_MIN /* also in wchar.h */
|
||||
#define WCHAR_MIN 0
|
||||
#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wint_t is unsigned short for compatibility with MS runtime
|
||||
*/
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX ((wint_t)-1) /* UINT16_MAX */
|
||||
|
||||
#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
|
||||
|
||||
|
||||
/* 7.18.4 Macros for integer constants */
|
||||
#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
|
||||
|
||||
/* 7.18.4.1 Macros for minimum-width integer constants */
|
||||
|
||||
#define INT8_C(val) ((int8_t) + (val))
|
||||
#define UINT8_C(val) ((uint8_t) + (val##U))
|
||||
#define INT16_C(val) ((int16_t) + (val))
|
||||
#define UINT16_C(val) ((uint16_t) + (val##U))
|
||||
|
||||
#define INT32_C(val) val##L
|
||||
#define UINT32_C(val) val##UL
|
||||
#define INT64_C(val) val##LL
|
||||
#define UINT64_C(val) val##ULL
|
||||
|
||||
/* 7.18.4.2 Macros for greatest-width integer constants */
|
||||
#define INTMAX_C(val) INT64_C(val)
|
||||
#define UINTMAX_C(val) UINT64_C(val)
|
||||
|
||||
#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
|
||||
|
||||
|
||||
|
||||
#endif
|
46
SysCore/include/string.h
Normal file
46
SysCore/include/string.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef _STRING_H
|
||||
#define _STRING_H
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** [string.h]
|
||||
//** - Standard C String routines
|
||||
//**
|
||||
//****************************************************************************
|
||||
//============================================================================
|
||||
// INTERFACE REQUIRED HEADERS
|
||||
//============================================================================
|
||||
|
||||
#include <size_t.h>
|
||||
|
||||
//============================================================================
|
||||
// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE STRUCTURES / UTILITY CLASSES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE DATA DECLARATIONS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE FUNCTION PROTOTYPES
|
||||
//============================================================================
|
||||
|
||||
extern size_t strlen (const char *str);
|
||||
extern int strcmp(const char *pStr1, const char *pStr2);
|
||||
|
||||
//============================================================================
|
||||
// INTERFACE OBJECT CLASS DEFINITIONS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE TRAILING HEADERS
|
||||
//============================================================================
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** END [string.h]
|
||||
//**
|
||||
//****************************************************************************
|
||||
|
||||
#endif
|
21
SysCore/include/sys/declarat.h
Normal file
21
SysCore/include/sys/declarat.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __DECLARAT_H
|
||||
#define __DECLARAT_H
|
||||
|
||||
// Data type declarations
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
|
||||
// Functions
|
||||
void system_init();
|
||||
|
||||
void isrs_install();
|
||||
|
||||
void irq_install_handler(int irq, void (*handler)(ISR_stack_regs *r));
|
||||
void irq_uninstall_handler(int irq);
|
||||
void irq_install();
|
||||
void kb_handler(ISR_stack_regs *r);
|
||||
void reboot();
|
||||
void kb_waitin();
|
||||
|
||||
#endif
|
40
SysCore/include/system.h
Normal file
40
SysCore/include/system.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*******************************************************************
|
||||
* system.c - Basic system functions and variables declaration *
|
||||
*******************************************************************/
|
||||
#ifndef __SYSTEM_H
|
||||
#define __SYSTEM_H
|
||||
#include <regs.h>
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
// Data type declarations
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
|
||||
extern byte *TextVideoRam;
|
||||
extern volatile int cursor_x, cursor_y;
|
||||
extern int current_mode_width;
|
||||
extern int current_mode_height;
|
||||
|
||||
extern void *memcpy(void *dest, const void *src, int count);
|
||||
extern void *memset(void *dest, char val, int count);
|
||||
extern unsigned short *memsetw(unsigned short *dest, unsigned short val, int count);
|
||||
|
||||
extern byte inportb (word _port);
|
||||
extern byte inb (word _port);
|
||||
|
||||
static inline void outportb (word _port, byte _data) {
|
||||
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
||||
}
|
||||
static inline void outb (word _port, byte _data) {
|
||||
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
||||
}
|
||||
|
||||
static inline void iowait() {
|
||||
asm volatile ("outb %al, $0x80");
|
||||
}
|
||||
|
||||
|
||||
#endif
|
25
SysCore/include/time.h
Normal file
25
SysCore/include/time.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __TIME_C
|
||||
#define __TIME_C
|
||||
|
||||
extern const char* clock_months[13];
|
||||
extern const char* clock_weekdays[8];
|
||||
extern byte clock_months_len[13];
|
||||
|
||||
typedef struct {
|
||||
byte seconds;
|
||||
byte minutes;
|
||||
byte hours;
|
||||
byte weekday;
|
||||
byte day;
|
||||
byte month;
|
||||
byte year;
|
||||
byte century;
|
||||
byte am_pm;
|
||||
|
||||
} TIME;
|
||||
|
||||
extern void _CLOCK_INC(TIME *tim);
|
||||
|
||||
//extern char* asctime (TIME time);
|
||||
|
||||
#endif
|
52
SysCore/include/va_list.h
Normal file
52
SysCore/include/va_list.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef __VA_LIST_H
|
||||
#define __VA_LIST_H
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** va_list.h
|
||||
//** - varable length parameter definition
|
||||
//**
|
||||
//****************************************************************************
|
||||
//============================================================================
|
||||
// INTERFACE REQUIRED HEADERS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
|
||||
//============================================================================
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* va list parameter list */
|
||||
typedef unsigned char *va_list;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE STRUCTURES / UTILITY CLASSES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE DATA DECLARATIONS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE FUNCTION PROTOTYPES
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE OBJECT CLASS DEFINITIONS
|
||||
//============================================================================
|
||||
//============================================================================
|
||||
// INTERFACE TRAILING HEADERS
|
||||
//============================================================================
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** END va_list.h
|
||||
//**
|
||||
//****************************************************************************
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user