diff options
author | Marvin Borner | 2020-08-09 16:51:01 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-09 16:51:01 +0200 |
commit | 162d024a53e1e31e00ff0b6f47dd4590edebc551 (patch) | |
tree | 711d3886c300dfaddffdafaa89b690b45eb2101d /src/inc | |
parent | 79f2fa136f26a0b87917336e089485712ee49bd6 (diff) |
Heavy restructuring of libc, kernel and apps
Diffstat (limited to 'src/inc')
-rw-r--r-- | src/inc/boot.h | 10 | ||||
-rw-r--r-- | src/inc/cpu.h | 29 | ||||
-rw-r--r-- | src/inc/fs.h | 102 | ||||
-rw-r--r-- | src/inc/gui.h | 22 | ||||
-rw-r--r-- | src/inc/ide.h | 40 | ||||
-rw-r--r-- | src/inc/interrupts.h | 95 | ||||
-rw-r--r-- | src/inc/keyboard.h | 8 | ||||
-rw-r--r-- | src/inc/load.h | 10 | ||||
-rw-r--r-- | src/inc/proc.h | 30 | ||||
-rw-r--r-- | src/inc/psf.h | 48 | ||||
-rw-r--r-- | src/inc/serial.h | 9 | ||||
-rw-r--r-- | src/inc/syscall.h | 8 | ||||
-rw-r--r-- | src/inc/timer.h | 11 | ||||
-rw-r--r-- | src/inc/vesa.h | 57 |
14 files changed, 0 insertions, 479 deletions
diff --git a/src/inc/boot.h b/src/inc/boot.h deleted file mode 100644 index 1a41c32..0000000 --- a/src/inc/boot.h +++ /dev/null @@ -1,10 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner -// This file specifies the structs passed by the bootloader - -#include <def.h> -#include <vesa.h> - -struct vid_info { - u32 mode; - struct vbe *info; -}; diff --git a/src/inc/cpu.h b/src/inc/cpu.h deleted file mode 100644 index eb09291..0000000 --- a/src/inc/cpu.h +++ /dev/null @@ -1,29 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef CPU_H -#define CPU_H - -#include <def.h> - -u8 inb(u16 port); -u16 inw(u16 port); -u32 inl(u16 port); -void insl(u16 port, void *addr, int n); - -void outb(u16 port, u8 data); -void outw(u16 port, u16 data); -void outl(u16 port, u32 data); -void cli(); -void sti(); -void hlt(); -void idle(); - -static inline void spinlock(int *ptr) -{ - int prev; - do - __asm__ volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1)); - while (prev); -} - -#endif diff --git a/src/inc/fs.h b/src/inc/fs.h deleted file mode 100644 index 775a1ce..0000000 --- a/src/inc/fs.h +++ /dev/null @@ -1,102 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner -// EXT2 based filesystem - -#ifndef FS_H -#define FS_H - -#include <def.h> - -#define EXT2_BOOT 0 -#define EXT2_SUPER 1 -#define EXT2_ROOT 2 -#define EXT2_MAGIC 0x0000EF53 - -struct superblock { - u32 total_inodes; - u32 total_blocks; - u32 su_res_blocks; // Superuser reserved - u32 free_blocks; - u32 free_inodes; - u32 superblock_block_num; - u32 log2_block_size; - u32 log2_frag_size; - u32 blocks_per_group; - u32 frags_per_group; - u32 inodes_per_group; - u32 last_mount_time; - u32 last_write_time; - u16 mounts_since_fsck; - u16 max_mounts_since_fsck; - u16 magic; - u16 state; // 1 clean; 2 errors - u16 error_action; - u16 minor_version; - u32 last_fsck_time; - u32 max_time_since_fsck; - u32 creator_os_id; - u32 major_version; - u16 res_block_uid; - u16 res_block_gid; -}; - -struct bgd { - u32 block_bitmap; - u32 inode_bitmap; - u32 inode_table; - u16 free_blocks; - u16 free_inodes; - u16 used_dirs; - u16 pad; - u8 bg_reserved[12]; -}; - -struct inode { - u16 mode; - u16 uid; - u32 size; - - u32 last_access_time; - u32 creation_time; - u32 last_modification_time; - u32 deletion_time; - - u16 gid; - u16 link_count; - u32 blocks; - u32 flags; - u32 os_specific_val1; - u32 block[15]; - u32 generation; - - u32 reserved1; - u32 reserved2; - - u32 fragment_addr; - u8 os_specific_val2[12]; -}; - -#define INODE_SIZE (sizeof(struct inode)) - -struct dirent { - u32 inode_num; - u16 total_len; - u8 name_len; - u8 type_indicator; - u8 name[]; -}; - -struct file { - struct inode inode; - u32 pos; - u8 block_index; - u8 *buf; - u32 curr_block_pos; -}; - -int find_inode(const char *name, int dir_inode); -struct inode *get_inode(int i); -void *read_inode(struct inode *in); -void *read_file(char *path); -void ls_root(); // DEMO ;) - -#endif diff --git a/src/inc/gui.h b/src/inc/gui.h deleted file mode 100644 index 760bcb9..0000000 --- a/src/inc/gui.h +++ /dev/null @@ -1,22 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner -// Some GUI functions - -#ifndef GUI_H -#define GUI_H - -#include <def.h> - -// Generalized font struct -struct font { - char *chars; - int height; - int width; - int char_size; -}; - -void gui_write(int x, int y, const u32 c[3], char *text); -void gui_term_write_char(char ch); -void gui_term_write(char *text); -void gui_init(char *font_path); - -#endif diff --git a/src/inc/ide.h b/src/inc/ide.h deleted file mode 100644 index 9d753ae..0000000 --- a/src/inc/ide.h +++ /dev/null @@ -1,40 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef IDE_H -#define IDE_H - -#include <def.h> - -#define BLOCK_SIZE 1024 -#define SECTOR_SIZE 512 - -#define IDE_BUSY (1 << 7) -#define IDE_READY (1 << 6) -#define IDE_DRIVE_FAULT (1 << 5) -#define IDE_ERROR (1 << 0) - -#define IDE_IO 0x1F0 -#define IDE_DATA 0x0 -#define IDE_FEATURES 0x1 -#define IDE_SECTOR_COUNT 0x2 -#define IDE_LOW 0x3 -#define IDE_MID 0x4 -#define IDE_HIGH 0x5 -#define IDE_HEAD 0x6 -#define IDE_CMD 0x7 -#define IDE_ALTERNATE 0x3F6 - -#define LBA_LOW(c) ((u8)(c & 0xFF)) -#define LBA_MID(c) ((u8)(c >> 8) & 0xFF) -#define LBA_HIGH(c) ((u8)(c >> 16) & 0xFF) -#define LBA_LAST(c) ((u8)(c >> 24) & 0xF) - -#define IDE_CMD_READ (BLOCK_SIZE / SECTOR_SIZE == 1) ? 0x20 : 0xC4 -#define IDE_CMD_WRITE (BLOCK_SIZE / SECTOR_SIZE == 1) ? 0x30 : 0xC5 -#define IDE_CMD_READ_MUL 0xC4 -#define IDE_CMD_WRITE_MUL 0xC5 - -int ide_wait(int check); -void *ide_read(void *b, u32 block); - -#endif diff --git a/src/inc/interrupts.h b/src/inc/interrupts.h deleted file mode 100644 index e943e5a..0000000 --- a/src/inc/interrupts.h +++ /dev/null @@ -1,95 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef IDT_H -#define IDT_H - -#include <def.h> - -struct regs { - u32 gs, fs, es, ds; - u32 edi, esi, ebp, esp, ebx, edx, ecx, eax; - u32 int_no, err_code; - u32 eip, cs, eflags, useresp, ss; -}; - -struct idt_entry { - u16 base_low; - u16 sel; // Kernel segment - u8 always0; // Always 0 - u8 flags; - u16 base_high; -} __attribute__((packed)); - -struct idt_ptr { - u16 limit; - void *base; -} __attribute__((packed)); - -struct idt_entry idt[256]; -struct idt_ptr idt_ptr; - -void idt_set_gate(u8 num, u32 base, u16 sel, u8 flags); - -void irq_install_handler(int irq, void (*handler)(struct regs *r)); -void irq_uninstall_handler(int irq); - -void isr_install_handler(int isr, void (*handler)(struct regs *r)); -void isr_uninstall_handler(int isr); - -void interrupts_install(); - -// External handlers (ASM) - -extern void isr0(); -extern void isr1(); -extern void isr2(); -extern void isr3(); -extern void isr4(); -extern void isr5(); -extern void isr6(); -extern void isr7(); -extern void isr8(); -extern void isr9(); -extern void isr10(); -extern void isr11(); -extern void isr12(); -extern void isr13(); -extern void isr14(); -extern void isr15(); -extern void isr16(); -extern void isr17(); -extern void isr18(); -extern void isr19(); -extern void isr20(); -extern void isr21(); -extern void isr22(); -extern void isr23(); -extern void isr24(); -extern void isr25(); -extern void isr26(); -extern void isr27(); -extern void isr28(); -extern void isr29(); -extern void isr30(); -extern void isr31(); -extern void isr128(); - -extern void irq0(); -extern void irq1(); -extern void irq2(); -extern void irq3(); -extern void irq4(); -extern void irq5(); -extern void irq6(); -extern void irq7(); -extern void irq8(); -extern void irq9(); -extern void irq10(); -extern void irq11(); -extern void irq12(); -extern void irq13(); -extern void irq14(); -extern void irq15(); -extern void irq128(); - -#endif diff --git a/src/inc/keyboard.h b/src/inc/keyboard.h deleted file mode 100644 index f0effc7..0000000 --- a/src/inc/keyboard.h +++ /dev/null @@ -1,8 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef KEYBOARD_H -#define KEYBOARD_H - -void keyboard_install(); - -#endif diff --git a/src/inc/load.h b/src/inc/load.h deleted file mode 100644 index 60fecf9..0000000 --- a/src/inc/load.h +++ /dev/null @@ -1,10 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef LOAD_H -#define LOAD_H - -#include <proc.h> - -void bin_load(char *path, struct proc *proc); - -#endif diff --git a/src/inc/proc.h b/src/inc/proc.h deleted file mode 100644 index 39ba704..0000000 --- a/src/inc/proc.h +++ /dev/null @@ -1,30 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef PROC_H -#define PROC_H - -#include <def.h> -#include <interrupts.h> - -#define EFLAGS_ALWAYS 0x2 // Always one -#define EFLAGS_INTERRUPTS 0x200 // Enable interrupts - -#define GDT_USER_CODE_OFFSET 0x1b // User code segment offset in GDT (with ring3 mask) -#define GDT_USER_DATA_OFFSET 0x23 // User data segment offset in GDT (with ring3 mask) - -enum state { PROC_RUNNING, PROC_ASLEEP }; - -struct proc { - u32 pid; - enum state state; - char name[32]; - struct regs regs; - /* struct proc *parent; */ - struct proc *next; -}; - -void proc_init(); -void proc_print(); -struct proc *proc_make(); - -#endif diff --git a/src/inc/psf.h b/src/inc/psf.h deleted file mode 100644 index 63a3d1e..0000000 --- a/src/inc/psf.h +++ /dev/null @@ -1,48 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner -// PSF parser - -#ifndef PSF_H -#define PSF_H - -#include <def.h> - -/** - * PSF version 1 - */ - -#define PSF1_MAGIC_0 0x36 -#define PSF1_MAGIC_1 0x04 -#define PSF1_MODE_256 0 -#define PSF1_MODE_512 1 -#define PSF1_MODE_256_UNICODE 2 -#define PSF1_MODE_512_UNICODE 3 - -struct psf1_header { - u8 magic[2]; - u8 mode; - u8 char_size; -}; - -/** - * PSF version 2 - */ - -#define PSF2_MAGIC_0 0x72 -#define PSF2_MAGIC_1 0xb5 -#define PSF2_MAGIC_2 0x4a -#define PSF2_MAGIC_3 0x86 - -struct psf2_header { - u8 magic[4]; - u32 version; - u32 size; - u32 flags; - u32 glyph_count; - u32 char_size; - u32 height; - u32 width; -}; - -struct font *psf_parse(char *data); - -#endif diff --git a/src/inc/serial.h b/src/inc/serial.h deleted file mode 100644 index 6511952..0000000 --- a/src/inc/serial.h +++ /dev/null @@ -1,9 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef SERIAL_H -#define SERIAL_H - -void serial_install(); -void serial_print(const char *data); - -#endif diff --git a/src/inc/syscall.h b/src/inc/syscall.h deleted file mode 100644 index 3f89365..0000000 --- a/src/inc/syscall.h +++ /dev/null @@ -1,8 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef SYSCALL_H -#define SYSCALL_H - -void syscall_init(); - -#endif diff --git a/src/inc/timer.h b/src/inc/timer.h deleted file mode 100644 index 7c4f077..0000000 --- a/src/inc/timer.h +++ /dev/null @@ -1,11 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef TIMER_H -#define TIMER_H - -#include <def.h> - -void timer_install(); -void timer_handler(); // For scheduler - -#endif diff --git a/src/inc/vesa.h b/src/inc/vesa.h deleted file mode 100644 index e34cdc0..0000000 --- a/src/inc/vesa.h +++ /dev/null @@ -1,57 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef VBE_H -#define VBE_H - -#include <def.h> - -struct vbe { - u16 attributes; - u8 window_a; - u8 window_b; - u16 granularity; - u16 window_size; - u16 segment_a; - u16 segment_b; - u32 win_func_ptr; - u16 pitch; - u16 width; - u16 height; - u8 w_char; - u8 y_char; - u8 planes; - u8 bpp; - u8 banks; - u8 memory_model; - u8 bank_size; - u8 image_pages; - u8 reserved0; - - u8 red_mask; - u8 red_position; - u8 green_mask; - u8 green_position; - u8 blue_mask; - u8 blue_position; - u8 reserved_mask; - u8 reserved_position; - u8 direct_color_attributes; - - u32 framebuffer; - u32 off_screen_mem_off; - u16 off_screen_mem_size; - u8 reserved1[206]; -}; - -struct vbe *vbe; -int vbe_width; -int vbe_height; -int vbe_bpl; -int vbe_pitch; -u8 *fb; - -void vesa_fill(const u32 color[3]); -void vesa_set_pixel(u16 x, u16 y, const u32 color[3]); -void vesa_init(struct vbe *info); - -#endif |