1#ifndef _SPARC64_LDC_H
2#define _SPARC64_LDC_H
3
4#include <asm/hypervisor.h>
5
6extern int ldom_domaining_enabled;
7void ldom_set_var(const char *var, const char *value);
8void ldom_reboot(const char *boot_command);
9void ldom_power_off(void);
10
11
12
13
14
15
16
17
18
19
20
21struct ldc_channel_config {
22 void (*event)(void *arg, int event);
23
24 u32 mtu;
25 unsigned int rx_irq;
26 unsigned int tx_irq;
27 u8 mode;
28#define LDC_MODE_RAW 0x00
29#define LDC_MODE_UNRELIABLE 0x01
30#define LDC_MODE_RESERVED 0x02
31#define LDC_MODE_STREAM 0x03
32
33 u8 debug;
34#define LDC_DEBUG_HS 0x01
35#define LDC_DEBUG_STATE 0x02
36#define LDC_DEBUG_RX 0x04
37#define LDC_DEBUG_TX 0x08
38#define LDC_DEBUG_DATA 0x10
39};
40
41#define LDC_EVENT_RESET 0x01
42#define LDC_EVENT_UP 0x02
43#define LDC_EVENT_DATA_READY 0x04
44
45#define LDC_STATE_INVALID 0x00
46#define LDC_STATE_INIT 0x01
47#define LDC_STATE_BOUND 0x02
48#define LDC_STATE_READY 0x03
49#define LDC_STATE_CONNECTED 0x04
50
51struct ldc_channel;
52
53
54struct ldc_channel *ldc_alloc(unsigned long id,
55 const struct ldc_channel_config *cfgp,
56 void *event_arg,
57 const char *name);
58
59
60void ldc_free(struct ldc_channel *lp);
61
62
63int ldc_bind(struct ldc_channel *lp);
64void ldc_unbind(struct ldc_channel *lp);
65
66
67
68
69
70
71int ldc_connect(struct ldc_channel *lp);
72int ldc_disconnect(struct ldc_channel *lp);
73
74int ldc_state(struct ldc_channel *lp);
75
76
77int ldc_write(struct ldc_channel *lp, const void *buf,
78 unsigned int size);
79int ldc_read(struct ldc_channel *lp, void *buf, unsigned int size);
80
81#define LDC_MAP_SHADOW 0x01
82#define LDC_MAP_DIRECT 0x02
83#define LDC_MAP_IO 0x04
84#define LDC_MAP_R 0x08
85#define LDC_MAP_W 0x10
86#define LDC_MAP_X 0x20
87#define LDC_MAP_RW (LDC_MAP_R | LDC_MAP_W)
88#define LDC_MAP_RWX (LDC_MAP_R | LDC_MAP_W | LDC_MAP_X)
89#define LDC_MAP_ALL 0x03f
90
91struct ldc_trans_cookie {
92 u64 cookie_addr;
93 u64 cookie_size;
94};
95
96struct scatterlist;
97int ldc_map_sg(struct ldc_channel *lp,
98 struct scatterlist *sg, int num_sg,
99 struct ldc_trans_cookie *cookies, int ncookies,
100 unsigned int map_perm);
101
102int ldc_map_single(struct ldc_channel *lp,
103 void *buf, unsigned int len,
104 struct ldc_trans_cookie *cookies, int ncookies,
105 unsigned int map_perm);
106
107void ldc_unmap(struct ldc_channel *lp, struct ldc_trans_cookie *cookies,
108 int ncookies);
109
110int ldc_copy(struct ldc_channel *lp, int copy_dir,
111 void *buf, unsigned int len, unsigned long offset,
112 struct ldc_trans_cookie *cookies, int ncookies);
113
114static inline int ldc_get_dring_entry(struct ldc_channel *lp,
115 void *buf, unsigned int len,
116 unsigned long offset,
117 struct ldc_trans_cookie *cookies,
118 int ncookies)
119{
120 return ldc_copy(lp, LDC_COPY_IN, buf, len, offset, cookies, ncookies);
121}
122
123static inline int ldc_put_dring_entry(struct ldc_channel *lp,
124 void *buf, unsigned int len,
125 unsigned long offset,
126 struct ldc_trans_cookie *cookies,
127 int ncookies)
128{
129 return ldc_copy(lp, LDC_COPY_OUT, buf, len, offset, cookies, ncookies);
130}
131
132void *ldc_alloc_exp_dring(struct ldc_channel *lp, unsigned int len,
133 struct ldc_trans_cookie *cookies,
134 int *ncookies, unsigned int map_perm);
135
136void ldc_free_exp_dring(struct ldc_channel *lp, void *buf,
137 unsigned int len,
138 struct ldc_trans_cookie *cookies, int ncookies);
139
140#endif
141