Import backup from 2006-01-02

This commit is contained in:
Josh Holtrop 2006-01-02 22:00:00 -05:00
parent 89d962e33a
commit 0aaf5db5ad
14 changed files with 164 additions and 67 deletions

View File

@ -1,5 +1,5 @@
all: all:
make -C hash make -C hash
nasm -f bin test1.asm -o test1.app nasm -f bin -l test1.lst test1.asm -o test1.app
nasm -f bin test2.asm -o test2.app nasm -f bin test2.asm -o test2.app

Binary file not shown.

View File

@ -10,8 +10,11 @@ org 0x0
; dd 0 ; reserved ; dd 0 ; reserved
start: start:
mov eax, 1 mov ebx, astring
mov ebx, 'h' mov eax, 2
int 0x30 int 0x30
jmp start jmp start
ret ret
astring:
db "Hello there from test1!", 10, 0

22
apps/test1.lst Normal file
View File

@ -0,0 +1,22 @@
1 ; test app 1
2
3 [bits 32]
4 org 0x0
5
6 ;header:
7 ; dd 0x4D534F48 ; magic identifier "HOSM"
8 ; dd 2 ; test app
9 ; dd start ; start address
10 ; dd 0 ; reserved
11
12 start:
13 00000000 BB[0F000000] mov ebx, astring
14 00000005 B802000000 mov eax, 2
15 0000000A CD30 int 0x30
16 0000000C EBF2 jmp start
17 0000000E C3 ret
18
19 astring:
20 0000000F 48656C6C6F20746865- db "Hello there from test1!", 10, 0
21 00000018 72652066726F6D2074-
22 00000021 65737431210A00

Binary file not shown.

View File

@ -22,7 +22,8 @@ LDFLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
OBJS=boot.o lang/lang_a.o \ OBJS=boot.o lang/lang_a.o \
kernel.o mm/mm.o mm/vmm.o lang/conv.o display/kout.o \ kernel.o mm/mm.o mm/vmm.o lang/conv.o display/kout.o \
display/display.o sys/pic.o char/keyboard.o lang/lang.o \ display/display.o sys/pic.o char/keyboard.o lang/lang.o \
sys/pci_classes.o proc/proc.o proc/hash.o \ sys/pci_classes.o syscall.o \
proc/proc.o proc/hash.o \
lang/string.o lang/new.o char/misc_char.o char/vconsole.o \ lang/string.o lang/new.o char/misc_char.o char/vconsole.o \
devices.o block/ramdisk.o fs/vfs.o fs/FileSystem.o fs/VFSMount.o \ devices.o block/ramdisk.o fs/vfs.o fs/FileSystem.o fs/VFSMount.o \
fs/ext2/ext2.o fs/sysfs/sysfs.o fs/sysfs/sysfs_entry.o \ fs/ext2/ext2.o fs/sysfs/sysfs.o fs/sysfs/sysfs_entry.o \
@ -31,7 +32,7 @@ OBJS=boot.o lang/lang_a.o \
fs/ext2/Ext2BlockCache.o fs/ext2/Ext2BlockCache.o
CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c \ CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c \
display/display.c sys/pic.c char/keyboard.c lang/lang.c \ display/display.c sys/pic.c char/keyboard.c lang/lang.c \
sys/pci_classes.c sys/pci_classes.c syscall.c
CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \ CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \
block/ramdisk.cpp devices.cpp fs/vfs.cpp fs/FileSystem.o fs/VFSMount.o\ block/ramdisk.cpp devices.cpp fs/vfs.cpp fs/FileSystem.o fs/VFSMount.o\
fs/ext2/ext2.cpp fs/sysfs/sysfs.cpp fs/sysfs/sysfs_entry.cpp \ fs/ext2/ext2.cpp fs/sysfs/sysfs.cpp fs/sysfs/sysfs_entry.cpp \
@ -95,13 +96,12 @@ block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h
devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h
devices.o: char/vconsole.h block/ramdisk.h devices.o: char/vconsole.h block/ramdisk.h
fs/vfs.o: hos_defines.h display/kout.h functions.h sys/io.h lang/lang.h fs/vfs.o: hos_defines.h display/kout.h functions.h sys/io.h lang/lang.h
fs/vfs.o: fs/vfs.h devices.h fs/FileSystem.h fs/OpenDirectory.h fs/OpenFile.h fs/vfs.o: fs/vfs.h devices.h fs/FileSystem.h fs/OpenDirectory.h lang/string.h
fs/vfs.o: lang/string.h fs/VFSMount.h fs/FileSystem.h fs/ext2/ext2.h fs/vfs.h fs/vfs.o: fs/OpenFile.h fs/VFSMount.h fs/FileSystem.h fs/ext2/ext2.h fs/vfs.h
fs/vfs.o: lang/vector.h fs/vfs.o: lang/vector.h
fs/ext2/ext2.o: display/kout.h hos_defines.h mm/vmm.h multiboot.h lang/lang.h fs/ext2/ext2.o: display/kout.h hos_defines.h mm/vmm.h multiboot.h lang/lang.h
fs/ext2/ext2.o: fs/ext2/ext2.h fs/vfs.h devices.h fs/ext2/Ext2OpenDirectory.h fs/ext2/ext2.o: fs/ext2/ext2.h fs/vfs.h devices.h fs/ext2/Ext2OpenDirectory.h
fs/ext2/ext2.o: fs/OpenDirectory.h fs/vfs.h fs/OpenFile.h lang/string.h fs/ext2/ext2.o: fs/ext2/Ext2BlockCache.h fs/ext2/Ext2OpenFile.h fs/OpenFile.h
fs/ext2/ext2.o: fs/ext2/Ext2OpenFile.h fs/OpenFile.h
fs/sysfs/sysfs.o: display/kout.h hos_defines.h fs/vfs.h devices.h fs/sysfs/sysfs.o: display/kout.h hos_defines.h fs/vfs.h devices.h
fs/sysfs/sysfs.o: fs/sysfs/sysfs.h fs/sysfs/sysfs_entry.h lang/vector.h fs/sysfs/sysfs.o: fs/sysfs/sysfs.h fs/sysfs/sysfs_entry.h lang/vector.h
fs/sysfs/sysfs.o: lang/string.h fs/sysfs/sysfs.o: lang/string.h
@ -115,8 +115,14 @@ proc/hash.o: hos_defines.h proc/hash.h lang/vector.h display/kout.h mm/vmm.h
proc/hash.o: multiboot.h proc/hash.o: multiboot.h
fs/OpenFile.o: fs/OpenFile.h hos_defines.h fs/OpenFile.o: fs/OpenFile.h hos_defines.h
fs/OpenDirectory.o: fs/vfs.h hos_defines.h devices.h fs/OpenDirectory.h fs/OpenDirectory.o: fs/vfs.h hos_defines.h devices.h fs/OpenDirectory.h
fs/OpenDirectory.o: fs/OpenFile.h lang/string.h fs/OpenDirectory.o: lang/string.h
fs/ext2/Ext2OpenDirectory.o: display/kout.h hos_defines.h lang/lang.h fs/ext2/Ext2OpenDirectory.o: lang/lang.h hos_defines.h fs/vfs.h devices.h
fs/ext2/Ext2OpenDirectory.o: fs/vfs.h devices.h fs/ext2/Ext2OpenDirectory.h fs/ext2/Ext2OpenDirectory.o: fs/ext2/Ext2OpenDirectory.h fs/ext2/ext2.h
fs/ext2/Ext2OpenDirectory.o: fs/OpenDirectory.h fs/vfs.h fs/OpenFile.h fs/ext2/Ext2OpenDirectory.o: fs/ext2/Ext2BlockCache.h fs/ext2/Ext2OpenFile.h
fs/ext2/Ext2OpenDirectory.o: lang/string.h fs/ext2/ext2.h fs/ext2/Ext2OpenDirectory.o: fs/OpenFile.h
fs/ext2/Ext2OpenFile.o: fs/ext2/Ext2OpenFile.h fs/ext2/ext2.h fs/vfs.h
fs/ext2/Ext2OpenFile.o: hos_defines.h devices.h fs/OpenFile.h
fs/ext2/Ext2OpenFile.o: fs/ext2/Ext2BlockCache.h lang/lang.h functions.h
fs/ext2/Ext2OpenFile.o: sys/io.h
fs/ext2/Ext2BlockCache.o: fs/vfs.h hos_defines.h devices.h
fs/ext2/Ext2BlockCache.o: fs/ext2/Ext2BlockCache.h fs/ext2/ext2.h

View File

@ -22,7 +22,8 @@ LDFLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
OBJS=boot.o lang/lang_a.o \ OBJS=boot.o lang/lang_a.o \
kernel.o mm/mm.o mm/vmm.o lang/conv.o display/kout.o \ kernel.o mm/mm.o mm/vmm.o lang/conv.o display/kout.o \
display/display.o sys/pic.o char/keyboard.o lang/lang.o \ display/display.o sys/pic.o char/keyboard.o lang/lang.o \
sys/pci_classes.o proc/proc.o proc/hash.o \ sys/pci_classes.o syscall.o \
proc/proc.o proc/hash.o \
lang/string.o lang/new.o char/misc_char.o char/vconsole.o \ lang/string.o lang/new.o char/misc_char.o char/vconsole.o \
devices.o block/ramdisk.o fs/vfs.o fs/FileSystem.o fs/VFSMount.o \ devices.o block/ramdisk.o fs/vfs.o fs/FileSystem.o fs/VFSMount.o \
fs/ext2/ext2.o fs/sysfs/sysfs.o fs/sysfs/sysfs_entry.o \ fs/ext2/ext2.o fs/sysfs/sysfs.o fs/sysfs/sysfs_entry.o \
@ -31,7 +32,7 @@ OBJS=boot.o lang/lang_a.o \
fs/ext2/Ext2BlockCache.o fs/ext2/Ext2BlockCache.o
CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c \ CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c \
display/display.c sys/pic.c char/keyboard.c lang/lang.c \ display/display.c sys/pic.c char/keyboard.c lang/lang.c \
sys/pci_classes.c sys/pci_classes.c syscall.c
CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \ CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \
block/ramdisk.cpp devices.cpp fs/vfs.cpp fs/FileSystem.o fs/VFSMount.o\ block/ramdisk.cpp devices.cpp fs/vfs.cpp fs/FileSystem.o fs/VFSMount.o\
fs/ext2/ext2.cpp fs/sysfs/sysfs.cpp fs/sysfs/sysfs_entry.cpp \ fs/ext2/ext2.cpp fs/sysfs/sysfs.cpp fs/sysfs/sysfs_entry.cpp \
@ -95,15 +96,16 @@ block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h
devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h
devices.o: char/vconsole.h block/ramdisk.h devices.o: char/vconsole.h block/ramdisk.h
fs/vfs.o: hos_defines.h display/kout.h functions.h sys/io.h lang/lang.h fs/vfs.o: hos_defines.h display/kout.h functions.h sys/io.h lang/lang.h
fs/vfs.o: fs/vfs.h devices.h lang/string.h lang/vector.h fs/FileSystem.h fs/vfs.o: fs/vfs.h devices.h fs/FileSystem.h fs/OpenDirectory.h fs/OpenFile.h
fs/vfs.o: fs/OpenFile.h fs/OpenDirectory.h fs/VFSMount.h fs/FileSystem.h fs/vfs.o: lang/string.h fs/VFSMount.h fs/FileSystem.h fs/ext2/ext2.h fs/vfs.h
fs/vfs.o: fs/vfs.h fs/ext2/ext2.h fs/vfs.o: lang/vector.h
fs/ext2/ext2.o: display/kout.h hos_defines.h mm/vmm.h multiboot.h lang/lang.h fs/ext2/ext2.o: display/kout.h hos_defines.h mm/vmm.h multiboot.h lang/lang.h
fs/ext2/ext2.o: fs/ext2/ext2.h fs/vfs.h devices.h fs/ext2/ext2.o: fs/ext2/ext2.h fs/vfs.h devices.h fs/ext2/Ext2OpenDirectory.h
fs/ext2/ext2.o: fs/OpenDirectory.h fs/vfs.h fs/OpenFile.h lang/string.h
fs/ext2/ext2.o: fs/ext2/Ext2OpenFile.h fs/OpenFile.h
fs/sysfs/sysfs.o: display/kout.h hos_defines.h fs/vfs.h devices.h fs/sysfs/sysfs.o: display/kout.h hos_defines.h fs/vfs.h devices.h
fs/sysfs/sysfs.o: fs/sysfs/sysfs.h fs/FileSystem.h fs/OpenFile.h fs/sysfs/sysfs.o: fs/sysfs/sysfs.h fs/sysfs/sysfs_entry.h lang/vector.h
fs/sysfs/sysfs.o: fs/OpenDirectory.h fs/vfs.h lang/string.h lang/vector.h fs/sysfs/sysfs.o: lang/string.h
fs/sysfs/sysfs.o: fs/VFSMount.h fs/FileSystem.h fs/sysfs/sysfs_entry.h
fs/sysfs/sysfs_entry.o: fs/sysfs/sysfs_entry.h lang/vector.h hos_defines.h fs/sysfs/sysfs_entry.o: fs/sysfs/sysfs_entry.h lang/vector.h hos_defines.h
fs/sysfs/sysfs_entry.o: lang/string.h fs/sysfs/sysfs_entry.o: lang/string.h
sys/pci.o: hos_defines.h display/kout.h sys/io.h sys/pci.h lang/vector.h sys/pci.o: hos_defines.h display/kout.h sys/io.h sys/pci.h lang/vector.h
@ -113,6 +115,9 @@ proc/proc.o: lang/vector.h
proc/hash.o: hos_defines.h proc/hash.h lang/vector.h display/kout.h mm/vmm.h proc/hash.o: hos_defines.h proc/hash.h lang/vector.h display/kout.h mm/vmm.h
proc/hash.o: multiboot.h proc/hash.o: multiboot.h
fs/OpenFile.o: fs/OpenFile.h hos_defines.h fs/OpenFile.o: fs/OpenFile.h hos_defines.h
fs/OpenDirectory.o: fs/OpenDirectory.h fs/vfs.h hos_defines.h devices.h fs/OpenDirectory.o: fs/vfs.h hos_defines.h devices.h fs/OpenDirectory.h
fs/OpenDirectory.o: lang/string.h lang/vector.h fs/FileSystem.h fs/OpenFile.h fs/OpenDirectory.o: fs/OpenFile.h lang/string.h
fs/OpenDirectory.o: fs/VFSMount.h fs/FileSystem.h fs/vfs.h fs/ext2/Ext2OpenDirectory.o: display/kout.h hos_defines.h lang/lang.h
fs/ext2/Ext2OpenDirectory.o: fs/vfs.h devices.h fs/ext2/Ext2OpenDirectory.h
fs/ext2/Ext2OpenDirectory.o: fs/OpenDirectory.h fs/vfs.h fs/OpenFile.h
fs/ext2/Ext2OpenDirectory.o: lang/string.h fs/ext2/ext2.h

View File

@ -1,7 +1,7 @@
;idt.inc ;idt.inc
;Author: Josh Holtrop ;Author: Josh Holtrop
;Date: 10/30/03 ;Date: 10/30/03
;Modified: 07/06/04 ;Modified: 01/02/06
idtr: idtr:
dw 50*8-1 ;size of idt dw 50*8-1 ;size of idt
@ -67,6 +67,23 @@ isr_label 48
isr_label 49 isr_label 49
isr_main: isr_main:
; ok, here, we need to duplicate the top item on the stack
; (the old eax) if the interrupt number is not 8 or 10-14
; this is to properly align the stack for both exceptions
; having and not having error codes
cmp eax, 8
jz isr_main_nodup ; if int=8, no dup
cmp eax, 10
jb isr_main_dup ; if int<10, dup
cmp eax, 14
jbe isr_main_nodup ; if int<=14, no dup
isr_main_dup: ; else dup
sub esp, 4
push eax
mov eax, [esp+8]
mov [esp+4], eax
pop eax
isr_main_nodup:
push ebx push ebx
push ecx push ecx
push edx push edx
@ -93,6 +110,7 @@ isr_main:
pop edx pop edx
pop ecx pop ecx
pop ebx pop ebx
add esp, 4 ;bypass error code
pop eax ;original saved eax pop eax ;original saved eax
iret iret

View File

@ -24,6 +24,7 @@
#include "fs/ext2/ext2.h" #include "fs/ext2/ext2.h"
#include "sys/pci.h" #include "sys/pci.h"
#include "proc/proc.h" #include "proc/proc.h"
#include "syscall.h"
mb_info_t mb_info_block; mb_info_t mb_info_block;
mb_mmap_t mb_mmap[MAX_MMAP]; mb_mmap_t mb_mmap[MAX_MMAP];
@ -38,6 +39,7 @@ u32_t timer; // number of IRQ 0's
extern u32_t mm_freepages; extern u32_t mm_freepages;
extern u32_t proc_new_esp; extern u32_t proc_new_esp;
extern u32_t cur_task;
/* This function runs in segmented memory - 0xC000_0000 is mapped to 0x0 but 0x0 /* This function runs in segmented memory - 0xC000_0000 is mapped to 0x0 but 0x0
itself is an invalid linear address. Therefore, the multiboot information addresses itself is an invalid linear address. Therefore, the multiboot information addresses
@ -151,35 +153,6 @@ void k_init()
} }
} }
char *buffer = kmalloc(2000);
void *ulab;
vfs_stat_t ulabstat;
vfs_stat("/ulab", &ulabstat);
ulab = vfs_open_file("/ulab", VFS_MODE_READ);
vfs_read_file_block(ulab, buffer, ulabstat.size);
for (i = 0; i < ulabstat.size; i++)
putc(buffer[i]);
kprintf("\n");
vfs_close_file(ulab);
ulab = vfs_open_file("/ulab", VFS_MODE_WRITE | VFS_MODE_APPEND);
vfs_write_file_block(ulab, "String!!!", 9);
vfs_write_file(ulab, 'H');
vfs_write_file_block(ulab, "String!!!", 9);
vfs_write_file(ulab, 'I');
vfs_write_file_block(ulab, "String!!!", 9);
vfs_write_file(ulab, '!');
vfs_write_file_block(ulab, "String!!!", 9);
vfs_close_file(ulab);
vfs_stat("/ulab", &ulabstat);
ulab = vfs_open_file("/ulab", VFS_MODE_READ);
vfs_read_file_block(ulab, buffer, ulabstat.size);
for (i = 0; i < ulabstat.size; i++)
putc(buffer[i]);
kprintf("\n");
vfs_close_file(ulab);
void *root = vfs_open_dir("///"); void *root = vfs_open_dir("///");
char name[VFS_MAX_PATH_LENGTH]; char name[VFS_MAX_PATH_LENGTH];
@ -224,7 +197,7 @@ void k_init()
kprintf("Error: Could not open directory\n"); kprintf("Error: Could not open directory\n");
/* Create the initial task */ /* Create the initial task */
/* vfs_stat_t stat; vfs_stat_t stat;
if (!vfs_stat(HOS_INIT_TASK, &stat)) if (!vfs_stat(HOS_INIT_TASK, &stat))
{ {
if (stat.permissions & if (stat.permissions &
@ -237,7 +210,7 @@ void k_init()
create_task(buf, stat.size, 0, 0); create_task(buf, stat.size, 0, 0);
} }
} }
*/
criticalCounter--; criticalCounter--;
} }
@ -246,6 +219,9 @@ void isr(u32_t num, int_stack_t *int_stack)
criticalCounter++; criticalCounter++;
switch (num) switch (num)
{ {
case 0x0: /* divide by zero */
kprintf("divide by zero, current process: %u\n", cur_task);
break;
case 0x20: // timer case 0x20: // timer
timer++; timer++;
(*(u16_t *)CONSOLE_MEMORY)++; (*(u16_t *)CONSOLE_MEMORY)++;
@ -257,9 +233,29 @@ void isr(u32_t num, int_stack_t *int_stack)
pic_eoi(); pic_eoi();
break; break;
case 0x30: case 0x30:
if (int_stack->eax == 1) syscall(cur_task, int_stack);
putc(int_stack->ebx);
break; break;
case 0x0D: /* general protection (error code) */
kprintf("General protection fault process %u, error #%u\n", cur_task, int_stack->error);
break;
case 0x0E: /* Page fault (error code) */
kprintf("Page fault process %u, error #%u\n", cur_task, int_stack->error);
break;
case 0x01: /* debug exception */
case 0x02: /* non-maskable interrupt */
case 0x03: /* breakpoint */
case 0x04: /* overflow */
case 0x05: /* bound exception */
case 0x06: /* invalid opcode */
case 0x07: /* FPU not available */
case 0x08: /* Double fault (error code) */
case 0x09: /* coprocessor segment overrun */
case 0x0A: /* invalid TSS (error code) */
case 0x0B: /* segment not present (error code) */
case 0x0C: /* stack exception (error code) */
case 0x10: /* floating point error */
case 0x11: /* alignment check */
case 0x12: /* machine check */
default: default:
kprintf("Unhandled interrupt #%d, CR2 = 0x%x, int_stack at 0x%x!\n", num, read_cr2(), int_stack); kprintf("Unhandled interrupt #%d, CR2 = 0x%x, int_stack at 0x%x!\n", num, read_cr2(), int_stack);
halt(); halt();

View File

@ -32,11 +32,12 @@ typedef struct
u32_t ecx; u32_t ecx;
u32_t ebx; u32_t ebx;
u32_t eax; u32_t eax;
u32_t eip;
u32_t error; /* valid on exceptions 8, 10-14 */
u32_t eip;
u32_t cs; u32_t cs;
u32_t eflags; u32_t eflags;
u32_t esp; /* present if ring3->ring0 transition ?? */ u32_t esp; /* present if privilege transition */
u32_t ss; u32_t ss;
} int_stack_t; } int_stack_t;

View File

@ -22,11 +22,11 @@ extern u32_t mm_freepages;
#include "proc/hash.h" #include "proc/hash.h"
extern "C" { extern "C" {
u32_t cur_task = 0; u32_t cur_task = 0; /* PID of currently executing process */
u32_t n_processes = 0; u32_t n_processes = 0; /* total number of processes */
tss_t tss0; tss_t tss0;
u32_t pid_base = 1024; u32_t pid_base = 1024;
u32_t pid_index = 0; u32_t pid_index = 0; /* index of running process in 'pids' vector */
} }
hash *processes; hash *processes;
@ -48,6 +48,11 @@ int proc_init()
return 0; return 0;
} }
process_t *proc_get_struct(u32_t pid)
{
return (process_t *) processes->get(pid);
}
void proc_sched(int_stack_t *int_stack) void proc_sched(int_stack_t *int_stack)
{ {
u32_t new_pid_index = (pid_index + 1) % pids->size(); u32_t new_pid_index = (pid_index + 1) % pids->size();
@ -146,7 +151,7 @@ void create_process_stack(process_t *p, void *entry)
p->int_stack.fs = SEG_USER_DATA | 0x3; p->int_stack.fs = SEG_USER_DATA | 0x3;
p->int_stack.gs = SEG_USER_DATA | 0x3; p->int_stack.gs = SEG_USER_DATA | 0x3;
p->int_stack.ss = SEG_USER_DATA | 0x3; p->int_stack.ss = SEG_USER_DATA | 0x3;
p->int_stack.esp = 0x20000000; p->int_stack.esp = 0x80000000; /* esp at 2GB */
p->int_stack.eflags = 0x0202; p->int_stack.eflags = 0x0202;
p->int_stack.cs = SEG_USER_CODE | 0x3; p->int_stack.cs = SEG_USER_CODE | 0x3;
p->int_stack.eip = (u32_t)entry; p->int_stack.eip = (u32_t)entry;

View File

@ -68,6 +68,8 @@ typedef struct
} __attribute__((packed)) tss_t; } __attribute__((packed)) tss_t;
int proc_init(); int proc_init();
process_t *proc_get_struct(u32_t pid);
void proc_sched(int_stack_t *int_stack); void proc_sched(int_stack_t *int_stack);
u32_t get_pid(); u32_t get_pid();
void switch_task(int_stack_t *int_stack, u32_t new_task); void switch_task(int_stack_t *int_stack, u32_t new_task);

25
kernel/syscall.c Normal file
View File

@ -0,0 +1,25 @@
// syscall.c
// Author: Josh Holtrop
// Date; 01/02/06
// Modified: 01/02/06
#include "syscall.h"
#include "display/kout.h"
#include "proc/proc.h"
void syscall(u32_t cur_task, int_stack_t *int_stack)
{
static u32_t times = 0;
process_t *proc = proc_get_struct(cur_task);
switch (int_stack->eax)
{
case 1:
times++;
kprintf("\033[sTimes Called: %d\033[u", times);
break;
case 2:
kprintf("%s", int_stack->ebx);
break;
}
}

14
kernel/syscall.h Normal file
View File

@ -0,0 +1,14 @@
// syscall.h
// Author: Josh Holtrop
// Date; 01/02/06
// Modified: 01/02/06
#ifndef __HOS_SYSCALL_H__
#define __HOS_SYSCALL_H__ __HOS_SYSCALL_H__
#include "hos_defines.h"
#include "kernel.h"
void syscall(u32_t cur_task, int_stack_t *int_stack);
#endif