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

Last change on this file since 619 was 619, checked in by alain, 5 years ago

1) Fix a bug in KSH : after the "load" command,

the [ksh] prompt is now printed after completion
of the loaded application.

2) Fix a bug in vmm_handle_cow() : the copy-on-write

use now a hal_remote_memcpy() to replicate the page content.


File size: 7.7 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;
33
34///////////////////////////////////////////////////////////////////////////////////////////
35//      Generic Special Registers Access API (implementation in hal_special.c)
[17]36//
[296]37// ALMOS-MKH uses the following API to access the core protected registers.
[1]38///////////////////////////////////////////////////////////////////////////////////////////
39
40/*****************************************************************************************
[279]41 * This function returns the calling core status register value.
42 ****************************************************************************************/
[480]43inline reg_t hal_get_sr( void );
[279]44
45/*****************************************************************************************
[1]46 * This function returns the global core identifier from the calling core register.
47 ****************************************************************************************/
[480]48inline gid_t hal_get_gid( void );
[1]49
50/*****************************************************************************************
[121]51 * This function returns the current value of the hardware cycles counter.
[408]52 * This cycle counter is reset when the core is initialised (at each boot).
[121]53 ****************************************************************************************/
[480]54inline reg_t hal_time_stamp( void );
[121]55
56/*****************************************************************************************
[296]57 * This function returns the content of the calling core private cycles counter,
58 * taking into account overflow if the core hardware register is not 64 bits.
[101]59 * This cycle counter is reset when the core is initialised (at each boot).
[1]60 ****************************************************************************************/
[480]61cycle_t hal_get_cycles( void );
[1]62
63/*****************************************************************************************
64 * This function returns the current thread pointer from the calling core register.
65 ****************************************************************************************/
[480]66inline struct thread_s * hal_get_current_thread( void );
[1]67
68/*****************************************************************************************
69 * This function registers a thread pointer in the calling core register.
70 ****************************************************************************************/
71void hal_set_current_thread( struct thread_s * thread );
72
73/*****************************************************************************************
74 * This function writes into the proper core register to enable the floating point unit.
75 ****************************************************************************************/
[480]76void hal_fpu_enable( void );
[1]77
78/*****************************************************************************************
79 * This function writes into the proper core register to disable the floating point unit.
80 ****************************************************************************************/
[480]81void hal_fpu_disable( void );
[1]82
83/*****************************************************************************************
84 * This function returns the current value of stack pointer from core register.
85 ****************************************************************************************/
[619]86uint32_t hal_get_sp( void );
[1]87
88/*****************************************************************************************
[619]89 * This function returns the current value of the return adddress from core register.
90 ****************************************************************************************/
91uint32_t hal_get_ra( void );
92
93/*****************************************************************************************
[1]94 * This function registers a new value in the core stack pointer and returns previous one.
95 ****************************************************************************************/
[619]96inline uint32_t hal_set_sp( void * new_val );
[1]97
98/*****************************************************************************************
99 * This function returns the faulty address in case of address exception.
100 ****************************************************************************************/
[480]101uint32_t hal_get_bad_vaddr( void );
[1]102
103/*****************************************************************************************
104 * This function makes an uncachable read to a 32 bits variable in local memory.
105 * @ ptr     : pointer on the variable
106 * @ returns the value
107 ****************************************************************************************/
108uint32_t hal_uncached_read( uint32_t * ptr );
109
110/*****************************************************************************************
111 * This function invalidates the cache line containing a given address.
112 * @ ptr     : address in local memory
113 ****************************************************************************************/
114void hal_invalid_dcache_line( void * ptr );
115
116/*****************************************************************************************
117 * This blocking function flushes the write buffer to synchronize all pending writes.
118 ****************************************************************************************/
[480]119void hal_fence( void );
[1]120
121/*****************************************************************************************
[401]122 * This forbids code reordering accross this barrier by the compiler.
[1]123 ****************************************************************************************/
[480]124void hal_rdbar( void );
[1]125
126/*****************************************************************************************
127 * This function forces the calling core in idle-low-power mode.
128 ****************************************************************************************/
[480]129void hal_core_sleep( void ) __attribute__((__noreturn__));
[1]130
131/*****************************************************************************************
[407]132 * This function returns after approximately <delay> cycles.
133 * @ delay  : number of cycles.
[1]134 ****************************************************************************************/
[407]135void hal_fixed_delay( uint32_t delay );
[1]136
[16]137/*****************************************************************************************
[17]138 * This function returns information on MMU exceptions :
[16]139 * @ mmu_ins_excp_code : [out] instruction fetch exception code
140 * @ mmu_ins_bad_vaddr : [out] instruction fetch faulty virtual address
141 * @ mmu_dat_excp_code : [out] data access exception code
142 * @ mmu_dat_bad_vaddr : [out] data access faulty virtual address
143 ****************************************************************************************/
144void hal_get_mmu_excp( intptr_t * mmu_ins_excp_code,
145                       intptr_t * mmu_ins_bad_vaddr,
146                       intptr_t * mmu_dat_excp_code,
147                       intptr_t * mmu_dat_bad_vaddr );
[1]148
149
150#endif  /* _HAL_SPECIAL_H_ */
Note: See TracBrowser for help on using the repository browser.