Changeset 666773c in mainline
- Timestamp:
- 2008-12-31T15:33:29Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9805cde
- Parents:
- d8c0dc5
- Location:
- kernel/arch/ia64/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/cpu/cpu.c
rd8c0dc5 r666773c 71 71 72 72 printf("cpu%d: %s (%s), archrev=%d, model=%d, revision=%d\n", CPU->id, 73 family_str, vendor, CPU->arch.cpuid3.archrev, CPU->arch.cpuid3.model,74 CPU->arch.cpuid3. revision);73 family_str, vendor, CPU->arch.cpuid3.archrev, 74 CPU->arch.cpuid3.model, CPU->arch.cpuid3.revision); 75 75 } 76 76 -
kernel/arch/ia64/src/ddi/ddi.c
rd8c0dc5 r666773c 1 1 /* 2 * Copyright (c) 2006 Jakub Jermar, Jakub vana 2 * Copyright (c) 2006 Jakub Jermar 3 * Copyright (c) 2008 Jakub vana 3 4 * All rights reserved. 4 5 * … … 39 40 #include <errno.h> 40 41 41 #define IO_MEMMAP_PAGES 42 #define PORTS_PER_PAGE 42 #define IO_MEMMAP_PAGES 16384 43 #define PORTS_PER_PAGE 4 43 44 44 45 /** Enable I/O space range for task. … … 46 47 * Interrupts are disabled and task is locked. 47 48 * 48 * @param task 49 * @param ioaddr StartignI/O space address.50 * @param size 49 * @param task Task. 50 * @param ioaddr Starting I/O space address. 51 * @param size Size of the enabled I/O range. 51 52 * 52 53 * @return 0 on success or an error code from errno.h. … … 54 55 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) 55 56 { 57 if (!task->arch.iomap) { 58 uint8_t *map; 56 59 57 if(!task->arch.iomap) 58 { 59 uint8_t *map; 60 task->arch.iomap=malloc(sizeof(bitmap_t),0); 61 map=malloc(BITS2BYTES(IO_MEMMAP_PAGES),0); 60 task->arch.iomap = malloc(sizeof(bitmap_t), 0); 61 map = malloc(BITS2BYTES(IO_MEMMAP_PAGES), 0); 62 62 if(!map) 63 63 return ENOMEM; 64 bitmap_initialize(task->arch.iomap, map,IO_MEMMAP_PAGES);65 bitmap_clear_range(task->arch.iomap, 0,IO_MEMMAP_PAGES);64 bitmap_initialize(task->arch.iomap, map, IO_MEMMAP_PAGES); 65 bitmap_clear_range(task->arch.iomap, 0, IO_MEMMAP_PAGES); 66 66 } 67 67 68 68 uintptr_t iopage = ioaddr / PORTS_PER_PAGE; 69 size = ALIGN_UP (size+ioaddr-4*iopage,PORTS_PER_PAGE); 70 bitmap_set_range(task->arch.iomap,iopage,size/4); 71 69 size = ALIGN_UP(size + ioaddr - 4 * iopage, PORTS_PER_PAGE); 70 bitmap_set_range(task->arch.iomap, iopage, size / 4); 72 71 73 72 return 0; -
kernel/arch/ia64/src/drivers/ega.c
rd8c0dc5 r666773c 83 83 stdout = &ega_console; 84 84 85 86 85 ega_parea.pbase = VIDEORAM & 0xffffffff; 87 86 ega_parea.vbase = (uintptr_t) videoram; … … 90 89 ddi_parea_register(&ega_parea); 91 90 92 93 91 sysinfo_set_item_val("fb", NULL, true); 94 92 sysinfo_set_item_val("fb.kind", NULL, 2); … … 96 94 sysinfo_set_item_val("fb.height", NULL, ROWS); 97 95 sysinfo_set_item_val("fb.blinking", NULL, true); 98 sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM & 0xffffffff); 96 sysinfo_set_item_val("fb.address.physical", NULL, 97 VIDEORAM & 0xffffffff); 99 98 100 99 #ifndef CONFIG_FB … … 117 116 return; 118 117 119 memmove((void *) videoram, (void *) (videoram + ROW * 2), (SCREEN - ROW) * 2); 118 memmove((void *) videoram, (void *) (videoram + ROW * 2), 119 (SCREEN - ROW) * 2); 120 120 _memsetw(videoram + (SCREEN - ROW) * 2, ROW, 0x0720); 121 121 ega_cursor = ega_cursor - ROW; -
kernel/arch/ia64/src/drivers/it.c
rd8c0dc5 r666773c 45 45 #include <arch.h> 46 46 47 #define IT_SERVICE_CLOCKS 47 #define IT_SERVICE_CLOCKS 64 48 48 49 #define FREQ_NUMERATOR_SHIFT 50 #define FREQ_NUMERATOR_MASK 0xffffffff00000000LL49 #define FREQ_NUMERATOR_SHIFT 32 50 #define FREQ_NUMERATOR_MASK 0xffffffff00000000ULL 51 51 52 #define FREQ_DENOMINATOR_SHIFT 0 53 #define FREQ_DENOMINATOR_MASK 0xffffffffLL 54 52 #define FREQ_DENOMINATOR_SHIFT 0 53 #define FREQ_DENOMINATOR_MASK 0xffffffffULL 55 54 56 55 uint64_t it_delta; 57 58 56 59 57 static irq_t it_irq; … … 67 65 cr_itv_t itv; 68 66 69 if(config.cpu_active==1) 70 { 67 if (config.cpu_active == 1) { 71 68 irq_initialize(&it_irq); 72 69 it_irq.inr = INTERRUPT_TIMER; … … 77 74 78 75 uint64_t base_freq; 79 base_freq = ((bootinfo->freq_scale) & FREQ_NUMERATOR_MASK) >> FREQ_NUMERATOR_SHIFT; 76 base_freq = ((bootinfo->freq_scale) & FREQ_NUMERATOR_MASK) >> 77 FREQ_NUMERATOR_SHIFT; 80 78 base_freq *= bootinfo->sys_freq; 81 base_freq /= ((bootinfo->freq_scale) & FREQ_DENOMINATOR_MASK) >> FREQ_DENOMINATOR_SHIFT; 79 base_freq /= ((bootinfo->freq_scale) & FREQ_DENOMINATOR_MASK) >> 80 FREQ_DENOMINATOR_SHIFT; 82 81 83 it_delta = base_freq /HZ; 84 82 it_delta = base_freq / HZ; 85 83 } 86 84 -
kernel/arch/ia64/src/fpu_context.c
rd8c0dc5 r666773c 150 150 151 151 : 152 : "r" (&((fctx->fr)[0])), "r" (&((fctx->fr)[1])), "r" (&((fctx->fr)[2])), "r" (&((fctx->fr)[3])), 153 "r" (&((fctx->fr)[4])), "r" (&((fctx->fr)[5])), "r" (&((fctx->fr)[6])), "r" (&((fctx->fr)[7])) 152 : "r" (&((fctx->fr)[0])), "r" (&((fctx->fr)[1])), 153 "r" (&((fctx->fr)[2])), "r" (&((fctx->fr)[3])), 154 "r" (&((fctx->fr)[4])), "r" (&((fctx->fr)[5])), 155 "r" (&((fctx->fr)[6])), "r" (&((fctx->fr)[7])) 154 156 ); 155 157 … … 268 270 269 271 : 270 : "r" (&((fctx->fr)[0])), "r" (&((fctx->fr)[1])), "r" (&((fctx->fr)[2])), "r" (&((fctx->fr)[3])), 271 "r" (&((fctx->fr)[4])), "r" (&((fctx->fr)[5])), "r" (&((fctx->fr)[6])), "r" (&((fctx->fr)[7])) 272 : "r" (&((fctx->fr)[0])), "r" (&((fctx->fr)[1])), 273 "r" (&((fctx->fr)[2])), "r" (&((fctx->fr)[3])), 274 "r" (&((fctx->fr)[4])), "r" (&((fctx->fr)[5])), 275 "r" (&((fctx->fr)[6])), "r" (&((fctx->fr)[7])) 272 276 ); 273 277 } … … 275 279 void fpu_enable(void) 276 280 { 277 uint64_t a = 0 281 uint64_t a = 0; 278 282 279 283 asm volatile ( -
kernel/arch/ia64/src/ia64.c
rd8c0dc5 r666773c 63 63 #include <sysinfo/sysinfo.h> 64 64 65 /* NS16550 as a COM 1*/66 #define NS16550_IRQ (4+LEGACY_INTERRUPT_BASE)67 #define NS16550_PORT 65 /* NS16550 as a COM 1 */ 66 #define NS16550_IRQ (4 + LEGACY_INTERRUPT_BASE) 67 #define NS16550_PORT 0x3f8 68 68 69 69 bootinfo_t *bootinfo; 70 70 71 static uint64_t iosapic_base =0xfec00000;71 static uint64_t iosapic_base = 0xfec00000; 72 72 73 73 void arch_pre_main(void) … … 80 80 81 81 for (i = 0; i < init.cnt; i++) { 82 init.tasks[i].addr = ((unsigned long) bootinfo->taskmap.tasks[i].addr) | VRN_MASK; 82 init.tasks[i].addr = 83 ((unsigned long) bootinfo->taskmap.tasks[i].addr) | 84 VRN_MASK; 83 85 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 84 86 } … … 87 89 void arch_pre_mm_init(void) 88 90 { 89 /* Set Interruption Vector Address (i.e. location of interruption vector table). */ 91 /* 92 * Set Interruption Vector Address (i.e. location of interruption vector 93 * table). 94 */ 90 95 iva_write((uintptr_t) &ivt); 91 96 srlz_d(); … … 96 101 { 97 102 98 uint64_t IOSAPIC = PA2KA((unative_t)(iosapic_base)) |FW_OFFSET;103 uint64_t IOSAPIC = PA2KA((unative_t)(iosapic_base)) | FW_OFFSET; 99 104 int i; 100 105 101 106 int myid,myeid; 102 107 103 myid =ia64_get_cpu_id();104 myeid =ia64_get_cpu_eid();105 106 for (i=0;i<16;i++)107 {108 109 if(i==2) continue; //Disable Cascade interrupt110 ((uint32_t*)(IOSAPIC+0x00))[0]=0x10+2*i;111 srlz_d();112 ((uint32_t*)(IOSAPIC+0x10))[0]=LEGACY_INTERRUPT_BASE+i;113 srlz_d();114 ((uint32_t*)(IOSAPIC+0x00))[0]=0x10+2*i+1;115 srlz_d();116 ((uint32_t*)(IOSAPIC+0x10))[0]=myid<<(56-32) | myeid<<(48-32);108 myid = ia64_get_cpu_id(); 109 myeid = ia64_get_cpu_eid(); 110 111 for (i = 0; i < 16; i++) { 112 if (i == 2) 113 continue; /* Disable Cascade interrupt */ 114 ((uint32_t *)(IOSAPIC + 0x00))[0] = 0x10 + 2 * i; 115 srlz_d(); 116 ((uint32_t *)(IOSAPIC + 0x10))[0] = LEGACY_INTERRUPT_BASE + i; 117 srlz_d(); 118 ((uint32_t *)(IOSAPIC + 0x00))[0] = 0x10 + 2 * i + 1; 119 srlz_d(); 120 ((uint32_t *)(IOSAPIC + 0x10))[0] = myid << (56 - 32) | 121 myeid << (48 - 32); 117 122 srlz_d(); 118 123 } … … 123 128 void arch_post_mm_init(void) 124 129 { 125 if(config.cpu_active==1) 126 { 130 if (config.cpu_active == 1) { 127 131 iosapic_init(); 128 129 132 irq_init(INR_COUNT, INR_COUNT); 130 133 #ifdef SKI … … 167 170 #endif 168 171 169 170 void end_of_irq_void(void *cir_arg __attribute__((unused)),inr_t inr __attribute__((unused)));171 void end_of_irq_void(void *cir_arg __attribute__((unused)),inr_t inr __attribute__((unused)))172 {173 return;174 }175 176 177 172 void arch_post_smp_init(void) 178 173 { 179 180 { 181 /* 182 * Create thread that polls keyboard. 183 */ 184 #ifdef SKI 185 thread_t *t; 186 t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 187 if (!t) 188 panic("cannot create kkbdpoll\n"); 189 thread_ready(t); 174 thread_t *t; 175 176 /* 177 * Create thread that polls keyboard. 178 */ 179 #ifdef SKI 180 t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 181 if (!t) 182 panic("cannot create kkbdpoll\n"); 183 thread_ready(t); 190 184 #endif 191 185 192 186 #ifdef I460GX 193 devno_t kbd = device_assign_devno(); 194 /* keyboard controller */ 195 196 #ifdef CONFIG_NS16550 197 ns16550_init(kbd, NS16550_PORT, NS16550_IRQ,end_of_irq_void,NULL); // as a COM 1 198 #else 199 devno_t mouse = device_assign_devno(); 200 i8042_init(kbd, IRQ_KBD, mouse, IRQ_MOUSE); 201 #endif 202 thread_t *t; 203 t = thread_create(i8042_kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 204 if (!t) 205 panic("cannot create kkbdpoll\n"); 206 thread_ready(t); 207 208 #endif 209 210 } 211 187 devno_t kbd = device_assign_devno(); 188 189 #ifdef CONFIG_NS16550 190 ns16550_init(kbd, NS16550_PORT, NS16550_IRQ, NULL, NULL); 191 #else 192 devno_t mouse = device_assign_devno(); 193 i8042_init(kbd, IRQ_KBD, mouse, IRQ_MOUSE); 194 #endif 195 t = thread_create(i8042_kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 196 if (!t) 197 panic("cannot create kkbdpoll\n"); 198 thread_ready(t); 199 #endif 200 212 201 sysinfo_set_item_val("ia64_iospace", NULL, true); 213 202 sysinfo_set_item_val("ia64_iospace.address", NULL, true); 214 203 sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, IO_OFFSET); 215 216 217 218 219 220 204 } 221 205 … … 229 213 psr.value = psr_read(); 230 214 psr.cpl = PL_USER; 231 psr.i = true; 215 psr.i = true; /* start with interrupts enabled */ 232 216 psr.ic = true; 233 psr.ri = 0; 234 psr.bn = 1; 217 psr.ri = 0; /* start with instruction #0 */ 218 psr.bn = 1; /* start in bank 0 */ 235 219 236 220 asm volatile ("mov %0 = ar.rsc\n" : "=r" (rsc.value)); … … 238 222 rsc.be = false; 239 223 rsc.pl = PL_USER; 240 rsc.mode = 3; 224 rsc.mode = 3; /* eager mode */ 241 225 242 226 switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry, 243 ((uintptr_t) kernel_uarg->uspace_stack)+PAGE_SIZE-ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),244 ((uintptr_t) kernel_uarg->uspace_stack)+PAGE_SIZE,245 (uintptr_t) kernel_uarg->uspace_uarg,246 247 248 while (1) {227 ((uintptr_t) kernel_uarg->uspace_stack) + PAGE_SIZE - 228 ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT), 229 ((uintptr_t) kernel_uarg->uspace_stack) + PAGE_SIZE, 230 (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value); 231 232 while (1) 249 233 ; 250 }251 234 } 252 235 … … 268 251 ski_kbd_grab(); 269 252 #else 270 #ifdef CONFIG_NS16550 271 ns16550_grab(); 272 #else 273 i8042_grab(); 274 #endif 275 #endif 276 } 253 #ifdef CONFIG_NS16550 254 ns16550_grab(); 255 #else 256 i8042_grab(); 257 #endif 258 #endif 259 } 260 277 261 /** Return console to userspace 278 262 * … … 283 267 ski_kbd_release(); 284 268 #else 285 #ifdef CONFIG_NS16550 286 ns16550_release(); 287 #else 288 i8042_release(); 289 #endif 290 269 #ifdef CONFIG_NS16550 270 ns16550_release(); 271 #else 272 i8042_release(); 273 #endif 291 274 #endif 292 275 } … … 294 277 void arch_reboot(void) 295 278 { 296 outb(0x64,0xfe); 297 while (1); 279 outb(0x64, 0xfe); 280 while (1) 281 ; 298 282 } 299 283 -
kernel/arch/ia64/src/interrupt.c
rd8c0dc5 r666773c 245 245 { 246 246 cr_ivr_t ivr; 247 irq_t *irq; 247 248 248 249 ivr.value = ivr_read(); 249 250 srlz_d(); 250 251 251 252 252 switch (ivr.vector) { 253 case INTERRUPT_SPURIOUS: 253 254 #ifdef CONFIG_DEBUG 254 255 printf("cpu%d: spurious interrupt\n", CPU->id); 255 256 #endif 256 257 break; 257 258 258 259 #ifdef CONFIG_SMP 259 case VECTOR_TLB_SHOOTDOWN_IPI: 260 tlb_shootdown_ipi_recv(); 260 case VECTOR_TLB_SHOOTDOWN_IPI: 261 tlb_shootdown_ipi_recv(); 262 end_of_local_irq(); 263 break; 264 #endif 265 266 case INTERRUPT_TIMER: 267 irq = irq_dispatch_and_lock(ivr.vector); 268 if (irq) { 269 irq->handler(irq, irq->arg); 270 spinlock_unlock(&irq->lock); 271 } else { 272 panic("\nUnhandled Internal Timer Interrupt (%d)\n", 273 ivr.vector); 274 } 275 break; 276 default: 277 irq = irq_dispatch_and_lock(ivr.vector); 278 if (irq) { 279 /* 280 * The IRQ handler was found. 281 */ 282 if (irq->preack) { 283 /* Send EOI before processing the interrupt */ 284 end_of_local_irq(); 285 } 286 irq->handler(irq, irq->arg); 287 if (!irq->preack) 288 end_of_local_irq(); 289 spinlock_unlock(&irq->lock); 290 } else { 291 /* 292 * Unhandled interrupt. 293 */ 261 294 end_of_local_irq(); 262 break; 295 #ifdef CONFIG_DEBUG 296 printf("\nUnhandled External Interrupt Vector %d\n", 297 ivr.vector); 263 298 #endif 264 265 case INTERRUPT_TIMER:266 {267 268 irq_t *irq = irq_dispatch_and_lock(ivr.vector);269 if (irq) {270 irq->handler(irq, irq->arg);271 spinlock_unlock(&irq->lock);272 } else {273 panic("\nUnhandled Internal Timer Interrupt (%d)\n",ivr.vector);274 }275 }276 break;277 278 default:279 {280 281 int ack=false;282 irq_t *irq = irq_dispatch_and_lock(ivr.vector);283 if (irq) {284 /*285 * The IRQ handler was found.286 */287 288 if (irq->preack) {289 /* Send EOI before processing the interrupt */290 end_of_local_irq();291 ack=true;292 }293 irq->handler(irq, irq->arg);294 spinlock_unlock(&irq->lock);295 } else {296 /*297 * Unhandled interrupt.298 */299 end_of_local_irq();300 ack=true;301 #ifdef CONFIG_DEBUG302 printf("\nUnhandled External Interrupt Vector %d\n",ivr.vector);303 #endif304 }305 if(!ack) end_of_local_irq();306 307 }308 309 310 break;311 299 } 300 break; 301 } 312 302 } 313 303 -
kernel/arch/ia64/src/mm/as.c
rd8c0dc5 r666773c 69 69 70 70 rr.word = rr_read(i); 71 rr.map.ve = false; 71 rr.map.ve = false; /* disable VHPT walker */ 72 72 rr.map.rid = ASID2RID(as->asid, i); 73 73 rr.map.ps = PAGE_WIDTH; -
kernel/arch/ia64/src/mm/page.c
rd8c0dc5 r666773c 124 124 * Interrupts must be disabled. 125 125 * 126 * @param page 127 * @param asid 128 * 129 * @return 126 * @param page Address of virtual page including VRN bits. 127 * @param asid Address space identifier. 128 * 129 * @return VHPT entry address. 130 130 */ 131 131 vhpt_entry_t *vhpt_hash(uintptr_t page, asid_t asid) … … 168 168 * Interrupts must be disabled. 169 169 * 170 * @param page Address of virtual page including VRN bits. 171 * @param asid Address space identifier. 172 * 173 * @return True if page and asid match the page and asid of t, false otherwise. 170 * @param page Address of virtual page including VRN bits. 171 * @param asid Address space identifier. 172 * 173 * @return True if page and asid match the page and asid of t, 174 * false otherwise. 174 175 */ 175 176 bool vhpt_compare(uintptr_t page, asid_t asid, vhpt_entry_t *v) … … 212 213 * 213 214 * @param v VHPT entry to be set up. 214 * @param page Virtual address of the page mapped by the entry. 215 * @param asid Address space identifier of the address space to which page belongs. 216 * @param frame Physical address of the frame to wich page is mapped. 217 * @param flags Different flags for the mapping. 218 */ 219 void vhpt_set_record(vhpt_entry_t *v, uintptr_t page, asid_t asid, uintptr_t frame, int flags) 215 * @param page Virtual address of the page mapped by the entry. 216 * @param asid Address space identifier of the address space to which 217 * page belongs. 218 * @param frame Physical address of the frame to wich page is mapped. 219 * @param flags Different flags for the mapping. 220 */ 221 void 222 vhpt_set_record(vhpt_entry_t *v, uintptr_t page, asid_t asid, uintptr_t frame, 223 int flags) 220 224 { 221 225 region_register rr_save, rr; … … 251 255 252 256 v->present.p = true; 253 v->present.ma = (flags & PAGE_CACHEABLE) ? MA_WRITEBACK : MA_UNCACHEABLE; 257 v->present.ma = (flags & PAGE_CACHEABLE) ? 258 MA_WRITEBACK : MA_UNCACHEABLE; 254 259 v->present.a = false; /* not accessed */ 255 260 v->present.d = false; /* not dirty */ … … 266 271 extern uintptr_t last_frame; 267 272 268 269 273 uintptr_t hw_map(uintptr_t physaddr, size_t size) 270 274 { 271 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 272 panic("Unable to map physical memory %p (%d bytes)", physaddr, size) 275 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > 276 KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 277 panic("Unable to map physical memory %p (%d bytes)", physaddr, 278 size) 273 279 274 280 uintptr_t virtaddr = PA2KA(last_frame); … … 276 282 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { 277 283 uintptr_t addr = PFN2ADDR(i); 278 page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, PAGE_NOT_CACHEABLE | PAGE_WRITE); 284 page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, 285 PAGE_NOT_CACHEABLE | PAGE_WRITE); 279 286 } 280 287 … … 284 291 } 285 292 286 287 288 293 /** @} 289 294 */ -
kernel/arch/ia64/src/mm/tlb.c
rd8c0dc5 r666773c 93 93 /** Invalidate entries belonging to an address space. 94 94 * 95 * @param asid 95 * @param asid Address space identifier. 96 96 */ 97 97 void tlb_invalidate_asid(asid_t asid) … … 132 132 133 133 switch (b) { 134 case 0: /* cnt 1-3*/134 case 0: /* cnt 1 - 3 */ 135 135 ps = PAGE_WIDTH; 136 136 break; 137 case 1: /* cnt 4-15*/138 ps = PAGE_WIDTH +2;139 va &= ~((1 <<ps)-1);140 break; 141 case 2: /* cnt 16-63*/142 ps = PAGE_WIDTH +4;143 va &= ~((1 <<ps)-1);144 break; 145 case 3: /* cnt 64-255*/146 ps = PAGE_WIDTH +6;147 va &= ~((1 <<ps)-1);148 break; 149 case 4: /* cnt 256-1023*/150 ps = PAGE_WIDTH +8;151 va &= ~((1 <<ps)-1);152 break; 153 case 5: /* cnt 1024-4095*/154 ps = PAGE_WIDTH +10;155 va &= ~((1 <<ps)-1);156 break; 157 case 6: /* cnt 4096-16383*/158 ps = PAGE_WIDTH +12;159 va &= ~((1 <<ps)-1);160 break; 161 case 7: /* cnt 16384-65535*/162 case 8: /* cnt 65536-(256K-1)*/163 ps = PAGE_WIDTH +14;164 va &= ~((1 <<ps)-1);137 case 1: /* cnt 4 - 15 */ 138 ps = PAGE_WIDTH + 2; 139 va &= ~((1 << ps) - 1); 140 break; 141 case 2: /* cnt 16 - 63 */ 142 ps = PAGE_WIDTH + 4; 143 va &= ~((1 << ps) - 1); 144 break; 145 case 3: /* cnt 64 - 255 */ 146 ps = PAGE_WIDTH + 6; 147 va &= ~((1 << ps) - 1); 148 break; 149 case 4: /* cnt 256 - 1023 */ 150 ps = PAGE_WIDTH + 8; 151 va &= ~((1 << ps) - 1); 152 break; 153 case 5: /* cnt 1024 - 4095 */ 154 ps = PAGE_WIDTH + 10; 155 va &= ~((1 << ps) - 1); 156 break; 157 case 6: /* cnt 4096 - 16383 */ 158 ps = PAGE_WIDTH + 12; 159 va &= ~((1 << ps) - 1); 160 break; 161 case 7: /* cnt 16384 - 65535 */ 162 case 8: /* cnt 65536 - (256K - 1) */ 163 ps = PAGE_WIDTH + 14; 164 va &= ~((1 << ps) - 1); 165 165 break; 166 166 default: 167 ps=PAGE_WIDTH+18; 168 va&=~((1<<ps)-1); 169 break; 170 } 171 for(; va<(page+cnt*(PAGE_SIZE)); va += (1<<ps)) { 172 asm volatile ( 173 "ptc.l %0,%1;;" 174 : 175 : "r" (va), "r" (ps<<2) 176 ); 177 } 167 ps = PAGE_WIDTH + 18; 168 va &= ~((1 << ps) - 1); 169 break; 170 } 171 for(; va < (page + cnt * PAGE_SIZE); va += (1 << ps)) 172 asm volatile ("ptc.l %0, %1;;" :: "r" (va), "r" (ps << 2)); 178 173 srlz_d(); 179 174 srlz_i(); … … 188 183 /** Insert data into data translation cache. 189 184 * 190 * @param va Virtual page address. 191 * @param asid Address space identifier. 192 * @param entry The rest of TLB entry as required by TLB insertion format. 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. 193 189 */ 194 190 void dtc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry) … … 199 195 /** Insert data into instruction translation cache. 200 196 * 201 * @param va Virtual page address. 202 * @param asid Address space identifier. 203 * @param entry The rest of TLB entry as required by TLB insertion format. 197 * @param va Virtual page address. 198 * @param asid Address space identifier. 199 * @param entry The rest of TLB entry as required by TLB insertion 200 * format. 204 201 */ 205 202 void itc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry) … … 210 207 /** Insert data into instruction or data translation cache. 211 208 * 212 * @param va Virtual page address. 213 * @param asid Address space identifier. 214 * @param entry The rest of TLB entry as required by TLB insertion format. 215 * @param dtc If true, insert into data translation cache, use instruction translation cache otherwise. 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. 216 215 */ 217 216 void tc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtc) … … 236 235 237 236 asm volatile ( 238 "mov r8 =psr;;\n"237 "mov r8 = psr;;\n" 239 238 "rsm %0;;\n" /* PSR_IC_MASK */ 240 239 "srlz.d;;\n" 241 240 "srlz.i;;\n" 242 "mov cr.ifa =%1\n" /* va */243 "mov cr.itir =%2;;\n" /* entry.word[1] */244 "cmp.eq p6,p7 = %4,r0;;\n" /* decide between itc and dtc */ 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 */ 245 244 "(p6) itc.i %3;;\n" 246 245 "(p7) itc.d %3;;\n" 247 "mov psr.l =r8;;\n"246 "mov psr.l = r8;;\n" 248 247 "srlz.d;;\n" 249 248 : 250 : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]), "r" (entry.word[0]), "r" (dtc) 249 : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]), 250 "r" (entry.word[0]), "r" (dtc) 251 251 : "p6", "p7", "r8" 252 252 ); … … 261 261 /** Insert data into instruction translation register. 262 262 * 263 * @param va Virtual page address. 264 * @param asid Address space identifier. 265 * @param entry The rest of TLB entry as required by TLB insertion format. 266 * @param tr Translation register. 267 */ 268 void itr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, index_t tr) 263 * @param va Virtual page address. 264 * @param asid Address space identifier. 265 * @param entry The rest of TLB entry as required by TLB insertion 266 * format. 267 * @param tr Translation register. 268 */ 269 void 270 itr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, index_t tr) 269 271 { 270 272 tr_mapping_insert(va, asid, entry, false, tr); … … 273 275 /** Insert data into data translation register. 274 276 * 275 * @param va Virtual page address. 276 * @param asid Address space identifier. 277 * @param entry The rest of TLB entry as required by TLB insertion format. 278 * @param tr Translation register. 279 */ 280 void dtr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, index_t tr) 277 * @param va Virtual page address. 278 * @param asid Address space identifier. 279 * @param entry The rest of TLB entry as required by TLB insertion 280 * format. 281 * @param tr Translation register. 282 */ 283 void 284 dtr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, index_t tr) 281 285 { 282 286 tr_mapping_insert(va, asid, entry, true, tr); … … 285 289 /** Insert data into instruction or data translation register. 286 290 * 287 * @param va Virtual page address. 288 * @param asid Address space identifier. 289 * @param entry The rest of TLB entry as required by TLB insertion format. 290 * @param dtr If true, insert into data translation register, use instruction translation register otherwise. 291 * @param tr Translation register. 292 */ 293 void tr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtr, index_t tr) 291 * @param va Virtual page address. 292 * @param asid Address space identifier. 293 * @param entry The rest of TLB entry as required by TLB insertion 294 * format. 295 * @param dtr If true, insert into data translation register, use 296 * instruction translation register otherwise. 297 * @param tr Translation register. 298 */ 299 void 300 tr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtr, 301 index_t tr) 294 302 { 295 303 region_register rr; … … 312 320 313 321 asm volatile ( 314 "mov r8 =psr;;\n"322 "mov r8 = psr;;\n" 315 323 "rsm %0;;\n" /* PSR_IC_MASK */ 316 324 "srlz.d;;\n" 317 325 "srlz.i;;\n" 318 "mov cr.ifa =%1\n" /* va */319 "mov cr.itir =%2;;\n" /* entry.word[1] */320 "cmp.eq p6,p7 =%5,r0;;\n" /* decide between itr and dtr */321 "(p6) itr.i itr[%4] =%3;;\n"322 "(p7) itr.d dtr[%4] =%3;;\n"323 "mov psr.l =r8;;\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" 324 332 "srlz.d;;\n" 325 333 : 326 : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]), "r" (entry.word[0]), "r" (tr), "r" (dtr) 334 : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]), 335 "r" (entry.word[0]), "r" (tr), "r" (dtr) 327 336 : "p6", "p7", "r8" 328 337 ); … … 337 346 /** Insert data into DTLB. 338 347 * 339 * @param page Virtual page address including VRN bits. 340 * @param frame Physical frame address. 341 * @param dtr If true, insert into data translation register, use data translation cache otherwise. 342 * @param tr Translation register if dtr is true, ignored otherwise. 343 */ 344 void dtlb_kernel_mapping_insert(uintptr_t page, uintptr_t frame, bool dtr, index_t tr) 348 * @param page Virtual page address including VRN bits. 349 * @param frame Physical frame address. 350 * @param dtr If true, insert into data translation register, use data 351 * translation cache otherwise. 352 * @param tr Translation register if dtr is true, ignored otherwise. 353 */ 354 void 355 dtlb_kernel_mapping_insert(uintptr_t page, uintptr_t frame, bool dtr, 356 index_t tr) 345 357 { 346 358 tlb_entry_t entry; … … 368 380 * Purge DTR entries used by the kernel. 369 381 * 370 * @param page 371 * @param width 382 * @param page Virtual page address including VRN bits. 383 * @param width Width of the purge in bits. 372 384 */ 373 385 void dtr_purge(uintptr_t page, count_t width) 374 386 { 375 asm volatile ("ptr.d %0, %1\n" : : "r" (page), "r" (width <<2));387 asm volatile ("ptr.d %0, %1\n" : : "r" (page), "r" (width << 2)); 376 388 } 377 389 … … 379 391 /** Copy content of PTE into data translation cache. 380 392 * 381 * @param t 393 * @param t PTE. 382 394 */ 383 395 void dtc_pte_copy(pte_t *t) … … 405 417 /** Copy content of PTE into instruction translation cache. 406 418 * 407 * @param t 419 * @param t PTE. 408 420 */ 409 421 void itc_pte_copy(pte_t *t) … … 432 444 /** Instruction TLB fault handler for faults with VHPT turned off. 433 445 * 434 * @param vector 435 * @param istate 446 * @param vector Interruption vector. 447 * @param istate Structure with saved interruption state. 436 448 */ 437 449 void alternate_instruction_tlb_fault(uint64_t vector, istate_t *istate) … … 462 474 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 463 475 fault_if_from_uspace(istate,"Page fault at %p",va); 464 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); 465 } 466 } 467 } 468 469 476 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, 477 istate->cr_iip); 478 } 479 } 480 } 470 481 471 482 static int is_io_page_accessible(int page) 472 483 { 473 if(TASK->arch.iomap) return bitmap_get(TASK->arch.iomap,page); 474 else return 0; 484 if (TASK->arch.iomap) 485 return bitmap_get(TASK->arch.iomap,page); 486 else 487 return 0; 475 488 } 476 489 477 490 #define IO_FRAME_BASE 0xFFFFC000000 478 491 479 /** There is special handling of memmaped lagacy io, because 480 * of 4KB sized access 481 * only for userspace 482 * 483 * @param va virtual address of page fault 484 * @param istate Structure with saved interruption state. 485 * 486 * 487 * @return 1 on success, 0 on fail 492 /** 493 * There is special handling of memory mapped legacy io, because of 4KB sized 494 * access for userspace. 495 * 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. 488 500 */ 489 501 static int try_memmap_io_insertion(uintptr_t va, istate_t *istate) 490 502 { 491 if((va >= IO_OFFSET ) && (va < IO_OFFSET + (1<<IO_PAGE_WIDTH))) 492 if(TASK){ 493 494 uint64_t io_page=(va & ((1<<IO_PAGE_WIDTH)-1)) >> (USPACE_IO_PAGE_WIDTH); 495 if(is_io_page_accessible(io_page)){ 496 uint64_t page,frame; 497 498 page = IO_OFFSET + (1 << USPACE_IO_PAGE_WIDTH) * io_page; 499 frame = IO_FRAME_BASE + (1 << USPACE_IO_PAGE_WIDTH) * io_page; 500 503 if ((va >= IO_OFFSET ) && (va < IO_OFFSET + (1 << IO_PAGE_WIDTH))) { 504 if (TASK) { 505 uint64_t io_page = (va & ((1 << IO_PAGE_WIDTH) - 1)) >> 506 USPACE_IO_PAGE_WIDTH; 507 508 if (is_io_page_accessible(io_page)) { 509 uint64_t page, frame; 510 511 page = IO_OFFSET + 512 (1 << USPACE_IO_PAGE_WIDTH) * io_page; 513 frame = IO_FRAME_BASE + 514 (1 << USPACE_IO_PAGE_WIDTH) * io_page; 501 515 502 516 tlb_entry_t entry; … … 505 519 entry.word[1] = 0; 506 520 507 entry.p = true; 521 entry.p = true; /* present */ 508 522 entry.ma = MA_UNCACHEABLE; 509 entry.a = true; 510 entry.d = true; 523 entry.a = true; /* already accessed */ 524 entry.d = true; /* already dirty */ 511 525 entry.pl = PL_USER; 512 526 entry.ar = AR_READ | AR_WRITE; … … 516 530 dtc_mapping_insert(page, TASK->as->asid, entry); 517 531 return 1; 518 }else { 519 fault_if_from_uspace(istate,"IO access fault at %p",va); 520 return 0; 521 } 522 } else 523 return 0; 524 else 525 return 0; 532 } else { 533 fault_if_from_uspace(istate, 534 "IO access fault at %p", va); 535 } 536 } 537 } 526 538 527 539 return 0; 528 529 } 530 531 532 540 } 533 541 534 542 /** Data TLB fault handler for faults with VHPT turned off. 535 543 * 536 * @param vector 537 * @param istate 544 * @param vector Interruption vector. 545 * @param istate Structure with saved interruption state. 538 546 */ 539 547 void alternate_data_tlb_fault(uint64_t vector, istate_t *istate) … … 569 577 } else { 570 578 page_table_unlock(AS, true); 571 if (try_memmap_io_insertion(va,istate)) return; 572 /* 573 * Forward the page fault to the address space page fault handler. 579 if (try_memmap_io_insertion(va, istate)) 580 return; 581 /* 582 * Forward the page fault to the address space page fault 583 * handler. 574 584 */ 575 585 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 576 586 fault_if_from_uspace(istate,"Page fault at %p",va); 577 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); 587 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, 588 istate->cr_iip); 578 589 } 579 590 } … … 584 595 * This fault should not occur. 585 596 * 586 * @param vector 587 * @param istate 597 * @param vector Interruption vector. 598 * @param istate Structure with saved interruption state. 588 599 */ 589 600 void data_nested_tlb_fault(uint64_t vector, istate_t *istate) … … 594 605 /** Data Dirty bit fault handler. 595 606 * 596 * @param vector 597 * @param istate 607 * @param vector Interruption vector. 608 * @param istate Structure with saved interruption state. 598 609 */ 599 610 void data_dirty_bit_fault(uint64_t vector, istate_t *istate) … … 621 632 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 622 633 fault_if_from_uspace(istate,"Page fault at %p",va); 623 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); 624 t->d = true; 625 dtc_pte_copy(t); 634 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, 635 istate->cr_iip); 626 636 } 627 637 } … … 631 641 /** Instruction access bit fault handler. 632 642 * 633 * @param vector 634 * @param istate 643 * @param vector Interruption vector. 644 * @param istate Structure with saved interruption state. 635 645 */ 636 646 void instruction_access_bit_fault(uint64_t vector, istate_t *istate) … … 657 667 } else { 658 668 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 659 fault_if_from_uspace(istate,"Page fault at %p",va); 660 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); 661 t->a = true; 662 itc_pte_copy(t); 669 fault_if_from_uspace(istate, "Page fault at %p", va); 670 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, 671 istate->cr_iip); 663 672 } 664 673 } … … 694 703 } else { 695 704 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 696 fault_if_from_uspace(istate,"Page fault at %p",va); 697 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, istate->cr_iip); 698 t->a = true; 699 itc_pte_copy(t); 705 fault_if_from_uspace(istate, "Page fault at %p", va); 706 panic("%s: va=%p, rid=%d, iip=%p\n", __func__, va, rid, 707 istate->cr_iip); 700 708 } 701 709 } … … 736 744 page_table_unlock(AS, true); 737 745 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 738 fault_if_from_uspace(istate, "Page fault at %p",va);746 fault_if_from_uspace(istate, "Page fault at %p", va); 739 747 panic("%s: va=%p, rid=%d\n", __func__, va, rid); 740 748 } -
kernel/arch/ia64/src/mm/vhpt.c
rd8c0dc5 r666773c 42 42 uintptr_t vhpt_set_up(void) 43 43 { 44 vhpt_base = frame_alloc(VHPT_WIDTH - FRAME_WIDTH, FRAME_KA | FRAME_ATOMIC); 44 vhpt_base = frame_alloc(VHPT_WIDTH - FRAME_WIDTH, 45 FRAME_KA | FRAME_ATOMIC); 45 46 if (!vhpt_base) 46 47 panic("Kernel configured with VHPT but no memory for table."); -
kernel/arch/ia64/src/proc/scheduler.c
rd8c0dc5 r666773c 48 48 } 49 49 50 /** Prepare kernel stack pointers in bank 0 r22 and r23 and make sure the stack is mapped in DTR. */ 50 /** Prepare kernel stack pointers in bank 0 r22 and r23 and make sure the stack 51 * is mapped in DTR. 52 */ 51 53 void before_thread_runs_arch(void) 52 54 { 53 55 uintptr_t base; 54 56 55 base = ALIGN_DOWN(config.base, 1 <<KERNEL_PAGE_WIDTH);57 base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 56 58 57 if ((uintptr_t) THREAD->kstack < base || (uintptr_t) THREAD->kstack > base + (1<<(KERNEL_PAGE_WIDTH))) { 59 if ((uintptr_t) THREAD->kstack < base || 60 (uintptr_t) THREAD->kstack > base + (1 << (KERNEL_PAGE_WIDTH))) { 58 61 /* 59 62 * Kernel stack of this thread is not mapped by DTR[TR_KERNEL]. … … 65 68 66 69 /* insert DTR[TR_STACK1] and DTR[TR_STACK2] */ 67 dtlb_kernel_mapping_insert((uintptr_t) THREAD->kstack, KA2PA(THREAD->kstack), true, DTR_KSTACK1); 68 dtlb_kernel_mapping_insert((uintptr_t) THREAD->kstack + PAGE_SIZE, KA2PA(THREAD->kstack) + FRAME_SIZE, true, DTR_KSTACK2); 70 dtlb_kernel_mapping_insert((uintptr_t) THREAD->kstack, 71 KA2PA(THREAD->kstack), true, DTR_KSTACK1); 72 dtlb_kernel_mapping_insert((uintptr_t) THREAD->kstack + 73 PAGE_SIZE, KA2PA(THREAD->kstack) + FRAME_SIZE, true, 74 DTR_KSTACK2); 69 75 } 70 76 -
kernel/arch/ia64/src/ski/ski.c
rd8c0dc5 r666773c 119 119 while(!(ch = ski_getchar())) 120 120 ; 121 if (ch == '\r')121 if (ch == '\r') 122 122 ch = '\n'; 123 123 return (char) ch; … … 144 144 ch = '\n'; 145 145 if (ch) { 146 if (ski_kbd_irq.notif_cfg.notify && ski_kbd_irq.notif_cfg.answerbox) { 146 if (ski_kbd_irq.notif_cfg.notify && 147 ski_kbd_irq.notif_cfg.answerbox) { 147 148 chardev_push_character(&ski_uconsole, ch); 148 149 ipc_irq_send_notif(&ski_kbd_irq); … … 157 158 158 159 if (last) { 159 if (ski_kbd_irq.notif_cfg.notify && ski_kbd_irq.notif_cfg.answerbox) { 160 if (ski_kbd_irq.notif_cfg.notify && 161 ski_kbd_irq.notif_cfg.answerbox) { 160 162 chardev_push_character(&ski_uconsole, 0); 161 163 ipc_irq_send_notif(&ski_kbd_irq); -
kernel/arch/ia64/src/smp/smp.c
rd8c0dc5 r666773c 62 62 #include <print.h> 63 63 64 65 66 67 68 69 64 #ifdef CONFIG_SMP 70 71 65 72 66 extern char cpu_by_id_eid_list[256][256]; 73 67 74 75 68 static void sapic_init(void) 76 69 { 77 bootinfo->sapic=(unative_t *)(PA2KA((unative_t)(bootinfo->sapic))|FW_OFFSET); 70 bootinfo->sapic = (unative_t *)(PA2KA((unative_t)(bootinfo->sapic)) | 71 FW_OFFSET); 78 72 } 79 73 80 81 82 static void ipi_broadcast_arch_all(int ipi ) 74 static void ipi_broadcast_arch_all(int ipi) 83 75 { 84 76 int id,eid; 85 int myid, myeid;77 int myid, myeid; 86 78 87 myid=ia64_get_cpu_id(); 88 myeid=ia64_get_cpu_eid(); 89 79 myid = ia64_get_cpu_id(); 80 myeid = ia64_get_cpu_eid(); 90 81 91 for (id=0;id<256;id++)92 for (eid=0;eid<256;eid++)93 if ((id!=myid) || (eid!=myeid))94 ipi_send_ipi(id, eid,ipi);82 for (id = 0; id < 256; id++) 83 for (eid = 0; eid < 256; eid++) 84 if ((id != myid) || (eid != myeid)) 85 ipi_send_ipi(id, eid, ipi); 95 86 } 96 87 … … 100 91 int myid,myeid; 101 92 102 myid =ia64_get_cpu_id();103 myeid =ia64_get_cpu_eid();93 myid = ia64_get_cpu_id(); 94 myeid = ia64_get_cpu_eid(); 104 95 105 for(id=0;id<256;id++) 106 for(eid=0;eid<256;eid++) 107 if((id!=myid) || (eid!=myeid)) 108 if(cpu_by_id_eid_list[id][eid]) 109 ipi_send_ipi(id,eid,ipi); 110 96 for (id = 0; id < 256; id++) 97 for (eid = 0; eid < 256; eid++) 98 if ((id != myid) || (eid != myeid)) 99 if (cpu_by_id_eid_list[id][eid]) 100 ipi_send_ipi(id, eid, ipi); 111 101 } 112 113 102 114 103 void smp_init(void) 115 104 { 116 if(!bootinfo->hello_configured) return; 117 //If we have not system prepared by hello, we are not able to start AP's 118 //this means we are running on simulator 105 if (!bootinfo->hello_configured) 106 return; 107 108 /* 109 * If we have not system prepared by hello, we are not able to start 110 * AP's. This means we are running on a simulator. 111 */ 119 112 120 113 sapic_init(); 121 114 ipi_broadcast_arch_all(bootinfo->wakeup_intno); 122 115 volatile long long brk; 123 for(brk=0;brk<100LL*1024LL*1024LL;brk++); //wait a while before CPUs starts 116 for (brk = 0; brk < 100LL * 1024LL * 1024LL; brk++) 117 ; /* wait a while before CPUs starts */ 124 118 125 config.cpu_count =0;126 int id, eid;119 config.cpu_count = 0; 120 int id, eid; 127 121 128 for (id=0;id<256;id++)129 for (eid=0;eid<256;eid++)130 if (cpu_by_id_eid_list[id][eid]==1){122 for (id = 0; id < 256; id++) 123 for (eid = 0; eid < 256; eid++) 124 if (cpu_by_id_eid_list[id][eid] == 1) { 131 125 config.cpu_count++; 132 cpu_by_id_eid_list[id][eid]=2; 133 126 cpu_by_id_eid_list[id][eid] = 2; 134 127 } 135 128 } 136 137 129 138 130 void kmp(void *arg __attribute__((unused))) 139 131 { 140 132 int id,eid; 141 int myid, myeid;133 int myid, myeid; 142 134 143 myid =ia64_get_cpu_id();144 myeid =ia64_get_cpu_eid();135 myid = ia64_get_cpu_id(); 136 myeid = ia64_get_cpu_eid(); 145 137 146 for(id=0;id<256;id++) 147 for(eid=0;eid<256;eid++) 148 if((id!=myid) || (eid!=myeid)) 149 if(cpu_by_id_eid_list[id][eid]!=0){ 150 if(cpu_by_id_eid_list[id][eid]==1){ 151 printf("Found Late CPU ID:%d EDI:%d Not added to system!!!\n",id,eid); 138 for (id = 0; id < 256; id++) 139 for (eid = 0; eid < 256; eid++) 140 if ((id != myid) || (eid != myeid)) 141 if (cpu_by_id_eid_list[id][eid] != 0) { 142 if (cpu_by_id_eid_list[id][eid] == 1) { 143 printf("Found Late CPU ID:%d " 144 "EDI:%d Not added to " 145 "system!!!\n", id, eid); 152 146 continue; 153 154 cpu_by_id_eid_list[id][eid] =3;147 } 148 cpu_by_id_eid_list[id][eid] = 3; 155 149 /* 156 * There may be just one AP being initialized at 157 * the time. After it comes completely up, it is 150 * There may be just one AP being 151 * initialized at the time. After 152 * it comes completely up, it is 158 153 * supposed to wake us up. 159 154 */ 160 if (waitq_sleep_timeout(&ap_completion_wq, 1000000, 161 SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) { 162 printf("%s: waiting for cpu ID:%d EID:%d" 163 "timed out\n", __FUNCTION__, 164 id, eid); 165 } 166 155 if (waitq_sleep_timeout( 156 &ap_completion_wq, 1000000, 157 SYNCH_FLAGS_NONE) == 158 ESYNCH_TIMEOUT) { 159 printf("%s: waiting for cpu " 160 "ID:%d EID:%d timed out\n", 161 __FUNCTION__, id, eid); 162 } 167 163 } 168 164 } 165 169 166 #endif 170 167 171 168 172 /*This is just a hack for linking with assembler - may be removed in future*/173 169 #ifndef CONFIG_SMP 170 171 /* This is just a hack for linking with assembler - may be removed in future. */ 174 172 void main_ap(void); 175 173 void main_ap(void) 176 174 { 177 while(1); 175 while(1) 176 ; 178 177 } 179 178 -
kernel/arch/ia64/src/start.S
rd8c0dc5 r666773c 33 33 34 34 #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 44 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 45 43 46 44 .section K_TEXT_START, "ax" … … 52 50 .auto 53 51 54 #identifi self(CPU) in OS structures by ID / EID 55 mov r9=cr64 56 mov r10=1 57 movl r12=0xffffffff 58 movl r8=cpu_by_id_eid_list 59 and r8=r8,r12 60 shr r9=r9,16 61 add r8=r8,r9 62 st1 [r8]=r10 63 64 52 # Identify self(CPU) in OS structures by ID / EID 53 54 mov r9 = cr64 55 mov r10 = 1 56 movl r12 = 0xffffffff 57 movl r8 = cpu_by_id_eid_list 58 and r8 = r8, r12 59 shr r9 = r9, 16 60 add r8 = r8, r9 61 st1 [r8] = r10 65 62 66 63 mov psr.l = r0 … … 70 67 # Fill TR.i and TR.d using Region Register #VRN_KERNEL 71 68 72 73 69 movl r8 = (VRN_KERNEL << VRN_SHIFT) 74 70 mov r9 = rr[r8] 75 76 71 77 72 movl r10 = (RR_MASK) … … 80 75 or r9 = r10, r9 81 76 82 83 77 mov rr[r8] = r9 84 78 85 86 87 79 movl r8 = (VRN_KERNEL << VRN_SHIFT) 88 80 mov cr.ifa = r8 89 81 90 91 82 mov r11 = cr.itir ;; 92 83 movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT);; 93 or r10 = r10 , r11;;84 or r10 = r10, r11 ;; 94 85 mov cr.itir = r10;; 95 86 96 97 87 movl r10 = (KERNEL_TRANSLATION_I) 98 88 itr.i itr[r0] = r10 99 100 101 89 movl r10 = (KERNEL_TRANSLATION_D) 102 90 itr.d dtr[r0] = r10 103 91 104 105 92 movl r7 = 1 106 93 movl r8 = (VRN_KERNEL << VRN_SHIFT) | VIO_OFFSET … … 109 96 itr.d dtr[r7] = r10 110 97 111 112 98 mov r11 = cr.itir ;; 113 99 movl r10 = ~0xfc;; 114 and r10 = r10 , r11;;100 and r10 = r10, r11 ;; 115 101 movl r11 = (IO_PAGE_WIDTH << PS_SHIFT);; 116 or r10 = r10 , r11;;102 or r10 = r10, r11 ;; 117 103 mov cr.itir = r10;; 118 119 104 120 105 movl r7 = 2 … … 124 109 itr.d dtr[r7] = r10 125 110 126 127 #setup mapping for fimware arrea (also SAPIC) 111 # Setup mapping for fimware arrea (also SAPIC) 112 128 113 mov r11 = cr.itir ;; 129 114 movl r10 = ~0xfc;; 130 and r10 = r10 , r11;;115 and r10 = r10, r11 ;; 131 116 movl r11 = (FW_PAGE_WIDTH << PS_SHIFT);; 132 or r10 = r10 , r11;;117 or r10 = r10, r11 ;; 133 118 mov cr.itir = r10;; 134 135 119 136 120 movl r7 = 3 … … 140 124 itr.d dtr[r7] = r10 141 125 142 143 144 145 146 # initialize PSR 126 # Initialize PSR 127 147 128 movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */ 148 129 mov r9 = psr 130 149 131 or r10 = r10, r9 150 132 mov cr.ipsr = r10 … … 156 138 157 139 .explicit 140 158 141 /* 159 142 * Return From Interupt is the only the way to fill upper half word of PSR. … … 161 144 rfi;; 162 145 146 163 147 .global paging_start 164 148 paging_start: … … 168 152 */ 169 153 170 # switch to register bank 1154 # Switch to register bank 1 171 155 bsw.1 172 156 173 #Am'I BSP or AP 174 movl r20=bsp_started;; 175 ld8 r20=[r20];; 176 cmp.eq p3,p2=r20,r0;; 177 157 # Am I BSP or AP? 158 movl r20 = bsp_started;; 159 ld8 r20 = [r20];; 160 cmp.eq p3, p2 = r20, r0;; 178 161 179 # initialize register stack162 # Initialize register stack 180 163 mov ar.rsc = r0 181 164 movl r8 = (VRN_KERNEL << VRN_SHIFT) ;; … … 183 166 loadrs 184 167 185 # initialize memory stack to some sane value168 # Initialize memory stack to some sane value 186 169 movl r12 = stack0 ;; 187 188 170 add r12 = -16, r12 /* allocate a scratch area on the stack */ 189 171 190 # initialize gp (Global Pointer) register172 # Initialize gp (Global Pointer) register 191 173 movl r20 = (VRN_KERNEL << VRN_SHIFT);; 192 174 or r20 = r20,r1;; … … 217 199 (p2) br.call.sptk.many b0 = b1 218 200 219 #Mark that BSP is on201 # Mark that BSP is on 220 202 mov r20=1;; 221 203 movl r21=bsp_started;; 222 204 st8 [r21]=r20;; 223 205 224 225 206 br.call.sptk.many b0 = arch_pre_main 226 207 … … 229 210 br.call.sptk.many b0 = b1 230 211 231 232 212 0: 233 213 br 0b … … 236 216 kernel_image_ap_start: 237 217 .auto 238 #identifi self(CPU) in OS structures by ID / EID 239 mov r9=cr64 240 mov r10=1 241 movl r12=0xffffffff 242 movl r8=cpu_by_id_eid_list 243 and r8=r8,r12 244 shr r9=r9,16 245 add r8=r8,r9 246 st1 [r8]=r10 218 219 # Identify self(CPU) in OS structures by ID / EID 220 221 mov r9 = cr64 222 mov r10 = 1 223 movl r12 = 0xffffffff 224 movl r8 = cpu_by_id_eid_list 225 and r8 = r8, r12 226 shr r9 = r9, 16 227 add r8 = r8, r9 228 st1 [r8] = r10 247 229 248 #wait for wakeup sychro signal (#3 in cpu_by_id_eid_list)230 # Wait for wakeup synchro signal (#3 in cpu_by_id_eid_list) 249 231 kernel_image_ap_start_loop: 250 movl r11 =kernel_image_ap_start_loop251 and r11 =r11,r12232 movl r11 = kernel_image_ap_start_loop 233 and r11 = r11, r12 252 234 mov b1 = r11 253 235 254 ld1 r20 =[r8];;255 movl r21 =3;;256 cmp.eq p2, p3=r20,r21;;257 (p3) br.call.sptk.many b0 = b1258 259 movl r11 =kernel_image_start260 and r11 =r11,r12261 236 ld1 r20 = [r8];; 237 movl r21 = 3;; 238 cmp.eq p2, p3 = r20, r21;; 239 (p3) br.call.sptk.many b0 = b1 240 241 movl r11 = kernel_image_start 242 and r11 = r11, r12 243 mov b1 = r11 262 244 br.call.sptk.many b0 = b1 263 245 … … 268 250 .space 8 269 251 270 271 252 .align 4096 272 253 .global cpu_by_id_eid_list … … 274 255 .space 65536 275 256 276
Note:
See TracChangeset
for help on using the changeset viewer.