mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 02:23:10 +00:00
MAJOR RESTRUCTURE
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#ifndef _DRIVERS_DISK_H
|
||||
#define _DRIVERS_DISK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PIO_PORT 0x1f0
|
||||
#define READ_COMMAND 0x20
|
||||
#define WRITE_COMMAND 0x30
|
||||
#define CACHE_FLUSH 0xE7
|
||||
|
||||
void diskRead(uint32_t lbaAddress, uint8_t sectorCount, char* dst);
|
||||
void diskWrite(uint32_t lbaAddress, uint8_t sectorCount, char* src);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef _DRIVERS_KEYBOARD_H
|
||||
#define _DRIVERS_KEYBOARD_H
|
||||
|
||||
#include <cpu/isr.h>
|
||||
|
||||
// Special keys
|
||||
#define LEFT_SHIFT_PRESS 0x2a
|
||||
#define LEFT_SHIFT_RELEASE (LEFT_SHIFT_PRESS | 0x80)
|
||||
#define RIGHT_SHIFT_PRESS 0x36
|
||||
#define RIGHT_SHIFT_RELEASE (RIGHT_SHIFT_PRESS | 0x80)
|
||||
#define LEFT_CTRL_PRESS 0x1D
|
||||
#define LEFT_CTRL_RELEASE (LEFT_CTRL_PRESS | 0x80)
|
||||
#define RIGHT_CTRL_PRESS 0x1D
|
||||
#define RIGHT_CTRL_RELEASE (RIGHT_CTRL_PRESS | 0x80)
|
||||
#define LEFT_ALT_PRESS 0x38
|
||||
#define LEFT_ALT_RELEASE (LEFT_ALT_PRESS | 0x80)
|
||||
#define RIGHT_ALT_PRESS 0x38
|
||||
#define RIGHT_ALT_RELEASE (RIGHT_ALT_PRESS | 0x80)
|
||||
|
||||
// Basic US Keyboard layout
|
||||
#define US_KEYBOARD {\
|
||||
{\
|
||||
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b',\
|
||||
'\t','q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',\
|
||||
0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'','`',\
|
||||
0, '\\','z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0,\
|
||||
'*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
|
||||
'7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.',\
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\
|
||||
},\
|
||||
{\
|
||||
0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', '\t',\
|
||||
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0, 'A', 'S',\
|
||||
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V',\
|
||||
'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
|
||||
0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.',\
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\
|
||||
}\
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char character;
|
||||
int shift;
|
||||
} keyboardState_t;
|
||||
|
||||
void keyboardHandler(intFrame_t*);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _DRIVERS_PCSPK_H
|
||||
#define _DRIVERS_PCSPK_H
|
||||
|
||||
#include <sys/notes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PC_SPEAKER 0x61
|
||||
|
||||
void enableSpeaker();
|
||||
void disableSpeaker();
|
||||
void playNote(note_t note, uint32_t ms);
|
||||
void rest(uint32_t ms);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef _DRIVERS_RTC_H
|
||||
#define _DRIVERS_RTC_H
|
||||
|
||||
#include <cpu/isr.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define CMOS_ADDRESS 0x70
|
||||
#define CMOS_DATA 0x71
|
||||
|
||||
typedef struct {
|
||||
uint8_t second;
|
||||
uint8_t minute;
|
||||
uint8_t hour;
|
||||
uint8_t day;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
} __attribute__ ((packed)) datetime_t;
|
||||
|
||||
void rtcHandler(intFrame_t*);
|
||||
int cmosUpdateProgress();
|
||||
uint8_t getRtcRegister(uint8_t reg);
|
||||
void enableRtc();
|
||||
void disableRtc();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _DRIVERS_SERIAL_H
|
||||
#define _DRIVERS_SERIAL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define PORT_COM1 0x3f8
|
||||
#define PORT_COM2 0x2f8
|
||||
#define PORT_COM3 0x3e8
|
||||
#define PORT_COM4 0x2e8
|
||||
|
||||
// IRQ4 -> COM1, IRQ3 -> COM2
|
||||
#define SERIAL_IRQ 4
|
||||
|
||||
int serialEnable(int port);
|
||||
int setupSerial();
|
||||
void serialWrite(int port, char c);
|
||||
char serialRead(int port);
|
||||
char serialReadAsync(int port);
|
||||
|
||||
int debugf(const char* fmt, ...);
|
||||
int vdebugf(const char* fmt, va_list va);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _DRIVERS_TIMER_H
|
||||
#define _DRIVERS_TIMER_H
|
||||
|
||||
#include <cpu/isr.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define CHANNEL_0 0x40 // Offset it by 1 or 2 for ch1 and ch2
|
||||
#define COMMAND 0x43
|
||||
#define INPUT_CLK 1193182
|
||||
|
||||
void timerHandler(intFrame_t*);
|
||||
void setPitPhase(uint8_t channel, uint8_t opMode, uint16_t hz);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user