Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / lib / libusb / usb-slof.c
1 /******************************************************************************
2  * Copyright (c) 2013 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12 /*
13  * All functions concerning interface to slof
14  */
15
16 #include <string.h>
17 #include "helpers.h"
18 #include "usb-core.h"
19 #include "paflof.h"
20
21 #undef SLOF_DEBUG
22 //#define SLOF_DEBUG
23 #ifdef SLOF_DEBUG
24 #define dprintf(_x ...) do { printf(_x); } while(0)
25 #else
26 #define dprintf(_x ...)
27 #endif
28
29 int slof_usb_handle(struct usb_dev *dev)
30 {
31         struct slof_usb_dev sdev;
32         sdev.port = dev->port;
33         sdev.addr = dev->addr;
34         sdev.hcitype = dev->hcidev->type;
35         sdev.num  = dev->hcidev->num;
36         sdev.udev  = dev;
37
38         if (dev->class == DEV_HID_KEYB) {
39                 dprintf("Keyboard %ld %ld\n", dev->hcidev->type, dev->hcidev->num);
40                 sdev.devtype = DEVICE_KEYBOARD;
41                 forth_push((long)&sdev);
42                 forth_eval("s\" dev-keyb.fs\" INCLUDED");
43         } else if (dev->class == DEV_HID_MOUSE) {
44                 dprintf("Mouse %ld %ld\n", dev->hcidev->type, dev->hcidev->num);
45                 sdev.devtype = DEVICE_MOUSE;
46                 forth_push((long)&sdev);
47                 forth_eval("s\" dev-mouse.fs\" INCLUDED");
48         } else if ((dev->class >> 16 & 0xFF) == 8) {
49                 dprintf("MASS Storage device %ld %ld\n", dev->hcidev->type, dev->hcidev->num);
50                 sdev.devtype = DEVICE_DISK;
51                 forth_push((long)&sdev);
52                 forth_eval("s\" dev-storage.fs\" INCLUDED");
53         } else if (dev->class == DEV_HUB) {
54                 dprintf("Generic hub device %ld %ld\n", dev->hcidev->type,
55                         dev->hcidev->num);
56                 sdev.devtype = DEVICE_HUB;
57                 forth_push((long)&sdev);
58                 forth_eval("s\" dev-hub.fs\" INCLUDED");
59         }
60         return true;
61 }