Changeset d6dcdd2e in mainline


Ignore:
Timestamp:
2005-09-13T21:20:56Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
01e48c1
Parents:
b1cf98c
Message:

Optimize some assembler functions.

Location:
arch
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/asm.h

    rb1cf98c rd6dcdd2e  
    5252}
    5353
    54 static inline void cpu_sleep(void) { __asm__ volatile ("hlt"); };
    55 static inline void cpu_halt(void) { __asm__ volatile ("hlt"); };
     54static inline void cpu_sleep(void) { __asm__ volatile ("hlt\n"); };
     55static inline void cpu_halt(void) { __asm__ volatile ("hlt\n"); };
    5656
    5757
     
    6161
    6262        __asm__ volatile (
    63                 "mov %1, %%dx;"
    64                 "inb %%dx,%%al;"
    65                 "mov %%al, %0;"
     63                "mov %1, %%dx\n"
     64                "inb %%dx,%%al\n"
     65                "mov %%al, %0\n"
    6666                :"=m"(out)
    6767                :"m"(port)
     
    7474{
    7575        __asm__ volatile (
    76                 "mov %0,%%dx;"
    77                 "mov %1,%%al;"
    78                 "outb %%al,%%dx;"
     76                "mov %0,%%dx\n"
     77                "mov %1,%%al\n"
     78                "outb %%al,%%dx\n"
    7979                :
    8080                :"m"( port), "m" (b)
     
    150150{
    151151        __u64 v;
    152         __asm__ volatile ("movq %%cr0,%0" : "=r" (v));
     152        __asm__ volatile ("movq %%cr0,%0\n" : "=r" (v));
    153153        return v;
    154154}
     
    163163{
    164164        __u64 v;
    165         __asm__ volatile ("movq %%cr2,%0" : "=r" (v));
     165        __asm__ volatile ("movq %%cr2,%0\n" : "=r" (v));
    166166        return v;
    167167}
     
    199199{
    200200        __asm__ volatile (
    201                 "movl $0x1b, %%ecx;"
    202                 "rdmsr;"
    203                 "orl $(1<<11),%%eax;"
    204                 "orl $(0xfee00000),%%eax;"
    205                 "wrmsr;"
     201                "movl $0x1b, %%ecx\n"
     202                "rdmsr\n"
     203                "orl $(1<<11),%%eax\n"
     204                "orl $(0xfee00000),%%eax\n"
     205                "wrmsr\n"
    206206                :
    207207                :
  • arch/amd64/src/asm_utils.S

    rb1cf98c rd6dcdd2e  
    7676#
    7777has_cpuid:
    78         pushq %rbx
    79        
    8078        pushfq                  # store flags
    8179        popq %rax               # read flags
    82         movq %rax,%rbx          # copy flags
    83         btcl $21,%ebx           # swap the ID bit
    84         pushq %rbx
     80        movq %rax,%rdx          # copy flags
     81        btcl $21,%edx           # swap the ID bit
     82        pushq %rdx
    8583        popfq                   # propagate the change into flags
    8684        pushfq
    87         popq %rbx               # read flags   
     85        popq %rdx               # read flags   
    8886        andl $(1<<21),%eax      # interested only in ID bit
    89         andl $(1<<21),%ebx
    90         xorl %ebx,%eax          # 0 if not supported, 1 if supported
    91        
    92         popq %rbx
     87        andl $(1<<21),%edx
     88        xorl %edx,%eax          # 0 if not supported, 1 if supported
    9389        ret
    9490
  • arch/ia32/include/asm.h

    rb1cf98c rd6dcdd2e  
    3131
    3232#include <arch/types.h>
    33 #include <typedefs.h>
    34 #include <config.h>
    35 #include <synch/spinlock.h>
    36 #include <arch/boot/memmap.h>
    3733#include <config.h>
    3834
     
    6258 * Halt the current CPU until interrupt event.
    6359 */
    64 static inline void cpu_halt(void) { __asm__("hlt"); };
    65 static inline void cpu_sleep(void) { __asm__("hlt"); };
     60static inline void cpu_halt(void) { __asm__("hlt\n"); };
     61static inline void cpu_sleep(void) { __asm__("hlt\n"); };
    6662
    6763/** Read CR2
     
    7167 * @return Value read.
    7268 */
    73 static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0" : "=r" (v)); return v; }
     69static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0\n" : "=r" (v)); return v; }
    7470
    7571/** Write CR3
     
    8783 * @return Value read.
    8884 */
    89 static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0" : "=r" (v)); return v; }
     85static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0\n" : "=r" (v)); return v; }
    9086
    9187/** Set priority level low
     
    162158}
    163159
     160static inline __u64 rdtsc(void)
     161{
     162        __u64 v;
     163       
     164        __asm__ volatile("rdtsc\n" : "=A" (v));
     165       
     166        return v;
     167}
     168
    164169#endif
  • arch/ia32/include/cpuid.h

    rb1cf98c rd6dcdd2e  
    4040
    4141extern int has_cpuid(void);
    42 extern void cpuid(__u32 cmd, cpu_info_t *info);
    4342
    44 extern __u64 rdtsc(void);
     43static inline void cpuid(__u32 cmd, struct cpu_info *info)
     44{
     45        __asm__ volatile (
     46                "movl %4, %%eax\n"
     47                "cpuid\n"
     48                "movl %%eax,%0\n"
     49                "movl %%ebx,%1\n"
     50                "movl %%ecx,%2\n"
     51                "movl %%edx,%3\n"
     52                : "=m" (info->cpuid_eax), "=m" (info->cpuid_ebx), "=m" (info->cpuid_ecx), "=m" (info->cpuid_edx)
     53                : "m" (cmd)
     54                : "eax", "ebx", "ecx", "edx"
     55        );
     56}
    4557
    4658#endif
  • arch/ia32/src/cpuid.s

    rb1cf98c rd6dcdd2e  
    2727#
    2828
    29 # The code below just interfaces the CPUID instruction.
    30 # CPU recognition logic is contained in higher-level functions.
    31 
    3229.text
    3330
    3431.global has_cpuid
    35 .global cpuid
    36 .global rdtsc
    3732
    3833
    3934## Determine CPUID support
    4035#
    41 # Return 0 in EAX if CPUID is not support, 1 if supported.
     36# Return 0 in EAX if CPUID is not supported, 1 if supported.
    4237#
    4338has_cpuid:
    44         push %ebx
    45        
    4639        pushf                   # store flags
    4740        popl %eax               # read flags
    48         movl %eax,%ebx          # copy flags
    49         btcl $21,%ebx           # swap the ID bit
    50         pushl %ebx
     41        movl %eax,%edx          # copy flags
     42        btcl $21,%edx           # swap the ID bit
     43        pushl %edx
    5144        popf                    # propagate the change into flags
    5245        pushf
    53         popl %ebx               # read flags   
     46        popl %edx               # read flags   
    5447        andl $(1<<21),%eax      # interested only in ID bit
    55         andl $(1<<21),%ebx
    56         xorl %ebx,%eax          # 0 if not supported, 1 if supported
    57        
    58         pop %ebx
     48        andl $(1<<21),%edx
     49        xorl %edx,%eax          # 0 if not supported, 1 if supported
    5950        ret
    60 
    61 
    62 ## Get CPUID data
    63 #
    64 # This code is just an interfaces the CPUID instruction, CPU recognition
    65 # logic is contained in higher-level functions.
    66 #
    67 # The C prototype is:
    68 #   void cpuid(__u32 cmd, struct cpu_info *info)
    69 #
    70 # @param cmd  CPUID command.
    71 # @param info Buffer to store CPUID output.
    72 #
    73 cpuid:
    74         pushl %ebp
    75         movl %esp,%ebp
    76         pusha
    77 
    78         movl 8(%ebp),%eax       # load the command into %eax
    79         movl 12(%ebp),%esi      # laod the address of the info struct
    80 
    81         cpuid   
    82         movl %eax,0(%esi)
    83         movl %ebx,4(%esi)
    84         movl %ecx,8(%esi)
    85         movl %edx,12(%esi)
    86 
    87         popa
    88         popl %ebp
    89         ret
    90 
    91 rdtsc:
    92         rdtsc
    93         ret
  • arch/ia32/src/delay.s

    rb1cf98c rd6dcdd2e  
    3737
    3838asm_delay_loop:
    39         pushl %ecx
    40         movl 8(%esp),%ecx       # move argument to %ecx
     39        movl 4(%esp),%ecx       # move argument to %ecx
    41400:      lahf
    4241        dec %ecx
    4342        jnz 0b
    44         popl %ecx
    4543        ret
    4644
    4745asm_fake_loop:
    48         pushl %ecx
    49         movl 8(%esp),%ecx       # move argument to %ecx
     46        movl 4(%esp),%ecx       # move argument to %ecx
    50470:      lahf
    5148        dec %ecx
    5249        jz 0b
    53         popl %ecx
    5450        ret
Note: See TracChangeset for help on using the changeset viewer.