Changeset 17 for trunk/hal/generic
- Timestamp:
- May 11, 2017, 7:49:17 PM (8 years ago)
- Location:
- trunk/hal/generic
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/generic/hal_atomic.h
r16 r17 1 1 /* 2 2 * hal_atomic.h - Generic Atomic Operations API definition. 3 * 3 * 4 4 * Authors Alain Greiner (2016) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites 7 * 7 * 8 8 * This file is part of ALMOS-MKH. 9 9 * … … 29 29 30 30 ////////////////////////////////////////////////////////////////////////////////////////// 31 // Generic Atomic Operations API (implementation in hal_atomic.c) 31 // Generic Atomic Operations API (implementation in hal_atomic.c) 32 32 // 33 // Atomic read-then-write operations depend s on the CPU instruction set.33 // Atomic read-then-write operations depend on the CPU instruction set. 34 34 // ALMOS-MKH uses the following generic API. 35 35 ////////////////////////////////////////////////////////////////////////////////////////// … … 40 40 ***************************************************************************************** 41 41 * @ ptr : pointer on the shared variable 42 * @ val : mask value 42 * @ val : mask value 43 43 ****************************************************************************************/ 44 44 void hal_atomic_and( uint32_t * ptr, … … 85 85 86 86 /***************************************************************************************** 87 * This NON blocking function makes an atomic Compare-And-Swap on a 32 bits unsigned int 87 * This NON blocking function makes an atomic Compare-And-Swap on a 32 bits unsigned int 88 88 * shared variable, returning a Boolean to indicate both success and atomicity. 89 89 ***************************************************************************************** … … 98 98 99 99 /***************************************************************************************** 100 * This non blocking function makes an atomic Test-if-zero-And-Set on a 32 bits unsigned 100 * This non blocking function makes an atomic Test-if-zero-And-Set on a 32 bits unsigned 101 101 * int shared variable, returning a Boolean to indicate both success and atomicity. 102 102 ***************************************************************************************** … … 105 105 * @ return true if (current == 0) and (access is atomic) 106 106 ****************************************************************************************/ 107 bool_t hal_atomic_test_set( uint32_t * ptr, 107 bool_t hal_atomic_test_set( uint32_t * ptr, 108 108 uint32_t val ); 109 109 -
trunk/hal/generic/hal_context.h
r16 r17 29 29 // 30 30 // A thread context is defined by the two (core specific) structures hal_context_t 31 // and hal_uzone_t, defined 31 // and hal_uzone_t, defined in hal_context.c file, that are accessed with generic 32 32 // void* pointers stored in the thread descriptor. 33 33 // - the "hal_context_t" structure is used to store the CPU registers values that … … 87 87 /**************************************************************************************** 88 88 * This function allocates, from the local cluster, the physical memory required for 89 * the thread CPU context, initialises it, and link the context to the thread.89 * the thread CPU context, initialises it, and links the context to the thread. 90 90 * Seven registers are initialised: 91 91 * - sp_29 / fp_30 / ra_31 … … 101 101 * This function allocates, from the local cluster, the physical memory required for 102 102 * a thread CPU context, initialises it from values contained in "src" thread context, 103 * and link the context to the "dst" thread.103 * and links the context to the "dst" thread. 104 104 **************************************************************************************** 105 105 * @ dst : pointer on the destination thread descriptor. … … 118 118 119 119 /**************************************************************************************** 120 * This function save in the thread context the CPU registers values that have not120 * This function saves in the thread context the CPU registers values that have not 121 121 * been saved in the thread stack by the exception handler: 122 122 * - GRs : s0 to S7 , sp , fp, ra … … 129 129 130 130 /**************************************************************************************** 131 * This function restore from the thread context the CPU registers values that have not131 * This function restores from the thread context the CPU registers values that have not 132 132 * been saved in the thread stack by the exception handler. 133 133 * - GRs : s0 to S7 , sp , fp, ra … … 140 140 141 141 /**************************************************************************************** 142 * This function load the relevant CPU registers from values contained in142 * This function loads the relevant CPU registers from values contained in 143 143 * the thread context. It should be called for a thread that has not been executed yet. 144 144 * - GRs : sp , fp , a0 … … 182 182 183 183 /**************************************************************************************** 184 * This function save in the thread uzone the FPU registers values.184 * This function saves in the thread uzone the FPU registers values. 185 185 **************************************************************************************** 186 186 * @ thread : pointer on the thread descriptor. … … 189 189 190 190 /**************************************************************************************** 191 * This function restore from the thread uzone the FPU registers values.191 * This function restores from the thread uzone the FPU registers values. 192 192 **************************************************************************************** 193 193 * @ thread : pointer on the thread descriptor. -
trunk/hal/generic/hal_exception.h
r16 r17 32 32 // ALMOS-MKH defines three classes of exceptions: 33 33 // 34 // - NON_FATAL : exceptions such as "page fault" or FPU unusable" are non fatal.35 // and the calling thread resumeexecution when the exception has been handled.34 // - NON_FATAL : exceptions such as "page fault" or "FPU unusable" are non fatal. 35 // The calling thread resumes execution when the exception has been handled. 36 36 // 37 37 // - USER_ERROR : these exceptions such a "illegal vaddr" or "illegal write access" … … 40 40 // 41 41 // - KERNEL_PANIC : events such as "no memory" or "kernel mistakes" are considered 42 // abnormal events. The calling core goes to sleep, after a fter a"panic" message42 // abnormal events. The calling core goes to sleep, after a "panic" message 43 43 // on the kernel terminal. 44 44 // … … 66 66 67 67 /***************************************************************************************** 68 * This function print on the kernel terminal the saved context (core registers)68 * This function prints on the kernel terminal the saved context (core registers) 69 69 * and the thread state of a faulty thread. 70 70 ***************************************************************************************** -
trunk/hal/generic/hal_gpt.h
r16 r17 30 30 // Generic Page Table Definition (implementation in hal_gpt.c) 31 31 // 32 // It is specified as a simple (one dimension nal) array indexed by the VPN (vpn_t type),33 // even if implementations can use a more sophisticated organis tion (two-levels or more).34 // - The number of entries (number of pages in a virtual space) is architecture 35 // depend ant, and is defined as (CONFIG_USER_SPACE_SIZE / CONFIG_PPM_PAGE_SIZE).36 // - Each entry contains a Physical Page Number (ppn_t type), 32 // It is specified as a simple (one dimensional) array indexed by the VPN (vpn_t type), 33 // even if implementations can use a more sophisticated organisation (two-levels or more). 34 // - The number of entries (number of pages in a virtual space) is architecture 35 // dependent, and is defined as (CONFIG_USER_SPACE_SIZE / CONFIG_PPM_PAGE_SIZE). 36 // - Each entry contains a Physical Page Number (ppn_t type), and a set of attributes, 37 37 // defined as masks on a 32 bits-vector. 38 38 // 39 // Any arch-specific implementation must implement this API. 39 // Any arch-specific implementation must implement this API. 40 40 ///////////////////////////////////////////////////////////////////////////////////////// 41 41 … … 71 71 void * ptr; /*! pointer on GPT root (must be page aligned) */ 72 72 ppn_t ppn; /*! PPN of GPT root */ 73 73 struct page_s * page; /*! pointer on page descriptor for GPT root */ 74 74 } 75 75 gpt_t; … … 78 78 /**************************************************************************************** 79 79 * This function allocates physical memory for first level page table (PT1), 80 * and initialize the page table descriptor.80 * and initializes the page table descriptor. 81 81 **************************************************************************************** 82 82 * @ gpt : pointer on generic page table descriptor. … … 88 88 * This function releases all memory dynamically allocated for a generic page table. 89 89 * For a multi-levels radix tree implementation, it includes all nodes in the tree. 90 * If the calling thread is running in the reference cluster, it checks that user PTE 90 * If the calling thread is running in the reference cluster, it checks that user PTE 91 91 * entries are unmapped, and release the mapped physical pages. 92 92 * The kernel pages are not released. … … 104 104 105 105 /**************************************************************************************** 106 * This blocking f onction geta lock on a PTE (page Table Entry) identified106 * This blocking function gets a lock on a PTE (page Table Entry) identified 107 107 * by its VPN, and returns only when the PTE has been successfully locked. 108 * If the target PTE is not present, it allocates and map a physical page.108 * If the target PTE is not present, it allocates and maps a physical page. 109 109 * A big page cannot be locked. 110 110 **************************************************************************************** 111 * @ gpt : pointer on the generic page table 111 * @ gpt : pointer on the generic page table 112 112 * @ vpn : virtual page number of the target PTE. 113 * @ returns 0 if success / return ENOMEM or EINVAL if error. 113 * @ returns 0 if success / return ENOMEM or EINVAL if error. 114 114 ***************************************************************************************/ 115 115 error_t hal_gpt_lock_pte( gpt_t * gpt, … … 119 119 * This function releases the lock on a PTE identified by its VPN. 120 120 **************************************************************************************** 121 * @ gpt : pointer on the generic page table 121 * @ gpt : pointer on the generic page table 122 122 * @ vpn : virtual page number of the target PTE. 123 * @ returns 0 if success / returns EINVAL if error. 123 * @ returns 0 if success / returns EINVAL if error. 124 124 ***************************************************************************************/ 125 error_t hal_gpt_unlock_pte( gpt_t * gpt, 126 vpn_t vpn ); 125 error_t hal_gpt_unlock_pte( gpt_t * gpt, 126 vpn_t vpn ); 127 127 128 128 /**************************************************************************************** 129 * This function map a page table entry identified by its VPN, from values defined129 * This function maps a page table entry identified by its VPN, from values defined 130 130 * by the ppn and attr arguments. It allocates physical memory for the local generic 131 131 * page table itself if required. … … 133 133 * @ gpt : [in] pointer on the page table 134 134 * @ vpn : [in] virtual page number 135 * @ ppn : [in] physical page number 135 * @ ppn : [in] physical page number 136 136 * @ attr : [in] generic attributes 137 137 * @ returns 0 if success / returns ENOMEM if error … … 143 143 144 144 /**************************************************************************************** 145 * This function unmap a page table entry identified by its VPN.146 * If the calling thread is running in the reference cluster, it send a broadcast RPC147 * to update all other spage table copies.145 * This function unmaps a page table entry identified by its VPN. 146 * If the calling thread is running in the reference cluster, it sends a broadcast RPC 147 * to update all other page table copies. 148 148 **************************************************************************************** 149 149 * @ gpt : [in] pointer on the page table … … 160 160 * @ vpn : [in] virtual page number 161 161 * @ attr : [out] generic attributes 162 * @ ppn : [out] physical page number 162 * @ ppn : [out] physical page number 163 163 ***************************************************************************************/ 164 164 void hal_gpt_get_pte( gpt_t * gpt, … … 166 166 uint32_t * attr, 167 167 ppn_t * ppn ); 168 168 169 169 170 170 #endif /* _GPT_H_ */ -
trunk/hal/generic/hal_interrupt.h
r16 r17 1 1 /* 2 2 * hal_interrupt.h - Architecture specific interrupt handler API definition. 3 * 3 * 4 4 * Author Alain Greiner (2016,2017) 5 5 * … … 32 32 // The interrupted thread context (core registers) has been saved by the hal_kentry 33 33 // function, in the cpu_uzone array stored in the user thread descriptor (for a core in 34 // user mode), or in the kernel stack (for a core in kernel mode). 34 // user mode), or in the kernel stack (for a core in kernel mode). 35 35 // This array can be used (or not) by the specific interrupt handler. 36 36 // … … 43 43 44 44 /****************************************************************************************** 45 * This function implement the TSAR_MIPS32 specific interrupt handler.45 * This function implements the TSAR_MIPS32 specific interrupt handler. 46 46 ****************************************************************************************** 47 47 * @ this : pointer on the interrupted thread. 48 48 * @ regs_tbl : array containing the core registers values, saved by hal_kentry. 49 49 *****************************************************************************************/ 50 void hal_do_interrupt( struct thread_s * this, 50 void hal_do_interrupt( struct thread_s * this, 51 51 reg_t * regs_tbl ); 52 52 -
trunk/hal/generic/hal_irqmask.h
r16 r17 1 1 /* 2 2 * hal_irqmask.h - Generic Interrupt Masking API definition 3 * 3 * 4 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) 5 5 * Alain Greiner (2016) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites 8 * 8 * 9 9 * This file is part of ALMOS-MKH. 10 10 * -
trunk/hal/generic/hal_remote.h
r16 r17 1 1 /* 2 2 * hal_remote.h - Generic Remote Access API definition. 3 * 3 * 4 4 * Authors Mohamed Karaoui (2015) 5 5 * Alain Greiner (2016) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites 8 * 8 * 9 9 * This file is part of ALMOS-MKH. 10 10 * … … 29 29 30 30 ////////////////////////////////////////////////////////////////////////////////////////// 31 // Generic Remote Access API (implementation in hal_remote.c)31 // Generic Remote Access API (implementation in hal_remote.c) 32 32 // 33 33 // Kernel accesses to local memory bank and peripherals can use normal C pointers. … … 76 76 ***************************************************************************************** 77 77 * @ xp : extended pointer to remote data 78 * @ return read value 78 * @ return read value 79 79 ****************************************************************************************/ 80 80 char hal_remote_lb( xptr_t xp ); … … 118 118 * @ old : expected value 119 119 * @ new : new value to be written 120 * @ return true if success / return false if failure 120 * @ return true if success / return false if failure 121 121 ****************************************************************************************/ 122 122 bool_t hal_remote_atomic_cas( xptr_t xp, … … 132 132 * @ return old value (before increment) of the remote integer 133 133 ****************************************************************************************/ 134 uint32_t hal_remote_atomic_add( xptr_t xp, 134 uint32_t hal_remote_atomic_add( xptr_t xp, 135 135 uint32_t incr ); 136 136 … … 143 143 * @ return old value (before increment) of the remote integer 144 144 ****************************************************************************************/ 145 uint32_t hal_remote_atomic_and( xptr_t xp, 145 uint32_t hal_remote_atomic_and( xptr_t xp, 146 146 uint32_t mask ); 147 147 … … 154 154 * @ return old value (before increment) of the remote integer 155 155 ****************************************************************************************/ 156 uint32_t hal_remote_atomic_or( xptr_t xp, 156 uint32_t hal_remote_atomic_or( xptr_t xp, 157 157 uint32_t mask ); 158 158 … … 164 164 * @ incr : increment value. 165 165 * @ old : local buffer address for the read value (before increment) 166 * @ return 0 if atomic / return non-zero if failure 166 * @ return 0 if atomic / return non-zero if failure 167 167 ****************************************************************************************/ 168 168 error_t hal_remote_atomic_try_add( xptr_t xp, … … 179 179 ****************************************************************************************/ 180 180 void hal_remote_memcpy( xptr_t dst, 181 xptr_t src, 181 xptr_t src, 182 182 uint32_t size ); 183 183 -
trunk/hal/generic/hal_special.h
r16 r17 1 1 /* 2 2 * hal_special.h - Generic Special Registers Access API definition. 3 * 3 * 4 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) 5 5 * Alain Greiner (2016) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites 8 * 8 * 9 9 * This file is part of ALMOS-MKH. 10 10 * … … 34 34 /////////////////////////////////////////////////////////////////////////////////////////// 35 35 // Generic Special Registers Access API (implementation in hal_special.c) 36 // 36 // 37 37 // ALMOS-MKH uses the following API to access the MMU and other core protected registers. 38 38 /////////////////////////////////////////////////////////////////////////////////////////// … … 112 112 113 113 /***************************************************************************************** 114 * This function returns after a fixed delay of 114 * This function returns after a fixed delay of (4 * delay) cycles. 115 115 ****************************************************************************************/ 116 116 void hal_fixed_delay(); 117 117 118 118 /***************************************************************************************** 119 * This function returns information son MMU exceptions :119 * This function returns information on MMU exceptions : 120 120 * @ mmu_ins_excp_code : [out] instruction fetch exception code 121 121 * @ mmu_ins_bad_vaddr : [out] instruction fetch faulty virtual address -
trunk/hal/generic/hal_syscall.h
r16 r17 1 1 /* 2 2 * hal_syscall.h - Architecture specific syscall handler API definition. 3 * 3 * 4 4 * Author Alain Greiner (2016,2017) 5 5 * … … 28 28 29 29 ////////////////////////////////////////////////////////////////////////////////////////// 30 // ARchitecture specific syscall handler 30 // ARchitecture specific syscall handler API 31 31 // 32 // The calling thread context has been saved in the cpu_uzone array, 32 // The calling thread context has been saved in the cpu_uzone array, 33 33 // stored in the user thread descriptor by the hal_kentry function. 34 34 // The architecture specific handler must use this array to get the syscall -
trunk/hal/generic/hal_uspace.h
r16 r17 1 1 /* 2 2 * hal_uspace.h - Generic User Space Access API definition 3 * 3 * 4 4 * Authors Mohamed Karaoui (2015) 5 5 * Alain Greiner (2016) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites 8 * 8 * 9 9 * This file is part of ALMOS-MKH. 10 10 * … … 30 30 ////////////////////////////////////////////////////////////////////////////////////////// 31 31 // User space access API (implementation in hal_uspace.c) 32 // 32 // 33 33 // When moving data between user space and kernel space, the user address is always 34 34 // a virtual address, but the kernel address can be a physical address, on some … … 64 64 65 65 /***************************************************************************************** 66 * This function activates the MMU to compute sthe length of a string in user space,66 * This function activates the MMU to compute the length of a string in user space, 67 67 * and returns it to a kernel buffer. 68 68 *****************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.