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 /* Some usefull helper defines ... */ 32 #define SIZEOF(array) (sizeof(array) / sizeof(array[0])) /* size of array */ 33 /* This one rounds the size to integral count of segs (segments) */ 34 #define ROUNDUP(size, seg) (((size) + (seg) - 1) & ~((seg) - 1)) 35 /* Default device buffer size */ 36 #define DEF_BUFFER_SIZE 0x200 37 38 39 extern usb_module_info *gUSBModule; 40 extern tty_module_info *gTTYModule; 41 extern struct ddomain gSerialDomain; 42 43 extern "C" { 44 status_t usb_serial_device_added(usb_device device, void **cookie); 45 status_t usb_serial_device_removed(void *cookie); 46 47 status_t init_hardware(); 48 void uninit_driver(); 49 50 bool usb_serial_service(struct tty *tty, uint32 op, void *buffer, 51 size_t length); 52 53 const char **publish_devices(); 54 device_hooks *find_device(const char *name); 55 } 56 57 #endif //_USB_SERIAL_DRIVER_H_ 58