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
23extern "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
37extern usb_module_info *gUSBModule;
38extern tty_module_info *gTTYModule;
39extern struct ddomain gSerialDomain;
40
41extern "C" {
42status_t	usb_serial_device_added(usb_device device, void **cookie);
43status_t	usb_serial_device_removed(void *cookie);
44
45status_t	init_hardware();
46void		uninit_driver();
47
48bool		usb_serial_service(struct tty *tty, uint32 op, void *buffer,
49				size_t length);
50
51const char **publish_devices();
52device_hooks *find_device(const char *name);
53}
54
55#endif //_USB_SERIAL_DRIVER_H_
56