kernel - Increase syscons history buffer size
[dragonfly.git] / sys / dev / misc / cmx / cmxvar.h
1 /*-
2  * Copyright (c) 2006-2007 Daniel Roethlisberger <daniel@roe.ch>
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  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: src/sys/dev/cmx/cmxvar.h,v 1.1 2008/03/06 08:09:45 rink Exp $
27  * $DragonFly: src/sys/dev/misc/cmx/cmxvar.h,v 1.1 2008/04/23 08:57:10 hasso Exp $
28  */
29
30 /*#define       CMX_DEBUG*/
31 /*#define       CMX_INTR*/
32
33 #define CMX_MIN_RDLEN   10              /* min read length */
34 #define CMX_MIN_WRLEN   5               /* min write length */
35 #define CMX_BUFSZ       512             /* I/O block size */
36
37 struct cmx_softc {
38         device_t dev;                   /* pccard device */
39         struct cdev *cdev;              /* character device */
40
41         struct resource *ioport;        /* io port resource descriptor */
42         int ioport_rid;                 /* io port resource identification */
43
44         bus_space_tag_t bst;            /* bus space tag */
45         bus_space_handle_t bsh;         /* bus space handle */
46
47 #ifdef CMX_INTR
48         struct resource* irq;           /* irq resource descriptor */
49         int irq_rid;                    /* irq resource identification */
50         void *ih;                       /* intr handle */
51 #endif
52
53         struct lock mtx;                /* per-unit lock */
54         struct callout ch;              /* callout handle */
55         struct kqinfo kq;               /* select/poll/kq queue handle */
56
57         int open;                       /* is chardev open? */
58         int polling;                    /* are we polling? */
59         int dying;                      /* are we detaching? */
60
61         unsigned long timeout;          /* response timeout */
62
63         uint8_t buf[CMX_BUFSZ];         /* read/write buffer */
64 };
65
66 extern devclass_t cmx_devclass;
67
68 void    cmx_init_softc(device_t);
69 int     cmx_alloc_resources(device_t);
70 void    cmx_release_resources(device_t);
71 int     cmx_attach(device_t);
72 int     cmx_detach(device_t);
73
74 #define CMX_READ_1(sc, off)                                             \
75         (bus_space_read_1((sc)->bst, (sc)->bsh, off))
76 #define CMX_WRITE_1(sc, off, val)                                       \
77         (bus_space_write_1((sc)->bst, (sc)->bsh, off, val))
78
79 #define cmx_read_BSR(sc)                                                \
80         CMX_READ_1(sc, REG_OFFSET_BSR)
81 #define cmx_write_BSR(sc, val)                                          \
82         CMX_WRITE_1(sc, REG_OFFSET_BSR, val)
83 #define cmx_read_SCR(sc)                                                \
84         CMX_READ_1(sc, REG_OFFSET_SCR)
85 #define cmx_write_SCR(sc, val)                                          \
86         CMX_WRITE_1(sc, REG_OFFSET_SCR, val)
87 #define cmx_read_DTR(sc)                                                \
88         CMX_READ_1(sc, REG_OFFSET_DTR)
89 #define cmx_write_DTR(sc, val)                                          \
90         CMX_WRITE_1(sc, REG_OFFSET_DTR, val)
91
92 #define cmx_test(byte, flags, test)                                     \
93         (((byte) & (flags)) == ((test) ? (flags) : 0))
94
95 #define cmx_test_BSR(sc, flags, test)                                   \
96         cmx_test(cmx_read_BSR(sc), flags, test)
97
98 #define CMX_LOCK(sc)                    lockmgr(&(sc)->mtx, LK_EXCLUSIVE);
99 #define CMX_UNLOCK(sc)                  lockmgr(&(sc)->mtx, LK_RELEASE);
100 #define CMX_LOCK_ASSERT(sc, what)