[1] | 1 | /* |
---|
| 2 | * hal_uspace.h - Generic User Space Access API definition |
---|
| 3 | * |
---|
| 4 | * Authors Mohamed Karaoui (2015) |
---|
| 5 | * Alain Greiner (2016) |
---|
| 6 | * |
---|
| 7 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 8 | * |
---|
| 9 | * This file is part of ALMOS-MKH. |
---|
| 10 | * |
---|
| 11 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 12 | * under the terms of the GNU General Public License as published by |
---|
| 13 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 14 | * |
---|
| 15 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 18 | * General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License |
---|
| 21 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #ifndef _HAL_USPACE_H_ |
---|
| 26 | #define _HAL_USPACE_H_ |
---|
| 27 | |
---|
| 28 | #include <hal_types.h> |
---|
| 29 | |
---|
| 30 | ////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 31 | // User space access API (implementation in hal_uspace.c) |
---|
| 32 | // |
---|
| 33 | // When moving data between user space and kernel space, the user address is always |
---|
| 34 | // a virtual address, but the kernel address can be a physical address, on some |
---|
| 35 | // architectures. Therefore, data transfers must use the following API. |
---|
| 36 | ////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | /***************************************************************************************** |
---|
| 40 | * This function tranfers a data buffer from the user space to the kernel space. |
---|
| 41 | * As the kernel is using physical addresses on the TSAR architecture, it activates |
---|
| 42 | * the MMU to access the user buffer. |
---|
| 43 | ***************************************************************************************** |
---|
| 44 | * @ k_dst : destination address in kernel space. |
---|
| 45 | * @ u_src : source buffer address in user space. |
---|
| 46 | * @ size : size (number of bytes). |
---|
| 47 | ****************************************************************************************/ |
---|
| 48 | extern void hal_copy_from_uspace( void * k_dst, |
---|
| 49 | void * u_src, |
---|
| 50 | uint32_t size ); |
---|
| 51 | |
---|
| 52 | /***************************************************************************************** |
---|
| 53 | * This function tranfers a data buffer from the kernel space to the user space. |
---|
| 54 | * As the kernel is using physical addresses on the TSAR architecture, it activates |
---|
| 55 | * the MMU to access the user buffer. |
---|
| 56 | ***************************************************************************************** |
---|
| 57 | * @ u_dst : destination buffer address and size in user space. |
---|
| 58 | * @ k_src : source address in kernel space. |
---|
| 59 | * @ size : size (number of bytes). |
---|
| 60 | ****************************************************************************************/ |
---|
| 61 | extern void hal_copy_to_uspace( void * udst, |
---|
| 62 | void * ksrc, |
---|
| 63 | uint32_t size ); |
---|
| 64 | |
---|
| 65 | /***************************************************************************************** |
---|
| 66 | * This function activates the MMU to computes the length of a string in user space, |
---|
| 67 | * and returns it to a kernel buffer. |
---|
| 68 | ***************************************************************************************** |
---|
| 69 | * @ u_str : string address in user space. |
---|
| 70 | * @ return length of the string. |
---|
| 71 | ****************************************************************************************/ |
---|
| 72 | uint32_t hal_strlen_from_uspace( char * string ); |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | #endif /* _HAL_USPACE_H_ */ |
---|