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 235

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
/* Registers */
25
 
26
struct dev_16450 {
27
        struct {
28
                unsigned char txbuf;
29
                unsigned char rxbuf;
30
                unsigned char dll;
31
                unsigned char dlh;
32
                unsigned char ier;
33
                unsigned char iir;
34
                unsigned char lcr;
35
                unsigned char mcr;
36
                unsigned char lsr;
37
                unsigned char msr;
38
                unsigned char scr;
39
        } regs;         /* Visible registers */
40
        struct {
41
                unsigned char txser;
42
                unsigned char rxser;
43
                unsigned char loopback;
44
        } iregs;        /* Internal registers */
45
        struct {
46
                unsigned char txser;
47
                unsigned char rxser;
48
                unsigned char txbuf;
49
                unsigned char rxbuf;
50 221 markom
                unsigned char thre_int;
51 31 lampret
                unsigned long txser_clks;
52
                unsigned long rxser_clks;
53
        } istat;        /* Internal status */
54
        unsigned long char_clks;
55 221 markom
        FILE * rxfs;
56
        FILE * txfs;
57 31 lampret
        unsigned long baseaddr;
58
};
59
 
60
/* Definitions */
61
#define FULL            1
62
#define EMPTY           0
63
#define UART_ADDR_SPACE 8       /* UART memory address space size in bytes */
64
 
65
/*
66
 * Addresses of visible registers
67
 *
68
 */
69
#define UART_RXBUF      0        /* R: Rx buffer, DLAB=0 */
70
#define UART_TXBUF      0        /* W: Tx buffer, DLAB=0 */
71
#define UART_DLL        0        /* R/W: Divisor Latch Low, DLAB=1 */
72
#define UART_DLH        1       /* R/W: Divisor Latch High, DLAB=1 */
73
#define UART_IER        1       /* R/W: Interrupt Enable Register */
74
#define UART_IIR        2       /* R: Interrupt ID Register */
75
#define UART_LCR        3       /* R/W: Line Control Register */
76
#define UART_MCR        4       /* R/W: Modem Control Register */
77
#define UART_LSR        5       /* R: Line Status Register */
78
#define UART_MSR        6       /* R: Modem Status Register */
79
#define UART_SCR        7       /* R/W: Scratch Register */
80
 
81
/*
82
 * R/W masks for valid bits in 8250/16450 (mask out 16550 and later bits)
83
 *
84
 */
85
#define UART_VALID_LCR  0xff
86
#define UART_VALID_LSR  0x7f
87
#define UART_VALID_IIR  0x07
88
#define UART_VALID_IER  0x0f
89
#define UART_VALID_MCR  0x1f
90
#define UART_VALID_MSR  0xff
91
 
92
/*
93
 * Bit definitions for the Line Control Register
94
 *
95
 */
96
#define UART_LCR_DLAB   0x80    /* Divisor latch access bit */
97
#define UART_LCR_SBC    0x40    /* Set break control */
98
#define UART_LCR_SPAR   0x20    /* Stick parity (?) */
99
#define UART_LCR_EPAR   0x10    /* Even parity select */
100
#define UART_LCR_PARITY 0x08    /* Parity Enable */
101
#define UART_LCR_STOP   0x04    /* Stop bits: 0=1 stop bit, 1= 2 stop bits */
102
#define UART_LCR_WLEN5  0x00    /* Wordlength: 5 bits */
103
#define UART_LCR_WLEN6  0x01    /* Wordlength: 6 bits */
104
#define UART_LCR_WLEN7  0x02    /* Wordlength: 7 bits */
105
#define UART_LCR_WLEN8  0x03    /* Wordlength: 8 bits */
106
 
107
/*
108
 * Bit definitions for the Line Status Register
109
 */
110
#define UART_LSR_TXSERE 0x40    /* Transmitter serial register empty */
111
#define UART_LSR_TXBUFE 0x20    /* Transmitter buffer register empty */
112
#define UART_LSR_BREAK  0x10    /* Break interrupt indicator */
113
#define UART_LSR_FRAME  0x08    /* Frame error indicator */
114
#define UART_LSR_PARITY 0x04    /* Parity error indicator */
115
#define UART_LSR_OVRRUN 0x02    /* Overrun error indicator */
116
#define UART_LSR_RDRDY  0x01    /* Receiver data ready */
117
 
118
/*
119
 * Bit definitions for the Interrupt Identification Register
120
 */
121
#define UART_IIR_NO_INT 0x01    /* No interrupts pending */
122
#define UART_IIR_ID     0x06    /* Mask for the interrupt ID */
123
 
124
#define UART_IIR_MSI    0x00    /* Modem status interrupt (Low priority) */
125
#define UART_IIR_THRI   0x02    /* Transmitter holding register empty */
126
#define UART_IIR_RDI    0x04    /* Receiver data interrupt */
127
#define UART_IIR_RLSI   0x06    /* Receiver line status interrupt (High p.) */
128
 
129
/*
130
 * Bit definitions for the Interrupt Enable Register
131
 */
132
#define UART_IER_MSI    0x08    /* Enable Modem status interrupt */
133
#define UART_IER_RLSI   0x04    /* Enable receiver line status interrupt */
134
#define UART_IER_THRI   0x02    /* Enable Transmitter holding register int. */
135
#define UART_IER_RDI    0x01    /* Enable receiver data interrupt */
136
 
137
/*
138
 * Bit definitions for the Modem Control Register
139
 */
140
#define UART_MCR_LOOP   0x10    /* Enable loopback mode */
141
#define UART_MCR_AUX2   0x08    /* Auxilary 2  */
142
#define UART_MCR_AUX1   0x04    /* Auxilary 1 */
143
#define UART_MCR_RTS    0x02    /* Force RTS */
144
#define UART_MCR_DTR    0x01    /* Force DTR */
145
 
146
/*
147
 * Bit definitions for the Modem Status Register
148
 */
149
#define UART_MSR_DCD    0x80    /* Data Carrier Detect */
150
#define UART_MSR_RI     0x40    /* Ring Indicator */
151
#define UART_MSR_DSR    0x20    /* Data Set Ready */
152
#define UART_MSR_CTS    0x10    /* Clear to Send */
153
#define UART_MSR_DDCD   0x08    /* Delta DCD */
154
#define UART_MSR_TERI   0x04    /* Trailing edge ring indicator */
155
#define UART_MSR_DDSR   0x02    /* Delta DSR */
156
#define UART_MSR_DCTS   0x01    /* Delta CTS */
157
 

powered by: WebSVN 2.1.0

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