2 * Copyright (C) 2016 Google, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef GOLDFISH_PIPE_H
15 #define GOLDFISH_PIPE_H
17 #include <linux/module.h>
18 #include <linux/interrupt.h>
19 #include <linux/kernel.h>
20 #include <linux/spinlock.h>
21 #include <linux/miscdevice.h>
22 #include <linux/platform_device.h>
23 #include <linux/poll.h>
24 #include <linux/sched.h>
25 #include <linux/bitops.h>
26 #include <linux/slab.h>
28 #include <linux/goldfish.h>
30 #include <linux/acpi.h>
33 /* Initialize the legacy version of the pipe device driver */
34 int goldfish_pipe_device_init_v1(struct platform_device *pdev);
36 /* Deinitialize the legacy version of the pipe device driver */
37 void goldfish_pipe_device_deinit_v1(struct platform_device *pdev);
39 /* Forward declarations for the device struct */
41 struct goldfish_pipe_device_buffers;
43 /* The global driver data. Holds a reference to the i/o page used to
44 * communicate with the emulator, and a wake queue for blocked tasks
45 * waiting to be awoken.
47 struct goldfish_pipe_dev {
49 * Global device spinlock. Protects the following members:
50 * - pipes, pipes_capacity
51 * - [*pipes, *pipes + pipes_capacity) - array data
52 * - first_signalled_pipe,
53 * goldfish_pipe::prev_signalled,
54 * goldfish_pipe::next_signalled,
55 * goldfish_pipe::signalled_flags - all singnalled-related fields,
56 * in all allocated pipes
57 * - open_command_params - PIPE_CMD_OPEN-related buffers
59 * It looks like a lot of different fields, but the trick is that the only
60 * operation that happens often is the signalled pipes array manipulation.
61 * That's why it's OK for now to keep the rest of the fields under the same
62 * lock. If we notice too much contention because of PIPE_CMD_OPEN,
63 * then we should add a separate lock there.
68 * Array of the pipes of |pipes_capacity| elements,
69 * indexed by goldfish_pipe::id
71 struct goldfish_pipe **pipes;
74 /* Pointers to the buffers host uses for interaction with this driver */
75 struct goldfish_pipe_dev_buffers *buffers;
77 /* Head of a doubly linked list of signalled pipes */
78 struct goldfish_pipe *first_signalled_pipe;
80 /* Some device-specific data */
83 unsigned char __iomem *base;
85 /* v1-specific access parameters */
86 struct access_params *aps;
89 extern struct goldfish_pipe_dev pipe_dev[1];
91 #endif /* GOLDFISH_PIPE_H */