Changeset 29 for trunk/hal/x86_64/hal_kentry.S
- Timestamp:
- Jun 21, 2017, 8:35:30 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/hal_kentry.S
r25 r29 1 1 /* 2 * hal_kentry.S - exception/interrupt/syscall kernel entry point for MIPS322 * hal_kentry.S - Entry points into the kernel (traps, interrupts, syscalls) 3 3 * 4 * AUthors Ghassan Almaless (2007,2008,2009,2010,2011,2012) 5 * Mohamed Lamine Karaoui (2015) 6 * Alain Greiner (2017) 7 * 8 * Copyright (c) UPMC Sorbonne Universites 4 * Copyright (c) 2017 Maxime Villard 9 5 * 10 6 * This file is part of ALMOS-MKH. … … 20 16 * 21 17 * You should have received a copy of the GNU General Public License 22 * along with ALMOS-MKH ; if not, write to the Free Software Foundation,18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation, 23 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 20 */ 25 21 22 #define x86_ASM 23 #include <hal_boot.h> 24 #include <hal_kentry.h> 26 25 27 #--------------------------------------------------------------------------------- 28 # This code is the unique kernel entry point in case of exception, interrupt, 29 # or syscall for the TSAR_MIPS32 architecture. 30 # 31 # - If the core is in user mode: 32 # . we desactivate the MMU. 33 # . we save the context in the uzone of the calling thread descriptor. 34 # . we increment the cores_in_kernel variable. 35 # . we call the relevant exception/interrupt/syscall handler 36 # 37 # - If the core is already in kernel mode: 38 # . we save the context in the kernel stack 39 # . we call the relevant exception/interrupt/syscall handler 40 # 41 # - In both cases, when the handler returns: 42 # . we restore the context 43 # . we reactivate the MMU ??? 44 #--------------------------------------------------------------------------------- 26 #define TRAPENTRY(a) \ 27 pushq $(a); \ 28 jmp alltraps; 45 29 46 .section .kentry,"ax",@progbits 47 .extern cpu_do_interrupt 48 .extern cpu_do_exception 49 .extern cpu_do_syscall 50 .extern cpu_kentry 51 .extern cpu_kexit 30 #define ZTRAPENTRY(a) \ 31 pushq $0; \ 32 TRAPENTRY(a) 52 33 53 .global kentry 54 .global kentry_load 34 .text 35 .globl hal_trap_entry 36 .type hal_trap_entry, @function 55 37 56 #define SAVE_SIZE CPU_REGS_NR*4 57 #define LID_WIDTH 2 58 #define CXY_WIDTH 8 59 #define CXY_MASK 0xFF 60 #define MMU_MODE_MASK 0xF 61 #define GID_MASK 0x3FF 62 #define LID_MASK 0x3 38 ASM_ENTRY(x86_trap00) 39 ZTRAPENTRY(T_DIVIDE) 63 40 64 #--------------------------------------------------------------------------------- 65 # Kernel Entry point 66 #--------------------------------------------------------------------------------- 41 ASM_ENTRY(x86_trap01) 42 ZTRAPENTRY(T_TRCTRAP) 67 43 68 kentry: 69 70 #--------------------------------------------------------------------------------------- 71 # this code is executed when the core is in user mode: 72 # - we use the uzone defined in user thread descriptor. 73 # - we set the MMU off, and save the CP2_MODE register to uzone. 74 # - we save the user thread stack pointer to uzone and load the kernel stack pointer 75 # - we store the uzone pointer in $27 44 ASM_ENTRY(x86_trap02) 45 ZTRAPENTRY(T_NMI) 76 46 77 user_mode: 47 ASM_ENTRY(x86_trap03) 48 ZTRAPENTRY(T_BPTFLT) 78 49 79 #--------------------------------------------------------------------------------------- 80 # this code is executed when the core is in kernel mode: 81 # - we use an uzone allocated in kernel stack. 82 # - we set the MMU off, set the MMU data_paddr extension to local_cxy, 83 # and save the CP2_MODE and CP2_DEXT to uzone. 84 # - we save the kernel stack pointer to uzone and load the new kernel stack pointer 85 # - we store the uzone pointer in $27 50 ASM_ENTRY(x86_trap04) 51 ZTRAPENTRY(T_OFLOW) 86 52 87 kernel_mode: 53 ASM_ENTRY(x86_trap05) 54 ZTRAPENTRY(T_BOUND) 88 55 89 #-------------------------------------------------------------------------------------- 90 # this code is executed in both modes, with the two following assumptions: 91 # - $27 contains the pointer on uzone to save the cpu registers 92 # - $29 contains the kernel stack pointer 56 ASM_ENTRY(x86_trap06) 57 ZTRAPENTRY(T_PRIVINFLT) 93 58 94 unified_mode: 59 ASM_ENTRY(x86_trap07) 60 ZTRAPENTRY(T_DNA) 95 61 96 #--------------------------------------------------------------------------------------- 97 # Depending on XCODE (in $1) , call the apropriate handler. The three called 98 # functions take the same two arguments: thread pointer and uzone pointer. 62 ASM_ENTRY(x86_trap08) 63 TRAPENTRY(T_DOUBLEFLT) 99 64 65 ASM_ENTRY(x86_trap09) 66 ZTRAPENTRY(T_FPOPFLT) 100 67 101 cause_excp: 68 ASM_ENTRY(x86_trap0a) 69 TRAPENTRY(T_TSSFLT) 102 70 103 cause_sys: 71 ASM_ENTRY(x86_trap0b) 72 ZTRAPENTRY(T_SEGNPFLT) 104 73 105 cause_int: 74 ASM_ENTRY(x86_trap0c) 75 ZTRAPENTRY(T_STKFLT) 106 76 107 # ----------------------------------------------------------------------------------- 108 # Kentry exit 109 # ----------------------------------------------------------------------------------- 110 kentry_exit: 77 ASM_ENTRY(x86_trap0d) 78 ZTRAPENTRY(T_PROTFLT) 111 79 112 # Possible value for MMU_MODE 113 # In kernel mode : 0x7/0x3 114 # In user mode : 0xF 80 ASM_ENTRY(x86_trap0e) 81 TRAPENTRY(T_PAGEFLT) 115 82 116 # DP_EXT can either be local or remote 117 # Once these register set we can no longuer 118 # access global data 83 ASM_ENTRY(x86_trap0f) 84 ZTRAPENTRY(T_ASTFLT) 119 85 120 out_mmu_F: 86 ASM_ENTRY(x86_trap10) 87 ZTRAPENTRY(T_ARITHTRAP) 121 88 122 out_mmu_7: 89 ASM_ENTRY(x86_trap11) 90 TRAPENTRY(T_ALIGNFLT) 123 91 124 out_mmu_3: 92 ASM_ENTRY(x86_trap12) 93 ZTRAPENTRY(T_MCA) 125 94 126 out_kentry: 95 ASM_ENTRY(x86_trap13) 96 ZTRAPENTRY(T_XMM) 127 97 128 kentry_load: 129 # theses nops are required to load the eret instruction 130 # while we are in virtual mode (processor pipeline) ? 98 ASM_ENTRY(x86_trap14) 99 ASM_ENTRY(x86_trap15) 100 ASM_ENTRY(x86_trap16) 101 ASM_ENTRY(x86_trap17) 102 ASM_ENTRY(x86_trap18) 103 ASM_ENTRY(x86_trap19) 104 ASM_ENTRY(x86_trap1a) 105 ASM_ENTRY(x86_trap1b) 106 ASM_ENTRY(x86_trap1c) 107 ASM_ENTRY(x86_trap1d) 108 ASM_ENTRY(x86_trap1e) 109 ASM_ENTRY(x86_trap1f) 110 /* 20 - 31 reserved for future exp */ 111 ZTRAPENTRY(T_RESERVED) 131 112 113 /* 114 * Arguments pushed on the stack: 115 * tf_trapno 116 * tf_err: Dummy inserted if not defined 117 * tf_rip 118 * tf_cs 119 * tf_rflags 120 * tf_rsp 121 * tf_ss 122 */ 123 alltraps: 124 movq %rsp,%rdi 125 call hal_trap_entry 126 /* NOTREACHED */ 132 127 133 #------------------------------------------------------------------------------- 128 .data 129 .globl x86_traps 130 .type x86_traps, @object 134 131 132 .align 64 133 x86_traps: 134 .quad x86_trap00, x86_trap01 135 .quad x86_trap02, x86_trap03 136 .quad x86_trap04, x86_trap05 137 .quad x86_trap06, x86_trap07 138 .quad x86_trap08, x86_trap09 139 .quad x86_trap0a, x86_trap0b 140 .quad x86_trap0c, x86_trap0d 141 .quad x86_trap0e, x86_trap0f 142 .quad x86_trap10, x86_trap11 143 .quad x86_trap12, x86_trap13 144 .quad x86_trap14, x86_trap15 145 .quad x86_trap16, x86_trap17 146 .quad x86_trap18, x86_trap19 147 .quad x86_trap1a, x86_trap1b 148 .quad x86_trap1c, x86_trap1d 149 .quad x86_trap1e, x86_trap1f 150
Note: See TracChangeset
for help on using the changeset viewer.