summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/interrupts.c20
-rw-r--r--kernel/kernel.c6
-rw-r--r--kernel/shell.c36
3 files changed, 57 insertions, 5 deletions
diff --git a/kernel/interrupts.c b/kernel/interrupts.c
index f5bd18f..56fa09f 100644
--- a/kernel/interrupts.c
+++ b/kernel/interrupts.c
@@ -9,6 +9,7 @@
void int_clock_handler();
void int_kb_handler();
+void int_syscall_handler();
void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr);
void int_default_handler();
void mouse_handler();
@@ -82,6 +83,22 @@ void int_irq16(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Coprocessor error");
void int_irq17(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Alignment Check"); X86_IRQ_END }
void int_irq18(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Machine Check"); X86_IRQ_END }
+//
+int example_syscall(int x,int y)
+{
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"example syscall called with %d + %d",x,y);
+ return x+y;
+
+}
+
+int example_syscall_2(int x,int y)
+{
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"example syscall 2 called with %d - %d",x,y);
+ return x-y;
+}
+
+//
+
//set a handler for a specific interrupt
void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr)
{
@@ -145,6 +162,9 @@ void int_init(uint16_t sel)
//mouse
int_install_ir(44, 0b10001110, 0x08,&mouse_handler);
+ //system calls
+ int_install_ir(0x80, 0b10001110, 0x08,&int_syscall_handler);
+
int_install();
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 04eaa50..811f4c1 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -30,7 +30,7 @@ void kernel_ap()
cpu_counter[p]++;
lock_spin(0);
- if(cpu_counter[p]%1000000==0)log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"cpu[%d] %d",p,cpu_counter[p]);
+ if(cpu_counter[p]%1000000==0)log(FOOLOS_MODULE_NAME,FOOLOS_LOG_DEBUG,"cpu[%d] %d",p,cpu_counter[p]);
lock_release(0);
}
}
@@ -116,7 +116,6 @@ void kernel_main(uint32_t initial_stack, int mp)
// mouse driver init (before interrupts)
mouse_init();
-
//
// Setup Interrupts (code segment: 0x08)
//
@@ -128,7 +127,6 @@ void kernel_main(uint32_t initial_stack, int mp)
//
smp_processors procdata;
- // try to find acpi tables
if(!acpi_find(&procdata))
if(!mp_find(&procdata))
panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!");
@@ -148,7 +146,6 @@ void kernel_main(uint32_t initial_stack, int mp)
// init spinlocks
init_spinlocks();
-
//
// Start the other Processors (also before paging for some reason!)
//
@@ -189,7 +186,6 @@ void kernel_main(uint32_t initial_stack, int mp)
//
shell_init();
-
//
// Initialize Multitasking
//
diff --git a/kernel/shell.c b/kernel/shell.c
index b377ce0..2e00bd0 100644
--- a/kernel/shell.c
+++ b/kernel/shell.c
@@ -82,6 +82,42 @@ void shell_execute()
{
// uint8_t *read= flpydsk_read_sector (10);
}
+ else if(1==strcmp(command,"SYSCALL",0))
+ {
+
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call 10");
+ uint32_t ebx; // will hold return value;
+ // system call
+ asm("pusha");
+ asm("mov $10,%eax"); // select syscall 10 (example_syscall)
+ asm("mov $666,%edx");
+ asm("mov $333,%ecx");
+ asm("int $0x80"); // actual syscall ! interrupt
+ asm("mov %%ebx, %0": "=b" (ebx));
+ asm("popa");
+ //
+
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call returned %d",ebx);
+
+ }
+ else if(1==strcmp(command,"TWO",0))
+ {
+
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call 20");
+ uint32_t ebx; // will hold return value;
+ // system call
+ asm("pusha");
+ asm("mov $20,%eax"); // select syscall2 20 (example_syscall)
+ asm("mov $566,%edx");
+ asm("mov $233,%ecx");
+ asm("int $0x80"); // actual syscall ! interrupt
+ asm("mov %%ebx, %0": "=b" (ebx));
+ asm("popa");
+ //
+
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"system call returned %d",ebx);
+
+ }
else
{
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"command unknown");