Skip to content

Commit

Permalink
cleaned up all includes, and removed shitty code
Browse files Browse the repository at this point in the history
  • Loading branch information
tmathmeyer committed Jan 21, 2018
1 parent 5f012cb commit b933038
Show file tree
Hide file tree
Showing 50 changed files with 334 additions and 901 deletions.
22 changes: 2 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This stuff is all for building the kernel itself
#
######
kernel_flags := -nostdinc -Isrc/include -fno-stack-protector -m64 -g
kernel_flags := -nostdinc -Iinclude -fno-stack-protector -m64 -g
arch ?= x86_64

BUILD := build
Expand Down Expand Up @@ -53,22 +53,4 @@ $(ISO): $(KERNEL) $(GRUB_CFG)
@echo grub-mkrescue -o $(ISO)

clean:
rm -rf build










#####
#
# This stuff is for building the fuse system
#
#####
fuse: src/fs/shittyfs.c src/include/shittyfs.h
mkdir -p $(BUILD)
gcc -DSTDLIB src/fs/shittyfs.c -o $(BUILD)/fuse
rm -rf build
11 changes: 2 additions & 9 deletions src/include/kio.h → include/arch/io.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef kio_h
#define kio_h

#include "ktype.h"
#include <std/int.h>

static inline void outb(uint16_t port, uint8_t val){
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(port) );
Expand Down Expand Up @@ -37,11 +37,4 @@ static inline uint32_t inl(uint16_t port) {
return ret;
}

int strncmp(char *a, char *b, size_t len);
uint64_t hex2int(char *x);
uint32_t backspace();
char *strfnd(char *, char);
void force_char(char, uint8_t, uint16_t, uint16_t);
void force_simple_string(char *, uint8_t, uint16_t, uint16_t);
uint32_t write_string(char *, uint8_t);
#endif
#endif
2 changes: 1 addition & 1 deletion src/include/lock.h → include/arch/lock.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef lock_h
#define lock_h

#include "ktype.h"
#include <std/int.h>

typedef int lock_t;

Expand Down
16 changes: 16 additions & 0 deletions include/arch/misc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* yeah, this is a _really_ bad file name */

#ifndef misc_h
#define misc_h

#define PAGE 1
#define FRAME 0

#define min(x, y) (((x)>(y))?(y):(x))
#define max(a, b) (((a)>(b))?(a):(b))


void wait(void);


#endif
4 changes: 2 additions & 2 deletions src/include/registers.h → include/arch/registers.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "libk.h"

#ifndef registers_h
#define registers_h

#include <std/int.h>

uint16_t cs();
uint64_t rip(void);

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/include/multiboot.h → include/kernel/multiboot.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef multiboot_h
#define multiboot_h

#include "libk.h"
#include <std/int.h>

#define ELF_TAG_TYPE 0x09
#define MMAP_TAG_TYPE 0x06
Expand Down
3 changes: 3 additions & 0 deletions src/include/alloc.h → include/mem/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ void *kmalloc_init(void);
void *kmalloc(uint64_t);
void kfree(void *_ptr);

void *memset(void *p, int b, size_t n);
void *memcpy(void *dest, void *src, size_t bytes);

#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef chunk_allocator_h
#define chunk_allocator_h

#include "ktype.h"
#include <std/int.h>

struct segment_list {
uint8_t allocated : 1;
Expand Down
3 changes: 2 additions & 1 deletion src/include/mmu.h → include/mmu/mmu.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef mmu_h
#define mmu_h

#include <multiboot.h>
#include <std/int.h>
#include <kernel/multiboot.h>

#define PAGE_SIZE 4096
#define PAGE_ENTRIES 512
Expand Down
2 changes: 1 addition & 1 deletion src/include/ata.h → include/pci/ata.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef ata_h
#define ata_h

#include <ktype.h>
#include <std/int.h>

#define ATA_REG_ALTSTATUS 0x0C
#define ATA_REG_HDDEVSEL 0x06
Expand Down
2 changes: 1 addition & 1 deletion src/include/pci.h → include/pci/pci.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef pci_h
#define pci_h

#include "ktype.h"
#include <std/int.h>

#define PCI_ADDRESS_PORT 0xCF8
#define PCI_VALUE_PORT 0xCFC
Expand Down
2 changes: 1 addition & 1 deletion src/include/interrupts.h → include/pic/interrupts.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef interrupts_h
#define interrupts_h

#include "ktype.h"
#include <std/int.h>

#define PIC1 0x20 // Master PIC
#define PIC2 0xA0 // Slave PIC
Expand Down
2 changes: 1 addition & 1 deletion src/include/keyboard.h → include/pic/keyboard.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef keyboard_h
#define keyboard_h

#include "ktype.h"
#include <std/int.h>

#define KR_size 128
#define KEYBOARD_STATUS_PORT 0x64
Expand Down
4 changes: 1 addition & 3 deletions src/include/timer.h → include/pic/timer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef timer_h
#define timer_h

#include "ktype.h"
#include <std/int.h>

#define PIT_CH0 0x40
#define PIT_CH1 0x41
Expand Down Expand Up @@ -34,6 +34,4 @@ union {

void init_timer();



#endif
56 changes: 16 additions & 40 deletions src/include/libk.h → include/shell/shell.h
Original file line number Diff line number Diff line change
@@ -1,46 +1,22 @@
#ifndef libk_h
#define libk_h

#include "ktype.h"

#define ROWS 25
#define COLS 80
#define VIDB 2

#define PAGE 1
#define FRAME 0

enum vga_color {
COLOR_BLACK = 0,
COLOR_BLUE = 1,
COLOR_GREEN = 2,
COLOR_CYAN = 3,
COLOR_RED = 4,
COLOR_MAGENTA = 5,
COLOR_BROWN = 6,
COLOR_LIGHT_GREY = 7,
COLOR_DARK_GREY = 8,
COLOR_LIGHT_BLUE = 9,
COLOR_LIGHT_GREEN = 10,
COLOR_LIGHT_CYAN = 11,
COLOR_LIGHT_RED = 12,
COLOR_LIGHT_MAGENTA = 13,
COLOR_LIGHT_BROWN = 14,
COLOR_WHITE = 15,
};

#define min(x, y) (((x)>(y))?(y):(x))
#define max(a, b) (((a)>(b))?(a):(b))

void *memset(void *p, int b, size_t n);
void *memcpy(void *dest, void *src, size_t bytes);
uint64_t strlen(char *c);
#ifndef kshell_h
#define kshell_h

#include <std/int.h>

#define RDL_SIZE 256

void kshell(unsigned char key);
int strncmp(char *a, char *b, size_t len);
uint64_t hex2int(char *x);
uint32_t backspace();
char *strfnd(char *, char);
void force_char(char, uint8_t, uint16_t, uint16_t);
void force_simple_string(char *, uint8_t, uint16_t, uint16_t);
uint32_t write_string(char *, uint8_t);

uint64_t stringlen(char *);


void wait(void);
void kio_init(void);
void clear_screen(void);
#define sprintf(...) _sprintf (0,0,0,0,0,0,0,0,0,0,__VA_ARGS__)
uint32_t _sprintf(int,int,int,int,int,int,int,int,int,int, char *dest, const char fmt[], ...);
#define kprintf(...) _kprintf (0,0,0,0,0,0,0,0,0,0,__VA_ARGS__)
Expand Down
33 changes: 33 additions & 0 deletions include/shell/tty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef tty_h
#define tty_h

#include <std/int.h>

#define ROWS 25
#define COLS 80
#define VIDB 2

enum vga_color {
COLOR_BLACK = 0,
COLOR_BLUE = 1,
COLOR_GREEN = 2,
COLOR_CYAN = 3,
COLOR_RED = 4,
COLOR_MAGENTA = 5,
COLOR_BROWN = 6,
COLOR_LIGHT_GREY = 7,
COLOR_DARK_GREY = 8,
COLOR_LIGHT_BLUE = 9,
COLOR_LIGHT_GREEN = 10,
COLOR_LIGHT_CYAN = 11,
COLOR_LIGHT_RED = 12,
COLOR_LIGHT_MAGENTA = 13,
COLOR_LIGHT_BROWN = 14,
COLOR_WHITE = 15,
};

void clear_screen(void);

void kio_init(void);

#endif
File renamed without changes.
14 changes: 14 additions & 0 deletions include/std/string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef string_h
#define string_h

#include <std/int.h>

int strncmp(char *, char *, size_t);
char *strfnd(char *, char);
uint64_t hex2int(char *);
uint64_t strlen(char *);
void *memcpy(void *, void *, size_t);
void *memset(void *, int b, size_t);
char hexr(char);

#endif
6 changes: 4 additions & 2 deletions src/alloc/alloc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <ktype.h>
#include <mmu.h>
#include <std/int.h>
#include <mmu/mmu.h>
#include <std/string.h>
#include <shell/shell.h>

typedef struct huge_alloc_info_s {
uint64_t starting_page;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lock.c → src/arch/lock.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "lock.h"
#include <arch/lock.h>

bool try_lock(lock_t *p) {
if (__sync_bool_compare_and_swap(p, 0, 1)) {
Expand Down
5 changes: 5 additions & 0 deletions src/arch/misc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <arch/misc.h>

void wait(void) {
for(int i=0;i<10000000;i++);
}
4 changes: 2 additions & 2 deletions src/lib/registers.c → src/arch/registers.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "libk.h"
#include "registers.h"
#include <std/int.h>
#include <arch/registers.h>

inline uint16_t cs(void) {
uint16_t val;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/time.c → src/arch/time.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "libk.h"
#include <shell/shell.h>
#include <arch/time.h>

#define outb_p(value,port) \
__asm__ ("outb %%al,%%dx\n" \
Expand Down
Empty file removed src/fs/dsfs/fs.c
Empty file.
Loading

0 comments on commit b933038

Please sign in to comment.