Changeset e7b7be3f in mainline for kernel/arch/ia32/include/asm.h
- Timestamp:
- 2007-01-22T13:10:08Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f3fc9b
- Parents:
- 62c63fc
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.