OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [peripheral/] [16450.h] - Blame information for rev 344

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 lampret
/* 16450.h -- Definition of types and structures for 8250/16450 serial UART
2
   Copyright (C) 2000 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
/* Prototypes */
21
void uart_reset();
22
void uart_clock();
23
 
24 341 markom
/* Definitions */
25
#define UART_ADDR_SPACE   (8)           /* UART memory address space size in bytes */
26
#define UART_RX_BUF       (8192)      /* VAPI should not send more that this amout of char before requesting something back */
27
#define UART_MAX_FIFO_LEN (16)        /* rx FIFO for uart 16550 */
28
 
29 31 lampret
/* Registers */
30
 
31
struct dev_16450 {
32
        struct {
33 341 markom
                unsigned char txbuf[UART_MAX_FIFO_LEN];
34
                unsigned char rxbuf[UART_MAX_FIFO_LEN];
35 31 lampret
                unsigned char dll;
36
                unsigned char dlh;
37
                unsigned char ier;
38
                unsigned char iir;
39
                unsigned char lcr;
40
                unsigned char mcr;
41
                unsigned char lsr;
42
                unsigned char msr;
43
                unsigned char scr;
44
        } regs;         /* Visible registers */
45
        struct {
46 341 markom
                unsigned long txser;    /* Character just sending */
47
                unsigned long rxser;    /* Character just receiving */
48 31 lampret
                unsigned char loopback;
49
        } iregs;        /* Internal registers */
50
        struct {
51 341 markom
          int txbuf_head;
52
          int txbuf_tail;
53
          int rxbuf_head;
54
          int rxbuf_tail;
55
                unsigned int txser_full;
56
                unsigned int rxser_full;
57
                unsigned int txbuf_full;
58
                unsigned int rxbuf_full;
59 221 markom
                unsigned char thre_int;
60 31 lampret
                unsigned long txser_clks;
61
                unsigned long rxser_clks;
62
        } istat;        /* Internal status */
63 341 markom
 
64
  unsigned long char_clks;
65
 
66
        /* Required by VAPI - circular buffer */
67
        unsigned long vapi_buf[UART_RX_BUF]; /* Buffer to store incoming characters to,
68
                                           since we cannot handle them so fast - we
69
                                           are serial */
70
  int vapi_buf_head_ptr;               /* Where we write to */
71
  int vapi_buf_tail_ptr;               /* Where we read from */
72
 
73
  /* Length of FIFO, 16 for 16550, 1 for 16450 */
74
  int fifo_len;
75
 
76
        /* Required by standard file streams */
77 221 markom
        FILE * rxfs;
78
        FILE * txfs;
79 31 lampret
};
80
 
81
/*
82
 * Addresses of visible registers
83
 *
84
 */
85
#define UART_RXBUF      0        /* R: Rx buffer, DLAB=0 */
86
#define UART_TXBUF      0        /* W: Tx buffer, DLAB=0 */
87
#define UART_DLL        0        /* R/W: Divisor Latch Low, DLAB=1 */
88
#define UART_DLH        1       /* R/W: Divisor Latch High, DLAB=1 */
89
#define UART_IER        1       /* R/W: Interrupt Enable Register */
90
#define UART_IIR        2       /* R: Interrupt ID Register */
91
#define UART_LCR        3       /* R/W: Line Control Register */
92 344 markom
#define UART_MCR        4       /* W: Modem Control Register */
93 31 lampret
#define UART_LSR        5       /* R: Line Status Register */
94
#define UART_MSR        6       /* R: Modem Status Register */
95
#define UART_SCR        7       /* R/W: Scratch Register */
96
 
97
/*
98
 * R/W masks for valid bits in 8250/16450 (mask out 16550 and later bits)
99
 *
100
 */
101
#define UART_VALID_LCR  0xff
102
#define UART_VALID_LSR  0x7f
103
#define UART_VALID_IIR  0x07
104
#define UART_VALID_IER  0x0f
105
#define UART_VALID_MCR  0x1f
106
#define UART_VALID_MSR  0xff
107
 
108
/*
109
 * Bit definitions for the Line Control Register
110
 *
111
 */
112
#define UART_LCR_DLAB   0x80    /* Divisor latch access bit */
113
#define UART_LCR_SBC    0x40    /* Set break control */
114
#define UART_LCR_SPAR   0x20    /* Stick parity (?) */
115
#define UART_LCR_EPAR   0x10    /* Even parity select */
116
#define UART_LCR_PARITY 0x08    /* Parity Enable */
117
#define UART_LCR_STOP   0x04    /* Stop bits: 0=1 stop bit, 1= 2 stop bits */
118
#define UART_LCR_WLEN5  0x00    /* Wordlength: 5 bits */
119
#define UART_LCR_WLEN6  0x01    /* Wordlength: 6 bits */
120
#define UART_LCR_WLEN7  0x02    /* Wordlength: 7 bits */
121
#define UART_LCR_WLEN8  0x03    /* Wordlength: 8 bits */
122 344 markom
#define UART_LCR_RESET  0x03
123 31 lampret
/*
124
 * Bit definitions for the Line Status Register
125
 */
126
#define UART_LSR_TXSERE 0x40    /* Transmitter serial register empty */
127
#define UART_LSR_TXBUFE 0x20    /* Transmitter buffer register empty */
128
#define UART_LSR_BREAK  0x10    /* Break interrupt indicator */
129
#define UART_LSR_FRAME  0x08    /* Frame error indicator */
130
#define UART_LSR_PARITY 0x04    /* Parity error indicator */
131
#define UART_LSR_OVRRUN 0x02    /* Overrun error indicator */
132
#define UART_LSR_RDRDY  0x01    /* Receiver data ready */
133
 
134
/*
135
 * Bit definitions for the Interrupt Identification Register
136
 */
137
#define UART_IIR_NO_INT 0x01    /* No interrupts pending */
138
#define UART_IIR_ID     0x06    /* Mask for the interrupt ID */
139
 
140
#define UART_IIR_MSI    0x00    /* Modem status interrupt (Low priority) */
141
#define UART_IIR_THRI   0x02    /* Transmitter holding register empty */
142
#define UART_IIR_RDI    0x04    /* Receiver data interrupt */
143
#define UART_IIR_RLSI   0x06    /* Receiver line status interrupt (High p.) */
144
 
145
/*
146
 * Bit definitions for the Interrupt Enable Register
147
 */
148
#define UART_IER_MSI    0x08    /* Enable Modem status interrupt */
149
#define UART_IER_RLSI   0x04    /* Enable receiver line status interrupt */
150
#define UART_IER_THRI   0x02    /* Enable Transmitter holding register int. */
151
#define UART_IER_RDI    0x01    /* Enable receiver data interrupt */
152
 
153
/*
154
 * Bit definitions for the Modem Control Register
155
 */
156
#define UART_MCR_LOOP   0x10    /* Enable loopback mode */
157
#define UART_MCR_AUX2   0x08    /* Auxilary 2  */
158
#define UART_MCR_AUX1   0x04    /* Auxilary 1 */
159
#define UART_MCR_RTS    0x02    /* Force RTS */
160
#define UART_MCR_DTR    0x01    /* Force DTR */
161
 
162
/*
163
 * Bit definitions for the Modem Status Register
164
 */
165
#define UART_MSR_DCD    0x80    /* Data Carrier Detect */
166
#define UART_MSR_RI     0x40    /* Ring Indicator */
167
#define UART_MSR_DSR    0x20    /* Data Set Ready */
168
#define UART_MSR_CTS    0x10    /* Clear to Send */
169
#define UART_MSR_DDCD   0x08    /* Delta DCD */
170
#define UART_MSR_TERI   0x04    /* Trailing edge ring indicator */
171
#define UART_MSR_DDSR   0x02    /* Delta DSR */
172
#define UART_MSR_DCTS   0x01    /* Delta CTS */
173
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.