Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Private include for xenbus communications.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2005 Rusty Russell, IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2005 XenSource Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * modify it under the terms of the GNU General Public License version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * as published by the Free Software Foundation; or, when distributed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * separately from the Linux kernel or incorporated into other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * software packages, subject to the following license:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * Permission is hereby granted, free of charge, to any person obtaining a copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * of this source file (the "Software"), to deal in the Software without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * restriction, including without limitation the rights to use, copy, modify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * and to permit persons to whom the Software is furnished to do so, subject to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * The above copyright notice and this permission notice shall be included in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * all copies or substantial portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #ifndef _XENBUS_XENBUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define _XENBUS_XENBUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/uio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <xen/xenbus.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define XEN_BUS_ID_SIZE			20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) struct xen_bus_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	char *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	unsigned int levels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	int (*probe)(struct xen_bus_type *bus, const char *type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		     const char *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	bool (*otherend_will_handle)(struct xenbus_watch *watch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				     const char *path, const char *token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	void (*otherend_changed)(struct xenbus_watch *watch, const char *path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 				 const char *token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct bus_type bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) enum xenstore_init {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	XS_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	XS_PV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	XS_HVM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	XS_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) struct xs_watch_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct xenbus_watch *handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	const char *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	const char *token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	char body[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) enum xb_req_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	xb_req_state_queued,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	xb_req_state_wait_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	xb_req_state_got_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	xb_req_state_aborted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) struct xb_req_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	wait_queue_head_t wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct xsd_sockmsg msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	uint32_t caller_req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	enum xsd_sockmsg_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	char *body;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	const struct kvec *vec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int num_vecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	enum xb_req_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	bool user_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	void (*cb)(struct xb_req_data *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	void *par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) extern enum xenstore_init xen_store_domain_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) extern const struct attribute_group *xenbus_dev_groups[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) extern struct mutex xs_response_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) extern struct list_head xs_reply_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) extern struct list_head xb_write_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) extern wait_queue_head_t xb_waitq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) extern struct mutex xb_write_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int xs_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int xb_init_comms(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) void xb_deinit_comms(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int xs_watch_msg(struct xs_watch_event *event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) void xs_request_exit(struct xb_req_data *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int xenbus_match(struct device *_dev, struct device_driver *_drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int xenbus_dev_probe(struct device *_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int xenbus_dev_remove(struct device *_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int xenbus_register_driver_common(struct xenbus_driver *drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 				  struct xen_bus_type *bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 				  struct module *owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				  const char *mod_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int xenbus_probe_node(struct xen_bus_type *bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		      const char *type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		      const char *nodename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int xenbus_probe_devices(struct xen_bus_type *bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int xenbus_dev_suspend(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int xenbus_dev_resume(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int xenbus_dev_cancel(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) void xenbus_otherend_changed(struct xenbus_watch *watch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			     const char *path, const char *token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			     int ignore_on_shutdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int xenbus_read_otherend_details(struct xenbus_device *xendev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 				 char *id_node, char *path_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) void xenbus_ring_ops_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) void xenbus_dev_queue_reply(struct xb_req_data *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) extern unsigned int xb_dev_generation_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #endif