1
0

bsp.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * File : bsp.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-09-15 QiuYi the first version */
  13. #ifndef __BSP_H_
  14. #define __BSP_H_
  15. #include <i386.h>
  16. /*******************************************************************/
  17. /* Timer Register */
  18. /*******************************************************************/
  19. #define TIMER_CNTR0 (IO_TIMER1 + 0) /* timer 0 counter port */
  20. #define TIMER_CNTR1 (IO_TIMER1 + 1) /* timer 1 counter port */
  21. #define TIMER_CNTR2 (IO_TIMER1 + 2) /* timer 2 counter port */
  22. #define TIMER_MODE (IO_TIMER1 + 3) /* timer mode port */
  23. #define TIMER_SEL0 0x00 /* select counter 0 */
  24. #define TIMER_SEL1 0x40 /* select counter 1 */
  25. #define TIMER_INTTC 0x00 /* mode 0, intr on terminal cnt */
  26. #define TIMER_ONESHOT 0x02 /* mode 1, one shot */
  27. #define TIMER_RATEGEN 0x04 /* mode 2, rate generator */
  28. #define TIMER_SQWAVE 0x06 /* mode 3, square wave */
  29. #define TIMER_SWSTROBE 0x08 /* mode 4, s/w triggered strobe */
  30. #define TIMER_HWSTROBE 0x0a /* mode 5, h/w triggered strobe */
  31. #define TIMER_LATCH 0x00 /* latch counter for reading */
  32. #define TIMER_LSB 0x10 /* r/w counter LSB */
  33. #define TIMER_MSB 0x20 /* r/w counter MSB */
  34. #define TIMER_16BIT 0x30 /* r/w counter 16 bits, LSB first */
  35. #define TIMER_BCD 0x01 /* count in BCD */
  36. #define TIMER_FREQ 1193182
  37. #define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
  38. #define IO_TIMER1 0x040 /* 8253 Timer #1 */
  39. /*******************************************************************/
  40. /* Interrupt Controller */
  41. /*******************************************************************/
  42. /* these are processor defined */
  43. #define T_DIVIDE 0 /* divide error */
  44. #define T_DEBUG 1 /* debug exception */
  45. #define T_NMI 2 /* non-maskable interrupt */
  46. #define T_BRKPT 3 /* breakpoint */
  47. #define T_OFLOW 4 /* overflow */
  48. #define T_BOUND 5 /* bounds check */
  49. #define T_ILLOP 6 /* illegal opcode */
  50. #define T_DEVICE 7 /* device not available */
  51. #define T_DBLFLT 8 /* double fault */
  52. /* 9 is reserved */
  53. #define T_TSS 10 /* invalid task switch segment */
  54. #define T_SEGNP 11 /* segment not present */
  55. #define T_STACK 12 /* stack exception */
  56. #define T_GPFLT 13 /* genernal protection fault */
  57. #define T_PGFLT 14 /* page fault */
  58. /* 15 is reserved */
  59. #define T_FPERR 16 /* floating point error */
  60. #define T_ALIGN 17 /* aligment check */
  61. #define T_MCHK 18 /* machine check */
  62. #define T_DEFAULT 500 /* catchall */
  63. #define INTTIMER0 0
  64. #define INTKEYBOARD 1
  65. #define INTUART0_RX 4
  66. /* I/O Addresses of the two 8259A programmable interrupt controllers */
  67. #define IO_PIC1 0x20 /* Master(IRQs 0-7) */
  68. #define IO_PIC2 0xa0 /* Slave(IRQs 8-15) */
  69. #define IRQ_SLAVE 0x2 /* IRQ at which slave connects to master */
  70. #define IRQ_OFFSET 0x20 /* IRQ 0 corresponds to int IRQ_OFFSET */
  71. #define MAX_HANDLERS 16 /*max number of isr handler*/
  72. /*******************************************************************/
  73. /* CRT Register */
  74. /*******************************************************************/
  75. #define MONO_BASE 0x3b4
  76. #define MONO_BUF 0xb0000
  77. #define CGA_BASE 0x3d4
  78. #define CGA_BUF 0xb8000
  79. #define CRT_ROWS 25
  80. #define CRT_COLS 80
  81. #define CRT_SIZE (CRT_ROWS * CRT_COLS)
  82. /*******************************************************************/
  83. /* Keyboard Register */
  84. /*******************************************************************/
  85. #define KBSTATP 0x64 /* kbd controller status port(I) */
  86. #define KBS_DIB 0x01 /* kbd data in buffer */
  87. #define KBDATAP 0x60 /* kbd data port(I) */
  88. /*******************************************************************/
  89. /* Serial Register */
  90. /*******************************************************************/
  91. /*Serial I/O code */
  92. #define COM1 0x3F8
  93. #define COMSTATUS 5
  94. #define COMDATA 0x01
  95. #define COMREAD 0
  96. #define COMWRITE 0
  97. /* Bits definition of the Line Status Register (LSR)*/
  98. #define DR 0x01 /* Data Ready */
  99. #define OE 0x02 /* Overrun Error */
  100. #define PE 0x04 /* Parity Error */
  101. #define FE 0x08 /* Framing Error */
  102. #define BI 0x10 /* Break Interrupt */
  103. #define THRE 0x20 /* Transmitter Holding Register Empty */
  104. #define TEMT 0x40 /* Transmitter Empty */
  105. #define ERFIFO 0x80 /* Error receive Fifo */
  106. #ifdef __cplusplus
  107. }
  108. #endif
  109. #endif /* __BSP_H_ */