Changeset 5bda2f3e in mainline
- Timestamp:
- 2009-09-04T18:06:24Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93d66ef
- Parents:
- 029d94a
- Location:
- kernel/arch/ia64
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/include/asm.h
r029d94a r5bda2f3e 27 27 */ 28 28 29 /** @addtogroup ia64 29 /** @addtogroup ia64 30 30 * @{ 31 31 */ … … 41 41 #include <arch/register.h> 42 42 43 #define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL43 #define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL 44 44 45 45 static inline void pio_write_8(ioport8_t *port, uint8_t v) 46 46 { 47 47 uintptr_t prt = (uintptr_t) port; 48 49 *((ioport8_t *) (IA64_IOSPACE_ADDRESS +48 49 *((ioport8_t *) (IA64_IOSPACE_ADDRESS + 50 50 ((prt & 0xfff) | ((prt >> 2) << 12)))) = v; 51 52 asm volatile ("mf\n" ::: "memory"); 51 52 asm volatile ( 53 "mf\n" 54 ::: "memory" 55 ); 53 56 } 54 57 … … 56 59 { 57 60 uintptr_t prt = (uintptr_t) port; 58 59 *((ioport16_t *) (IA64_IOSPACE_ADDRESS +61 62 *((ioport16_t *) (IA64_IOSPACE_ADDRESS + 60 63 ((prt & 0xfff) | ((prt >> 2) << 12)))) = v; 61 62 asm volatile ("mf\n" ::: "memory"); 64 65 asm volatile ( 66 "mf\n" 67 ::: "memory" 68 ); 63 69 } 64 70 … … 66 72 { 67 73 uintptr_t prt = (uintptr_t) port; 68 69 *((ioport32_t *) (IA64_IOSPACE_ADDRESS +74 75 *((ioport32_t *) (IA64_IOSPACE_ADDRESS + 70 76 ((prt & 0xfff) | ((prt >> 2) << 12)))) = v; 71 72 asm volatile ("mf\n" ::: "memory"); 77 78 asm volatile ( 79 "mf\n" 80 ::: "memory" 81 ); 73 82 } 74 83 … … 76 85 { 77 86 uintptr_t prt = (uintptr_t) port; 78 79 asm volatile ("mf\n" ::: "memory"); 80 81 return *((ioport8_t *)(IA64_IOSPACE_ADDRESS + 87 88 asm volatile ( 89 "mf\n" 90 ::: "memory" 91 ); 92 93 return *((ioport8_t *) (IA64_IOSPACE_ADDRESS + 82 94 ((prt & 0xfff) | ((prt >> 2) << 12)))); 83 95 } … … 86 98 { 87 99 uintptr_t prt = (uintptr_t) port; 88 89 asm volatile ("mf\n" ::: "memory"); 90 91 return *((ioport16_t *)(IA64_IOSPACE_ADDRESS + 100 101 asm volatile ( 102 "mf\n" 103 ::: "memory" 104 ); 105 106 return *((ioport16_t *) (IA64_IOSPACE_ADDRESS + 92 107 ((prt & 0xfff) | ((prt >> 2) << 12)))); 93 108 } … … 96 111 { 97 112 uintptr_t prt = (uintptr_t) port; 98 99 asm volatile ("mf\n" ::: "memory"); 100 101 return *((ioport32_t *)(IA64_IOSPACE_ADDRESS + 113 114 asm volatile ( 115 "mf\n" 116 ::: "memory" 117 ); 118 119 return *((ioport32_t *) (IA64_IOSPACE_ADDRESS + 102 120 ((prt & 0xfff) | ((prt >> 2) << 12)))); 103 121 } … … 112 130 { 113 131 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)); 132 133 /* I'm not sure why but this code bad inlines in scheduler, 134 so THE shifts about 16B and causes kernel panic 135 136 asm volatile ( 137 "and %[value] = %[mask], r12" 138 : [value] "=r" (v) 139 : [mask] "r" (~(STACK_SIZE - 1)) 140 ); 141 return v; 142 143 This code have the same meaning but inlines well. 144 */ 145 146 asm volatile ( 147 "mov %[value] = r12" 148 : [value] "=r" (v) 149 ); 150 151 return (v & (~(STACK_SIZE - 1))); 123 152 } 124 153 … … 131 160 uint64_t v; 132 161 133 asm volatile ("mov %0 = psr\n" : "=r" (v)); 162 asm volatile ( 163 "mov %[value] = psr\n" 164 : [value] "=r" (v) 165 ); 134 166 135 167 return v; … … 144 176 uint64_t v; 145 177 146 asm volatile ("mov %0 = cr.iva\n" : "=r" (v)); 178 asm volatile ( 179 "mov %[value] = cr.iva\n" 180 : [value] "=r" (v) 181 ); 147 182 148 183 return v; … … 155 190 static inline void iva_write(uint64_t v) 156 191 { 157 asm volatile ("mov cr.iva = %0\n" : : "r" (v)); 192 asm volatile ( 193 "mov cr.iva = %[value]\n" 194 :: [value] "r" (v) 195 ); 158 196 } 159 197 … … 167 205 uint64_t v; 168 206 169 asm volatile ("mov %0 = cr.ivr\n" : "=r" (v)); 207 asm volatile ( 208 "mov %[value] = cr.ivr\n" 209 : [value] "=r" (v) 210 ); 170 211 171 212 return v; … … 176 217 uint64_t v; 177 218 178 asm volatile ("mov %0 = cr64\n" : "=r" (v)); 219 asm volatile ( 220 "mov %[value] = cr64\n" 221 : [value] "=r" (v) 222 ); 179 223 180 224 return v; … … 188 232 static inline void itc_write(uint64_t v) 189 233 { 190 asm volatile ("mov ar.itc = %0\n" : : "r" (v)); 234 asm volatile ( 235 "mov ar.itc = %[value]\n" 236 :: [value] "r" (v) 237 ); 191 238 } 192 239 … … 199 246 uint64_t v; 200 247 201 asm volatile ("mov %0 = ar.itc\n" : "=r" (v)); 248 asm volatile ( 249 "mov %[value] = ar.itc\n" 250 : [value] "=r" (v) 251 ); 202 252 203 253 return v; … … 210 260 static inline void itm_write(uint64_t v) 211 261 { 212 asm volatile ("mov cr.itm = %0\n" : : "r" (v)); 262 asm volatile ( 263 "mov cr.itm = %[value]\n" 264 :: [value] "r" (v) 265 ); 213 266 } 214 267 … … 221 274 uint64_t v; 222 275 223 asm volatile ("mov %0 = cr.itm\n" : "=r" (v)); 276 asm volatile ( 277 "mov %[value] = cr.itm\n" 278 : [value] "=r" (v) 279 ); 224 280 225 281 return v; … … 234 290 uint64_t v; 235 291 236 asm volatile ("mov %0 = cr.itv\n" : "=r" (v)); 292 asm volatile ( 293 "mov %[value] = cr.itv\n" 294 : [value] "=r" (v) 295 ); 237 296 238 297 return v; … … 245 304 static inline void itv_write(uint64_t v) 246 305 { 247 asm volatile ("mov cr.itv = %0\n" : : "r" (v)); 306 asm volatile ( 307 "mov cr.itv = %[value]\n" 308 :: [value] "r" (v) 309 ); 248 310 } 249 311 … … 254 316 static inline void eoi_write(uint64_t v) 255 317 { 256 asm volatile ("mov cr.eoi = %0\n" : : "r" (v)); 318 asm volatile ( 319 "mov cr.eoi = %[value]\n" 320 :: [value] "r" (v) 321 ); 257 322 } 258 323 … … 264 329 { 265 330 uint64_t v; 266 267 asm volatile ("mov %0 = cr.tpr\n" : "=r" (v)); 331 332 asm volatile ( 333 "mov %[value] = cr.tpr\n" 334 : [value] "=r" (v) 335 ); 268 336 269 337 return v; … … 276 344 static inline void tpr_write(uint64_t v) 277 345 { 278 asm volatile ("mov cr.tpr = %0\n" : : "r" (v)); 346 asm volatile ( 347 "mov cr.tpr = %[value]\n" 348 :: [value] "r" (v) 349 ); 279 350 } 280 351 … … 291 362 292 363 asm volatile ( 293 "mov % 0= psr\n"294 "rsm % 1\n"295 : "=r" (v)296 : "i" (PSR_I_MASK)364 "mov %[value] = psr\n" 365 "rsm %[mask]\n" 366 : [value] "=r" (v) 367 : [mask] "i" (PSR_I_MASK) 297 368 ); 298 369 … … 312 383 313 384 asm volatile ( 314 "mov % 0= psr\n"315 "ssm % 1\n"385 "mov %[value] = psr\n" 386 "ssm %[mask]\n" 316 387 ";;\n" 317 388 "srlz.d\n" 318 : "=r" (v)319 : "i" (PSR_I_MASK)389 : [value] "=r" (v) 390 : [mask] "i" (PSR_I_MASK) 320 391 ); 321 392 … … 349 420 static inline void pk_disable(void) 350 421 { 351 asm volatile ("rsm %0\n" : : "i" (PSR_PK_MASK)); 422 asm volatile ( 423 "rsm %[mask]\n" 424 :: [mask] "i" (PSR_PK_MASK) 425 ); 352 426 } 353 427 -
kernel/arch/ia64/include/interrupt.h
r029d94a r5bda2f3e 40 40 41 41 /** ia64 has 256 INRs. */ 42 #define INR_COUNT 42 #define INR_COUNT 256 43 43 44 44 /* … … 47 47 * to genarch. 48 48 */ 49 #define IVT_ITEMS 50 #define IVT_FIRST 49 #define IVT_ITEMS 0 50 #define IVT_FIRST 0 51 51 52 52 /** External Interrupt vectors. */ 53 53 54 #define VECTOR_TLB_SHOOTDOWN_IPI 0xf0 55 #define INTERRUPT_TIMER 255 56 #define IRQ_KBD (0x01 + LEGACY_INTERRUPT_BASE) 57 #define IRQ_MOUSE (0x0c + LEGACY_INTERRUPT_BASE) 58 #define INTERRUPT_SPURIOUS 15 59 #define LEGACY_INTERRUPT_BASE 0x20 54 #define VECTOR_TLB_SHOOTDOWN_IPI 0xf0 55 56 #define INTERRUPT_SPURIOUS 15 57 #define INTERRUPT_TIMER 255 58 59 #define LEGACY_INTERRUPT_BASE 0x20 60 61 #define IRQ_KBD (0x01 + LEGACY_INTERRUPT_BASE) 62 #define IRQ_MOUSE (0x0c + LEGACY_INTERRUPT_BASE) 60 63 61 64 /** General Exception codes. */ 62 #define GE_ILLEGALOP 63 #define GE_PRIVOP 64 #define GE_PRIVREG 65 #define GE_RESREGFLD 66 #define GE_DISBLDISTRAN 67 #define GE_ILLEGALDEP 65 #define GE_ILLEGALOP 0 66 #define GE_PRIVOP 1 67 #define GE_PRIVREG 2 68 #define GE_RESREGFLD 3 69 #define GE_DISBLDISTRAN 4 70 #define GE_ILLEGALDEP 8 68 71 69 #define EOI 0/**< The actual value doesn't matter. */72 #define EOI 0 /**< The actual value doesn't matter. */ 70 73 71 74 typedef struct { … … 100 103 uint128_t f30; 101 104 uint128_t f31; 102 105 103 106 uintptr_t ar_bsp; 104 107 uintptr_t ar_bspstore; … … 132 135 { 133 136 istate->cr_iip = retaddr; 134 istate->cr_ipsr.ri = 0; 137 istate->cr_ipsr.ri = 0; /* return to instruction slot #0 */ 135 138 } 136 139 -
kernel/arch/ia64/include/mm/as.h
r029d94a r5bda2f3e 27 27 */ 28 28 29 /** @addtogroup ia64mm 29 /** @addtogroup ia64mm 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia64_AS_H_ 37 37 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 39 39 40 #define KERNEL_ADDRESS_SPACE_START_ARCH (unsigned long) 0xe000000000000000ULL41 #define KERNEL_ADDRESS_SPACE_END_ARCH (unsigned long) 0xffffffffffffffffULL42 #define USER_ADDRESS_SPACE_START_ARCH (unsigned long) 0x0000000000000000ULL43 #define USER_ADDRESS_SPACE_END_ARCH (unsigned long) 0xdfffffffffffffffULL40 #define KERNEL_ADDRESS_SPACE_START_ARCH ((unsigned long) 0xe000000000000000ULL) 41 #define KERNEL_ADDRESS_SPACE_END_ARCH ((unsigned long) 0xffffffffffffffffULL) 42 #define USER_ADDRESS_SPACE_START_ARCH ((unsigned long) 0x0000000000000000ULL) 43 #define USER_ADDRESS_SPACE_END_ARCH ((unsigned long) 0xdfffffffffffffffULL) 44 44 45 #define USTACK_ADDRESS_ARCH 45 #define USTACK_ADDRESS_ARCH 0x0000000ff0000000ULL 46 46 47 47 typedef struct { … … 50 50 #include <genarch/mm/as_ht.h> 51 51 52 #define as_constructor_arch(as, flags) 53 #define as_destructor_arch(as) 54 #define as_create_arch(as, flags) 52 #define as_constructor_arch(as, flags) (as != as) 53 #define as_destructor_arch(as) (as != as) 54 #define as_create_arch(as, flags) (as != as) 55 55 #define as_deinstall_arch(as) 56 56 #define as_invalidate_translation_cache(as, page, cnt) -
kernel/arch/ia64/include/mm/page.h
r029d94a r5bda2f3e 28 28 */ 29 29 30 /** @addtogroup ia64mm 30 /** @addtogroup ia64mm 31 31 * @{ 32 32 */ … … 39 39 #include <arch/mm/frame.h> 40 40 41 #define PAGE_SIZE 42 #define PAGE_WIDTH 41 #define PAGE_SIZE FRAME_SIZE 42 #define PAGE_WIDTH FRAME_WIDTH 43 43 44 44 #ifdef KERNEL 45 45 46 46 /** Bit width of the TLB-locked portion of kernel address space. */ 47 #define KERNEL_PAGE_WIDTH 28/* 256M */48 #define IO_PAGE_WIDTH 26/* 64M */49 #define FW_PAGE_WIDTH 28/* 256M */50 51 #define USPACE_IO_PAGE_WIDTH 12/* 4K */47 #define KERNEL_PAGE_WIDTH 28 /* 256M */ 48 #define IO_PAGE_WIDTH 26 /* 64M */ 49 #define FW_PAGE_WIDTH 28 /* 256M */ 50 51 #define USPACE_IO_PAGE_WIDTH 12 /* 4K */ 52 52 53 53 … … 59 59 60 60 /* Firmware area (bellow 4GB in phys mem) */ 61 #define FW_OFFSET 61 #define FW_OFFSET 0x00000000F0000000 62 62 /* Legacy IO space */ 63 #define IO_OFFSET 63 #define IO_OFFSET 0x0001000000000000 64 64 /* Videoram - now mapped to 0 as VGA text mode vram on 0xb8000 */ 65 #define VIO_OFFSET 66 67 68 #define PPN_SHIFT 69 70 #define VRN_SHIFT 71 #define VRN_MASK (7LL << VRN_SHIFT)72 #define VA2VRN(va) ((va)>>VRN_SHIFT)65 #define VIO_OFFSET 0x0002000000000000 66 67 68 #define PPN_SHIFT 12 69 70 #define VRN_SHIFT 61 71 #define VRN_MASK (7ULL << VRN_SHIFT) 72 #define VA2VRN(va) ((va) >> VRN_SHIFT) 73 73 74 74 #ifdef __ASM__ 75 #define VRN_KERNEL775 #define VRN_KERNEL 7 76 76 #else 77 #define VRN_KERNEL 7LL77 #define VRN_KERNEL 7ULL 78 78 #endif 79 79 80 #define REGION_REGISTERS 81 82 #define KA2PA(x) ((uintptr_t) (x- (VRN_KERNEL << VRN_SHIFT)))83 #define PA2KA(x) ((uintptr_t) (x+ (VRN_KERNEL << VRN_SHIFT)))84 85 #define VHPT_WIDTH 20/* 1M */86 #define VHPT_SIZE 87 88 #define PTA_BASE_SHIFT 80 #define REGION_REGISTERS 8 81 82 #define KA2PA(x) ((uintptr_t) ((x) - (VRN_KERNEL << VRN_SHIFT))) 83 #define PA2KA(x) ((uintptr_t) ((x) + (VRN_KERNEL << VRN_SHIFT))) 84 85 #define VHPT_WIDTH 20 /* 1M */ 86 #define VHPT_SIZE (1 << VHPT_WIDTH) 87 88 #define PTA_BASE_SHIFT 15 89 89 90 90 /** Memory Attributes. */ 91 #define MA_WRITEBACK 0x092 #define MA_UNCACHEABLE 0x491 #define MA_WRITEBACK 0x00 92 #define MA_UNCACHEABLE 0x04 93 93 94 94 /** Privilege Levels. Only the most and the least privileged ones are ever used. */ 95 #define PL_KERNEL 0x096 #define PL_USER 0x395 #define PL_KERNEL 0x00 96 #define PL_USER 0x03 97 97 98 98 /* Access Rigths. Only certain combinations are used by the kernel. */ 99 #define AR_READ 0x0100 #define AR_EXECUTE 0x1101 #define AR_WRITE 0x299 #define AR_READ 0x00 100 #define AR_EXECUTE 0x01 101 #define AR_WRITE 0x02 102 102 103 103 #ifndef __ASM__ … … 113 113 struct vhpt_tag_info { 114 114 unsigned long long tag : 63; 115 unsigned ti : 1;115 unsigned int ti : 1; 116 116 } __attribute__ ((packed)); 117 117 … … 123 123 struct vhpt_entry_present { 124 124 /* Word 0 */ 125 unsigned p : 1;126 unsigned : 1;127 unsigned ma : 3;128 unsigned a : 1;129 unsigned d : 1;130 unsigned pl : 2;131 unsigned ar : 3;125 unsigned int p : 1; 126 unsigned int : 1; 127 unsigned int ma : 3; 128 unsigned int a : 1; 129 unsigned int d : 1; 130 unsigned int pl : 2; 131 unsigned int ar : 3; 132 132 unsigned long long ppn : 38; 133 unsigned : 2;134 unsigned ed : 1;135 unsigned i g1 : 11;133 unsigned int : 2; 134 unsigned int ed : 1; 135 unsigned int ig1 : 11; 136 136 137 137 /* Word 1 */ 138 unsigned : 2;139 unsigned ps : 6;140 unsigned key : 24;141 unsigned : 32;138 unsigned int : 2; 139 unsigned int ps : 6; 140 unsigned int key : 24; 141 unsigned int : 32; 142 142 143 143 /* Word 2 */ 144 144 union vhpt_tag tag; 145 145 146 /* Word 3 */ 146 /* Word 3 */ 147 147 uint64_t ig3 : 64; 148 148 } __attribute__ ((packed)); … … 150 150 struct vhpt_entry_not_present { 151 151 /* Word 0 */ 152 unsigned p : 1;152 unsigned int p : 1; 153 153 unsigned long long ig0 : 52; 154 unsigned i g1 : 11;154 unsigned int ig1 : 11; 155 155 156 156 /* Word 1 */ 157 unsigned : 2;158 unsigned ps : 6;157 unsigned int : 2; 158 unsigned int ps : 6; 159 159 unsigned long long ig2 : 56; 160 160 161 161 /* Word 2 */ 162 162 union vhpt_tag tag; 163 163 164 /* Word 3 */ 164 /* Word 3 */ 165 165 uint64_t ig3 : 64; 166 166 } __attribute__ ((packed)); 167 167 168 typedef union vhpt_entry{168 typedef union { 169 169 struct vhpt_entry_present present; 170 170 struct vhpt_entry_not_present not_present; … … 173 173 174 174 struct region_register_map { 175 unsigned ve : 1;176 unsigned : 1;177 unsigned ps : 6;178 unsigned rid : 24;179 unsigned : 32;180 } __attribute__ ((packed)); 181 182 typedef union region_register{175 unsigned int ve : 1; 176 unsigned int : 1; 177 unsigned int ps : 6; 178 unsigned int rid : 24; 179 unsigned int : 32; 180 } __attribute__ ((packed)); 181 182 typedef union { 183 183 struct region_register_map map; 184 184 unsigned long long word; 185 } region_register ;185 } region_register_t; 186 186 187 187 struct pta_register_map { 188 unsigned ve : 1;189 unsigned : 1;190 unsigned size : 6;191 unsigned vf : 1;192 unsigned : 6;188 unsigned int ve : 1; 189 unsigned int : 1; 190 unsigned int size : 6; 191 unsigned int vf : 1; 192 unsigned int : 6; 193 193 unsigned long long base : 49; 194 194 } __attribute__ ((packed)); … … 197 197 struct pta_register_map map; 198 198 uint64_t word; 199 } pta_register ;199 } pta_register_t; 200 200 201 201 /** Return Translation Hashed Entry Address. … … 211 211 { 212 212 uint64_t ret; 213 214 asm volatile ("thash %0 = %1\n" : "=r" (ret) : "r" (va)); 215 213 214 asm volatile ( 215 "thash %[ret] = %[va]\n" 216 : [ret] "=r" (ret) 217 : [va] "r" (va) 218 ); 219 216 220 return ret; 217 221 } … … 229 233 { 230 234 uint64_t ret; 231 232 asm volatile ("ttag %0 = %1\n" : "=r" (ret) : "r" (va)); 233 235 236 asm volatile ( 237 "ttag %[ret] = %[va]\n" 238 : [ret] "=r" (ret) 239 : [va] "r" (va) 240 ); 241 234 242 return ret; 235 243 } … … 244 252 { 245 253 uint64_t ret; 254 246 255 ASSERT(i < REGION_REGISTERS); 247 asm volatile ("mov %0 = rr[%1]\n" : "=r" (ret) : "r" (i << VRN_SHIFT)); 256 257 asm volatile ( 258 "mov %[ret] = rr[%[index]]\n" 259 : [ret] "=r" (ret) 260 : [index] "r" (i << VRN_SHIFT) 261 ); 262 248 263 return ret; 249 264 } … … 257 272 { 258 273 ASSERT(i < REGION_REGISTERS); 259 asm volatile ( 260 "mov rr[%0] = %1\n" 261 : 262 : "r" (i << VRN_SHIFT), "r" (v) 263 ); 264 } 265 274 275 asm volatile ( 276 "mov rr[%[index]] = %[value]\n" 277 :: [index] "r" (i << VRN_SHIFT), 278 [value] "r" (v) 279 ); 280 } 281 266 282 /** Read Page Table Register. 267 283 * … … 272 288 uint64_t ret; 273 289 274 asm volatile ("mov %0 = cr.pta\n" : "=r" (ret)); 290 asm volatile ( 291 "mov %[ret] = cr.pta\n" 292 : [ret] "=r" (ret) 293 ); 275 294 276 295 return ret; … … 283 302 static inline void pta_write(uint64_t v) 284 303 { 285 asm volatile ("mov cr.pta = %0\n" : : "r" (v)); 304 asm volatile ( 305 "mov cr.pta = %[value]\n" 306 :: [value] "r" (v) 307 ); 286 308 } 287 309 -
kernel/arch/ia64/include/mm/tlb.h
r029d94a r5bda2f3e 27 27 */ 28 28 29 /** @addtogroup ia64mm 29 /** @addtogroup ia64mm 30 30 * @{ 31 31 */ … … 42 42 43 43 /** Data and instruction Translation Register indices. */ 44 #define DTR_KERNEL 45 #define ITR_KERNEL 46 #define DTR_KSTACK1 47 #define DTR_KSTACK2 44 #define DTR_KERNEL 0 45 #define ITR_KERNEL 0 46 #define DTR_KSTACK1 4 47 #define DTR_KSTACK2 5 48 48 49 49 /** Portion of TLB insertion format data structure. */ 50 union tlb_entry{50 typedef union { 51 51 uint64_t word[2]; 52 52 struct { 53 53 /* Word 0 */ 54 unsigned p : 1;/**< Present. */55 unsigned : 1;56 unsigned ma : 3;/**< Memory attribute. */57 unsigned a : 1;/**< Accessed. */58 unsigned d : 1;/**< Dirty. */59 unsigned pl : 2;/**< Privilege level. */60 unsigned ar : 3;/**< Access rights. */61 unsigned long long ppn : 38; 62 unsigned : 2;63 unsigned ed : 1;64 unsigned i g1 : 11;65 54 unsigned int p : 1; /**< Present. */ 55 unsigned int : 1; 56 unsigned int ma : 3; /**< Memory attribute. */ 57 unsigned int a : 1; /**< Accessed. */ 58 unsigned int d : 1; /**< Dirty. */ 59 unsigned int pl : 2; /**< Privilege level. */ 60 unsigned int ar : 3; /**< Access rights. */ 61 unsigned long long ppn : 38; /**< Physical Page Number, a.k.a. PFN. */ 62 unsigned int : 2; 63 unsigned int ed : 1; 64 unsigned int ig1 : 11; 65 66 66 /* Word 1 */ 67 unsigned : 2;68 unsigned ps : 6;/**< Page size will be 2^ps. */69 unsigned key : 24;/**< Protection key, unused. */70 unsigned : 32;67 unsigned int : 2; 68 unsigned int ps : 6; /**< Page size will be 2^ps. */ 69 unsigned int key : 24; /**< Protection key, unused. */ 70 unsigned int : 32; 71 71 } __attribute__ ((packed)); 72 } __attribute__ ((packed)); 73 typedef union tlb_entry tlb_entry_t; 72 } __attribute__ ((packed)) tlb_entry_t; 74 73 75 74 extern void tc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtc); -
kernel/arch/ia64/include/register.h
r029d94a r5bda2f3e 27 27 */ 28 28 29 /** @addtogroup ia64 29 /** @addtogroup ia64 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia64_REGISTER_H_ 37 37 38 #define CR_IVR_MASK 0xf 39 #define PSR_IC_MASK 0x2000 40 #define PSR_I_MASK 0x4000 41 #define PSR_PK_MASK 0x8000 42 43 #define PSR_DT_MASK (1 << 17) 44 #define PSR_RT_MASK (1 << 27) 45 46 #define PSR_DFL_MASK (1 << 18) 47 #define PSR_DFH_MASK (1 << 19) 48 49 #define PSR_IT_MASK 0x0000001000000000 50 51 #define PSR_CPL_SHIFT 32 52 #define PSR_CPL_MASK_SHIFTED 3 53 54 #define PFM_MASK (~0x3fffffffff) 55 56 #define RSC_MODE_MASK 3 57 #define RSC_PL_MASK 12 38 #define DCR_PP_MASK (1 << 0) 39 #define DCR_BE_MASK (1 << 1) 40 #define DCR_LC_MASK (1 << 2) 41 #define DCR_DM_MASK (1 << 8) 42 #define DCR_DP_MASK (1 << 9) 43 #define DCR_DK_MASK (1 << 10) 44 #define DCR_DX_MASK (1 << 11) 45 #define DCR_DR_MASK (1 << 12) 46 #define DCR_DA_MASK (1 << 13) 47 #define DCR_DD_MASK (1 << 14) 48 49 #define CR_IVR_MASK 0x0f 50 51 #define PSR_IC_MASK (1 << 13) 52 #define PSR_I_MASK (1 << 14) 53 #define PSR_PK_MASK (1 << 15) 54 #define PSR_DT_MASK (1 << 17) 55 #define PSR_DFL_MASK (1 << 18) 56 #define PSR_DFH_MASK (1 << 19) 57 #define PSR_RT_MASK (1 << 27) 58 #define PSR_IT_MASK (1 << 36) 59 60 #define PSR_CPL_SHIFT 32 61 #define PSR_CPL_MASK_SHIFTED 3 62 63 #define PFM_MASK (~0x3fffffffff) 64 65 #define RSC_MODE_MASK 3 66 #define RSC_PL_MASK 12 58 67 59 68 /** Application registers. */ 60 #define AR_KR0 61 #define AR_KR1 62 #define AR_KR2 63 #define AR_KR3 64 #define AR_KR4 65 #define AR_KR5 66 #define AR_KR6 67 #define AR_KR7 68 /* AR 8-15reserved */69 #define AR_RSC 70 #define AR_BSP 71 #define AR_BSPSTORE 72 #define AR_RNAT 73 /* AR 20 reserved */74 #define AR_FCR 75 /* AR 22-23reserved */76 #define AR_EFLAG 77 #define AR_CSD 78 #define AR_SSD 79 #define AR_CFLG 80 #define AR_FSR 81 #define AR_FIR 82 #define AR_FDR 83 /* AR 31 reserved */84 #define AR_CCV 85 /* AR 33-35reserved */86 #define AR_UNAT 87 /* AR 37-39reserved */88 #define AR_FPSR 89 /* AR 41-43reserved */90 #define AR_ITC 91 /* AR 45-47reserved */92 /* AR 48-63ignored */93 #define AR_PFS 94 #define AR_LC 95 #define AR_EC 96 /* AR 67-111reserved */97 /* AR 112-127ignored */69 #define AR_KR0 0 70 #define AR_KR1 1 71 #define AR_KR2 2 72 #define AR_KR3 3 73 #define AR_KR4 4 74 #define AR_KR5 5 75 #define AR_KR6 6 76 #define AR_KR7 7 77 /* ARs 8-15 are reserved */ 78 #define AR_RSC 16 79 #define AR_BSP 17 80 #define AR_BSPSTORE 18 81 #define AR_RNAT 19 82 /* AR 20 is reserved */ 83 #define AR_FCR 21 84 /* ARs 22-23 are reserved */ 85 #define AR_EFLAG 24 86 #define AR_CSD 25 87 #define AR_SSD 26 88 #define AR_CFLG 27 89 #define AR_FSR 28 90 #define AR_FIR 29 91 #define AR_FDR 30 92 /* AR 31 is reserved */ 93 #define AR_CCV 32 94 /* ARs 33-35 are reserved */ 95 #define AR_UNAT 36 96 /* ARs 37-39 are reserved */ 97 #define AR_FPSR 40 98 /* ARs 41-43 are reserved */ 99 #define AR_ITC 44 100 /* ARs 45-47 are reserved */ 101 /* ARs 48-63 are ignored */ 102 #define AR_PFS 64 103 #define AR_LC 65 104 #define AR_EC 66 105 /* ARs 67-111 are reserved */ 106 /* ARs 112-127 are ignored */ 98 107 99 108 /** Control registers. */ 100 #define CR_DCR 101 #define CR_ITM 102 #define CR_IVA 103 /* CR3-CR7 reserved */104 #define CR_PTA 105 /* CR9-CR15 reserved */106 #define CR_IPSR 107 #define CR_ISR 108 /* CR18 reserved */109 #define CR_IIP 110 #define CR_IFA 111 #define CR_ITIR 112 #define CR_IIPA 113 #define CR_IFS 114 #define CR_IIM 115 #define CR_IHA 116 /* CR26-CR63 reserved */117 #define CR_LID 118 #define CR_IVR 119 #define CR_TPR 120 #define CR_EOI 121 #define CR_IRR0 122 #define CR_IRR1 123 #define CR_IRR2 124 #define CR_IRR3 125 #define CR_ITV 126 #define CR_PMV 127 #define CR_CMCV 128 /* CR75-CR79 reserved */129 #define CR_LRR0 130 #define CR_LRR1 131 /* CR82-CR127 reserved */109 #define CR_DCR 0 110 #define CR_ITM 1 111 #define CR_IVA 2 112 /* CR3-CR7 are reserved */ 113 #define CR_PTA 8 114 /* CR9-CR15 are reserved */ 115 #define CR_IPSR 16 116 #define CR_ISR 17 117 /* CR18 is reserved */ 118 #define CR_IIP 19 119 #define CR_IFA 20 120 #define CR_ITIR 21 121 #define CR_IIPA 22 122 #define CR_IFS 23 123 #define CR_IIM 24 124 #define CR_IHA 25 125 /* CR26-CR63 are reserved */ 126 #define CR_LID 64 127 #define CR_IVR 65 128 #define CR_TPR 66 129 #define CR_EOI 67 130 #define CR_IRR0 68 131 #define CR_IRR1 69 132 #define CR_IRR2 70 133 #define CR_IRR3 71 134 #define CR_ITV 72 135 #define CR_PMV 73 136 #define CR_CMCV 74 137 /* CR75-CR79 are reserved */ 138 #define CR_LRR0 80 139 #define CR_LRR1 81 140 /* CR82-CR127 are reserved */ 132 141 133 142 #ifndef __ASM__ … … 136 145 137 146 /** Processor Status Register. */ 138 union psr { 139 uint64_t value; 140 struct { 141 unsigned : 1; 142 unsigned be : 1; /**< Big-Endian data accesses. */ 143 unsigned up : 1; /**< User Performance monitor enable. */ 144 unsigned ac : 1; /**< Alignment Check. */ 145 unsigned mfl : 1; /**< Lower floating-point register written. */ 146 unsigned mfh : 1; /**< Upper floating-point register written. */ 147 unsigned : 7; 148 unsigned ic : 1; /**< Interruption Collection. */ 149 unsigned i : 1; /**< Interrupt Bit. */ 150 unsigned pk : 1; /**< Protection Key enable. */ 151 unsigned : 1; 152 unsigned dt : 1; /**< Data address Translation. */ 153 unsigned dfl : 1; /**< Disabled Floating-point Low register set. */ 154 unsigned dfh : 1; /**< Disabled Floating-point High register set. */ 155 unsigned sp : 1; /**< Secure Performance monitors. */ 156 unsigned pp : 1; /**< Privileged Performance monitor enable. */ 157 unsigned di : 1; /**< Disable Instruction set transition. */ 158 unsigned si : 1; /**< Secure Interval timer. */ 159 unsigned db : 1; /**< Debug Breakpoint fault. */ 160 unsigned lp : 1; /**< Lower Privilege transfer trap. */ 161 unsigned tb : 1; /**< Taken Branch trap. */ 162 unsigned rt : 1; /**< Register Stack Translation. */ 163 unsigned : 4; 164 unsigned cpl : 2; /**< Current Privilege Level. */ 165 unsigned is : 1; /**< Instruction Set. */ 166 unsigned mc : 1; /**< Machine Check abort mask. */ 167 unsigned it : 1; /**< Instruction address Translation. */ 168 unsigned id : 1; /**< Instruction Debug fault disable. */ 169 unsigned da : 1; /**< Disable Data Access and Dirty-bit faults. */ 170 unsigned dd : 1; /**< Data Debug fault disable. */ 171 unsigned ss : 1; /**< Single Step enable. */ 172 unsigned ri : 2; /**< Restart Instruction. */ 173 unsigned ed : 1; /**< Exception Deferral. */ 174 unsigned bn : 1; /**< Register Bank. */ 175 unsigned ia : 1; /**< Disable Instruction Access-bit faults. */ 176 } __attribute__ ((packed)); 177 }; 178 typedef union psr psr_t; 147 typedef union { 148 uint64_t value; 149 struct { 150 unsigned int : 1; 151 unsigned int be : 1; /**< Big-Endian data accesses. */ 152 unsigned int up : 1; /**< User Performance monitor enable. */ 153 unsigned int ac : 1; /**< Alignment Check. */ 154 unsigned int mfl : 1; /**< Lower floating-point register written. */ 155 unsigned int mfh : 1; /**< Upper floating-point register written. */ 156 unsigned int : 7; 157 unsigned int ic : 1; /**< Interruption Collection. */ 158 unsigned int i : 1; /**< Interrupt Bit. */ 159 unsigned int pk : 1; /**< Protection Key enable. */ 160 unsigned int : 1; 161 unsigned int dt : 1; /**< Data address Translation. */ 162 unsigned int dfl : 1; /**< Disabled Floating-point Low register set. */ 163 unsigned int dfh : 1; /**< Disabled Floating-point High register set. */ 164 unsigned int sp : 1; /**< Secure Performance monitors. */ 165 unsigned int pp : 1; /**< Privileged Performance monitor enable. */ 166 unsigned int di : 1; /**< Disable Instruction set transition. */ 167 unsigned int si : 1; /**< Secure Interval timer. */ 168 unsigned int db : 1; /**< Debug Breakpoint fault. */ 169 unsigned int lp : 1; /**< Lower Privilege transfer trap. */ 170 unsigned int tb : 1; /**< Taken Branch trap. */ 171 unsigned int rt : 1; /**< Register Stack Translation. */ 172 unsigned int : 4; 173 unsigned int cpl : 2; /**< Current Privilege Level. */ 174 unsigned int is : 1; /**< Instruction Set. */ 175 unsigned int mc : 1; /**< Machine Check abort mask. */ 176 unsigned int it : 1; /**< Instruction address Translation. */ 177 unsigned int id : 1; /**< Instruction Debug fault disable. */ 178 unsigned int da : 1; /**< Disable Data Access and Dirty-bit faults. */ 179 unsigned int dd : 1; /**< Data Debug fault disable. */ 180 unsigned int ss : 1; /**< Single Step enable. */ 181 unsigned int ri : 2; /**< Restart Instruction. */ 182 unsigned int ed : 1; /**< Exception Deferral. */ 183 unsigned int bn : 1; /**< Register Bank. */ 184 unsigned int ia : 1; /**< Disable Instruction Access-bit faults. */ 185 } __attribute__ ((packed)); 186 } psr_t; 179 187 180 188 /** Register Stack Configuration Register */ 181 union rsc { 182 uint64_t value; 183 struct { 184 unsigned mode : 2; 185 unsigned pl : 2; /**< Privilege Level. */ 186 unsigned be : 1; /**< Big-endian. */ 187 unsigned : 11; 188 unsigned loadrs : 14; 189 } __attribute__ ((packed)); 190 }; 191 typedef union rsc rsc_t; 189 typedef union { 190 uint64_t value; 191 struct { 192 unsigned int mode : 2; 193 unsigned int pl : 2; /**< Privilege Level. */ 194 unsigned int be : 1; /**< Big-endian. */ 195 unsigned int : 11; 196 unsigned int loadrs : 14; 197 } __attribute__ ((packed)); 198 } rsc_t; 192 199 193 200 /** External Interrupt Vector Register */ 194 union cr_ivr { 195 uint8_t vector; 196 uint64_t value; 197 }; 198 199 typedef union cr_ivr cr_ivr_t; 201 typedef union { 202 uint8_t vector; 203 uint64_t value; 204 } cr_ivr_t; 200 205 201 206 /** Task Priority Register */ 202 union cr_tpr { 203 struct { 204 unsigned : 4; 205 unsigned mic: 4; /**< Mask Interrupt Class. */ 206 unsigned : 8; 207 unsigned mmi: 1; /**< Mask Maskable Interrupts. */ 208 } __attribute__ ((packed)); 209 uint64_t value; 210 }; 211 212 typedef union cr_tpr cr_tpr_t; 207 typedef union { 208 uint64_t value; 209 struct { 210 unsigned int : 4; 211 unsigned int mic: 4; /**< Mask Interrupt Class. */ 212 unsigned int : 8; 213 unsigned int mmi: 1; /**< Mask Maskable Interrupts. */ 214 } __attribute__ ((packed)); 215 } cr_tpr_t; 213 216 214 217 /** Interval Timer Vector */ 215 union cr_itv { 216 struct { 217 unsigned vector : 8; 218 unsigned : 4; 219 unsigned : 1; 220 unsigned : 3; 221 unsigned m : 1; /**< Mask. */ 222 } __attribute__ ((packed)); 223 uint64_t value; 224 }; 225 226 typedef union cr_itv cr_itv_t; 218 typedef union { 219 uint64_t value; 220 struct { 221 unsigned int vector : 8; 222 unsigned int : 4; 223 unsigned int : 1; 224 unsigned int : 3; 225 unsigned int m : 1; /**< Mask. */ 226 } __attribute__ ((packed)); 227 } cr_itv_t; 227 228 228 229 /** Interruption Status Register */ 229 union cr_isr { 230 typedef union { 231 uint64_t value; 230 232 struct { 231 233 union { 232 234 /** General Exception code field structuring. */ 235 uint16_t code; 233 236 struct { 234 unsigned ge_na : 4;235 unsigned ge_code : 4;237 unsigned int ge_na : 4; 238 unsigned int ge_code : 4; 236 239 } __attribute__ ((packed)); 237 uint16_t code;238 240 }; 239 241 uint8_t vector; 240 unsigned : 8; 241 unsigned x : 1; /**< Execute exception. */ 242 unsigned w : 1; /**< Write exception. */ 243 unsigned r : 1; /**< Read exception. */ 244 unsigned na : 1; /**< Non-access exception. */ 245 unsigned sp : 1; /**< Speculative load exception. */ 246 unsigned rs : 1; /**< Register stack. */ 247 unsigned ir : 1; /**< Incomplete Register frame. */ 248 unsigned ni : 1; /**< Nested Interruption. */ 249 unsigned so : 1; /**< IA-32 Supervisor Override. */ 250 unsigned ei : 2; /**< Excepting Instruction. */ 251 unsigned ed : 1; /**< Exception Deferral. */ 252 unsigned : 20; 253 } __attribute__ ((packed)); 254 uint64_t value; 255 }; 256 257 typedef union cr_isr cr_isr_t; 242 unsigned int : 8; 243 unsigned int x : 1; /**< Execute exception. */ 244 unsigned int w : 1; /**< Write exception. */ 245 unsigned int r : 1; /**< Read exception. */ 246 unsigned int na : 1; /**< Non-access exception. */ 247 unsigned int sp : 1; /**< Speculative load exception. */ 248 unsigned int rs : 1; /**< Register stack. */ 249 unsigned int ir : 1; /**< Incomplete Register frame. */ 250 unsigned int ni : 1; /**< Nested Interruption. */ 251 unsigned int so : 1; /**< IA-32 Supervisor Override. */ 252 unsigned int ei : 2; /**< Excepting Instruction. */ 253 unsigned int ed : 1; /**< Exception Deferral. */ 254 unsigned int : 20; 255 } __attribute__ ((packed)); 256 } cr_isr_t; 258 257 259 258 /** CPUID Register 3 */ 260 union cpuid3 { 259 typedef union { 260 uint64_t value; 261 261 struct { 262 262 uint8_t number; … … 266 266 uint8_t archrev; 267 267 } __attribute__ ((packed)); 268 uint64_t value; 269 }; 270 271 typedef union cpuid3 cpuid3_t; 268 } cpuid3_t; 272 269 273 270 #endif /* !__ASM__ */ -
kernel/arch/ia64/src/mm/as.c
r029d94a r5bda2f3e 55 55 void as_install_arch(as_t *as) 56 56 { 57 region_register rr;57 region_register_t rr; 58 58 int i; 59 59 -
kernel/arch/ia64/src/mm/page.c
r029d94a r5bda2f3e 63 63 void set_environment(void) 64 64 { 65 region_register rr;66 pta_register pta;65 region_register_t rr; 66 pta_register_t pta; 67 67 int i; 68 68 #ifdef CONFIG_VHPT … … 131 131 vhpt_entry_t *vhpt_hash(uintptr_t page, asid_t asid) 132 132 { 133 region_register rr_save, rr;133 region_register_t rr_save, rr; 134 134 size_t vrn; 135 135 rid_t rid; … … 176 176 bool vhpt_compare(uintptr_t page, asid_t asid, vhpt_entry_t *v) 177 177 { 178 region_register rr_save, rr;178 region_register_t rr_save, rr; 179 179 size_t vrn; 180 180 rid_t rid; … … 223 223 int flags) 224 224 { 225 region_register rr_save, rr;225 region_register_t rr_save, rr; 226 226 size_t vrn; 227 227 rid_t rid; … … 257 257 v->present.ma = (flags & PAGE_CACHEABLE) ? 258 258 MA_WRITEBACK : MA_UNCACHEABLE; 259 v->present.a = false; 260 v->present.d = false; 259 v->present.a = false; /* not accessed */ 260 v->present.d = false; /* not dirty */ 261 261 v->present.pl = (flags & PAGE_USER) ? PL_USER : PL_KERNEL; 262 262 v->present.ar = (flags & PAGE_WRITE) ? AR_WRITE : AR_READ; 263 263 v->present.ar |= (flags & PAGE_EXEC) ? AR_EXECUTE : 0; 264 264 v->present.ppn = frame >> PPN_SHIFT; 265 v->present.ed = false; 265 v->present.ed = false; /* exception not deffered */ 266 266 v->present.ps = PAGE_WIDTH; 267 267 v->present.key = 0; -
kernel/arch/ia64/src/mm/tlb.c
r029d94a r5bda2f3e 27 27 */ 28 28 29 /** @addtogroup ia64mm 29 /** @addtogroup ia64mm 30 30 * @{ 31 31 */ … … 53 53 #include <interrupt.h> 54 54 55 #define IO_FRAME_BASE 0xFFFFC000000 56 55 57 /** Invalidate all TLB entries. */ 56 58 void tlb_invalidate_all(void) … … 59 61 uintptr_t adr; 60 62 uint32_t count1, count2, stride1, stride2; 61 63 62 64 unsigned int i, j; 63 65 64 66 adr = PAL_PTCE_INFO_BASE(); 65 67 count1 = PAL_PTCE_INFO_COUNT1(); … … 67 69 stride1 = PAL_PTCE_INFO_STRIDE1(); 68 70 stride2 = PAL_PTCE_INFO_STRIDE2(); 69 71 70 72 ipl = interrupts_disable(); 71 73 72 74 for (i = 0; i < count1; i++) { 73 75 for (j = 0; j < count2; j++) { 74 76 asm volatile ( 75 "ptc.e %0 ;;" 76 : 77 : "r" (adr) 77 "ptc.e %[adr] ;;" 78 :: [adr] "r" (adr) 78 79 ); 79 80 adr += stride2; … … 81 82 adr += stride1; 82 83 } 83 84 84 85 interrupts_restore(ipl); 85 86 86 87 srlz_d(); 87 88 srlz_i(); 89 88 90 #ifdef CONFIG_VHPT 89 91 vhpt_invalidate_all(); 90 #endif 92 #endif 91 93 } 92 94 93 95 /** Invalidate entries belonging to an address space. 94 96 * 95 * @param asid Address space identifier. 97 * @param asid Address space identifier. 98 * 96 99 */ 97 100 void tlb_invalidate_asid(asid_t asid) … … 103 106 void tlb_invalidate_pages(asid_t asid, uintptr_t page, size_t cnt) 104 107 { 105 region_register rr;108 region_register_t rr; 106 109 bool restore_rr = false; 107 110 int b = 0; 108 111 int c = cnt; 109 112 110 113 uintptr_t va; 111 114 va = page; 112 115 113 116 rr.word = rr_read(VA2VRN(va)); 114 117 if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) { … … 117 120 * Save the old content of the register and replace the RID. 118 121 */ 119 region_register rr0;120 122 region_register_t rr0; 123 121 124 rr0 = rr; 122 125 rr0.map.rid = ASID2RID(asid, VA2VRN(va)); … … 126 129 } 127 130 128 while (c >>= 1)131 while (c >>= 1) 129 132 b++; 130 133 b >>= 1; … … 169 172 break; 170 173 } 171 for(; va < (page + cnt * PAGE_SIZE); va += (1 << ps)) 172 asm volatile ("ptc.l %0, %1;;" :: "r" (va), "r" (ps << 2)); 174 175 for (; va < (page + cnt * PAGE_SIZE); va += (1 << ps)) 176 asm volatile ( 177 "ptc.l %[va], %[ps] ;;" 178 :: [va]"r" (va), 179 [ps] "r" (ps << 2) 180 ); 181 173 182 srlz_d(); 174 183 srlz_i(); … … 183 192 /** Insert data into data translation cache. 184 193 * 185 * @param va Virtual page address. 186 * @param asid Address space identifier. 187 * @param entry The rest of TLB entry as required by TLB insertion 188 * format. 194 * @param va Virtual page address. 195 * @param asid Address space identifier. 196 * @param entry The rest of TLB entry as required by TLB insertion 197 * format. 198 * 189 199 */ 190 200 void dtc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry) … … 195 205 /** Insert data into instruction translation cache. 196 206 * 197 * @param va 198 * @param asid 199 * @param entry 200 * 207 * @param va Virtual page address. 208 * @param asid Address space identifier. 209 * @param entry The rest of TLB entry as required by TLB insertion 210 * format. 201 211 */ 202 212 void itc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry) … … 207 217 /** Insert data into instruction or data translation cache. 208 218 * 209 * @param va Virtual page address. 210 * @param asid Address space identifier. 211 * @param entry The rest of TLB entry as required by TLB insertion 212 * format. 213 * @param dtc If true, insert into data translation cache, use 214 * instruction translation cache otherwise. 219 * @param va Virtual page address. 220 * @param asid Address space identifier. 221 * @param entry The rest of TLB entry as required by TLB insertion 222 * format. 223 * @param dtc If true, insert into data translation cache, use 224 * instruction translation cache otherwise. 225 * 215 226 */ 216 227 void tc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtc) 217 228 { 218 region_register rr;229 region_register_t rr; 219 230 bool restore_rr = false; 220 231 221 232 rr.word = rr_read(VA2VRN(va)); 222 233 if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) { … … 225 236 * Save the old content of the register and replace the RID. 226 237 */ 227 region_register rr0;228 238 region_register_t rr0; 239 229 240 rr0 = rr; 230 241 rr0.map.rid = ASID2RID(asid, VA2VRN(va)); … … 235 246 236 247 asm volatile ( 237 "mov r8 = psr;;\n" 238 "rsm %0;;\n" /* PSR_IC_MASK */ 239 "srlz.d;;\n" 240 "srlz.i;;\n" 241 "mov cr.ifa = %1\n" /* va */ 242 "mov cr.itir = %2;;\n" /* entry.word[1] */ 243 "cmp.eq p6,p7 = %4,r0;;\n" /* decide between itc and dtc */ 244 "(p6) itc.i %3;;\n" 245 "(p7) itc.d %3;;\n" 246 "mov psr.l = r8;;\n" 247 "srlz.d;;\n" 248 : 249 : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]), 250 "r" (entry.word[0]), "r" (dtc) 248 "mov r8 = psr ;;\n" 249 "rsm %[mask] ;;\n" /* PSR_IC_MASK */ 250 "srlz.d ;;\n" 251 "srlz.i ;;\n" 252 "mov cr.ifa = %[va]\n" /* va */ 253 "mov cr.itir = %[word1] ;;\n" /* entry.word[1] */ 254 "cmp.eq p6, p7 = %[dtc], r0 ;;\n" /* decide between itc and dtc */ 255 "(p6) itc.i %[word0] ;;\n" 256 "(p7) itc.d %[word0] ;;\n" 257 "mov psr.l = r8 ;;\n" 258 "srlz.d ;;\n" 259 :: [mask] "i" (PSR_IC_MASK), 260 [va] "r" (va), 261 [word0] "r" (entry.word[0]), 262 [word1] "r" (entry.word[1]), 263 [dtc] "r" (dtc) 251 264 : "p6", "p7", "r8" 252 265 ); … … 261 274 /** Insert data into instruction translation register. 262 275 * 263 * @param va 264 * @param asid 265 * @param entry 266 * 267 * @param tr 268 * /269 void 270 itr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr)276 * @param va Virtual page address. 277 * @param asid Address space identifier. 278 * @param entry The rest of TLB entry as required by TLB insertion 279 * format. 280 * @param tr Translation register. 281 * 282 */ 283 void itr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr) 271 284 { 272 285 tr_mapping_insert(va, asid, entry, false, tr); … … 275 288 /** Insert data into data translation register. 276 289 * 277 * @param va 278 * @param asid 279 * @param entry 280 * 281 * @param tr 282 * /283 void 284 dtr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr)290 * @param va Virtual page address. 291 * @param asid Address space identifier. 292 * @param entry The rest of TLB entry as required by TLB insertion 293 * format. 294 * @param tr Translation register. 295 * 296 */ 297 void dtr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr) 285 298 { 286 299 tr_mapping_insert(va, asid, entry, true, tr); … … 289 302 /** Insert data into instruction or data translation register. 290 303 * 291 * @param va 292 * @param asid 293 * @param entry 294 * 295 * @param dtr 296 * 297 * @param tr 298 * /299 void 300 tr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtr,304 * @param va Virtual page address. 305 * @param asid Address space identifier. 306 * @param entry The rest of TLB entry as required by TLB insertion 307 * format. 308 * @param dtr If true, insert into data translation register, use 309 * instruction translation register otherwise. 310 * @param tr Translation register. 311 * 312 */ 313 void tr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtr, 301 314 size_t tr) 302 315 { 303 region_register rr;316 region_register_t rr; 304 317 bool restore_rr = false; 305 318 306 319 rr.word = rr_read(VA2VRN(va)); 307 320 if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) { … … 310 323 * Save the old content of the register and replace the RID. 311 324 */ 312 region_register rr0;313 325 region_register_t rr0; 326 314 327 rr0 = rr; 315 328 rr0.map.rid = ASID2RID(asid, VA2VRN(va)); … … 318 331 srlz_i(); 319 332 } 320 333 321 334 asm volatile ( 322 "mov r8 = psr;;\n" 323 "rsm %0;;\n" /* PSR_IC_MASK */ 324 "srlz.d;;\n" 325 "srlz.i;;\n" 326 "mov cr.ifa = %1\n" /* va */ 327 "mov cr.itir = %2;;\n" /* entry.word[1] */ 328 "cmp.eq p6,p7 = %5,r0;;\n" /* decide between itr and dtr */ 329 "(p6) itr.i itr[%4] = %3;;\n" 330 "(p7) itr.d dtr[%4] = %3;;\n" 331 "mov psr.l = r8;;\n" 332 "srlz.d;;\n" 333 : 334 : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]), 335 "r" (entry.word[0]), "r" (tr), "r" (dtr) 335 "mov r8 = psr ;;\n" 336 "rsm %[mask] ;;\n" /* PSR_IC_MASK */ 337 "srlz.d ;;\n" 338 "srlz.i ;;\n" 339 "mov cr.ifa = %[va]\n" /* va */ 340 "mov cr.itir = %[word1] ;;\n" /* entry.word[1] */ 341 "cmp.eq p6, p7 = %[dtr], r0 ;;\n" /* decide between itr and dtr */ 342 "(p6) itr.i itr[%[tr]] = %[word0] ;;\n" 343 "(p7) itr.d dtr[%[tr]] = %[word0] ;;\n" 344 "mov psr.l = r8 ;;\n" 345 "srlz.d ;;\n" 346 :: [mask] "i" (PSR_IC_MASK), 347 [va] "r" (va), 348 [word1] "r" (entry.word[1]), 349 [word0] "r" (entry.word[0]), 350 [tr] "r" (tr), 351 [dtr] "r" (dtr) 336 352 : "p6", "p7", "r8" 337 353 ); … … 346 362 /** Insert data into DTLB. 347 363 * 348 * @param page 349 * @param frame 350 * @param dtr 351 * 352 * @param tr 353 * /354 void 355 dtlb_kernel_mapping_insert(uintptr_t page, uintptr_t frame, bool dtr,364 * @param page Virtual page address including VRN bits. 365 * @param frame Physical frame address. 366 * @param dtr If true, insert into data translation register, use data 367 * translation cache otherwise. 368 * @param tr Translation register if dtr is true, ignored otherwise. 369 * 370 */ 371 void dtlb_kernel_mapping_insert(uintptr_t page, uintptr_t frame, bool dtr, 356 372 size_t tr) 357 373 { … … 361 377 entry.word[1] = 0; 362 378 363 entry.p = true; 379 entry.p = true; /* present */ 364 380 entry.ma = MA_WRITEBACK; 365 entry.a = true; 366 entry.d = true; 381 entry.a = true; /* already accessed */ 382 entry.d = true; /* already dirty */ 367 383 entry.pl = PL_KERNEL; 368 384 entry.ar = AR_READ | AR_WRITE; … … 380 396 * Purge DTR entries used by the kernel. 381 397 * 382 * @param page Virtual page address including VRN bits. 383 * @param width Width of the purge in bits. 398 * @param page Virtual page address including VRN bits. 399 * @param width Width of the purge in bits. 400 * 384 401 */ 385 402 void dtr_purge(uintptr_t page, size_t width) 386 403 { 387 asm volatile ("ptr.d %0, %1\n" : : "r" (page), "r" (width << 2)); 404 asm volatile ( 405 "ptr.d %[page], %[width]\n" 406 :: [page] "r" (page), 407 [width] "r" (width << 2) 408 ); 388 409 } 389 410 … … 391 412 /** Copy content of PTE into data translation cache. 392 413 * 393 * @param t PTE. 414 * @param t PTE. 415 * 394 416 */ 395 417 void dtc_pte_copy(pte_t *t) 396 418 { 397 419 tlb_entry_t entry; 398 420 399 421 entry.word[0] = 0; 400 422 entry.word[1] = 0; … … 410 432 411 433 dtc_mapping_insert(t->page, t->as->asid, entry); 434 412 435 #ifdef CONFIG_VHPT 413 436 vhpt_mapping_insert(t->page, t->as->asid, entry); 414 #endif 437 #endif 415 438 } 416 439 417 440 /** Copy content of PTE into instruction translation cache. 418 441 * 419 * @param t PTE. 442 * @param t PTE. 443 * 420 444 */ 421 445 void itc_pte_copy(pte_t *t) 422 446 { 423 447 tlb_entry_t entry; 424 448 425 449 entry.word[0] = 0; 426 450 entry.word[1] = 0; … … 437 461 438 462 itc_mapping_insert(t->page, t->as->asid, entry); 463 439 464 #ifdef CONFIG_VHPT 440 465 vhpt_mapping_insert(t->page, t->as->asid, entry); 441 #endif 466 #endif 442 467 } 443 468 444 469 /** Instruction TLB fault handler for faults with VHPT turned off. 445 470 * 446 * @param vector Interruption vector. 447 * @param istate Structure with saved interruption state. 471 * @param vector Interruption vector. 472 * @param istate Structure with saved interruption state. 473 * 448 474 */ 449 475 void alternate_instruction_tlb_fault(uint64_t vector, istate_t *istate) 450 476 { 451 region_register rr;477 region_register_t rr; 452 478 rid_t rid; 453 479 uintptr_t va; 454 480 pte_t *t; 455 481 456 va = istate->cr_ifa; 482 va = istate->cr_ifa; /* faulting address */ 457 483 rr.word = rr_read(VA2VRN(va)); 458 484 rid = rr.map.rid; 459 485 460 486 page_table_lock(AS, true); 461 487 t = page_mapping_find(AS, va); … … 473 499 page_table_unlock(AS, true); 474 500 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 475 fault_if_from_uspace(istate, "Page fault at %p.",va);501 fault_if_from_uspace(istate, "Page fault at %p.", va); 476 502 panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid, 477 503 istate->cr_iip); … … 488 514 } 489 515 490 #define IO_FRAME_BASE 0xFFFFC000000491 492 516 /** 493 517 * There is special handling of memory mapped legacy io, because of 4KB sized 494 518 * access for userspace. 495 519 * 496 * @param va Virtual address of page fault. 497 * @param istate Structure with saved interruption state. 498 * 499 * @return One on success, zero on failure. 520 * @param va Virtual address of page fault. 521 * @param istate Structure with saved interruption state. 522 * 523 * @return One on success, zero on failure. 524 * 500 525 */ 501 526 static int try_memmap_io_insertion(uintptr_t va, istate_t *istate) … … 505 530 uint64_t io_page = (va & ((1 << IO_PAGE_WIDTH) - 1)) >> 506 531 USPACE_IO_PAGE_WIDTH; 507 532 508 533 if (is_io_page_accessible(io_page)) { 509 534 uint64_t page, frame; 510 535 511 536 page = IO_OFFSET + 512 537 (1 << USPACE_IO_PAGE_WIDTH) * io_page; 513 538 frame = IO_FRAME_BASE + 514 539 (1 << USPACE_IO_PAGE_WIDTH) * io_page; 515 540 516 541 tlb_entry_t entry; 517 542 518 543 entry.word[0] = 0; 519 544 entry.word[1] = 0; 520 521 entry.p = true; 522 entry.ma = MA_UNCACHEABLE; 523 entry.a = true; 524 entry.d = true; 545 546 entry.p = true; /* present */ 547 entry.ma = MA_UNCACHEABLE; 548 entry.a = true; /* already accessed */ 549 entry.d = true; /* already dirty */ 525 550 entry.pl = PL_USER; 526 551 entry.ar = AR_READ | AR_WRITE; 527 552 entry.ppn = frame >> PPN_SHIFT; 528 553 entry.ps = USPACE_IO_PAGE_WIDTH; 529 554 530 555 dtc_mapping_insert(page, TASK->as->asid, entry); 531 556 return 1; … … 536 561 } 537 562 } 538 563 539 564 return 0; 540 565 } … … 542 567 /** Data TLB fault handler for faults with VHPT turned off. 543 568 * 544 * @param vector Interruption vector. 545 * @param istate Structure with saved interruption state. 569 * @param vector Interruption vector. 570 * @param istate Structure with saved interruption state. 571 * 546 572 */ 547 573 void alternate_data_tlb_fault(uint64_t vector, istate_t *istate) 548 574 { 549 region_register rr; 550 rid_t rid; 551 uintptr_t va; 552 pte_t *t; 553 554 va = istate->cr_ifa; /* faulting address */ 555 rr.word = rr_read(VA2VRN(va)); 556 rid = rr.map.rid; 575 uintptr_t va = istate->cr_ifa; /* faulting address */ 576 577 region_register_t rr; 578 rr.word = rr_read(VA2VRN(va)); 579 rid_t rid = rr.map.rid; 557 580 if (RID2ASID(rid) == ASID_KERNEL) { 558 581 if (VA2VRN(va) == VRN_KERNEL) { … … 565 588 } 566 589 } 567 590 591 568 592 page_table_lock(AS, true); 569 t= page_mapping_find(AS, va);570 if ( t) {593 pte_t *entry = page_mapping_find(AS, va); 594 if (entry) { 571 595 /* 572 596 * The mapping was found in the software page hash table. 573 597 * Insert it into data translation cache. 574 598 */ 575 dtc_pte_copy( t);599 dtc_pte_copy(entry); 576 600 page_table_unlock(AS, true); 577 601 } else { … … 579 603 if (try_memmap_io_insertion(va, istate)) 580 604 return; 581 /* 582 * Forward the page fault to the address space page fault 605 606 /* 607 * Forward the page fault to the address space page fault 583 608 * handler. 584 609 */ 585 610 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 586 fault_if_from_uspace(istate, "Page fault at %p.",va);611 fault_if_from_uspace(istate, "Page fault at %p.", va); 587 612 panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid, 588 613 istate->cr_iip); … … 595 620 * This fault should not occur. 596 621 * 597 * @param vector Interruption vector. 598 * @param istate Structure with saved interruption state. 622 * @param vector Interruption vector. 623 * @param istate Structure with saved interruption state. 624 * 599 625 */ 600 626 void data_nested_tlb_fault(uint64_t vector, istate_t *istate) 601 627 { 602 panic("%s.", __func__);628 ASSERT(false); 603 629 } 604 630 605 631 /** Data Dirty bit fault handler. 606 632 * 607 * @param vector Interruption vector. 608 * @param istate Structure with saved interruption state. 633 * @param vector Interruption vector. 634 * @param istate Structure with saved interruption state. 635 * 609 636 */ 610 637 void data_dirty_bit_fault(uint64_t vector, istate_t *istate) 611 638 { 612 region_register rr;639 region_register_t rr; 613 640 rid_t rid; 614 641 uintptr_t va; 615 642 pte_t *t; 616 643 617 va = istate->cr_ifa; 644 va = istate->cr_ifa; /* faulting address */ 618 645 rr.word = rr_read(VA2VRN(va)); 619 646 rid = rr.map.rid; 620 647 621 648 page_table_lock(AS, true); 622 649 t = page_mapping_find(AS, va); 623 ASSERT( t && t->p);624 if ( t && t->p && t->w) {650 ASSERT((t) && (t->p)); 651 if ((t) && (t->p) && (t->w)) { 625 652 /* 626 653 * Update the Dirty bit in page tables and reinsert … … 631 658 } else { 632 659 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 633 fault_if_from_uspace(istate, "Page fault at %p.",va);660 fault_if_from_uspace(istate, "Page fault at %p.", va); 634 661 panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid, 635 662 istate->cr_iip); … … 641 668 /** Instruction access bit fault handler. 642 669 * 643 * @param vector Interruption vector. 644 * @param istate Structure with saved interruption state. 670 * @param vector Interruption vector. 671 * @param istate Structure with saved interruption state. 672 * 645 673 */ 646 674 void instruction_access_bit_fault(uint64_t vector, istate_t *istate) 647 675 { 648 region_register rr;676 region_register_t rr; 649 677 rid_t rid; 650 678 uintptr_t va; 651 pte_t *t; 652 653 va = istate->cr_ifa; 679 pte_t *t; 680 681 va = istate->cr_ifa; /* faulting address */ 654 682 rr.word = rr_read(VA2VRN(va)); 655 683 rid = rr.map.rid; 656 684 657 685 page_table_lock(AS, true); 658 686 t = page_mapping_find(AS, va); 659 ASSERT( t && t->p);660 if ( t && t->p && t->x) {687 ASSERT((t) && (t->p)); 688 if ((t) && (t->p) && (t->x)) { 661 689 /* 662 690 * Update the Accessed bit in page tables and reinsert … … 679 707 * @param vector Interruption vector. 680 708 * @param istate Structure with saved interruption state. 709 * 681 710 */ 682 711 void data_access_bit_fault(uint64_t vector, istate_t *istate) 683 712 { 684 region_register rr;713 region_register_t rr; 685 714 rid_t rid; 686 715 uintptr_t va; 687 716 pte_t *t; 688 689 va = istate->cr_ifa; 717 718 va = istate->cr_ifa; /* faulting address */ 690 719 rr.word = rr_read(VA2VRN(va)); 691 720 rid = rr.map.rid; 692 721 693 722 page_table_lock(AS, true); 694 723 t = page_mapping_find(AS, va); 695 ASSERT( t && t->p);696 if ( t && t->p) {724 ASSERT((t) && (t->p)); 725 if ((t) && (t->p)) { 697 726 /* 698 727 * Update the Accessed bit in page tables and reinsert … … 715 744 * @param vector Interruption vector. 716 745 * @param istate Structure with saved interruption state. 746 * 717 747 */ 718 748 void data_access_rights_fault(uint64_t vector, istate_t *istate) 719 749 { 720 region_register rr;750 region_register_t rr; 721 751 rid_t rid; 722 752 uintptr_t va; 723 753 pte_t *t; 724 725 va = istate->cr_ifa; 754 755 va = istate->cr_ifa; /* faulting address */ 726 756 rr.word = rr_read(VA2VRN(va)); 727 757 rid = rr.map.rid; 728 758 729 759 /* 730 760 * Assume a write to a read-only page. … … 732 762 page_table_lock(AS, true); 733 763 t = page_mapping_find(AS, va); 734 ASSERT( t && t->p);764 ASSERT((t) && (t->p)); 735 765 ASSERT(!t->w); 736 766 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { … … 746 776 * @param vector Interruption vector. 747 777 * @param istate Structure with saved interruption state. 778 * 748 779 */ 749 780 void page_not_present(uint64_t vector, istate_t *istate) 750 781 { 751 region_register rr;782 region_register_t rr; 752 783 rid_t rid; 753 784 uintptr_t va; 754 785 pte_t *t; 755 786 756 va = istate->cr_ifa; 787 va = istate->cr_ifa; /* faulting address */ 757 788 rr.word = rr_read(VA2VRN(va)); 758 789 rid = rr.map.rid; 759 790 760 791 page_table_lock(AS, true); 761 792 t = page_mapping_find(AS, va); -
kernel/arch/ia64/src/mm/vhpt.c
r029d94a r5bda2f3e 27 27 */ 28 28 29 /** @addtogroup ia64mm 29 /** @addtogroup ia64mm 30 30 * @{ 31 31 */ … … 44 44 vhpt_base = frame_alloc(VHPT_WIDTH - FRAME_WIDTH, 45 45 FRAME_KA | FRAME_ATOMIC); 46 if (!vhpt_base) 46 if (!vhpt_base) 47 47 panic("Kernel configured with VHPT but no memory for table."); 48 48 vhpt_invalidate_all(); … … 53 53 void vhpt_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry) 54 54 { 55 region_register rr_save, rr;55 region_register_t rr_save, rr; 56 56 size_t vrn; 57 57 rid_t rid; 58 58 uint64_t tag; 59 59 60 60 vhpt_entry_t *ventry; 61 62 61 63 62 vrn = va >> VRN_SHIFT; 64 63 rid = ASID2RID(asid, vrn); 65 64 66 65 rr_save.word = rr_read(vrn); 67 66 rr.word = rr_save.word; … … 75 74 srlz_i(); 76 75 srlz_d(); 77 76 78 77 ventry->word[0] = entry.word[0]; 79 78 ventry->word[1] = entry.word[1]; -
kernel/arch/ia64/src/start.S
r029d94a r5bda2f3e 32 32 #include <mm/asid.h> 33 33 34 #define RR_MASK (0xFFFFFFFF00000002)35 #define RID_SHIFT 36 #define PS_SHIFT 37 38 #define KERNEL_TRANSLATION_I 39 #define KERNEL_TRANSLATION_D 40 #define KERNEL_TRANSLATION_VIO 41 #define KERNEL_TRANSLATION_IO 0x00100FFFFC00067142 #define KERNEL_TRANSLATION_FW 0x00100000F000067134 #define RR_MASK (0xFFFFFFFF00000002) 35 #define RID_SHIFT 8 36 #define PS_SHIFT 2 37 38 #define KERNEL_TRANSLATION_I 0x0010000000000661 39 #define KERNEL_TRANSLATION_D 0x0010000000000661 40 #define KERNEL_TRANSLATION_VIO 0x0010000000000671 41 #define KERNEL_TRANSLATION_IO 0x00100FFFFC000671 42 #define KERNEL_TRANSLATION_FW 0x00100000F0000671 43 43 44 44 .section K_TEXT_START, "ax" … … 49 49 kernel_image_start: 50 50 .auto 51 51 52 52 #ifdef CONFIG_SMP 53 53 # Identify self(CPU) in OS structures by ID / EID 54 54 55 55 mov r9 = cr64 56 56 mov r10 = 1 … … 62 62 st1 [r8] = r10 63 63 #endif 64 64 65 65 mov psr.l = r0 66 66 srlz.i 67 67 srlz.d 68 68 69 69 # Fill TR.i and TR.d using Region Register #VRN_KERNEL 70 70 71 71 movl r8 = (VRN_KERNEL << VRN_SHIFT) 72 72 mov r9 = rr[r8] 73 73 74 74 movl r10 = (RR_MASK) 75 75 and r9 = r10, r9 76 76 movl r10 = ((RID_KERNEL << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT)) 77 or 78 77 or r9 = r10, r9 78 79 79 mov rr[r8] = r9 80 80 81 81 movl r8 = (VRN_KERNEL << VRN_SHIFT) 82 82 mov cr.ifa = r8 83 83 84 84 mov r11 = cr.itir 85 85 movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT) 86 86 or r10 = r10, r11 87 87 mov cr.itir = r10 88 88 89 89 movl r10 = (KERNEL_TRANSLATION_I) 90 90 itr.i itr[r0] = r10 91 91 movl r10 = (KERNEL_TRANSLATION_D) 92 92 itr.d dtr[r0] = r10 93 93 94 94 movl r7 = 1 95 95 movl r8 = (VRN_KERNEL << VRN_SHIFT) | VIO_OFFSET … … 97 97 movl r10 = (KERNEL_TRANSLATION_VIO) 98 98 itr.d dtr[r7] = r10 99 99 100 100 mov r11 = cr.itir 101 101 movl r10 = ~0xfc … … 104 104 or r10 = r10, r11 105 105 mov cr.itir = r10 106 106 107 107 movl r7 = 2 108 108 movl r8 = (VRN_KERNEL << VRN_SHIFT) | IO_OFFSET … … 110 110 movl r10 = (KERNEL_TRANSLATION_IO) 111 111 itr.d dtr[r7] = r10 112 113 # Setup mapping for fi mware arrea (also SAPIC)114 112 113 # Setup mapping for firmware area (also SAPIC) 114 115 115 mov r11 = cr.itir 116 116 movl r10 = ~0xfc … … 119 119 or r10 = r10, r11 120 120 mov cr.itir = r10 121 121 122 122 movl r7 = 3 123 123 movl r8 = (VRN_KERNEL << VRN_SHIFT) | FW_OFFSET … … 125 125 movl r10 = (KERNEL_TRANSLATION_FW) 126 126 itr.d dtr[r7] = r10 127 127 128 128 # Initialize PSR 129 129 130 130 movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */ 131 131 mov r9 = psr 132 132 133 133 or r10 = r10, r9 134 134 mov cr.ipsr = r10 … … 138 138 srlz.d 139 139 srlz.i 140 140 141 141 .explicit 142 142 143 143 /* 144 144 * Return From Interrupt is the only way to … … 147 147 rfi ;; 148 148 149 150 149 .global paging_start 151 150 paging_start: 152 151 153 152 /* 154 153 * Now we are paging. 155 154 */ 156 155 157 156 # Switch to register bank 1 158 157 bsw.1 159 158 160 159 #ifdef CONFIG_SMP 161 160 # Am I BSP or AP? … … 164 163 cmp.eq p3, p2 = r20, r0 ;; 165 164 #else 166 cmp.eq p3, p2 = r0, r0 ;; 167 #endif 165 cmp.eq p3, p2 = r0, r0 ;; /* you are BSP */ 166 #endif /* CONFIG_SMP */ 168 167 169 168 # Initialize register stack … … 172 171 mov ar.bspstore = r8 173 172 loadrs 174 173 175 174 # Initialize memory stack to some sane value 176 175 movl r12 = stack0 ;; 177 add r12 = -16, r12 178 176 add r12 = -16, r12 /* allocate a scratch area on the stack */ 177 179 178 # Initialize gp (Global Pointer) register 180 movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;181 or r20 = r20, r1;;179 movl r20 = (VRN_KERNEL << VRN_SHIFT) ;; 180 or r20 = r20, r1 ;; 182 181 movl r1 = _hardcoded_load_address 183 182 … … 192 191 (p3) addl r19 = @gprel(hardcoded_load_address), gp 193 192 (p3) addl r21 = @gprel(bootinfo), gp 194 ;;193 ;; 195 194 (p3) st8 [r17] = r14 196 195 (p3) st8 [r18] = r15 197 196 (p3) st8 [r19] = r16 198 197 (p3) st8 [r21] = r20 199 198 200 199 ssm (1 << 19) ;; /* Disable f32 - f127 */ 201 200 srlz.i 202 201 srlz.d ;; 203 202 204 203 #ifdef CONFIG_SMP 205 204 (p2) movl r18 = main_ap ;; 206 (p2) 205 (p2) mov b1 = r18 ;; 207 206 (p2) br.call.sptk.many b0 = b1 208 207 209 208 # Mark that BSP is on 209 210 210 mov r20 = 1 ;; 211 211 movl r21 = bsp_started ;; 212 212 st8 [r21] = r20 ;; 213 213 #endif 214 214 215 215 br.call.sptk.many b0 = arch_pre_main 216 216 217 217 movl r18 = main_bsp ;; 218 218 mov b1 = r18 ;; … … 227 227 kernel_image_ap_start: 228 228 .auto 229 229 230 230 # Identify self(CPU) in OS structures by ID / EID 231 231 232 232 mov r9 = cr64 233 233 mov r10 = 1 … … 240 240 241 241 # Wait for wakeup synchro signal (#3 in cpu_by_id_eid_list) 242 242 243 243 kernel_image_ap_start_loop: 244 244 movl r11 = kernel_image_ap_start_loop 245 245 and r11 = r11, r12 246 mov b1 = r11 247 248 ld1 r20 = [r8] ;;249 movl r21 = 3 ;;250 cmp.eq p2, p3 = r20, r21 ;;246 mov b1 = r11 247 248 ld1 r20 = [r8] 249 movl r21 = 3 250 cmp.eq p2, p3 = r20, r21 251 251 (p3) br.call.sptk.many b0 = b1 252 252 253 253 movl r11 = kernel_image_start 254 254 and r11 = r11, r12 255 mov b1 = r11 255 mov b1 = r11 256 256 br.call.sptk.many b0 = b1 257 257 … … 259 259 .global bsp_started 260 260 bsp_started: 261 .space 8261 .space 8 262 262 263 263 .align 4096 264 264 .global cpu_by_id_eid_list 265 265 cpu_by_id_eid_list: 266 .space 65536267 268 #endif 266 .space 65536 267 268 #endif /* CONFIG_SMP */
Note:
See TracChangeset
for help on using the changeset viewer.