source: trunk/hal/generic/hal_special.h @ 678

Last change on this file since 678 was 625, checked in by alain, 6 years ago

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File size: 8.3 KB
RevLine 
[1]1/*
2 * hal_special.h - Generic Special Registers Access API definition.
[17]3 *
[101]4 * Authors   Alain Greiner    (2016,2017)
[1]5 *
6 * Copyright (c)  UPMC Sorbonne Universites
[17]7 *
[1]8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef  _HAL_CPU_H_
25#define  _HAL_CPU_H_
26
[457]27#include <hal_shared_types.h>
28#include <hal_kernel_types.h>
[1]29
30/****  Forward declarations  ***/
31
32struct thread_s;
[623]33struct gpt_s;
[1]34
35///////////////////////////////////////////////////////////////////////////////////////////
36//      Generic Special Registers Access API (implementation in hal_special.c)
[17]37//
[296]38// ALMOS-MKH uses the following API to access the core protected registers.
[1]39///////////////////////////////////////////////////////////////////////////////////////////
40
41/*****************************************************************************************
[623]42 * This function initialise - for architectures requiring it - the protected register(s)
43 * containing the kernel_entry adresse(s) for interrupts / exceptions / syscalls.
44 ****************************************************************************************/
45void hal_set_kentry( void );
46
47/*****************************************************************************************
[624]48 * This function initializes - for architectures requiring it - the MMU registers of the
49 * calling core to use the the kernel page table identified by the <gpt> argument for
50 * all threads attached to kernel process_zero.
51 * It is called by all cores in the kernel_init() function.
[623]52 *****************************************************************************************
53 * @ gpt :  local pointer on the kernel page table descriptor.
54 ****************************************************************************************/
55void hal_mmu_init( struct gpt_s * gpt );
56
57/*****************************************************************************************
[279]58 * This function returns the calling core status register value.
59 ****************************************************************************************/
[480]60inline reg_t hal_get_sr( void );
[279]61
62/*****************************************************************************************
[1]63 * This function returns the global core identifier from the calling core register.
64 ****************************************************************************************/
[480]65inline gid_t hal_get_gid( void );
[1]66
67/*****************************************************************************************
[121]68 * This function returns the current value of the hardware cycles counter.
[408]69 * This cycle counter is reset when the core is initialised (at each boot).
[121]70 ****************************************************************************************/
[480]71inline reg_t hal_time_stamp( void );
[121]72
73/*****************************************************************************************
[296]74 * This function returns the content of the calling core private cycles counter,
75 * taking into account overflow if the core hardware register is not 64 bits.
[101]76 * This cycle counter is reset when the core is initialised (at each boot).
[1]77 ****************************************************************************************/
[480]78cycle_t hal_get_cycles( void );
[1]79
80/*****************************************************************************************
81 * This function returns the current thread pointer from the calling core register.
82 ****************************************************************************************/
[480]83inline struct thread_s * hal_get_current_thread( void );
[1]84
85/*****************************************************************************************
86 * This function registers a thread pointer in the calling core register.
87 ****************************************************************************************/
88void hal_set_current_thread( struct thread_s * thread );
89
90/*****************************************************************************************
91 * This function writes into the proper core register to enable the floating point unit.
92 ****************************************************************************************/
[480]93void hal_fpu_enable( void );
[1]94
95/*****************************************************************************************
96 * This function writes into the proper core register to disable the floating point unit.
97 ****************************************************************************************/
[480]98void hal_fpu_disable( void );
[1]99
100/*****************************************************************************************
101 * This function returns the current value of stack pointer from core register.
102 ****************************************************************************************/
[625]103reg_t hal_get_sp( void );
[1]104
105/*****************************************************************************************
106 * This function returns the faulty address in case of address exception.
107 ****************************************************************************************/
[625]108reg_t hal_get_bad_vaddr( void );
[1]109
110/*****************************************************************************************
111 * This function makes an uncachable read to a 32 bits variable in local memory.
[623]112 *****************************************************************************************
[1]113 * @ ptr     : pointer on the variable
114 * @ returns the value
115 ****************************************************************************************/
116uint32_t hal_uncached_read( uint32_t * ptr );
117
118/*****************************************************************************************
119 * This function invalidates the cache line containing a given address.
120 * @ ptr     : address in local memory
121 ****************************************************************************************/
122void hal_invalid_dcache_line( void * ptr );
123
124/*****************************************************************************************
125 * This blocking function flushes the write buffer to synchronize all pending writes.
126 ****************************************************************************************/
[480]127void hal_fence( void );
[1]128
129/*****************************************************************************************
[401]130 * This forbids code reordering accross this barrier by the compiler.
[1]131 ****************************************************************************************/
[480]132void hal_rdbar( void );
[1]133
134/*****************************************************************************************
135 * This function forces the calling core in idle-low-power mode.
136 ****************************************************************************************/
[480]137void hal_core_sleep( void ) __attribute__((__noreturn__));
[1]138
139/*****************************************************************************************
[407]140 * This function returns after approximately <delay> cycles.
141 * @ delay  : number of cycles.
[1]142 ****************************************************************************************/
[407]143void hal_fixed_delay( uint32_t delay );
[1]144
[16]145/*****************************************************************************************
[17]146 * This function returns information on MMU exceptions :
[623]147 *****************************************************************************************
[16]148 * @ mmu_ins_excp_code : [out] instruction fetch exception code
149 * @ mmu_ins_bad_vaddr : [out] instruction fetch faulty virtual address
150 * @ mmu_dat_excp_code : [out] data access exception code
151 * @ mmu_dat_bad_vaddr : [out] data access faulty virtual address
152 ****************************************************************************************/
153void hal_get_mmu_excp( intptr_t * mmu_ins_excp_code,
154                       intptr_t * mmu_ins_bad_vaddr,
155                       intptr_t * mmu_dat_excp_code,
156                       intptr_t * mmu_dat_bad_vaddr );
[1]157
158
159#endif  /* _HAL_SPECIAL_H_ */
Note: See TracBrowser for help on using the repository browser.