Deleted Added
full compact
ata-dma.c (45554) ata-dma.c (45720)
1/*-
2 * Copyright (c) 1998,1999 S�ren Schmidt
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 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1998,1999 S�ren Schmidt
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 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Id: ata-dma.c,v 1.3 1999/03/30 13:09:47 sos Exp $
28 * $Id: ata-dma.c,v 1.4 1999/04/10 18:53:35 sos Exp $
29 */
30
31#include "ata.h"
32#include "pci.h"
33#if NATA > 0
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/buf.h>
38#include <sys/malloc.h>
39#include <vm/vm.h>
40#include <vm/pmap.h>
41#include <pci/pcivar.h>
42#include <pci/pcireg.h>
43#include <dev/ata/ata-all.h>
44
29 */
30
31#include "ata.h"
32#include "pci.h"
33#if NATA > 0
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/buf.h>
38#include <sys/malloc.h>
39#include <vm/vm.h>
40#include <vm/pmap.h>
41#include <pci/pcivar.h>
42#include <pci/pcireg.h>
43#include <dev/ata/ata-all.h>
44
45#ifdef __alpha__
46#undef vtophys
47#define vtophys(va) (pmap_kextract(((vm_offset_t) (va))) \
48 + 1*1024*1024*1024)
49#endif
50
45/* misc defines */
46#define MIN(a,b) ((a)>(b)?(b):(a))
47
48#if NPCI > 0
49
50int32_t
51ata_dmainit(struct ata_softc *scp, int32_t device,
52 int32_t apiomode, int32_t wdmamode, int32_t udmamode)

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

59#ifdef ATA_DEBUGDMA
60 printf("ata%d: dmainit: ioaddr=0x%x altioaddr=0x%x, bmaddr=0x%x\n",
61 scp->lun, scp->ioaddr, scp->altioaddr, scp->bmaddr);
62#endif
63
64 if (!(dmatab = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT)))
65 return -1;
66
51/* misc defines */
52#define MIN(a,b) ((a)>(b)?(b):(a))
53
54#if NPCI > 0
55
56int32_t
57ata_dmainit(struct ata_softc *scp, int32_t device,
58 int32_t apiomode, int32_t wdmamode, int32_t udmamode)

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

65#ifdef ATA_DEBUGDMA
66 printf("ata%d: dmainit: ioaddr=0x%x altioaddr=0x%x, bmaddr=0x%x\n",
67 scp->lun, scp->ioaddr, scp->altioaddr, scp->bmaddr);
68#endif
69
70 if (!(dmatab = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT)))
71 return -1;
72
67 if (((int)dmatab>>PAGE_SHIFT)^(((int)dmatab+PAGE_SIZE-1)>>PAGE_SHIFT)) {
73 if (((uintptr_t)dmatab>>PAGE_SHIFT)^(((uintptr_t)dmatab+PAGE_SIZE-1)>>PAGE_SHIFT)) {
68 printf("ata_dmainit: dmatab crosses page boundary, no DMA\n");
69 free(dmatab, M_DEVBUF);
70 return -1;
71 }
72 scp->dmatab[device ? 1 : 0] = dmatab;
73
74 type = pci_conf_read(scp->tag, PCI_ID_REG);
75

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

247{
248 struct ata_dmaentry *dmatab;
249 u_int32_t dma_count, dma_base;
250 int32_t i = 0;
251
252#ifdef ATA_DEBUGDMA
253 printf("ata%d: dmasetup\n", scp->lun);
254#endif
74 printf("ata_dmainit: dmatab crosses page boundary, no DMA\n");
75 free(dmatab, M_DEVBUF);
76 return -1;
77 }
78 scp->dmatab[device ? 1 : 0] = dmatab;
79
80 type = pci_conf_read(scp->tag, PCI_ID_REG);
81

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

253{
254 struct ata_dmaentry *dmatab;
255 u_int32_t dma_count, dma_base;
256 int32_t i = 0;
257
258#ifdef ATA_DEBUGDMA
259 printf("ata%d: dmasetup\n", scp->lun);
260#endif
255 if (((u_int32_t)data & 1) || (count & 1))
261 if (((uintptr_t)data & 1) || (count & 1))
256 return -1;
257
258 if (!count) {
259 printf("ata%d: zero length DMA transfer attempt on %s\n",
260 scp->lun, (device ? "slave" : "master"));
261 return -1;
262 }
263
264 dmatab = scp->dmatab[device ? 1 : 0];
265 dma_base = vtophys(data);
262 return -1;
263
264 if (!count) {
265 printf("ata%d: zero length DMA transfer attempt on %s\n",
266 scp->lun, (device ? "slave" : "master"));
267 return -1;
268 }
269
270 dmatab = scp->dmatab[device ? 1 : 0];
271 dma_base = vtophys(data);
266 dma_count = MIN(count, (PAGE_SIZE - ((u_int32_t)data & PAGE_MASK)));
272 dma_count = MIN(count, (PAGE_SIZE - ((uintptr_t)data & PAGE_MASK)));
267 data += dma_count;
268 count -= dma_count;
269
270 while (count) {
271 dmatab[i].base = dma_base;
272 dmatab[i].count = (dma_count & 0xffff);
273 i++;
274 if (i >= ATA_DMA_ENTRIES) {

--- 91 unchanged lines hidden ---
273 data += dma_count;
274 count -= dma_count;
275
276 while (count) {
277 dmatab[i].base = dma_base;
278 dmatab[i].count = (dma_count & 0xffff);
279 i++;
280 if (i >= ATA_DMA_ENTRIES) {

--- 91 unchanged lines hidden ---