Changeset ee454eb in mainline
- Timestamp:
- 2006-08-30T15:50:29Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- beb3926a
- Parents:
- e11ae91
- Location:
- kernel/arch/sparc64
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/include/mm/frame.h
re11ae91 ree454eb 33 33 */ 34 34 35 #ifndef __sparc64_FRAME_H__36 #define __sparc64_FRAME_H__35 #ifndef KERN_sparc64_FRAME_H_ 36 #define KERN_sparc64_FRAME_H_ 37 37 38 38 #define FRAME_WIDTH 13 /* 8K */ -
kernel/arch/sparc64/include/mm/page.h
re11ae91 ree454eb 33 33 */ 34 34 35 #ifndef __sparc64_PAGE_H__36 #define __sparc64_PAGE_H__35 #ifndef KERN_sparc64_PAGE_H_ 36 #define KERN_sparc64_PAGE_H_ 37 37 38 38 #include <arch/mm/frame.h> … … 42 42 43 43 #ifdef KERNEL 44 45 #ifndef __ASM__ 44 46 45 47 #include <mm/page.h> … … 54 56 struct { 55 57 uint64_t vpn : 51; /**< Virtual Page Number. */ 56 unsigned offset : 13; /**< Offset. */58 unsigned offset : 13; /**< Offset. */ 57 59 } __attribute__ ((packed)); 58 60 }; … … 62 64 extern void page_arch_init(void); 63 65 66 #endif /* !def __ASM__ */ 67 64 68 #endif /* KERNEL */ 65 69 -
kernel/arch/sparc64/include/regdef.h
re11ae91 ree454eb 50 50 #define TSTATE_CWP_MASK 0x1f 51 51 52 #define WSTATE_NORMAL(n) (n) 53 #define WSTATE_OTHER(n) ((n)<<3) 54 52 55 #endif 53 56 -
kernel/arch/sparc64/src/proc/scheduler.c
re11ae91 ree454eb 79 79 */ 80 80 ASSERT(THREAD->arch.uspace_window_buffer); 81 uintptr_t uw_buf = (uintptr_t) THREAD->arch.uspace_window_buffer;81 uintptr_t uw_buf = ALIGN_DOWN((uintptr_t) THREAD->arch.uspace_window_buffer, PAGE_SIZE); 82 82 if (!overlaps(uw_buf, PAGE_SIZE, base, 1<<KERNEL_PAGE_WIDTH)) { 83 83 /* 84 84 * The buffer is not covered by the 4M locked kernel DTLB entry. 85 85 */ 86 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t)uw_buf);86 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, uw_buf); 87 87 dtlb_insert_mapping(uw_buf, KA2PA(uw_buf), PAGESIZE_8K, true, true); 88 88 } … … 127 127 flushw(); /* force all userspace windows into memory */ 128 128 129 uintptr_t uw_buf = (uintptr_t) THREAD->arch.uspace_window_buffer;129 uintptr_t uw_buf = ALIGN_DOWN((uintptr_t) THREAD->arch.uspace_window_buffer, PAGE_SIZE); 130 130 if (!overlaps(uw_buf, PAGE_SIZE, base, 1<<KERNEL_PAGE_WIDTH)) { 131 131 /* … … 134 134 * Demap it. 135 135 */ 136 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t)uw_buf);136 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, uw_buf); 137 137 } 138 138 -
kernel/arch/sparc64/src/proc/thread.c
re11ae91 ree454eb 36 36 #include <arch/proc/thread.h> 37 37 #include <mm/frame.h> 38 #include <mm/page.h> 39 #include <arch/mm/page.h> 40 #include <align.h> 38 41 39 42 void thr_constructor_arch(thread_t *t) … … 47 50 void thr_destructor_arch(thread_t *t) 48 51 { 49 if (t->arch.uspace_window_buffer) 50 frame_free((uintptr_t) t->arch.uspace_window_buffer); 52 if (t->arch.uspace_window_buffer) { 53 /* 54 * Mind the possible alignment of the userspace window buffer 55 * belonging to a killed thread. 56 */ 57 frame_free(ALIGN_DOWN((uintptr_t) t->arch.uspace_window_buffer, PAGE_SIZE)); 58 } 51 59 } 52 60 … … 59 67 */ 60 68 t->arch.uspace_window_buffer = frame_alloc(ONE_FRAME, 0); 69 } else { 70 uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer; 71 72 /* 73 * Mind the possible alignment of the userspace window buffer 74 * belonging to a killed thread. 75 */ 76 t->arch.uspace_window_buffer = (uint8_t *) ALIGN_DOWN(uw_buf, PAGE_SIZE); 61 77 } 62 78 } -
kernel/arch/sparc64/src/trap/trap_table.S
re11ae91 ree454eb 41 41 #include <arch/trap/exception.h> 42 42 #include <arch/trap/mmu.h> 43 #include <arch/mm/page.h> 43 44 #include <arch/stack.h> 44 45 #include <arch/regdef.h> … … 330 331 331 332 /* 333 * Normal window spills will go to the userspace window buffer. 334 */ 335 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(2), %wstate 336 337 /* 332 338 * Switch to kernel stack. The old stack is 333 339 * automatically saved in the old window's %sp … … 364 370 */ 365 371 1: 366 372 373 /* 374 * Other window spills will go to the userspace window buffer 375 * and normal spills will go to the kernel stack. 376 */ 377 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate 378 367 379 /* 368 380 * Copy arguments. … … 450 462 */ 451 463 flushw 452 mov %sp, %g 1464 mov %sp, %g2 453 465 stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0] 454 466 stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1] … … 460 472 stx %i7, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7] 461 473 wrpr %l0, 0, %cwp 462 mov %g 1, %sp474 mov %g2, %sp 463 475 ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0], %i0 464 476 ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1], %i1 … … 472 484 /* 473 485 * OTHERWIN != 0 or fall-through from the OTHERWIN == 0 case. 486 * The CWP has already been restored to the value it had prior to the SAVE 487 * at the beginning of this function. 474 488 */ 475 489 0: 476 ! TODO: restore register windows from register window memory buffer 477 490 rdpr %tstate, %g1 491 andcc %g1, TSTATE_PRIV_BIT, %g0 ! if we are not returning to userspace..., 492 bnz 1f ! ...skip restoring userspace windows 493 nop 494 495 rdpr %cwp, %g1 496 rdpr %otherwin, %g2 497 498 /* 499 * Skip all OTHERWIN windows and descend to the first window 500 * in the userspace window buffer. 501 */ 502 sub %g1, %g2, %g3 503 dec %g3 504 and %g3, NWINDOW - 1, %g3 505 wrpr %g3, 0, %cwp 506 507 /* 508 * CWP is now in the window last saved in the userspace window buffer. 509 * Fill all windows stored in the buffer. 510 */ 511 clr %g4 512 0: andcc %g7, PAGE_WIDTH - 1, %g0 ! PAGE_SIZE alignment check 513 bz 0f ! %g7 is page-aligned, no more windows to refill 514 nop 515 516 add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7 517 ldx [%g7 + L0_OFFSET], %l0 518 ldx [%g7 + L1_OFFSET], %l1 519 ldx [%g7 + L2_OFFSET], %l2 520 ldx [%g7 + L3_OFFSET], %l3 521 ldx [%g7 + L4_OFFSET], %l4 522 ldx [%g7 + L5_OFFSET], %l5 523 ldx [%g7 + L6_OFFSET], %l6 524 ldx [%g7 + L7_OFFSET], %l7 525 ldx [%g7 + I0_OFFSET], %i0 526 ldx [%g7 + I1_OFFSET], %i1 527 ldx [%g7 + I2_OFFSET], %i2 528 ldx [%g7 + I3_OFFSET], %i3 529 ldx [%g7 + I4_OFFSET], %i4 530 ldx [%g7 + I5_OFFSET], %i5 531 ldx [%g7 + I6_OFFSET], %i6 532 ldx [%g7 + I7_OFFSET], %i7 533 534 dec %g3 535 and %g3, NWINDOW - 1, %g3 536 wrpr %g3, 0, %cwp ! switch to the preceeding window 537 538 ba 0b 539 inc %g4 540 541 0: 542 /* 543 * Switch back to the proper current window and adjust 544 * OTHERWIN, CANRESTORE, CANSAVE and CLEANWIN. 545 */ 546 wrpr %g1, 0, %cwp 547 add %g4, %g2, %g2 548 mov NWINDOW - 2, %g1 549 sub %g1, %g2, %g1 550 551 wrpr %g0, 0, %otherwin 552 wrpr %g1, 0, %cansave ! NWINDOW - 2 - CANRESTORE 553 wrpr %g2, 0, %canrestore ! OTHERWIN + windows in the buffer 554 wrpr %g2, 0, %cleanwin ! avoid information leak 555 556 /* 557 * Spills and fills will be processed by the {spill,fill}_1_normal 558 * handlers. 559 */ 560 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate 561 562 1: 478 563 restore 479 564 retry
Note:
See TracChangeset
for help on using the changeset viewer.