Changeset e7b7be3f in mainline for kernel/arch/ia32/include
- Timestamp:
- 2007-01-22T13:10:08Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f3fc9b
- Parents:
- 62c63fc
- Location:
- kernel/arch/ia32/include
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/include/asm.h
r62c63fc re7b7be3f 58 58 * Halt the current CPU until interrupt event. 59 59 */ 60 static inline void cpu_halt(void) { __asm__("hlt\n"); }; 61 static inline void cpu_sleep(void) { __asm__("hlt\n"); }; 60 static inline void cpu_halt(void) 61 { 62 asm("hlt\n"); 63 }; 64 65 static inline void cpu_sleep(void) 66 { 67 asm("hlt\n"); 68 }; 62 69 63 70 #define GEN_READ_REG(reg) static inline unative_t read_ ##reg (void) \ 64 71 { \ 65 72 unative_t res; \ 66 __asm__volatile ("movl %%" #reg ", %0" : "=r" (res) ); \73 asm volatile ("movl %%" #reg ", %0" : "=r" (res) ); \ 67 74 return res; \ 68 75 } … … 70 77 #define GEN_WRITE_REG(reg) static inline void write_ ##reg (unative_t regn) \ 71 78 { \ 72 __asm__volatile ("movl %0, %%" #reg : : "r" (regn)); \79 asm volatile ("movl %0, %%" #reg : : "r" (regn)); \ 73 80 } 74 81 … … 99 106 * @param val Value to write 100 107 */ 101 static inline void outb(uint16_t port, uint8_t val) { __asm__ volatile ("outb %b0, %w1\n" : : "a" (val), "d" (port) ); } 108 static inline void outb(uint16_t port, uint8_t val) 109 { 110 asm volatile ("outb %b0, %w1\n" : : "a" (val), "d" (port) ); 111 } 102 112 103 113 /** Word to port … … 108 118 * @param val Value to write 109 119 */ 110 static inline void outw(uint16_t port, uint16_t val) { __asm__ volatile ("outw %w0, %w1\n" : : "a" (val), "d" (port) ); } 120 static inline void outw(uint16_t port, uint16_t val) 121 { 122 asm volatile ("outw %w0, %w1\n" : : "a" (val), "d" (port) ); 123 } 111 124 112 125 /** Double word to port … … 117 130 * @param val Value to write 118 131 */ 119 static inline void outl(uint16_t port, uint32_t val) { __asm__ volatile ("outl %l0, %w1\n" : : "a" (val), "d" (port) ); } 132 static inline void outl(uint16_t port, uint32_t val) 133 { 134 asm volatile ("outl %l0, %w1\n" : : "a" (val), "d" (port) ); 135 } 120 136 121 137 /** Byte from port … … 126 142 * @return Value read 127 143 */ 128 static inline uint8_t inb(uint16_t port) { uint8_t val; __asm__ volatile ("inb %w1, %b0 \n" : "=a" (val) : "d" (port) ); return val; } 144 static inline uint8_t inb(uint16_t port) 145 { 146 uint8_t val; 147 148 asm volatile ("inb %w1, %b0 \n" : "=a" (val) : "d" (port) ); 149 return val; 150 } 129 151 130 152 /** Word from port … … 135 157 * @return Value read 136 158 */ 137 static inline uint16_t inw(uint16_t port) { uint16_t val; __asm__ volatile ("inw %w1, %w0 \n" : "=a" (val) : "d" (port) ); return val; } 159 static inline uint16_t inw(uint16_t port) 160 { 161 uint16_t val; 162 163 asm volatile ("inw %w1, %w0 \n" : "=a" (val) : "d" (port) ); 164 return val; 165 } 138 166 139 167 /** Double word from port … … 144 172 * @return Value read 145 173 */ 146 static inline uint32_t inl(uint16_t port) { uint32_t val; __asm__ volatile ("inl %w1, %l0 \n" : "=a" (val) : "d" (port) ); return val; } 174 static inline uint32_t inl(uint16_t port) 175 { 176 uint32_t val; 177 178 asm volatile ("inl %w1, %l0 \n" : "=a" (val) : "d" (port) ); 179 return val; 180 } 147 181 148 182 /** Enable interrupts. … … 156 190 { 157 191 ipl_t v; 158 __asm__volatile (192 asm volatile ( 159 193 "pushf\n\t" 160 194 "popl %0\n\t" … … 175 209 { 176 210 ipl_t v; 177 __asm__volatile (211 asm volatile ( 178 212 "pushf\n\t" 179 213 "popl %0\n\t" … … 192 226 static inline void interrupts_restore(ipl_t ipl) 193 227 { 194 __asm__volatile (228 asm volatile ( 195 229 "pushl %0\n\t" 196 230 "popf\n" … … 206 240 { 207 241 ipl_t v; 208 __asm__volatile (242 asm volatile ( 209 243 "pushf\n\t" 210 244 "popl %0\n" … … 224 258 uintptr_t v; 225 259 226 __asm__volatile ("andl %%esp, %0\n" : "=r" (v) : "0" (~(STACK_SIZE-1)));260 asm volatile ("andl %%esp, %0\n" : "=r" (v) : "0" (~(STACK_SIZE-1))); 227 261 228 262 return v; … … 234 268 uintptr_t *ip; 235 269 236 __asm__volatile (270 asm volatile ( 237 271 "mov %%eip, %0" 238 272 : "=r" (ip) … … 247 281 static inline void invlpg(uintptr_t addr) 248 282 { 249 __asm__volatile ("invlpg %0\n" :: "m" (*(unative_t *)addr));283 asm volatile ("invlpg %0\n" :: "m" (*(unative_t *)addr)); 250 284 } 251 285 … … 256 290 static inline void gdtr_load(ptr_16_32_t *gdtr_reg) 257 291 { 258 __asm__volatile ("lgdtl %0\n" : : "m" (*gdtr_reg));292 asm volatile ("lgdtl %0\n" : : "m" (*gdtr_reg)); 259 293 } 260 294 … … 265 299 static inline void gdtr_store(ptr_16_32_t *gdtr_reg) 266 300 { 267 __asm__volatile ("sgdtl %0\n" : : "m" (*gdtr_reg));301 asm volatile ("sgdtl %0\n" : : "m" (*gdtr_reg)); 268 302 } 269 303 … … 274 308 static inline void idtr_load(ptr_16_32_t *idtr_reg) 275 309 { 276 __asm__volatile ("lidtl %0\n" : : "m" (*idtr_reg));310 asm volatile ("lidtl %0\n" : : "m" (*idtr_reg)); 277 311 } 278 312 … … 283 317 static inline void tr_load(uint16_t sel) 284 318 { 285 __asm__volatile ("ltr %0" : : "r" (sel));319 asm volatile ("ltr %0" : : "r" (sel)); 286 320 } 287 321 -
kernel/arch/ia32/include/atomic.h
r62c63fc re7b7be3f 43 43 static inline void atomic_inc(atomic_t *val) { 44 44 #ifdef CONFIG_SMP 45 __asm__volatile ("lock incl %0\n" : "=m" (val->count));45 asm volatile ("lock incl %0\n" : "=m" (val->count)); 46 46 #else 47 __asm__volatile ("incl %0\n" : "=m" (val->count));47 asm volatile ("incl %0\n" : "=m" (val->count)); 48 48 #endif /* CONFIG_SMP */ 49 49 } … … 51 51 static inline void atomic_dec(atomic_t *val) { 52 52 #ifdef CONFIG_SMP 53 __asm__volatile ("lock decl %0\n" : "=m" (val->count));53 asm volatile ("lock decl %0\n" : "=m" (val->count)); 54 54 #else 55 __asm__volatile ("decl %0\n" : "=m" (val->count));55 asm volatile ("decl %0\n" : "=m" (val->count)); 56 56 #endif /* CONFIG_SMP */ 57 57 } … … 61 61 long r = 1; 62 62 63 __asm__volatile (63 asm volatile ( 64 64 "lock xaddl %1, %0\n" 65 65 : "=m" (val->count), "+r" (r) … … 73 73 long r = -1; 74 74 75 __asm__volatile (75 asm volatile ( 76 76 "lock xaddl %1, %0\n" 77 77 : "=m" (val->count), "+r"(r) … … 87 87 uint32_t v; 88 88 89 __asm__volatile (89 asm volatile ( 90 90 "movl $1, %0\n" 91 91 "xchgl %0, %1\n" … … 102 102 103 103 preemption_disable(); 104 __asm__volatile (104 asm volatile ( 105 105 "0:;" 106 106 #ifdef CONFIG_HT -
kernel/arch/ia32/include/barrier.h
r62c63fc re7b7be3f 47 47 */ 48 48 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") 51 51 52 52 static inline void cpuid_serialization(void) 53 53 { 54 __asm__volatile (54 asm volatile ( 55 55 "xorl %%eax, %%eax\n" 56 56 "cpuid\n" … … 60 60 61 61 #ifdef CONFIG_FENCES_P4 62 # define memory_barrier() __asm__volatile ("mfence\n" ::: "memory")63 # define read_barrier() __asm__volatile ("lfence\n" ::: "memory")62 # define memory_barrier() asm volatile ("mfence\n" ::: "memory") 63 # define read_barrier() asm volatile ("lfence\n" ::: "memory") 64 64 # ifdef CONFIG_WEAK_MEMORY 65 # define write_barrier() __asm__volatile ("sfence\n" ::: "memory")65 # define write_barrier() asm volatile ("sfence\n" ::: "memory") 66 66 # else 67 # define write_barrier() __asm__volatile( "" ::: "memory");67 # define write_barrier() asm volatile( "" ::: "memory"); 68 68 # endif 69 69 #elif CONFIG_FENCES_P3 … … 71 71 # define read_barrier() cpuid_serialization() 72 72 # ifdef CONFIG_WEAK_MEMORY 73 # define write_barrier() __asm__volatile ("sfence\n" ::: "memory")73 # define write_barrier() asm volatile ("sfence\n" ::: "memory") 74 74 # else 75 # define write_barrier() __asm__volatile( "" ::: "memory");75 # define write_barrier() asm volatile( "" ::: "memory"); 76 76 # endif 77 77 #else … … 81 81 # define write_barrier() cpuid_serialization() 82 82 # else 83 # define write_barrier() __asm__volatile( "" ::: "memory");83 # define write_barrier() asm volatile( "" ::: "memory"); 84 84 # endif 85 85 #endif -
kernel/arch/ia32/include/cpuid.h
r62c63fc re7b7be3f 77 77 uint32_t val, ret; 78 78 79 __asm__volatile (79 asm volatile ( 80 80 "pushf\n" /* read flags */ 81 81 "popl %0\n" … … 100 100 static inline void cpuid(uint32_t cmd, cpu_info_t *info) 101 101 { 102 __asm__volatile (102 asm volatile ( 103 103 "movl %4, %%eax\n" 104 104 "cpuid\n" -
kernel/arch/ia32/include/memstr.h
r62c63fc re7b7be3f 52 52 unative_t d0, d1, d2; 53 53 54 __asm__ __volatile__(54 asm volatile( 55 55 /* copy all full dwords */ 56 56 "rep movsl\n\t" … … 89 89 int ret; 90 90 91 __asm__(91 asm ( 92 92 "repe cmpsb\n\t" 93 93 "je 1f\n\t" … … 115 115 uint32_t d0, d1; 116 116 117 __asm__ __volatile__(117 asm volatile ( 118 118 "rep stosw\n\t" 119 119 : "=&D" (d0), "=&c" (d1), "=a" (x) … … 137 137 uint32_t d0, d1; 138 138 139 __asm__ __volatile__(139 asm volatile ( 140 140 "rep stosb\n\t" 141 141 : "=&D" (d0), "=&c" (d1), "=a" (x)
Note:
See TracChangeset
for help on using the changeset viewer.