[core] Various fixes.

This commit is contained in:
Kevin Lange 2011-01-17 18:22:48 -06:00
parent 1fdddc482e
commit 04d1b192e8
6 changed files with 36 additions and 32 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ struct idt_entry {
struct idt_ptr {
unsigned short limit;
unsigned int base;
unsigned long base; /* int? */
} __attribute__((packed));
struct idt_entry idt[256];
@ -46,7 +46,7 @@ idt_set_gate(
void
idt_install() {
idtp.limit = (sizeof(struct idt_entry) * 256) - 1;
idtp.base = &idt;
idtp.base = (uintptr_t)&idt;
memset(&idt, 0, sizeof(struct idt_entry) * 256);
idt_load();

View File

@ -17,15 +17,12 @@ extern void _irq13();
extern void _irq14();
extern void _irq15();
void *irq_routines[16] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
static irq_handler_t irq_routines[16] = { NULL };
void
irq_install_handler(
int irq,
void *handler
irq_handler_t handler
) {
irq_routines[irq] = handler;
}

View File

@ -10,7 +10,7 @@ timer_phase(
outportb(0x40, divisor >> 8);
}
int timer_ticks = 0;
long timer_ticks = 0;
unsigned long ticker = 0;
void
@ -37,7 +37,7 @@ void
timer_wait(
int ticks
) {
unsigned long eticks;
eticks = timer_ticks + ticks;
long eticks;
eticks = (long)timer_ticks + (long)ticks;
while(timer_ticks < eticks);
}

View File

@ -1,9 +1,14 @@
#ifndef __SYSTEM_H
#define __SYSTEM_H
#define NULL ((void *)0UL)
typedef unsigned long uintptr_t;
typedef long size_t;
/* Kernel Main */
extern unsigned char *memcpy(unsigned char *dest, const unsigned char *src, int count);
extern unsigned char *memset(unsigned char *dest, unsigned char val, int count);
extern void *memcpy(void * restrict dest, const void * restrict src, size_t count);
extern void *memset(void *dest, int val, size_t count);
extern unsigned short *memsetw(unsigned short *dest, unsigned short val, int count);
extern int strlen(const char *str);
extern unsigned char inportb (unsigned short _port);
@ -32,17 +37,19 @@ struct regs {
unsigned int eip, cs, eflags, useresp, ss;
};
typedef void (*irq_handler_t)(struct regs *);
/* ISRS */
extern void isrs_install();
/* Interrupt Handlers */
extern void irq_install();
extern void irq_install_handler(int irq, void *handler);
extern void irq_install_handler(int irq, irq_handler_t);
extern void irq_uninstall_handler(int irq);
/* Timer */
extern void timer_install();
extern int timer_ticks;
extern long timer_ticks;
extern void timer_wait(int ticks);
/* Keyboard */

36
main.c
View File

@ -5,17 +5,17 @@
* Copy from source to destination. Assumes that
* source and destination are not overlapping.
*/
unsigned char *
void *
memcpy(
unsigned char *dest,
const unsigned char *src,
int count
void * restrict dest,
const void * restrict src,
size_t count
) {
int i;
i = 0;
for ( ; i < count; ++i ) {
dest[i] = src[i];
size_t i;
unsigned char *a = dest;
const unsigned char *b = src;
for ( i = 0; i < count; ++i ) {
a[i] = b[i];
}
return dest;
}
@ -24,18 +24,18 @@ memcpy(
* memset
* Set `count` bytes to `val`.
*/
unsigned char *
void *
memset(
unsigned char *dest,
unsigned char val,
int count
void *b,
int val,
size_t count
) {
int i;
i = 0;
for ( ; i < count; ++i ) {
dest[i] = val;
size_t i;
unsigned char * dest = b;
for ( i = 0; i < count; ++i ) {
dest[i] = (unsigned char)val;
}
return dest;
return b;
}
/*