Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / drivers / adb_mouse.c
1 /*
2  *
3  * Open Hack'Ware BIOS ADB mouse support, ported to OpenBIOS
4  *
5  *  Copyright (c) 2005 Jocelyn Mayer
6  *  Copyright (c) 2005 Stefan Reinauer
7  *
8  *   This program is free software; you can redistribute it and/or
9  *   modify it under the terms of the GNU General Public License V2
10  *   as published by the Free Software Foundation
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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
20  */
21
22 #include "config.h"
23 #include "libopenbios/bindings.h"
24 #include "libc/byteorder.h"
25 #include "libc/vsprintf.h"
26
27 #include "adb_bus.h"
28 #include "adb_mouse.h"
29
30 DECLARE_UNNAMED_NODE( mouse, INSTALL_OPEN, sizeof(int));
31
32 static void
33 mouse_open(int *idx)
34 {
35         RET(-1);
36 }
37
38 static void
39 mouse_close(int *idx)
40 {
41 }
42
43 NODE_METHODS( mouse ) = {
44         { "open",               mouse_open              },
45         { "close",              mouse_close             },
46 };
47
48 void adb_mouse_new (char *path, void *private)
49 {
50         char buf[64];
51         int props[1];
52         phandle_t ph, aliases;
53         adb_dev_t *dev = private;
54
55         snprintf(buf, sizeof(buf), "%s/mouse", path);
56         REGISTER_NAMED_NODE( mouse, buf);
57
58         ph = find_dev(buf);
59
60         set_property(ph, "device_type", "mouse", 6);
61         props[0] = __cpu_to_be32(dev->addr);
62         set_property(ph, "reg", (char *)&props, sizeof(props));
63         set_int_property(ph, "#buttons", 3);
64
65         aliases = find_dev("/aliases");
66         set_property(aliases, "adb-mouse", buf, strlen(buf) + 1);
67 }