Subversion Repositories HelenOS-historic

Rev

Rev 803 | Rev 955 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 803 Rev 806
Line 32... Line 32...
32
#include <arch/cpu.h>
32
#include <arch/cpu.h>
33
#include <arch/pm.h>
33
#include <arch/pm.h>
34
#include <arch/asm.h>
34
#include <arch/asm.h>
35
 
35
 
36
#include <print.h>
36
#include <print.h>
-
 
37
#include <arch/cpu.h>
37
 
38
 
38
extern void syscall_entry(void);
39
extern void syscall_entry(void);
39
 
40
 
40
/** Enable & setup support for SYSCALL/SYSRET */
41
/** Enable & setup support for SYSCALL/SYSRET */
41
void syscall_setup_cpu(void)
42
void syscall_setup_cpu(void)
Line 52... Line 53...
52
    write_msr(AMD_MSR_STAR,
53
    write_msr(AMD_MSR_STAR,
53
          ((__u64)(gdtselector(KDATA_DES) | PL_USER)<<48) \
54
          ((__u64)(gdtselector(KDATA_DES) | PL_USER)<<48) \
54
          | ((__u64)(gdtselector(KTEXT_DES) | PL_KERNEL)<<32));
55
          | ((__u64)(gdtselector(KTEXT_DES) | PL_KERNEL)<<32));
55
    write_msr(AMD_MSR_LSTAR, (__u64)syscall_entry);
56
    write_msr(AMD_MSR_LSTAR, (__u64)syscall_entry);
56
    /* Mask RFLAGS on syscall
57
    /* Mask RFLAGS on syscall
57
     * - we do not care what is in the flags field
58
     * - disable interrupts, until we exchange the stack register
-
 
59
     *   (mask the IE bit)
58
     */
60
     */
59
    write_msr(AMD_MSR_SFMASK, 0);
61
    write_msr(AMD_MSR_SFMASK, 0x200);
60
}
62
}
61
 
63
 
62
/** Dispatch system call */
64
/** Dispatch system call */
63
__native syscall_handler(__native id, __native a1, __native a2, __native a3)
65
__native syscall_handler(__native id, __native a1, __native a2, __native a3)
64
{
66
{
-
 
67
    interrupts_enable();
65
    if (id < SYSCALL_END)
68
    if (id < SYSCALL_END)
66
        return syscall_table[id](a1,a2,a3);
69
        return syscall_table[id](a1,a2,a3);
67
    else
70
    else
68
        panic("Undefined syscall %d", id);
71
        panic("Undefined syscall %d", id);
69
   
72
    interrupts_disable();
70
}
73
}