1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2 /*
3  * Apple RTKit IPC library
4  * Copyright (C) The Asahi Linux Contributors
5  */
6 
7 #ifndef _APPLE_RTKIT_INTERAL_H
8 #define _APPLE_RTKIT_INTERAL_H
9 
10 #include <linux/apple-mailbox.h>
11 #include <linux/bitfield.h>
12 #include <linux/bitmap.h>
13 #include <linux/completion.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/io.h>
16 #include <linux/kernel.h>
17 #include <linux/mailbox_client.h>
18 #include <linux/module.h>
19 #include <linux/slab.h>
20 #include <linux/soc/apple/rtkit.h>
21 #include <linux/workqueue.h>
22 
23 #define APPLE_RTKIT_APP_ENDPOINT_START 0x20
24 #define APPLE_RTKIT_MAX_ENDPOINTS 0x100
25 
26 struct apple_rtkit {
27 	void *cookie;
28 	const struct apple_rtkit_ops *ops;
29 	struct device *dev;
30 
31 	const char *mbox_name;
32 	int mbox_idx;
33 	struct mbox_client mbox_cl;
34 	struct mbox_chan *mbox_chan;
35 
36 	struct completion epmap_completion;
37 	struct completion iop_pwr_ack_completion;
38 	struct completion ap_pwr_ack_completion;
39 
40 	int boot_result;
41 	int version;
42 
43 	unsigned int iop_power_state;
44 	unsigned int ap_power_state;
45 	bool crashed;
46 
47 	DECLARE_BITMAP(endpoints, APPLE_RTKIT_MAX_ENDPOINTS);
48 
49 	struct apple_rtkit_shmem ioreport_buffer;
50 	struct apple_rtkit_shmem crashlog_buffer;
51 
52 	struct apple_rtkit_shmem syslog_buffer;
53 	char *syslog_msg_buffer;
54 	size_t syslog_n_entries;
55 	size_t syslog_msg_size;
56 
57 	struct workqueue_struct *wq;
58 };
59 
60 void apple_rtkit_crashlog_dump(struct apple_rtkit *rtk, u8 *bfr, size_t size);
61 
62 #endif
63