Deleted Added
full compact
uart_cpu.h (120378) uart_cpu.h (127215)
1/*
1/*
2 * Copyright (c) 2003 Marcel Moolenaar
2 * Copyright (c) 2003, 2004 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/uart/uart_cpu.h 120378 2003-09-23 09:25:38Z nyan $
26 * $FreeBSD: head/sys/dev/uart/uart_cpu.h 127215 2004-03-20 02:14:02Z marcel $
27 */
28
29#ifndef _DEV_UART_CPU_H_
30#define _DEV_UART_CPU_H_
31
32/*
33 * Low-level operations for use by console and/or debug port support.
34 */
35struct uart_ops {
36 int (*probe)(struct uart_bas *);
37 void (*init)(struct uart_bas *, int, int, int, int);
38 void (*term)(struct uart_bas *);
39 void (*putc)(struct uart_bas *, int);
40 int (*poll)(struct uart_bas *);
41 int (*getc)(struct uart_bas *);
42};
43
44extern struct uart_ops uart_i8251_ops;
45extern struct uart_ops uart_ns8250_ops;
46extern struct uart_ops uart_sab82532_ops;
47extern struct uart_ops uart_z8530_ops;
48
27 */
28
29#ifndef _DEV_UART_CPU_H_
30#define _DEV_UART_CPU_H_
31
32/*
33 * Low-level operations for use by console and/or debug port support.
34 */
35struct uart_ops {
36 int (*probe)(struct uart_bas *);
37 void (*init)(struct uart_bas *, int, int, int, int);
38 void (*term)(struct uart_bas *);
39 void (*putc)(struct uart_bas *, int);
40 int (*poll)(struct uart_bas *);
41 int (*getc)(struct uart_bas *);
42};
43
44extern struct uart_ops uart_i8251_ops;
45extern struct uart_ops uart_ns8250_ops;
46extern struct uart_ops uart_sab82532_ops;
47extern struct uart_ops uart_z8530_ops;
48
49extern bus_space_tag_t uart_bus_space_io;
50extern bus_space_tag_t uart_bus_space_mem;
51
49/*
50 * Console and debug port device info.
51 */
52struct uart_softc;
53struct uart_devinfo {
54 SLIST_ENTRY(uart_devinfo) next;
55 struct uart_ops ops;
56 struct uart_bas bas;
57 int baudrate;
58 int databits;
59 int stopbits;
60 int parity;
61 int type;
62#define UART_DEV_CONSOLE 0
63#define UART_DEV_DBGPORT 1
64#define UART_DEV_KEYBOARD 2
65 int (*attach)(struct uart_softc*);
66 int (*detach)(struct uart_softc*);
67 void *cookie; /* Type dependent use. */
68};
69
70int uart_cpu_eqres(struct uart_bas *, struct uart_bas *);
71int uart_cpu_getdev(int, struct uart_devinfo *);
52/*
53 * Console and debug port device info.
54 */
55struct uart_softc;
56struct uart_devinfo {
57 SLIST_ENTRY(uart_devinfo) next;
58 struct uart_ops ops;
59 struct uart_bas bas;
60 int baudrate;
61 int databits;
62 int stopbits;
63 int parity;
64 int type;
65#define UART_DEV_CONSOLE 0
66#define UART_DEV_DBGPORT 1
67#define UART_DEV_KEYBOARD 2
68 int (*attach)(struct uart_softc*);
69 int (*detach)(struct uart_softc*);
70 void *cookie; /* Type dependent use. */
71};
72
73int uart_cpu_eqres(struct uart_bas *, struct uart_bas *);
74int uart_cpu_getdev(int, struct uart_devinfo *);
75int uart_getenv(int, struct uart_devinfo *);
72
76
73void uart_add_sysdev(struct uart_devinfo*);
77void uart_add_sysdev(struct uart_devinfo *);
74
75/*
76 * Operations for low-level access to the UART. Primarily for use
77 * by console and debug port logic.
78 */
79static __inline int
80uart_probe(struct uart_devinfo *di)
81{
82 return (di->ops.probe(&di->bas));
83}
84
85static __inline void
86uart_init(struct uart_devinfo *di)
87{
88 di->ops.init(&di->bas, di->baudrate, di->databits, di->stopbits,
89 di->parity);
90}
91
92static __inline void
93uart_term(struct uart_devinfo *di)
94{
95 di->ops.term(&di->bas);
96}
97
98static __inline void
99uart_putc(struct uart_devinfo *di, int c)
100{
101 di->ops.putc(&di->bas, c);
102}
103
104static __inline int
105uart_poll(struct uart_devinfo *di)
106{
107 return (di->ops.poll(&di->bas));
108}
109
110static __inline int
111uart_getc(struct uart_devinfo *di)
112{
113 return (di->ops.getc(&di->bas));
114}
115
116#endif /* _DEV_UART_CPU_H_ */
78
79/*
80 * Operations for low-level access to the UART. Primarily for use
81 * by console and debug port logic.
82 */
83static __inline int
84uart_probe(struct uart_devinfo *di)
85{
86 return (di->ops.probe(&di->bas));
87}
88
89static __inline void
90uart_init(struct uart_devinfo *di)
91{
92 di->ops.init(&di->bas, di->baudrate, di->databits, di->stopbits,
93 di->parity);
94}
95
96static __inline void
97uart_term(struct uart_devinfo *di)
98{
99 di->ops.term(&di->bas);
100}
101
102static __inline void
103uart_putc(struct uart_devinfo *di, int c)
104{
105 di->ops.putc(&di->bas, c);
106}
107
108static __inline int
109uart_poll(struct uart_devinfo *di)
110{
111 return (di->ops.poll(&di->bas));
112}
113
114static __inline int
115uart_getc(struct uart_devinfo *di)
116{
117 return (di->ops.getc(&di->bas));
118}
119
120#endif /* _DEV_UART_CPU_H_ */