Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/asm.S

    r45f7449 r0f17bff  
    3131 */
    3232
     33#include <abi/asmtool.h>
    3334#include <arch/pm.h>
    3435#include <arch/cpu.h>
    3536#include <arch/mm/page.h>
     37#include <arch/istate_struct.h>
     38#include <arch/smp/apic.h>
    3639
    3740.text
    38 .global paging_on
    39 .global enable_l_apic_in_msr
    40 .global memcpy_from_uspace
    41 .global memcpy_from_uspace_failover_address
    42 .global memcpy_to_uspace
    43 .global memcpy_to_uspace_failover_address
    44 .global early_putchar
    4541
    4642#define MEMCPY_DST   4
     
    6359 *
    6460 */
    65 memcpy_from_uspace:
    66 memcpy_to_uspace:
     61FUNCTION_BEGIN(memcpy_from_uspace)
     62FUNCTION_BEGIN(memcpy_to_uspace)
    6763        movl %edi, %edx  /* save %edi */
    6864        movl %esi, %eax  /* save %esi */
     
    9288                movl MEMCPY_DST(%esp), %eax
    9389                ret
     90FUNCTION_END(memcpy_from_uspace)
     91FUNCTION_END(memcpy_to_uspace)
    9492
    9593/*
     
    9795 * above had caused a page fault.
    9896 */
    99 memcpy_from_uspace_failover_address:
    100 memcpy_to_uspace_failover_address:
     97SYMBOL(memcpy_from_uspace_failover_address)
     98SYMBOL(memcpy_to_uspace_failover_address)
    10199        movl %edx, %edi
    102100        movl %eax, %esi
     
    111109 *
    112110 */
    113 paging_on:
     111FUNCTION_BEGIN(paging_on)
    114112        movl %cr0, %edx
    115         orl $(1 << 31), %edx  /* paging on */
     113        orl $CR0_PG, %edx  /* paging on */
    116114       
    117115        /* Clear Cache Disable and not Write Though */
    118         andl $~((1 << 30) | (1 << 29)), %edx
     116        andl $~(CR0_CD | CR0_NW), %edx
    119117        movl %edx, %cr0
    120118        jmp 0f
     
    122120        0:
    123121                ret
     122FUNCTION_END(paging_on)
    124123
    125124/** Enable local APIC
     
    128127 *
    129128 */
    130 enable_l_apic_in_msr:
    131         movl $0x1b, %ecx
     129FUNCTION_BEGIN(enable_l_apic_in_msr)
     130        movl $IA32_MSR_APIC_BASE, %ecx
    132131        rdmsr
    133         orl $(1 << 11), %eax
    134         orl $(0xfee00000), %eax
     132        orl $(L_APIC_BASE | IA32_APIC_BASE_GE), %eax
    135133        wrmsr
    136134        ret
    137 
    138 #define ISTATE_OFFSET_EDX         0
    139 #define ISTATE_OFFSET_ECX         4
    140 #define ISTATE_OFFSET_EBX         8
    141 #define ISTATE_OFFSET_ESI         12
    142 #define ISTATE_OFFSET_EDI         16
    143 #define ISTATE_OFFSET_EBP         20
    144 #define ISTATE_OFFSET_EAX         24
    145 #define ISTATE_OFFSET_EBP_FRAME   28
    146 #define ISTATE_OFFSET_EIP_FRAME   32
    147 #define ISTATE_OFFSET_GS          36
    148 #define ISTATE_OFFSET_FS          40
    149 #define ISTATE_OFFSET_ES          44
    150 #define ISTATE_OFFSET_DS          48
    151 #define ISTATE_OFFSET_ERROR_WORD  52
    152 #define ISTATE_OFFSET_EIP         56
    153 #define ISTATE_OFFSET_CS          60
    154 #define ISTATE_OFFSET_EFLAGS      64
    155 #define ISTATE_OFFSET_ESP         68
    156 #define ISTATE_OFFSET_SS          72
     135FUNCTION_END(enable_l_apic_in_msr)
    157136
    158137/*
     
    160139 * and without the error word.
    161140 */
    162 #define ISTATE_SOFT_SIZE  52
     141#define ISTATE_SOFT_SIZE        ISTATE_SIZE - (6 * 4)
    163142
    164143/*
     
    171150 * entirely in registers.
    172151 */
    173 .global sysenter_handler
    174 sysenter_handler:
     152SYMBOL(sysenter_handler)
    175153
    176154        /*
     
    205183
    206184        /*
    207          * Save TLS.
    208          */
    209         movl %gs, %edx
    210         movl %edx, ISTATE_OFFSET_GS(%esp)
    211 
    212         /*
    213185         * Switch to kernel selectors.
    214186         */
    215         movw $(GDT_SELECTOR(KDATA_DES)), %ax
    216         movw %ax, %ds
    217         movw %ax, %es
     187        movl $(GDT_SELECTOR(KDATA_DES)), %eax
     188        movl %eax, %ds
     189        movl %eax, %es
     190        movl $(GDT_SELECTOR(VREG_DES)), %eax
     191        movl %eax, %gs
    218192       
    219193        /*
     
    235209       
    236210        /*
    237          * Restore TLS.
    238          */
    239         movl ISTATE_OFFSET_GS(%esp), %edx
    240         movl %edx, %gs
    241        
    242         /*
    243211         * Prepare return address and userspace stack for SYSEXIT.
    244212         */
     
    251219 * This is the legacy syscall handler using the interrupt mechanism.
    252220 */
    253 .global int_syscall
    254 int_syscall:
     221SYMBOL(int_syscall)
    255222        subl $(ISTATE_SOFT_SIZE + 4), %esp
    256223
     
    275242
    276243        /*
    277          * Save the selector registers.
     244         * Save the segment registers.
    278245         */
    279246        movl %gs, %ecx
     
    295262        movl %eax, %ds
    296263        movl %eax, %es
     264        movl $(GDT_SELECTOR(VREG_DES)), %eax
     265        movl %eax, %gs
    297266               
    298267        movl $0, ISTATE_OFFSET_EBP_FRAME(%esp)
     
    307276                       
    308277        /*
    309          * Restore the selector registers.
     278         * Restore the segment registers.
    310279         */
    311280        movl ISTATE_OFFSET_GS(%esp), %ecx
     
    338307
    339308.macro handler i
    340 .global int_\i
    341 int_\i:
     309SYMBOL(int_\i)
    342310        /*
    343311         * This macro distinguishes between two versions of ia32
     
    378346       
    379347        /*
    380          * Save the selector registers.
     348         * Save the segment registers.
    381349         */
    382350        movl %gs, %ecx
     
    398366        movl %eax, %ds
    399367        movl %eax, %es
     368        movl $(GDT_SELECTOR(VREG_DES)), %eax
     369        movl %eax, %gs
    400370       
    401371        /*
     
    481451 *
    482452 */
    483 early_putchar:
     453FUNCTION_BEGIN(early_putchar)
    484454       
    485455#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
     
    613583       
    614584        ret
    615 
     585FUNCTION_END(early_putchar)
     586
Note: See TracChangeset for help on using the changeset viewer.