use 64bit ABI
[ps3hvc-utils.git] / ps3hvc_dev.c
blobd023b08e342876bd89c579bfeba13a87014e2d6c
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 <stdlib.h>
18 #include <string.h>
19 #include <errno.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <fcntl.h>
23 #include <sys/ioctl.h>
24 #include <unistd.h>
26 #include "ps3hvc_dev.h"
28 int ps3hvc_dev_open(const char *path)
30 return open(path, O_RDWR);
33 int ps3hvc_dev_close(int fd)
35 return close(fd);
38 int ps3hvc_dev_hvcall(int fd, uint64_t number, uint64_t in_args,
39 uint64_t out_args, uint64_t args[], uint64_t *result)
41 struct ps3hvc_ioctl_hvcall *arg;
42 int size, error;
44 size = sizeof(struct ps3hvc_ioctl_hvcall) + (in_args + out_args) * sizeof(uint64_t);
46 arg = malloc(size);
47 if (!arg)
48 return ENOMEM;
50 memset(arg, 0, size);
51 arg->number = number;
52 arg->in_args = in_args;
53 arg->out_args = out_args;
54 memcpy(arg->args, args, in_args);
56 error = ioctl(fd, PS3HVC_IOCTL_HVCALL, arg);
58 if (error == 0)
59 *result = arg->result;
61 free(arg);
63 return error;