This commit is contained in:
2021-09-14 18:46:50 +03:00
parent d605c6a016
commit b6ddeca1c3
180 changed files with 5909 additions and 2039 deletions

View File

@@ -0,0 +1,26 @@
/***** floppy.h ******************************************************
* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
* *
* Floppy Drive I/O Routines *
* ========================= *
* *
************************************************************ cta os */
#include<regs.h>
extern unsigned char FloppyInitializeDMA(unsigned char* buffer, unsigned length);
extern void FloppyMotor (unsigned char drive, unsigned char on);
extern void i86_FloppyHandler(ISR_stack_regs *r);
extern void FloppyDriveData (unsigned char drv, unsigned char dma);
extern unsigned char FloppyCalibrate(unsigned drive);
extern void FloppyReset();
extern unsigned char FloppySeek (unsigned drive, unsigned cyl, unsigned head);
extern void FloppyInstall();
extern unsigned char FloppyIsDriverEnabled();
// Read/Write routines
extern unsigned* FloppyReadSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count);
extern unsigned* FloppyWriteSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count);
extern void FloppyReadSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector);
extern void FloppyWritedSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector);

View File

@@ -0,0 +1,173 @@
#ifndef __KEYBOARD_H
#define __KEYBOARD_H
#include <regs.h>
#define KeyboardKeyModifierLeftShift 0x81 // 1000 0001
#define KeyboardKeyModifierRightShift 0x82 // 1000 0010
#define KeyboardKeyModifierLeftAlt 0x84 // 1000 0100
#define KeyboardKeyModifierRightAlt 0x88 // 1000 1000
#define KeyboardKeyModifierLeftCtrl 0x90 // 1001 0000
#define KeyboardKeyModifierRightCtrl 0xA0 // 1010 0000
#define KeyboardKeyFakeShift 0xC0 // 1100 0000
#define KeyboardLightScroll 0xF1 // 1111 0001
#define KeyboardLightNum 0xF2 // 1111 0010
#define KeyboardLightCaps 0xF4 // 1111 0100
enum KeyboardKeys {
KeyboardKeyPause = 0x00,
KeyboardKeyF9 = 0x01,
KeyboardKeyF7 = 0x02,
KeyboardKeyF5 = 0X03,
KeyboardKeyF3 = 0x04,
KeyboardKeyF1 = 0x05,
KeyboardKeyF2 = 0x06,
KeyboardKeyF12 = 0x07,
KeyboardKeyPrintScreen = 0x08,
KeyboardKeyF10 = 0x09,
KeyboardKeyF8 = 0x0A,
KeyboardKeyF6 = 0x0B,
KeyboardKeyF4 = 0x0C,
KeyboardKeyTab = 0x0D,
KeyboardKeyTilda = 0x0E,
KeyboardKeyQ = 0x15,
KeyboardKey1 = 0x16,
KeyboardKeyZ = 0x1A,
KeyboardKeyS = 0x1B,
KeyboardKeyA = 0x1C,
KeyboardKeyW = 0x1D,
KeyboardKey2 = 0x1E,
KeyboardKeyLeftWin = 0x1F,
KeyboardKeyC = 0x21,
KeyboardKeyX = 0x22,
KeyboardKeyD = 0x23,
KeyboardKeyE = 0x24,
KeyboardKey4 = 0x25,
KeyboardKey3 = 0x26,
KeyboardKeyRightWin = 0x27,
KeyboardKeySpace = 0x29,
KeyboardKeyV = 0x2A,
KeyboardKeyF = 0x2B,
KeyboardKeyT = 0x2C,
KeyboardKeyR = 0x2D,
KeyboardKey5 = 0x2E,
KeyboardKeyMenu = 0x2F,
KeyboardKeyN = 0x31,
KeyboardKeyB = 0x32,
KeyboardKeyH = 0x33,
KeyboardKeyG = 0x34,
KeyboardKeyY = 0x35,
KeyboardKey6 = 0x36,
KeyboardKeyM = 0x3A,
KeyboardKeyJ = 0x3B,
KeyboardKeyU = 0x3C,
KeyboardKey7 = 0x3D,
KeyboardKey8 = 0x3E,
KeyboardKeyComma = 0x41,
KeyboardKeyK = 0x42,
KeyboardKeyI = 0x43,
KeyboardKeyO = 0x44,
KeyboardKey0 = 0x45,
KeyboardKey9 = 0x46,
KeyboardKeyPeriod = 0x49,
KeyboardKeySlash = 0x4A,
KeyboardKeyL = 0x4B,
KeyboardKeySemicolon = 0x4C,
KeyboardKeyP = 0x4D,
KeyboardKeyDash = 0x4E,
KeyboardKeyApostrophe = 0x52,
KeyboardKeyLeftBracket = 0x54,
KeyboardKeyEqual = 0x55,
KeyboardKeyNumpadEnter = 0x59,
KeyboardKeyReturn = 0x5A,
KeyboardKeyRightBracket = 0x5B,
KeyboardKeyBackSlash = 0x5D,
KeyboardKeyEnd = 0x5E,
KeyboardKeyLeft = 0x5F,
KeyboardKeyHome = 0x60,
KeyboardKeyInsert = 0x61,
KeyboardKeyDelete = 0x62,
KeyboardKeyDown = 0x63,
KeyboardKeyRight = 0x64,
KeyboardKeyUp = 0x65,
KeyboardKeyBackspace = 0x66,
KeyboardKeyPageDown = 0x67,
KeyboardKeyPageUp = 0x68,
KeyboardKeyNumpad1 = 0x69,
KeyboardKeyNumpadSlash = 0x6A,
KeyboardKeyNumpad4 = 0x6B,
KeyboardKeyNumpad7 = 0x6C,
KeyboardKeyNumpad0 = 0x70,
KeyboardKeyNumpadColon = 0x71,
KeyboardKeyNumpad2 = 0x72,
KeyboardKeyNumpad5 = 0x73,
KeyboardKeyNumpad6 = 0x74,
KeyboardKeyNumpad8 = 0x75,
KeyboardKeyEscape = 0x76,
KeyboardKeyF11 = 0x78,
KeyboardKeyNumpadPlus = 0x79,
KeyboardKeyNumpad3 = 0x7A,
KeyboardKeyNumpadMinus = 0x7B,
KeyboardKeyNumpadAsterisk = 0x7C,
KeyboardKeyNumpad9 = 0x7D
};
typedef struct {
unsigned char ModifierStatus;
unsigned char Lights;
unsigned char Scancode;
unsigned char Character;
} KeyboardKey;
extern void KeyboardSetKey(unsigned char scancode, unsigned char val);
extern unsigned char KeyIsPressed(unsigned char scancode);
extern void i86_KeyboardHandler(ISR_stack_regs *r);
extern KeyboardKey GetKey();
/**\n
Sets the repeat rate/delay\n
\n\Delay:
Values for inter-character delay (bits 4-0)\n
(characters per second; default is 10.9)\n
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 \n
----+----+----+----+----+----+----+----+----\n
0 |30.0|26.7|24.0|21.8|20.0|18.5|17.1|16.0\n
8 |15.0|13.3|12.0|10.9|10.0|9.2 |8.6 |8.0\n
16 |7.5 |6.7 |6.0 |5.5 |5.0 |4.6 |4.3 |4.0\n
24 |3.7 |3.3 |3.0 |2.7 |2.5 |2.3 |2.1 |2.0\n
\n
Values for delay:\n
(miliseconds; default is 500)\n
0 | 1 | 2 | 3\n
-----+-----+-----+-----\n
250 | 500 | 750 | 1000\n \n*/
extern void KeyboardSetRepeatRate(unsigned char rate, unsigned char delay);
/***************************************
* Set keyboard LEDs *
***************************************
+-----------+-------+-------+--------+
| Bits 7-3 | Bit 2 | Bit 1 | Bit 0 |
| 0 | Caps | Num | Scroll |
|(reserved) | lock | lock | lock |
+-----------+-------+-------+--------+
***************************************/
extern void KeyboardSetLEDs(unsigned char status);
/***************************************
* Set scancode set *
***************************************
0 Get current scancode set
1 Set to scancode set 1
2 Set to scancode set 2
3 Set to scancode set 3
***************************************/
extern void KeyboardSetScancodeSet(unsigned char set);
extern void KeyboardWaitInput();
extern void KeyboardWaitOutput();
extern void KeyboardInstallA();
extern void KeyboardInstallB();
#endif

View File

@@ -10,7 +10,7 @@
#define i86_start_interrupts() __asm__ __volatile__ ("sti");
#define i86_clear_interrupts() __asm__ __volatile__ ("cli");
extern TIME i86_pit_get_time() ;
extern TIME ClockGetTime() ;
extern unsigned* i86_read_sector (unsigned* where, unsigned char drive, int sectorLBA);
// initialize hardware abstraction layer
extern void i86_hal_initialize ();
@@ -39,146 +39,129 @@ extern void sound (unsigned frequency);
//! returns cpu vender
extern const char* get_cpu_vender ();
extern void reboot();
extern void SystemReboot();
/**********************************************************************
* 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 unsigned char kb_modifier_status;
#define KeyboardKeyModifierLeftShift 0x81 // 1000 0001
#define KeyboardKeyModifierRightShift 0x82 // 1000 0010
#define KeyboardKeyModifierLeftAlt 0x84 // 1000 0100
#define KeyboardKeyModifierRightAlt 0x88 // 1000 1000
#define KeyboardKeyModifierLeftCtrl 0x90 // 1001 0000
#define KeyboardKeyModifierRightCtrl 0xA0 // 1010 0000
#define KeyboardKeyFakeShift 0xC0 // 1100 0000
#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 unsigned char from pause/break
extern volatile unsigned char kb_prefix;
#define KeyboardLightScroll 0xF1 // 1111 0001
#define KeyboardLightNum 0xF2 // 1111 0010
#define KeyboardLightCaps 0xF4 // 1111 0100
#define KB_KEY_SCROLL 0xF1 // 1111 0001
#define KB_KEY_NUM 0xF2 // 1111 0010
#define KB_KEY_CAPS 0xF4 // 1111 0100
extern volatile unsigned char kb_lights_status;
extern unsigned char kb_scancode_set;
enum KB_KEYS {
KB_KEY_PAUSE = 0x00,
KB_KEY_F9 = 0x01,
KB_KEY_F7 = 0x02,
KB_KEY_F5 = 0X03,
KB_KEY_F3 = 0x04,
KB_KEY_F1 = 0x05,
KB_KEY_F2 = 0x06,
KB_KEY_F12 = 0x07,
KB_KEY_PRINTSCRN = 0x08,
KB_KEY_F10 = 0x09,
KB_KEY_F8 = 0x0A,
KB_KEY_F6 = 0x0B,
KB_KEY_F4 = 0x0C,
KB_KEY_TAB = 0x0D,
KB_KEY_TILDA = 0x0E,
KB_KEY_Q = 0x15,
KB_KEY_1 = 0x16,
KB_KEY_Z = 0x1A,
KB_KEY_S = 0x1B,
KB_KEY_A = 0x1C,
KB_KEY_W = 0x1D,
KB_KEY_2 = 0x1E,
KB_KEY_LWIN = 0x1F,
KB_KEY_C = 0x21,
KB_KEY_X = 0x22,
KB_KEY_D = 0x23,
KB_KEY_E = 0x24,
KB_KEY_4 = 0x25,
KB_KEY_3 = 0x26,
KB_KEY_RWIN = 0x27,
KB_KEY_SPACE = 0x29,
KB_KEY_V = 0x2A,
KB_KEY_F = 0x2B,
KB_KEY_T = 0x2C,
KB_KEY_R = 0x2D,
KB_KEY_5 = 0x2E,
KB_KEY_MENU = 0x2F,
KB_KEY_N = 0x31,
KB_KEY_B = 0x32,
KB_KEY_H = 0x33,
KB_KEY_G = 0x34,
KB_KEY_Y = 0x35,
KB_KEY_6 = 0x36,
KB_KEY_M = 0x3A,
KB_KEY_J = 0x3B,
KB_KEY_U = 0x3C,
KB_KEY_7 = 0x3D,
KB_KEY_8 = 0x3E,
KB_KEY_COMMA = 0x41,
KB_KEY_K = 0x42,
KB_KEY_I = 0x43,
KB_KEY_O = 0x44,
KB_KEY_0 = 0x45,
KB_KEY_9 = 0x46,
KB_KEY_PERIOD = 0x49,
KB_KEY_SLASH = 0x4A,
KB_KEY_L = 0x4B,
KB_KEY_SEMICOLON = 0x4C,
KB_KEY_P = 0x4D,
KB_KEY_DASH = 0x4E,
KB_KEY_APOSTROPHE = 0x52,
KB_KEY_LBRACKET = 0x54,
KB_KEY_EQUAL = 0x55,
KB_KEY_NUMPAD_ENTER = 0x59,
KB_KEY_ENTER = 0x5A,
KB_KEY_RBRACKET = 0x5B,
KB_KEY_BACKSLASH = 0x5D,
KB_KEY_END = 0x5E,
KB_KEY_LEFT = 0x5F,
KB_KEY_HOME = 0x60,
KB_KEY_INSERT = 0x61,
KB_KEY_DELETE = 0x62,
KB_KEY_DOWN = 0x63,
KB_KEY_RIGHT = 0x64,
KB_KEY_UP = 0x65,
KB_KEY_BACKSPACE = 0x66,
KB_KEY_PGDOWN = 0x67,
KB_KEY_PGUP = 0x68,
KB_KEY_NUMPAD_1 = 0x69,
KB_KEY_NUMPAD_SLASH = 0x6A,
KB_KEY_NUMPAD_4 = 0x6B,
KB_KEY_NUMPAD_7 = 0x6C,
KB_KEY_NUMPAD_0 = 0x70,
KB_KEY_NUMPAD_COLON = 0x71,
KB_KEY_NUMPAD_2 = 0x72,
KB_KEY_NUMPAD_5 = 0x73,
KB_KEY_NUMPAD_6 = 0x74,
KB_KEY_NUMPAD_8 = 0x75,
KB_KEY_ESC = 0x76,
KB_KEY_F11 = 0x78,
KB_KEY_NUMPAD_PLUS = 0x79,
KB_KEY_NUMPAD_3 = 0x7A,
KB_KEY_NUMPAD_MINUS = 0x7B,
KB_KEY_NUMPAD_ASTERISK = 0x7C,
KB_KEY_NUMPAD_9 = 0x7D
enum KeyboardKeys {
KeyboardKeyPause = 0x00,
KeyboardKeyF9 = 0x01,
KeyboardKeyF7 = 0x02,
KeyboardKeyF5 = 0X03,
KeyboardKeyF3 = 0x04,
KeyboardKeyF1 = 0x05,
KeyboardKeyF2 = 0x06,
KeyboardKeyF12 = 0x07,
KeyboardKeyPrintScreen = 0x08,
KeyboardKeyF10 = 0x09,
KeyboardKeyF8 = 0x0A,
KeyboardKeyF6 = 0x0B,
KeyboardKeyF4 = 0x0C,
KeyboardKeyTab = 0x0D,
KeyboardKeyTilda = 0x0E,
KeyboardKeyQ = 0x15,
KeyboardKey1 = 0x16,
KeyboardKeyZ = 0x1A,
KeyboardKeyS = 0x1B,
KeyboardKeyA = 0x1C,
KeyboardKeyW = 0x1D,
KeyboardKey2 = 0x1E,
KeyboardKeyLeftWin = 0x1F,
KeyboardKeyC = 0x21,
KeyboardKeyX = 0x22,
KeyboardKeyD = 0x23,
KeyboardKeyE = 0x24,
KeyboardKey4 = 0x25,
KeyboardKey3 = 0x26,
KeyboardKeyRightWin = 0x27,
KeyboardKeySpace = 0x29,
KeyboardKeyV = 0x2A,
KeyboardKeyF = 0x2B,
KeyboardKeyT = 0x2C,
KeyboardKeyR = 0x2D,
KeyboardKey5 = 0x2E,
KeyboardKeyMenu = 0x2F,
KeyboardKeyN = 0x31,
KeyboardKeyB = 0x32,
KeyboardKeyH = 0x33,
KeyboardKeyG = 0x34,
KeyboardKeyY = 0x35,
KeyboardKey6 = 0x36,
KeyboardKeyM = 0x3A,
KeyboardKeyJ = 0x3B,
KeyboardKeyU = 0x3C,
KeyboardKey7 = 0x3D,
KeyboardKey8 = 0x3E,
KeyboardKeyComma = 0x41,
KeyboardKeyK = 0x42,
KeyboardKeyI = 0x43,
KeyboardKeyO = 0x44,
KeyboardKey0 = 0x45,
KeyboardKey9 = 0x46,
KeyboardKeyPeriod = 0x49,
KeyboardKeySlash = 0x4A,
KeyboardKeyL = 0x4B,
KeyboardKeySemicolon = 0x4C,
KeyboardKeyP = 0x4D,
KeyboardKeyDash = 0x4E,
KeyboardKeyApostrophe = 0x52,
KeyboardKeyLeftBracket = 0x54,
KeyboardKeyEqual = 0x55,
KeyboardKeyNumpadEnter = 0x59,
KeyboardKeyReturn = 0x5A,
KeyboardKeyRightBracket = 0x5B,
KeyboardKeyBackSlash = 0x5D,
KeyboardKeyEnd = 0x5E,
KeyboardKeyLeft = 0x5F,
KeyboardKeyHome = 0x60,
KeyboardKeyInsert = 0x61,
KeyboardKeyDelete = 0x62,
KeyboardKeyDown = 0x63,
KeyboardKeyRight = 0x64,
KeyboardKeyUp = 0x65,
KeyboardKeyBackspace = 0x66,
KeyboardKeyPageDown = 0x67,
KeyboardKeyPageUp = 0x68,
KeyboardKeyNumpad1 = 0x69,
KeyboardKeyNumpadSlash = 0x6A,
KeyboardKeyNumpad4 = 0x6B,
KeyboardKeyNumpad7 = 0x6C,
KeyboardKeyNumpad0 = 0x70,
KeyboardKeyNumpadColon = 0x71,
KeyboardKeyNumpad2 = 0x72,
KeyboardKeyNumpad5 = 0x73,
KeyboardKeyNumpad6 = 0x74,
KeyboardKeyNumpad8 = 0x75,
KeyboardKeyEscape = 0x76,
KeyboardKeyF11 = 0x78,
KeyboardKeyNumpadPlus = 0x79,
KeyboardKeyNumpad3 = 0x7A,
KeyboardKeyNumpadMinus = 0x7B,
KeyboardKeyNumpadAsterisk = 0x7C,
KeyboardKeyNumpad9 = 0x7D
};
typedef struct {
unsigned char status;
unsigned char lights;
unsigned char scancode;
unsigned char character;
} kb_key;
unsigned char ModifierStatus;
unsigned char Lights;
unsigned char Scancode;
unsigned char Character;
} KeyboardKey;
//extern char getch();
extern kb_key getkey();
extern char scancode_to_ascii(unsigned char scancode, unsigned char status);
extern unsigned char get_key_status(unsigned char scancode);
extern void kb_set_repeat(float rate, int delay);
extern void kb_set_LEDs(unsigned char status);
#endif

View File

@@ -18,6 +18,8 @@ typedef struct {
extern void _CLOCK_INC(TIME *tim);
#include "../drivers/clock/clock.h"
//extern char* asctime (TIME time);
#endif