Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/powerpc/platforms/pseries/papr-rtas-common.h
26481 views
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
#ifndef _ASM_POWERPC_PAPR_RTAS_COMMON_H
3
#define _ASM_POWERPC_PAPR_RTAS_COMMON_H
4
5
#include <linux/types.h>
6
7
/*
8
* Return codes for sequence based RTAS calls.
9
* Not listed under PAPR+ v2.13 7.2.8: "Return Codes".
10
* But defined in the specific section of each RTAS call.
11
*/
12
#define RTAS_SEQ_COMPLETE 0 /* All data has been retrieved. */
13
#define RTAS_SEQ_MORE_DATA 1 /* More data is available */
14
#define RTAS_SEQ_START_OVER -4 /* Data changed, restart call sequence. */
15
16
/*
17
* Internal "blob" APIs for accumulating RTAS call results into
18
* an immutable buffer to be attached to a file descriptor.
19
*/
20
struct papr_rtas_blob {
21
const char *data;
22
size_t len;
23
};
24
25
/**
26
* struct papr_sequence - State for managing a sequence of RTAS calls.
27
* @error: Shall be zero as long as the sequence has not encountered an error,
28
* -ve errno otherwise. Use papr_rtas_sequence_set_err() to update.
29
* @params: Parameter block to pass to rtas_*() calls.
30
* @begin: Work area allocation and initialize the needed parameter
31
* values passed to RTAS call
32
* @end: Free the allocated work area
33
* @work: Obtain data with RTAS call and invoke it until the sequence is
34
* completed.
35
*
36
*/
37
struct papr_rtas_sequence {
38
int error;
39
void *params;
40
void (*begin)(struct papr_rtas_sequence *seq);
41
void (*end)(struct papr_rtas_sequence *seq);
42
const char *(*work)(struct papr_rtas_sequence *seq, size_t *len);
43
};
44
45
extern bool papr_rtas_blob_has_data(const struct papr_rtas_blob *blob);
46
extern void papr_rtas_blob_free(const struct papr_rtas_blob *blob);
47
extern int papr_rtas_sequence_set_err(struct papr_rtas_sequence *seq,
48
int err);
49
extern const struct papr_rtas_blob *papr_rtas_retrieve(struct papr_rtas_sequence *seq);
50
extern long papr_rtas_setup_file_interface(struct papr_rtas_sequence *seq,
51
const struct file_operations *fops, char *name);
52
extern bool papr_rtas_sequence_should_stop(const struct papr_rtas_sequence *seq,
53
s32 status, bool init_state);
54
extern ssize_t papr_rtas_common_handle_read(struct file *file,
55
char __user *buf, size_t size, loff_t *off);
56
extern int papr_rtas_common_handle_release(struct inode *inode,
57
struct file *file);
58
extern loff_t papr_rtas_common_handle_seek(struct file *file, loff_t off,
59
int whence);
60
#endif /* _ASM_POWERPC_PAPR_RTAS_COMMON_H */
61
62
63