This source file includes following definitions.
- hvcs_convert
- hvcs_free_partner_info
- hvcs_next_partner
- hvcs_get_partner_info
- hvcs_register_connection
- hvcs_free_connection
1
2
3
4
5
6
7
8
9 #include <linux/kernel.h>
10 #include <linux/list.h>
11 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <linux/string.h>
14
15 #include <asm/hvcall.h>
16 #include <asm/hvcserver.h>
17 #include <asm/io.h>
18
19 #define HVCS_ARCH_VERSION "1.0.0"
20
21 MODULE_AUTHOR("Ryan S. Arnold <rsa@us.ibm.com>");
22 MODULE_DESCRIPTION("IBM hvcs ppc64 API");
23 MODULE_LICENSE("GPL");
24 MODULE_VERSION(HVCS_ARCH_VERSION);
25
26
27
28
29
30
31 static int hvcs_convert(long to_convert)
32 {
33 switch (to_convert) {
34 case H_SUCCESS:
35 return 0;
36 case H_PARAMETER:
37 return -EINVAL;
38 case H_HARDWARE:
39 return -EIO;
40 case H_BUSY:
41 case H_LONG_BUSY_ORDER_1_MSEC:
42 case H_LONG_BUSY_ORDER_10_MSEC:
43 case H_LONG_BUSY_ORDER_100_MSEC:
44 case H_LONG_BUSY_ORDER_1_SEC:
45 case H_LONG_BUSY_ORDER_10_SEC:
46 case H_LONG_BUSY_ORDER_100_SEC:
47 return -EBUSY;
48 case H_FUNCTION:
49 default:
50 return -EPERM;
51 }
52 }
53
54
55
56
57
58
59
60
61
62 int hvcs_free_partner_info(struct list_head *head)
63 {
64 struct hvcs_partner_info *pi;
65 struct list_head *element;
66
67 if (!head)
68 return -EINVAL;
69
70 while (!list_empty(head)) {
71 element = head->next;
72 pi = list_entry(element, struct hvcs_partner_info, node);
73 list_del(element);
74 kfree(pi);
75 }
76
77 return 0;
78 }
79 EXPORT_SYMBOL(hvcs_free_partner_info);
80
81
82 static int hvcs_next_partner(uint32_t unit_address,
83 unsigned long last_p_partition_ID,
84 unsigned long last_p_unit_address, unsigned long *pi_buff)
85
86 {
87 long retval;
88 retval = plpar_hcall_norets(H_VTERM_PARTNER_INFO, unit_address,
89 last_p_partition_ID,
90 last_p_unit_address, virt_to_phys(pi_buff));
91 return hvcs_convert(retval);
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119 int hvcs_get_partner_info(uint32_t unit_address, struct list_head *head,
120 unsigned long *pi_buff)
121 {
122
123
124
125
126 unsigned long last_p_partition_ID;
127 unsigned long last_p_unit_address;
128 struct hvcs_partner_info *next_partner_info = NULL;
129 int more = 1;
130 int retval;
131
132
133 if (!head || !pi_buff)
134 return -EINVAL;
135
136 memset(pi_buff, 0x00, PAGE_SIZE);
137 last_p_partition_ID = last_p_unit_address = ~0UL;
138 INIT_LIST_HEAD(head);
139
140 do {
141 retval = hvcs_next_partner(unit_address, last_p_partition_ID,
142 last_p_unit_address, pi_buff);
143 if (retval) {
144
145
146
147
148 if (!list_empty(head))
149 return 0;
150 return retval;
151 }
152
153 last_p_partition_ID = be64_to_cpu(pi_buff[0]);
154 last_p_unit_address = be64_to_cpu(pi_buff[1]);
155
156
157 if (last_p_partition_ID == ~0UL
158 && last_p_unit_address == ~0UL)
159 break;
160
161
162
163 next_partner_info = kmalloc(sizeof(struct hvcs_partner_info),
164 GFP_ATOMIC);
165
166 if (!next_partner_info) {
167 printk(KERN_WARNING "HVCONSOLE: kmalloc() failed to"
168 " allocate partner info struct.\n");
169 hvcs_free_partner_info(head);
170 return -ENOMEM;
171 }
172
173 next_partner_info->unit_address
174 = (unsigned int)last_p_unit_address;
175 next_partner_info->partition_ID
176 = (unsigned int)last_p_partition_ID;
177
178
179 strlcpy(&next_partner_info->location_code[0],
180 (char *)&pi_buff[2],
181 sizeof(next_partner_info->location_code));
182
183 list_add_tail(&(next_partner_info->node), head);
184 next_partner_info = NULL;
185
186 } while (more);
187
188 return 0;
189 }
190 EXPORT_SYMBOL(hvcs_get_partner_info);
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213 int hvcs_register_connection( uint32_t unit_address,
214 uint32_t p_partition_ID, uint32_t p_unit_address)
215 {
216 long retval;
217 retval = plpar_hcall_norets(H_REGISTER_VTERM, unit_address,
218 p_partition_ID, p_unit_address);
219 return hvcs_convert(retval);
220 }
221 EXPORT_SYMBOL(hvcs_register_connection);
222
223
224
225
226
227
228
229
230
231
232
233 int hvcs_free_connection(uint32_t unit_address)
234 {
235 long retval;
236 retval = plpar_hcall_norets(H_FREE_VTERM, unit_address);
237 return hvcs_convert(retval);
238 }
239 EXPORT_SYMBOL(hvcs_free_connection);