Changeset 382fb4ba in mainline
- Timestamp:
- 2013-12-10T22:33:33Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f7a33de
- Parents:
- 2955bb9
- Location:
- kernel/arch/sparc32
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc32/Makefile.inc
r2955bb9 r382fb4ba 48 48 arch/$(KARCH)/src/context.S \ 49 49 arch/$(KARCH)/src/debug/stacktrace.c \ 50 arch/$(KARCH)/src/debug/stacktrace_asm.S \ 50 51 arch/$(KARCH)/src/proc/scheduler.c \ 51 52 arch/$(KARCH)/src/proc/task.c \ -
kernel/arch/sparc32/include/arch/interrupt.h
r2955bb9 r382fb4ba 39 39 #include <arch/istate.h> 40 40 41 #define IVT_ITEMS 041 #define IVT_ITEMS 32 42 42 #define IVT_FIRST 0 43 43 -
kernel/arch/sparc32/include/arch/mm/page.h
r2955bb9 r382fb4ba 37 37 #define KERN_sparc32_PAGE_H_ 38 38 39 #ifndef __ASM__ 40 39 41 #include <arch/mm/frame.h> 40 42 #include <trace.h> … … 268 270 #endif 269 271 272 #endif 273 270 274 /** @} 271 275 */ -
kernel/arch/sparc32/src/debug/stacktrace.c
r2955bb9 r382fb4ba 1 1 /* 2 2 * Copyright (c) 2010 Jakub Jermar 3 * Copyright (c) 2013 Jakub Klama 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup abs32le30 /** @addtogroup sparc32 30 31 * @{ 31 32 */ … … 37 38 #include <typedefs.h> 38 39 40 #include <arch.h> 41 #include <arch/stack.h> 42 43 #define FRAME_OFFSET_FP_PREV 14 44 #define FRAME_OFFSET_RA 15 45 46 extern void alloc_window_and_flush(void); 47 39 48 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 40 49 { 41 return true; 50 uintptr_t kstack; 51 uint32_t l1, l2; 52 53 read_from_invalid(&kstack, &l1, &l2); 54 kstack -= 128; 55 56 if (THREAD && (ctx->fp == kstack)) 57 return false; 58 return ctx->fp != 0; 42 59 } 43 60 44 61 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 45 62 { 63 uint64_t *stack = (void *) ctx->fp; 64 alloc_window_and_flush(); 65 *prev = stack[FRAME_OFFSET_FP_PREV]; 46 66 return true; 47 67 } … … 49 69 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 50 70 { 71 uint64_t *stack = (void *) ctx->fp; 72 alloc_window_and_flush(); 73 *ra = stack[FRAME_OFFSET_RA]; 51 74 return true; 52 75 } … … 54 77 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 55 78 { 56 return true;79 return false; 57 80 } 58 81 59 82 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 60 83 { 61 return true;84 return false; 62 85 } 63 86 64 bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra)87 bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra) 65 88 { 66 return true; 67 } 68 69 uintptr_t frame_pointer_get(void) 70 { 71 return 0; 72 } 73 74 uintptr_t program_counter_get(void) 75 { 76 return 0; 89 return false; 77 90 } 78 91 -
kernel/arch/sparc32/src/mm/page.c
r2955bb9 r382fb4ba 74 74 as_switch(NULL, AS_KERNEL); 75 75 76 printf("as_context_table=0x%08x\n", as_context_table);76 // printf("as_context_table=0x%08x\n", as_context_table); 77 77 78 78 /* Switch MMU to new context table */ … … 89 89 mmu_fault_type_t type = (mmu_fault_type_t)fault->at; 90 90 91 printf("page fault on address 0x%08x, status 0x%08x, type %d\n", fault_address, fault_status, type);91 // printf("page fault on address 0x%08x, status 0x%08x, type %d\n", fault_address, fault_status, type); 92 92 93 93 if (type == FAULT_TYPE_LOAD_USER_DATA || … … 101 101 if (type == FAULT_TYPE_STORE_USER_DATA || 102 102 type == FAULT_TYPE_STORE_USER_INSTRUCTION || 103 type == FAULT_TYPE_STORE_SUPERVISOR_INSTRUCTION) 103 type == FAULT_TYPE_STORE_SUPERVISOR_INSTRUCTION || 104 type == FAULT_TYPE_STORE_SUPERVISOR_DATA) 104 105 as_page_fault(fault_address, PF_ACCESS_WRITE, istate); 105 106 } -
kernel/arch/sparc32/src/proc/scheduler.c
r2955bb9 r382fb4ba 44 44 void before_thread_runs_arch(void) 45 45 { 46 printf("before_thread_runs_arch(uspace=%d, kernel_sp=0x%08x\n", THREAD->uspace, (uintptr_t)THREAD->kstack + STACK_SIZE);47 46 if (THREAD->uspace) { 48 47 uint32_t kernel_sp = (uint32_t) THREAD->kstack + STACK_SIZE - 8; … … 54 53 void after_thread_ran_arch(void) 55 54 { 55 if (THREAD->uspace) { 56 uint32_t kernel_sp; 57 uint32_t uspace_wbuf; 58 uint32_t l7; 59 read_from_invalid(&kernel_sp, &uspace_wbuf, &l7); 60 THREAD->arch.uspace_window_buffer = (uint8_t *)uspace_wbuf; 61 } 56 62 } 57 63 -
kernel/arch/sparc32/src/sparc32.c
r2955bb9 r382fb4ba 165 165 { 166 166 memcpy(dst, uspace_src, size); 167 return size;167 return 1; 168 168 } 169 169 … … 171 171 { 172 172 memcpy(uspace_dst, src, size); 173 return size;173 return 1; 174 174 } 175 175 -
kernel/arch/sparc32/src/trap_table.S
r2955bb9 r382fb4ba 279 279 restore 280 280 mov %g5, %wim 281 282 /* Check beginning of %sp */ 281 283 and %g4, 0xfffff000, %l4 284 lda [%l4] 0x18, %l4 285 cmp %l4, 0 286 bne 1f 287 nop 288 289 /* prepare args for preemptible handler */ 290 mov %g4, %o0 291 set preemptible_save_uspace, %o2 292 b preemptible_trap 293 nop 294 295 /* Check end of %sp */ 296 add %g4, 56, %g4 297 and %l4, 0xfffff000, %l4 282 298 lda [%l4] 0x18, %l4 283 299 cmp %l4, 0 … … 532 548 nop 533 549 550 /* Get UWB address */ 551 // switch_to_invalid %g5, %g6 552 // mov %l6, %g1 553 // switch_back %g5, %g6 554 555 # /* Flush windows to stack */ 556 call flush_windows 557 nop 558 /* 559 get_wim_number %g2 560 get_cwp %g5 561 mov %psr, %g6 562 563 sub %g2, 1, %g4 564 and %g4, 0x7, %g4 565 0: mov %g0, %wim 566 cmp %g5, %g4 567 be 0f 568 nop 569 570 restore 571 add %g1, 64, %g1 572 std %l0, [%g1 + 0] 573 std %l2, [%g1 + 8] 574 std %l4, [%g1 + 16] 575 std %l6, [%g1 + 24] 576 std %i0, [%g1 + 32] 577 std %l2, [%g1 + 40] 578 std %l4, [%g1 + 48] 579 std %l6, [%g1 + 56] 580 inc %g5 581 and %g5, 0x7, %g5 582 ba 0b 583 nop 584 585 0: inc %g4 586 and %g4, 0x7, %g4 587 clr %g5 588 inc %g5 589 sll %g5, %g4, %g5 590 591 * Write values to invalid window and switch back * 592 mov %g7, %l5 593 mov %g1, %l6 594 clr %l7 595 switch_back %g5, %g6 596 */ 597 534 598 /* Jump to actual subroutine */ 535 599 call %o2 … … 548 612 549 613 /* If trap originated from uspace, clear uspace window mark and save uwb address for future use */ 550 if_from_kernel 6f614 if_from_kernel 9f 551 615 switch_to_invalid %g5, %g6 552 616 clr %l7 … … 594 658 switch_back %g5, %g6 595 659 596 /* If next window is invalid, do inline restore */ 597 6: get_wim_number %g6 598 get_cwp %g7 599 inc %g7 600 and %g7, 0x7, %g7 601 cmp %g6, %g7 602 bne 8f 603 604 if_from_kernel 7f 605 606 inline_restore_uspace %g1 607 switch_to_invalid %g5, %g6 608 mov %g1, %l6 609 switch_back %g5, %g6 610 b 8f 611 nop 612 613 7: inline_restore_kernel 614 615 8: ld [%sp + 104], %g1 660 mov %sp, %l3 661 sub %g2, 128, %sp 662 ld [%sp + 104], %g1 616 663 ld [%sp + 108], %g2 617 664 ld [%sp + 112], %g3 618 665 ld [%sp + 116], %g4 619 666 ld [%sp + 120], %g7 620 jmp %l1 667 mov %l3, %sp 668 b 10f 669 nop 670 671 9: ld [%sp + 104], %g1 672 ld [%sp + 108], %g2 673 ld [%sp + 112], %g3 674 ld [%sp + 116], %g4 675 ld [%sp + 120], %g7 676 677 10: jmp %l1 621 678 rett %l2 622 679 623 680 interrupt_trap: 624 mov %psr, %l0625 626 /* Check whether previous mode was usermode */627 and %l0, (1 << 6), %l0628 cmp %l0, 0629 bne 1f630 nop631 632 /* Set up stack */633 set kernel_sp, %l4634 ld [%l4], %sp635 mov %sp, %fp636 1: sub %sp, 112, %sp637 638 /* Save trap data on stack */639 mov %psr, %l0640 st %l1, [%fp - 4]641 st %l2, [%fp - 8]642 st %l0, [%fp - 12]643 644 /* Enable traps */645 mov %psr, %l0646 or %l0, (1 << 5), %l0647 mov %l0, %psr648 nop649 nop650 nop651 nop652 653 /* Jump to actual subroutine */654 mov %g2, %o0655 call exc_dispatch656 sub %fp, 12, %o1657 658 /* Return from handler */659 ld [%fp - 4], %l1660 ld [%fp - 8], %l2661 ld [%fp - 12], %l0662 mov %l0, %psr663 nop664 nop665 nop666 nop667 nop668 669 /* If trap originated from uspace, clear uspace window mark and save uwb address for future use */670 if_from_kernel 6f671 switch_to_invalid %g5, %g6672 clr %l7673 mov %l6, %g7674 switch_back %g5, %g6675 mov %g7, %g1676 677 /* If next window is invalid, do inline restore */678 6: get_wim_number %g6679 get_cwp %g7680 inc %g7681 cmp %g6, %g7682 bne 8f683 684 if_from_kernel 7f685 686 inline_restore_uspace %g1687 switch_to_invalid %g5, %g6688 mov %g1, %l6689 switch_back %g5, %g6690 b 8f691 nop692 693 7: inline_restore_kernel694 695 8: jmp %l1696 rett %l2697 698 syscall_trap:699 681 /* Save %g7 */ 700 682 mov %g7, %l0 … … 766 748 nop 767 749 750 /* Flush windows to stack */ 751 call flush_windows 752 nop 753 768 754 /* Jump to actual subroutine */ 769 sub %o0, 0x80, %o0 770 st %o0, [ %sp + 92 ] 771 mov %i0, %o0 772 mov %i1, %o1 773 mov %i2, %o2 774 mov %i3, %o3 775 mov %i4, %o4 776 call syscall 777 mov %i5, %o5 755 mov %g2, %o0 756 call exc_dispatch 757 add %sp, 128, %o1 778 758 779 759 /* Return from handler */ … … 781 761 ld [%sp + 96], %l2 782 762 ld [%sp + 100], %l0 783 mov %o0, %i0784 mov %psr, %l1785 and %l1, 0xf, %l1786 and %l0, 0xfffffff0, %l0787 or %l0, %l1, %l0788 763 mov %l0, %psr 789 764 nop … … 864 839 ld [%sp + 116], %g4 865 840 ld [%sp + 120], %g7 841 jmp %l1 842 rett %l2 843 844 845 syscall_trap: 846 /* Save %g7 */ 847 mov %g7, %l0 848 849 /* Check whether we landed in invalid window */ 850 get_wim_number %g6 851 get_cwp %g7 852 cmp %g6, %g7 853 bne 4f 854 nop 855 856 /* We are in invalid window. Check whether previous mode was usermode */ 857 if_from_kernel 3f 858 859 /* Trap originated from uspace */ 860 /* Kernel stack pointer is at %l5, uwb is at %l6 */ 861 inline_save_uspace %l6 862 863 /* set uspace window mark */ 864 mov %psr, %l7 865 inc %l7 866 and %l7, 0x7, %l7 867 or %l7, 0x10, %l7 868 b 4f 869 nop 870 871 3: /* Trap originated from kernel */ 872 inline_save_kernel 873 874 4: /* Check whether previous mode was usermode */ 875 if_from_kernel 5f 876 877 /* Load kernel stack pointer from invalid window */ 878 switch_to_invalid %g5, %g6 879 880 /* set uspace window mark */ 881 mov %g6, %l7 882 inc %l7 883 and %l7, 0x7, %l7 884 or %l7, 0x10, %l7 885 886 /* Save stack pointer */ 887 mov %l5, %g7 888 switch_back %g5, %g6 889 mov %g7, %sp 890 // mov %sp, %fp 891 892 5: /* Set up stack frame */ 893 sub %sp, 128, %sp 894 895 /* Save trap data on stack */ 896 mov %psr, %l5 897 st %l1, [%sp + 92] 898 st %l2, [%sp + 96] 899 st %l5, [%sp + 100] 900 st %g1, [%sp + 104] 901 st %g2, [%sp + 108] 902 st %g3, [%sp + 112] 903 st %g4, [%sp + 116] 904 st %l0, [%sp + 120] 905 906 /* Enable traps */ 907 mov %psr, %l0 908 or %l0, (1 << 5), %l0 909 mov %l0, %psr 910 nop 911 nop 912 nop 913 nop 914 915 /* Flush windows */ 916 call flush_windows 917 nop 918 919 /* Jump to actual subroutine */ 920 sub %o0, 0x80, %o0 921 st %o0, [ %sp + 92 ] 922 mov %i0, %o0 923 mov %i1, %o1 924 mov %i2, %o2 925 mov %i3, %o3 926 mov %i4, %o4 927 call syscall 928 mov %i5, %o5 929 930 /* Return from handler */ 931 ld [%sp + 92], %l1 932 ld [%sp + 96], %l2 933 ld [%sp + 100], %l0 934 mov %o0, %i0 935 mov %psr, %l1 936 and %l1, 0xf, %l1 937 and %l0, 0xfffffff0, %l0 938 or %l0, %l1, %l0 939 mov %l0, %psr 940 nop 941 nop 942 nop 943 nop 944 nop 945 946 /* If trap originated from uspace, clear uspace window mark and save uwb address for future use */ 947 if_from_kernel 8f 948 switch_to_invalid %g5, %g6 949 mov %l5, %g2 950 mov %l6, %g1 951 mov %l7, %g7 952 switch_back %g5, %g6 953 954 /* If trap originated from uspace, restore all windows from UWB */ 955 /* UWB pointer is at %g1 */ 956 0: mov %g0, %wim 957 clr %g5 958 andcc %g1, UWB_ALIGNMENT - 1, %g0 959 bz 0f 960 nop 961 962 restore 963 sub %g1, 64, %g1 964 ldd [%g1 + 0], %l0 965 ldd [%g1 + 8], %l2 966 ldd [%g1 + 16], %l4 967 ldd [%g1 + 24], %l6 968 ldd [%g1 + 32], %i0 969 ldd [%g1 + 40], %i2 970 ldd [%g1 + 48], %i4 971 ldd [%g1 + 56], %i6 972 inc %g5 973 and %g5, 0x7, %g5 974 ba 0b 975 nop 976 977 /* We've restored all uspace windows. Now time to 978 * fix CWP and WIM 979 */ 980 0: restore 981 get_cwp %g7 982 clr %g5 983 inc %g5 984 sll %g5, %g7, %g5 985 986 /* Write values to invalid window and switch back */ 987 mov %g2, %l5 988 mov %g1, %l6 989 clr %l7 990 switch_back %g5, %g6 991 992 8: mov %sp, %l1 993 sub %g2, 128, %sp 994 ld [%sp + 104], %g1 995 ld [%sp + 108], %g2 996 ld [%sp + 112], %g3 997 ld [%sp + 116], %g4 998 ld [%sp + 120], %g7 999 mov %l1, %sp 866 1000 jmp %l2 867 1001 rett %l2 + 4
Note:
See TracChangeset
for help on using the changeset viewer.