SERSETUP.H 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <conio.h>
  6. #include <ctype.h>
  7. #include <dos.h>
  8. #include <process.h>
  9. #include <stdarg.h>
  10. #include <bios.h>
  11. #include <ctype.h>
  12. #define INPUT(port) inportb(port)
  13. #define OUTPUT(port,data) outportb(port,data)
  14. #define CLI() disable()
  15. #define STI() enable()
  16. typedef enum {false, true} boolean;
  17. typedef unsigned char byte;
  18. #define TRANSMIT_HOLDING_REGISTER 0x00
  19. #define RECEIVE_BUFFER_REGISTER 0x00
  20. #define INTERRUPT_ENABLE_REGISTER 0x01
  21. #define IER_RX_DATA_READY 0x01
  22. #define IER_TX_HOLDING_REGISTER_EMPTY 0x02
  23. #define IER_LINE_STATUS 0x04
  24. #define IER_MODEM_STATUS 0x08
  25. #define INTERRUPT_ID_REGISTER 0x02
  26. #define IIR_MODEM_STATUS_INTERRUPT 0x00
  27. #define IIR_TX_HOLDING_REGISTER_INTERRUPT 0x02
  28. #define IIR_RX_DATA_READY_INTERRUPT 0x04
  29. #define IIR_LINE_STATUS_INTERRUPT 0x06
  30. #define FIFO_CONTROL_REGISTER 0x02
  31. #define FCR_FIFO_ENABLE 0x01
  32. #define FCR_RCVR_FIFO_RESET 0x02
  33. #define FCR_XMIT_FIFO_RESET 0x04
  34. #define FCR_RCVR_TRIGGER_LSB 0x40
  35. #define FCR_RCVR_TRIGGER_MSB 0x80
  36. #define FCR_TRIGGER_01 0x00
  37. #define FCR_TRIGGER_04 0x40
  38. #define FCR_TRIGGER_08 0x80
  39. #define FCR_TRIGGER_14 0xc0
  40. #define LINE_CONTROL_REGISTER 0x03
  41. #define LCR_WORD_LENGTH_MASK 0x03
  42. #define LCR_WORD_LENGTH_SELECT_0 0x01
  43. #define LCR_WORD_LENGTH_SELECT_1 0x02
  44. #define LCR_STOP_BITS 0x04
  45. #define LCR_PARITY_MASK 0x38
  46. #define LCR_PARITY_ENABLE 0x08
  47. #define LCR_EVEN_PARITY_SELECT 0x10
  48. #define LCR_STICK_PARITY 0x20
  49. #define LCR_SET_BREAK 0x40
  50. #define LCR_DLAB 0x80
  51. #define MODEM_CONTROL_REGISTER 0x04
  52. #define MCR_DTR 0x01
  53. #define MCR_RTS 0x02
  54. #define MCR_OUT1 0x04
  55. #define MCR_OUT2 0x08
  56. #define MCR_LOOPBACK 0x10
  57. #define LINE_STATUS_REGISTER 0x05
  58. #define LSR_DATA_READY 0x01
  59. #define LSR_OVERRUN_ERROR 0x02
  60. #define LSR_PARITY_ERROR 0x04
  61. #define LSR_FRAMING_ERROR 0x08
  62. #define LSR_BREAK_DETECT 0x10
  63. #define LSR_THRE 0x20
  64. #define MODEM_STATUS_REGISTER 0x06
  65. #define MSR_DELTA_CTS 0x01
  66. #define MSR_DELTA_DSR 0x02
  67. #define MSR_TERI 0x04
  68. #define MSR_DELTA_CD 0x08
  69. #define MSR_CTS 0x10
  70. #define MSR_DSR 0x20
  71. #define MSR_RI 0x40
  72. #define MSR_CD 0x80
  73. #define DIVISOR_LATCH_LOW 0x00
  74. #define DIVISOR_LATCH_HIGH 0x01
  75. #define QUESIZE 2048
  76. typedef struct
  77. {
  78. long head, tail; // bytes are put on head and pulled from tail
  79. unsigned char data[QUESIZE];
  80. } que_t;
  81. void InitPort (void);
  82. void ShutdownPort (void);
  83. int read_byte( void );
  84. void write_byte( int c );
  85. void Error (char *error, ...);
  86. extern int argc;
  87. extern char **argv;