summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boot/vesa_setup_16.asm35
-rw-r--r--kernel/kernel.c11
-rw-r--r--kernel/shell.c1
-rw-r--r--kernel/x86.c28
4 files changed, 64 insertions, 11 deletions
diff --git a/boot/vesa_setup_16.asm b/boot/vesa_setup_16.asm
index 62d8d46..25eba22 100644
--- a/boot/vesa_setup_16.asm
+++ b/boot/vesa_setup_16.asm
@@ -51,17 +51,30 @@ VesaSetup:
; call print_nextline
;preempt keyboard buffer
-; next_key:
-;
-; mov al,0
-; mov ah,1 ; block waiting for keyboard scancode
-;
-; int 0x16
-; cmp ax,0
-; jne next_key
-;
-; mov ah,0 ; block waiting for keyboard scancode
-; int 0x16
+
+ next_key:
+
+ mov ah,0x1 ;get scnacode from kb (non-blocking)
+ int 0x16
+ jnz get_key ; nothing to preempt
+
+ jmp wait_key
+
+ get_key:
+ mov ah,0 ;get key from buffer
+ int 0x16
+
+; mov al,ah
+; call print_hex_byte
+; call print_nextline
+
+ jmp next_key
+
+ ;;;;;;;;;;;;;;;;;
+ wait_key:
+ mov ah,0 ; block waiting for keyboard scancode
+ int 0x16
+
;VESA: finally switch to the mode of choice!
mov ax,0x4f02 ;vesa function: Set Mode
diff --git a/kernel/kernel.c b/kernel/kernel.c
index a9f8e54..533ff7c 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -130,13 +130,24 @@ void kernel_main(uint32_t initial_stack, int mp)
//
mem_init(0x7c00+1,*((uint16_t *)(0x7c00)));
+ // init spinlocks
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Initializing Spinlocks");
+
+ init_spinlocks();
+
+ lock_spin(0);
+
//
// Start the other Processors (also before paging !)
//
smp_log_procdata(&procdata);
+
+ lock_spin(0);
+
smp_start_aps(&procdata,0x80000); // starts at 0x90000
// but it will be copied over mbr
+
//
// Activate Virtual Memory (paging)
//
diff --git a/kernel/shell.c b/kernel/shell.c
index b377ce0..9767a58 100644
--- a/kernel/shell.c
+++ b/kernel/shell.c
@@ -85,6 +85,7 @@ void shell_execute()
else
{
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"command unknown");
+ lock_release(0);
}
pos=0;
diff --git a/kernel/x86.c b/kernel/x86.c
index 782baec..7775ab7 100644
--- a/kernel/x86.c
+++ b/kernel/x86.c
@@ -49,6 +49,10 @@ uint32_t x86_get_cr1()
return cr;
}
+void x86_mov(uint8_t val)
+{
+}
+
uint32_t x86_get_cr2()
{
uint32_t cr;
@@ -134,4 +138,28 @@ void x86_flush_tlb(uint32_t addr)
asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
}
+//xchg
+volatile uint8_t x86_xchg(volatile uint8_t *addr, uint8_t val)
+{
+ uint8_t result;
+
+ // test. because asm does not work !?
+ uint8_t oldval=*addr;
+ *addr=val;
+ return oldval;
+
+
+
+ // The + in "+m" denotes a read-modify-write operand.
+ asm volatile("lock xchg %0, %1" :
+ "+m" (*addr), "=a" (result) :
+ "1" (val) :
+ "cc");
+
+ //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"xchg val:%d with addr:0x%08X : result: %d",val,addr,result);
+//
+ return result;
+}
+
+