-
Notifications
You must be signed in to change notification settings - Fork 1
/
sysSerial.c
156 lines (130 loc) · 4.4 KB
/
sysSerial.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* sysSerial.c - serial device initialization */
/* Copyright 1984-2002 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
* This file has been developed or significantly modified by the
* MIPS Center of Excellence Dedicated Engineering Staff.
* This notice is as per the MIPS Center of Excellence Master Partner
* Agreement, do not remove this notice without checking first with
* WR/Platforms MIPS Center of Excellence engineering management.
*/
/*
modification history
--------------------
01a,12sep02,zmm Written.
*/
#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "Lsn2eCpciSBC.h"
#include "config.h"
#include "sysLib.h"
#include "drv/sio/ns16552Sio.h"
NS16550_CHAN ns16550Chan[NUM_TTY];
/******************************************************************************
*
* sysSerialHwInit - initialize the BSP serial devices to a quiescent state
*
* This routine initializes the BSP serial device descriptors and puts the
* devices in a quiescent state. It is called from sysHwInit() with
* interrupts locked.
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit()
*/
void sysSerialHwInit (void)
{
/* intialize the chips device descriptors */
ns16550Chan[0].regs = (UINT8 *)(COM1_BASE_ADDR)/*(K1BASE + BONITO_PCIIO_BASE + COM1_BASE_ADDR)*/;
ns16550Chan[0].level = IV_VIA686_COM1_OFFSET;
ns16550Chan[0].regDelta = UART_REG_ADDR_INTERVAL;
ns16550Chan[0].baudRate = CONSOLE_BAUD_RATE;
ns16550Chan[0].xtal = UART_CLK_RATE;
#if 0
/* intialize the chips device descriptors */
ns16550Chan[1].regs = (UINT8 *) (COM2_BASE_ADDR);
ns16550Chan[1].level = IV_VIA686_COM2_OFFSET;
ns16550Chan[1].regDelta = UART_REG_ADDR_INTERVAL;
ns16550Chan[1].baudRate = CONSOLE_BAUD_RATE;
ns16550Chan[1].xtal = UART_CLK_RATE;
/* intialize the chips device descriptors */
ns16550Chan[2].regs = (UINT8 *) (COM3_BASE_ADDR);
ns16550Chan[2].level = IV_VIA686_COM2_OFFSET;
ns16550Chan[2].regDelta = UART_REG_ADDR_INTERVAL;
ns16550Chan[2].baudRate = CONSOLE_BAUD_RATE;
ns16550Chan[2].xtal = UART_CLK_RATE;
/* intialize the chips device descriptors */
ns16550Chan[3].regs = (UINT8 *) (COM4_BASE_ADDR);
ns16550Chan[3].level = IV_VIA686_COM2_OFFSET;
ns16550Chan[3].regDelta = UART_REG_ADDR_INTERVAL;
ns16550Chan[3].baudRate = CONSOLE_BAUD_RATE;
ns16550Chan[3].xtal = UART_CLK_RATE;
#endif
/* reset the chips */
ns16550DevInit (&ns16550Chan[0]); /* uart int. disabled */
#if 0
ns16550DevInit (&ns16550Chan[1]); /* uart int. disabled */
ns16550DevInit (&ns16550Chan[2]); /* uart int. disabled */
ns16550DevInit (&ns16550Chan[3]); /* uart int. disabled */
#endif
}
/******************************************************************************
*
* sysSerialHwInit2 - connect BSP serial device interrupts
*
* This routine connects the BSP serial device interrupts. It is called from
* sysHwInit2().
*
* Serial device interrupts cannot be connected in sysSerialHwInit() because
* the kernel memory allocator was not initialized at that point, and
* intConnect() calls malloc().
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit2()
*/
void sysSerialHwInit2 (void)
{
(void) intConnect (INUM_TO_IVEC (IV_COM1_VEC), ns16550Int, (int)sysSerialChanGet(0));
sysIntEnablePIC(IV_VIA686_COM1_OFFSET);
#if 0
(void) intConnect (INUM_TO_IVEC (IV_COM2_VEC), ns16550Int, (int)sysSerialChanGet(1));
sysIntEnablePIC(IV_VIA686_COM2_OFFSET);
(void) intConnect (INUM_TO_IVEC (IV_COM3_VEC), ns16550Int, (int)sysSerialChanGet(2));
sysIntEnablePIC(IV_VIA686_COM2_OFFSET);
(void) intConnect (INUM_TO_IVEC (IV_COM4_VEC), ns16550Int, (int)sysSerialChanGet(3));
sysIntEnablePIC(IV_VIA686_COM2_OFFSET);
/*tmp=read_c0_status;
write_c0_status(tmp|0x400);*/
#endif
}
/******************************************************************************
*
* sysSerialChanGet - get the SIO_CHAN device associated with a serial channel
*
* This routine gets the SIO_CHAN device associated with a specified serial
* channel.
*
* RETURNS: A pointer to the SIO_CHAN structure for the channel, or ERROR
* if the channel is invalid.
*/
SIO_CHAN * sysSerialChanGet
(
int channel /* serial channel */
)
{
switch (channel)
{
case 0:
return ((SIO_CHAN *)&ns16550Chan[0]);
case 1:
return ((SIO_CHAN *)&ns16550Chan[1]);
case 2:
return ((SIO_CHAN *)&ns16550Chan[2]);
case 3:
return ((SIO_CHAN *)&ns16550Chan[3]);
default:
return NULL;
}
}