source: trunk/hal/generic/hal_uspace.h @ 630

Last change on this file since 630 was 626, checked in by alain, 6 years ago

This version has been tested on the sort multithreaded application
for TSAR_IOB architectures ranging from 1 to 8 clusters.
It fixes three bigs bugs:
1) the dev_ioc device API has been modified: the dev_ioc_sync_read()
and dev_ioc_sync_write() function use now extended pointers on the
kernel buffer to access a mapper stored in any cluster.
2) the hal_uspace API has been modified: the hal_copy_to_uspace()
and hal_copy_from_uspace() functions use now a (cxy,ptr) couple
to identify the target buffer (equivalent to an extended pointer.
3) an implementation bug has been fixed in the assembly code contained
in the hal_copy_to_uspace() and hal_copy_from_uspace() functions.

File size: 5.4 KB
Line 
1/*
2 * hal_uspace.h - Generic User Space Access API definition
3 *
4 * Authors    Alain Greiner (2016,2017,2018,2019)
5 *
6 * Copyright (c)  UPMC Sorbonne Universites
7 *
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_USPACE_H_
25#define  _HAL_USPACE_H_
26
27#include <hal_kernel_types.h>
28
29//////////////////////////////////////////////////////////////////////////////////////////
30//           User space access API (implementation in hal_uspace.c)
31//
32// When moving data between user space and kernel space, the user address is always
33// a virtual address, but the kernel address can be a physical address, on 32 bits
34// architectures, and require MMU dynamic activation/deactivation.
35// For sake of portability, user/kernel data transfers must use the following API.
36//////////////////////////////////////////////////////////////////////////////////////////
37
38
39/*****************************************************************************************
40 * This function tranfers a data buffer in user space to a kernel buffer
41 * that can be located in any cluster.
42 *****************************************************************************************
43 * @ k_cxy     : cluster identifier for kernel destination buffer.
44 * @ k_dst     : local pointer on kernel destination buffer.
45 * @ u_src     : source buffer address in user space.
46 * @ size      : size (number of bytes).
47 ****************************************************************************************/
48extern void hal_copy_from_uspace( cxy_t      k_cxy,
49                                  void     * k_dst,
50                                  void     * u_src,
51                                  uint32_t   size );
52
53/*****************************************************************************************
54 * This function tranfers a kernel buffer that can be located in any cluster
55 * to a data buffer in the user space.
56 *****************************************************************************************
57 * @ k_cxy     : cluster identifier for kernel source buffer.
58 * @ k_src     : local pointer on kernel source buffer.
59 * @ u_dst     : destination buffer address in user space.
60 * @ size      : size (number of bytes).
61 ****************************************************************************************/
62extern void hal_copy_to_uspace( cxy_t      k_cxy,
63                                void     * k_src,
64                                void     * u_dst,
65                                uint32_t   size );
66
67/*****************************************************************************************
68 * This function tranfers a string from the user space to the kernel space.
69 * The transfer stops after the first encountered NUL character, and no more than
70 * <max_size> characters are actually copied to target buffer.
71 * If the kernel uses physical addresses, it activates the MMU to access the user buffer.
72 *****************************************************************************************
73 * @ u_dst     : destination buffer address in user space.
74 * @ k_src     : source address in kernel space.
75 * @ max_size  : max number of characters to be copied.
76 ****************************************************************************************/
77extern void hal_strcpy_from_uspace( char     * k_dst,
78                                    char     * u_src, 
79                                    uint32_t   max_size );
80
81/*****************************************************************************************
82 * This function tranfers a string from the kernel space to the user space.
83 * The transfer stops after the first encountered NUL character, and no more than
84 * <max_size> characters are actually copied to target buffer.
85 * If the kernel uses physical addresses, it activates the MMU to access the user buffer.
86 *****************************************************************************************
87 * @ u_dst     : destination buffer address in user space.
88 * @ k_src     : source address in kernel space.
89 * @ max_size  : max number of characters to be copied.
90 ****************************************************************************************/
91extern void hal_strcpy_to_uspace( char     * u_dst,
92                                  char     * k_src,
93                                  uint32_t   max_size );
94
95/*****************************************************************************************
96 * This function computes the length of a string in user space.
97 * If the kernel uses physical addresses, it activates the MMU to access the user buffer.
98 *****************************************************************************************
99 * @ string     : string in user space.
100 * @ return length of the string.
101 ****************************************************************************************/
102uint32_t hal_strlen_from_uspace( char * string );
103
104
105#endif  /* _HAL_USPACE_H_ */
Note: See TracBrowser for help on using the repository browser.