Changeset dd4d6b0 in mainline


Ignore:
Timestamp:
2006-02-06T23:47:47Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37b451f7
Parents:
40ca402
Message:

Basic amd syscall support.

Location:
arch/amd64
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/Makefile.inc

    r40ca402 rdd4d6b0  
    100100        arch/$(ARCH)/src/cpu/cpu.c \
    101101        arch/$(ARCH)/src/proc/scheduler.c \
    102         arch/$(ARCH)/src/userspace.c
     102        arch/$(ARCH)/src/userspace.c \
     103        arch/$(ARCH)/src/syscall.c
    103104
    104105ifeq ($(CONFIG_SMP),y)
  • arch/amd64/include/asm.h

    r40ca402 rdd4d6b0  
    189189}
    190190
     191/** Write to MSR */
     192static inline void write_msr(__u32 msr, __u64 value)
     193{
     194        __asm__ volatile (
     195                "wrmsr;" : : "c" (msr),
     196                "a" ((__u32)(value)),
     197                "d" ((__u32)(value >> 32))
     198                );
     199}
     200
     201static inline __native read_msr(__u32 msr)
     202{
     203        __u32 ax, dx;
     204
     205        __asm__ volatile (
     206                "rdmsr;" : "=a"(ax), "=d"(dx) : "c" (msr)
     207                );
     208        return ((__u64)dx << 32) | ax;
     209}
     210
    191211
    192212/** Enable local APIC
  • arch/amd64/include/cpu.h

    r40ca402 rdd4d6b0  
    3838#define AMD_NXE_FLAG    11
    3939
     40/* MSR registers */
     41#define AMD_MSR_STAR    0xc0000081
     42#define AMD_MSR_LSTAR   0xc0000082
     43#define AMD_MSR_SFMASK  0xc0000084
     44
    4045#ifndef __ASM__
    4146
  • arch/amd64/include/pm.h

    r40ca402 rdd4d6b0  
    4040
    4141#define NULL_DES        0
     42/* Warning: Do not reorder next items, unless you look into syscall.c!!! */
    4243#define KTEXT_DES       1
    4344#define KDATA_DES       2
    44 #define UTEXT_DES       3
    45 #define UDATA_DES       4
     45#define UDATA_DES       3
     46#define UTEXT_DES       4
    4647#define KTEXT32_DES     5
     48/* EndOfWarning */
    4749#define TSS_DES         6
    4850
  • arch/amd64/src/amd64.c

    r40ca402 rdd4d6b0  
    4646#include <panic.h>
    4747#include <interrupt.h>
     48#include <arch/syscall.h>
    4849
    4950/** Disable I/O on non-privileged levels
     
    100101        /* Enable No-execute pages */
    101102        set_efer_flag(AMD_NXE_FLAG);
    102         /* Enable SYSCALL/SYSRET */
    103         set_efer_flag(AMD_SCE_FLAG);
    104103        /* Enable FPU */
    105104        cpu_setup_fpu();
     105
    106106        /* Initialize segmentation */
    107107        pm_init();
     
    113113        /* Disable alignment check */
    114114        clean_AM_flag();
    115        
    116115
    117116        if (config.cpu_active == 1) {
     
    133132                ega_init();     /* video */
    134133        }
     134        /* Setup fast SYSCALL/SYSRET */
     135        syscall_setup_cpu();
     136
    135137}
    136138
  • arch/amd64/src/asm_utils.S

    r40ca402 rdd4d6b0  
    3939.text
    4040.global interrupt_handlers
     41.global syscall_entry
    4142.global panic_printf
    4243
     
    189190        handler 0 IDT_ITEMS
    190191h_end:
    191        
     192
     193       
     194syscall_entry:
     195        # TODO: Switch to kernel stack
     196        call syscall_handler
     197        # Switch back
     198        sysret
     199               
    192200.data
    193201.global interrupt_handler_size
  • arch/amd64/src/pm.c

    r40ca402 rdd4d6b0  
    7272          .granularity = 1,
    7373          .base_24_31  = 0 },
     74        /* UDATA descriptor */
     75        { .limit_0_15  = 0xffff,
     76          .base_0_15   = 0,
     77          .base_16_23  = 0,
     78          .access      = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER,
     79          .limit_16_19 = 0xf,
     80          .available   = 0,
     81          .longmode    = 0,
     82          .special     = 1,
     83          .granularity = 1,
     84          .base_24_31  = 0 },
    7485        /* UTEXT descriptor */
    7586        { .limit_0_15  = 0xffff,
     
    8192          .longmode    = 1,
    8293          .special     = 0,
    83           .granularity = 1,
    84           .base_24_31  = 0 },
    85         /* UDATA descriptor */
    86         { .limit_0_15  = 0xffff,
    87           .base_0_15   = 0,
    88           .base_16_23  = 0,
    89           .access      = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER,
    90           .limit_16_19 = 0xf,
    91           .available   = 0,
    92           .longmode    = 0,
    93           .special     = 1,
    9494          .granularity = 1,
    9595          .base_24_31  = 0 },
Note: See TracChangeset for help on using the changeset viewer.