Skip to content

Commit

Permalink
Cleaning up bkerndev code
Browse files Browse the repository at this point in the history
  • Loading branch information
enkiv2 committed Jul 13, 2011
1 parent ae56386 commit 6c55e75
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 63 deletions.
29 changes: 29 additions & 0 deletions include/gdt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef gdt_h
#define gdt_h

/* This defines what the stack looks like after an ISR was running */
struct regs {
unsigned int gs, fs, es, ds;
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
unsigned int int_no, err_code;
unsigned int eip, cs, eflags, useresp, ss;
};

// from gdt.c
extern void gdt_set_gate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran);
extern void gdt_install();

// from idt.c
extern void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
extern void idt_install();

// from isrs.c
extern void isrs_install();

// from irq.c
extern void irq_install_handler(int irq, void (*handler)(struct regs *r));
extern void irq_uninstall_handler(int irq);
extern void irq_install();


#endif
8 changes: 4 additions & 4 deletions include/kb.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ void handle_kb();
extern unsigned char* kbcmd_trans;
extern char kb_buf;
extern char kb_cmd;
extern void keyboard_install();
#endif // not kb.c

#ifdef kb_c
char caps;
char mode;
char kb_buf;
char kb_cmd;
#ifdef user_kb
void keyboard_install();
#ifdef USER_KB

/* write your own keymapping and use the same names */

#endif

#ifndef user_kb
#else
unsigned char kbd[128] = {
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
'9', '0', '-', '=', '\b', /* Backspace */
Expand Down
60 changes: 4 additions & 56 deletions include/system.h
Original file line number Diff line number Diff line change
@@ -1,65 +1,13 @@
/* bkerndev - Bran's Kernel Development Tutorial
* By: Brandon F. ([email protected])
* Desc: Global function declarations and type definitions
*
* Notes: No warranty expressed or implied. Use at own risk. */
#ifndef __SYSTEM_H
#define __SYSTEM_H

#include "kernel_assert.h"
#include "vga.h"
#include "zz.h"
#include "io.h"


typedef int size_t;

/* This defines what the stack looks like after an ISR was running */
struct regs {
unsigned int gs, fs, es, ds;
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
unsigned int int_no, err_code;
unsigned int eip, cs, eflags, useresp, ss;
};

// from util.c
extern void *memcpy(void *dest, const void *src, size_t count);
extern void *memset(void *dest, char val, size_t count);
extern unsigned short *memsetw(unsigned short *dest, unsigned short val, size_t count);
extern size_t strlen(const char *str);
extern int pow(int, int);
extern char* itoa(int, char*);
extern char* padl(int, char*, char);

// from gdt.c
extern void gdt_set_gate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran);
extern void gdt_install();

// from idt.c
extern void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
extern void idt_install();

// from isrs.c
extern void isrs_install();

// from irq.c
extern void irq_install_handler(int irq, void (*handler)(struct regs *r));
extern void irq_uninstall_handler(int irq);
extern void irq_install();

// from timer.c
extern void timer_wait(int ticks);
extern void timer_install();
extern void displaytime();
extern int request_atomicity(int);
extern void yield();
extern int spawn(void(*fn)(int));
extern int fork();
extern void kill(int);
extern int renice(int, int);
#define MAX_PROCESSES 512

// from kb.c
extern void keyboard_install();
#include "kb.h"
#include "timer.h"
#include "util.h"
#include "gdt.h"

#endif
14 changes: 14 additions & 0 deletions include/timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef timer_h
#define timer_h
extern void timer_wait(int ticks);
extern void timer_install();
extern void displaytime();
extern int request_atomicity(int);
extern void yield();
extern int spawn(void(*fn)(int));
extern int fork();
extern void kill(int);
extern int renice(int, int);
#define MAX_PROCESSES 512
#endif

14 changes: 14 additions & 0 deletions include/util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef util_h
#define util_h

typedef int size_t;

extern void *memcpy(void *dest, const void *src, size_t count);
extern void *memset(void *dest, char val, size_t count);
extern unsigned short *memsetw(unsigned short *dest, unsigned short val, size_t count);
extern size_t strlen(const char *str);
extern int pow(int, int);
extern char* itoa(int, char*);
extern char* padl(int, char*, char);

#endif
1 change: 0 additions & 1 deletion include/vga.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ typedef struct vgapair_t {
char attr;
} vgapair;

//typedef vgapair[VGAX][VGAY] vgascreen;
#ifdef vga_c
vgapair*** screen=(vgapair***)VGAADDR;
int cursorx;
Expand Down
4 changes: 2 additions & 2 deletions src/kb.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <system.h>
#define kb_c
#include "kb.h"
#undef USER_KB
#include "system.h"


/* Handles the keyboard interrupt */
Expand Down

0 comments on commit 6c55e75

Please sign in to comment.