Changeset add04f7 in mainline for kernel/arch/ia32/src


Ignore:
Timestamp:
2009-03-03T15:20:49Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f24d300
Parents:
deca67b
Message:

better inline assembler readability using the new symbolic syntax

Location:
kernel/arch/ia32/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/cpu/cpu.c

    rdeca67b radd04f7  
    4949 * Contains only non-MP-Specification specific SMP code.
    5050 */
    51 #define AMD_CPUID_EBX   0x68747541
    52 #define AMD_CPUID_ECX   0x444d4163
    53 #define AMD_CPUID_EDX   0x69746e65
     51#define AMD_CPUID_EBX  0x68747541
     52#define AMD_CPUID_ECX  0x444d4163
     53#define AMD_CPUID_EDX  0x69746e65
    5454
    55 #define INTEL_CPUID_EBX 0x756e6547
    56 #define INTEL_CPUID_ECX 0x6c65746e
    57 #define INTEL_CPUID_EDX 0x49656e69
     55#define INTEL_CPUID_EBX  0x756e6547
     56#define INTEL_CPUID_ECX  0x6c65746e
     57#define INTEL_CPUID_EDX  0x49656e69
    5858
    5959
    6060enum vendor {
    61         VendorUnknown=0,
     61        VendorUnknown = 0,
    6262        VendorAMD,
    6363        VendorIntel
     
    7373{
    7474        asm volatile (
    75                 "mov %%cr0,%%eax;"
    76                 "or $8,%%eax;"
    77                 "mov %%eax,%%cr0;"
    78                 :
    79                 :
    80                 : "%eax"
     75                "mov %%cr0, %%eax\n"
     76                "or $8, %%eax\n"
     77                "mov %%eax, %%cr0\n"
     78                ::: "%eax"
    8179        );
    8280}
     
    8583{
    8684        asm volatile (
    87                 "mov %%cr0,%%eax;"
    88                 "and $0xffFFffF7,%%eax;"
    89                 "mov %%eax,%%cr0;"
    90                 :
    91                 :
    92                 : "%eax"
    93         );     
     85                "mov %%cr0, %%eax\n"
     86                "and $0xffFFffF7, %%eax\n"
     87                "mov %%eax,%%cr0\n"
     88                ::: "%eax"
     89        );
    9490}
    9591
     
    10399        CPU->arch.tss = tss_p;
    104100        CPU->arch.tss->iomap_base = &CPU->arch.tss->iomap[0] - ((uint8_t *) CPU->arch.tss);
    105 
     101       
    106102        CPU->fpu_owner = NULL;
    107 
     103       
    108104        cpuid(1, &info);
    109 
     105       
    110106        fi.word = info.cpuid_edx;
    111107        efi.word = info.cpuid_ecx;
     
    114110                fpu_fxsr();
    115111        else
    116                 fpu_fsr();     
     112                fpu_fsr();
    117113       
    118114        if (fi.bits.sse) {
    119115                asm volatile (
    120                         "mov %%cr4,%0\n"
    121                         "or %1,%0\n"
    122                         "mov %0,%%cr4\n"
    123                         : "+r" (help)
    124                         : "i" (CR4_OSFXSR_MASK|(1<<10))
     116                        "mov %%cr4, %[help]\n"
     117                        "or %[mask], %[help]\n"
     118                        "mov %[help], %%cr4\n"
     119                        : [help] "+r" (help)
     120                        : [mask] "i" (CR4_OSFXSR_MASK | (1 << 10))
    125121                );
    126122        }
  • kernel/arch/ia32/src/fpu_context.c

    rdeca67b radd04f7  
    4545{
    4646        asm volatile (
    47                 "fnsave %0"
    48                 : "=m"(*fctx)
    49                 );
     47                "fnsave %[fctx]"
     48                : [fctx] "=m" (*fctx)
     49        );
    5050}
    5151
     
    5353{
    5454        asm volatile (
    55                 "frstor %0"
    56                 : "=m"(*fctx)
    57                 );
     55                "frstor %[fctx]"
     56                : [fctx] "=m" (*fctx)
     57        );
    5858}
    5959
     
    6161{
    6262        asm volatile (
    63                 "fxsave %0"
    64                 : "=m"(*fctx)
    65                 );
     63                "fxsave %[fctx]"
     64                : [fctx] "=m" (*fctx)
     65        );
    6666}
    6767
     
    6969{
    7070        asm volatile (
    71                 "fxrstor %0"
    72                 : "=m"(*fctx)
    73                 );
     71                "fxrstor %[fctx]"
     72                : [fctx] "=m" (*fctx)
     73        );
    7474}
    7575
    76 /*
    77         Setup using fxsr instruction
    78 */
     76/* Setup using fxsr instruction */
    7977void fpu_fxsr(void)
    8078{
     
    8280        fpu_restore=fpu_context_fx_restore;
    8381}
    84 /*
    85         Setup using not fxsr instruction
    86 */
     82
     83/* Setup using not fxsr instruction */
    8784void fpu_fsr(void)
    8885{
     
    103100void fpu_init()
    104101{
    105         uint32_t help0 = 0, help1 = 0;
     102        uint32_t help0 = 0;
     103        uint32_t help1 = 0;
     104       
    106105        asm volatile (
    107                 "fninit;\n"
    108                 "stmxcsr %0\n"
    109                 "mov %0,%1;\n"
    110                 "or %2,%1;\n"
    111                 "mov %1,%0;\n"
    112                 "ldmxcsr %0;\n"
    113                 : "+m" (help0), "+r" (help1)
    114                 : "i" (0x1f80)
     106                "fninit\n"
     107                "stmxcsr %[help0]\n"
     108                "mov %[help0], %[help1]\n"
     109                "or %[magic], %[help1]\n"
     110                "mov %[help1], %[help0]\n"
     111                "ldmxcsr %[help0]\n"
     112                : [help0] "+m" (help0), [help1] "+r" (help1)
     113                : [magic] "i" (0x1f80)
    115114        );
    116115}
  • kernel/arch/ia32/src/interrupt.c

    rdeca67b radd04f7  
    139139        uint32_t mxcsr;
    140140        asm (
    141                 "stmxcsr %0;\n"
    142                 : "=m" (mxcsr)
     141                "stmxcsr %[mxcsr]\n"
     142                : [mxcsr] "=m" (mxcsr)
    143143        );
    144144        fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR: %#zx.",
    145145            (unative_t) mxcsr);
    146 
     146       
    147147        decode_istate(istate);
    148148        printf("MXCSR: %#lx\n", mxcsr);
  • kernel/arch/ia32/src/pm.c

    rdeca67b radd04f7  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    155155                "push %%eax\n"
    156156                "popfl\n"
    157                 : : : "eax"
     157                ::: "eax"
    158158        );
    159159}
     
    166166                "and $0xfffbffff, %%eax\n"
    167167                "mov %%eax, %%cr0\n"
    168                 : : : "eax"
     168                ::: "eax"
    169169        );
    170170}
  • kernel/arch/ia32/src/userspace.c

    rdeca67b radd04f7  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    4848void userspace(uspace_arg_t *kernel_uarg)
    4949{
    50         ipl_t ipl;
    51 
    52         ipl = interrupts_disable();
    53 
     50        ipl_t ipl = interrupts_disable();
     51       
    5452        asm volatile (
    5553                /*
     
    6159                "push %%eax\n"
    6260                "popfl\n"
    63 
     61               
    6462                /* Set up GS register (TLS) */
    65                 "movl %6, %%gs\n"
    66 
    67                 "pushl %0\n"
    68                 "pushl %1\n"
    69                 "pushl %2\n"
    70                 "pushl %3\n"
    71                 "pushl %4\n"
    72                 "movl %5, %%eax\n"
    73 
     63                "movl %[tls_des], %%gs\n"
     64               
     65                "pushl %[udata_des]\n"
     66                "pushl %[stack_size]\n"
     67                "pushl %[ipl]\n"
     68                "pushl %[utext_des]\n"
     69                "pushl %[entry]\n"
     70                "movl %[uarg], %%eax\n"
     71               
    7472                /* %ebx is defined to hold pcb_ptr - set it to 0 */
    75                 "xorl %%ebx, %%ebx\n"   
    76 
     73                "xorl %%ebx, %%ebx\n"
     74               
    7775                "iret\n"
    78                 :
    79                 : "i" (selector(UDATA_DES) | PL_USER),
    80                   "r" ((uint8_t *) kernel_uarg->uspace_stack +
    81                       THREAD_STACK_SIZE),
    82                   "r" (ipl),
    83                   "i" (selector(UTEXT_DES) | PL_USER),
    84                   "r" (kernel_uarg->uspace_entry),
    85                   "r" (kernel_uarg->uspace_uarg),
    86                   "r" (selector(TLS_DES))
     76                :
     77                : [udata_des] "i" (selector(UDATA_DES) | PL_USER),
     78                  [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
     79                  [ipl] "r" (ipl),
     80                  [utext_des] "i" (selector(UTEXT_DES) | PL_USER),
     81                  [entry] "r" (kernel_uarg->uspace_entry),
     82                  [uarg] "r" (kernel_uarg->uspace_uarg),
     83                  [tls_des] "r" (selector(TLS_DES))
    8784                : "eax");
    8885       
    8986        /* Unreachable */
    90         for(;;)
    91                 ;
     87        while (1);
    9288}
    9389
Note: See TracChangeset for help on using the changeset viewer.