Make modules work again part 1: hook up 'dev'. Note that not all devices
[dragonfly.git] / sys / dev / video / gfb / gfb_pci.h
1 /*
2  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
3  * All rights reserved.
4  *
5  * Author: Chris G. Demetriou
6  * 
7  * Permission to use, copy, modify and distribute this software and
8  * its documentation is hereby granted, provided that both the copyright
9  * notice and this permission notice appear in all copies of the
10  * software, derivative works or modified versions, and any portions
11  * thereof, and that both notices appear in supporting documentation.
12  * 
13  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
14  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
15  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16  * 
17  * Carnegie Mellon requests users of this software to return to
18  *
19  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
20  *  School of Computer Science
21  *  Carnegie Mellon University
22  *  Pittsburgh PA 15213-3890
23  *
24  * any improvements or extensions that they make and grant Carnegie the
25  * rights to redistribute these changes.
26  *
27  * Copyright (c) 2000 Andrew Miklic
28  *
29  * $FreeBSD: src/sys/dev/gfb/gfb_pci.h,v 1.1.2.1 2001/11/01 08:33:15 obrien Exp $
30  * $DragonFly: src/sys/dev/video/gfb/Attic/gfb_pci.h,v 1.2 2003/06/17 04:28:26 dillon Exp $
31  */
32
33 #ifndef _PCI_GFB_H_
34 #define _PCI_GFB_H_
35
36 #define GFB_MEM_BASE_RID        0x10
37
38 typedef u_int32_t gfb_reg_t;
39
40 /* GFB register access macros */
41
42 #define BUFADDR(adp, off)                                       \
43 /*      (adp)->va_buffer = (adp)->va_mem_base +                 \
44                            (((adp)->va_buffer -                 \
45                              (adp)->va_mem_base +               \
46                              (adp)->va_buffer_size) %           \
47                             (adp)->va_mem_size),                \
48         (adp)->va_buffer_alias = ((adp)->va_buffer -            \
49                                   (adp)->va_mem_base) /         \
50                                  (adp)->va_buffer_size,         \
51         (adp)->va_window = (adp)->va_buffer +                   \
52                            (((adp)->va_window -                 \
53                              (adp)->va_mem_base) /              \
54                             (adp)->va_buffer_alias),            \
55 */      ((adp)->va_window + (adp)->va_window_orig +             \
56          ((vm_offset_t)(off) << 2L))
57
58 #define REGADDR(adp, reg)                                       \
59 /*      (adp)->va_buffer = (adp)->va_mem_base +                 \
60                            (((adp)->va_buffer -                 \
61                              (adp)->va_mem_base +               \
62                              (adp)->va_buffer_size) %           \
63                             (adp)->va_mem_size),                \
64         (adp)->va_buffer_alias = ((adp)->va_buffer -            \
65                                   (adp)->va_mem_base) /         \
66                                  (adp)->va_buffer_size,         \
67         (adp)->va_registers = (adp)->va_buffer +                \
68                               (((adp)->va_registers -           \
69                                 (adp)->va_mem_base) /           \
70                                (adp)->va_buffer_alias),         \
71 */      ((adp)->va_registers + ((vm_offset_t)(reg) << 2L))
72
73 #define READ_GFB_REGISTER(adp, reg)                             \
74         (*(u_int32_t *)(REGADDR(adp, reg)))
75 #define WRITE_GFB_REGISTER(adp, reg, val)                       \
76         (*(u_int32_t*)(REGADDR(adp, reg)) = (val))
77 #define GFB_REGISTER_WRITE_BARRIER(sc, reg, nregs)              \
78         bus_space_barrier((sc)->btag, (sc)->regs, ((reg) << 2), \
79                           4 * (nregs), BUS_SPACE_BARRIER_WRITE)
80 #define GFB_REGISTER_READ_BARRIER(sc, reg, nregs)               \
81         bus_space_barrier((sc)->btag, (sc)->regs, ((reg) << 2), \
82                           4 * (nregs), BUS_SPACE_BARRIER_READ)
83 #define GFB_REGISTER_READWRITE_BARRIER(sc, reg, nregs)          \
84         bus_space_barrier((sc)->btag, (sc)->regs, ((reg) << 2), \
85                           4 * (nregs),                          \
86                           BUS_SPACE_BARRIER_READ |              \
87                           BUS_SPACE_BARRIER_WRITE)
88
89 #define READ_GFB_BUFFER(adp, reg)                               \
90         (*(u_int32_t *)(BUFADDR(adp, reg)))
91 #define WRITE_GFB_BUFFER(adp, reg, val)                         \
92         (*(u_int32_t*)(BUFADDR(adp, reg)) = (val))
93
94 /*int pcigfb_probe(device_t);*/
95 int pcigfb_attach(device_t);
96 int pcigfb_detach(device_t);
97
98 #ifdef FB_INSTALL_CDEV
99
100 d_open_t pcigfb_open;
101 d_close_t pcigfb_close;
102 d_read_t pcigfb_read;
103 d_write_t pcigfb_write;
104 d_ioctl_t pcigfb_ioctl;
105 d_mmap_t pcigfb_mmap;
106
107 #endif /*FB_INSTALL_CDEV*/
108
109 typedef struct gfb_type {
110         int vendor_id;
111         int device_id;
112         char* name;
113 } *gfb_type_t;
114
115 #endif /* _PCI_GFB_H_ */