WE WORK. TO EARN THE RIGHT TO WORK. TO EARN THE RIGHT TO LIVE. TO EARN THE RIGHT TO DIE.
This commit is contained in:
parent
a973e385a1
commit
843d3b6c0c
74
src/kernel/ctype.c
Normal file
74
src/kernel/ctype.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2026|
|
||||
|Xircon |
|
||||
\*----------------*/
|
||||
#include "ctype.h"
|
||||
|
||||
/*Takes an input charater and outputs it as its lowercase*/
|
||||
char tolower(char character){
|
||||
switch(character) {
|
||||
case 'A': return 'a';
|
||||
case 'B': return 'b';
|
||||
case 'C': return 'c';
|
||||
case 'D': return 'd';
|
||||
case 'E': return 'e';
|
||||
case 'F': return 'f';
|
||||
case 'G': return 'g';
|
||||
case 'H': return 'h';
|
||||
case 'I': return 'i';
|
||||
case 'J': return 'j';
|
||||
case 'K': return 'k';
|
||||
case 'L': return 'l';
|
||||
case 'M': return 'm';
|
||||
case 'N': return 'n';
|
||||
case 'O': return 'o';
|
||||
case 'P': return 'p';
|
||||
case 'Q': return 'q';
|
||||
case 'R': return 'r';
|
||||
case 'S': return 's';
|
||||
case 'T': return 't';
|
||||
case 'U': return 'u';
|
||||
case 'V': return 'v';
|
||||
case 'W': return 'w';
|
||||
case 'X': return 'x';
|
||||
case 'Y': return 'y';
|
||||
case 'Z': return 'z';
|
||||
|
||||
default: return character;
|
||||
}
|
||||
}
|
||||
|
||||
/*Takes an input charater and outputs it as its uppercase*/
|
||||
char toupper(char character) {
|
||||
switch(character) {
|
||||
case 'a': return 'A';
|
||||
case 'b': return 'B';
|
||||
case 'c': return 'C';
|
||||
case 'd': return 'D';
|
||||
case 'e': return 'E';
|
||||
case 'f': return 'F';
|
||||
case 'g': return 'G';
|
||||
case 'h': return 'H';
|
||||
case 'i': return 'I';
|
||||
case 'j': return 'J';
|
||||
case 'k': return 'K';
|
||||
case 'l': return 'L';
|
||||
case 'm': return 'M';
|
||||
case 'n': return 'N';
|
||||
case 'o': return 'O';
|
||||
case 'p': return 'P';
|
||||
case 'q': return 'Q';
|
||||
case 'r': return 'R';
|
||||
case 's': return 'S';
|
||||
case 't': return 'T';
|
||||
case 'u': return 'U';
|
||||
case 'v': return 'V';
|
||||
case 'w': return 'W';
|
||||
case 'x': return 'X';
|
||||
case 'y': return 'Y';
|
||||
case 'z': return 'Z';
|
||||
|
||||
default: return character;
|
||||
}
|
||||
}
|
||||
10
src/kernel/ctype.h
Normal file
10
src/kernel/ctype.h
Normal file
@ -0,0 +1,10 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2026|
|
||||
|Xircon |
|
||||
\*----------------*/
|
||||
#pragma once
|
||||
|
||||
char tolower(char character);
|
||||
|
||||
char toupper(char character);
|
||||
@ -29,15 +29,21 @@ extern uint16_t DEBUG_COM_PORT;
|
||||
void Keyboard_Handler()
|
||||
{
|
||||
_keyboard_scancode = inb(KEYBOARD_ENC_INPUT_BUF);
|
||||
Serial_Printf(DEBUG_COM_PORT, "KEYBOARD:> Scancode %u\n", _keyboard_scancode);
|
||||
// Serial_Printf(DEBUG_COM_PORT, "KEYBOARD:> Scancode %u\n", _keyboard_scancode);
|
||||
|
||||
// CTRL + ALT + SHIFT Handlers
|
||||
if(_keyboard_scancode == 29) _ctrl = true;
|
||||
if(_keyboard_scancode == 29) _ctrl = true;
|
||||
if(_keyboard_scancode == 157) _ctrl = false;
|
||||
if(_keyboard_scancode == 157) _ctrl = false;
|
||||
if(_keyboard_scancode == 56) _alt = true;
|
||||
if(_keyboard_scancode == 56) _alt = true;
|
||||
if(_keyboard_scancode == 184) _alt = false;
|
||||
if(_keyboard_scancode == 184) _alt = false;
|
||||
if(_keyboard_scancode == 42) _shift = true;
|
||||
if(_keyboard_scancode == 54) _shift = true;
|
||||
if(_keyboard_scancode == 170) _shift = false;
|
||||
if(_keyboard_scancode == 182) _shift = false;
|
||||
|
||||
// Three finger salute (lol)
|
||||
if(_keyboard_scancode == 224 && _ctrl == true && _alt == true) Reboot();
|
||||
@ -140,73 +146,73 @@ void Keyboard_Init()
|
||||
|
||||
char kscan() {
|
||||
switch(_keyboard_scancode) {
|
||||
case KEYBOARD_LAYOUT_OEM_3: return '`';
|
||||
case KEYBOARD_LAYOUT_1: return '1';
|
||||
case KEYBOARD_LAYOUT_2: return '2';
|
||||
case KEYBOARD_LAYOUT_3: return '3';
|
||||
case KEYBOARD_LAYOUT_4: return '4';
|
||||
case KEYBOARD_LAYOUT_5: return '5';
|
||||
case KEYBOARD_LAYOUT_6: return '6';
|
||||
case KEYBOARD_LAYOUT_7: return '7';
|
||||
case KEYBOARD_LAYOUT_8: return '8';
|
||||
case KEYBOARD_LAYOUT_9: return '9';
|
||||
case KEYBOARD_LAYOUT_0: return '0';
|
||||
case KEYBOARD_LAYOUT_OEM_MI: return '-';
|
||||
case KEYBOARD_LAYOUT_OEM_PL: return '=';
|
||||
case KEYBOARD_LAYOUT_BACK: return '\b';
|
||||
case KEYBOARD_LAYOUT_TAB: return '\t';
|
||||
case KEYBOARD_LAYOUT_Q: return 'Q';
|
||||
case KEYBOARD_LAYOUT_W: return 'W';
|
||||
case KEYBOARD_LAYOUT_E: return 'E';
|
||||
case KEYBOARD_LAYOUT_R: return 'R';
|
||||
case KEYBOARD_LAYOUT_T: return 'T';
|
||||
case KEYBOARD_LAYOUT_Y: return 'Y';
|
||||
case KEYBOARD_LAYOUT_U: return 'U';
|
||||
case KEYBOARD_LAYOUT_I: return 'I';
|
||||
case KEYBOARD_LAYOUT_O: return 'O';
|
||||
case KEYBOARD_LAYOUT_P: return 'P';
|
||||
case KEYBOARD_LAYOUT_OEM_4: return '[';
|
||||
case KEYBOARD_LAYOUT_OEM_6: return ']';
|
||||
case KEYBOARD_LAYOUT_OEM_5: return '\\';
|
||||
case KEYBOARD_LAYOUT_A: return 'A';
|
||||
case KEYBOARD_LAYOUT_S: return 'S';
|
||||
case KEYBOARD_LAYOUT_D: return 'D';
|
||||
case KEYBOARD_LAYOUT_F: return 'F';
|
||||
case KEYBOARD_LAYOUT_G: return 'G';
|
||||
case KEYBOARD_LAYOUT_H: return 'H';
|
||||
case KEYBOARD_LAYOUT_J: return 'J';
|
||||
case KEYBOARD_LAYOUT_K: return 'K';
|
||||
case KEYBOARD_LAYOUT_L: return 'L';
|
||||
case KEYBOARD_LAYOUT_OEM_1: return ';';
|
||||
case KEYBOARD_LAYOUT_OEM_7: return '\'';
|
||||
case KEYBOARD_LAYOUT_RETURN: return '\n';
|
||||
case KEYBOARD_LAYOUT_Z: return 'Z';
|
||||
case KEYBOARD_LAYOUT_X: return 'X';
|
||||
case KEYBOARD_LAYOUT_C: return 'C';
|
||||
case KEYBOARD_LAYOUT_V: return 'V';
|
||||
case KEYBOARD_LAYOUT_B: return 'B';
|
||||
case KEYBOARD_LAYOUT_N: return 'N';
|
||||
case KEYBOARD_LAYOUT_M: return 'M';
|
||||
case KEYBOARD_LAYOUT_OEM_CC: return ',';
|
||||
case KEYBOARD_LAYOUT_OEM_PE: return '.';
|
||||
case KEYBOARD_LAYOUT_OEM_2: return '/';
|
||||
case KEYBOARD_LAYOUT_SPACE: return ' ';
|
||||
case KEYBOARD_LAYOUT_DIVIDE: return '/';
|
||||
case KEYBOARD_LAYOUT_MULTIPLY: return '*';
|
||||
case KEYBOARD_LAYOUT_SUBTRACT: return '-';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_1: return '1';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_2: return '2';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_3: return '3';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_4: return '4';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_5: return '5';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_6: return '6';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_7: return '7';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_8: return '8';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_9: return '9';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_0: return '0';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_PERIOD: return '.';
|
||||
case KEYBOARD_LAYOUT_ADD: return '+';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_RETURN: return '\n';
|
||||
case KEYBOARD_LAYOUT_OEM_3: _keyboard_scancode = 0; return '`';
|
||||
case KEYBOARD_LAYOUT_1: _keyboard_scancode = 0; if(_shift == true) return '!'; else return '1';
|
||||
case KEYBOARD_LAYOUT_2: _keyboard_scancode = 0; return '2';
|
||||
case KEYBOARD_LAYOUT_3: _keyboard_scancode = 0; return '3';
|
||||
case KEYBOARD_LAYOUT_4: _keyboard_scancode = 0; return '4';
|
||||
case KEYBOARD_LAYOUT_5: _keyboard_scancode = 0; return '5';
|
||||
case KEYBOARD_LAYOUT_6: _keyboard_scancode = 0; return '6';
|
||||
case KEYBOARD_LAYOUT_7: _keyboard_scancode = 0; return '7';
|
||||
case KEYBOARD_LAYOUT_8: _keyboard_scancode = 0; return '8';
|
||||
case KEYBOARD_LAYOUT_9: _keyboard_scancode = 0; return '9';
|
||||
case KEYBOARD_LAYOUT_0: _keyboard_scancode = 0; return '0';
|
||||
case KEYBOARD_LAYOUT_OEM_MI: _keyboard_scancode = 0; return '-';
|
||||
case KEYBOARD_LAYOUT_OEM_PL: _keyboard_scancode = 0; return '=';
|
||||
case KEYBOARD_LAYOUT_BACK: _keyboard_scancode = 0; return '\b';
|
||||
case KEYBOARD_LAYOUT_TAB: _keyboard_scancode = 0; return '\t';
|
||||
case KEYBOARD_LAYOUT_Q: _keyboard_scancode = 0; return 'Q';
|
||||
case KEYBOARD_LAYOUT_W: _keyboard_scancode = 0; return 'W';
|
||||
case KEYBOARD_LAYOUT_E: _keyboard_scancode = 0; return 'E';
|
||||
case KEYBOARD_LAYOUT_R: _keyboard_scancode = 0; return 'R';
|
||||
case KEYBOARD_LAYOUT_T: _keyboard_scancode = 0; return 'T';
|
||||
case KEYBOARD_LAYOUT_Y: _keyboard_scancode = 0; return 'Y';
|
||||
case KEYBOARD_LAYOUT_U: _keyboard_scancode = 0; return 'U';
|
||||
case KEYBOARD_LAYOUT_I: _keyboard_scancode = 0; return 'I';
|
||||
case KEYBOARD_LAYOUT_O: _keyboard_scancode = 0; return 'O';
|
||||
case KEYBOARD_LAYOUT_P: _keyboard_scancode = 0; return 'P';
|
||||
case KEYBOARD_LAYOUT_OEM_4: _keyboard_scancode = 0; return '[';
|
||||
case KEYBOARD_LAYOUT_OEM_6: _keyboard_scancode = 0; return ']';
|
||||
case KEYBOARD_LAYOUT_OEM_5: _keyboard_scancode = 0; return '\\';
|
||||
case KEYBOARD_LAYOUT_A: _keyboard_scancode = 0; return 'A';
|
||||
case KEYBOARD_LAYOUT_S: _keyboard_scancode = 0; return 'S';
|
||||
case KEYBOARD_LAYOUT_D: _keyboard_scancode = 0; return 'D';
|
||||
case KEYBOARD_LAYOUT_F: _keyboard_scancode = 0; return 'F';
|
||||
case KEYBOARD_LAYOUT_G: _keyboard_scancode = 0; return 'G';
|
||||
case KEYBOARD_LAYOUT_H: _keyboard_scancode = 0; return 'H';
|
||||
case KEYBOARD_LAYOUT_J: _keyboard_scancode = 0; return 'J';
|
||||
case KEYBOARD_LAYOUT_K: _keyboard_scancode = 0; return 'K';
|
||||
case KEYBOARD_LAYOUT_L: _keyboard_scancode = 0; return 'L';
|
||||
case KEYBOARD_LAYOUT_OEM_1: _keyboard_scancode = 0; return ';';
|
||||
case KEYBOARD_LAYOUT_OEM_7: _keyboard_scancode = 0; return '\'';
|
||||
case KEYBOARD_LAYOUT_RETURN: _keyboard_scancode = 0; return '\n';
|
||||
case KEYBOARD_LAYOUT_Z: _keyboard_scancode = 0; return 'Z';
|
||||
case KEYBOARD_LAYOUT_X: _keyboard_scancode = 0; return 'X';
|
||||
case KEYBOARD_LAYOUT_C: _keyboard_scancode = 0; return 'C';
|
||||
case KEYBOARD_LAYOUT_V: _keyboard_scancode = 0; return 'V';
|
||||
case KEYBOARD_LAYOUT_B: _keyboard_scancode = 0; return 'B';
|
||||
case KEYBOARD_LAYOUT_N: _keyboard_scancode = 0; return 'N';
|
||||
case KEYBOARD_LAYOUT_M: _keyboard_scancode = 0; return 'M';
|
||||
case KEYBOARD_LAYOUT_OEM_CC: _keyboard_scancode = 0; return ',';
|
||||
case KEYBOARD_LAYOUT_OEM_PE: _keyboard_scancode = 0; return '.';
|
||||
case KEYBOARD_LAYOUT_OEM_2: _keyboard_scancode = 0; if(_shift == true) return '?'; else return '/';
|
||||
case KEYBOARD_LAYOUT_SPACE: _keyboard_scancode = 0; return ' ';
|
||||
// case KEYBOARD_LAYOUT_DIVIDE: _keyboard_scancode = 0; return '/';
|
||||
case KEYBOARD_LAYOUT_MULTIPLY: _keyboard_scancode = 0; return '*';
|
||||
case KEYBOARD_LAYOUT_SUBTRACT: _keyboard_scancode = 0; return '-';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_1: _keyboard_scancode = 0; return '1';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_2: _keyboard_scancode = 0; return '2';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_3: _keyboard_scancode = 0; return '3';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_4: _keyboard_scancode = 0; return '4';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_5: _keyboard_scancode = 0; return '5';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_6: _keyboard_scancode = 0; return '6';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_7: _keyboard_scancode = 0; return '7';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_8: _keyboard_scancode = 0; return '8';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_9: _keyboard_scancode = 0; return '9';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_0: _keyboard_scancode = 0; return '0';
|
||||
case KEYBOARD_LAYOUT_NUMPAD_PERIOD: _keyboard_scancode = 0; return '.';
|
||||
case KEYBOARD_LAYOUT_ADD: _keyboard_scancode = 0; return '+';
|
||||
// case KEYBOARD_LAYOUT_NUMPAD_RETURN: _keyboard_scancode = 0; return '\n';
|
||||
default: return '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +168,6 @@ enum KEYBOARD_LAYOUT_QWERTY {
|
||||
};
|
||||
|
||||
#ifdef __LAYOUT_QWERTY
|
||||
|
||||
enum KEYBOARD_LAYOUT {
|
||||
KEYBOARD_LAYOUT_ESCAPE = KEYBOARD_LAYOUT_QWERTY_ESCAPE,
|
||||
KEYBOARD_LAYOUT_F1 = KEYBOARD_LAYOUT_QWERTY_F1,
|
||||
@ -275,5 +274,113 @@ enum KEYBOARD_LAYOUT {
|
||||
KEYBOARD_LAYOUT_ADD = KEYBOARD_LAYOUT_QWERTY_ADD,
|
||||
KEYBOARD_LAYOUT_NUMPAD_RETURN = KEYBOARD_LAYOUT_QWERTY_NUMPAD_RETURN,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __LAYOUT_DVORAK // I Need to implement this lol
|
||||
enum KEYBOARD_LAYOUT_DVORAK {
|
||||
KEYBOARD_LAYOUT_QWERTY_ESCAPE = 0x01,
|
||||
KEYBOARD_LAYOUT_QWERTY_F1 = 0x3B,
|
||||
KEYBOARD_LAYOUT_QWERTY_F2 = 0x3C,
|
||||
KEYBOARD_LAYOUT_QWERTY_F3 = 0x3D,
|
||||
KEYBOARD_LAYOUT_QWERTY_F4 = 0x3E,
|
||||
KEYBOARD_LAYOUT_QWERTY_F5 = 0x3F,
|
||||
KEYBOARD_LAYOUT_QWERTY_F6 = 0x40,
|
||||
KEYBOARD_LAYOUT_QWERTY_F7 = 0x41,
|
||||
KEYBOARD_LAYOUT_QWERTY_F8 = 0x42,
|
||||
KEYBOARD_LAYOUT_QWERTY_F9 = 0x43,
|
||||
KEYBOARD_LAYOUT_QWERTY_F10 = 0x44,
|
||||
KEYBOARD_LAYOUT_QWERTY_F11 = 0x57,
|
||||
KEYBOARD_LAYOUT_QWERTY_F12 = 0x58,
|
||||
KEYBOARD_LAYOUT_QWERTY_SNAPSHOT = 0x54,
|
||||
KEYBOARD_LAYOUT_QWERTY_SCROLL = 0x46,
|
||||
KEYBOARD_LAYOUT_QWERTY_PAUSE = 0xE1D1,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_3 = 0x29,
|
||||
KEYBOARD_LAYOUT_QWERTY_1 = 0x02,
|
||||
KEYBOARD_LAYOUT_QWERTY_2 = 0x03,
|
||||
KEYBOARD_LAYOUT_QWERTY_3 = 0x04,
|
||||
KEYBOARD_LAYOUT_QWERTY_4 = 0x05,
|
||||
KEYBOARD_LAYOUT_QWERTY_5 = 0x06,
|
||||
KEYBOARD_LAYOUT_QWERTY_6 = 0x07,
|
||||
KEYBOARD_LAYOUT_QWERTY_7 = 0x08,
|
||||
KEYBOARD_LAYOUT_QWERTY_8 = 0x09,
|
||||
KEYBOARD_LAYOUT_QWERTY_9 = 0x0A,
|
||||
KEYBOARD_LAYOUT_QWERTY_0 = 0x0B,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_MI = 0x0C,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_PL = 0x0D,
|
||||
KEYBOARD_LAYOUT_QWERTY_BACK = 0x0E,
|
||||
KEYBOARD_LAYOUT_QWERTY_TAB = 0x0F,
|
||||
KEYBOARD_LAYOUT_QWERTY_Q = 0x10,
|
||||
KEYBOARD_LAYOUT_QWERTY_W = 0x11,
|
||||
KEYBOARD_LAYOUT_QWERTY_E = 0x12,
|
||||
KEYBOARD_LAYOUT_QWERTY_R = 0x13,
|
||||
KEYBOARD_LAYOUT_QWERTY_T = 0x14,
|
||||
KEYBOARD_LAYOUT_QWERTY_Y = 0x15,
|
||||
KEYBOARD_LAYOUT_QWERTY_U = 0x16,
|
||||
KEYBOARD_LAYOUT_QWERTY_I = 0x17,
|
||||
KEYBOARD_LAYOUT_QWERTY_O = 0x18,
|
||||
KEYBOARD_LAYOUT_QWERTY_P = 0x19,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_4 = 0x1A,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_6 = 0x1B,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_5 = 0x2B,
|
||||
KEYBOARD_LAYOUT_QWERTY_CAPITAL = 0x3A,
|
||||
KEYBOARD_LAYOUT_QWERTY_A = 0x1E,
|
||||
KEYBOARD_LAYOUT_QWERTY_S = 0x1F,
|
||||
KEYBOARD_LAYOUT_QWERTY_D = 0x20,
|
||||
KEYBOARD_LAYOUT_QWERTY_F = 0x21,
|
||||
KEYBOARD_LAYOUT_QWERTY_G = 0x22,
|
||||
KEYBOARD_LAYOUT_QWERTY_H = 0x23,
|
||||
KEYBOARD_LAYOUT_QWERTY_J = 0x24,
|
||||
KEYBOARD_LAYOUT_QWERTY_K = 0x25,
|
||||
KEYBOARD_LAYOUT_QWERTY_L = 0x26,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_1 = 0x27,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_7 = 0x28,
|
||||
KEYBOARD_LAYOUT_QWERTY_RETURN = 0x1C,
|
||||
KEYBOARD_LAYOUT_QWERTY_LSHIFT = 0x2A,
|
||||
KEYBOARD_LAYOUT_QWERTY_Z = 0x2C,
|
||||
KEYBOARD_LAYOUT_QWERTY_X = 0x2D,
|
||||
KEYBOARD_LAYOUT_QWERTY_C = 0x2E,
|
||||
KEYBOARD_LAYOUT_QWERTY_V = 0x2F,
|
||||
KEYBOARD_LAYOUT_QWERTY_B = 0x30,
|
||||
KEYBOARD_LAYOUT_QWERTY_N = 0x31,
|
||||
KEYBOARD_LAYOUT_QWERTY_M = 0x32,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_CC = 0x33,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_PE = 0x34,
|
||||
KEYBOARD_LAYOUT_QWERTY_OEM_2 = 0x35,
|
||||
KEYBOARD_LAYOUT_QWERTY_RSHIFT = 0x36,
|
||||
KEYBOARD_LAYOUT_QWERTY_LCONTROL = 0x1D,
|
||||
KEYBOARD_LAYOUT_QWERTY_LSUPER = 0xE05B,
|
||||
KEYBOARD_LAYOUT_QWERTY_LMENU = 0x38,
|
||||
KEYBOARD_LAYOUT_QWERTY_SPACE = 0x39,
|
||||
KEYBOARD_LAYOUT_QWERTY_RMENU = 0xE038,
|
||||
KEYBOARD_LAYOUT_QWERTY_RSUPER = 0xE05C,
|
||||
KEYBOARD_LAYOUT_QWERTY_APPS = 0xE05D,
|
||||
KEYBOARD_LAYOUT_QWERTY_RCONTROL = 0xE01D,
|
||||
KEYBOARD_LAYOUT_QWERTY_INSERT = 0xE052,
|
||||
KEYBOARD_LAYOUT_QWERTY_HOME = 0xE047,
|
||||
KEYBOARD_LAYOUT_QWERTY_PRIOR = 0xE049,
|
||||
KEYBOARD_LAYOUT_QWERTY_DELETE = 0xE053,
|
||||
KEYBOARD_LAYOUT_QWERTY_END = 0xE04F,
|
||||
KEYBOARD_LAYOUT_QWERTY_NEXT = 0xE051,
|
||||
KEYBOARD_LAYOUT_QWERTY_UP = 0xE048,
|
||||
KEYBOARD_LAYOUT_QWERTY_LEFT = 0xE04B,
|
||||
KEYBOARD_LAYOUT_QWERTY_RIGHT = 0xE04D,
|
||||
KEYBOARD_LAYOUT_QWERTY_DOWN = 0xE050,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMLOCK = 0x45,
|
||||
KEYBOARD_LAYOUT_QWERTY_DIVIDE = 0xE035,
|
||||
KEYBOARD_LAYOUT_QWERTY_MULTIPLY = 0x37,
|
||||
KEYBOARD_LAYOUT_QWERTY_SUBTRACT = 0x4A,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_1 = 0x47,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_2 = 0x48,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_3 = 0x49,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_4 = 0x4B,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_5 = 0x4C,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_6 = 0x4D,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_7 = 0x4F,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_8 = 0x50,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_9 = 0x51,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_0 = 0x52,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_PERIOD = 0x53,
|
||||
KEYBOARD_LAYOUT_QWERTY_ADD = 0x4E,
|
||||
KEYBOARD_LAYOUT_QWERTY_NUMPAD_RETURN = 0xE01,
|
||||
}
|
||||
#endif
|
||||
6
src/kernel/dri/power/apm.c
Normal file
6
src/kernel/dri/power/apm.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2026|
|
||||
|Xircon |
|
||||
\*----------------*/
|
||||
#include "apm.h"
|
||||
6
src/kernel/dri/power/apm.h
Normal file
6
src/kernel/dri/power/apm.h
Normal file
@ -0,0 +1,6 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2026|
|
||||
|Xircon |
|
||||
\*----------------*/
|
||||
#pragma once
|
||||
@ -40,7 +40,7 @@ void COM1_Serial_Handler()
|
||||
{
|
||||
// Serial_Read_Buffer = Read_Serial(COM1_PORT);
|
||||
// printf("Serial Read Buffer: %s", Serial_Read_Buffer);
|
||||
printf("IRQ 4 Triggered?!");
|
||||
// printf("IRQ 4 Triggered?!");
|
||||
}
|
||||
|
||||
/*Initialize Serial Driver on `COM_Port` port with `baud` as baud rate*/
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <nanstd.h>
|
||||
#include <string.h>
|
||||
|
||||
// Drivers
|
||||
|
||||
@ -61,7 +63,6 @@ extern uint8_t __bss_start; // Start of Kernel in memory
|
||||
extern uint8_t __end; // End of Kernel in memory
|
||||
|
||||
extern int uptime; // System uptime measured by precision timer unit.
|
||||
extern unsigned RAND_SEED; // Random number generator's seed
|
||||
|
||||
uint16_t DEBUG_COM_PORT = COM1_PORT; // COM Port to Output Debug strings to
|
||||
|
||||
@ -84,7 +85,7 @@ void start(unsigned long magic, unsigned long address) {
|
||||
#endif
|
||||
|
||||
printf("The Nano OS %s\n--------------------------------------------\n", VERSION);
|
||||
printf("Tip: The RD in the Version stands for Research and Development!\n");
|
||||
printTip();
|
||||
printf("--------------------------------------------\n");
|
||||
|
||||
// Multiboot Debug Stuff
|
||||
@ -108,7 +109,7 @@ void start(unsigned long magic, unsigned long address) {
|
||||
IRQ_RegisterHandler(4, COM1_Serial_Handler);
|
||||
IRQ_RegisterHandler(6, Floppy_Handler);
|
||||
IRQ_RegisterHandler(8, CMOS_RTC_Handler);
|
||||
RAND_SEED = Read_CMOS(CMOS_RTC_Hours);
|
||||
srand(Read_CMOS(CMOS_RTC_Hours) + Read_CMOS(CMOS_RTC_Seconds));
|
||||
#endif
|
||||
// Other Stuff
|
||||
Serial_Init(DEBUG_COM_PORT, 9600);
|
||||
@ -139,9 +140,21 @@ void start(unsigned long magic, unsigned long address) {
|
||||
BCD2BIN(Read_CMOS(CMOS_RTC_Year)));
|
||||
// Beep!
|
||||
PCSP_Beep();
|
||||
char* answer;
|
||||
printf("Would you like to change the time and date? [Y/n] ");
|
||||
scanf("");
|
||||
char* answer = "\0";
|
||||
printf("Would you like to change the time and date? [y/N] ");
|
||||
scanf("%s", answer);
|
||||
if (!strcmp(answer, "Y") || !strcmp(answer, "y")) {
|
||||
printf("Please insert Date and Time in [SS]:[MM]:[HH] [DD]/[MM]/[YYYY] Format: ");
|
||||
scanf("%s", answer);
|
||||
printf("\n");
|
||||
}
|
||||
printf("Starting Shell...");
|
||||
spinner(20);
|
||||
printf("Done!\n");
|
||||
for(;;) {
|
||||
printf(":>");
|
||||
scanf("");
|
||||
}
|
||||
|
||||
end:
|
||||
for (;;);
|
||||
|
||||
@ -6,12 +6,35 @@
|
||||
#include "nanstd.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <dri/timer.h>
|
||||
|
||||
extern uint8_t _keyboard_scancode;
|
||||
|
||||
// Prints a helpful tip!
|
||||
/*Prints a helpful or cool tip About the OS!*/
|
||||
void printTip() {
|
||||
|
||||
int number = rand() % 17;
|
||||
switch (number) {
|
||||
case 1: printf("Tip: The RD in the Version stands for Research and Development!\n"); break;
|
||||
case 2: printf("Tip: You can use Ctrl+Alt+Del to Reboot!\n"); break;
|
||||
case 3: printf("Tip: You can use Ctrl+Alt+ESC to Shutdown!\n"); break;
|
||||
case 4: printf("Tip: Nanite is under a modified BSD 3-Clause Licence!\n"); break;
|
||||
case 5: printf("Tip: Nanite is also supported on the ESP32 Dev Board!\n"); break;
|
||||
case 6: printf("Tip: The Serial Interface is at 9600 Baud by Default!\n"); break;
|
||||
case 7: printf("Tip: This is a hobby OS, worked on in the Author's Spare Time!\n"); break;
|
||||
case 8: printf("Tip: Nanite Has been Written By Xircon Since 2024!\n"); break;
|
||||
case 9: printf("Tip: Nanite has its own C std header, like unistd! Its called nanstd.h!\n"); break;
|
||||
case 10: printf("Tip: Nanite Can be built with a Different Keyboard Layout!\n"); break;
|
||||
case 11: printf("Tip: Nanite is and always will be Open Source Software!\n"); break;
|
||||
case 12: printf("Tip: The RD Versioning is in Reference to early Minecraft!\n"); break;
|
||||
case 13: printf("Tip: Nanite's nanstd.h has factorial support! (I like them!)\n"); break;
|
||||
case 14: printf("Tip: The Shell's Loading Spinner is just decor and can be removed!\n"); break;
|
||||
case 15: printf("Tip: Nanite is around 6000 lines of C and ASM as of Version RD-00127!\n"); break;
|
||||
case 16: printf("Tip: A Bug in the Keyboard Driver used to Allow RCtrl+RAlt to Reboot!\n"); break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*Calculate Factorial of `N`*/
|
||||
@ -25,3 +48,24 @@ unsigned int factorial(unsigned int N) {
|
||||
|
||||
return fact;
|
||||
}
|
||||
|
||||
/*Prints A Little Spinning cursor*/
|
||||
void spinner(int times) {
|
||||
int x, y;
|
||||
while (times >= 0) {
|
||||
printf("|");
|
||||
Timer_Wait(1);
|
||||
printf("\b");
|
||||
printf("/");
|
||||
Timer_Wait(1);
|
||||
printf("\b");
|
||||
printf("-");
|
||||
Timer_Wait(1);
|
||||
printf("\b");
|
||||
printf("\\");
|
||||
Timer_Wait(1);
|
||||
printf("\b");
|
||||
times--;
|
||||
}
|
||||
printf(" \b");
|
||||
}
|
||||
@ -5,4 +5,6 @@
|
||||
\*----------------*/
|
||||
#pragma once
|
||||
|
||||
unsigned int factorial(unsigned int N);
|
||||
unsigned int factorial(unsigned int N);
|
||||
void spinner(int times);
|
||||
void printTip();
|
||||
@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <dri/keyboard.h>
|
||||
|
||||
@ -20,6 +21,8 @@ const uint8_t DEFAULT_COLOUR = 0x6;
|
||||
const unsigned SCREEN_WIDTH = 80;
|
||||
const unsigned SCREEN_HEIGHT = 25;
|
||||
|
||||
extern bool _shift;
|
||||
|
||||
uint8_t* g_ScreenBuffer = (uint8_t*)0xB8000;
|
||||
int g_ScreenX = 0, g_ScreenY = 0;
|
||||
|
||||
@ -353,7 +356,7 @@ void print_buffer(const char* msg, const void* buffer, uint32_t count)
|
||||
|
||||
/*Take user input from Keyboard!*/
|
||||
int scanf(const char* fmt, ...) {
|
||||
va_list(args);
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int state = SCANF_STATE_NORMAL;
|
||||
int mode = SCANF_MODE_DEFAULT;
|
||||
@ -396,16 +399,53 @@ int scanf(const char* fmt, ...) {
|
||||
switch(mode) {
|
||||
case SCANF_MODE_DEFAULT:
|
||||
for(;;) {
|
||||
char character = '\0';
|
||||
character = kscan();
|
||||
switch (character) {
|
||||
case '\n': return 0;
|
||||
default: if(character != 0) {printf("%c", character); character = 0;}
|
||||
}
|
||||
char character = '\0';
|
||||
character = kscan();
|
||||
switch (character) {
|
||||
case '\n': printf("\n");
|
||||
return 0;
|
||||
case '\b': printf("\b ");
|
||||
default: if(character != 0) {
|
||||
if(_shift == true) {
|
||||
printf("%c", character);
|
||||
break;}
|
||||
else {
|
||||
printf("%c", tolower(character));}
|
||||
}
|
||||
}
|
||||
}
|
||||
case SCANF_MODE_STRING:
|
||||
char* buffer = "\0";
|
||||
int i = 0;
|
||||
for(;;) {
|
||||
char character = '\0';
|
||||
character = kscan();
|
||||
switch (character) {
|
||||
case '\n': printf("\n");
|
||||
*va_arg(args, char*) = *buffer;
|
||||
return 0;
|
||||
case '\b': printf("\b"); i--; buffer[i] = '\0';
|
||||
break;
|
||||
case '\t': printf(" ");
|
||||
break;
|
||||
default: if(character != 0) {
|
||||
if(_shift == true) {
|
||||
printf("%c", character);
|
||||
buffer[i] = character;
|
||||
i++;
|
||||
break;}
|
||||
else {
|
||||
printf("%c", tolower(character));
|
||||
buffer[i] = tolower(character);
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default: return 0;
|
||||
|
||||
}
|
||||
va_end(args);
|
||||
return 0;
|
||||
}
|
||||
@ -16,7 +16,7 @@ unsigned bit;
|
||||
/*Random Number Generator using a Linear Feedback Shift Register*/
|
||||
unsigned rand(void) {
|
||||
RAND_SEED = (RAND_SEED + uptime - Read_CMOS(CMOS_RTC_Minutes) + Read_CMOS(CMOS_RTC_Seconds));
|
||||
bit = ((factorial(RAND_SEED+uptime) >> 0) ^ (RAND_SEED >> 2) ^ ((RAND_SEED+Read_CMOS(CMOS_RTC_Seconds)) >> 3) ^ ((RAND_SEED+uptime) >> 5)) & 1;
|
||||
bit = ((RAND_SEED+uptime) >> 0) ^ (RAND_SEED >> 2) ^ ((RAND_SEED+Read_CMOS(CMOS_RTC_Seconds)) >> 3) ^ ((RAND_SEED+uptime) >> 5) & 1;
|
||||
return RAND_SEED = (RAND_SEED >> 1) | (bit << 15);
|
||||
}
|
||||
|
||||
|
||||
@ -61,4 +61,13 @@ char* strcat(char *dest, const char *src) {
|
||||
}
|
||||
*dest = '\0';
|
||||
return original_dest;
|
||||
}
|
||||
|
||||
int strcmp(const char* s1, const char* s2) {
|
||||
while(*s1 && (*s1 == *s2))
|
||||
{
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
|
||||
}
|
||||
@ -9,3 +9,4 @@ const char* strchr(const char* str, char chr);
|
||||
char* strcpy(char* dst, const char* src);
|
||||
unsigned strlen(const char* str);
|
||||
char* strcat(char* dest, const char* src);
|
||||
int strcmp(const char* s1, const char* s2);
|
||||
@ -6,6 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/" // Nanite's Logo as a formatted string
|
||||
#define VERSION "RD-00124" // Current Version of Nanite
|
||||
#define VERSION "RD-00128" // Current Version of Nanite
|
||||
#define BOOTLOGO " _ ______ ____ ____ ______\n / | / / __ )/ __ \\/ __ /_ __/\n / |/ / __ / / / / / / // / \n / /| / /_/ / /_/ / /_/ // / \n/_/ |_/_____/\\____/\\____//_/ \n" // Old bootloader logo
|
||||
// one day i will re-implement NBOOT V 2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user