1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 # T2 SDE: architecture/powerpc64/package/.../0240-ps3lv1call.patch
5 # Copyright (C) 2019 - 2020 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 --- a/drivers/char/Makefile 2018-11-15 23:03:11.806936490 +0000
18 +++ b/drivers/char/Makefile 2018-11-15 23:04:25.450935383 +0000
20 obj-$(CONFIG_PS3_STRGMNGR) += ps3strgmngr.o
21 obj-$(CONFIG_PS3_ENCDEC) += ps3encdec.o
22 +obj-$(CONFIG_PS3_LV1CALL) += ps3lv1call/
24 obj-$(CONFIG_XILLYBUS) += xillybus/
25 obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o
26 --- a/arch/powerpc/platforms/ps3/Kconfig 2012-10-27 02:11:58.000000000 -0800
27 +++ b/arch/powerpc/platforms/ps3/Kconfig 2012-10-27 02:13:08.000000000 -0800
30 The isolated SPU loader file system is used to execute isolated SPU loaders.
33 + tristate "PS3 LV1 Call Driver"
36 + This driver allows you to execute LV1 calls.
39 bool "PS3 udbg output via UDP broadcasts on Ethernet"
41 --- /dev/null 2012-10-27 01:55:30.097760558 -0800
42 +++ b/drivers/char/ps3lv1call/Makefile 2012-10-27 02:10:35.000000000 -0800
45 +ps3lv1call-y := ps3lv1call_misc.o generic_lv1call.o
47 +obj-$(CONFIG_PS3_LV1CALL) += ps3lv1call.o
48 --- /dev/null 2012-10-27 01:55:30.097760558 -0800
49 +++ b/drivers/char/ps3lv1call/generic_lv1call.S 2012-10-27 02:08:57.000000000 -0800
52 + * PS3 Generic LV1 Call
54 + * Copyright (C) 2012 glevand <geoffrey.levand@mail.ru>
55 + * All rights reserved.
57 + * This program is free software; you can redistribute it and/or modify it
58 + * under the terms of the GNU General Public License as published
59 + * by the Free Software Foundation; version 2 of the License.
61 + * This program is distributed in the hope that it will be useful, but
62 + * WITHOUT ANY WARRANTY; without even the implied warranty of
63 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64 + * General Public License for more details.
66 + * You should have received a copy of the GNU General Public License along
67 + * with this program; if not, write to the Free Software Foundation, Inc.,
68 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
71 +#include <asm/processor.h>
72 +#include <asm/ppc_asm.h>
74 +#define lv1call .long 0x44000022; extsw r3, r3
76 +_GLOBAL(generic_lv1call)
106 +++ b/drivers/char/ps3lv1call/ps3lv1call_misc.c
111 + * Copyright (C) 2012, 2013 glevand <geoffrey.levand@mail.ru>
112 + * All rights reserved.
114 + * This program is free software; you can redistribute it and/or modify it
115 + * under the terms of the GNU General Public License as published
116 + * by the Free Software Foundation; version 2 of the License.
118 + * This program is distributed in the hope that it will be useful, but
119 + * WITHOUT ANY WARRANTY; without even the implied warranty of
120 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
121 + * General Public License for more details.
123 + * You should have received a copy of the GNU General Public License along
124 + * with this program; if not, write to the Free Software Foundation, Inc.,
125 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
128 +#include <linux/module.h>
129 +#include <linux/kernel.h>
130 +#include <linux/init.h>
131 +#include <linux/mm.h>
132 +#include <linux/fs.h>
133 +#include <linux/uaccess.h>
134 +#include <linux/miscdevice.h>
140 +} ps3lv1call_args[256] = {
141 + [8] = { 0, 1 }, /* lv1_undocumented_function_8 */
142 + [44] = { 1, 0 }, /* lv1_shutdown_logical_partition */
143 + [91] = { 5, 2 }, /* lv1_read_repository_node */
144 + [102] = { 0, 1 }, /* lv1_undocumented_function_102 */
145 + [105] = { 7, 0 }, /* lv1_undocumented_function_105 */
146 + [106] = { 1, 0 }, /* lv1_undocumented_function_106 */
147 + [107] = { 6, 1 }, /* lv1_undocumented_function_107 */
148 + [108] = { 1, 5 }, /* lv1_undocumented_function_108 */
149 + [109] = { 1, 0 }, /* lv1_undocumented_function_109 */
150 + [127] = { 0, 2 }, /* lv1_get_version_info */
151 + [194] = { 6, 2 }, /* lv1_net_control */
152 + [231] = { 1, 0 }, /* lv1_undocumented_function_231 */
153 + [232] = { 0, 2 }, /* lv1_get_rtc */
154 + [255] = { 1, 0 }, /* lv1_panic */
157 +extern int generic_lv1call(int num_lv1call, u64 *in_args, u64 *out_args);
159 +static ssize_t ps3lv1call_do_call(char *buf, size_t size)
164 + int num_args, i, rv;
166 + if (size < sizeof(u64))
169 + if (size % sizeof(u64))
172 + num_lv1call = *(u64 *) buf;
173 + if (num_lv1call > 255)
176 + num_args = (size - sizeof(u64)) / sizeof(u64);
180 + memset(args, 0, sizeof(args));
182 + for (i = 0; i < num_args; i++)
183 + args[i] = *(u64 *) (buf + (i + 1) * sizeof(u64));
185 + err = generic_lv1call(num_lv1call, args, args);
188 + memcpy(buf, &err, sizeof(err));
191 + rv += ps3lv1call_args[num_lv1call].num_out_args * sizeof(u64);
192 + memcpy(buf + sizeof(err), args,
193 + ps3lv1call_args[num_lv1call].num_out_args * sizeof(u64));
199 +static int ps3lv1call_open(struct inode *inode, struct file *file)
201 + file->private_data = NULL;
205 +static ssize_t ps3lv1call_write(struct file *file, const char __user *buf,
206 + size_t size, loff_t *pos)
211 + data = simple_transaction_get(file, buf, size);
213 + return PTR_ERR(data);
215 + rv = ps3lv1call_do_call(data, size);
217 + simple_transaction_set(file, rv);
224 +static ssize_t ps3lv1call_read(struct file *file, char __user *buf,
225 + size_t size, loff_t *pos)
229 + if (!file->private_data) {
230 + rv = ps3lv1call_write(file, buf, 0, pos);
235 + return simple_transaction_read(file, buf, size, pos);
238 +static const struct file_operations ps3lv1call_fops = {
239 + .owner = THIS_MODULE,
240 + .open = ps3lv1call_open,
241 + .write = ps3lv1call_write,
242 + .read = ps3lv1call_read,
243 + .release = simple_transaction_release,
244 + .llseek = default_llseek,
247 +static struct miscdevice ps3lv1call_misc = {
248 + .minor = MISC_DYNAMIC_MINOR,
249 + .name = "ps3lv1call",
250 + .fops = &ps3lv1call_fops,
253 +static int __init ps3lv1call_init(void)
257 + err = misc_register(&ps3lv1call_misc);
262 +static void __exit ps3lv1call_exit(void)
264 + misc_deregister(&ps3lv1call_misc);
267 +module_init(ps3lv1call_init);
268 +module_exit(ps3lv1call_exit);
270 +MODULE_AUTHOR("glevand");
271 +MODULE_DESCRIPTION("PS3 LV1 Call");
272 +MODULE_LICENSE("GPL");