mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
Initial commit: SUB-OS 64-Bit Production Monolithic Operating System with LazyBox userland suite
This commit is contained in:
commit
cd9c786d14
88 files changed
+7132
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#ifndef _DRIVERS_ATA_H
|
||||
#define _DRIVERS_ATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define ATA_SECTOR_SIZE 512
|
||||
|
||||
#define ATA_PRIMARY_IO 0x1F0
|
||||
#define ATA_PRIMARY_CTRL 0x3F6
|
||||
#define ATA_SECONDARY_IO 0x170
|
||||
#define ATA_SECONDARY_CTRL 0x376
|
||||
|
||||
typedef struct {
|
||||
bool present;
|
||||
bool is_master;
|
||||
uint32_t sector_count;
|
||||
char model[41];
|
||||
char serial[21];
|
||||
} ata_device_t;
|
||||
|
||||
bool ata_init(void);
|
||||
bool ata_read_sectors(uint32_t lba, uint8_t count, void* buffer);
|
||||
bool ata_write_sectors(uint32_t lba, uint8_t count, const void* buffer);
|
||||
const ata_device_t* ata_get_primary_master(void);
|
||||
|
||||
#endif // _DRIVERS_ATA_H
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _DRIVERS_E1000_H
|
||||
#define _DRIVERS_E1000_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define E1000_VENDOR_ID 0x8086
|
||||
#define E1000_DEV_82540EM 0x100E
|
||||
#define E1000_DEV_82545EM 0x100F
|
||||
|
||||
bool e1000_init(void);
|
||||
void e1000_send(const void* data, uint16_t len);
|
||||
void e1000_get_mac(uint8_t* mac_out);
|
||||
bool e1000_is_link_up(void);
|
||||
|
||||
uint64_t e1000_get_rx_packets(void);
|
||||
uint64_t e1000_get_tx_packets(void);
|
||||
uint64_t e1000_get_rx_bytes(void);
|
||||
uint64_t e1000_get_tx_bytes(void);
|
||||
|
||||
#endif // _DRIVERS_E1000_H
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef _DRIVERS_KEYBOARD_H
|
||||
#define _DRIVERS_KEYBOARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define KEY_SPECIAL_FLAG 0x0100
|
||||
|
||||
enum special_keys {
|
||||
KEY_UP = KEY_SPECIAL_FLAG | 0x01,
|
||||
KEY_DOWN = KEY_SPECIAL_FLAG | 0x02,
|
||||
KEY_LEFT = KEY_SPECIAL_FLAG | 0x03,
|
||||
KEY_RIGHT = KEY_SPECIAL_FLAG | 0x04,
|
||||
KEY_HOME = KEY_SPECIAL_FLAG | 0x05,
|
||||
KEY_END = KEY_SPECIAL_FLAG | 0x06,
|
||||
KEY_PAGE_UP = KEY_SPECIAL_FLAG | 0x07,
|
||||
KEY_PAGE_DOWN= KEY_SPECIAL_FLAG | 0x08,
|
||||
KEY_INSERT = KEY_SPECIAL_FLAG | 0x09,
|
||||
KEY_DELETE = KEY_SPECIAL_FLAG | 0x0A,
|
||||
KEY_F1 = KEY_SPECIAL_FLAG | 0x11,
|
||||
KEY_F2 = KEY_SPECIAL_FLAG | 0x12,
|
||||
KEY_F3 = KEY_SPECIAL_FLAG | 0x13,
|
||||
KEY_F4 = KEY_SPECIAL_FLAG | 0x14,
|
||||
KEY_F5 = KEY_SPECIAL_FLAG | 0x15,
|
||||
KEY_F6 = KEY_SPECIAL_FLAG | 0x16,
|
||||
KEY_F7 = KEY_SPECIAL_FLAG | 0x17,
|
||||
KEY_F8 = KEY_SPECIAL_FLAG | 0x18,
|
||||
KEY_F9 = KEY_SPECIAL_FLAG | 0x19,
|
||||
KEY_F10 = KEY_SPECIAL_FLAG | 0x1A,
|
||||
KEY_F11 = KEY_SPECIAL_FLAG | 0x1B,
|
||||
KEY_F12 = KEY_SPECIAL_FLAG | 0x1C,
|
||||
};
|
||||
|
||||
void keyboard_init(void);
|
||||
uint16_t keyboard_get_key(void);
|
||||
bool keyboard_has_key(void);
|
||||
char keyboard_get_char(void);
|
||||
|
||||
#endif // _DRIVERS_KEYBOARD_H
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef _DRIVERS_PCI_H
|
||||
#define _DRIVERS_PCI_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PCI_CONFIG_ADDRESS 0xCF8
|
||||
#define PCI_CONFIG_DATA 0xCFC
|
||||
|
||||
#define PCI_CLASS_NETWORK 0x02
|
||||
#define PCI_CLASS_DISPLAY 0x03
|
||||
#define PCI_CLASS_STORAGE 0x01
|
||||
|
||||
#define PCI_SUBCLASS_ETHERNET 0x00
|
||||
#define PCI_SUBCLASS_IDE 0x01
|
||||
#define PCI_SUBCLASS_SATA 0x06
|
||||
|
||||
typedef struct pci_device {
|
||||
uint8_t bus;
|
||||
uint8_t slot;
|
||||
uint8_t function;
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint8_t class_id;
|
||||
uint8_t subclass_id;
|
||||
uint8_t prog_if;
|
||||
uint8_t revision;
|
||||
uint8_t irq;
|
||||
uint32_t bar[6];
|
||||
uint8_t bar_type[6];
|
||||
struct pci_device* next;
|
||||
} pci_device_t;
|
||||
|
||||
void pci_init(void);
|
||||
pci_device_t* pci_get_devices(void);
|
||||
pci_device_t* pci_find_device(uint16_t vendor_id, uint16_t device_id);
|
||||
pci_device_t* pci_find_class(uint8_t class_id, uint8_t subclass_id);
|
||||
void pci_enable_bus_mastering(pci_device_t* dev);
|
||||
|
||||
uint32_t pci_config_read32(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
uint16_t pci_config_read16(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
uint8_t pci_config_read8(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
void pci_config_write32(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, uint32_t val);
|
||||
void pci_config_write16(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, uint16_t val);
|
||||
|
||||
#endif // _DRIVERS_PCI_H
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _DRIVERS_SERIAL_H
|
||||
#define _DRIVERS_SERIAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define COM1_PORT 0x3F8
|
||||
|
||||
void serial_init(void);
|
||||
void serial_write_char(char c);
|
||||
void serial_write_string(const char* str);
|
||||
char serial_read_char(void);
|
||||
bool serial_received(void);
|
||||
|
||||
#endif // _DRIVERS_SERIAL_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef _DRIVERS_SPEAKER_H
|
||||
#define _DRIVERS_SPEAKER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void speaker_on(uint32_t frequency);
|
||||
void speaker_off(void);
|
||||
void speaker_beep(uint32_t frequency, uint32_t duration_ms);
|
||||
|
||||
#endif // _DRIVERS_SPEAKER_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _DRIVERS_TTY_H
|
||||
#define _DRIVERS_TTY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAX_TTYS 4
|
||||
#define TTY_WIDTH 80
|
||||
#define TTY_HEIGHT 25
|
||||
|
||||
void tty_init(void);
|
||||
void tty_switch(int index);
|
||||
int tty_get_current(void);
|
||||
void tty_write(const char* data, size_t size);
|
||||
void tty_write_string(const char* data);
|
||||
void tty_clear(void);
|
||||
void tty_set_cursor(int row, int col);
|
||||
|
||||
#endif // _DRIVERS_TTY_H
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef _DRIVERS_VGA_H
|
||||
#define _DRIVERS_VGA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define VGA_WIDTH 80
|
||||
#define VGA_HEIGHT 25
|
||||
#define VGA_MEMORY 0xB8000
|
||||
|
||||
enum vga_color {
|
||||
VGA_COLOR_BLACK = 0,
|
||||
VGA_COLOR_BLUE = 1,
|
||||
VGA_COLOR_GREEN = 2,
|
||||
VGA_COLOR_CYAN = 3,
|
||||
VGA_COLOR_RED = 4,
|
||||
VGA_COLOR_MAGENTA = 5,
|
||||
VGA_COLOR_BROWN = 6,
|
||||
VGA_COLOR_LIGHT_GREY = 7,
|
||||
VGA_COLOR_DARK_GREY = 8,
|
||||
VGA_COLOR_LIGHT_BLUE = 9,
|
||||
VGA_COLOR_LIGHT_GREEN = 10,
|
||||
VGA_COLOR_LIGHT_CYAN = 11,
|
||||
VGA_COLOR_LIGHT_RED = 12,
|
||||
VGA_COLOR_LIGHT_MAGENTA = 13,
|
||||
VGA_COLOR_LIGHT_BROWN = 14,
|
||||
VGA_COLOR_WHITE = 15,
|
||||
};
|
||||
|
||||
static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
|
||||
return fg | (bg << 4);
|
||||
}
|
||||
|
||||
static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
|
||||
return (uint16_t)uc | ((uint16_t)color << 8);
|
||||
}
|
||||
|
||||
void vga_init(void);
|
||||
void vga_clear(void);
|
||||
void vga_putc(char c);
|
||||
void vga_write(const char* str);
|
||||
void vga_set_color(enum vga_color fg, enum vga_color bg);
|
||||
void vga_set_cursor(int row, int col);
|
||||
void vga_get_cursor(int* row, int* col);
|
||||
void vga_enable_cursor(uint8_t cursor_start, uint8_t cursor_end);
|
||||
void vga_disable_cursor(void);
|
||||
|
||||
#endif // _DRIVERS_VGA_H
|
||||
Reference in new issue
Block a user