Changeset add04f7 in mainline


Ignore:
Timestamp:
2009-03-03T15:20:49Z (15 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
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/include/asm.h

    rdeca67b radd04f7  
    2828 */
    2929
    30 /** @addtogroup ia32   
     30/** @addtogroup ia32
    3131 * @{
    3232 */
     
    5757 *
    5858 * Halt the current CPU until interrupt event.
     59 *
    5960 */
    6061static inline void cpu_halt(void)
     
    6970
    7071#define GEN_READ_REG(reg) static inline unative_t read_ ##reg (void) \
    71     { \
    72         unative_t res; \
    73         asm volatile ("movl %%" #reg ", %0" : "=r" (res) ); \
    74         return res; \
    75     }
     72        { \
     73                unative_t res; \
     74                asm volatile ( \
     75                        "movl %%" #reg ", %[res]" \
     76                        : [res] "=r" (res) \
     77                ); \
     78                return res; \
     79        }
    7680
    7781#define GEN_WRITE_REG(reg) static inline void write_ ##reg (unative_t regn) \
    78     { \
    79         asm volatile ("movl %0, %%" #reg : : "r" (regn)); \
    80     }
     82        { \
     83                asm volatile ( \
     84                        "movl %[regn], %%" #reg \
     85                        :: [regn] "r" (regn) \
     86                ); \
     87        }
    8188
    8289GEN_READ_REG(cr0)
     
    105112 * @param port Port to write to
    106113 * @param val Value to write
     114 *
    107115 */
    108116static inline void pio_write_8(ioport8_t *port, uint8_t val)
    109117{
    110         asm volatile ("outb %b0, %w1\n" : : "a" (val), "d" (port));
     118        asm volatile (
     119                "outb %b[val], %w[port]\n"
     120                :: [val] "a" (val), [port] "d" (port)
     121        );
    111122}
    112123
     
    117128 * @param port Port to write to
    118129 * @param val Value to write
     130 *
    119131 */
    120132static inline void pio_write_16(ioport16_t *port, uint16_t val)
    121133{
    122         asm volatile ("outw %w0, %w1\n" : : "a" (val), "d" (port));
     134        asm volatile (
     135                "outw %w[val], %w[port]\n"
     136                :: [val] "a" (val), [port] "d" (port)
     137        );
    123138}
    124139
     
    129144 * @param port Port to write to
    130145 * @param val Value to write
     146 *
    131147 */
    132148static inline void pio_write_32(ioport32_t *port, uint32_t val)
    133149{
    134         asm volatile ("outl %0, %w1\n" : : "a" (val), "d" (port));
     150        asm volatile (
     151                "outl %[val], %w[port]\n"
     152                :: [val] "a" (val), [port] "d" (port)
     153        );
    135154}
    136155
     
    141160 * @param port Port to read from
    142161 * @return Value read
     162 *
    143163 */
    144164static inline uint8_t pio_read_8(ioport8_t *port)
     
    146166        uint8_t val;
    147167       
    148         asm volatile ("inb %w1, %b0 \n" : "=a" (val) : "d" (port));
     168        asm volatile (
     169                "inb %w[port], %b[val]\n"
     170                : [val] "=a" (val)
     171                : [port] "d" (port)
     172        );
     173       
    149174        return val;
    150175}
     
    156181 * @param port Port to read from
    157182 * @return Value read
     183 *
    158184 */
    159185static inline uint16_t pio_read_16(ioport16_t *port)
     
    161187        uint16_t val;
    162188       
    163         asm volatile ("inw %w1, %w0 \n" : "=a" (val) : "d" (port));
     189        asm volatile (
     190                "inw %w[port], %w[val]\n"
     191                : [val] "=a" (val)
     192                : [port] "d" (port)
     193        );
     194       
    164195        return val;
    165196}
     
    171202 * @param port Port to read from
    172203 * @return Value read
     204 *
    173205 */
    174206static inline uint32_t pio_read_32(ioport32_t *port)
     
    176208        uint32_t val;
    177209       
    178         asm volatile ("inl %w1, %0 \n" : "=a" (val) : "d" (port));
     210        asm volatile (
     211                "inl %w[port], %[val]\n"
     212                : [val] "=a" (val)
     213                : [port] "d" (port)
     214        );
     215       
    179216        return val;
    180217}
     
    186223 *
    187224 * @return Old interrupt priority level.
     225 *
    188226 */
    189227static inline ipl_t interrupts_enable(void)
    190228{
    191229        ipl_t v;
    192         asm volatile (
    193                 "pushf\n\t"
    194                 "popl %0\n\t"
     230       
     231        asm volatile (
     232                "pushf\n"
     233                "popl %[v]\n"
    195234                "sti\n"
    196                 : "=r" (v)
    197         );
     235                : [v] "=r" (v)
     236        );
     237       
    198238        return v;
    199239}
     
    205245 *
    206246 * @return Old interrupt priority level.
     247 *
    207248 */
    208249static inline ipl_t interrupts_disable(void)
    209250{
    210251        ipl_t v;
    211         asm volatile (
    212                 "pushf\n\t"
    213                 "popl %0\n\t"
     252       
     253        asm volatile (
     254                "pushf\n"
     255                "popl %[v]\n"
    214256                "cli\n"
    215                 : "=r" (v)
    216         );
     257                : [v] "=r" (v)
     258        );
     259       
    217260        return v;
    218261}
     
    223266 *
    224267 * @param ipl Saved interrupt priority level.
     268 *
    225269 */
    226270static inline void interrupts_restore(ipl_t ipl)
    227271{
    228272        asm volatile (
    229                 "pushl %0\n\t"
     273                "pushl %[ipl]\n"
    230274                "popf\n"
    231                 : : "r" (ipl)
     275                :: [ipl] "r" (ipl)
    232276        );
    233277}
     
    236280 *
    237281 * @return EFLAFS.
     282 *
    238283 */
    239284static inline ipl_t interrupts_read(void)
    240285{
    241286        ipl_t v;
    242         asm volatile (
    243                 "pushf\n\t"
    244                 "popl %0\n"
    245                 : "=r" (v)
    246         );
     287       
     288        asm volatile (
     289                "pushf\n"
     290                "popl %[v]\n"
     291                : [v] "=r" (v)
     292        );
     293       
    247294        return v;
    248295}
     
    251298static inline void write_msr(uint32_t msr, uint64_t value)
    252299{
    253         asm volatile ("wrmsr" : : "c" (msr), "a" ((uint32_t)(value)),
    254             "d" ((uint32_t)(value >> 32)));
     300        asm volatile (
     301                "wrmsr"
     302                :: "c" (msr), "a" ((uint32_t) (value)),
     303                   "d" ((uint32_t) (value >> 32))
     304        );
    255305}
    256306
     
    258308{
    259309        uint32_t ax, dx;
    260 
    261         asm volatile ("rdmsr" : "=a"(ax), "=d"(dx) : "c" (msr));
    262         return ((uint64_t)dx << 32) | ax;
     310       
     311        asm volatile (
     312                "rdmsr"
     313                : "=a" (ax), "=d" (dx)
     314                : "c" (msr)
     315        );
     316       
     317        return ((uint64_t) dx << 32) | ax;
    263318}
    264319
     
    269324 * The stack is assumed to be STACK_SIZE bytes long.
    270325 * The stack must start on page boundary.
     326 *
    271327 */
    272328static inline uintptr_t get_stack_base(void)
     
    275331       
    276332        asm volatile (
    277                 "andl %%esp, %0\n"
    278                 : "=r" (v)
     333                "andl %%esp, %[v]\n"
     334                : [v] "=r" (v)
    279335                : "0" (~(STACK_SIZE - 1))
    280336        );
     
    287343{
    288344        uintptr_t *ip;
    289 
    290         asm volatile (
    291                 "mov %%eip, %0"
    292                 : "=r" (ip)
    293                 );
     345       
     346        asm volatile (
     347                "mov %%eip, %[ip]"
     348                : [ip] "=r" (ip)
     349        );
     350       
    294351        return ip;
    295352}
     
    298355 *
    299356 * @param addr Address on a page whose TLB entry is to be invalidated.
     357 *
    300358 */
    301359static inline void invlpg(uintptr_t addr)
    302360{
    303         asm volatile ("invlpg %0\n" :: "m" (*(unative_t *)addr));
     361        asm volatile (
     362                "invlpg %[addr]\n"
     363                :: [addr] "m" (*(unative_t *) addr)
     364        );
    304365}
    305366
     
    307368 *
    308369 * @param gdtr_reg Address of memory from where to load GDTR.
     370 *
    309371 */
    310372static inline void gdtr_load(ptr_16_32_t *gdtr_reg)
    311373{
    312         asm volatile ("lgdtl %0\n" : : "m" (*gdtr_reg));
     374        asm volatile (
     375                "lgdtl %[gdtr_reg]\n"
     376                :: [gdtr_reg] "m" (*gdtr_reg)
     377        );
    313378}
    314379
     
    316381 *
    317382 * @param gdtr_reg Address of memory to where to load GDTR.
     383 *
    318384 */
    319385static inline void gdtr_store(ptr_16_32_t *gdtr_reg)
    320386{
    321         asm volatile ("sgdtl %0\n" : : "m" (*gdtr_reg));
     387        asm volatile (
     388                "sgdtl %[gdtr_reg]\n"
     389                :: [gdtr_reg] "m" (*gdtr_reg)
     390        );
    322391}
    323392
     
    325394 *
    326395 * @param idtr_reg Address of memory from where to load IDTR.
     396 *
    327397 */
    328398static inline void idtr_load(ptr_16_32_t *idtr_reg)
    329399{
    330         asm volatile ("lidtl %0\n" : : "m" (*idtr_reg));
     400        asm volatile (
     401                "lidtl %[idtr_reg]\n"
     402                :: [idtr_reg] "m" (*idtr_reg)
     403        );
    331404}
    332405
     
    334407 *
    335408 * @param sel Selector specifying descriptor of TSS segment.
     409 *
    336410 */
    337411static inline void tr_load(uint16_t sel)
    338412{
    339         asm volatile ("ltr %0" : : "r" (sel));
     413        asm volatile (
     414                "ltr %[sel]"
     415                :: [sel] "r" (sel)
     416        );
    340417}
    341418
  • kernel/arch/ia32/include/atomic.h

    rdeca67b radd04f7  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    4242static inline void atomic_inc(atomic_t *val) {
    4343#ifdef CONFIG_SMP
    44         asm volatile ("lock incl %0\n" : "+m" (val->count));
     44        asm volatile (
     45                "lock incl %[count]\n"
     46                : [count] "+m" (val->count)
     47        );
    4548#else
    46         asm volatile ("incl %0\n" : "+m" (val->count));
     49        asm volatile (
     50                "incl %[count]\n"
     51                : [count] "+m" (val->count)
     52        );
    4753#endif /* CONFIG_SMP */
    4854}
     
    5056static inline void atomic_dec(atomic_t *val) {
    5157#ifdef CONFIG_SMP
    52         asm volatile ("lock decl %0\n" : "+m" (val->count));
     58        asm volatile (
     59                "lock decl %[count]\n"
     60                : [count] "+m" (val->count)
     61        );
    5362#else
    54         asm volatile ("decl %0\n" : "+m" (val->count));
     63        asm volatile (
     64                "decl %[count]\n"
     65                : "+m" (val->count)
     66        );
    5567#endif /* CONFIG_SMP */
    5668}
     
    5971{
    6072        long r = 1;
    61 
     73       
    6274        asm volatile (
    63                 "lock xaddl %1, %0\n"
    64                 : "+m" (val->count), "+r" (r)
     75                "lock xaddl %[r], %[count]\n"
     76                : [count] "+m" (val->count), [r] "+r" (r)
    6577        );
    66 
     78       
    6779        return r;
    6880}
     
    7385       
    7486        asm volatile (
    75                 "lock xaddl %1, %0\n"
    76                 : "+m" (val->count), "+r"(r)
     87                "lock xaddl %[r], %[count]\n"
     88                : [count] "+m" (val->count), [r] "+r"(r)
    7789        );
    7890       
     
    8092}
    8193
    82 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    83 #define atomic_predec(val) (atomic_postdec(val) - 1)
     94#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     95#define atomic_predec(val)  (atomic_postdec(val) - 1)
    8496
    8597static inline uint32_t test_and_set(atomic_t *val) {
     
    8799       
    88100        asm volatile (
    89                 "movl $1, %0\n"
    90                 "xchgl %0, %1\n"
    91                 : "=r" (v),"+m" (val->count)
     101                "movl $1, %[v]\n"
     102                "xchgl %[v], %[count]\n"
     103                : [v] "=r" (v), [count] "+m" (val->count)
    92104        );
    93105       
     
    99111{
    100112        uint32_t tmp;
    101 
     113       
    102114        preemption_disable();
    103115        asm volatile (
    104116                "0:\n"
    105117#ifdef CONFIG_HT
    106                 "pause\n" /* Pentium 4's HT love this instruction */
     118                "pause\n"        /* Pentium 4's HT love this instruction */
    107119#endif
    108                 "mov %0, %1\n"
    109                 "testl %1, %1\n"
     120                "mov %[count], %[tmp]\n"
     121                "testl %[tmp], %[tmp]\n"
    110122                "jnz 0b\n"       /* lightweight looping on locked spinlock */
    111123               
    112                 "incl %1\n"      /* now use the atomic operation */
    113                 "xchgl %0, %1\n"       
    114                 "testl %1, %1\n"
     124                "incl %[tmp]\n"  /* now use the atomic operation */
     125                "xchgl %[count], %[tmp]\n"
     126                "testl %[tmp], %[tmp]\n"
    115127                "jnz 0b\n"
    116                 : "+m" (val->count), "=&r"(tmp)
     128                : [count] "+m" (val->count), [tmp] "=&r" (tmp)
    117129        );
    118130        /*
  • kernel/arch/ia32/include/barrier.h

    rdeca67b radd04f7  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    4747 */
    4848
    49 #define CS_ENTER_BARRIER()      asm volatile ("" ::: "memory")
    50 #define CS_LEAVE_BARRIER()      asm volatile ("" ::: "memory")
     49#define CS_ENTER_BARRIER()  asm volatile ("" ::: "memory")
     50#define CS_LEAVE_BARRIER()  asm volatile ("" ::: "memory")
    5151
    5252static inline void cpuid_serialization(void)
     
    6060
    6161#if defined(CONFIG_FENCES_P4)
    62 #       define memory_barrier()         asm volatile ("mfence\n" ::: "memory")
    63 #       define read_barrier()           asm volatile ("lfence\n" ::: "memory")
    64 #       ifdef CONFIG_WEAK_MEMORY
    65 #               define write_barrier()  asm volatile ("sfence\n" ::: "memory")
    66 #       else
    67 #               define write_barrier()  asm volatile( "" ::: "memory");
    68 #       endif
     62        #define memory_barrier()  asm volatile ("mfence\n" ::: "memory")
     63        #define read_barrier()    asm volatile ("lfence\n" ::: "memory")
     64        #ifdef CONFIG_WEAK_MEMORY
     65                #define write_barrier()  asm volatile ("sfence\n" ::: "memory")
     66        #else
     67                #define write_barrier()  asm volatile ("" ::: "memory");
     68        #endif
    6969#elif defined(CONFIG_FENCES_P3)
    70 #       define memory_barrier()         cpuid_serialization()
    71 #       define read_barrier()           cpuid_serialization()
    72 #       ifdef CONFIG_WEAK_MEMORY
    73 #               define write_barrier()  asm volatile ("sfence\n" ::: "memory")
    74 #       else
    75 #               define write_barrier()  asm volatile( "" ::: "memory");
    76 #       endif
     70        #define memory_barrier()  cpuid_serialization()
     71        #define read_barrier()    cpuid_serialization()
     72        #ifdef CONFIG_WEAK_MEMORY
     73                #define write_barrier()  asm volatile ("sfence\n" ::: "memory")
     74        #else
     75                #define write_barrier()  asm volatile ("" ::: "memory");
     76        #endif
    7777#else
    78 #       define memory_barrier()         cpuid_serialization()
    79 #       define read_barrier()           cpuid_serialization()
    80 #       ifdef CONFIG_WEAK_MEMORY
    81 #               define write_barrier()  cpuid_serialization()
    82 #       else
    83 #               define write_barrier()  asm volatile( "" ::: "memory");
    84 #       endif
     78        #define memory_barrier()  cpuid_serialization()
     79        #define read_barrier()    cpuid_serialization()
     80        #ifdef CONFIG_WEAK_MEMORY
     81                #define write_barrier()  cpuid_serialization()
     82        #else
     83                #define write_barrier()  asm volatile ("" ::: "memory");
     84        #endif
    8585#endif
    8686
     
    9191 * sufficient for them to drain to the D-cache).
    9292 */
    93 #define smc_coherence(a)                write_barrier()
    94 #define smc_coherence_block(a, l)       write_barrier()
     93#define smc_coherence(a)           write_barrier()
     94#define smc_coherence_block(a, l)  write_barrier()
    9595
    9696#endif
  • kernel/arch/ia32/include/cpuid.h

    rdeca67b radd04f7  
    7575       
    7676        asm volatile (
    77                 "pushf\n"               /* read flags */
    78                 "popl %0\n"
    79                 "movl %0, %1\n"
     77                "pushf\n"                    /* read flags */
     78                "popl %[ret]\n"
     79                "movl %[ret], %[val]\n"
    8080               
    81                 "btcl $21, %1\n"        /* swap the ID bit */
     81                "btcl $21, %[val]\n"         /* swap the ID bit */
    8282               
    83                 "pushl %1\n"            /* propagate the change into flags */
     83                "pushl %[val]\n"             /* propagate the change into flags */
    8484                "popf\n"
    8585                "pushf\n"
    86                 "popl %1\n"
     86                "popl %[val]\n"
    8787               
    88                 "andl $(1 << 21), %0\n" /* interrested only in ID bit */
    89                 "andl $(1 << 21), %1\n"
    90                 "xorl %1, %0\n"
    91                 : "=r" (ret), "=r" (val)
     88                "andl $(1 << 21), %[ret]\n" /* interrested only in ID bit */
     89                "andl $(1 << 21), %[val]\n"
     90                "xorl %[val], %[ret]\n"
     91                : [ret] "=r" (ret), [val] "=r" (val)
    9292        );
    9393       
     
    9999        asm volatile (
    100100                "cpuid\n"
    101                 : "=a" (info->cpuid_eax), "=b" (info->cpuid_ebx), "=c" (info->cpuid_ecx), "=d" (info->cpuid_edx)
     101                : "=a" (info->cpuid_eax), "=b" (info->cpuid_ebx),
     102                  "=c" (info->cpuid_ecx), "=d" (info->cpuid_edx)
    102103                : "a" (cmd)
    103104        );
  • 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
  • kernel/test/fpu/sse1.c

    rdeca67b radd04f7  
    5959        for (i = 0; i < ATTEMPTS; i++) {
    6060                asm volatile (
    61                         "movlpd %0, %%xmm2\n"
    62                         : "=m" (arg)
     61                        "movlpd %[arg], %%xmm2\n"
     62                        : [arg] "=m" (arg)
    6363                );
    6464
    6565                delay(DELAY);
    6666                asm volatile (
    67                         "movlpd %%xmm2, %0\n"
    68                         : "=m" (after_arg)
     67                        "movlpd %%xmm2, %[after_arg]\n"
     68                        : [after_arg] "=m" (after_arg)
    6969                );
    7070               
     
    9191        for (i = 0; i < ATTEMPTS; i++) {
    9292                asm volatile (
    93                         "movlpd %0, %%xmm2\n"
    94                         : "=m" (arg)
     93                        "movlpd %[arg], %%xmm2\n"
     94                        : [arg] "=m" (arg)
    9595                );
    9696
    9797                scheduler();
    9898                asm volatile (
    99                         "movlpd %%xmm2, %0\n"
    100                         : "=m" (after_arg)
     99                        "movlpd %%xmm2, %[after_arg]\n"
     100                        : [after_arg] "=m" (after_arg)
    101101                );
    102102               
Note: See TracChangeset for help on using the changeset viewer.