Changeset d6dcdd2e in mainline
- Timestamp:
- 2005-09-13T21:20:56Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 01e48c1
- Parents:
- b1cf98c
- Location:
- arch
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/asm.h
rb1cf98c rd6dcdd2e 52 52 } 53 53 54 static inline void cpu_sleep(void) { __asm__ volatile ("hlt "); };55 static inline void cpu_halt(void) { __asm__ volatile ("hlt "); };54 static inline void cpu_sleep(void) { __asm__ volatile ("hlt\n"); }; 55 static inline void cpu_halt(void) { __asm__ volatile ("hlt\n"); }; 56 56 57 57 … … 61 61 62 62 __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" 66 66 :"=m"(out) 67 67 :"m"(port) … … 74 74 { 75 75 __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" 79 79 : 80 80 :"m"( port), "m" (b) … … 150 150 { 151 151 __u64 v; 152 __asm__ volatile ("movq %%cr0,%0 " : "=r" (v));152 __asm__ volatile ("movq %%cr0,%0\n" : "=r" (v)); 153 153 return v; 154 154 } … … 163 163 { 164 164 __u64 v; 165 __asm__ volatile ("movq %%cr2,%0 " : "=r" (v));165 __asm__ volatile ("movq %%cr2,%0\n" : "=r" (v)); 166 166 return v; 167 167 } … … 199 199 { 200 200 __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" 206 206 : 207 207 : -
arch/amd64/src/asm_utils.S
rb1cf98c rd6dcdd2e 76 76 # 77 77 has_cpuid: 78 pushq %rbx79 80 78 pushfq # store flags 81 79 popq %rax # read flags 82 movq %rax,%r bx # copy flags83 btcl $21,%e bx # swap the ID bit84 pushq %r bx80 movq %rax,%rdx # copy flags 81 btcl $21,%edx # swap the ID bit 82 pushq %rdx 85 83 popfq # propagate the change into flags 86 84 pushfq 87 popq %r bx # read flags85 popq %rdx # read flags 88 86 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 93 89 ret 94 90 -
arch/ia32/include/asm.h
rb1cf98c rd6dcdd2e 31 31 32 32 #include <arch/types.h> 33 #include <typedefs.h>34 #include <config.h>35 #include <synch/spinlock.h>36 #include <arch/boot/memmap.h>37 33 #include <config.h> 38 34 … … 62 58 * Halt the current CPU until interrupt event. 63 59 */ 64 static inline void cpu_halt(void) { __asm__("hlt "); };65 static inline void cpu_sleep(void) { __asm__("hlt "); };60 static inline void cpu_halt(void) { __asm__("hlt\n"); }; 61 static inline void cpu_sleep(void) { __asm__("hlt\n"); }; 66 62 67 63 /** Read CR2 … … 71 67 * @return Value read. 72 68 */ 73 static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0 " : "=r" (v)); return v; }69 static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0\n" : "=r" (v)); return v; } 74 70 75 71 /** Write CR3 … … 87 83 * @return Value read. 88 84 */ 89 static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0 " : "=r" (v)); return v; }85 static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0\n" : "=r" (v)); return v; } 90 86 91 87 /** Set priority level low … … 162 158 } 163 159 160 static inline __u64 rdtsc(void) 161 { 162 __u64 v; 163 164 __asm__ volatile("rdtsc\n" : "=A" (v)); 165 166 return v; 167 } 168 164 169 #endif -
arch/ia32/include/cpuid.h
rb1cf98c rd6dcdd2e 40 40 41 41 extern int has_cpuid(void); 42 extern void cpuid(__u32 cmd, cpu_info_t *info);43 42 44 extern __u64 rdtsc(void); 43 static 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 } 45 57 46 58 #endif -
arch/ia32/src/cpuid.s
rb1cf98c rd6dcdd2e 27 27 # 28 28 29 # The code below just interfaces the CPUID instruction.30 # CPU recognition logic is contained in higher-level functions.31 32 29 .text 33 30 34 31 .global has_cpuid 35 .global cpuid36 .global rdtsc37 32 38 33 39 34 ## Determine CPUID support 40 35 # 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. 42 37 # 43 38 has_cpuid: 44 push %ebx45 46 39 pushf # store flags 47 40 popl %eax # read flags 48 movl %eax,%e bx # copy flags49 btcl $21,%e bx # swap the ID bit50 pushl %e bx41 movl %eax,%edx # copy flags 42 btcl $21,%edx # swap the ID bit 43 pushl %edx 51 44 popf # propagate the change into flags 52 45 pushf 53 popl %e bx # read flags46 popl %edx # read flags 54 47 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 59 50 ret 60 61 62 ## Get CPUID data63 #64 # This code is just an interfaces the CPUID instruction, CPU recognition65 # 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 %ebp75 movl %esp,%ebp76 pusha77 78 movl 8(%ebp),%eax # load the command into %eax79 movl 12(%ebp),%esi # laod the address of the info struct80 81 cpuid82 movl %eax,0(%esi)83 movl %ebx,4(%esi)84 movl %ecx,8(%esi)85 movl %edx,12(%esi)86 87 popa88 popl %ebp89 ret90 91 rdtsc:92 rdtsc93 ret -
arch/ia32/src/delay.s
rb1cf98c rd6dcdd2e 37 37 38 38 asm_delay_loop: 39 pushl %ecx 40 movl 8(%esp),%ecx # move argument to %ecx 39 movl 4(%esp),%ecx # move argument to %ecx 41 40 0: lahf 42 41 dec %ecx 43 42 jnz 0b 44 popl %ecx45 43 ret 46 44 47 45 asm_fake_loop: 48 pushl %ecx 49 movl 8(%esp),%ecx # move argument to %ecx 46 movl 4(%esp),%ecx # move argument to %ecx 50 47 0: lahf 51 48 dec %ecx 52 49 jz 0b 53 popl %ecx54 50 ret
Note:
See TracChangeset
for help on using the changeset viewer.