[core] Various fixes.
This commit is contained in:
parent
1fdddc482e
commit
04d1b192e8
BIN
bootdisk.img
BIN
bootdisk.img
Binary file not shown.
@ -13,7 +13,7 @@ struct idt_entry {
|
|||||||
|
|
||||||
struct idt_ptr {
|
struct idt_ptr {
|
||||||
unsigned short limit;
|
unsigned short limit;
|
||||||
unsigned int base;
|
unsigned long base; /* int? */
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct idt_entry idt[256];
|
struct idt_entry idt[256];
|
||||||
@ -46,7 +46,7 @@ idt_set_gate(
|
|||||||
void
|
void
|
||||||
idt_install() {
|
idt_install() {
|
||||||
idtp.limit = (sizeof(struct idt_entry) * 256) - 1;
|
idtp.limit = (sizeof(struct idt_entry) * 256) - 1;
|
||||||
idtp.base = &idt;
|
idtp.base = (uintptr_t)&idt;
|
||||||
memset(&idt, 0, sizeof(struct idt_entry) * 256);
|
memset(&idt, 0, sizeof(struct idt_entry) * 256);
|
||||||
|
|
||||||
idt_load();
|
idt_load();
|
||||||
|
@ -17,15 +17,12 @@ extern void _irq13();
|
|||||||
extern void _irq14();
|
extern void _irq14();
|
||||||
extern void _irq15();
|
extern void _irq15();
|
||||||
|
|
||||||
void *irq_routines[16] = {
|
static irq_handler_t irq_routines[16] = { NULL };
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
irq_install_handler(
|
irq_install_handler(
|
||||||
int irq,
|
int irq,
|
||||||
void *handler
|
irq_handler_t handler
|
||||||
) {
|
) {
|
||||||
irq_routines[irq] = handler;
|
irq_routines[irq] = handler;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ timer_phase(
|
|||||||
outportb(0x40, divisor >> 8);
|
outportb(0x40, divisor >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
int timer_ticks = 0;
|
long timer_ticks = 0;
|
||||||
unsigned long ticker = 0;
|
unsigned long ticker = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -37,7 +37,7 @@ void
|
|||||||
timer_wait(
|
timer_wait(
|
||||||
int ticks
|
int ticks
|
||||||
) {
|
) {
|
||||||
unsigned long eticks;
|
long eticks;
|
||||||
eticks = timer_ticks + ticks;
|
eticks = (long)timer_ticks + (long)ticks;
|
||||||
while(timer_ticks < eticks);
|
while(timer_ticks < eticks);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
#ifndef __SYSTEM_H
|
#ifndef __SYSTEM_H
|
||||||
#define __SYSTEM_H
|
#define __SYSTEM_H
|
||||||
|
|
||||||
|
#define NULL ((void *)0UL)
|
||||||
|
|
||||||
|
typedef unsigned long uintptr_t;
|
||||||
|
typedef long size_t;
|
||||||
|
|
||||||
/* Kernel Main */
|
/* Kernel Main */
|
||||||
extern unsigned char *memcpy(unsigned char *dest, const unsigned char *src, int count);
|
extern void *memcpy(void * restrict dest, const void * restrict src, size_t count);
|
||||||
extern unsigned char *memset(unsigned char *dest, unsigned char val, int count);
|
extern void *memset(void *dest, int val, size_t count);
|
||||||
extern unsigned short *memsetw(unsigned short *dest, unsigned short val, int count);
|
extern unsigned short *memsetw(unsigned short *dest, unsigned short val, int count);
|
||||||
extern int strlen(const char *str);
|
extern int strlen(const char *str);
|
||||||
extern unsigned char inportb (unsigned short _port);
|
extern unsigned char inportb (unsigned short _port);
|
||||||
@ -32,17 +37,19 @@ struct regs {
|
|||||||
unsigned int eip, cs, eflags, useresp, ss;
|
unsigned int eip, cs, eflags, useresp, ss;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*irq_handler_t)(struct regs *);
|
||||||
|
|
||||||
/* ISRS */
|
/* ISRS */
|
||||||
extern void isrs_install();
|
extern void isrs_install();
|
||||||
|
|
||||||
/* Interrupt Handlers */
|
/* Interrupt Handlers */
|
||||||
extern void irq_install();
|
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);
|
extern void irq_uninstall_handler(int irq);
|
||||||
|
|
||||||
/* Timer */
|
/* Timer */
|
||||||
extern void timer_install();
|
extern void timer_install();
|
||||||
extern int timer_ticks;
|
extern long timer_ticks;
|
||||||
extern void timer_wait(int ticks);
|
extern void timer_wait(int ticks);
|
||||||
|
|
||||||
/* Keyboard */
|
/* Keyboard */
|
||||||
|
36
main.c
36
main.c
@ -5,17 +5,17 @@
|
|||||||
* Copy from source to destination. Assumes that
|
* Copy from source to destination. Assumes that
|
||||||
* source and destination are not overlapping.
|
* source and destination are not overlapping.
|
||||||
*/
|
*/
|
||||||
unsigned char *
|
void *
|
||||||
memcpy(
|
memcpy(
|
||||||
unsigned char *dest,
|
void * restrict dest,
|
||||||
const unsigned char *src,
|
const void * restrict src,
|
||||||
int count
|
size_t count
|
||||||
) {
|
) {
|
||||||
int i;
|
size_t i;
|
||||||
i = 0;
|
unsigned char *a = dest;
|
||||||
for ( ; i < count; ++i ) {
|
const unsigned char *b = src;
|
||||||
dest[i] = src[i];
|
for ( i = 0; i < count; ++i ) {
|
||||||
|
a[i] = b[i];
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
@ -24,18 +24,18 @@ memcpy(
|
|||||||
* memset
|
* memset
|
||||||
* Set `count` bytes to `val`.
|
* Set `count` bytes to `val`.
|
||||||
*/
|
*/
|
||||||
unsigned char *
|
void *
|
||||||
memset(
|
memset(
|
||||||
unsigned char *dest,
|
void *b,
|
||||||
unsigned char val,
|
int val,
|
||||||
int count
|
size_t count
|
||||||
) {
|
) {
|
||||||
int i;
|
size_t i;
|
||||||
i = 0;
|
unsigned char * dest = b;
|
||||||
for ( ; i < count; ++i ) {
|
for ( i = 0; i < count; ++i ) {
|
||||||
dest[i] = val;
|
dest[i] = (unsigned char)val;
|
||||||
}
|
}
|
||||||
return dest;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user