2 * Copyright (C) 2014 glevand <geoffrey.levand@mail.ru>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #define CONS_LENGTH 0xff0
39 static struct option long_opts
[] = {
40 { "device", no_argument
, NULL
, 'd' },
44 static const char *device
= "/dev/ps3lv1call";
49 static int parse_opts(int argc
, char **argv
)
53 while ((c
= getopt_long(argc
, argv
, "d:", long_opts
, NULL
)) != -1) {
59 fprintf(stderr
, "invalid option specified: %c\n", c
);
68 static void lv1_console_init(uint64_t id
, uint64_t len
)
84 dev_do_lv1call(device
, 105, in_args
, num_in_args
, out_args
, &result
);
87 static void lv1_console_putchar(uint64_t id
, int c
)
109 dev_do_lv1call(device
, 107, in_args
, num_in_args
, out_args
, &result
);
112 static void lv1_console_flush(uint64_t id
)
116 uint64_t out_args
[8];
122 dev_do_lv1call(device
, 109, in_args
, num_in_args
, out_args
, &result
);
128 int main(int argc
, char **argv
)
133 ret
= parse_opts(argc
, argv
);
137 lv1_console_init(CONS_ID
, CONS_LENGTH
);
139 for (i
= optind
; i
< argc
; i
++) {
140 for (j
= 0; j
< strlen(argv
[i
]); j
++)
141 lv1_console_putchar(CONS_ID
, argv
[i
][j
]);
142 lv1_console_putchar(CONS_ID
, '\n');
143 lv1_console_flush(CONS_ID
);