From: John Hodge Date: Thu, 19 Sep 2013 04:30:57 +0000 (+0800) Subject: Kernel - Fixed compilation of x86_64 and armv7 X-Git-Tag: rel0.15~200 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=60088c0ff18ee5fe5050e65c6c1cb5eb539f6c04;p=tpg%2Facess2.git Kernel - Fixed compilation of x86_64 and armv7 --- diff --git a/KernelLand/Kernel/arch/armv6/proc.S b/KernelLand/Kernel/arch/armv6/proc.S index 19790583..6287314c 100644 --- a/KernelLand/Kernel/arch/armv6/proc.S +++ b/KernelLand/Kernel/arch/armv6/proc.S @@ -95,6 +95,16 @@ Proc_int_DropToUser: cps #16 mov sp, r1 mov pc, r0 +.globl User_Signal_Kill +@ R0: Signal +User_Signal_Kill: + mov r1, r0 + and r1, 0x00FF + or r1, 0x0200 + mov r0, 0 + swi 0 + b . + .section .rodata csProc_CloneInt_NewTaskMessage: diff --git a/KernelLand/Kernel/arch/armv7/proc.S b/KernelLand/Kernel/arch/armv7/proc.S index 19790583..d7cc2c25 100644 --- a/KernelLand/Kernel/arch/armv7/proc.S +++ b/KernelLand/Kernel/arch/armv7/proc.S @@ -95,6 +95,15 @@ Proc_int_DropToUser: cps #16 mov sp, r1 mov pc, r0 +.globl User_Signal_Kill +@ R0: Signal +User_Signal_Kill: + mov r1, r0 + and r1, #0x00FF + orr r1, #0x0200 + mov r0, #0 + swi 0 + b . .section .rodata csProc_CloneInt_NewTaskMessage: diff --git a/KernelLand/Kernel/arch/x86_64/proc.asm b/KernelLand/Kernel/arch/x86_64/proc.asm index f3b3a28a..aff670ac 100644 --- a/KernelLand/Kernel/arch/x86_64/proc.asm +++ b/KernelLand/Kernel/arch/x86_64/proc.asm @@ -147,4 +147,15 @@ Proc_RestoreSSE: fxrstor [rdi] ret +[section .usertext] + +[global User_Signal_Kill] +User_Signal_Kill: + xor rax, rax + mov bx, di + mov bh, 0x02 + int 0xAC + jmp $ + + ; vim: ft=nasm diff --git a/KernelLand/Kernel/arch/x86_64/time.c b/KernelLand/Kernel/arch/x86_64/time.c index 03c889fe..fabd9286 100644 --- a/KernelLand/Kernel/arch/x86_64/time.c +++ b/KernelLand/Kernel/arch/x86_64/time.c @@ -5,12 +5,14 @@ */ #include #include +#include // === MACROS === #define TIMER_QUANTUM 100 #define TIMER_FREQ PIT_TIMER_BASE_N/(PIT_TIMER_BASE_D*PIT_TIMER_DIVISOR) #define MS_PER_TICK_WHOLE (1000*(PIT_TIMER_BASE_D*PIT_TIMER_DIVISOR)/PIT_TIMER_BASE_N) #define MS_PER_TICK_FRACT ((0x80000000ULL*1000ULL*PIT_TIMER_BASE_D*PIT_TIMER_DIVISOR/PIT_TIMER_BASE_N)&0x7FFFFFFF) +#define US_PER_TICK (1000*1000/(TIMER_FREQ)) // === IMPORTS === extern volatile Sint64 giTimestamp; @@ -103,6 +105,21 @@ void Time_TimerThread(void) } #endif +void Time_MicroSleep(Uint16 Microsecs) // max 64 ms +{ + Uint64 cur_tsc = Time_ReadTSC(); + // tsc_per_us * Microsec + Uint64 delta_tsc = (Uint64)Microsecs * giTime_TSCPerTick / US_PER_TICK; + Uint64 tgt_tsc = cur_tsc + delta_tsc; + + if( tgt_tsc < cur_tsc ) + while(Time_ReadTSC() > cur_tsc) + ; + + while( Time_ReadTSC() < tgt_tsc ) + ; +} + Uint64 Time_ReadTSC(void) { Uint32 a, d;