1 /* 2 * Copyright (c) 2007-2008 by Michael Lotz 3 * Heavily based on the original usb_serial driver which is: 4 * 5 * Copyright (c) 2003 by Siarzhuk Zharski <imker@gmx.li> 6 * Distributed under the terms of the MIT License. 7 */ 8 #ifndef _USB_SERIAL_DRIVER_H_ 9 #define _USB_SERIAL_DRIVER_H_ 10 11 #include <Drivers.h> 12 #include <KernelExport.h> 13 #include <OS.h> 14 #include <USB3.h> 15 16 #include <usb/USB_cdc.h> 17 18 #include <lock.h> 19 #include <string.h> 20 21 #include "Tracing.h" 22 23 extern "C" { 24 #include <tty_module.h> 25 } 26 27 28 #define DRIVER_NAME "usb_serial" // driver name for debug output 29 #define DEVICES_COUNT 20 // max simultaneously open devices 30 31 /* This one rounds the size to integral count of segs (segments) */ 32 #define ROUNDUP(size, seg) (((size) + (seg) - 1) & ~((seg) - 1)) 33 /* Default device buffer size */ 34 #define DEF_BUFFER_SIZE 0x200 35 36 37 extern usb_module_info *gUSBModule; 38 extern tty_module_info *gTTYModule; 39 extern struct ddomain gSerialDomain; 40 41 extern "C" { 42 status_t usb_serial_device_added(usb_device device, void **cookie); 43 status_t usb_serial_device_removed(void *cookie); 44 45 status_t init_hardware(); 46 void uninit_driver(); 47 48 bool usb_serial_service(struct tty *tty, uint32 op, void *buffer, 49 size_t length); 50 51 const char **publish_devices(); 52 device_hooks *find_device(const char *name); 53 } 54 55 #endif //_USB_SERIAL_DRIVER_H_ 56