diff options
author | Paul Mackerras <paulus@samba.org> | 2005-11-14 01:30:17 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-11-14 01:30:17 -0500 |
commit | 7568cb4ef6c507164b65b01f972a3bd026898ae1 (patch) | |
tree | ba608f4c84d8765d5a1491c345f6dc265b5ec4ea /arch/powerpc/platforms | |
parent | c55377ee73f6efeb373ae06f6e918d87660b4852 (diff) |
powerpc: Move most remaining ppc64 files over to arch/powerpc
Also deletes files in arch/ppc64 that are no longer used now that
we don't compile with ARCH=ppc64 any more.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/pseries/Makefile | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/hvconsole.c | 74 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/hvcserver.c | 251 |
3 files changed, 329 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index e7ca5b1f591e..06d5ef501218 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile | |||
@@ -4,4 +4,7 @@ obj-$(CONFIG_SMP) += smp.o | |||
4 | obj-$(CONFIG_IBMVIO) += vio.o | 4 | obj-$(CONFIG_IBMVIO) += vio.o |
5 | obj-$(CONFIG_XICS) += xics.o | 5 | obj-$(CONFIG_XICS) += xics.o |
6 | obj-$(CONFIG_SCANLOG) += scanlog.o | 6 | obj-$(CONFIG_SCANLOG) += scanlog.o |
7 | obj-$(CONFIG_EEH) += eeh.o eeh_event.o | 7 | obj-$(CONFIG_EEH) += eeh.o eeh_event.o |
8 | |||
9 | obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o | ||
10 | obj-$(CONFIG_HVCS) += hvcserver.o | ||
diff --git a/arch/powerpc/platforms/pseries/hvconsole.c b/arch/powerpc/platforms/pseries/hvconsole.c new file mode 100644 index 000000000000..138e128a3886 --- /dev/null +++ b/arch/powerpc/platforms/pseries/hvconsole.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * hvconsole.c | ||
3 | * Copyright (C) 2004 Hollis Blanchard, IBM Corporation | ||
4 | * Copyright (C) 2004 IBM Corporation | ||
5 | * | ||
6 | * Additional Author(s): | ||
7 | * Ryan S. Arnold <rsa@us.ibm.com> | ||
8 | * | ||
9 | * LPAR console support. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <asm/hvcall.h> | ||
29 | #include <asm/hvconsole.h> | ||
30 | |||
31 | /** | ||
32 | * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper | ||
33 | * @vtermno: The vtermno or unit_address of the adapter from which to fetch the | ||
34 | * data. | ||
35 | * @buf: The character buffer into which to put the character data fetched from | ||
36 | * firmware. | ||
37 | * @count: not used? | ||
38 | */ | ||
39 | int hvc_get_chars(uint32_t vtermno, char *buf, int count) | ||
40 | { | ||
41 | unsigned long got; | ||
42 | |||
43 | if (plpar_hcall(H_GET_TERM_CHAR, vtermno, 0, 0, 0, &got, | ||
44 | (unsigned long *)buf, (unsigned long *)buf+1) == H_Success) | ||
45 | return got; | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | EXPORT_SYMBOL(hvc_get_chars); | ||
50 | |||
51 | |||
52 | /** | ||
53 | * hvc_put_chars: send characters to firmware for denoted vterm adapter | ||
54 | * @vtermno: The vtermno or unit_address of the adapter from which the data | ||
55 | * originated. | ||
56 | * @buf: The character buffer that contains the character data to send to | ||
57 | * firmware. | ||
58 | * @count: Send this number of characters. | ||
59 | */ | ||
60 | int hvc_put_chars(uint32_t vtermno, const char *buf, int count) | ||
61 | { | ||
62 | unsigned long *lbuf = (unsigned long *) buf; | ||
63 | long ret; | ||
64 | |||
65 | ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count, lbuf[0], | ||
66 | lbuf[1]); | ||
67 | if (ret == H_Success) | ||
68 | return count; | ||
69 | if (ret == H_Busy) | ||
70 | return 0; | ||
71 | return -EIO; | ||
72 | } | ||
73 | |||
74 | EXPORT_SYMBOL(hvc_put_chars); | ||
diff --git a/arch/powerpc/platforms/pseries/hvcserver.c b/arch/powerpc/platforms/pseries/hvcserver.c new file mode 100644 index 000000000000..4d584172055a --- /dev/null +++ b/arch/powerpc/platforms/pseries/hvcserver.c | |||
@@ -0,0 +1,251 @@ | |||
1 | /* | ||
2 | * hvcserver.c | ||
3 | * Copyright (C) 2004 Ryan S Arnold, IBM Corporation | ||
4 | * | ||
5 | * PPC64 virtual I/O console server support. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/slab.h> | ||
26 | |||
27 | #include <asm/hvcall.h> | ||
28 | #include <asm/hvcserver.h> | ||
29 | #include <asm/io.h> | ||
30 | |||
31 | #define HVCS_ARCH_VERSION "1.0.0" | ||
32 | |||
33 | MODULE_AUTHOR("Ryan S. Arnold <rsa@us.ibm.com>"); | ||
34 | MODULE_DESCRIPTION("IBM hvcs ppc64 API"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | MODULE_VERSION(HVCS_ARCH_VERSION); | ||
37 | |||
38 | /* | ||
39 | * Convert arch specific return codes into relevant errnos. The hvcs | ||
40 | * functions aren't performance sensitive, so this conversion isn't an | ||
41 | * issue. | ||
42 | */ | ||
43 | int hvcs_convert(long to_convert) | ||
44 | { | ||
45 | switch (to_convert) { | ||
46 | case H_Success: | ||
47 | return 0; | ||
48 | case H_Parameter: | ||
49 | return -EINVAL; | ||
50 | case H_Hardware: | ||
51 | return -EIO; | ||
52 | case H_Busy: | ||
53 | case H_LongBusyOrder1msec: | ||
54 | case H_LongBusyOrder10msec: | ||
55 | case H_LongBusyOrder100msec: | ||
56 | case H_LongBusyOrder1sec: | ||
57 | case H_LongBusyOrder10sec: | ||
58 | case H_LongBusyOrder100sec: | ||
59 | return -EBUSY; | ||
60 | case H_Function: /* fall through */ | ||
61 | default: | ||
62 | return -EPERM; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * hvcs_free_partner_info - free pi allocated by hvcs_get_partner_info | ||
68 | * @head: list_head pointer for an allocated list of partner info structs to | ||
69 | * free. | ||
70 | * | ||
71 | * This function is used to free the partner info list that was returned by | ||
72 | * calling hvcs_get_partner_info(). | ||
73 | */ | ||
74 | int hvcs_free_partner_info(struct list_head *head) | ||
75 | { | ||
76 | struct hvcs_partner_info *pi; | ||
77 | struct list_head *element; | ||
78 | |||
79 | if (!head) | ||
80 | return -EINVAL; | ||
81 | |||
82 | while (!list_empty(head)) { | ||
83 | element = head->next; | ||
84 | pi = list_entry(element, struct hvcs_partner_info, node); | ||
85 | list_del(element); | ||
86 | kfree(pi); | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | EXPORT_SYMBOL(hvcs_free_partner_info); | ||
92 | |||
93 | /* Helper function for hvcs_get_partner_info */ | ||
94 | int hvcs_next_partner(uint32_t unit_address, | ||
95 | unsigned long last_p_partition_ID, | ||
96 | unsigned long last_p_unit_address, unsigned long *pi_buff) | ||
97 | |||
98 | { | ||
99 | long retval; | ||
100 | retval = plpar_hcall_norets(H_VTERM_PARTNER_INFO, unit_address, | ||
101 | last_p_partition_ID, | ||
102 | last_p_unit_address, virt_to_phys(pi_buff)); | ||
103 | return hvcs_convert(retval); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * hvcs_get_partner_info - Get all of the partner info for a vty-server adapter | ||
108 | * @unit_address: The unit_address of the vty-server adapter for which this | ||
109 | * function is fetching partner info. | ||
110 | * @head: An initialized list_head pointer to an empty list to use to return the | ||
111 | * list of partner info fetched from the hypervisor to the caller. | ||
112 | * @pi_buff: A page sized buffer pre-allocated prior to calling this function | ||
113 | * that is to be used to be used by firmware as an iterator to keep track | ||
114 | * of the partner info retrieval. | ||
115 | * | ||
116 | * This function returns non-zero on success, or if there is no partner info. | ||
117 | * | ||
118 | * The pi_buff is pre-allocated prior to calling this function because this | ||
119 | * function may be called with a spin_lock held and kmalloc of a page is not | ||
120 | * recommended as GFP_ATOMIC. | ||
121 | * | ||
122 | * The first long of this buffer is used to store a partner unit address. The | ||
123 | * second long is used to store a partner partition ID and starting at | ||
124 | * pi_buff[2] is the 79 character Converged Location Code (diff size than the | ||
125 | * unsigned longs, hence the casting mumbo jumbo you see later). | ||
126 | * | ||
127 | * Invocation of this function should always be followed by an invocation of | ||
128 | * hvcs_free_partner_info() using a pointer to the SAME list head instance | ||
129 | * that was passed as a parameter to this function. | ||
130 | */ | ||
131 | int hvcs_get_partner_info(uint32_t unit_address, struct list_head *head, | ||
132 | unsigned long *pi_buff) | ||
133 | { | ||
134 | /* | ||
135 | * Dealt with as longs because of the hcall interface even though the | ||
136 | * values are uint32_t. | ||
137 | */ | ||
138 | unsigned long last_p_partition_ID; | ||
139 | unsigned long last_p_unit_address; | ||
140 | struct hvcs_partner_info *next_partner_info = NULL; | ||
141 | int more = 1; | ||
142 | int retval; | ||
143 | |||
144 | memset(pi_buff, 0x00, PAGE_SIZE); | ||
145 | /* invalid parameters */ | ||
146 | if (!head || !pi_buff) | ||
147 | return -EINVAL; | ||
148 | |||
149 | last_p_partition_ID = last_p_unit_address = ~0UL; | ||
150 | INIT_LIST_HEAD(head); | ||
151 | |||
152 | do { | ||
153 | retval = hvcs_next_partner(unit_address, last_p_partition_ID, | ||
154 | last_p_unit_address, pi_buff); | ||
155 | if (retval) { | ||
156 | /* | ||
157 | * Don't indicate that we've failed if we have | ||
158 | * any list elements. | ||
159 | */ | ||
160 | if (!list_empty(head)) | ||
161 | return 0; | ||
162 | return retval; | ||
163 | } | ||
164 | |||
165 | last_p_partition_ID = pi_buff[0]; | ||
166 | last_p_unit_address = pi_buff[1]; | ||
167 | |||
168 | /* This indicates that there are no further partners */ | ||
169 | if (last_p_partition_ID == ~0UL | ||
170 | && last_p_unit_address == ~0UL) | ||
171 | break; | ||
172 | |||
173 | /* This is a very small struct and will be freed soon in | ||
174 | * hvcs_free_partner_info(). */ | ||
175 | next_partner_info = kmalloc(sizeof(struct hvcs_partner_info), | ||
176 | GFP_ATOMIC); | ||
177 | |||
178 | if (!next_partner_info) { | ||
179 | printk(KERN_WARNING "HVCONSOLE: kmalloc() failed to" | ||
180 | " allocate partner info struct.\n"); | ||
181 | hvcs_free_partner_info(head); | ||
182 | return -ENOMEM; | ||
183 | } | ||
184 | |||
185 | next_partner_info->unit_address | ||
186 | = (unsigned int)last_p_unit_address; | ||
187 | next_partner_info->partition_ID | ||
188 | = (unsigned int)last_p_partition_ID; | ||
189 | |||
190 | /* copy the Null-term char too */ | ||
191 | strncpy(&next_partner_info->location_code[0], | ||
192 | (char *)&pi_buff[2], | ||
193 | strlen((char *)&pi_buff[2]) + 1); | ||
194 | |||
195 | list_add_tail(&(next_partner_info->node), head); | ||
196 | next_partner_info = NULL; | ||
197 | |||
198 | } while (more); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | EXPORT_SYMBOL(hvcs_get_partner_info); | ||
203 | |||
204 | /** | ||
205 | * hvcs_register_connection - establish a connection between this vty-server and | ||
206 | * a vty. | ||
207 | * @unit_address: The unit address of the vty-server adapter that is to be | ||
208 | * establish a connection. | ||
209 | * @p_partition_ID: The partition ID of the vty adapter that is to be connected. | ||
210 | * @p_unit_address: The unit address of the vty adapter to which the vty-server | ||
211 | * is to be connected. | ||
212 | * | ||
213 | * If this function is called once and -EINVAL is returned it may | ||
214 | * indicate that the partner info needs to be refreshed for the | ||
215 | * target unit address at which point the caller must invoke | ||
216 | * hvcs_get_partner_info() and then call this function again. If, | ||
217 | * for a second time, -EINVAL is returned then it indicates that | ||
218 | * there is probably already a partner connection registered to a | ||
219 | * different vty-server adapter. It is also possible that a second | ||
220 | * -EINVAL may indicate that one of the parms is not valid, for | ||
221 | * instance if the link was removed between the vty-server adapter | ||
222 | * and the vty adapter that you are trying to open. Don't shoot the | ||
223 | * messenger. Firmware implemented it this way. | ||
224 | */ | ||
225 | int hvcs_register_connection( uint32_t unit_address, | ||
226 | uint32_t p_partition_ID, uint32_t p_unit_address) | ||
227 | { | ||
228 | long retval; | ||
229 | retval = plpar_hcall_norets(H_REGISTER_VTERM, unit_address, | ||
230 | p_partition_ID, p_unit_address); | ||
231 | return hvcs_convert(retval); | ||
232 | } | ||
233 | EXPORT_SYMBOL(hvcs_register_connection); | ||
234 | |||
235 | /** | ||
236 | * hvcs_free_connection - free the connection between a vty-server and vty | ||
237 | * @unit_address: The unit address of the vty-server that is to have its | ||
238 | * connection severed. | ||
239 | * | ||
240 | * This function is used to free the partner connection between a vty-server | ||
241 | * adapter and a vty adapter. | ||
242 | * | ||
243 | * If -EBUSY is returned continue to call this function until 0 is returned. | ||
244 | */ | ||
245 | int hvcs_free_connection(uint32_t unit_address) | ||
246 | { | ||
247 | long retval; | ||
248 | retval = plpar_hcall_norets(H_FREE_VTERM, unit_address); | ||
249 | return hvcs_convert(retval); | ||
250 | } | ||
251 | EXPORT_SYMBOL(hvcs_free_connection); | ||