Changes in kernel/arch/ia64/include/asm.h [7a0359b:a1d89ad] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/include/asm.h
r7a0359b ra1d89ad 27 27 */ 28 28 29 /** @addtogroup ia64 29 /** @addtogroup ia64 30 30 * @{ 31 31 */ … … 38 38 #include <config.h> 39 39 #include <typedefs.h> 40 #include < typedefs.h>40 #include <arch/types.h> 41 41 #include <arch/register.h> 42 #include <trace.h> 43 44 #define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL 45 46 NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v) 47 { 48 uintptr_t prt = (uintptr_t) port; 49 50 *((ioport8_t *) (IA64_IOSPACE_ADDRESS + 42 43 #define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL 44 45 static inline void pio_write_8(ioport8_t *port, uint8_t v) 46 { 47 uintptr_t prt = (uintptr_t) port; 48 49 *((ioport8_t *)(IA64_IOSPACE_ADDRESS + 51 50 ((prt & 0xfff) | ((prt >> 2) << 12)))) = v; 52 53 asm volatile ( 54 "mf\n" 55 ::: "memory" 56 ); 57 } 58 59 NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v) 60 { 61 uintptr_t prt = (uintptr_t) port; 62 63 *((ioport16_t *) (IA64_IOSPACE_ADDRESS + 51 52 asm volatile ("mf\n" ::: "memory"); 53 } 54 55 static inline void pio_write_16(ioport16_t *port, uint16_t v) 56 { 57 uintptr_t prt = (uintptr_t) port; 58 59 *((ioport16_t *)(IA64_IOSPACE_ADDRESS + 64 60 ((prt & 0xfff) | ((prt >> 2) << 12)))) = v; 65 66 asm volatile ( 67 "mf\n" 68 ::: "memory" 69 ); 70 } 71 72 NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v) 73 { 74 uintptr_t prt = (uintptr_t) port; 75 76 *((ioport32_t *) (IA64_IOSPACE_ADDRESS + 61 62 asm volatile ("mf\n" ::: "memory"); 63 } 64 65 static inline void pio_write_32(ioport32_t *port, uint32_t v) 66 { 67 uintptr_t prt = (uintptr_t) port; 68 69 *((ioport32_t *)(IA64_IOSPACE_ADDRESS + 77 70 ((prt & 0xfff) | ((prt >> 2) << 12)))) = v; 78 79 asm volatile ( 80 "mf\n" 81 ::: "memory" 82 ); 83 } 84 85 NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port) 86 { 87 uintptr_t prt = (uintptr_t) port; 88 89 asm volatile ( 90 "mf\n" 91 ::: "memory" 92 ); 93 94 return *((ioport8_t *) (IA64_IOSPACE_ADDRESS + 71 72 asm volatile ("mf\n" ::: "memory"); 73 } 74 75 static inline uint8_t pio_read_8(ioport8_t *port) 76 { 77 uintptr_t prt = (uintptr_t) port; 78 79 asm volatile ("mf\n" ::: "memory"); 80 81 return *((ioport8_t *)(IA64_IOSPACE_ADDRESS + 95 82 ((prt & 0xfff) | ((prt >> 2) << 12)))); 96 83 } 97 84 98 NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port) 99 { 100 uintptr_t prt = (uintptr_t) port; 101 102 asm volatile ( 103 "mf\n" 104 ::: "memory" 105 ); 106 107 return *((ioport16_t *) (IA64_IOSPACE_ADDRESS + 85 static inline uint16_t pio_read_16(ioport16_t *port) 86 { 87 uintptr_t prt = (uintptr_t) port; 88 89 asm volatile ("mf\n" ::: "memory"); 90 91 return *((ioport16_t *)(IA64_IOSPACE_ADDRESS + 108 92 ((prt & 0xfff) | ((prt >> 2) << 12)))); 109 93 } 110 94 111 NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port) 112 { 113 uintptr_t prt = (uintptr_t) port; 114 115 asm volatile ( 116 "mf\n" 117 ::: "memory" 118 ); 119 120 return *((ioport32_t *) (IA64_IOSPACE_ADDRESS + 95 static inline uint32_t pio_read_32(ioport32_t *port) 96 { 97 uintptr_t prt = (uintptr_t) port; 98 99 asm volatile ("mf\n" ::: "memory"); 100 101 return *((ioport32_t *)(IA64_IOSPACE_ADDRESS + 121 102 ((prt & 0xfff) | ((prt >> 2) << 12)))); 122 103 } … … 127 108 * The stack is assumed to be STACK_SIZE long. 128 109 * The stack must start on page boundary. 129 * 130 */ 131 NO_TRACE static inline uintptr_t get_stack_base(void) 132 { 133 uint64_t v; 134 135 /* 136 * I'm not sure why but this code inlines badly 137 * in scheduler, resulting in THE shifting about 138 * 16B and causing kernel panic. 139 * 140 * asm volatile ( 141 * "and %[value] = %[mask], r12" 142 * : [value] "=r" (v) 143 * : [mask] "r" (~(STACK_SIZE - 1)) 144 * ); 145 * return v; 146 * 147 * The following code has the same semantics but 148 * inlines correctly. 149 * 150 */ 151 152 asm volatile ( 153 "mov %[value] = r12" 154 : [value] "=r" (v) 155 ); 156 157 return (v & (~(STACK_SIZE - 1))); 110 */ 111 static inline uintptr_t get_stack_base(void) 112 { 113 uint64_t v; 114 115 //I'm not sure why but this code bad inlines in scheduler, 116 //so THE shifts about 16B and causes kernel panic 117 //asm volatile ("and %0 = %1, r12" : "=r" (v) : "r" (~(STACK_SIZE-1))); 118 //return v; 119 120 //this code have the same meaning but inlines well 121 asm volatile ("mov %0 = r12" : "=r" (v) ); 122 return v & (~(STACK_SIZE-1)); 158 123 } 159 124 … … 161 126 * 162 127 * @return PSR. 163 * 164 */ 165 NO_TRACE static inline uint64_t psr_read(void) 166 { 167 uint64_t v; 168 169 asm volatile ( 170 "mov %[value] = psr\n" 171 : [value] "=r" (v) 172 ); 128 */ 129 static inline uint64_t psr_read(void) 130 { 131 uint64_t v; 132 133 asm volatile ("mov %0 = psr\n" : "=r" (v)); 173 134 174 135 return v; … … 178 139 * 179 140 * @return Return location of interruption vector table. 180 * 181 */ 182 NO_TRACE static inline uint64_t iva_read(void) 183 { 184 uint64_t v; 185 186 asm volatile ( 187 "mov %[value] = cr.iva\n" 188 : [value] "=r" (v) 189 ); 141 */ 142 static inline uint64_t iva_read(void) 143 { 144 uint64_t v; 145 146 asm volatile ("mov %0 = cr.iva\n" : "=r" (v)); 190 147 191 148 return v; … … 195 152 * 196 153 * @param v New location of interruption vector table. 197 * 198 */ 199 NO_TRACE static inline void iva_write(uint64_t v) 200 { 201 asm volatile ( 202 "mov cr.iva = %[value]\n" 203 :: [value] "r" (v) 204 ); 205 } 154 */ 155 static inline void iva_write(uint64_t v) 156 { 157 asm volatile ("mov cr.iva = %0\n" : : "r" (v)); 158 } 159 206 160 207 161 /** Read IVR (External Interrupt Vector Register). 208 162 * 209 * @return Highest priority, pending, unmasked external 210 * interrupt vector. 211 * 212 */ 213 NO_TRACE static inline uint64_t ivr_read(void) 214 { 215 uint64_t v; 216 217 asm volatile ( 218 "mov %[value] = cr.ivr\n" 219 : [value] "=r" (v) 220 ); 221 222 return v; 223 } 224 225 NO_TRACE static inline uint64_t cr64_read(void) 226 { 227 uint64_t v; 228 229 asm volatile ( 230 "mov %[value] = cr64\n" 231 : [value] "=r" (v) 232 ); 233 234 return v; 235 } 163 * @return Highest priority, pending, unmasked external interrupt vector. 164 */ 165 static inline uint64_t ivr_read(void) 166 { 167 uint64_t v; 168 169 asm volatile ("mov %0 = cr.ivr\n" : "=r" (v)); 170 171 return v; 172 } 173 174 static inline uint64_t cr64_read(void) 175 { 176 uint64_t v; 177 178 asm volatile ("mov %0 = cr64\n" : "=r" (v)); 179 180 return v; 181 } 182 236 183 237 184 /** Write ITC (Interval Timer Counter) register. 238 185 * 239 186 * @param v New counter value. 240 * 241 */ 242 NO_TRACE static inline void itc_write(uint64_t v) 243 { 244 asm volatile ( 245 "mov ar.itc = %[value]\n" 246 :: [value] "r" (v) 247 ); 187 */ 188 static inline void itc_write(uint64_t v) 189 { 190 asm volatile ("mov ar.itc = %0\n" : : "r" (v)); 248 191 } 249 192 … … 251 194 * 252 195 * @return Current counter value. 253 * 254 */ 255 NO_TRACE static inline uint64_t itc_read(void) 256 { 257 uint64_t v; 258 259 asm volatile ( 260 "mov %[value] = ar.itc\n" 261 : [value] "=r" (v) 262 ); 196 */ 197 static inline uint64_t itc_read(void) 198 { 199 uint64_t v; 200 201 asm volatile ("mov %0 = ar.itc\n" : "=r" (v)); 263 202 264 203 return v; … … 268 207 * 269 208 * @param v New match value. 270 * 271 */ 272 NO_TRACE static inline void itm_write(uint64_t v) 273 { 274 asm volatile ( 275 "mov cr.itm = %[value]\n" 276 :: [value] "r" (v) 277 ); 209 */ 210 static inline void itm_write(uint64_t v) 211 { 212 asm volatile ("mov cr.itm = %0\n" : : "r" (v)); 278 213 } 279 214 … … 281 216 * 282 217 * @return Match value. 283 * 284 */ 285 NO_TRACE static inline uint64_t itm_read(void) 286 { 287 uint64_t v; 288 289 asm volatile ( 290 "mov %[value] = cr.itm\n" 291 : [value] "=r" (v) 292 ); 218 */ 219 static inline uint64_t itm_read(void) 220 { 221 uint64_t v; 222 223 asm volatile ("mov %0 = cr.itm\n" : "=r" (v)); 293 224 294 225 return v; … … 298 229 * 299 230 * @return Current vector and mask bit. 300 * 301 */ 302 NO_TRACE static inline uint64_t itv_read(void) 303 { 304 uint64_t v; 305 306 asm volatile ( 307 "mov %[value] = cr.itv\n" 308 : [value] "=r" (v) 309 ); 231 */ 232 static inline uint64_t itv_read(void) 233 { 234 uint64_t v; 235 236 asm volatile ("mov %0 = cr.itv\n" : "=r" (v)); 310 237 311 238 return v; … … 315 242 * 316 243 * @param v New vector and mask bit. 317 * 318 */ 319 NO_TRACE static inline void itv_write(uint64_t v) 320 { 321 asm volatile ( 322 "mov cr.itv = %[value]\n" 323 :: [value] "r" (v) 324 ); 244 */ 245 static inline void itv_write(uint64_t v) 246 { 247 asm volatile ("mov cr.itv = %0\n" : : "r" (v)); 325 248 } 326 249 … … 328 251 * 329 252 * @param v This value is ignored. 330 * 331 */ 332 NO_TRACE static inline void eoi_write(uint64_t v) 333 { 334 asm volatile ( 335 "mov cr.eoi = %[value]\n" 336 :: [value] "r" (v) 337 ); 253 */ 254 static inline void eoi_write(uint64_t v) 255 { 256 asm volatile ("mov cr.eoi = %0\n" : : "r" (v)); 338 257 } 339 258 … … 341 260 * 342 261 * @return Current value of TPR. 343 * 344 */ 345 NO_TRACE static inline uint64_t tpr_read(void) 346 { 347 uint64_t v; 348 349 asm volatile ( 350 "mov %[value] = cr.tpr\n" 351 : [value] "=r" (v) 352 ); 262 */ 263 static inline uint64_t tpr_read(void) 264 { 265 uint64_t v; 266 267 asm volatile ("mov %0 = cr.tpr\n" : "=r" (v)); 353 268 354 269 return v; … … 358 273 * 359 274 * @param v New value of TPR. 360 * 361 */ 362 NO_TRACE static inline void tpr_write(uint64_t v) 363 { 364 asm volatile ( 365 "mov cr.tpr = %[value]\n" 366 :: [value] "r" (v) 367 ); 275 */ 276 static inline void tpr_write(uint64_t v) 277 { 278 asm volatile ("mov cr.tpr = %0\n" : : "r" (v)); 368 279 } 369 280 … … 374 285 * 375 286 * @return Old interrupt priority level. 376 * 377 */ 378 NO_TRACE static ipl_t interrupts_disable(void) 287 */ 288 static ipl_t interrupts_disable(void) 379 289 { 380 290 uint64_t v; 381 291 382 292 asm volatile ( 383 "mov % [value]= psr\n"384 "rsm % [mask]\n"385 : [value]"=r" (v)386 : [mask]"i" (PSR_I_MASK)293 "mov %0 = psr\n" 294 "rsm %1\n" 295 : "=r" (v) 296 : "i" (PSR_I_MASK) 387 297 ); 388 298 … … 396 306 * 397 307 * @return Old interrupt priority level. 398 * 399 */ 400 NO_TRACE static ipl_t interrupts_enable(void) 308 */ 309 static ipl_t interrupts_enable(void) 401 310 { 402 311 uint64_t v; 403 312 404 313 asm volatile ( 405 "mov % [value]= psr\n"406 "ssm % [mask]\n"314 "mov %0 = psr\n" 315 "ssm %1\n" 407 316 ";;\n" 408 317 "srlz.d\n" 409 : [value]"=r" (v)410 : [mask]"i" (PSR_I_MASK)318 : "=r" (v) 319 : "i" (PSR_I_MASK) 411 320 ); 412 321 … … 419 328 * 420 329 * @param ipl Saved interrupt priority level. 421 * 422 */ 423 NO_TRACE static inline void interrupts_restore(ipl_t ipl) 330 */ 331 static inline void interrupts_restore(ipl_t ipl) 424 332 { 425 333 if (ipl & PSR_I_MASK) … … 432 340 * 433 341 * @return PSR. 434 * 435 */ 436 NO_TRACE static inline ipl_t interrupts_read(void) 342 */ 343 static inline ipl_t interrupts_read(void) 437 344 { 438 345 return (ipl_t) psr_read(); 439 346 } 440 347 441 /** Check interrupts state.442 *443 * @return True if interrupts are disabled.444 *445 */446 NO_TRACE static inline bool interrupts_disabled(void)447 {448 return !(psr_read() & PSR_I_MASK);449 }450 451 348 /** Disable protection key checking. */ 452 NO_TRACE static inline void pk_disable(void) 453 { 454 asm volatile ( 455 "rsm %[mask]\n" 456 ";;\n" 457 "srlz.d\n" 458 :: [mask] "i" (PSR_PK_MASK) 459 ); 460 } 461 462 extern void cpu_halt(void) __attribute__((noreturn)); 349 static inline void pk_disable(void) 350 { 351 asm volatile ("rsm %0\n" : : "i" (PSR_PK_MASK)); 352 } 353 354 extern void cpu_halt(void); 463 355 extern void cpu_sleep(void); 464 356 extern void asm_delay_loop(uint32_t t);
Note:
See TracChangeset
for help on using the changeset viewer.