ps3dm_sm: set_del_encdec_key: fixed description for default key
[ps3dm-utils.git] / ps3dm_proxy.c
blob04ac6df9b54108a124b7ff715362395db0e91028
2 /*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; version 2 of the License.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include <string.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <fcntl.h>
21 #include <sys/ioctl.h>
22 #include <unistd.h>
23 #include <asm/ps3dmproxy.h>
25 #include "ps3dm_proxy.h"
27 int ps3dm_proxy_open(const char *path)
29 return open(path, O_RDWR);
32 int ps3dm_proxy_close(int fd)
34 return close(fd);
37 int ps3dm_proxy_user_to_lpar_addr(int fd, uint64_t user_addr, uint64_t *lpar_addr)
39 struct ps3dmproxy_ioctl_user_to_lpar_addr arg;
40 int error;
42 memset(&arg, 0, sizeof(arg));
43 arg.user_addr = user_addr;
45 error = ioctl(fd, PS3DMPROXY_IOCTL_USER_TO_LPAR_ADDR, &arg);
47 if (!error)
48 *lpar_addr = arg.lpar_addr;
50 return error;
53 int ps3dm_proxy_get_repo_node_val(int fd, uint64_t lpar_id, const uint64_t key[4], uint64_t val[2])
55 struct ps3dmproxy_ioctl_get_repo_node_val arg;
56 int error;
58 memset(&arg, 0, sizeof(arg));
59 arg.lpar_id = lpar_id;
60 arg.key[0] = key[0];
61 arg.key[1] = key[1];
62 arg.key[2] = key[2];
63 arg.key[3] = key[3];
65 error = ioctl(fd, PS3DMPROXY_IOCTL_GET_REPO_NODE_VAL, &arg);
67 if (!error) {
68 val[0] = arg.val[0];
69 val[1] = arg.val[1];
72 return error;
75 int ps3dm_proxy_do_request(int fd, struct ps3dm_hdr *sendbuf, unsigned int sendbuf_size,
76 struct ps3dm_hdr *recvbuf, unsigned int recvbuf_size)
78 struct ps3dmproxy_ioctl_do_request arg;
80 memset(&arg, 0, sizeof(arg));
81 arg.sendbuf = (uint64_t) sendbuf;
82 arg.sendbuf_size = sendbuf_size;
83 arg.recvbuf = (uint64_t) recvbuf;
84 arg.recvbuf_size = recvbuf_size;
86 return ioctl(fd, PS3DMPROXY_IOCTL_DO_REQUEST, &arg);