• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2017, 2020-2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 #ifndef _KERNEL_UTF_HELPERS_H_
23 #define _KERNEL_UTF_HELPERS_H_
24 
25 /* kutf_helpers.h
26  * Test helper functions for the kernel UTF test infrastructure.
27  *
28  * These functions provide methods for enqueuing/dequeuing lines of text sent
29  * by user space. They are used to implement the transfer of "userdata" from
30  * user space to kernel.
31  */
32 
33 #include <kutf/kutf_suite.h>
34 
35 /**
36  * kutf_helper_pending_input() - Check any pending lines sent by user space
37  * @context:    KUTF context
38  *
39  * Return: true if there are pending lines, otherwise false
40  */
41 bool kutf_helper_pending_input(struct kutf_context *context);
42 
43 /**
44  * kutf_helper_input_dequeue() - Dequeue a line sent by user space
45  * @context:    KUTF context
46  * @str_size:   Pointer to an integer to receive the size of the string
47  *
48  * If no line is available then this function will wait (interruptibly) until
49  * a line is available.
50  *
51  * Return: The line dequeued, ERR_PTR(-EINTR) if interrupted or NULL on end
52  * of data.
53  */
54 char *kutf_helper_input_dequeue(struct kutf_context *context, size_t *str_size);
55 
56 /**
57  * kutf_helper_input_enqueue() - Enqueue a line sent by user space
58  * @context:   KUTF context
59  * @str:       The user space address of the line
60  * @size:      The length in bytes of the string
61  *
62  * This function will use copy_from_user to copy the string out of user space.
63  * The string need not be NULL-terminated (@size should not include the NULL
64  * termination).
65  *
66  * As a special case @str==NULL and @size==0 is valid to mark the end of input,
67  * but callers should use kutf_helper_input_enqueue_end_of_data() instead.
68  *
69  * Return: 0 on success, -EFAULT if the line cannot be copied from user space,
70  * -ENOMEM if out of memory.
71  */
72 int kutf_helper_input_enqueue(struct kutf_context *context,
73 		const char __user *str, size_t size);
74 
75 /**
76  * kutf_helper_input_enqueue_end_of_data() - Signal no more data is to be sent
77  * @context:    KUTF context
78  *
79  * After this function has been called, kutf_helper_input_dequeue() will always
80  * return NULL.
81  */
82 void kutf_helper_input_enqueue_end_of_data(struct kutf_context *context);
83 
84 /* kutf_helper_external_reset_gpu() - Mimic power-on-reset using external reset
85  *
86  * Reset GPU using FPGA SYSCTL register.
87  *
88  * Note that
89  * - It must be called on the platform that has FPGA SYSCTL
90  *   register available such as Juno board.
91  * - It won't reinitialize GPU related settings such as interrupt for kbase.
92  *
93  * Return:  0 on success, negative value otherwise.
94  */
95 int kutf_helper_external_reset_gpu(void);
96 
97 #endif	/* _KERNEL_UTF_HELPERS_H_ */
98