Fix caddr_t fallout. Well, this driver is too ugly to read...

This commit is contained in:
tsutsui 2007-03-05 15:05:24 +00:00
parent fdcc1ff67a
commit f29951d982
2 changed files with 28 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: esp.c,v 1.53 2007/03/04 06:00:26 christos Exp $ */ /* $NetBSD: esp.c,v 1.54 2007/03/05 15:05:24 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -82,7 +82,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: esp.c,v 1.53 2007/03/04 06:00:26 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: esp.c,v 1.54 2007/03/05 15:05:24 tsutsui Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -664,8 +664,8 @@ esp_dma_intr(struct ncr53c9x_softc *sc)
ndtracep += strlen (ndtracep); ndtracep += strlen (ndtracep);
); );
*(esc->sc_dmaaddr) += xfer_len; *esc->sc_dmaaddr = (char *)*esc->sc_dmaaddr + xfer_len;
*(esc->sc_dmalen) -= xfer_len; *esc->sc_dmalen -= xfer_len;
esc->sc_dmaaddr = 0; esc->sc_dmaaddr = 0;
esc->sc_dmalen = 0; esc->sc_dmalen = 0;
esc->sc_dmasize = 0; esc->sc_dmasize = 0;
@ -826,7 +826,7 @@ esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, int datain,
{ {
u_long bgn = (u_long)(*esc->sc_dmaaddr); u_long bgn = (u_long)(*esc->sc_dmaaddr);
u_long end = (u_long)(*esc->sc_dmaaddr+esc->sc_dmasize); u_long end = bgn + esc->sc_dmasize;
slop_bgn_size = DMA_SCSI_ALIGNMENT-(bgn % DMA_SCSI_ALIGNMENT); slop_bgn_size = DMA_SCSI_ALIGNMENT-(bgn % DMA_SCSI_ALIGNMENT);
if (slop_bgn_size == DMA_SCSI_ALIGNMENT) slop_bgn_size = 0; if (slop_bgn_size == DMA_SCSI_ALIGNMENT) slop_bgn_size = 0;
@ -873,7 +873,8 @@ esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, int datain,
#if 01 #if 01
/* Load the normal DMA map */ /* Load the normal DMA map */
{ {
esc->sc_main = *esc->sc_dmaaddr+slop_bgn_size; esc->sc_main = *esc->sc_dmaaddr;
esc->sc_main += slop_bgn_size;
esc->sc_main_size = (esc->sc_dmasize)-(slop_end_size+slop_bgn_size); esc->sc_main_size = (esc->sc_dmasize)-(slop_end_size+slop_bgn_size);
if (esc->sc_main_size) { if (esc->sc_main_size) {
@ -885,7 +886,7 @@ esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, int datain,
esc->sc_main_size += slop_end_size; esc->sc_main_size += slop_end_size;
slop_end_size = 0; slop_end_size = 0;
if (!esc->sc_datain) { if (!esc->sc_datain) {
esc->sc_main_size = DMA_ENDALIGN(void *,esc->sc_main+esc->sc_main_size)-esc->sc_main; esc->sc_main_size = DMA_ENDALIGN(uint8_t *,esc->sc_main+esc->sc_main_size)-esc->sc_main;
} }
} }
@ -926,13 +927,13 @@ esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, int datain,
/* Load the tail DMA map */ /* Load the tail DMA map */
if (slop_end_size) { if (slop_end_size) {
esc->sc_tail = DMA_ENDALIGN(void *,esc->sc_tailbuf+slop_end_size)-slop_end_size; esc->sc_tail = DMA_ENDALIGN(uint8_t *,esc->sc_tailbuf+slop_end_size)-slop_end_size;
/* If the beginning of the tail is not correctly aligned, /* If the beginning of the tail is not correctly aligned,
* we have no choice but to align the start, which might then unalign the end. * we have no choice but to align the start, which might then unalign the end.
*/ */
esc->sc_tail = DMA_SCSI_ALIGN(void *,esc->sc_tail); esc->sc_tail = DMA_SCSI_ALIGN(uint8_t *,esc->sc_tail);
/* So therefore, we change the tail size to be end aligned again. */ /* So therefore, we change the tail size to be end aligned again. */
esc->sc_tail_size = DMA_ENDALIGN(void *,esc->sc_tail+slop_end_size)-esc->sc_tail; esc->sc_tail_size = DMA_ENDALIGN(uint8_t *,esc->sc_tail+slop_end_size)-esc->sc_tail;
/* @@@ next DMA overrun lossage */ /* @@@ next DMA overrun lossage */
if (!esc->sc_datain) { if (!esc->sc_datain) {
@ -971,8 +972,9 @@ esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, int datain,
esc->sc_tail_size = 0; esc->sc_tail_size = 0;
esc->sc_begin_size = slop_bgn_size; esc->sc_begin_size = slop_bgn_size;
esc->sc_main = *esc->sc_dmaaddr+slop_bgn_size; esc->sc_main = *esc->sc_dmaaddr;
esc->sc_main_size = DMA_ENDALIGN(void *,esc->sc_main+esc->sc_dmasize-slop_bgn_size)-esc->sc_main; esc->sc_main += slop_bgn_size;
esc->sc_main_size = DMA_ENDALIGN(uint8_t *,esc->sc_main+esc->sc_dmasize-slop_bgn_size)-esc->sc_main;
if (!esc->sc_datain) { if (!esc->sc_datain) {
esc->sc_main_size += ESP_DMA_OVERRUN; esc->sc_main_size += ESP_DMA_OVERRUN;
@ -992,14 +994,14 @@ esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, int datain,
esc->sc_main_size = 0; esc->sc_main_size = 0;
#if 0 #if 0
esc->sc_tail = DMA_ENDALIGN(void *,esc->sc_tailbuf+slop_bgn_size)-slop_bgn_size; esc->sc_tail = DMA_ENDALIGN(uint8_t *,esc->sc_tailbuf+slop_bgn_size)-slop_bgn_size;
/* If the beginning of the tail is not correctly aligned, /* If the beginning of the tail is not correctly aligned,
* we have no choice but to align the start, which might then unalign the end. * we have no choice but to align the start, which might then unalign the end.
*/ */
#endif #endif
esc->sc_tail = DMA_SCSI_ALIGN(void *,esc->sc_tailbuf); esc->sc_tail = DMA_SCSI_ALIGN(void *,esc->sc_tailbuf);
/* So therefore, we change the tail size to be end aligned again. */ /* So therefore, we change the tail size to be end aligned again. */
esc->sc_tail_size = DMA_ENDALIGN(void *,esc->sc_tail+esc->sc_dmasize)-esc->sc_tail; esc->sc_tail_size = DMA_ENDALIGN(uint8_t *,esc->sc_tail+esc->sc_dmasize)-esc->sc_tail;
/* @@@ next DMA overrun lossage */ /* @@@ next DMA overrun lossage */
if (!esc->sc_datain) { if (!esc->sc_datain) {
@ -1174,7 +1176,7 @@ esp_dma_go(struct ncr53c9x_softc *sc)
if (esc->sc_tail_dmamap->dm_mapsize) { if (esc->sc_tail_dmamap->dm_mapsize) {
/* if we are a DMA write cycle, copy the end slop */ /* if we are a DMA write cycle, copy the end slop */
if (!esc->sc_datain) { if (!esc->sc_datain) {
memcpy(esc->sc_tail, *esc->sc_dmaaddr+esc->sc_begin_size+esc->sc_main_size, memcpy(esc->sc_tail, (char *)*esc->sc_dmaaddr+esc->sc_begin_size+esc->sc_main_size,
esc->sc_dmasize-(esc->sc_begin_size+esc->sc_main_size)); esc->sc_dmasize-(esc->sc_begin_size+esc->sc_main_size));
} }
bus_dmamap_sync(esc->sc_dma->sc_dmat, esc->sc_tail_dmamap, bus_dmamap_sync(esc->sc_dma->sc_dmat, esc->sc_tail_dmamap,
@ -1642,7 +1644,7 @@ esp_dmacb_shutdown(void *arg)
bus_dmamap_unload(esc->sc_dma->sc_dmat, esc->sc_tail_dmamap); bus_dmamap_unload(esc->sc_dma->sc_dmat, esc->sc_tail_dmamap);
/* copy the tail DMA buffer data for read transfers */ /* copy the tail DMA buffer data for read transfers */
if (esc->sc_datain) { if (esc->sc_datain) {
memcpy(*esc->sc_dmaaddr+esc->sc_begin_size+esc->sc_main_size, memcpy((char *)*esc->sc_dmaaddr+esc->sc_begin_size+esc->sc_main_size,
esc->sc_tail, esc->sc_dmasize-(esc->sc_begin_size+esc->sc_main_size)); esc->sc_tail, esc->sc_dmasize-(esc->sc_begin_size+esc->sc_main_size));
} }
NDTRACEIF ( NDTRACEIF (

View File

@ -1,4 +1,4 @@
/* $NetBSD: espvar.h,v 1.16 2007/03/04 06:00:26 christos Exp $ */ /* $NetBSD: espvar.h,v 1.17 2007/03/05 15:05:24 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -44,8 +44,8 @@ struct esp_softc {
bus_space_handle_t sc_bsh; /* the device registers */ bus_space_handle_t sc_bsh; /* the device registers */
void **sc_dmaaddr; /* saved argument to esp_dma_setup */ void **sc_dmaaddr; /* saved argument to esp_dma_setup */
size_t *sc_dmalen; /* saved argument to esp_dma_setup */ size_t *sc_dmalen; /* saved argument to esp_dma_setup */
size_t sc_dmasize; /* saved argument to esp_dma_setup */ size_t sc_dmasize; /* saved argument to esp_dma_setup */
int sc_datain; /* saved argument to esp_dma_setup */ int sc_datain; /* saved argument to esp_dma_setup */
#define ESP_LOADED_MAIN (0x01) #define ESP_LOADED_MAIN (0x01)
@ -60,12 +60,12 @@ struct esp_softc {
/* To deal with begin alignment problems, we stuff the fifo /* To deal with begin alignment problems, we stuff the fifo
* with a begin buffer * with a begin buffer
*/ */
void * sc_begin; /* pointer to start io buf, NULL if invalid */ uint8_t *sc_begin; /* pointer to start io buf, NULL if invalid */
size_t sc_begin_size; /* */ size_t sc_begin_size; /* */
bus_dmamap_t sc_main_dmamap; /* I/O DMA map */ bus_dmamap_t sc_main_dmamap; /* I/O DMA map */
void * sc_main; /* pointer to main io buf, NULL if invalid */ uint8_t *sc_main; /* pointer to main io buf, NULL if invalid */
size_t sc_main_size; /* aligned length of main io buf we are using */ size_t sc_main_size; /* aligned length of main io buf we are using */
/* To deal with end alignment problems, we copy the end of the DMA /* To deal with end alignment problems, we copy the end of the DMA
* buffer into a "tail" buffer that we can control more carefully. * buffer into a "tail" buffer that we can control more carefully.
@ -75,9 +75,9 @@ struct esp_softc {
#define ESP_DMA_MAXTAIL 128 #define ESP_DMA_MAXTAIL 128
#define ESP_DMA_TAILBUFSIZE (ESP_DMA_MAXTAIL+2*DMA_ENDALIGNMENT+ESP_DMA_OVERRUN) #define ESP_DMA_TAILBUFSIZE (ESP_DMA_MAXTAIL+2*DMA_ENDALIGNMENT+ESP_DMA_OVERRUN)
bus_dmamap_t sc_tail_dmamap; bus_dmamap_t sc_tail_dmamap;
void *sc_tail; /* pointer into sc_tailbuf, NULL if invalid */ uint8_t *sc_tail; /* pointer into sc_tailbuf, NULL if invalid */
size_t sc_tail_size; /* aligned length of tailbuf we are using */ size_t sc_tail_size; /* aligned length of tailbuf we are using */
u_char sc_tailbuf[ESP_DMA_TAILBUFSIZE]; uint8_t sc_tailbuf[ESP_DMA_TAILBUFSIZE];
}; };
#ifndef ESP_MAX_DMASIZE #ifndef ESP_MAX_DMASIZE