source: trunk/hal/x86_64/hal_kentry.S @ 27

Last change on this file since 27 was 25, checked in by max@…, 7 years ago

First shot of the x86_64 port. It uses Multiboot V1. Most of the HAL functions
are empty, and several TSAR-specific files and comments remain; they will be
cleaned up later. The Makefile and LD script will come in another commit.

File size: 4.4 KB
Line 
1/*
2 * hal_kentry.S - exception/interrupt/syscall kernel entry point for MIPS32
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
9 *
10 * This file is part of ALMOS-MKH.
11 *
12 * ALMOS-MKH is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2.0 of the License.
15 *
16 * ALMOS-MKH is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * General Public License for more details.
20 *
21 * 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,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26
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#---------------------------------------------------------------------------------
45
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
52
53        .global    kentry
54        .global    kentry_load
55
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     
63
64#---------------------------------------------------------------------------------
65# Kernel Entry point
66#---------------------------------------------------------------------------------
67
68kentry:
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
76
77user_mode:
78
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
86
87kernel_mode:
88
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
93
94unified_mode:   
95
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.
99
100
101cause_excp:
102
103cause_sys:
104
105cause_int:
106
107# -----------------------------------------------------------------------------------
108# Kentry exit
109# -----------------------------------------------------------------------------------
110kentry_exit:
111
112# Possible value for MMU_MODE
113# In kernel mode : 0x7/0x3
114# In user mode   : 0xF
115
116# DP_EXT can either be local or remote
117# Once these register set we can no longuer
118# access global data
119
120out_mmu_F:
121
122out_mmu_7:
123
124out_mmu_3:
125
126out_kentry:
127
128kentry_load:
129        # theses nops are required to load the eret instruction
130        # while we are in virtual mode (processor pipeline) ?
131
132
133#-------------------------------------------------------------------------------
134
Note: See TracBrowser for help on using the repository browser.