bsp.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /*******************************************************************/
  20. /* Timer Register */
  21. /*******************************************************************/
  22. #define TIMER_CNTR0 (IO_TIMER1 + 0) /* timer 0 counter port */
  23. #define TIMER_CNTR1 (IO_TIMER1 + 1) /* timer 1 counter port */
  24. #define TIMER_CNTR2 (IO_TIMER1 + 2) /* timer 2 counter port */
  25. #define TIMER_MODE (IO_TIMER1 + 3) /* timer mode port */
  26. #define TIMER_SEL0 0x00 /* select counter 0 */
  27. #define TIMER_SEL1 0x40 /* select counter 1 */
  28. #define TIMER_INTTC 0x00 /* mode 0, intr on terminal cnt */
  29. #define TIMER_ONESHOT 0x02 /* mode 1, one shot */
  30. #define TIMER_RATEGEN 0x04 /* mode 2, rate generator */
  31. #define TIMER_SQWAVE 0x06 /* mode 3, square wave */
  32. #define TIMER_SWSTROBE 0x08 /* mode 4, s/w triggered strobe */
  33. #define TIMER_HWSTROBE 0x0a /* mode 5, h/w triggered strobe */
  34. #define TIMER_LATCH 0x00 /* latch counter for reading */
  35. #define TIMER_LSB 0x10 /* r/w counter LSB */
  36. #define TIMER_MSB 0x20 /* r/w counter MSB */
  37. #define TIMER_16BIT 0x30 /* r/w counter 16 bits, LSB first */
  38. #define TIMER_BCD 0x01 /* count in BCD */
  39. #define TIMER_FREQ 1193182
  40. #define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
  41. #define IO_TIMER1 0x040 /* 8253 Timer #1 */
  42. /*******************************************************************/
  43. /* Interrupt Controller */
  44. /*******************************************************************/
  45. /* these are processor defined */
  46. #define T_DIVIDE 0 /* divide error */
  47. #define T_DEBUG 1 /* debug exception */
  48. #define T_NMI 2 /* non-maskable interrupt */
  49. #define T_BRKPT 3 /* breakpoint */
  50. #define T_OFLOW 4 /* overflow */
  51. #define T_BOUND 5 /* bounds check */
  52. #define T_ILLOP 6 /* illegal opcode */
  53. #define T_DEVICE 7 /* device not available */
  54. #define T_DBLFLT 8 /* double fault */
  55. /* 9 is reserved */
  56. #define T_TSS 10 /* invalid task switch segment */
  57. #define T_SEGNP 11 /* segment not present */
  58. #define T_STACK 12 /* stack exception */
  59. #define T_GPFLT 13 /* genernal protection fault */
  60. #define T_PGFLT 14 /* page fault */
  61. /* 15 is reserved */
  62. #define T_FPERR 16 /* floating point error */
  63. #define T_ALIGN 17 /* aligment check */
  64. #define T_MCHK 18 /* machine check */
  65. #define T_DEFAULT 500 /* catchall */
  66. #define INTTIMER0 0
  67. #define INTKEYBOARD 1
  68. #define INTUART0_RX 4
  69. #define CLOCK_IRQ 0
  70. #define KEYBOARD_IRQ 1
  71. #define CASCADE_IRQ 2 /* cascade enable for 2nd AT controller */
  72. #define ETHER_IRQ 3 /* default ethernet interrupt vector */
  73. #define SECONDARY_IRQ 3 /* RS232 interrupt vector for port 2 */
  74. #define RS232_IRQ 4 /* RS232 interrupt vector for port 1 */
  75. #define XT_WINI_IRQ 5 /* xt winchester */
  76. #define FLOPPY_IRQ 6 /* floppy disk */
  77. #define PRINTER_IRQ 7
  78. #define AT_WINI_IRQ 14 /* at winchester */
  79. /* I/O Addresses of the two 8259A programmable interrupt controllers */
  80. #define IO_PIC1 0x20 /* Master(IRQs 0-7) */
  81. #define IO_PIC2 0xa0 /* Slave(IRQs 8-15) */
  82. #define IRQ_SLAVE 0x2 /* IRQ at which slave connects to master */
  83. #define IRQ_OFFSET 0x20 /* IRQ 0 corresponds to int IRQ_OFFSET */
  84. #define MAX_HANDLERS 16 /*max number of isr handler*/
  85. /*******************************************************************/
  86. /* CRT Register */
  87. /*******************************************************************/
  88. #define MONO_BASE 0x3b4
  89. #define MONO_BUF 0xb0000
  90. #define CGA_BASE 0x3d4
  91. #define CGA_BUF 0xb8000
  92. #define CRT_ROWS 25
  93. #define CRT_COLS 80
  94. #define CRT_SIZE (CRT_ROWS * CRT_COLS)
  95. /*******************************************************************/
  96. /* Keyboard Register */
  97. /*******************************************************************/
  98. #define KBSTATP 0x64 /* kbd controller status port(I) */
  99. #define KBS_DIB 0x01 /* kbd data in buffer */
  100. #define KBDATAP 0x60 /* kbd data port(I) */
  101. /* AT keyboard */
  102. /* 8042 ports */
  103. #define KB_DATA 0x60 /* I/O port for keyboard data
  104. Read : Read Output Buffer
  105. Write: Write Input Buffer(8042 Data&8048 Command) */
  106. #define KB_CMD 0x64 /* I/O port for keyboard command
  107. Read : Read Status Register
  108. Write: Write Input Buffer(8042 Command) */
  109. #define LED_CODE 0xED
  110. #define KB_ACK 0xFA
  111. /*******************************************************************/
  112. /* Serial Register */
  113. /*******************************************************************/
  114. /*Serial I/O code */
  115. #define COM1 0x3F8
  116. #define COMSTATUS 5
  117. #define COMDATA 0x01
  118. #define COMREAD 0
  119. #define COMWRITE 0
  120. /* Bits definition of the Line Status Register (LSR)*/
  121. #define DR 0x01 /* Data Ready */
  122. #define OE 0x02 /* Overrun Error */
  123. #define PE 0x04 /* Parity Error */
  124. #define FE 0x08 /* Framing Error */
  125. #define BI 0x10 /* Break Interrupt */
  126. #define THRE 0x20 /* Transmitter Holding Register Empty */
  127. #define TEMT 0x40 /* Transmitter Empty */
  128. #define ERFIFO 0x80 /* Error receive Fifo */
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif /* __BSP_H_ */