Deleted Added
full compact
agp_ali.c (129878) agp_ali.c (134098)
1/*-
2 * Copyright (c) 2000 Doug Rabson
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

--- 11 unchanged lines hidden (view full) ---

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
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000 Doug Rabson
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

--- 11 unchanged lines hidden (view full) ---

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
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/agp/agp_ali.c 129878 2004-05-30 20:00:41Z phk $");
28__FBSDID("$FreeBSD: head/sys/dev/agp/agp_ali.c 134098 2004-08-21 06:18:11Z anholt $");
29
30#include "opt_bus.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>
35#include <sys/kernel.h>
36#include <sys/module.h>

--- 56 unchanged lines hidden (view full) ---

93}
94
95static int
96agp_ali_attach(device_t dev)
97{
98 struct agp_ali_softc *sc = device_get_softc(dev);
99 struct agp_gatt *gatt;
100 int error;
29
30#include "opt_bus.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>
35#include <sys/kernel.h>
36#include <sys/module.h>

--- 56 unchanged lines hidden (view full) ---

93}
94
95static int
96agp_ali_attach(device_t dev)
97{
98 struct agp_ali_softc *sc = device_get_softc(dev);
99 struct agp_gatt *gatt;
100 int error;
101 u_int32_t attbase;
101
102 error = agp_generic_attach(dev);
103 if (error)
104 return error;
105
106 sc->initial_aperture = AGP_GET_APERTURE(dev);
107 if (sc->initial_aperture == 0) {
108 device_printf(dev, "bad initial aperture size, disabling\n");

--- 12 unchanged lines hidden (view full) ---

121 if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) {
122 agp_generic_detach(dev);
123 return ENOMEM;
124 }
125 }
126 sc->gatt = gatt;
127
128 /* Install the gatt. */
102
103 error = agp_generic_attach(dev);
104 if (error)
105 return error;
106
107 sc->initial_aperture = AGP_GET_APERTURE(dev);
108 if (sc->initial_aperture == 0) {
109 device_printf(dev, "bad initial aperture size, disabling\n");

--- 12 unchanged lines hidden (view full) ---

122 if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) {
123 agp_generic_detach(dev);
124 return ENOMEM;
125 }
126 }
127 sc->gatt = gatt;
128
129 /* Install the gatt. */
129 pci_write_config(dev, AGP_ALI_ATTBASE,
130 (gatt->ag_physical
131 | (pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xff)),
132 4);
130 attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
131 pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical |
132 (attbase & 0xff), 4);
133
134 /* Enable the TLB. */
135 pci_write_config(dev, AGP_ALI_TLBCTRL, 0x10, 1);
136
137 return 0;
138}
139
140static int
141agp_ali_detach(device_t dev)
142{
143 struct agp_ali_softc *sc = device_get_softc(dev);
144 int error;
133
134 /* Enable the TLB. */
135 pci_write_config(dev, AGP_ALI_TLBCTRL, 0x10, 1);
136
137 return 0;
138}
139
140static int
141agp_ali_detach(device_t dev)
142{
143 struct agp_ali_softc *sc = device_get_softc(dev);
144 int error;
145 u_int32_t attbase;
145
146 error = agp_generic_detach(dev);
147 if (error)
148 return error;
149
150 /* Disable the TLB.. */
151 pci_write_config(dev, AGP_ALI_TLBCTRL, 0x90, 1);
152
153 /* Put the aperture back the way it started. */
154 AGP_SET_APERTURE(dev, sc->initial_aperture);
146
147 error = agp_generic_detach(dev);
148 if (error)
149 return error;
150
151 /* Disable the TLB.. */
152 pci_write_config(dev, AGP_ALI_TLBCTRL, 0x90, 1);
153
154 /* Put the aperture back the way it started. */
155 AGP_SET_APERTURE(dev, sc->initial_aperture);
155 pci_write_config(dev, AGP_ALI_ATTBASE,
156 pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xff,
157 4);
156 attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
157 pci_write_config(dev, AGP_ALI_ATTBASE, attbase & 0xff, 4);
158
159 agp_free_gatt(sc->gatt);
160 return 0;
161}
162
163#define M 1024*1024
164
165static u_int32_t agp_ali_table[] = {

--- 23 unchanged lines hidden (view full) ---

189 return 0;
190 return agp_ali_table[i];
191}
192
193static int
194agp_ali_set_aperture(device_t dev, u_int32_t aperture)
195{
196 int i;
158
159 agp_free_gatt(sc->gatt);
160 return 0;
161}
162
163#define M 1024*1024
164
165static u_int32_t agp_ali_table[] = {

--- 23 unchanged lines hidden (view full) ---

189 return 0;
190 return agp_ali_table[i];
191}
192
193static int
194agp_ali_set_aperture(device_t dev, u_int32_t aperture)
195{
196 int i;
197 u_int32_t attbase;
197
198 for (i = 0; i < agp_ali_table_size; i++)
199 if (agp_ali_table[i] == aperture)
200 break;
201 if (i == agp_ali_table_size)
202 return EINVAL;
203
198
199 for (i = 0; i < agp_ali_table_size; i++)
200 if (agp_ali_table[i] == aperture)
201 break;
202 if (i == agp_ali_table_size)
203 return EINVAL;
204
204 pci_write_config(dev, AGP_ALI_ATTBASE,
205 ((pci_read_config(dev, AGP_ALI_ATTBASE, 4) & ~0xff)
206 | i), 4);
205 attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
206 pci_write_config(dev, AGP_ALI_ATTBASE, (attbase & ~0xff) | i, 4);
207 return 0;
208}
209
210static int
211agp_ali_bind_page(device_t dev, int offset, vm_offset_t physical)
212{
213 struct agp_ali_softc *sc = device_get_softc(dev);
214

--- 61 unchanged lines hidden ---
207 return 0;
208}
209
210static int
211agp_ali_bind_page(device_t dev, int offset, vm_offset_t physical)
212{
213 struct agp_ali_softc *sc = device_get_softc(dev);
214

--- 61 unchanged lines hidden ---