Remove obsolete compatibility glue and improve firewire code readability.

Commit my version of style(9) pass over the firewire code. Now that
other people have started changing the code carrying this is as a
local patch is not longer a viable option.

MFC after:	1 month
This commit is contained in:
kan 2014-09-27 16:50:21 +00:00
parent e0eb5b421d
commit acfad8859d
20 changed files with 939 additions and 1014 deletions

View File

@ -235,7 +235,7 @@ struct ohci_registers {
fwohcireg_t config_rom; /* config ROM map 0x34 */
fwohcireg_t post_wr_lo; /* post write addr lo 0x38 */
fwohcireg_t post_wr_hi; /* post write addr hi 0x3c */
fwohcireg_t vender; /* vender ID 0x40 */
fwohcireg_t vendor; /* vendor ID 0x40 */
fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */
fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */
fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* $FreeBSD$
*
*/
@ -42,8 +42,8 @@
#define DEV_DV 2
struct fw_isochreq {
unsigned char ch:6,
tag:2;
unsigned char ch:6;
unsigned char tag:2;
};
struct fw_isobufreq {
@ -247,15 +247,15 @@ struct fw_eui64 {
uint32_t hi, lo;
};
#define FW_EUI64_BYTE(eui, x) \
((((x)<4)? \
((eui)->hi >> (8*(3-(x)))): \
((eui)->lo >> (8*(7-(x)))) \
((((x) < 4)? \
((eui)->hi >> (8 * (3 - (x)))): \
((eui)->lo >> (8 * (7 - (x)))) \
) & 0xff)
#define FW_EUI64_EQUAL(x, y) \
((x).hi == (y).hi && (x).lo == (y).lo)
struct fw_asyreq {
struct fw_asyreq_t{
struct fw_asyreq_t {
unsigned char sped;
unsigned int type;
#define FWASREQNODE 0
@ -265,8 +265,8 @@ struct fw_asyreq {
unsigned short len;
union {
struct fw_eui64 eui;
}dst;
}req;
} dst;
} req;
struct fw_pkt pkt;
uint32_t data[512];
};
@ -406,7 +406,7 @@ struct fw_topology_map {
uint32_t generation;
uint32_t self_id_count:16,
node_count:16;
union fw_self_id self_id[4*64];
union fw_self_id self_id[4 * 64];
};
struct fw_speed_map {

View File

@ -29,7 +29,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* $FreeBSD$
*
*/

View File

@ -30,21 +30,13 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* $FreeBSD$
*
*/
#ifdef __DragonFly__
typedef d_thread_t fw_proc;
#include <sys/select.h>
#elif __FreeBSD_version >= 500000
typedef struct thread fw_proc;
#include <sys/selinfo.h>
#else
typedef struct proc fw_proc;
#include <sys/select.h>
#endif
#include <sys/uio.h>
#include <sys/mutex.h>
@ -54,7 +46,7 @@ typedef struct proc fw_proc;
STAILQ_HEAD(fw_xferlist, fw_xfer);
struct fw_device{
struct fw_device {
uint16_t dst;
struct fw_eui64 eui;
uint8_t speed;
@ -64,7 +56,7 @@ struct fw_device{
#define CSRROMOFF 0x400
#define CSRROMSIZE 0x400
int rommax; /* offset from 0xffff f000 0000 */
uint32_t csrrom[CSRROMSIZE/4];
uint32_t csrrom[CSRROMSIZE / 4];
int rcnt;
struct firewire_comm *fc;
uint32_t status;
@ -101,11 +93,11 @@ struct tcode_info {
u_char valid_res;
};
struct firewire_comm{
struct firewire_comm {
device_t dev;
device_t bdev;
uint16_t busid:10,
nodeid:6;
nodeid:6;
u_int mode;
u_int nport;
u_int speed;
@ -137,7 +129,7 @@ struct firewire_comm{
STAILQ_HEAD(, fw_device) devices;
u_int sid_cnt;
#define CSRSIZE 0x4000
uint32_t csr_arc[CSRSIZE/4];
uint32_t csr_arc[CSRSIZE / 4];
#define CROMSIZE 0x400
uint32_t *config_rom;
struct crom_src_buf *crom_src_buf;
@ -149,7 +141,7 @@ struct firewire_comm{
struct callout bmr_callout;
struct callout timeout_callout;
struct task task_timeout;
uint32_t (*cyctimer) (struct firewire_comm *);
uint32_t (*cyctimer) (struct firewire_comm *);
void (*ibr) (struct firewire_comm *);
uint32_t (*set_bmr) (struct firewire_comm *, uint32_t);
int (*ioctl) (struct cdev *, u_long, caddr_t, int, fw_proc *);
@ -169,7 +161,7 @@ struct firewire_comm{
struct taskqueue *taskqueue;
struct proc *probe_thread;
};
#define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4])
#define CSRARC(sc, offset) ((sc)->csr_arc[(offset) / 4])
#define FW_GMTX(fc) (&(fc)->mtx)
#define FW_GLOCK(fc) mtx_lock(FW_GMTX(fc))
@ -190,7 +182,7 @@ struct fw_xferq {
#define FWXFERQ_HANDLER (1 << 16)
#define FWXFERQ_WAKEUP (1 << 17)
void (*start) (struct firewire_comm*);
void (*start) (struct firewire_comm *);
int dmach;
struct fw_xferlist q;
u_int queued;
@ -209,7 +201,7 @@ struct fw_xferq {
void (*hand) (struct fw_xferq *);
};
struct fw_bulkxfer{
struct fw_bulkxfer {
int poffset;
struct mbuf *mbuf;
STAILQ_ENTRY(fw_bulkxfer) link;
@ -218,7 +210,7 @@ struct fw_bulkxfer{
int resp;
};
struct fw_bind{
struct fw_bind {
u_int64_t start;
u_int64_t end;
struct fw_xferlist xferlist;
@ -227,7 +219,7 @@ struct fw_bind{
void *sc;
};
struct fw_xfer{
struct fw_xfer {
caddr_t sc;
struct firewire_comm *fc;
struct fw_xferq *q;
@ -267,9 +259,9 @@ struct fw_rcv_buf {
void fw_sidrcv (struct firewire_comm *, uint32_t *, u_int);
void fw_rcv (struct fw_rcv_buf *);
void fw_xfer_unload ( struct fw_xfer*);
void fw_xfer_free_buf ( struct fw_xfer*);
void fw_xfer_free ( struct fw_xfer*);
void fw_xfer_unload (struct fw_xfer *);
void fw_xfer_free_buf (struct fw_xfer *);
void fw_xfer_free (struct fw_xfer*);
struct fw_xfer *fw_xfer_alloc (struct malloc_type *);
struct fw_xfer *fw_xfer_alloc_buf (struct malloc_type *, int, int);
void fw_init (struct firewire_comm *);
@ -280,7 +272,7 @@ int fw_bindremove (struct firewire_comm *, struct fw_bind *);
int fw_xferlist_add (struct fw_xferlist *, struct malloc_type *, int, int, int,
struct firewire_comm *, void *, void (*)(struct fw_xfer *));
void fw_xferlist_remove (struct fw_xferlist *);
int fw_asyreq (struct firewire_comm *, int, struct fw_xfer*);
int fw_asyreq (struct firewire_comm *, int, struct fw_xfer *);
void fw_busreset (struct firewire_comm *, uint32_t);
uint16_t fw_crc16 (uint32_t *, uint32_t);
void fw_xfer_timeout (void *);
@ -301,7 +293,7 @@ extern int firewire_debug;
extern devclass_t firewire_devclass;
extern int firewire_phydma_enable;
#define FWPRI ((PZERO+8)|PCATCH)
#define FWPRI ((PZERO + 8) | PCATCH)
#define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */)

View File

@ -59,13 +59,8 @@ __FBSDID("$FreeBSD$");
#endif
#endif
#ifdef __DragonFly__
#include "firewire.h"
#include "iec13213.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/iec13213.h>
#endif
#define MAX_ROM (1024 - sizeof(uint32_t) * 5)
#define CROM_END(cc) ((vm_offset_t)(cc)->stack[0].dir + MAX_ROM - 1)
@ -116,7 +111,7 @@ crom_next(struct crom_context *cc)
printf("crom_next: too deep\n");
goto again;
}
cc->depth ++;
cc->depth++;
ptr = &cc->stack[cc->depth];
ptr->dir = (struct csrdirectory *) (reg + reg->val);
@ -125,10 +120,10 @@ crom_next(struct crom_context *cc)
}
again:
ptr = &cc->stack[cc->depth];
ptr->index ++;
ptr->index++;
check:
if (ptr->index < ptr->dir->crc_len &&
(vm_offset_t)crom_get(cc) <= CROM_END(cc))
(vm_offset_t)crom_get(cc) <= CROM_END(cc))
return;
if (ptr->index < ptr->dir->crc_len)
@ -148,7 +143,7 @@ crom_search_key(struct crom_context *cc, uint8_t key)
{
struct csrreg *reg;
while(cc->depth >= 0) {
while (cc->depth >= 0) {
reg = crom_get(cc);
if (reg->key == key)
return reg;
@ -166,7 +161,7 @@ crom_has_specver(uint32_t *p, uint32_t spec, uint32_t ver)
cc = &c;
crom_init_context(cc, p);
while(cc->depth >= 0) {
while (cc->depth >= 0) {
reg = crom_get(cc);
if (state == 0) {
if (reg->key == CSRKEY_SPEC && reg->val == spec)
@ -198,7 +193,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len)
reg = crom_get(cc);
if (reg->key != CROM_TEXTLEAF ||
(vm_offset_t)(reg + reg->val) > CROM_END(cc)) {
(vm_offset_t)(reg + reg->val) > CROM_END(cc)) {
strncpy(buf, nullstr, len);
return;
}
@ -215,7 +210,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len)
qlen = textleaf->crc_len - 2;
if (len < qlen * 4)
qlen = len/4;
for (i = 0; i < qlen; i ++)
for (i = 0; i < qlen; i++)
*bp++ = ntohl(textleaf->text[i]);
/* make sure to terminate the string */
if (len <= qlen * 4)
@ -238,7 +233,7 @@ crom_crc(uint32_t *ptr, int len)
}
crc &= 0xffff;
}
return((uint16_t) crc);
return ((uint16_t) crc);
}
#if !defined(_KERNEL) && !defined(_BOOT)
@ -315,17 +310,17 @@ crom_desc(struct crom_context *cc, char *buf, int len)
break;
case CSRTYPE_C:
len -= snprintf(buf, len, "offset=0x%04x(%d)",
reg->val, reg->val);
reg->val, reg->val);
buf += strlen(buf);
break;
case CSRTYPE_L:
/* XXX fall through */
case CSRTYPE_D:
dir = (struct csrdirectory *) (reg + reg->val);
dir = (struct csrdirectory *)(reg + reg->val);
crc = crom_crc((uint32_t *)&dir->entry[0], dir->crc_len);
len -= snprintf(buf, len, "len=%d crc=0x%04x(%s) ",
dir->crc_len, dir->crc,
(crc == dir->crc) ? "OK" : "NG");
dir->crc_len, dir->crc,
(crc == dir->crc) ? "OK" : "NG");
buf += strlen(buf);
}
switch (reg->key) {
@ -399,11 +394,11 @@ crom_add_quad(struct crom_chunk *chunk, uint32_t entry)
index = chunk->data.crc_len;
if (index >= CROM_MAX_CHUNK_LEN - 1) {
printf("too large chunk %d\n", index);
return(-1);
return (-1);
}
chunk->data.buf[index] = entry;
chunk->data.crc_len++;
return(index);
return (index);
}
int
@ -414,7 +409,7 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val)
struct csrreg reg;
uint32_t i;
} foo;
foo.reg.key = key;
foo.reg.val = val;
return (crom_add_quad(chunk, foo.i));
@ -422,29 +417,29 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val)
int
crom_add_chunk(struct crom_src *src, struct crom_chunk *parent,
struct crom_chunk *child, int key)
struct crom_chunk *child, int key)
{
int index;
if (parent == NULL) {
STAILQ_INSERT_TAIL(&src->chunk_list, child, link);
return(0);
return (0);
}
index = crom_add_entry(parent, key, 0);
if (index < 0) {
return(-1);
return (-1);
}
child->ref_chunk = parent;
child->ref_index = index;
STAILQ_INSERT_TAIL(&src->chunk_list, child, link);
return(index);
return (index);
}
#define MAX_TEXT ((CROM_MAX_CHUNK_LEN + 1) * 4 - sizeof(struct csrtext))
int
crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
struct crom_chunk *chunk, char *buf)
struct crom_chunk *chunk, char *buf)
{
struct csrtext *tl;
uint32_t *p;
@ -453,7 +448,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
len = strlen(buf);
if (len > MAX_TEXT) {
printf("text(%d) trancated to %td.\n", len, MAX_TEXT);
printf("text(%d) truncated to %td.\n", len, MAX_TEXT);
len = MAX_TEXT;
}
@ -465,7 +460,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
bzero(&t[0], roundup2(len, sizeof(uint32_t)));
bcopy(buf, &t[0], len);
p = (uint32_t *)&t[0];
for (i = 0; i < howmany(len, sizeof(uint32_t)); i ++)
for (i = 0; i < howmany(len, sizeof(uint32_t)); i++)
tl->text[i] = ntohl(*p++);
return (crom_add_chunk(src, parent, chunk, CROM_TEXTLEAF));
}
@ -475,11 +470,11 @@ crom_copy(uint32_t *src, uint32_t *dst, int *offset, int len, int maxlen)
{
if (*offset + len > maxlen) {
printf("Config. ROM is too large for the buffer\n");
return(-1);
return (-1);
}
bcopy(src, (char *)(dst + *offset), len * sizeof(uint32_t));
*offset += len;
return(0);
return (0);
}
int
@ -503,9 +498,9 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen)
if (parent != NULL) {
struct csrreg *reg;
reg = (struct csrreg *)
&parent->data.buf[chunk->ref_index];
&parent->data.buf[chunk->ref_index];
reg->val = offset -
(parent->offset + 1 + chunk->ref_index);
(parent->offset + 1 + chunk->ref_index);
}
offset += 1 + chunk->data.crc_len;
}
@ -514,15 +509,15 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen)
len = 1 + src->hdr.info_len;
count = 0;
if (crom_copy((uint32_t *)&src->hdr, buf, &count, len, maxlen) < 0)
return(-1);
return (-1);
STAILQ_FOREACH(chunk, &src->chunk_list, link) {
chunk->data.crc =
crom_crc(&chunk->data.buf[0], chunk->data.crc_len);
crom_crc(&chunk->data.buf[0], chunk->data.crc_len);
len = 1 + chunk->data.crc_len;
if (crom_copy((uint32_t *)&chunk->data, buf,
&count, len, maxlen) < 0)
return(-1);
&count, len, maxlen) < 0)
return (-1);
}
hdr = (struct csrhdr *)buf;
hdr->crc_len = count - 1;
@ -531,19 +526,20 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen)
#if defined(_KERNEL) || defined(_BOOT)
/* byte swap */
ptr = buf;
for (i = 0; i < count; i ++) {
for (i = 0; i < count; i++) {
*ptr = htonl(*ptr);
ptr++;
}
#endif
return(count);
return (count);
}
#endif
#ifdef TEST
int
main () {
main()
{
struct crom_src src;
struct crom_chunk root,unit1,unit2,unit3;
struct crom_chunk text1,text2,text3,text4,text5,text6,text7;
@ -587,15 +583,9 @@ main () {
/* private company_id */
crom_add_entry(&root, CSRKEY_VENDOR, 0xacde48);
#ifdef __DragonFly__
crom_add_simple_text(&src, &root, &text1, "DragonFly");
crom_add_entry(&root, CSRKEY_HW, __DragonFly_cc_version);
crom_add_simple_text(&src, &root, &text2, "DragonFly-1");
#else
crom_add_simple_text(&src, &root, &text1, "FreeBSD");
crom_add_entry(&root, CSRKEY_HW, __FreeBSD_version);
crom_add_simple_text(&src, &root, &text2, "FreeBSD-5");
#endif
/* SBP unit directory */
crom_add_chunk(&src, &root, &unit1, CROM_UDIR);
@ -628,11 +618,11 @@ main () {
crom_load(&src, buf, 256);
p = buf;
#define DUMP_FORMAT "%08x %08x %08x %08x %08x %08x %08x %08x\n"
for (i = 0; i < 256/8; i ++) {
for (i = 0; i < 256/8; i++) {
printf(DUMP_FORMAT,
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
p += 8;
}
return(0);
return (0);
}
#endif

View File

@ -30,7 +30,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* $FreeBSD$
*
*/
@ -52,19 +52,11 @@
#include <sys/ioccom.h>
#ifdef __DragonFly__
#include "firewire.h"
#include "firewirereg.h"
#include "fwdma.h"
#include "fwmem.h"
#include "iec68113.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwdma.h>
#include <dev/firewire/fwmem.h>
#include <dev/firewire/iec68113.h>
#endif
#define FWNODE_INVAL 0xffff
@ -78,12 +70,6 @@ static d_mmap_t fw_mmap;
static d_strategy_t fw_strategy;
struct cdevsw firewire_cdevsw = {
#ifdef __DragonFly__
#define CDEV_MAJOR 127
"fw", CDEV_MAJOR, D_MEM, NULL, 0,
fw_open, fw_close, fw_read, fw_write, fw_ioctl,
fw_poll, fw_mmap, fw_strategy, nodump, nopsize,
#elif __FreeBSD_version >= 500104
.d_version = D_VERSION,
.d_open = fw_open,
.d_close = fw_close,
@ -95,12 +81,6 @@ struct cdevsw firewire_cdevsw = {
.d_strategy = fw_strategy,
.d_name = "fw",
.d_flags = D_MEM
#else
#define CDEV_MAJOR 127
fw_open, fw_close, fw_read, fw_write, fw_ioctl,
fw_poll, fw_mmap, fw_strategy, "fw", CDEV_MAJOR,
nodump, nopsize, D_MEM, -1
#endif
};
struct fw_drv1 {
@ -119,22 +99,21 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q,
int i;
if (q->flag & (FWXFERQ_RUNNING | FWXFERQ_EXTBUF))
return(EBUSY);
return (EBUSY);
q->bulkxfer = (struct fw_bulkxfer *) malloc(
sizeof(struct fw_bulkxfer) * b->nchunk,
M_FW, M_WAITOK);
q->bulkxfer = malloc(sizeof(struct fw_bulkxfer) * b->nchunk,
M_FW, M_WAITOK);
if (q->bulkxfer == NULL)
return(ENOMEM);
return (ENOMEM);
b->psize = roundup2(b->psize, sizeof(uint32_t));
q->buf = fwdma_malloc_multiseg(fc, sizeof(uint32_t),
b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK);
b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK);
if (q->buf == NULL) {
free(q->bulkxfer, M_FW);
q->bulkxfer = NULL;
return(ENOMEM);
return (ENOMEM);
}
q->bnchunk = b->nchunk;
q->bnpacket = b->npacket;
@ -146,7 +125,7 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q,
STAILQ_INIT(&q->stdma);
q->stproc = NULL;
for(i = 0 ; i < q->bnchunk; i++){
for (i = 0; i < q->bnchunk; i++) {
q->bulkxfer[i].poffset = i * q->bnpacket;
q->bulkxfer[i].mbuf = NULL;
STAILQ_INSERT_TAIL(&q->stfree, &q->bulkxfer[i], link);
@ -177,7 +156,7 @@ fwdev_freebuf(struct fw_xferq *q)
static int
fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
fw_open(struct cdev *dev, int flags, int fmt, fw_proc *td)
{
int err = 0;
int unit = DEV2UNIT(dev);
@ -209,10 +188,10 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
int sub = DEV2SUB(dev);
make_dev(&firewire_cdevsw, dev2unit(dev),
UID_ROOT, GID_OPERATOR, 0660,
"fw%d.%d", unit, sub);
UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, sub);
}
d = (struct fw_drv1 *)dev->si_drv1;
d = dev->si_drv1;
d->fc = sc->fc;
STAILQ_INIT(&d->binds);
STAILQ_INIT(&d->rq);
@ -221,7 +200,7 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
}
static int
fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
fw_close(struct cdev *dev, int flags, int fmt, fw_proc *td)
{
struct firewire_comm *fc;
struct fw_drv1 *d;
@ -232,12 +211,12 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
if (DEV_FWMEM(dev))
return fwmem_close(dev, flags, fmt, td);
d = (struct fw_drv1 *)dev->si_drv1;
d = dev->si_drv1;
fc = d->fc;
/* remove binding */
for (fwb = STAILQ_FIRST(&d->binds); fwb != NULL;
fwb = STAILQ_FIRST(&d->binds)) {
fwb = STAILQ_FIRST(&d->binds)) {
fw_bindremove(fc, fwb);
STAILQ_REMOVE_HEAD(&d->binds, chlist);
fw_xferlist_remove(&fwb->xferlist);
@ -256,15 +235,15 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
fwdev_freebuf(ir);
/* drain receiving buffer */
for (xfer = STAILQ_FIRST(&ir->q);
xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) {
ir->queued --;
xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) {
ir->queued--;
STAILQ_REMOVE_HEAD(&ir->q, link);
xfer->resp = 0;
fw_xfer_done(xfer);
}
ir->flag &= ~(FWXFERQ_OPEN |
FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
ir->flag &= ~(FWXFERQ_OPEN | FWXFERQ_MODEMASK |
FWXFERQ_CHTAGMASK);
d->ir = NULL;
}
@ -280,7 +259,7 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
/* free extbuf */
fwdev_freebuf(it);
it->flag &= ~(FWXFERQ_OPEN |
FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
d->it = NULL;
}
free(dev->si_drv1, M_FW);
@ -317,10 +296,10 @@ fw_read_async(struct fw_drv1 *d, struct uio *uio, int ioflag)
fc->irx_post(fc, fp->mode.ld);
#endif
tinfo = &xfer->fc->tcode[fp->mode.hdr.tcode];
err = uiomove((void *)fp, tinfo->hdr_len, uio);
err = uiomove(fp, tinfo->hdr_len, uio);
if (err)
goto out;
err = uiomove((void *)xfer->recv.payload, xfer->recv.pay_len, uio);
err = uiomove(xfer->recv.payload, xfer->recv.pay_len, uio);
out:
/* recycle this xfer */
@ -337,7 +316,7 @@ fw_read_async(struct fw_drv1 *d, struct uio *uio, int ioflag)
* read request.
*/
static int
fw_read (struct cdev *dev, struct uio *uio, int ioflag)
fw_read(struct cdev *dev, struct uio *uio, int ioflag)
{
struct fw_drv1 *d;
struct fw_xferq *ir;
@ -348,7 +327,7 @@ fw_read (struct cdev *dev, struct uio *uio, int ioflag)
if (DEV_FWMEM(dev))
return (physio(dev, uio, ioflag));
d = (struct fw_drv1 *)dev->si_drv1;
d = dev->si_drv1;
fc = d->fc;
ir = d->ir;
@ -383,21 +362,21 @@ fw_read (struct cdev *dev, struct uio *uio, int ioflag)
err = EIO;
FW_GUNLOCK(fc);
return err;
} else if(ir->stproc != NULL) {
} else if (ir->stproc != NULL) {
/* iso bulkxfer */
FW_GUNLOCK(fc);
fp = (struct fw_pkt *)fwdma_v_addr(ir->buf,
ir->stproc->poffset + ir->queued);
if(fc->irx_post != NULL)
fp = (struct fw_pkt *)fwdma_v_addr(ir->buf,
ir->stproc->poffset + ir->queued);
if (fc->irx_post != NULL)
fc->irx_post(fc, fp->mode.ld);
if(fp->mode.stream.len == 0){
if (fp->mode.stream.len == 0) {
err = EIO;
return err;
}
err = uiomove((caddr_t)fp,
fp->mode.stream.len + sizeof(uint32_t), uio);
ir->queued ++;
if(ir->queued >= ir->bnpacket){
ir->queued++;
if (ir->queued >= ir->bnpacket) {
s = splfw();
STAILQ_INSERT_TAIL(&ir->stfree, ir->stproc, link);
splx(s);
@ -470,7 +449,7 @@ fw_write_async(struct fw_drv1 *d, struct uio *uio, int ioflag)
}
static int
fw_write (struct cdev *dev, struct uio *uio, int ioflag)
fw_write(struct cdev *dev, struct uio *uio, int ioflag)
{
int err = 0;
int s, slept = 0;
@ -482,7 +461,7 @@ fw_write (struct cdev *dev, struct uio *uio, int ioflag)
if (DEV_FWMEM(dev))
return (physio(dev, uio, ioflag));
d = (struct fw_drv1 *)dev->si_drv1;
d = dev->si_drv1;
fc = d->fc;
it = d->it;
@ -523,7 +502,7 @@ fw_write (struct cdev *dev, struct uio *uio, int ioflag)
err = uiomove((caddr_t)fp, sizeof(struct fw_isohdr), uio);
err = uiomove((caddr_t)fp->mode.stream.payload,
fp->mode.stream.len, uio);
it->queued ++;
it->queued++;
if (it->queued >= it->bnpacket) {
s = splfw();
STAILQ_INSERT_TAIL(&it->stvalid, it->stproc, link);
@ -550,7 +529,7 @@ fw_hand(struct fw_xfer *xfer)
struct fw_drv1 *d;
fwb = (struct fw_bind *)xfer->sc;
d = (struct fw_drv1 *)fwb->sc;
d = fwb->sc;
FW_GLOCK(xfer->fc);
STAILQ_INSERT_TAIL(&d->rq, xfer, link);
FW_GUNLOCK(xfer->fc);
@ -561,7 +540,7 @@ fw_hand(struct fw_xfer *xfer)
* ioctl support.
*/
int
fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
fw_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
{
struct firewire_comm *fc;
struct fw_drv1 *d;
@ -585,9 +564,9 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
return fwmem_ioctl(dev, cmd, data, flag, td);
if (!data)
return(EINVAL);
return (EINVAL);
d = (struct fw_drv1 *)dev->si_drv1;
d = dev->si_drv1;
fc = d->fc;
ir = d->ir;
it = d->it;
@ -703,7 +682,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
bcopy(fp, (void *)&xfer->send.hdr, tinfo->hdr_len);
if (pay_len > 0)
bcopy((char *)fp + tinfo->hdr_len,
(void *)xfer->send.payload, pay_len);
xfer->send.payload, pay_len);
xfer->send.spd = asyreq->req.sped;
xfer->hand = fw_xferwake;
@ -725,7 +704,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
pay_len = xfer->recv.pay_len;
if (asyreq->req.len >= xfer->recv.pay_len + tinfo->hdr_len) {
asyreq->req.len = xfer->recv.pay_len +
tinfo->hdr_len;
tinfo->hdr_len;
} else {
err = EINVAL;
pay_len = 0;
@ -745,7 +724,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
case FW_CBINDADDR:
fwb = fw_bindlookup(fc,
bindreq->start.hi, bindreq->start.lo);
if(fwb == NULL){
if (fwb == NULL) {
err = EINVAL;
break;
}
@ -755,30 +734,30 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
free(fwb, M_FW);
break;
case FW_SBINDADDR:
if(bindreq->len <= 0 ){
if (bindreq->len <= 0) {
err = EINVAL;
break;
}
if(bindreq->start.hi > 0xffff ){
if (bindreq->start.hi > 0xffff) {
err = EINVAL;
break;
}
fwb = (struct fw_bind *)malloc(sizeof (struct fw_bind), M_FW, M_WAITOK);
if(fwb == NULL){
fwb = malloc(sizeof(struct fw_bind), M_FW, M_WAITOK);
if (fwb == NULL) {
err = ENOMEM;
break;
}
fwb->start = ((u_int64_t)bindreq->start.hi << 32) |
bindreq->start.lo;
fwb->end = fwb->start + bindreq->len;
fwb->sc = (void *)d;
fwb->sc = d;
STAILQ_INIT(&fwb->xferlist);
err = fw_bindadd(fc, fwb);
if (err == 0) {
fw_xferlist_add(&fwb->xferlist, M_FWXFER,
/* XXX */
PAGE_SIZE, PAGE_SIZE, 5,
fc, (void *)fwb, fw_hand);
fc, fwb, fw_hand);
STAILQ_INSERT_TAIL(&d->binds, fwb, chlist);
}
break;
@ -791,11 +770,11 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
devinfo->eui.hi = fc->eui.hi;
devinfo->eui.lo = fc->eui.lo;
STAILQ_FOREACH(fwdev, &fc->devices, link) {
if(len < FW_MAX_DEVLST){
if (len < FW_MAX_DEVLST) {
devinfo = &fwdevlst->dev[len++];
devinfo->dst = fwdev->dst;
devinfo->status =
(fwdev->status == FWDEVINVAL)?0:1;
devinfo->status =
(fwdev->status == FWDEVINVAL) ? 0 : 1;
devinfo->eui.hi = fwdev->eui.hi;
devinfo->eui.lo = fwdev->eui.lo;
}
@ -806,7 +785,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
break;
case FW_GTPMAP:
bcopy(fc->topology_map, data,
(fc->topology_map->crc_len + 1) * 4);
(fc->topology_map->crc_len + 1) * 4);
break;
case FW_GCROM:
STAILQ_FOREACH(fwdev, &fc->devices, link)
@ -841,7 +820,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
free(ptr, M_FW);
break;
default:
fc->ioctl (dev, cmd, data, flag, td);
fc->ioctl(dev, cmd, data, flag, td);
break;
}
return err;
@ -867,7 +846,7 @@ fw_poll(struct cdev *dev, int events, fw_proc *td)
}
tmp = POLLOUT | POLLWRNORM;
if (events & tmp) {
/* XXX should be fixed */
/* XXX should be fixed */
revents |= tmp;
}
@ -877,7 +856,7 @@ fw_poll(struct cdev *dev, int events, fw_proc *td)
static int
fw_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
int nproto, vm_memattr_t *memattr)
{
{
if (DEV_FWMEM(dev))
return fwmem_mmap(dev, offset, paddr, nproto, memattr);
@ -912,12 +891,9 @@ fwdev_makedev(struct firewire_softc *sc)
unit = device_get_unit(sc->fc->bdev);
sc->dev = make_dev(&firewire_cdevsw, MAKEMINOR(0, unit, 0),
UID_ROOT, GID_OPERATOR, 0660,
"fw%d.%d", unit, 0);
d = make_dev(&firewire_cdevsw,
MAKEMINOR(FWMEM_FLAG, unit, 0),
UID_ROOT, GID_OPERATOR, 0660,
"fwmem%d.%d", unit, 0);
UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, 0);
d = make_dev(&firewire_cdevsw, MAKEMINOR(FWMEM_FLAG, unit, 0),
UID_ROOT, GID_OPERATOR, 0660, "fwmem%d.%d", unit, 0);
dev_depends(sc->dev, d);
make_dev_alias(sc->dev, "fw%d", unit);
make_dev_alias(d, "fwmem%d", unit);

View File

@ -1,7 +1,7 @@
/*-
* Copyright (c) 2003
* Hidetoshi Shimokawa. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
*/
#ifdef __FreeBSD__
@ -87,7 +87,7 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size,
&dma->dma_tag);
if (err) {
printf("fwdma_malloc: failed(1)\n");
return(NULL);
return (NULL);
}
err = bus_dmamem_alloc(dma->dma_tag, &dma->v_addr,
@ -95,13 +95,13 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size,
if (err) {
printf("fwdma_malloc: failed(2)\n");
/* XXX destroy tag */
return(NULL);
return (NULL);
}
bus_dmamap_load(dma->dma_tag, dma->dma_map, dma->v_addr,
size, fwdma_map_cb, &dma->bus_addr, /*flags*/0);
return(dma->v_addr);
return (dma->v_addr);
}
void
@ -121,11 +121,11 @@ fwdma_malloc_size(bus_dma_tag_t dmat, bus_dmamap_t *dmamap,
if (bus_dmamem_alloc(dmat, &v_addr, flag, dmamap)) {
printf("fwdma_malloc_size: failed(1)\n");
return(NULL);
return (NULL);
}
bus_dmamap_load(dmat, *dmamap, v_addr, size,
fwdma_map_cb, bus_addr, /*flags*/0);
return(v_addr);
return (v_addr);
}
void
@ -134,7 +134,7 @@ fwdma_free_size(bus_dma_tag_t dmat, bus_dmamap_t dmamap,
{
bus_dmamap_unload(dmat, dmamap);
bus_dmamem_free(dmat, vaddr, dmamap);
}
}
/*
* Allocate multisegment dma buffers
@ -162,7 +162,7 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment,
+ sizeof(struct fwdma_seg)*nseg, M_FW, M_WAITOK);
if (am == NULL) {
printf("fwdma_malloc_multiseg: malloc failed\n");
return(NULL);
return (NULL);
}
am->ssize = ssize;
am->esize = esize;
@ -183,21 +183,21 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment,
&am->dma_tag)) {
printf("fwdma_malloc_multiseg: tag_create failed\n");
free(am, M_FW);
return(NULL);
return (NULL);
}
for (seg = &am->seg[0]; nseg --; seg ++) {
for (seg = &am->seg[0]; nseg--; seg++) {
seg->v_addr = fwdma_malloc_size(am->dma_tag, &seg->dma_map,
ssize, &seg->bus_addr, flag);
if (seg->v_addr == NULL) {
printf("fwdma_malloc_multi: malloc_size failed %d\n",
am->nseg);
fwdma_free_multiseg(am);
return(NULL);
return (NULL);
}
am->nseg++;
}
return(am);
return (am);
}
void
@ -205,7 +205,7 @@ fwdma_free_multiseg(struct fwdma_alloc_multi *am)
{
struct fwdma_seg *seg;
for (seg = &am->seg[0]; am->nseg --; seg ++) {
for (seg = &am->seg[0]; am->nseg--; seg++) {
fwdma_free_size(am->dma_tag, seg->dma_map,
seg->v_addr, am->ssize);
}

View File

@ -1,7 +1,7 @@
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -30,20 +30,20 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* $FreeBSD$
*/
struct fwdma_alloc {
bus_dma_tag_t dma_tag;
bus_dmamap_t dma_map;
void * v_addr;
void *v_addr;
bus_addr_t bus_addr;
};
struct fwdma_seg {
bus_dmamap_t dma_map;
void * v_addr;
void *v_addr;
bus_addr_t bus_addr;
};
@ -74,20 +74,20 @@ fwdma_bus_addr(struct fwdma_alloc_multi *am, int index)
}
static __inline void
fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op)
fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op)
{
bus_dmamap_sync(dma->dma_tag, dma->dma_map, op);
}
static __inline void
fwdma_sync_multiseg(struct fwdma_alloc_multi *am,
int start, int end, bus_dmasync_op_t op)
int start, int end, bus_dmasync_op_t op)
{
struct fwdma_seg *seg, *eseg;
seg = &am->seg[am->esize * start / am->ssize];
eseg = &am->seg[am->esize * end / am->ssize];
for (; seg <= eseg; seg ++)
for (; seg <= eseg; seg++)
bus_dmamap_sync(am->dma_tag, seg->dma_map, op);
}

View File

@ -1,7 +1,7 @@
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
*/
#ifdef __FreeBSD__
@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwmem.h>
static int fwmem_speed=2, fwmem_debug=0;
static int fwmem_speed = 2, fwmem_debug = 0;
static struct fw_eui64 fwmem_eui64;
SYSCTL_DECL(_hw_firewire);
static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwmem, CTLFLAG_RD, 0,
@ -126,7 +126,7 @@ fwmem_read_quad(
struct fw_xfer *xfer;
struct fw_pkt *fp;
xfer = fwmem_xfer_req(fwdev, (void *)sc, spd, 0, 4, hand);
xfer = fwmem_xfer_req(fwdev, sc, spd, 0, 4, hand);
if (xfer == NULL) {
return NULL;
}
@ -141,7 +141,7 @@ fwmem_read_quad(
if (fwmem_debug)
printf("fwmem_read_quad: %d %04x:%08x\n", fwdev->dst,
dst_hi, dst_lo);
dst_hi, dst_lo);
if (fw_asyreq(xfer->fc, -1, xfer) == 0)
return xfer;
@ -177,7 +177,7 @@ fwmem_write_quad(
if (fwmem_debug)
printf("fwmem_write_quad: %d %04x:%08x %08x\n", fwdev->dst,
dst_hi, dst_lo, *(uint32_t *)data);
dst_hi, dst_lo, *(uint32_t *)data);
if (fw_asyreq(xfer->fc, -1, xfer) == 0)
return xfer;
@ -199,7 +199,7 @@ fwmem_read_block(
{
struct fw_xfer *xfer;
struct fw_pkt *fp;
xfer = fwmem_xfer_req(fwdev, sc, spd, 0, roundup2(len, 4), hand);
if (xfer == NULL)
return NULL;
@ -216,7 +216,7 @@ fwmem_read_block(
if (fwmem_debug)
printf("fwmem_read_block: %d %04x:%08x %d\n", fwdev->dst,
dst_hi, dst_lo, len);
dst_hi, dst_lo, len);
if (fw_asyreq(xfer->fc, -1, xfer) == 0)
return xfer;
@ -262,9 +262,8 @@ fwmem_write_block(
return NULL;
}
int
fwmem_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
fwmem_open(struct cdev *dev, int flags, int fmt, fw_proc *td)
{
struct fwmem_softc *fms;
struct firewire_softc *sc;
@ -278,20 +277,20 @@ fwmem_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
if (dev->si_drv1 != NULL) {
if ((flags & FWRITE) != 0) {
FW_GUNLOCK(sc->fc);
return(EBUSY);
return (EBUSY);
}
FW_GUNLOCK(sc->fc);
fms = (struct fwmem_softc *)dev->si_drv1;
fms->refcount ++;
fms = dev->si_drv1;
fms->refcount++;
} else {
dev->si_drv1 = (void *)-1;
FW_GUNLOCK(sc->fc);
dev->si_drv1 = malloc(sizeof(struct fwmem_softc),
M_FWMEM, M_WAITOK);
M_FWMEM, M_WAITOK);
if (dev->si_drv1 == NULL)
return(ENOMEM);
return (ENOMEM);
dev->si_iosize_max = DFLTPHYS;
fms = (struct fwmem_softc *)dev->si_drv1;
fms = dev->si_drv1;
bcopy(&fwmem_eui64, &fms->eui, sizeof(struct fw_eui64));
fms->sc = sc;
fms->refcount = 1;
@ -307,10 +306,10 @@ fwmem_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
{
struct fwmem_softc *fms;
fms = (struct fwmem_softc *)dev->si_drv1;
fms = dev->si_drv1;
FW_GLOCK(fms->sc->fc);
fms->refcount --;
fms->refcount--;
FW_GUNLOCK(fms->sc->fc);
if (fwmem_debug)
printf("%s: refcount=%d\n", __func__, fms->refcount);
@ -349,18 +348,18 @@ fwmem_strategy(struct bio *bp)
struct fw_device *fwdev;
struct fw_xfer *xfer;
struct cdev *dev;
int err=0, s, iolen;
int err = 0, s, iolen;
dev = bp->bio_dev;
/* XXX check request length */
s = splfw();
fms = (struct fwmem_softc *)dev->si_drv1;
fms = dev->si_drv1;
fwdev = fw_noderesolve_eui64(fms->sc->fc, &fms->eui);
if (fwdev == NULL) {
if (fwmem_debug)
printf("fwmem: no such device ID:%08x%08x\n",
fms->eui.hi, fms->eui.lo);
fms->eui.hi, fms->eui.lo);
err = EINVAL;
goto error;
}
@ -369,12 +368,12 @@ fwmem_strategy(struct bio *bp)
if ((bp->bio_cmd & BIO_READ) == BIO_READ) {
if (iolen == 4 && (bp->bio_offset & 3) == 0)
xfer = fwmem_read_quad(fwdev,
(void *) bp, fwmem_speed,
(void *)bp, fwmem_speed,
bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
bp->bio_data, fwmem_biodone);
else
xfer = fwmem_read_block(fwdev,
(void *) bp, fwmem_speed,
(void *)bp, fwmem_speed,
bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
iolen, bp->bio_data, fwmem_biodone);
} else {
@ -408,12 +407,12 @@ fwmem_strategy(struct bio *bp)
}
int
fwmem_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
fwmem_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
{
struct fwmem_softc *fms;
int err = 0;
fms = (struct fwmem_softc *)dev->si_drv1;
fms = dev->si_drv1;
switch (cmd) {
case FW_SDEUI64:
bcopy(data, &fms->eui, sizeof(struct fw_eui64));
@ -424,16 +423,18 @@ fwmem_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
default:
err = EINVAL;
}
return(err);
return (err);
}
int
fwmem_poll (struct cdev *dev, int events, fw_proc *td)
{
fwmem_poll(struct cdev *dev, int events, fw_proc *td)
{
return EINVAL;
}
int
fwmem_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
fwmem_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
int nproto, vm_memattr_t *memattr)
{
{
return EINVAL;
}

File diff suppressed because it is too large Load Diff

View File

@ -67,7 +67,7 @@ static int fwohci_pci_detach(device_t self);
* The probe routine.
*/
static int
fwohci_pci_probe( device_t dev )
fwohci_pci_probe(device_t dev)
{
uint32_t id;
@ -211,7 +211,7 @@ fwohci_pci_init(device_t self)
cmd = pci_read_config(self, PCIR_COMMAND, 2);
cmd |= PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN;
#if 1 /* for broken hardware */
cmd &= ~PCIM_CMD_MWRICEN;
cmd &= ~PCIM_CMD_MWRICEN;
#endif
pci_write_config(self, PCIR_COMMAND, cmd, 2);
@ -311,14 +311,15 @@ fwohci_pci_attach(device_t self)
/*lockarg*/FW_GMTX(&sc->fc),
&sc->fc.dmat);
if (err != 0) {
printf("fwohci_pci_attach: Could not allocate DMA tag "
"- error %d\n", err);
return (ENOMEM);
device_printf(self, "fwohci_pci_attach: Could not allocate DMA "
"tag - error %d\n", err);
fwohci_pci_detach(self);
return (ENOMEM);
}
err = fwohci_init(sc, self);
if (err) {
if (err != 0) {
device_printf(self, "fwohci_init failed with err=%d\n", err);
fwohci_pci_detach(self);
return EIO;
@ -337,13 +338,13 @@ fwohci_pci_detach(device_t self)
fwohci_softc_t *sc = device_get_softc(self);
int s;
s = splfw();
if (sc->bsr)
fwohci_stop(sc, self);
bus_generic_detach(self);
if (sc->fc.bdev) {
device_delete_child(self, sc->fc.bdev);
sc->fc.bdev = NULL;
@ -368,7 +369,7 @@ fwohci_pci_detach(device_t self)
}
if (sc->bsr) {
bus_release_resource(self, SYS_RES_MEMORY,PCI_CBMEM,sc->bsr);
bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, sc->bsr);
sc->bsr = NULL;
sc->bst = 0;
sc->bsh = 0;
@ -428,7 +429,7 @@ fwohci_pci_add_child(device_t dev, u_int order, const char *name, int unit)
return (child);
sc->fc.bdev = child;
device_set_ivars(child, (void *)&sc->fc);
device_set_ivars(child, &sc->fc);
err = device_probe_and_attach(child);
if (err) {
@ -447,7 +448,7 @@ fwohci_pci_add_child(device_t dev, u_int order, const char *name, int unit)
int s;
DELAY(250); /* 2 cycles */
s = splfw();
fwohci_poll((void *)sc, 0, -1);
fwohci_poll(&sc->fc, 0, -1);
splx(s);
}

View File

@ -184,7 +184,7 @@ struct fwohcidb {
#define FWOHCIEV_MASK 0x1f
struct ohci_dma{
struct ohci_dma {
fwohcireg_t cntl;
#define OHCI_CNTL_CYCMATCH_S (0x1 << 31)
@ -211,7 +211,7 @@ struct ohci_dma{
fwohcireg_t dummy3;
};
struct ohci_itdma{
struct ohci_itdma {
fwohcireg_t cntl;
fwohcireg_t cntl_clr;
fwohcireg_t dummy0;
@ -237,7 +237,7 @@ struct ohci_registers {
fwohcireg_t config_rom; /* config ROM map 0x34 */
fwohcireg_t post_wr_lo; /* post write addr lo 0x38 */
fwohcireg_t post_wr_hi; /* post write addr hi 0x3c */
fwohcireg_t vender; /* vender ID 0x40 */
fwohcireg_t vendor; /* vendor ID 0x40 */
fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */
fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */
fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */
@ -308,7 +308,7 @@ struct ohci_registers {
fwohcireg_t pys_upper; /* Physical Upper bound 0x120 */
fwohcireg_t dummy7[23]; /* dummy 0x124-0x17c */
/* 0x180, 0x184, 0x188, 0x18c */
/* 0x190, 0x194, 0x198, 0x19c */
/* 0x1a0, 0x1a4, 0x1a8, 0x1ac */
@ -328,7 +328,7 @@ struct ohci_registers {
struct ohci_dma dma_irch[0x20];
};
struct fwohcidb_tr{
struct fwohcidb_tr {
STAILQ_ENTRY(fwohcidb_tr) link;
struct fw_xfer *xfer;
struct fwohcidb *db;
@ -341,8 +341,8 @@ struct fwohcidb_tr{
/*
* OHCI info structure.
*/
struct fwohci_txpkthdr{
union{
struct fwohci_txpkthdr {
union {
uint32_t ld[4];
struct {
#if BYTE_ORDER == BIG_ENDIAN
@ -376,7 +376,7 @@ struct fwohci_txpkthdr{
:8;
#endif
BIT16x2(dst, );
}asycomm;
} asycomm;
struct {
#if BYTE_ORDER == BIG_ENDIAN
uint32_t :13,
@ -392,16 +392,17 @@ struct fwohci_txpkthdr{
:13;
#endif
BIT16x2(len, );
}stream;
}mode;
} stream;
} mode;
};
struct fwohci_trailer{
struct fwohci_trailer {
#if BYTE_ORDER == BIG_ENDIAN
uint32_t stat:16,
time:16;
time:16;
#else
uint32_t time:16,
stat:16;
stat:16;
#endif
};
@ -412,7 +413,7 @@ struct fwohci_trailer{
#define OHCI_CNTL_SID (0x1 << 9)
/*
* defined in OHCI 1.1
* defined in OHCI 1.1
* chapter 6.1
*/
#define OHCI_INT_DMA_ATRQ (0x1 << 0)

View File

@ -44,7 +44,7 @@ typedef struct fwohci_softc {
void *ih;
struct resource *bsr;
struct resource *irq_res;
struct fwohci_dbch{
struct fwohci_dbch {
u_int ndb;
u_int ndesc;
STAILQ_HEAD(, fwohcidb_tr) db_trq;

View File

@ -97,7 +97,7 @@ struct ciphdr {
} fdf;
};
struct dvdbc{
struct dvdbc {
#if BYTE_ORDER == BIG_ENDIAN
uint8_t sct:3, /* Section type */
:1, /* Reserved */

View File

@ -1,7 +1,7 @@
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* $FreeBSD$
*/
@ -123,8 +123,8 @@ fwe_probe(device_t dev)
device_t pa;
pa = device_get_parent(dev);
if(device_get_unit(dev) != device_get_unit(pa)){
return(ENXIO);
if (device_get_unit(dev) != device_get_unit(pa)) {
return (ENXIO);
}
device_set_desc(dev, "Ethernet over FireWire");
@ -176,7 +176,7 @@ fwe_attach(device_t dev)
"%02x:%02x:%02x:%02x:%02x:%02x\n", unit,
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
/* fill the rest and attach interface */
/* fill the rest and attach interface */
ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
@ -220,12 +220,12 @@ fwe_stop(struct fwe_softc *fwe)
if (xferq->flag & FWXFERQ_RUNNING)
fc->irx_disable(fc, fwe->dma_ch);
xferq->flag &=
xferq->flag &=
~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM |
FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);
xferq->hand = NULL;
for (i = 0; i < xferq->bnchunk; i ++)
for (i = 0; i < xferq->bnchunk; i++)
m_freem(xferq->bulkxfer[i].mbuf);
free(xferq->bulkxfer, M_FWE);
@ -315,7 +315,7 @@ fwe_init(void *arg)
STAILQ_INIT(&xferq->stfree);
STAILQ_INIT(&xferq->stdma);
xferq->stproc = NULL;
for (i = 0; i < xferq->bnchunk; i ++) {
for (i = 0; i < xferq->bnchunk; i++) {
m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
xferq->bulkxfer[i].mbuf = m;
m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
@ -393,7 +393,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
!(ifp->if_capenable & IFCAP_POLLING)) {
error = ether_poll_register(fwe_poll, ifp);
if (error)
return(error);
return (error);
/* Disable interrupts */
fc->set_intr(fc, 0);
ifp->if_capenable |= IFCAP_POLLING;
@ -435,7 +435,6 @@ fwe_output_callback(struct fw_xfer *xfer)
FWEDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
m_freem(xfer->mbuf);
fw_xfer_unload(xfer);
@ -604,7 +603,7 @@ fwe_as_input(struct fw_xferq *xferq)
c[16], c[17], c[18], c[19],
c[20], c[21], c[22], c[23],
c[20], c[21], c[22], c[23]
);
);
#endif
(*ifp->if_input)(ifp, m);
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);

View File

@ -60,16 +60,10 @@
#include <net/firewire.h>
#include <net/if_arp.h>
#include <net/if_types.h>
#ifdef __DragonFly__
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
#include "if_fwipvar.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/iec13213.h>
#include <dev/firewire/if_fwipvar.h>
#endif
/*
* We really need a mechanism for allocating regions in the FIFO
@ -139,8 +133,8 @@ fwip_probe(device_t dev)
device_t pa;
pa = device_get_parent(dev);
if(device_get_unit(dev) != device_get_unit(pa)){
return(ENXIO);
if (device_get_unit(dev) != device_get_unit(pa)) {
return (ENXIO);
}
device_set_desc(dev, "IP over FireWire");
@ -228,7 +222,7 @@ fwip_stop(struct fwip_softc *fwip)
FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);
xferq->hand = NULL;
for (i = 0; i < xferq->bnchunk; i ++)
for (i = 0; i < xferq->bnchunk; i++)
m_freem(xferq->bulkxfer[i].mbuf);
free(xferq->bulkxfer, M_FWIP);
@ -322,7 +316,7 @@ fwip_init(void *arg)
STAILQ_INIT(&xferq->stfree);
STAILQ_INIT(&xferq->stdma);
xferq->stproc = NULL;
for (i = 0; i < xferq->bnchunk; i ++) {
for (i = 0; i < xferq->bnchunk; i++) {
m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
xferq->bulkxfer[i].mbuf = m;
m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
@ -335,7 +329,7 @@ fwip_init(void *arg)
/* pre-allocate xfer */
STAILQ_INIT(&fwip->fwb.xferlist);
for (i = 0; i < rx_queue_len; i ++) {
for (i = 0; i < rx_queue_len; i++) {
xfer = fw_xfer_alloc(M_FWIP);
if (xfer == NULL)
break;
@ -411,13 +405,12 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
!(ifp->if_capenable & IFCAP_POLLING)) {
error = ether_poll_register(fwip_poll, ifp);
if (error)
return(error);
return (error);
/* Disable interrupts */
fc->set_intr(fc, 0);
ifp->if_capenable |= IFCAP_POLLING |
IFCAP_POLLING_NOCOUNT;
return (error);
}
if (!(ifr->ifr_reqcap & IFCAP_POLLING) &&
ifp->if_capenable & IFCAP_POLLING) {
@ -485,7 +478,6 @@ fwip_output_callback(struct fw_xfer *xfer)
FWIPDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
m_freem(xfer->mbuf);
fw_xfer_unload(xfer);
@ -937,9 +929,6 @@ static driver_t fwip_driver = {
};
#ifdef __DragonFly__
DECLARE_DUMMY_MODULE(fwip);
#endif
DRIVER_MODULE(fwip, firewire, fwip_driver, fwip_devclass, 0, 0);
MODULE_VERSION(fwip, 1);
MODULE_DEPEND(fwip, firewire, 1, 1, 1);

View File

@ -30,7 +30,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* $FreeBSD$
*
*/
@ -75,16 +75,16 @@
#define SBP_QUEUE_LEN ((SBP_DMA_SIZE - SBP_LOGIN_SIZE) / sizeof(struct sbp_ocb))
#define SBP_NUM_OCB (SBP_QUEUE_LEN * SBP_NUM_TARGETS)
/*
/*
* STATUS FIFO addressing
* bit
* -----------------------
*-----------------------
* 0- 1( 2): 0 (alignment)
* 2- 7( 6): target
* 8-15( 8): lun
* 16-31( 8): reserved
* 32-47(16): SBP_BIND_HI
* 48-64(16): bus_id, node_id
* 32-47(16): SBP_BIND_HI
* 48-64(16): bus_id, node_id
*/
#define SBP_BIND_HI 0x1
#define SBP_DEV2ADDR(t, l) \
@ -154,7 +154,7 @@ struct sbp_ocb {
#define OCB_ACT_CMD 1
#define OCB_MATCH(o,s) ((o)->bus_addr == ntohl((s)->orb_lo))
struct sbp_dev{
struct sbp_dev {
#define SBP_DEV_RESET 0 /* accept login */
#define SBP_DEV_LOGIN 1 /* to login */
#if 0
@ -232,7 +232,7 @@ static void sbp_cmd_callback (struct fw_xfer *);
#endif
static void sbp_orb_pointer (struct sbp_dev *, struct sbp_ocb *);
static void sbp_doorbell(struct sbp_dev *);
static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int);
static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int);
static void sbp_free_ocb (struct sbp_dev *, struct sbp_ocb *);
static void sbp_abort_ocb (struct sbp_ocb *, int);
static void sbp_abort_all_ocbs (struct sbp_dev *, int);
@ -388,7 +388,7 @@ sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev)
/* XXX wired-down configuration should be gotten from
tunable or device hint */
for (i = 0; wired[i].bus >= 0; i ++) {
for (i = 0; wired[i].bus >= 0; i++) {
if (wired[i].bus == bus) {
w[wired[i].target] = 1;
if (wired[i].eui.hi == fwdev->eui.hi &&
@ -397,16 +397,16 @@ sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev)
}
}
if (target >= 0) {
if(target < SBP_NUM_TARGETS &&
if (target < SBP_NUM_TARGETS &&
sbp->targets[target].fwdev == NULL)
return(target);
return (target);
device_printf(sbp->fd.dev,
"target %d is not free for %08x:%08x\n",
"target %d is not free for %08x:%08x\n",
target, fwdev->eui.hi, fwdev->eui.lo);
target = -1;
}
/* non-wired target */
for (i = 0; i < SBP_NUM_TARGETS; i ++)
for (i = 0; i < SBP_NUM_TARGETS; i++)
if (sbp->targets[i].fwdev == NULL && w[i] == 0) {
target = i;
break;
@ -445,12 +445,12 @@ END_DEBUG
device_printf(target->sbp->fd.dev, "%d no LUN found\n",
target->target_id);
maxlun ++;
maxlun++;
if (maxlun >= SBP_NUM_LUNS)
maxlun = SBP_NUM_LUNS;
/* Invalidiate stale devices */
for (lun = 0; lun < target->num_lun; lun ++) {
for (lun = 0; lun < target->num_lun; lun++) {
sdev = target->luns[lun];
if (sdev == NULL)
continue;
@ -468,7 +468,7 @@ END_DEBUG
newluns = (struct sbp_dev **) realloc(target->luns,
sizeof(struct sbp_dev *) * maxlun,
M_SBP, M_NOWAIT | M_ZERO);
if (newluns == NULL) {
printf("%s: realloc failed\n", __func__);
newluns = target->luns;
@ -527,7 +527,7 @@ END_DEBUG
if (new == 0)
goto next;
fwdma_malloc(sbp->fd.fc,
fwdma_malloc(sbp->fd.fc,
/* alignment */ sizeof(uint32_t),
SBP_DMA_SIZE, &sdev->dma, BUS_DMA_NOWAIT |
BUS_DMA_COHERENT);
@ -542,7 +542,7 @@ END_DEBUG
sdev->ocb = (struct sbp_ocb *)
((char *)sdev->dma.v_addr + SBP_LOGIN_SIZE);
bzero((char *)sdev->ocb,
sizeof (struct sbp_ocb) * SBP_QUEUE_LEN);
sizeof(struct sbp_ocb) * SBP_QUEUE_LEN);
STAILQ_INIT(&sdev->free_ocbs);
for (i = 0; i < SBP_QUEUE_LEN; i++) {
@ -564,7 +564,7 @@ END_DEBUG
crom_next(&cc);
}
for (lun = 0; lun < target->num_lun; lun ++) {
for (lun = 0; lun < target->num_lun; lun++) {
sdev = target->luns[lun];
if (sdev != NULL && (sdev->flags & VALID_LUN) == 0) {
sbp_cam_detach_sdev(sdev);
@ -713,7 +713,7 @@ END_DEBUG
if (alive && (sdev->status != SBP_DEV_DEAD)) {
if (sdev->path != NULL) {
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
sdev->freeze++;
}
sbp_probe_lun(sdev);
sbp_show_sdev_info(sdev);
@ -743,7 +743,7 @@ SBP_DEBUG(0)
END_DEBUG
if (sdev->path) {
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
sdev->freeze++;
}
sdev->status = SBP_DEV_RETRY;
sbp_cam_detach_sdev(sdev);
@ -797,7 +797,7 @@ END_DEBUG
return;
if (sbp_cold > 0)
sbp_cold --;
sbp_cold--;
SBP_LOCK(sbp);
#if 0
@ -809,7 +809,7 @@ END_DEBUG
#endif
/* Garbage Collection */
for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){
for (i = 0; i < SBP_NUM_TARGETS; i++) {
target = &sbp->targets[i];
STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link)
if (target->fwdev == NULL || target->fwdev == fwdev)
@ -829,14 +829,14 @@ SBP_DEBUG(0)
fwdev->status);
END_DEBUG
alive = SBP_FWDEV_ALIVE(fwdev);
for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){
for (i = 0; i < SBP_NUM_TARGETS; i++) {
target = &sbp->targets[i];
if(target->fwdev == fwdev ) {
if (target->fwdev == fwdev) {
/* known target */
break;
}
}
if(i == SBP_NUM_TARGETS){
if (i == SBP_NUM_TARGETS) {
if (alive) {
/* new target */
target = sbp_alloc_target(sbp, fwdev);
@ -857,7 +857,8 @@ END_DEBUG
#if NEED_RESPONSE
static void
sbp_loginres_callback(struct fw_xfer *xfer){
sbp_loginres_callback(struct fw_xfer *xfer)
{
struct sbp_dev *sdev;
sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1)
@ -950,8 +951,8 @@ sbp_next_dev(struct sbp_target *target, int lun)
for (i = lun, sdevp = &target->luns[lun]; i < target->num_lun;
i++, sdevp++)
if (*sdevp != NULL && (*sdevp)->status == SBP_DEV_PROBE)
return(*sdevp);
return(NULL);
return (*sdevp);
return (NULL);
}
#define SCAN_PRI 1
@ -1147,7 +1148,7 @@ END_DEBUG
fp = &xfer->send.hdr;
fp->mode.wreqq.dest_hi = 0xffff;
fp->mode.wreqq.dest_lo = 0xf0000000 | BUSY_TIMEOUT;
fp->mode.wreqq.data = htonl((1 << (13+12)) | 0xf);
fp->mode.wreqq.data = htonl((1 << (13 + 12)) | 0xf);
fw_asyreq(xfer->fc, -1, xfer);
}
@ -1213,8 +1214,8 @@ END_DEBUG
fp = &xfer->send.hdr;
fp->mode.wreqb.len = 8;
fp->mode.wreqb.extcode = 0;
xfer->send.payload[0] =
htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS )<< 16));
xfer->send.payload[0] =
htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS) << 16));
xfer->send.payload[1] = htonl((uint32_t)ocb->bus_addr);
if (fw_asyreq(xfer->fc, -1, xfer) != 0) {
@ -1288,14 +1289,14 @@ sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
if (xfer == NULL) {
if (target->n_xfer > 5 /* XXX */) {
printf("sbp: no more xfer for this target\n");
return(NULL);
return (NULL);
}
xfer = fw_xfer_alloc_buf(M_SBP, 8, 0);
if(xfer == NULL){
if (xfer == NULL) {
printf("sbp: fw_xfer_alloc_buf failed\n");
return NULL;
}
target->n_xfer ++;
target->n_xfer++;
if (debug)
printf("sbp: alloc %d xfer\n", target->n_xfer);
new = 1;
@ -1362,7 +1363,7 @@ SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
"%s:%s %s\n",
__func__,sdev->bustgtlun,
orb_fun_name[(func>>16)&0xf]);
orb_fun_name[(func >> 16) & 0xf]);
END_DEBUG
switch (func) {
case ORB_FUN_LGI:
@ -1399,7 +1400,7 @@ END_DEBUG
callout_reset(&target->mgm_ocb_timeout, 5*hz,
sbp_mgm_timeout, (caddr_t)ocb);
xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0);
if(xfer == NULL){
if (xfer == NULL) {
return;
}
xfer->hand = sbp_mgm_callback;
@ -1470,25 +1471,25 @@ END_DEBUG
case SCSI_STATUS_CHECK_COND:
case SCSI_STATUS_BUSY:
case SCSI_STATUS_CMD_TERMINATED:
if(sbp_cmd_status->sfmt == SBP_SFMT_CURR){
if (sbp_cmd_status->sfmt == SBP_SFMT_CURR) {
sense->error_code = SSD_CURRENT_ERROR;
}else{
} else {
sense->error_code = SSD_DEFERRED_ERROR;
}
if(sbp_cmd_status->valid)
if (sbp_cmd_status->valid)
sense->error_code |= SSD_ERRCODE_VALID;
sense->flags = sbp_cmd_status->s_key;
if(sbp_cmd_status->mark)
if (sbp_cmd_status->mark)
sense->flags |= SSD_FILEMARK;
if(sbp_cmd_status->eom)
if (sbp_cmd_status->eom)
sense->flags |= SSD_EOM;
if(sbp_cmd_status->ill_len)
if (sbp_cmd_status->ill_len)
sense->flags |= SSD_ILI;
bcopy(&sbp_cmd_status->info, &sense->info[0], 4);
if (sbp_status->len <= 1)
/* XXX not scsi status. shouldn't be happened */
/* XXX not scsi status. shouldn't be happened */
sense->extra_len = 0;
else if (sbp_status->len <= 4)
/* add_sense_code(_qual), info, cmd_spec_info */
@ -1513,10 +1514,10 @@ END_DEBUG
{
uint8_t j, *tmp;
tmp = sense;
for( j = 0 ; j < 32 ; j+=8){
printf("sense %02x%02x %02x%02x %02x%02x %02x%02x\n",
tmp[j], tmp[j+1], tmp[j+2], tmp[j+3],
tmp[j+4], tmp[j+5], tmp[j+6], tmp[j+7]);
for (j = 0; j < 32; j += 8) {
printf("sense %02x%02x %02x%02x %02x%02x %02x%02x\n",
tmp[j], tmp[j + 1], tmp[j + 2], tmp[j + 3],
tmp[j + 4], tmp[j + 5], tmp[j + 6], tmp[j + 7]);
}
}
@ -1550,7 +1551,7 @@ END_DEBUG
switch (SID_TYPE(inq)) {
case T_DIRECT:
#if 0
/*
/*
* XXX Convert Direct Access device to RBC.
* I've never seen FireWire DA devices which support READ_6.
*/
@ -1566,7 +1567,7 @@ END_DEBUG
#if 1
bcopy(sdev->vendor, inq->vendor, sizeof(inq->vendor));
bcopy(sdev->product, inq->product, sizeof(inq->product));
bcopy(sdev->revision+2, inq->revision, sizeof(inq->revision));
bcopy(sdev->revision + 2, inq->revision, sizeof(inq->revision));
#endif
break;
}
@ -1606,16 +1607,16 @@ printf("sbp %08x %08x %08x %08x\n", ntohl(ld[8]), ntohl(ld[9]), ntohl(ld[10]), n
*/
sbp = (struct sbp_softc *)xfer->sc;
SBP_LOCK_ASSERT(sbp);
if (xfer->resp != 0){
if (xfer->resp != 0) {
printf("sbp_recv: xfer->resp = %d\n", xfer->resp);
goto done0;
}
if (xfer->recv.payload == NULL){
if (xfer->recv.payload == NULL) {
printf("sbp_recv: xfer->recv.payload == NULL\n");
goto done0;
}
rfp = &xfer->recv.hdr;
if(rfp->mode.wreqb.tcode != FWTCODE_WREQB){
if (rfp->mode.wreqb.tcode != FWTCODE_WREQB) {
printf("sbp_recv: tcode = %d\n", rfp->mode.wreqb.tcode);
goto done0;
}
@ -1677,7 +1678,7 @@ END_DEBUG
&& sbp_status->dead == 0);
status_valid = (status_valid0 && sbp_status->status == 0);
if (!status_valid0 || debug > 2){
if (!status_valid0 || debug > 2) {
int status;
SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
@ -1691,7 +1692,7 @@ END_DEBUG
device_printf(sdev->target->sbp->fd.dev,
"%s\n", sdev->bustgtlun);
status = sbp_status->status;
switch(sbp_status->resp) {
switch (sbp_status->resp) {
case 0:
if (status > MAX_ORB_STATUS0)
printf("%s\n", orb_status0[MAX_ORB_STATUS0]);
@ -1700,7 +1701,7 @@ END_DEBUG
break;
case 1:
printf("Obj: %s, Error: %s\n",
orb_status1_object[(status>>6) & 3],
orb_status1_object[(status >> 6) & 3],
orb_status1_serial_bus_error[status & 0xf]);
break;
case 2:
@ -1718,7 +1719,7 @@ END_DEBUG
if (sbp_status->dead) {
if (sdev->path) {
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
sdev->freeze++;
}
reset_agent = 1;
}
@ -1726,17 +1727,17 @@ END_DEBUG
if (ocb == NULL)
goto done;
switch(ntohl(ocb->orb[4]) & ORB_FMT_MSK){
switch (ntohl(ocb->orb[4]) & ORB_FMT_MSK) {
case ORB_FMT_NOP:
break;
case ORB_FMT_VED:
break;
case ORB_FMT_STD:
switch(ocb->flags) {
switch (ocb->flags) {
case OCB_ACT_MGM:
orb_fun = ntohl(ocb->orb[4]) & ORB_FUN_MSK;
reset_agent = 0;
switch(orb_fun) {
switch (orb_fun) {
case ORB_FUN_LGI:
fwdma_sync(&sdev->dma, BUS_DMASYNC_POSTREAD);
login_res = sdev->login;
@ -1807,16 +1808,16 @@ END_DEBUG
break;
case OCB_ACT_CMD:
sdev->timeout = 0;
if(ocb->ccb != NULL){
if (ocb->ccb != NULL) {
union ccb *ccb;
ccb = ocb->ccb;
if(sbp_status->len > 1){
if (sbp_status->len > 1) {
sbp_scsi_status(sbp_status, ocb);
}else{
if(sbp_status->resp != ORB_RES_CMPL){
} else {
if (sbp_status->resp != ORB_RES_CMPL) {
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
}else{
} else {
ccb->ccb_h.status = CAM_REQ_CMP;
}
}
@ -1843,7 +1844,7 @@ END_DEBUG
* the buffer. In that case, the controller return ack_complete and
* no respose is necessary.
*
* XXX fwohci.c and firewire.c should inform event_code such as
* XXX fwohci.c and firewire.c should inform event_code such as
* ack_complete or ack_pending to upper driver.
*/
#if NEED_RESPONSE
@ -1900,7 +1901,7 @@ SBP_DEBUG(0)
END_DEBUG
if (cold)
sbp_cold ++;
sbp_cold++;
sbp = device_get_softc(dev);
sbp->fd.dev = dev;
sbp->fd.fc = fc = device_get_ivars(dev);
@ -1932,7 +1933,7 @@ END_DEBUG
if (devq == NULL)
return (ENXIO);
for( i = 0 ; i < SBP_NUM_TARGETS ; i++){
for (i = 0; i < SBP_NUM_TARGETS; i++) {
sbp->targets[i].fwdev = NULL;
sbp->targets[i].luns = NULL;
sbp->targets[i].sbp = sbp;
@ -2001,7 +2002,7 @@ SBP_DEBUG(0)
printf("sbp_logout_all\n");
END_DEBUG
SBP_LOCK_ASSERT(sbp);
for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) {
for (i = 0; i < SBP_NUM_TARGETS; i++) {
target = &sbp->targets[i];
if (target->luns == NULL)
continue;
@ -2090,7 +2091,7 @@ SBP_DEBUG(0)
END_DEBUG
SBP_LOCK(sbp);
for (i = 0; i < SBP_NUM_TARGETS; i ++)
for (i = 0; i < SBP_NUM_TARGETS; i++)
sbp_cam_detach_target(&sbp->targets[i]);
xpt_async(AC_LOST_DEVICE, sbp->path, NULL);
@ -2105,7 +2106,7 @@ END_DEBUG
pause("sbpdtc", hz/2);
SBP_LOCK(sbp);
for (i = 0 ; i < SBP_NUM_TARGETS ; i ++)
for (i = 0; i < SBP_NUM_TARGETS; i++)
sbp_free_target(&sbp->targets[i]);
SBP_UNLOCK(sbp);
@ -2172,12 +2173,12 @@ sbp_target_reset(struct sbp_dev *sdev, int method)
if (tsdev->status == SBP_DEV_RESET)
continue;
xpt_freeze_devq(tsdev->path, 1);
tsdev->freeze ++;
tsdev->freeze++;
sbp_abort_all_ocbs(tsdev, CAM_CMD_TIMEOUT);
if (method == 2)
tsdev->status = SBP_DEV_LOGIN;
}
switch(method) {
switch (method) {
case 1:
printf("target reset\n");
sbp_mgm_orb(sdev, ORB_FUN_RST, NULL);
@ -2187,7 +2188,7 @@ sbp_target_reset(struct sbp_dev *sdev, int method)
sbp_reset_start(sdev);
break;
}
}
static void
@ -2225,12 +2226,12 @@ sbp_timeout(void *arg)
__func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
SBP_LOCK_ASSERT(sdev->target->sbp);
sdev->timeout ++;
switch(sdev->timeout) {
sdev->timeout++;
switch (sdev->timeout) {
case 1:
printf("agent reset\n");
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
sdev->freeze++;
sbp_abort_all_ocbs(sdev, CAM_CMD_TIMEOUT);
sbp_agent_reset(sdev);
break;
@ -2309,7 +2310,7 @@ END_DEBUG
* sometimes aimed at the SIM (sc is invalid and target is
* CAM_TARGET_WILDCARD)
*/
if (sbp == NULL &&
if (sbp == NULL &&
ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
SBP_DEBUG(0)
printf("%s:%d:%jx func_code 0x%04x: "
@ -2361,7 +2362,7 @@ SBP_DEBUG(2)
csio->cdb_len, csio->dxfer_len,
csio->sense_len);
END_DEBUG
if(sdev == NULL){
if (sdev == NULL) {
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
xpt_done(ccb);
return;
@ -2383,7 +2384,7 @@ END_DEBUG
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
if (sdev->freeze == 0) {
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
sdev->freeze++;
}
xpt_done(ccb);
return;
@ -2395,12 +2396,12 @@ END_DEBUG
ccb->ccb_h.ccb_sdev_ptr = sdev;
ocb->orb[0] = htonl(1U << 31);
ocb->orb[1] = 0;
ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS )<< 16) );
ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS) << 16));
ocb->orb[3] = htonl(ocb->bus_addr + IND_PTR_OFFSET);
speed = min(target->fwdev->speed, max_speed);
ocb->orb[4] = htonl(ORB_NOTIFY | ORB_CMD_SPD(speed)
| ORB_CMD_MAXP(speed + 7));
if((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN){
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
ocb->orb[4] |= htonl(ORB_CMD_IN);
}
@ -2467,7 +2468,7 @@ END_DEBUG
case XPT_PATH_INQ: /* Path routing inquiry */
{
struct ccb_pathinq *cpi = &ccb->cpi;
SBP_DEBUG(1)
printf("%s:%d:%jx XPT_PATH_INQ:.\n",
device_get_nameunit(sbp->fd.dev),
@ -2536,7 +2537,7 @@ END_DEBUG
}
static void
sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error)
sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error)
{
int i;
struct sbp_ocb *ocb;
@ -2563,7 +2564,7 @@ END_DEBUG
panic("ds_len > SBP_SEG_MAX, fix busdma code");
ocb->orb[3] = htonl(s->ds_addr);
ocb->orb[4] |= htonl(s->ds_len);
} else if(seg > 1) {
} else if (seg > 1) {
/* page table */
for (i = 0; i < seg; i++) {
s = &segments[i];
@ -2572,7 +2573,7 @@ SBP_DEBUG(0)
if (s->ds_len < 16)
printf("sbp_execute_ocb: warning, "
"segment length(%zd) is less than 16."
"(seg=%d/%d)\n", (size_t)s->ds_len, i+1, seg);
"(seg=%d/%d)\n", (size_t)s->ds_len, i + 1, seg);
END_DEBUG
if (s->ds_len > SBP_SEG_MAX)
panic("ds_len > SBP_SEG_MAX, fix busdma code");
@ -2581,7 +2582,7 @@ END_DEBUG
}
ocb->orb[4] |= htonl(ORB_CMD_PTBL | seg);
}
if (seg > 0)
bus_dmamap_sync(ocb->sdev->target->sbp->dmat, ocb->dmamap,
(ntohl(ocb->orb[4]) & ORB_CMD_IN) ?
@ -2593,19 +2594,19 @@ END_DEBUG
if (ocb->sdev->last_ocb != NULL)
sbp_doorbell(ocb->sdev);
else
sbp_orb_pointer(ocb->sdev, ocb);
sbp_orb_pointer(ocb->sdev, ocb);
}
} else {
if (prev == NULL || (ocb->sdev->flags & ORB_LINK_DEAD) != 0) {
ocb->sdev->flags &= ~ORB_LINK_DEAD;
sbp_orb_pointer(ocb->sdev, ocb);
sbp_orb_pointer(ocb->sdev, ocb);
}
}
}
static void
sbp_poll(struct cam_sim *sim)
{
{
struct sbp_softc *sbp;
struct firewire_comm *fc;
@ -2648,7 +2649,7 @@ END_DEBUG
if (!use_doorbell) {
if (sbp_status->src == SRC_NO_NEXT) {
if (next != NULL)
sbp_orb_pointer(sdev, next);
sbp_orb_pointer(sdev, next);
else if (order > 0) {
/*
* Unordered execution
@ -2661,7 +2662,7 @@ END_DEBUG
} else {
/*
* XXX this is not correct for unordered
* execution.
* execution.
*/
if (sdev->last_ocb != NULL) {
sbp_free_ocb(sdev, sdev->last_ocb);
@ -2673,7 +2674,7 @@ END_DEBUG
}
break;
} else
order ++;
order++;
}
SBP_DEBUG(0)
if (ocb && order > 0) {

View File

@ -76,7 +76,7 @@ struct ind_ptr {
#define SBP_RECV_LEN 32
struct sbp_login_res{
struct sbp_login_res {
uint16_t len;
uint16_t id;
uint16_t res0;
@ -86,7 +86,7 @@ struct sbp_login_res{
uint16_t recon_hold;
};
struct sbp_status{
struct sbp_status {
#if BYTE_ORDER == BIG_ENDIAN
uint8_t src:2,
resp:2,
@ -155,7 +155,7 @@ struct sbp_status{
/* F: Address error */
struct sbp_cmd_status{
struct sbp_cmd_status {
#define SBP_SFMT_CURR 0
#define SBP_SFMT_DEFER 1
#if BYTE_ORDER == BIG_ENDIAN

View File

@ -1,7 +1,7 @@
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* $FreeBSD$
*/
@ -104,16 +104,16 @@ struct sbp_targ_login {
struct sbp_targ_lstate *lstate;
struct fw_device *fwdev;
struct sbp_login_res loginres;
uint16_t fifo_hi;
uint16_t fifo_hi;
uint16_t last_hi;
uint32_t fifo_lo;
uint32_t fifo_lo;
uint32_t last_lo;
STAILQ_HEAD(, orb_info) orbs;
STAILQ_ENTRY(sbp_targ_login) link;
uint16_t hold_sec;
uint16_t id;
uint8_t flags;
uint8_t spd;
uint8_t flags;
uint8_t spd;
struct callout hold_callout;
};
@ -124,7 +124,7 @@ struct sbp_targ_lstate {
struct ccb_hdr_slist accept_tios;
struct ccb_hdr_slist immed_notifies;
struct crom_chunk model;
uint32_t flags;
uint32_t flags;
STAILQ_HEAD(, sbp_targ_login) logins;
};
@ -205,7 +205,7 @@ struct orb_info {
struct sbp_targ_login *login;
union ccb *ccb;
struct ccb_accept_tio *atio;
uint8_t state;
uint8_t state;
#define ORBI_STATUS_NONE 0
#define ORBI_STATUS_FETCH 1
#define ORBI_STATUS_ATIO 2
@ -213,7 +213,7 @@ struct orb_info {
#define ORBI_STATUS_STATUS 4
#define ORBI_STATUS_POINTER 5
#define ORBI_STATUS_ABORTED 7
uint8_t refcount;
uint8_t refcount;
uint16_t orb_hi;
uint32_t orb_lo;
uint32_t data_hi;
@ -250,8 +250,8 @@ sbp_targ_probe(device_t dev)
device_t pa;
pa = device_get_parent(dev);
if(device_get_unit(dev) != device_get_unit(pa)){
return(ENXIO);
if (device_get_unit(dev) != device_get_unit(pa)) {
return (ENXIO);
}
device_set_desc(dev, "SBP-2/SCSI over FireWire target mode");
@ -336,7 +336,7 @@ sbp_targ_post_busreset(void *arg)
crom_add_entry(unit, CROM_MGM, SBP_TARG_MGM >> 2);
crom_add_entry(unit, CSRKEY_UNIT_CH, (10<<8) | 8);
for (i = 0; i < MAX_LUN; i ++) {
for (i = 0; i < MAX_LUN; i++) {
lstate = sc->lstate[i];
if (lstate == NULL)
continue;
@ -347,7 +347,7 @@ sbp_targ_post_busreset(void *arg)
}
/* Process for reconnection hold time */
for (i = 0; i < MAX_LOGINS; i ++) {
for (i = 0; i < MAX_LOGINS; i++) {
login = sc->logins[i];
if (login == NULL)
continue;
@ -355,7 +355,7 @@ sbp_targ_post_busreset(void *arg)
if (login->flags & F_LOGIN) {
login->flags |= F_HOLD;
callout_reset(&login->hold_callout,
hz * login->hold_sec,
hz * login->hold_sec,
sbp_targ_hold_expire, (void *)login);
}
}
@ -392,7 +392,7 @@ sbp_targ_find_devs(struct sbp_targ_softc *sc, union ccb *ccb,
lun = ccb->ccb_h.target_lun;
if (lun >= MAX_LUN)
return (CAM_LUN_INVALID);
*lstate = sc->lstate[lun];
if (notfound_failure != 0 && *lstate == NULL) {
@ -840,7 +840,7 @@ sbp_targ_cam_done(struct fw_xfer *xfer)
sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link));
}
orbi->refcount --;
orbi->refcount--;
ccb = orbi->ccb;
if (orbi->refcount == 0) {
@ -916,7 +916,7 @@ sbp_targ_abort_ccb(struct sbp_targ_softc *sc, union ccb *ccb)
found = 1;
SLIST_REMOVE_HEAD(list, sim_links.sle);
} else {
while(curelm != NULL) {
while (curelm != NULL) {
struct ccb_hdr *nextelm;
nextelm = SLIST_NEXT(curelm, sim_links.sle);
@ -982,7 +982,7 @@ sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset,
if (xfer == NULL) {
printf("%s: xfer == NULL", __func__);
/* XXX what should we do?? */
orbi->refcount --;
orbi->refcount--;
}
off += len;
}
@ -1354,7 +1354,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
ccb->ccb_h.status = CAM_UA_ABORT;
break;
default:
printf("%s: aborting unknown function %d\n",
printf("%s: aborting unknown function %d\n",
__func__, accb->ccb_h.func_code);
ccb->ccb_h.status = CAM_REQ_INVALID;
break;
@ -1464,7 +1464,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
orb = orbi->orb;
/* swap payload except SCSI command */
for (i = 0; i < 5; i ++)
for (i = 0; i < 5; i++)
orb[i] = ntohl(orb[i]);
orb4 = (struct corb4 *)&orb[4];
@ -1545,12 +1545,12 @@ sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun)
int i;
lstate = sc->lstate[lun];
STAILQ_FOREACH(login, &lstate->logins, link)
if (login->fwdev == fwdev)
return (login);
for (i = 0; i < MAX_LOGINS; i ++)
for (i = 0; i < MAX_LOGINS; i++)
if (sc->logins[i] == NULL)
goto found;
@ -1607,7 +1607,7 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
orb = orbi->orb;
/* swap payload */
for (i = 0; i < 8; i ++) {
for (i = 0; i < 8; i++) {
orb[i] = ntohl(orb[i]);
}
orb4 = (struct morb4 *)&orb[4];
@ -1628,10 +1628,10 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
lstate = orbi->sc->lstate[lun];
if (lun >= MAX_LUN || lstate == NULL ||
(exclusive &&
(exclusive &&
STAILQ_FIRST(&lstate->logins) != NULL &&
STAILQ_FIRST(&lstate->logins)->fwdev != orbi->fwdev)
) {
) {
/* error */
orbi->status.dead = 1;
orbi->status.status = STATUS_ACCESS_DENY;
@ -1819,16 +1819,16 @@ sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id,
int rtcode = 0;
if (login_id < 0 || login_id >= MAX_LOGINS)
return(RESP_ADDRESS_ERROR);
return (RESP_ADDRESS_ERROR);
sc = (struct sbp_targ_softc *)xfer->sc;
login = sc->logins[login_id];
if (login == NULL)
return(RESP_ADDRESS_ERROR);
return (RESP_ADDRESS_ERROR);
if (login->fwdev != fwdev) {
/* XXX */
return(RESP_ADDRESS_ERROR);
return (RESP_ADDRESS_ERROR);
}
switch (reg) {
@ -1895,17 +1895,17 @@ sbp_targ_mgm(struct fw_xfer *xfer, struct fw_device *fwdev)
sc = (struct sbp_targ_softc *)xfer->sc;
fp = &xfer->recv.hdr;
if (fp->mode.wreqb.tcode != FWTCODE_WREQB){
if (fp->mode.wreqb.tcode != FWTCODE_WREQB) {
printf("%s: tcode = %d\n", __func__, fp->mode.wreqb.tcode);
return(RESP_TYPE_ERROR);
return (RESP_TYPE_ERROR);
}
sbp_targ_fetch_orb(sc, fwdev,
ntohl(xfer->recv.payload[0]),
ntohl(xfer->recv.payload[1]),
NULL, FETCH_MGM);
return(0);
return (0);
}
static void
@ -2023,9 +2023,9 @@ sbp_targ_detach(device_t dev)
xpt_free_path(sc->path);
xpt_bus_deregister(cam_sim_path(sc->sim));
SBP_UNLOCK(sc);
cam_sim_free(sc->sim, /*free_devq*/TRUE);
cam_sim_free(sc->sim, /*free_devq*/TRUE);
for (i = 0; i < MAX_LUN; i ++) {
for (i = 0; i < MAX_LUN; i++) {
lstate = sc->lstate[i];
if (lstate != NULL) {
xpt_free_path(lstate->path);
@ -2036,7 +2036,7 @@ sbp_targ_detach(device_t dev)
xpt_free_path(sc->black_hole->path);
free(sc->black_hole, M_SBP_TARG);
}
fw_bindremove(sc->fd.fc, &sc->fwb);
fw_xferlist_remove(&sc->fwb.xferlist);