
/**
*.Name      FP_MAKE
*
*.Title     Макро для составления FAR-указателя
*
*.Descr     Макро составляет FAR-указатель, пользуясь
*           значениями сегмента и смещения
*
*.Params    FP_MAKE(seg,off)
*              seg - сегмент;
*              off - смещение
*
*.Return    FAR-указатель seg:off
**/


#define FP_MAKE(seg,off) ((void far *)                         \
					((((unsigned long) (unsigned)(seg)) << 16L) |   \
					((unsigned long) (unsigned) (off))))


#pragma pack(1)


// регистр управления прерываниями

#define ICR_N     1

typedef union _ICR_ {

	struct {

		unsigned char in_ready : 1;
		unsigned char out_ready : 1;
		unsigned char err : 1;
		unsigned char change : 1;
		unsigned char reserv : 4;

	} bit_reg;

	unsigned char byte;

} ICR;


// регистр идентификации прерывания

#define IIDR_N     2

typedef union _IIDR_ {

	struct  {

		unsigned char no_inter : 1;
		unsigned char inter_id : 2;
		unsigned char reserv : 5;

	} bit_reg;

	unsigned char byte;

} IIDR;


// регистр управления модемом

#define MCR_N     4

typedef union  _MCR_ {

	struct {

		unsigned char dtr : 1;
		unsigned char rts : 1;
		unsigned char out1 : 1;
		unsigned char out2 : 1;
		unsigned char diag : 1;
		unsigned char reserv : 3;

	} bit_reg;

	unsigned char byte;

} MCR;


// регистр состояния модема

#define MSR_N     6

typedef union _MSR_ {

	struct {

		unsigned char change_cts : 1;
		unsigned char change_dsr : 1;
		unsigned char change_ri : 1;
		unsigned char change_dcd : 1;
		unsigned char cts : 1;
		unsigned char dsr : 1;
		unsigned char ri : 1;
		unsigned char dcd : 1;

	} bit_reg;

	unsigned char byte;

} MSR;


// регистр состояния линии

#define LSR_N     5

typedef union _LSR_ {

	struct {

		unsigned char in_ready : 1;
		unsigned char overflow : 1;
		unsigned char parity : 1;
		unsigned char synxr : 1;
		unsigned char break_detect : 1;
		unsigned char out_ready : 1;
		unsigned char shift_ready : 1;
		unsigned char taimout : 1;


	} bit_reg;

	unsigned char byte;

} LSR;



// управляющий регистр

#define LCR_N     3

typedef union _LCR_ {

	struct {

		unsigned char len : 2;
		unsigned char stop : 1;
		unsigned char parity : 2;
		unsigned char stuck_parity : 1;
		unsigned char en_break_ctl : 1;
		unsigned char dlab : 1;


	} bit_reg;

	unsigned char byte;

} LCR;


#pragma pack()


int test_com( unsigned );

