source: rtems/c/src/lib/libbsp/i386/go32/include/bsp.h @ 1690c6b

4.104.114.84.95
Last change on this file since 1690c6b was 9e738b65, checked in by Joel Sherrill <joel.sherrill@…>, on 07/20/95 at 19:20:31

updating go32 to make timer more accurate

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*  bsp.h
2 *
3 *  This include file definitions related to the ibm386 (go32) board.
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#ifndef __IBMPC_h
17#define __IBMPC_h
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <rtems.h>
24#include <iosupp.h>
25
26/*
27 *  Define the time limits for RTEMS Test Suite test durations.
28 *  Long test and short test duration limits are provided.  These
29 *  values are in seconds and need to be converted to ticks for the
30 *  application.
31 *
32 */
33
34#define MAX_LONG_TEST_DURATION       300 /* 5 minutes = 300 seconds */
35#define MAX_SHORT_TEST_DURATION      3   /* 3 seconds */
36
37
38/*
39 *  Define the interrupt mechanism for Time Test 27
40 *
41 *  NOTE:  Use a software interrupt for the i386 family.
42 */
43#define MUST_WAIT_FOR_INTERRUPT 0
44#define Install_tm27_vector( handler ) set_vector( (handler), 0x90, 1 )
45#define Cause_tm27_intr()              asm volatile( "int $0x90" : : );
46#define Clear_tm27_intr()
47#define Lower_tm27_intr()
48
49/*
50 *  Simple spin delay in microsecond units for device drivers.
51 *  This is very dependent on the clock speed of the target.
52 */
53
54#define delay( _microseconds )  { \
55    rtems_unsigned32 _cnt = (_microseconds); \
56    asm volatile ("0: nop; mov %0,%0; loop 0b" : "=c"(_cnt) : "0"(_cnt) ); \
57}
58
59
60/* Constants */
61
62/* Assume color console */
63#define COLOR           1
64#if COLOR
65# define        GDC_REG_PORT    0x3d4
66# define        GDC_VAL_PORT    0x3d5
67# define        TVRAM           ((unsigned short *)0xb8000L)
68#else
69# define        GDC_REG_PORT    0x3b4
70# define        GDC_VAL_PORT    0x3b5
71# define        TVRAM           ((unsigned short *)0xb0000L)
72#endif
73
74/* White character attribute--works for MGA and CGA */
75#define WHITE   0x07
76
77/* Ports for PC keyboard */
78#define KBD_CTL 0x61
79#define KBD_DATA 0x60
80#define KBD_STATUS 0x64
81
82/* Constants relating to the 8254 (or 8253) programmable interval timers */
83 /*     Port address of the control port and timer channels */
84/*
85 * Macros for specifying values to be written into a mode register.
86 */
87#define IO_TIMER1       0x40
88#define TIMER_CNTR0     (IO_TIMER1 + 0) /* timer 0 counter port */
89#define TIMER_CNTR1     (IO_TIMER1 + 1) /* timer 1 counter port */
90#define TIMER_CNTR2     (IO_TIMER1 + 2) /* timer 2 counter port */
91#define TIMER_MODE      (IO_TIMER1 + 3) /* timer mode port */
92#define         TIMER_SEL0      0x00    /* select counter 0 */
93#define         TIMER_SEL1      0x40    /* select counter 1 */
94#define         TIMER_SEL2      0x80    /* select counter 2 */
95#define         TIMER_INTTC     0x00    /* mode 0, intr on terminal cnt */
96#define         TIMER_ONESHOT   0x02    /* mode 1, one shot */
97#define         TIMER_RATEGEN   0x04    /* mode 2, rate generator */
98#define         TIMER_SQWAVE    0x06    /* mode 3, square wave */
99#define         TIMER_SWSTROBE  0x08    /* mode 4, s/w triggered strobe */
100#define         TIMER_HWSTROBE  0x0a    /* mode 5, h/w triggered strobe */
101#define         TIMER_LATCH     0x00    /* latch counter for reading */
102#define         TIMER_LSB       0x10    /* r/w counter LSB */
103#define         TIMER_MSB       0x20    /* r/w counter MSB */
104#define         TIMER_16BIT     0x30    /* r/w counter 16 bits, LSB first */
105#define         TIMER_BCD       0x01    /* count in BCD */
106
107#define CLOCK_DISABLE() \
108    ({ char mask; inport_byte( 0x21, mask ); outport_byte( 0x21, mask | 1 ); })
109#define CLOCK_ENABLE()  \
110    ({ char mask; inport_byte( 0x21, mask ); outport_byte( 0x21, mask & ~1); })
111
112/*      The internal tick rate in ticks per second */
113#define         TIMER_TICK      1193182
114#define         US_TO_TICK(us)  (((us)*105+44)/88)
115#define         TICK_TO_US(tk)  (((tk)*88+52)/105)
116
117/* Structures */
118
119#ifdef IBMPC_INIT
120#undef BSP_EXTERN
121#define BSP_EXTERN
122#else
123#undef BSP_EXTERN
124#define BSP_EXTERN extern
125#endif
126
127/* functions */
128
129int _IBMPC_chrdy( char * ch );
130int _IBMPC_inch( void );
131void _IBMPC_outch( unsigned char );
132
133/* miscellaneous stuff assumed to exist */
134
135extern rtems_configuration_table BSP_Configuration;
136
137#if 0
138extern i386_IDT_slot Interrupt_descriptor_table[ 256 ];
139extern i386_GDT_slot Global_descriptor_table[ 8192 ];
140BSP_EXTERN unsigned short Idt[3];  /* Interrupt Descriptor Table Address */
141BSP_EXTERN unsigned short Gdt[3];  /* Global Descriptor Table Address */
142BSP_EXTERN unsigned int   Idt_base;
143BSP_EXTERN unsigned int   Gdt_base;
144#endif
145
146/* routines */
147
148i386_isr_entry set_vector(
149  rtems_isr_entry     handler,
150  rtems_vector_number vector,
151  int                 type
152);
153
154#ifdef __cplusplus
155}
156#endif
157
158#endif
159/* end of include file */
160
161
Note: See TracBrowser for help on using the repository browser.