Ignore:
File:
1 edited

Legend:

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

    r0f17bff r45f7449  
    3131 */
    3232
    33 #include <abi/asmtool.h>
    3433#include <arch/pm.h>
    3534#include <arch/cpu.h>
    3635#include <arch/mm/page.h>
    37 #include <arch/istate_struct.h>
    38 #include <arch/smp/apic.h>
    3936
    4037.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
    4145
    4246#define MEMCPY_DST   4
     
    5963 *
    6064 */
    61 FUNCTION_BEGIN(memcpy_from_uspace)
    62 FUNCTION_BEGIN(memcpy_to_uspace)
     65memcpy_from_uspace:
     66memcpy_to_uspace:
    6367        movl %edi, %edx  /* save %edi */
    6468        movl %esi, %eax  /* save %esi */
     
    8892                movl MEMCPY_DST(%esp), %eax
    8993                ret
    90 FUNCTION_END(memcpy_from_uspace)
    91 FUNCTION_END(memcpy_to_uspace)
    9294
    9395/*
     
    9597 * above had caused a page fault.
    9698 */
    97 SYMBOL(memcpy_from_uspace_failover_address)
    98 SYMBOL(memcpy_to_uspace_failover_address)
     99memcpy_from_uspace_failover_address:
     100memcpy_to_uspace_failover_address:
    99101        movl %edx, %edi
    100102        movl %eax, %esi
     
    109111 *
    110112 */
    111 FUNCTION_BEGIN(paging_on)
     113paging_on:
    112114        movl %cr0, %edx
    113         orl $CR0_PG, %edx  /* paging on */
     115        orl $(1 << 31), %edx  /* paging on */
    114116       
    115117        /* Clear Cache Disable and not Write Though */
    116         andl $~(CR0_CD | CR0_NW), %edx
     118        andl $~((1 << 30) | (1 << 29)), %edx
    117119        movl %edx, %cr0
    118120        jmp 0f
     
    120122        0:
    121123                ret
    122 FUNCTION_END(paging_on)
    123124
    124125/** Enable local APIC
     
    127128 *
    128129 */
    129 FUNCTION_BEGIN(enable_l_apic_in_msr)
    130         movl $IA32_MSR_APIC_BASE, %ecx
     130enable_l_apic_in_msr:
     131        movl $0x1b, %ecx
    131132        rdmsr
    132         orl $(L_APIC_BASE | IA32_APIC_BASE_GE), %eax
     133        orl $(1 << 11), %eax
     134        orl $(0xfee00000), %eax
    133135        wrmsr
    134136        ret
    135 FUNCTION_END(enable_l_apic_in_msr)
     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
    136157
    137158/*
     
    139160 * and without the error word.
    140161 */
    141 #define ISTATE_SOFT_SIZE        ISTATE_SIZE - (6 * 4)
     162#define ISTATE_SOFT_SIZE  52
    142163
    143164/*
     
    150171 * entirely in registers.
    151172 */
    152 SYMBOL(sysenter_handler)
     173.global sysenter_handler
     174sysenter_handler:
    153175
    154176        /*
     
    183205
    184206        /*
     207         * Save TLS.
     208         */
     209        movl %gs, %edx
     210        movl %edx, ISTATE_OFFSET_GS(%esp)
     211
     212        /*
    185213         * Switch to kernel selectors.
    186214         */
    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
     215        movw $(GDT_SELECTOR(KDATA_DES)), %ax
     216        movw %ax, %ds
     217        movw %ax, %es
    192218       
    193219        /*
     
    209235       
    210236        /*
     237         * Restore TLS.
     238         */
     239        movl ISTATE_OFFSET_GS(%esp), %edx
     240        movl %edx, %gs
     241       
     242        /*
    211243         * Prepare return address and userspace stack for SYSEXIT.
    212244         */
     
    219251 * This is the legacy syscall handler using the interrupt mechanism.
    220252 */
    221 SYMBOL(int_syscall)
     253.global int_syscall
     254int_syscall:
    222255        subl $(ISTATE_SOFT_SIZE + 4), %esp
    223256
     
    242275
    243276        /*
    244          * Save the segment registers.
     277         * Save the selector registers.
    245278         */
    246279        movl %gs, %ecx
     
    262295        movl %eax, %ds
    263296        movl %eax, %es
    264         movl $(GDT_SELECTOR(VREG_DES)), %eax
    265         movl %eax, %gs
    266297               
    267298        movl $0, ISTATE_OFFSET_EBP_FRAME(%esp)
     
    276307                       
    277308        /*
    278          * Restore the segment registers.
     309         * Restore the selector registers.
    279310         */
    280311        movl ISTATE_OFFSET_GS(%esp), %ecx
     
    307338
    308339.macro handler i
    309 SYMBOL(int_\i)
     340.global int_\i
     341int_\i:
    310342        /*
    311343         * This macro distinguishes between two versions of ia32
     
    346378       
    347379        /*
    348          * Save the segment registers.
     380         * Save the selector registers.
    349381         */
    350382        movl %gs, %ecx
     
    366398        movl %eax, %ds
    367399        movl %eax, %es
    368         movl $(GDT_SELECTOR(VREG_DES)), %eax
    369         movl %eax, %gs
    370400       
    371401        /*
     
    451481 *
    452482 */
    453 FUNCTION_BEGIN(early_putchar)
     483early_putchar:
    454484       
    455485#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
     
    583613       
    584614        ret
    585 FUNCTION_END(early_putchar)
    586 
     615
Note: See TracChangeset for help on using the changeset viewer.