#ifndef _PC_SERIAL_DRIVER_H_
#define _PC_SERIAL_DRIVER_H_
#include <OS.h>
#include <KernelExport.h>
#include <Drivers.h>
#include <ISA.h>
#include <PCI.h>
#include <string.h>
#include <lock.h>
#include <new>
#include "Tracing.h"
extern "C" {
#include <tty_module.h>
}
#define HANDLE_ISA_COM
#define DRIVER_NAME "pc_serial"
#define DEVICES_COUNT 20
#define DEVFS_BASE "ports/pc_serial"
#ifndef PCI_serial_16650
#define PCI_serial_16650 0x03
#define PCI_serial_16750 0x04
#define PCI_serial_16850 0x05
#define PCI_serial_16950 0x06
#endif
typedef enum {
B_ISA_BUS,
B_PCI_BUS,
B_PCMCIA_BUS,
B_UNKNOWN_BUS = 0x80
} bus_type;
class SerialDevice;
struct port_constraints {
uint32 minsize;
uint32 maxsize;
uint32 split;
uint8 ignoremask;
uint8 maxports;
uint32 subsystem_id_mask;
};
#define PCI_INVAL 0xffff
struct serial_support_descriptor {
const bus_type bus;
const char *name;
const uint32 *bauds;
SerialDevice *(*instanciator)(struct serial_support_descriptor *desc);
struct port_constraints constraints;
struct {
uchar class_base;
uchar class_sub;
uchar class_api;
ushort vendor_id;
ushort device_id;
ushort subsystem_vendor_id;
ushort subsystem_device_id;
} match;
};
typedef struct serial_support_descriptor serial_support_descriptor;
#define ROUNDUP(size, seg) (((size) + (seg) - 1) & ~((seg) - 1))
#define DEF_BUFFER_SIZE 0x200
#define BLAST B230400
#define LC_STOP_BIT_1 0
#define LC_STOP_BIT_2 2
#define LC_PARITY_NONE 0
#define LC_PARITY_ODD 1
#define LC_PARITY_EVEN 2
typedef struct pc_serial_line_coding_s {
uint32 speed;
uint8 stopbits;
uint8 parity;
uint8 databits;
} pc_serial_line_coding;
#define CLS_LINE_DTR 0x0001
#define CLS_LINE_RTS 0x0002
extern isa_module_info *gISAModule;
extern pci_module_info *gPCIModule;
extern tty_module_info *gTTYModule;
extern struct ddomain gSerialDomain;
extern "C" {
status_t init_hardware();
void uninit_driver();
bool pc_serial_service(struct tty *tty, uint32 op, void *buffer,
size_t length);
int32 pc_serial_interrupt(void *arg);
status_t pc_serial_open(const char *name, uint32 flags, void **cookie);
status_t pc_serial_read(void *cookie, off_t position, void *buffer, size_t *numBytes);
status_t pc_serial_write(void *cookie, off_t position, const void *buffer, size_t *numBytes);
status_t pc_serial_control(void *cookie, uint32 op, void *arg, size_t length);
status_t pc_serial_select(void *cookie, uint8 event, uint32 ref, selectsync *sync);
status_t pc_serial_deselect(void *coookie, uint8 event, selectsync *sync);
status_t pc_serial_close(void *cookie);
status_t pc_serial_free(void *cookie);
const char **publish_devices();
device_hooks *find_device(const char *name);
}
#endif