diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c index 0f8cab34b476..85e14ccd8fc8 100644 --- a/sys/dev/scsipi/cd.c +++ b/sys/dev/scsipi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.83 1996/03/17 00:59:41 thorpej Exp $ */ +/* $NetBSD: cd.c,v 1.84 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -553,9 +553,7 @@ cdstart(v) bzero(&cmd_small, sizeof(cmd_small)); cmd_small.opcode = (bp->b_flags & B_READ) ? READ_COMMAND : WRITE_COMMAND; - cmd_small.addr_2 = (blkno >> 16) & 0x1f; - cmd_small.addr_1 = (blkno >> 8) & 0xff; - cmd_small.addr_0 = blkno & 0xff; + _lto3b(blkno, cmd_small.addr); cmd_small.length = nblks & 0xff; cmdlen = sizeof(cmd_small); cmdp = (struct scsi_generic *)&cmd_small; @@ -566,12 +564,8 @@ cdstart(v) bzero(&cmd_big, sizeof(cmd_big)); cmd_big.opcode = (bp->b_flags & B_READ) ? READ_BIG : WRITE_BIG; - cmd_big.addr_3 = (blkno >> 24) & 0xff; - cmd_big.addr_2 = (blkno >> 16) & 0xff; - cmd_big.addr_1 = (blkno >> 8) & 0xff; - cmd_big.addr_0 = blkno & 0xff; - cmd_big.length2 = (nblks >> 8) & 0xff; - cmd_big.length1 = nblks & 0xff; + _lto4b(blkno, cmd_big.addr); + _lto2b(nblks, cmd_big.length); cmdlen = sizeof(cmd_big); cmdp = (struct scsi_generic *)&cmd_big; } @@ -734,9 +728,8 @@ cdioctl(dev, cmd, addr, flag, p) &data, len); if (error) return error; - len = min(len, ((data.header.data_len[0] << 8) + - data.header.data_len[1] + - sizeof(struct cd_sub_channel_header))); + len = min(len, _2btol(data.header.data_len) + + sizeof(struct cd_sub_channel_header)); return copyout(&data, args->data, len); } case CDIOREADTOCHEADER: { @@ -972,14 +965,12 @@ cd_size(cd, flags) 2000, NULL, flags | SCSI_DATA_IN) != 0) return 0; - blksize = (rdcap.length_3 << 24) + (rdcap.length_2 << 16) + - (rdcap.length_1 << 8) + rdcap.length_0; + blksize = _4btol(rdcap.length); if (blksize < 512) blksize = 2048; /* some drives lie ! */ cd->params.blksize = blksize; - size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) + - (rdcap.addr_1 << 8) + rdcap.addr_0 + 1; + size = _4btol(rdcap.addr) + 1; if (size < 100) size = 400000; /* ditto */ cd->params.disksize = size; @@ -1040,12 +1031,8 @@ cd_play(cd, blkno, nblks) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = PLAY; - scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff; - scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff; - scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff; - scsi_cmd.blk_addr[3] = blkno & 0xff; - scsi_cmd.xfer_len[0] = (nblks >> 8) & 0xff; - scsi_cmd.xfer_len[1] = nblks & 0xff; + _lto4b(blkno, scsi_cmd.blk_addr); + _lto2b(nblks, scsi_cmd.xfer_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), 0, 0, CDRETRIES, 200000, NULL, 0); } @@ -1062,14 +1049,8 @@ cd_play_big(cd, blkno, nblks) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = PLAY_BIG; - scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff; - scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff; - scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff; - scsi_cmd.blk_addr[3] = blkno & 0xff; - scsi_cmd.xfer_len[0] = (nblks >> 24) & 0xff; - scsi_cmd.xfer_len[1] = (nblks >> 16) & 0xff; - scsi_cmd.xfer_len[2] = (nblks >> 8) & 0xff; - scsi_cmd.xfer_len[3] = nblks & 0xff; + _lto4b(blkno, scsi_cmd.blk_addr); + _lto4b(nblks, scsi_cmd.xfer_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), 0, 0, CDRETRIES, 20000, NULL, 0); } @@ -1163,8 +1144,7 @@ cd_read_subchannel(cd, mode, format, track, data, len) scsi_cmd.byte3 = SRS_SUBQ; scsi_cmd.subchan_format = format; scsi_cmd.track = track; - scsi_cmd.data_len[0] = (len >> 8) & 0xff; - scsi_cmd.data_len[1] = len & 0xff; + _lto2b(len, scsi_cmd.data_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(struct scsi_read_subchannel), (u_char *)data, len, CDRETRIES, 5000, NULL, SCSI_DATA_IN); @@ -1191,8 +1171,7 @@ cd_read_toc(cd, mode, start, data, len) if (mode == CD_MSF_FORMAT) scsi_cmd.byte2 |= CD_MSF; scsi_cmd.from_track = start; - scsi_cmd.data_len[0] = (ntoc >> 8) & 0xff; - scsi_cmd.data_len[1] = ntoc & 0xff; + _lto2b(ntoc, scsi_cmd.data_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(struct scsi_read_toc), (u_char *)data, len, CDRETRIES, 5000, NULL, SCSI_DATA_IN); diff --git a/sys/dev/scsipi/ch.c b/sys/dev/scsipi/ch.c index 125a4e918674..e1644af55edf 100644 --- a/sys/dev/scsipi/ch.c +++ b/sys/dev/scsipi/ch.c @@ -1,4 +1,4 @@ -/* $NetBSD: ch.c,v 1.17 1996/03/17 00:59:44 thorpej Exp $ */ +/* $NetBSD: ch.c,v 1.18 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -312,8 +312,7 @@ ch_getelem(ch, stat, type, from, data, flags) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = READ_ELEMENT_STATUS; scsi_cmd.byte2 = type; - scsi_cmd.starting_element_addr[0] = (from >> 8) & 0xff; - scsi_cmd.starting_element_addr[1] = from & 0xff; + _lto2b(from, scsi_cmd.starting_element_addr); scsi_cmd.number_of_elements[1] = 1; scsi_cmd.allocation_length[2] = 32; @@ -339,12 +338,9 @@ ch_move(ch, stat, chm, from, to, flags) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = MOVE_MEDIUM; - scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff; - scsi_cmd.transport_element_address[1] = chm & 0xff; - scsi_cmd.source_address[0] = (from >> 8) & 0xff; - scsi_cmd.source_address[1] = from & 0xff; - scsi_cmd.destination_address[0] = (to >> 8) & 0xff; - scsi_cmd.destination_address[1] = to & 0xff; + _lto2b(chm, scsi_cmd.transport_element_address); + _lto2b(from, scsi_cmd.source_address); + _lto2b(to, scsi_cmd.destination_address); scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0; error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd, sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags); @@ -366,10 +362,8 @@ ch_position(ch, stat, chm, to, flags) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = POSITION_TO_ELEMENT; - scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff; - scsi_cmd.transport_element_address[1] = chm & 0xff; - scsi_cmd.source_address[0] = (to >> 8) & 0xff; - scsi_cmd.source_address[1] = to & 0xff; + _lto2b(chm, scsi_cmd.transport_element_address); + _lto2b(to, scsi_cmd.source_address); scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0; error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd, sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags); diff --git a/sys/dev/scsipi/scsi_all.h b/sys/dev/scsipi/scsi_all.h index 646826c872b4..81eeb7d9bd52 100644 --- a/sys/dev/scsipi/scsi_all.h +++ b/sys/dev/scsipi/scsi_all.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_all.h,v 1.6 1994/12/28 19:42:54 mycroft Exp $ */ +/* $NetBSD: scsi_all.h,v 1.7 1996/03/19 03:05:15 mycroft Exp $ */ /* * SCSI general interface description @@ -229,58 +229,33 @@ struct scsi_inquiry_data { u_int8_t extra[8]; }; -/* - * This looks bad, and it is. However it fixes padding problems - * caused by using unions. This *needs* to be an array, if this code - * is to work on any architecture. - */ -struct scsi_sense_data { -/* 1*/ u_int8_t error_code; /* same bits as new version */ -#define XXX_unextended_blockhi extended_segment -#define XXX_unextended_blockmed extended_flags -#define XXX_unextended_blocklow extended_info[0] -/* 2*/ u_int8_t extended_segment; -/* 3*/ u_int8_t extended_flags; /* same bits as new version */ -/* 7*/ u_int8_t extended_info[4]; -/* 8*/ u_int8_t extended_extra_len; - /* - * allocate enough room to hold new stuff - * (by increasing 16 to 24 below) - */ -/*32*/ u_int8_t extended_extra_bytes[24]; -}; /* total of 32 bytes */ +struct scsi_sense_data_unextended { +/* 1*/ u_int8_t error_code; +/* 4*/ u_int8_t block[3]; +}; -struct scsi_sense_data_new { +struct scsi_sense_data { /* 1*/ u_int8_t error_code; #define SSD_ERRCODE 0x7F #define SSD_ERRCODE_VALID 0x80 - union { - struct { /* this is deprecated, the standard says "DON'T"*/ -/* 2*/ u_int8_t blockhi; -/* 3*/ u_int8_t blockmed; -/* 4*/ u_int8_t blocklow; - } unextended; - struct { -/* 2*/ u_int8_t segment; -/* 3*/ u_int8_t flags; +/* 2*/ u_int8_t segment; +/* 3*/ u_int8_t flags; #define SSD_KEY 0x0F #define SSD_ILI 0x20 #define SSD_EOM 0x40 #define SSD_FILEMARK 0x80 -/* 7*/ u_int8_t info[4]; -/* 8*/ u_int8_t extra_len; -/*12*/ u_int8_t cmd_spec_info[4]; -/*13*/ u_int8_t add_sense_code; -/*14*/ u_int8_t add_sense_code_qual; -/*15*/ u_int8_t fru; -/*16*/ u_int8_t sense_key_spec_1; -#define SSD_SCS_VALID 0x80 -/*17*/ u_int8_t sense_key_spec_2; -/*18*/ u_int8_t sense_key_spec_3; -/*32*/ u_int8_t extra_bytes[14]; - } extended; - } ext; -}; /* total of 32 bytes */ +/* 7*/ u_int8_t info[4]; +/* 8*/ u_int8_t extra_len; +/*12*/ u_int8_t cmd_spec_info[4]; +/*13*/ u_int8_t add_sense_code; +/*14*/ u_int8_t add_sense_code_qual; +/*15*/ u_int8_t fru; +/*16*/ u_int8_t sense_key_spec_1; +#define SSD_SCS_VALID 0x80 +/*17*/ u_int8_t sense_key_spec_2; +/*18*/ u_int8_t sense_key_spec_3; +/*32*/ u_int8_t extra_bytes[14]; +}; struct scsi_blk_desc { u_int8_t density; diff --git a/sys/dev/scsipi/scsi_base.c b/sys/dev/scsipi/scsi_base.c index b33da12ccb89..0b6ef6ef063e 100644 --- a/sys/dev/scsipi/scsi_base.c +++ b/sys/dev/scsipi/scsi_base.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_base.c,v 1.33 1996/02/14 21:47:14 christos Exp $ */ +/* $NetBSD: scsi_base.c,v 1.34 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles Hannum. All rights reserved. @@ -194,7 +194,6 @@ scsi_size(sc_link, flags) { struct scsi_read_cap_data rdcap; struct scsi_read_capacity scsi_cmd; - u_long size; /* * make up a scsi command and ask the scsi driver to do @@ -213,13 +212,9 @@ scsi_size(sc_link, flags) sc_print_addr(sc_link); printf("could not get size\n"); return 0; - } else { - size = rdcap.addr_0 + 1; - size += rdcap.addr_1 << 8; - size += rdcap.addr_2 << 16; - size += rdcap.addr_3 << 24; } - return size; + + return _4btol(rdcap.addr) + 1; } /* @@ -625,20 +620,20 @@ scsi_interpret_sense(xs) sense->error_code & SSD_ERRCODE, sense->error_code & SSD_ERRCODE_VALID ? 1 : 0); printf("seg%x key%x ili%x eom%x fmark%x\n", - sense->extended_segment, - sense->extended_flags & SSD_KEY, - sense->extended_flags & SSD_ILI ? 1 : 0, - sense->extended_flags & SSD_EOM ? 1 : 0, - sense->extended_flags & SSD_FILEMARK ? 1 : 0); + sense->segment, + sense->flags & SSD_KEY, + sense->flags & SSD_ILI ? 1 : 0, + sense->flags & SSD_EOM ? 1 : 0, + sense->flags & SSD_FILEMARK ? 1 : 0); printf("info: %x %x %x %x followed by %d extra bytes\n", - sense->extended_info[0], - sense->extended_info[1], - sense->extended_info[2], - sense->extended_info[3], - sense->extended_extra_len); + sense->info[0], + sense->info[1], + sense->info[2], + sense->info[3], + sense->extra_len); printf("extra: "); - for (count = 0; count < sense->extended_extra_len; count++) - printf("%x ", sense->extended_extra_bytes[count]); + for (count = 0; count < sense->extra_len; count++) + printf("%x ", sense->extra_bytes[count]); printf("\n"); } #endif /*SCSIDEBUG */ @@ -660,15 +655,14 @@ scsi_interpret_sense(xs) */ case 0x71: /* delayed error */ sc_print_addr(sc_link); - key = sense->extended_flags & SSD_KEY; + key = sense->flags & SSD_KEY; printf(" DELAYED ERROR, key = 0x%x\n", key); case 0x70: - if ((sense->error_code & SSD_ERRCODE_VALID) != 0) { - bcopy(sense->extended_info, &info, sizeof info); - info = ntohl(info); - } else + if ((sense->error_code & SSD_ERRCODE_VALID) != 0) + info = _4btol(sense->info); + else info = 0; - key = sense->extended_flags & SSD_KEY; + key = sense->flags & SSD_KEY; switch (key) { case 0x0: /* NO SENSE */ @@ -744,11 +738,11 @@ scsi_interpret_sense(xs) printf(", info = %d (decimal)", info); } } - if (sense->extended_extra_len != 0) { + if (sense->extra_len != 0) { int n; printf(", data ="); - for (n = 0; n < sense->extended_extra_len; n++) - printf(" %02x", sense->extended_extra_bytes[n]); + for (n = 0; n < sense->extra_len; n++) + printf(" %02x", sense->extra_bytes[n]); } printf("\n"); } @@ -762,10 +756,10 @@ scsi_interpret_sense(xs) printf("error code %d", sense->error_code & SSD_ERRCODE); if ((sense->error_code & SSD_ERRCODE_VALID) != 0) { + struct scsi_sense_data_unextended *usense = + (struct scsi_sense_data_unextended *)sense; printf(" at block no. %d (decimal)", - (sense->XXX_unextended_blockhi << 16) + - (sense->XXX_unextended_blockmed << 8) + - (sense->XXX_unextended_blocklow)); + _3btol(usense->block)); } printf("\n"); return EIO; @@ -776,36 +770,6 @@ scsi_interpret_sense(xs) * Utility routines often used in SCSI stuff */ -/* - * convert a physical address to 3 bytes, - * MSB at the lowest address, - * LSB at the highest. - */ -void -lto3b(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - *bytes++ = (val >> 16) & 0xff; - *bytes++ = (val >> 8) & 0xff; - *bytes = val & 0xff; -} - -/* - * The reverse of lto3b - */ -u_int32_t -_3btol(bytes) - u_int8_t *bytes; -{ - u_int32_t rc; - - rc = (*bytes++ << 16); - rc += (*bytes++ << 8); - rc += *bytes; - return (rc); -} /* * Print out the scsi_link structure's address info. diff --git a/sys/dev/scsipi/scsi_cd.h b/sys/dev/scsipi/scsi_cd.h index bbd15676e981..526ef5eaae7f 100644 --- a/sys/dev/scsipi/scsi_cd.h +++ b/sys/dev/scsipi/scsi_cd.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_cd.h,v 1.5 1994/12/28 19:42:58 mycroft Exp $ */ +/* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:05:15 mycroft Exp $ */ /* * Written by Julian Elischer (julian@tfs.com) @@ -31,117 +31,111 @@ struct scsi_read_capacity_cd { u_int8_t opcode; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_pause { - u_char opcode; - u_char byte2; - u_char unused[6]; - u_char resume; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[6]; + u_int8_t resume; + u_int8_t control; }; #define PA_PAUSE 1 #define PA_RESUME 0 struct scsi_play_msf { - u_char opcode; - u_char byte2; - u_char unused; - u_char start_m; - u_char start_s; - u_char start_f; - u_char end_m; - u_char end_s; - u_char end_f; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused; + u_int8_t start_m; + u_int8_t start_s; + u_int8_t start_f; + u_int8_t end_m; + u_int8_t end_s; + u_int8_t end_f; + u_int8_t control; }; struct scsi_play_track { - u_char opcode; - u_char byte2; - u_char unused[2]; - u_char start_track; - u_char start_index; - u_char unused1; - u_char end_track; - u_char end_index; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t start_track; + u_int8_t start_index; + u_int8_t unused1; + u_int8_t end_track; + u_int8_t end_index; + u_int8_t control; }; struct scsi_play { - u_char opcode; - u_char byte2; - u_char blk_addr[4]; - u_char unused; - u_char xfer_len[2]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t blk_addr[4]; + u_int8_t unused; + u_int8_t xfer_len[2]; + u_int8_t control; }; struct scsi_play_big { - u_char opcode; - u_char byte2; /* same as above */ - u_char blk_addr[4]; - u_char xfer_len[4]; - u_char unused; - u_char control; + u_int8_t opcode; + u_int8_t byte2; /* same as above */ + u_int8_t blk_addr[4]; + u_int8_t xfer_len[4]; + u_int8_t unused; + u_int8_t control; }; struct scsi_play_rel_big { - u_char opcode; - u_char byte2; /* same as above */ - u_char blk_addr[4]; - u_char xfer_len[4]; - u_char track; - u_char control; + u_int8_t opcode; + u_int8_t byte2; /* same as above */ + u_int8_t blk_addr[4]; + u_int8_t xfer_len[4]; + u_int8_t track; + u_int8_t control; }; struct scsi_read_header { - u_char opcode; - u_char byte2; - u_char blk_addr[4]; - u_char unused; - u_char data_len[2]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t blk_addr[4]; + u_int8_t unused; + u_int8_t data_len[2]; + u_int8_t control; }; struct scsi_read_subchannel { - u_char opcode; - u_char byte2; - u_char byte3; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t byte3; #define SRS_SUBQ 0x40 - u_char subchan_format; - u_char unused[2]; - u_char track; - u_char data_len[2]; - u_char control; + u_int8_t subchan_format; + u_int8_t unused[2]; + u_int8_t track; + u_int8_t data_len[2]; + u_int8_t control; }; struct scsi_read_toc { - u_char opcode; - u_char byte2; - u_char unused[4]; - u_char from_track; - u_char data_len[2]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[4]; + u_int8_t from_track; + u_int8_t data_len[2]; + u_int8_t control; }; ; struct scsi_read_cd_capacity { - u_char opcode; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; }; /* @@ -162,33 +156,27 @@ struct scsi_read_cd_capacity { struct scsi_read_cd_cap_data { - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least significant */ - u_char length_3; /* Most significant */ - u_char length_2; - u_char length_1; - u_char length_0; /* Least significant */ + u_int8_t addr[4]; + u_int8_t length[4]; }; union cd_pages { struct audio_page { - u_char page_code; + u_int8_t page_code; #define CD_PAGE_CODE 0x3F #define AUDIO_PAGE 0x0e #define CD_PAGE_PS 0x80 - u_char param_len; - u_char flags; + u_int8_t param_len; + u_int8_t flags; #define CD_PA_SOTC 0x02 #define CD_PA_IMMED 0x04 - u_char unused[2]; - u_char format_lba; + u_int8_t unused[2]; + u_int8_t format_lba; #define CD_PA_FORMAT_LBA 0x0F #define CD_PA_APR_VALID 0x80 - u_char lb_per_sec[2]; + u_int8_t lb_per_sec[2]; struct port_control { - u_char channels; + u_int8_t channels; #define CHANNEL 0x0F #define CHANNEL_0 1 #define CHANNEL_1 2 @@ -196,7 +184,7 @@ union cd_pages { #define CHANNEL_3 8 #define LEFT_CHANNEL CHANNEL_0 #define RIGHT_CHANNEL CHANNEL_1 - u_char volume; + u_int8_t volume; } port[4]; #define LEFT_PORT 0 #define RIGHT_PORT 1 diff --git a/sys/dev/scsipi/scsi_changer.h b/sys/dev/scsipi/scsi_changer.h index 5161ce8e1664..677237e6a046 100644 --- a/sys/dev/scsipi/scsi_changer.h +++ b/sys/dev/scsipi/scsi_changer.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_changer.h,v 1.5 1994/12/28 19:42:59 mycroft Exp $ */ +/* $NetBSD: scsi_changer.h,v 1.6 1996/03/19 03:05:15 mycroft Exp $ */ /* * SCSI changer interface description @@ -28,16 +28,16 @@ * SCSI command format */ struct scsi_read_element_status { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRES_ELEM_TYPE_CODE 0x0F #define SRES_ELEM_VOLTAG 0x10 - u_char starting_element_addr[2]; - u_char number_of_elements[2]; - u_char resv1; - u_char allocation_length[3]; - u_char resv2; - u_char control; + u_int8_t starting_element_addr[2]; + u_int8_t number_of_elements[2]; + u_int8_t resv1; + u_int8_t allocation_length[3]; + u_int8_t resv2; + u_int8_t control; }; #define RE_ALL_ELEMENTS 0 #define RE_MEDIUM_TRANSPORT_ELEMENT 1 @@ -46,24 +46,24 @@ struct scsi_read_element_status { #define RE_DATA_TRANSFER_ELEMENT 4 struct scsi_move_medium { - u_char opcode; - u_char byte2; - u_char transport_element_address[2]; - u_char source_address[2]; - u_char destination_address[2]; - u_char rsvd[2]; - u_char invert; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t transport_element_address[2]; + u_int8_t source_address[2]; + u_int8_t destination_address[2]; + u_int8_t rsvd[2]; + u_int8_t invert; + u_int8_t control; }; struct scsi_position_to_element { - u_char opcode; - u_char byte2; - u_char transport_element_address[2]; - u_char source_address[2]; - u_char rsvd[2]; - u_char invert; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t transport_element_address[2]; + u_int8_t source_address[2]; + u_int8_t rsvd[2]; + u_int8_t invert; + u_int8_t control; }; /* @@ -74,20 +74,20 @@ struct scsi_position_to_element { #define READ_ELEMENT_STATUS 0xb8 struct scsi_element_status_data { - u_char first_element_reported[2]; - u_char number_of_elements_reported[2]; - u_char rsvd; - u_char byte_count_of_report[3]; + u_int8_t first_element_reported[2]; + u_int8_t number_of_elements_reported[2]; + u_int8_t rsvd; + u_int8_t byte_count_of_report[3]; }; struct element_status_page { - u_char element_type_code; - u_char flags; + u_int8_t element_type_code; + u_int8_t flags; #define ESP_AVOLTAG 0x40 #define ESP_PVOLTAG 0x80 - u_char element_descriptor_length[2]; - u_char rsvd; - u_char byte_count_of_descriptor_data[3]; + u_int8_t element_descriptor_length[2]; + u_int8_t rsvd; + u_int8_t byte_count_of_descriptor_data[3]; }; #endif /* _SCSI_SCSI_CHANGER_H */ diff --git a/sys/dev/scsipi/scsi_disk.h b/sys/dev/scsipi/scsi_disk.h index 3b3e3350c886..fd09456a5cf3 100644 --- a/sys/dev/scsipi/scsi_disk.h +++ b/sys/dev/scsipi/scsi_disk.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_disk.h,v 1.8 1995/10/15 23:32:02 thorpej Exp $ */ +/* $NetBSD: scsi_disk.h,v 1.9 1996/03/19 03:05:15 mycroft Exp $ */ /* * SCSI interface description @@ -57,56 +57,47 @@ #define _SCSI_SCSI_DISK_H 1 struct scsi_reassign_blocks { - u_char opcode; - u_char byte2; - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_rw { - u_char opcode; - u_char addr_2; /* Most significant */ + u_int8_t opcode; + u_int8_t addr[3]; #define SRW_TOPADDR 0x1F /* only 5 bits here */ - u_char addr_1; - u_char addr_0; /* least significant */ - u_char length; - u_char control; + u_int8_t length; + u_int8_t control; }; struct scsi_rw_big { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRWB_RELADDR 0x01 - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* least significant */ - u_char reserved; - u_char length2; - u_char length1; - u_char control; + u_int8_t addr[4]; + u_int8_t reserved; + u_int8_t length[2]; + u_int8_t control; }; struct scsi_read_capacity { - u_char opcode; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_start_stop { - u_char opcode; - u_char byte2; - u_char unused[2]; - u_char how; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t how; #define SSS_STOP 0x00 #define SSS_START 0x01 #define SSS_LOEJ 0x02 - u_char control; + u_int8_t control; }; @@ -128,89 +119,60 @@ struct scsi_start_stop { struct scsi_read_cap_data { - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least significant */ - u_char length_3; /* Most significant */ - u_char length_2; - u_char length_1; - u_char length_0; /* Least significant */ + u_int8_t addr[4]; + u_int8_t length[4]; }; struct scsi_reassign_blocks_data { - u_char reserved[2]; - u_char length_msb; - u_char length_lsb; + u_int8_t reserved[2]; + u_int8_t length[2]; struct { - u_char dlbaddr_3; /* defect logical block address (MSB) */ - u_char dlbaddr_2; - u_char dlbaddr_1; - u_char dlbaddr_0; /* defect logical block address (LSB) */ + u_int8_t dlbaddr[4]; } defect_descriptor[1]; }; -union disk_pages { /* this is the structure copied from osf */ - struct page_disk_format { - u_char pg_code; /* page code (should be 3) */ +union disk_pages { #define DISK_PGCODE 0x3F /* only 6 bits valid */ - u_char pg_length; /* page length (should be 0x16) */ - u_char trk_z_1; /* tracks per zone (MSB) */ - u_char trk_z_0; /* tracks per zone (LSB) */ - u_char alt_sec_1; /* alternate sectors per zone (MSB) */ - u_char alt_sec_0; /* alternate sectors per zone (LSB) */ - u_char alt_trk_z_1; /* alternate tracks per zone (MSB) */ - u_char alt_trk_z_0; /* alternate tracks per zone (LSB) */ - u_char alt_trk_v_1; /* alternate tracks per volume (MSB) */ - u_char alt_trk_v_0; /* alternate tracks per volume (LSB) */ - u_char ph_sec_t_1; /* physical sectors per track (MSB) */ - u_char ph_sec_t_0; /* physical sectors per track (LSB) */ - u_char bytes_s_1; /* bytes per sector (MSB) */ - u_char bytes_s_0; /* bytes per sector (LSB) */ - u_char interleave_1;/* interleave (MSB) */ - u_char interleave_0;/* interleave (LSB) */ - u_char trk_skew_1; /* track skew factor (MSB) */ - u_char trk_skew_0; /* track skew factor (LSB) */ - u_char cyl_skew_1; /* cylinder skew (MSB) */ - u_char cyl_skew_0; /* cylinder skew (LSB) */ - u_char flags; /* various */ -#define DISK_FMT_SURF 0x10 -#define DISK_FMT_RMB 0x20 -#define DISK_FMT_HSEC 0x40 -#define DISK_FMT_SSEC 0x80 - u_char reserved2; - u_char reserved3; + struct page_disk_format { + u_int8_t pg_code; /* page code (should be 3) */ + u_int8_t pg_length; /* page length (should be 0x16) */ + u_int8_t trk_z[2]; /* tracks per zone */ + u_int8_t alt_sec[2]; /* alternate sectors per zone */ + u_int8_t alt_trk_z[2]; /* alternate tracks per zone */ + u_int8_t alt_trk_v[2]; /* alternate tracks per volume */ + u_int8_t ph_sec_t[2]; /* physical sectors per track */ + u_int8_t bytes_s[2]; /* bytes per sector */ + u_int8_t interleave[2]; /* interleave */ + u_int8_t trk_skew[2]; /* track skew factor */ + u_int8_t cyl_skew[2]; /* cylinder skew */ + u_int8_t flags; /* various */ +#define DISK_FMT_SURF 0x10 +#define DISK_FMT_RMB 0x20 +#define DISK_FMT_HSEC 0x40 +#define DISK_FMT_SSEC 0x80 + u_int8_t reserved2; + u_int8_t reserved3; } disk_format; struct page_rigid_geometry { - u_char pg_code; /* page code (should be 4) */ - u_char pg_length; /* page length (should be 0x16) */ - u_char ncyl_2; /* number of cylinders (MSB) */ - u_char ncyl_1; /* number of cylinders */ - u_char ncyl_0; /* number of cylinders (LSB) */ - u_char nheads; /* number of heads */ - u_char st_cyl_wp_2; /* starting cyl., write precomp (MSB) */ - u_char st_cyl_wp_1; /* starting cyl., write precomp */ - u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */ - u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/ - u_char st_cyl_rwc_1;/* starting cyl., red. write cur */ - u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/ - u_char driv_step_1; /* drive step rate (MSB) */ - u_char driv_step_0; /* drive step rate (LSB) */ - u_char land_zone_2; /* landing zone cylinder (MSB) */ - u_char land_zone_1; /* landing zone cylinder */ - u_char land_zone_0; /* landing zone cylinder (LSB) */ - u_char sp_sync_ctl; /* spindle synch control */ + u_int8_t pg_code; /* page code (should be 4) */ + u_int8_t pg_length; /* page length (should be 0x16) */ + u_int8_t ncyl[3]; /* number of cylinders */ + u_int8_t nheads; /* number of heads */ + u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */ + u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */ + u_int8_t driv_step[2]; /* drive step rate */ + u_int8_t land_zone[3]; /* landing zone cylinder */ + u_int8_t sp_sync_ctl; /* spindle synch control */ #define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */ #define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */ #define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */ #define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */ #define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */ - u_char rot_offset; /* rotational offset (for spindle synch) */ - u_char reserved1; - u_char rpm_1; /* media rotation speed (MSB) */ - u_char rpm_0; /* media rotation speed (LSB) */ - u_char reserved2; - u_char reserved3; + u_int8_t rot_offset; /* rotational offset (for spindle synch) */ + u_int8_t reserved1; + u_int8_t rpm[2]; /* media rotation speed */ + u_int8_t reserved2; + u_int8_t reserved3; } rigid_geometry; }; diff --git a/sys/dev/scsipi/scsi_scanner.h b/sys/dev/scsipi/scsi_scanner.h index 0db8028c2f69..7ea6985c44f0 100644 --- a/sys/dev/scsipi/scsi_scanner.h +++ b/sys/dev/scsipi/scsi_scanner.h @@ -47,62 +47,62 @@ struct scsi_rw_scanner { #define READ 0x08 #define WRITE 0x0a - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRW_FIXED 0x01 - u_char len[3]; - u_char control; + u_int8_t len[3]; + u_int8_t control; }; struct scsi_start_stop { - u_char opcode; - u_char byte2; - u_char unused[2]; - u_char how; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t how; #define SSS_STOP 0x00 #define SSS_START 0x01 #define SSS_LOEJ 0x02 - u_char control; + u_int8_t control; }; struct scsi_set_window { #define SET_WINDOW 0x24 /* set params of image area and windows */ #define GET_WINDOW 0x25 - u_char opcode; - u_char byte2; - u_char reserved[4]; - u_char len[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t reserved[4]; + u_int8_t len[3]; + u_int8_t control; }; struct scsi_window_header { - u_char reserved[6]; - u_char len[2]; /* MSB-LSB */ + u_int8_t reserved[6]; + u_int8_t len[2]; }; struct scsi_window_data { - u_char window_id; /* must be zero */ - u_char res1:7; - u_char auto_bit:1; - u_char x_res[2]; - u_char y_res[2]; - u_char x_org[4]; - u_char y_org[4]; - u_char width[4]; - u_char length[4]; - u_char brightness; - u_char threshold; - u_char contrast; - u_char image_comp; /* image composition (data type) */ - u_char bits_per_pixel; - u_char halftone_pattern[2]; - u_char rif:1; /* reverse image format (mono negative) */ - u_char res2:4; - u_char pad_type:3; - u_char bit_ordering[2]; - u_char compression_type; - u_char compression_arg; - u_char res3[6]; + u_int8_t window_id; /* must be zero */ + u_int8_t res1:7; + u_int8_t auto_bit:1; + u_int8_t x_res[2]; + u_int8_t y_res[2]; + u_int8_t x_org[4]; + u_int8_t y_org[4]; + u_int8_t width[4]; + u_int8_t length[4]; + u_int8_t brightness; + u_int8_t threshold; + u_int8_t contrast; + u_int8_t image_comp; /* image composition (data type) */ + u_int8_t bits_per_pixel; + u_int8_t halftone_pattern[2]; + u_int8_t rif:1; /* reverse image format (mono negative) */ + u_int8_t res2:4; + u_int8_t pad_type:3; + u_int8_t bit_ordering[2]; + u_int8_t compression_type; + u_int8_t compression_arg; + u_int8_t res3[6]; }; /* mustek scsi commands */ diff --git a/sys/dev/scsipi/scsi_tape.h b/sys/dev/scsipi/scsi_tape.h index 654b02ac7ec1..eaaf276bc6c0 100644 --- a/sys/dev/scsipi/scsi_tape.h +++ b/sys/dev/scsipi/scsi_tape.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_tape.h,v 1.7 1996/01/11 03:36:34 thorpej Exp $ */ +/* $NetBSD: scsi_tape.h,v 1.8 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -60,97 +60,93 @@ #define READ 0x08 #define WRITE 0x0a struct scsi_rw_tape { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRW_FIXED 0x01 - u_char len[3]; - u_char control; + u_int8_t len[3]; + u_int8_t control; }; #define SPACE 0x11 struct scsi_space { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SS_CODE 0x03 #define SP_BLKS 0x00 #define SP_FILEMARKS 0x01 #define SP_SEQ_FILEMARKS 0x02 #define SP_EOM 0x03 - u_char number[3]; - u_char control; + u_int8_t number[3]; + u_int8_t control; }; #define WRITE_FILEMARKS 0x10 struct scsi_write_filemarks { - u_char opcode; - u_char byte2; - u_char number[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t number[3]; + u_int8_t control; }; #define REWIND 0x01 struct scsi_rewind { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SR_IMMED 0x01 - u_char unused[3]; - u_char control; + u_int8_t unused[3]; + u_int8_t control; }; #define LOAD 0x1b struct scsi_load { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SL_IMMED 0x01 - u_char unused[2]; - u_char how; + u_int8_t unused[2]; + u_int8_t how; #define LD_UNLOAD 0x00 #define LD_LOAD 0x01 #define LD_RETENSION 0x02 - u_char control; + u_int8_t control; }; #define ERASE 0x19 struct scsi_erase { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SE_LONG 0x01 #define SE_IMMED 0x02 - u_char unused[3]; - u_char control; + u_int8_t unused[3]; + u_int8_t control; }; #define READ_BLOCK_LIMITS 0x05 struct scsi_block_limits { - u_char opcode; - u_char byte2; - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_block_limits_data { - u_char reserved; - u_char max_length_2; /* Most significant */ - u_char max_length_1; - u_char max_length_0; /* Least significant */ - u_char min_length_1; /* Most significant */ - u_char min_length_0; /* Least significant */ + u_int8_t reserved; + u_int8_t max_length[3]; /* Most significant */ + u_int8_t min_length[2]; /* Most significant */ }; /* See SCSI-II spec 9.3.3.1 */ struct scsi_tape_dev_conf_page { - u_char pagecode; /* 0x10 */ - u_char pagelength; /* 0x0e */ - u_char byte2; + u_int8_t pagecode; /* 0x10 */ + u_int8_t pagelength; /* 0x0e */ + u_int8_t byte2; #define SMT_CAP 0x40 /* change active partition */ #define SMT_CAF 0x20 /* change active format */ #define SMT_AFMASK 0x1f /* active format mask */ - u_char active_partition; - u_char wb_full_ratio; - u_char rb_empty_ratio; - u_char wrdelay_time_1; /* MSB */ - u_char wrdelay_time_0; /* LSB */ - u_char byte8; + u_int8_t active_partition; + u_int8_t wb_full_ratio; + u_int8_t rb_empty_ratio; + u_int8_t wrdelay_time[2]; + u_int8_t byte8; #define SMT_DBR 0x80 /* data buffer recovery */ #define SMT_BIS 0x40 /* block identifiers supported */ #define SMT_RSMK 0x20 /* report setmarks */ @@ -158,18 +154,16 @@ struct scsi_tape_dev_conf_page { #define SMT_SOCF_MASK 0xc0 /* stop on consecutive formats */ #define SMT_RBO 0x20 /* recover buffer order */ #define SMT_REW 0x10 /* report early warning */ - u_char gap_size; - u_char byte10; + u_int8_t gap_size; + u_int8_t byte10; #define SMT_EODDEFINED 0xe0 /* EOD defined */ #define SMT_EEG 0x10 /* enable EOD generation */ #define SMT_SEW 0x80 /* synchronize at early warning */ - u_char ew_bufsize_2; /* MSB */ - u_char ew_bufsize_1; /* ... */ - u_char ew_bufsize_0; /* LSB */ - u_char sel_comp_alg; + u_int8_t ew_bufsize[3]; + u_int8_t sel_comp_alg; #define SMT_COMP_NONE 0x00 #define SMT_COMP_DEFAULT 0x01 - u_char reserved; + u_int8_t reserved; }; /* defines for the device specific byte in the mode select/sense header */ @@ -182,11 +176,11 @@ struct scsi_tape_dev_conf_page { /* A special for the CIPHER ST150S(old drive) */ struct block_desc_cipher { - u_char density; - u_char nblocks[3]; - u_char reserved; - u_char blklen[3]; - u_char other; + u_int8_t density; + u_int8_t nblocks[3]; + u_int8_t reserved; + u_int8_t blklen[3]; + u_int8_t other; #define ST150_SEC 0x01 /* soft error count */ #define SR150_AUI 0x02 /* autoload inhibit */ }; diff --git a/sys/dev/scsipi/scsiconf.h b/sys/dev/scsipi/scsiconf.h index efda1dde6bf1..dc94894f8bd1 100644 --- a/sys/dev/scsipi/scsiconf.h +++ b/sys/dev/scsipi/scsiconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.h,v 1.28 1996/02/18 20:32:45 mycroft Exp $ */ +/* $NetBSD: scsiconf.h,v 1.29 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved. @@ -288,8 +288,156 @@ void show_mem __P((u_char *, int)); int scsi_probe_busses __P((int, int, int)); void scsi_strvis __P((u_char *, u_char *, int)); +static __inline void _lto2b __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto3b __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto4b __P((u_int32_t val, u_int8_t *bytes)); +static __inline u_int32_t _2btol __P((u_int8_t *bytes)); +static __inline u_int32_t _3btol __P((u_int8_t *bytes)); +static __inline u_int32_t _4btol __P((u_int8_t *bytes)); -void lto3b __P((u_int32_t val, u_int8_t *bytes)); -u_int32_t _3btol __P((u_int8_t *bytes)); +static __inline void _lto2l __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto3l __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto4l __P((u_int32_t val, u_int8_t *bytes)); +static __inline u_int32_t _2ltol __P((u_int8_t *bytes)); +static __inline u_int32_t _3ltol __P((u_int8_t *bytes)); +static __inline u_int32_t _4ltol __P((u_int8_t *bytes)); + +static __inline void +_lto2b(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = (val >> 8) & 0xff; + bytes[1] = val & 0xff; +} + +static __inline void +_lto3b(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = (val >> 16) & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = val & 0xff; +} + +static __inline void +_lto4b(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = (val >> 24) & 0xff; + bytes[1] = (val >> 16) & 0xff; + bytes[2] = (val >> 8) & 0xff; + bytes[3] = val & 0xff; +} + +static __inline u_int32_t +_2btol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = (bytes[0] << 8) | + bytes[1]; + return (rv); +} + +static __inline u_int32_t +_3btol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = (bytes[0] << 16) | + (bytes[1] << 8) | + bytes[2]; + return (rv); +} + +static __inline u_int32_t +_4btol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = (bytes[0] << 24) | + (bytes[1] << 16) | + (bytes[2] << 8) | + bytes[3]; + return (rv); +} + +static __inline void +_lto2l(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; +} + +static __inline void +_lto3l(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; +} + +static __inline void +_lto4l(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; + bytes[3] = (val >> 24) & 0xff; +} + +static __inline u_int32_t +_2ltol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8); + return (rv); +} + +static __inline u_int32_t +_3ltol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8) | + (bytes[2] << 16); + return (rv); +} + +static __inline u_int32_t +_4ltol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8) | + (bytes[2] << 16) | + (bytes[3] << 24); + return (rv); +} #endif /* SCSI_SCSICONF_H */ diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c index 6125fd68a924..d22ff46cef73 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.90 1996/03/17 02:06:50 pk Exp $ */ +/* $NetBSD: sd.c,v 1.91 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -106,7 +106,6 @@ void sdminphys __P((struct buf *)); void sdgetdisklabel __P((struct sd_softc *)); void sdstart __P((void *)); int sddone __P((struct scsi_xfer *, int)); -u_long sd_size __P((struct sd_softc *, int)); int sd_reassign_blocks __P((struct sd_softc *, u_long)); int sd_get_parms __P((struct sd_softc *, int)); @@ -569,9 +568,7 @@ sdstart(v) bzero(&cmd_small, sizeof(cmd_small)); cmd_small.opcode = (bp->b_flags & B_READ) ? READ_COMMAND : WRITE_COMMAND; - cmd_small.addr_2 = (blkno >> 16) & 0x1f; - cmd_small.addr_1 = (blkno >> 8) & 0xff; - cmd_small.addr_0 = blkno & 0xff; + _lto3b(blkno, cmd_small.addr); cmd_small.length = nblks & 0xff; cmdlen = sizeof(cmd_small); cmdp = (struct scsi_generic *)&cmd_small; @@ -582,12 +579,8 @@ sdstart(v) bzero(&cmd_big, sizeof(cmd_big)); cmd_big.opcode = (bp->b_flags & B_READ) ? READ_BIG : WRITE_BIG; - cmd_big.addr_3 = (blkno >> 24) & 0xff; - cmd_big.addr_2 = (blkno >> 16) & 0xff; - cmd_big.addr_1 = (blkno >> 8) & 0xff; - cmd_big.addr_0 = blkno & 0xff; - cmd_big.length2 = (nblks >> 8) & 0xff; - cmd_big.length1 = nblks & 0xff; + _lto4b(blkno, cmd_big.addr); + _lto2b(nblks, cmd_big.length); cmdlen = sizeof(cmd_big); cmdp = (struct scsi_generic *)&cmd_big; } @@ -805,47 +798,13 @@ sdgetdisklabel(sd) } } -/* - * Find out from the device what it's capacity is - */ -u_long -sd_size(sd, flags) - struct sd_softc *sd; - int flags; -{ - struct scsi_read_cap_data rdcap; - struct scsi_read_capacity scsi_cmd; - u_long size; - - /* - * make up a scsi command and ask the scsi driver to do - * it for you. - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.opcode = READ_CAPACITY; - - /* - * If the command works, interpret the result as a 4 byte - * number of blocks - */ - if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), SDRETRIES, - 2000, NULL, flags | SCSI_DATA_IN) != 0) - return 0; - - size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) + - (rdcap.addr_1 << 8) + rdcap.addr_0 + 1; - - return size; -} - /* * Tell the device to map out a defective block */ int -sd_reassign_blocks(sd, block) +sd_reassign_blocks(sd, blkno) struct sd_softc *sd; - u_long block; + u_long blkno; { struct scsi_reassign_blocks scsi_cmd; struct scsi_reassign_blocks_data rbdata; @@ -854,20 +813,14 @@ sd_reassign_blocks(sd, block) bzero(&rbdata, sizeof(rbdata)); scsi_cmd.opcode = REASSIGN_BLOCKS; - rbdata.length_msb = 0; - rbdata.length_lsb = sizeof(rbdata.defect_descriptor[0]); - rbdata.defect_descriptor[0].dlbaddr_3 = (block >> 24) & 0xff; - rbdata.defect_descriptor[0].dlbaddr_2 = (block >> 16) & 0xff; - rbdata.defect_descriptor[0].dlbaddr_1 = (block >> 8) & 0xff; - rbdata.defect_descriptor[0].dlbaddr_0 = block & 0xff; + _lto2b(sizeof(rbdata.defect_descriptor[0]), rbdata.length); + _lto4b(blkno, rbdata.defect_descriptor[0].dlbaddr); return scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), SDRETRIES, 5000, NULL, SCSI_DATA_OUT); } -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 ) - /* * Get the scsi driver to send a full inquiry to the * device and use the * results to fill out the disk parameter structure. @@ -908,7 +861,7 @@ sd_get_parms(sd, flags) * this depends on which controller (e.g. 1542C is * different. but we have to put SOMETHING here..) */ - sectors = sd_size(sd, flags); + sectors = scsi_size(sd->sc_link, flags); dp->heads = 64; dp->sectors = 32; dp->cyls = sectors / (64 * 32); @@ -919,9 +872,9 @@ sd_get_parms(sd, flags) ("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n", _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2), scsi_sense.pages.rigid_geometry.nheads, - b2tol(scsi_sense.pages.rigid_geometry.st_cyl_wp), - b2tol(scsi_sense.pages.rigid_geometry.st_cyl_rwc), - b2tol(scsi_sense.pages.rigid_geometry.land_zone))); + _2btol(scsi_sense.pages.rigid_geometry.st_cyl_wp), + _2btol(scsi_sense.pages.rigid_geometry.st_cyl_rwc), + _2btol(scsi_sense.pages.rigid_geometry.land_zone))); /* * KLUDGE!! (for zone recorded disks) @@ -930,8 +883,7 @@ sd_get_parms(sd, flags) * can lead to wasted space! THINK ABOUT THIS ! */ dp->heads = scsi_sense.pages.rigid_geometry.nheads; - dp->cyls = - _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2); + dp->cyls = _3btol(scsi_sense.pages.rigid_geometry.ncyl); dp->blksize = _3btol(scsi_sense.blk_desc.blklen); if (dp->heads == 0 || dp->cyls == 0) { @@ -943,7 +895,7 @@ sd_get_parms(sd, flags) if (dp->blksize == 0) dp->blksize = 512; - sectors = sd_size(sd, flags); + sectors = scsi_size(sd->sc_link, flags); dp->disksize = sectors; sectors /= (dp->heads * dp->cyls); dp->sectors = sectors; /* XXX dubious on SCSI */ @@ -1047,12 +999,8 @@ sddump(dev, blkno, va, size) */ bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE_BIG; - cmd.addr_3 = (blkno >> 24) & 0xff; - cmd.addr_2 = (blkno >> 16) & 0xff; - cmd.addr_1 = (blkno >> 8) & 0xff; - cmd.addr_0 = blkno & 0xff; - cmd.length2 = (nwrt >> 8) & 0xff; - cmd.length1 = nwrt & 0xff; + _lto4b(blkno, cmd.addr); + _lto2b(nwrt, cmd.length); /* * Fill out the scsi_xfer structure * Note: we cannot sleep as we may be an interrupt diff --git a/sys/dev/scsipi/ss_mustek.c b/sys/dev/scsipi/ss_mustek.c index 7be6628fe01f..02249389039c 100644 --- a/sys/dev/scsipi/ss_mustek.c +++ b/sys/dev/scsipi/ss_mustek.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss_mustek.c,v 1.1 1996/02/18 20:32:47 mycroft Exp $ */ +/* $NetBSD: ss_mustek.c,v 1.2 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved. @@ -277,9 +277,7 @@ mustek_trigger_scanner(ss) struct mustek_set_window_data window_data; struct mustek_start_scan_cmd start_scan_cmd; struct scsi_link *sc_link = ss->sc_link; -#ifndef MUSTEK_INCH_SPEC int pixel_tlx, pixel_tly, pixel_brx, pixel_bry, paperlength; -#endif int error; mustek_compute_sizes(ss); @@ -294,46 +292,29 @@ mustek_trigger_scanner(ss) window_cmd.length = sizeof(window_data); bzero(&window_data, sizeof(window_data)); - window_data.frame_header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC; + window_data.frame.header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC; #ifdef MUSTEK_INCH_SPEC /* the positional values are all 1 byte because 256 / 8 = 32" */ - window_data.frame_tl_x_0 = ss->sio.scan_x_origin / 150; - window_data.frame_tl_x_1 = 0; - window_data.frame_tl_y_0 = ss->sio.scan_y_origin / 150; - window_data.frame_tl_y_1 = 0; - window_data.frame_br_x_0 = (ss->sio.scan_x_origin + - ss->sio.scan_width) / 150; - window_data.frame_br_x_1 = 0; - window_data.frame_br_y_0 = (ss->sio.scan_y_origin + - ss->sio.scan_height) / 150; - window_data.frame_br_y_1 = 0; + pixel_tlx = ss->sio.scan_x_origin / 150; + pixel_tly = ss->sio.scan_y_origin / 150; + pixel_brx = pixel_tlx + ss->sio.scan_width / 150; + pixel_bry = pixel_tly + ss->sio.scan_height / 150; #else pixel_tlx = (ss->sio.scan_x_origin * ss->sio.scan_x_resolution) / 1200; - window_data.frame_tl_x_0 = pixel_tlx & 0xff; - window_data.frame_tl_x_1 = (pixel_tlx >> 8) & 0xff; pixel_tly = (ss->sio.scan_y_origin * ss->sio.scan_y_resolution) / 1200; - window_data.frame_tl_y_0 = pixel_tly & 0xff; - window_data.frame_tl_y_1 = (pixel_tly >> 8) & 0xff; pixel_brx = pixel_tlx + (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200; - window_data.frame_br_x_0 = pixel_brx & 0xff; - window_data.frame_br_x_1 = (pixel_brx >> 8) & 0xff; pixel_bry = pixel_tly + (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200; - window_data.frame_br_y_0 = pixel_bry & 0xff; - window_data.frame_br_y_1 = (pixel_bry >> 8) & 0xff; #endif + _lto2l(pixel_tlx, window_data.frame.tl_x); + _lto2l(pixel_tly, window_data.frame.tl_y); + _lto2l(pixel_brx, window_data.frame.br_x); + _lto2l(pixel_bry, window_data.frame.br_y); #if MUSTEK_WINDOWS >= 1 - window_data.window1_header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC; - window_data.window1_tl_x_0 = window_data.frame_tl_x_0; - window_data.window1_tl_x_1 = window_data.frame_tl_x_1; - window_data.window1_tl_y_0 = window_data.frame_tl_y_0; - window_data.window1_tl_y_1 = window_data.frame_tl_y_1; - window_data.window1_br_x_0 = window_data.frame_br_x_0; - window_data.window1_br_x_1 = window_data.frame_br_x_1; - window_data.window1_br_y_0 = window_data.frame_br_y_0; - window_data.window1_br_y_1 = window_data.frame_br_y_1; + window_data.window1 = window_data.frame; + window_data.window1.header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC; #endif /* send the set window command to the scanner */ @@ -349,7 +330,7 @@ mustek_trigger_scanner(ss) */ bzero(&mode_cmd, sizeof(mode_cmd)); mode_cmd.opcode = MUSTEK_MODE_SELECT; - mode_cmd.length_0 = sizeof(mode_data); + _lto2b(sizeof(mode_data), mode_cmd.length); bzero(&mode_data, sizeof(mode_data)); mode_data.mode = @@ -369,13 +350,11 @@ mustek_trigger_scanner(ss) mode_data.grain = 0; mode_data.velocity = ss->sio.scan_quality / 20 - 1; #ifdef MUSTEK_INCH_SPEC - mode_data.paperlength_0 = 14 * 8; /* 14" */ - mode_data.paperlength_1 = 0; + paperlength = 14 * 8; /* 14" */ #else - paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */ - mode_data.paperlength_0 = paperlength & 0xff; - mode_data.paperlength_1 = (paperlength >> 8) & 0xff; + paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */ #endif + _lto2l(paperlength, mode_data.paperlength); SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n")); /* send the command to the scanner */ @@ -492,9 +471,7 @@ mustek_read(ss, bp) ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8); SC_DEBUG(sc_link, SDEV_DB1, ("mustek_read: read %d lines\n", lines_to_read)); - cmd.length_0 = lines_to_read & 0xff; - cmd.length_1 = (lines_to_read >> 8) & 0xff; - cmd.length_2 = (lines_to_read >> 16) & 0xff; + _lto3b(lines_to_read, cmd.length); /* * go ask the adapter to do all this for us @@ -547,13 +524,8 @@ mustek_get_status(ss, timeout, update) } if (update) { - bytes_per_line = - (data.bytes_per_line_1 << 8) | - data.bytes_per_line_0; - lines = - (data.lines_2 << 16) | - (data.lines_1 << 8) | - data.lines_0; + bytes_per_line = _2ltol(data.bytes_per_line); + lines = _3ltol(data.lines); if (lines != ss->sio.scan_lines) { printf("mustek: lines actual(%d) != computed(%d)\n", lines, ss->sio.scan_lines); diff --git a/sys/dev/scsipi/ss_mustek.h b/sys/dev/scsipi/ss_mustek.h index c045675077bd..599f129a06f2 100644 --- a/sys/dev/scsipi/ss_mustek.h +++ b/sys/dev/scsipi/ss_mustek.h @@ -1,4 +1,4 @@ -/* $NetBSD: ss_mustek.h,v 1.1 1996/02/18 20:32:48 mycroft Exp $ */ +/* $NetBSD: ss_mustek.h,v 1.2 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved. @@ -70,104 +70,66 @@ */ struct mustek_set_window_cmd { - u_char opcode; /* 0x04 */ - u_char reserved[3]; - u_char length; /* in bytes */ - u_char control; + u_int8_t opcode; /* 0x04 */ + u_int8_t reserved[3]; + u_int8_t length; /* in bytes */ + u_int8_t control; +}; + +struct mustek_window { + u_int8_t header; /* unit-defines also apply */ + u_int8_t tl_x[2]; /* LSB */ + u_int8_t tl_y[2]; + u_int8_t br_x[2]; + u_int8_t br_y[2]; }; struct mustek_set_window_data { #define MUSTEK_LINEART_BACKGROUND 0x00 #define MUSTEK_HALFTONE_BACKGROUND 0x01 - u_char frame_header; /* unit-defines also apply */ - u_char frame_tl_x_0; - u_char frame_tl_x_1; - u_char frame_tl_y_0; - u_char frame_tl_y_1; - u_char frame_br_x_0; - u_char frame_br_x_1; - u_char frame_br_y_0; - u_char frame_br_y_1; + struct mustek_window frame; #if MUSTEK_WINDOWS >= 1 #define MUSTEK_WINDOW_MASK 0x80 - u_char window1_header; /* unit-defines also apply */ - u_char window1_tl_x_0; - u_char window1_tl_x_1; - u_char window1_tl_y_0; - u_char window1_tl_y_1; - u_char window1_br_x_0; - u_char window1_br_x_1; - u_char window1_br_y_0; - u_char window1_br_y_1; + struct mustek_window window1; #endif #if MUSTEK_WINDOWS >= 2 - u_char window2_header; - u_char window2_tl_x_0; - u_char window2_tl_x_1; - u_char window2_tl_y_0; - u_char window2_tl_y_1; - u_char window2_br_x_0; - u_char window2_br_x_1; - u_char window2_br_y_0; - u_char window2_br_y_1; + struct mustek_window window2; #endif #if MUSTEK_WINDOWS >= 3 - u_char window3_header; - u_char window3_tl_x_0; - u_char window3_tl_x_1; - u_char window3_tl_y_0; - u_char window3_tl_y_1; - u_char window3_br_x_0; - u_char window3_br_x_1; - u_char window3_br_y_0; - u_char window3_br_y_1; + struct mustek_window window3; #endif -#if MUSTEK_WINDOWS == 4 - u_char window4_header; - u_char window4_tl_x_0; - u_char window4_tl_x_1; - u_char window4_tl_y_0; - u_char window4_tl_y_1; - u_char window4_br_x_0; - u_char window4_br_x_1; - u_char window4_br_y_0; - u_char window4_br_y_1; +#if MUSTEK_WINDOWS >= 4 + struct mustek_window window4; #endif }; struct mustek_read_cmd { - u_char opcode; /* 0x08 */ - u_char reserved; - u_char length_2; /* number of LINES to be read (MSB) */ - u_char length_1; /* number of LINES to be read */ - u_char length_0; /* number of LINES to be read (LSB) */ - u_char control; + u_int8_t opcode; /* 0x08 */ + u_int8_t reserved; + u_int8_t length[3]; + u_int8_t control; }; struct mustek_get_status_cmd { - u_char opcode; /* 0x0f */ - u_char reserved[3]; - u_char length; /* 0x06 */ - u_char control; + u_int8_t opcode; /* 0x0f */ + u_int8_t reserved[3]; + u_int8_t length; /* 0x06 */ + u_int8_t control; }; struct mustek_get_status_data { #define MUSTEK_READY 0 #define MUSTEK_BUSY -1 - u_char ready_busy; /* 0 = ready */ - u_char bytes_per_line_0; /* LSB */ - u_char bytes_per_line_1; /* MSB */ - u_char lines_0; /* LSB */ - u_char lines_1; - u_char lines_2; /* MSB */ + u_int8_t ready_busy; /* 0 = ready */ + u_int8_t bytes_per_line[2]; /* LSB */ + u_int8_t lines[3]; /* LSB */ }; struct mustek_mode_select_cmd { - u_char opcode; /* 0x15 */ - u_char reserved[2]; - u_char length_1; /* MSB */ - u_char length_0; /* LSB */ - u_char control; + u_int8_t opcode; /* 0x15 */ + u_int8_t reserved[2]; + u_int8_t length[2]; + u_int8_t control; }; /* @@ -187,20 +149,19 @@ struct mustek_mode_select_data { #define MUSTEK_MODE_MASK 0x83 #define MUSTEK_HT_PATTERN_BUILTIN 0x00 #define MUSTEK_HT_PATTERN_DOWNLOADED 0x10 - u_char mode; - u_char resolution; - u_char brightness; - u_char contrast; - u_char grain; /* 0 = 8x8, ..... 5 = 2x2 */ - u_char velocity; /* 0 = fast, ...., 4 = slow */ - u_char reserved[2]; - u_char paperlength_0; /* LSB */ - u_char paperlength_1; /* MSB */ + u_int8_t mode; + u_int8_t resolution; + u_int8_t brightness; + u_int8_t contrast; + u_int8_t grain; /* 0 = 8x8, ..... 5 = 2x2 */ + u_int8_t velocity; /* 0 = fast, ...., 4 = slow */ + u_int8_t reserved[2]; + u_int8_t paperlength[2]; /* LSB */ }; struct mustek_start_scan_cmd { - u_char opcode; /* 0x1b */ - u_char reserved[3]; + u_int8_t opcode; /* 0x1b */ + u_int8_t reserved[3]; #define MUSTEK_SCAN_STOP 0x00 #define MUSTEK_SCAN_START 0x01 #define MUSTEK_GRAY_FILTER 0x00 @@ -211,8 +172,8 @@ struct mustek_start_scan_cmd { #define MUSTEK_BIT_MODE 0x00 #define MUSTEK_RES_STEP_1 0x00 #define MUSTEK_RES_STEP_10 0x80 - u_char mode; - u_char control; + u_int8_t mode; + u_int8_t control; }; #endif /* _SS_MUSTEK_H_ */ diff --git a/sys/dev/scsipi/ss_scanjet.c b/sys/dev/scsipi/ss_scanjet.c index 4faebc78a75c..5e2fdd689a5c 100644 --- a/sys/dev/scsipi/ss_scanjet.c +++ b/sys/dev/scsipi/ss_scanjet.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss_scanjet.c,v 1.1 1996/02/18 20:32:49 mycroft Exp $ */ +/* $NetBSD: ss_scanjet.c,v 1.2 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -240,7 +240,7 @@ scanjet_read(ss, bp) * Handle "fixed-block-mode" tape drives by using the * block count instead of the length. */ - lto3b(bp->b_bcount, cmd.len); + _lto3b(bp->b_bcount, cmd.len); /* * go ask the adapter to do all this for us @@ -278,7 +278,7 @@ scanjet_write(ss, buf, size, flags) return (0); bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE; - lto3b(size, cmd.len); + _lto3b(size, cmd.len); return (scsi_scsi_cmd(ss->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL, flags | SCSI_DATA_OUT)); diff --git a/sys/dev/scsipi/st.c b/sys/dev/scsipi/st.c index 91e53ae1e67a..1982985952bd 100644 --- a/sys/dev/scsipi/st.c +++ b/sys/dev/scsipi/st.c @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.63 1996/03/17 00:59:54 thorpej Exp $ */ +/* $NetBSD: st.c,v 1.64 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -1005,9 +1005,9 @@ ststart(v) */ if (st->flags & ST_FIXEDBLOCKS) { cmd.byte2 |= SRW_FIXED; - lto3b(bp->b_bcount / st->blksize, cmd.len); + _lto3b(bp->b_bcount / st->blksize, cmd.len); } else - lto3b(bp->b_bcount, cmd.len); + _lto3b(bp->b_bcount, cmd.len); /* * go ask the adapter to do all this for us @@ -1254,21 +1254,15 @@ st_read(st, buf, size, flags) cmd.opcode = READ; if (st->flags & ST_FIXEDBLOCKS) { cmd.byte2 |= SRW_FIXED; - lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE), + _lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE), cmd.len); } else - lto3b(size, cmd.len); + _lto3b(size, cmd.len); return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL, flags | SCSI_DATA_IN); } -#ifdef __STDC__ -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0) -#else -#define b2tol(a) (((unsigned)(a/**/_1) << 8) + (unsigned)a/**/_0) -#endif - /* * Ask the drive what it's min and max blk sizes are. */ @@ -1304,8 +1298,8 @@ st_read_block_limits(st, flags) if (error) return error; - st->blkmin = b2tol(block_limits.min_length); - st->blkmax = _3btol(&block_limits.max_length_2); + st->blkmin = _2btol(block_limits.min_length); + st->blkmax = _3btol(block_limits.max_length); SC_DEBUG(sc_link, SDEV_DB3, ("(%d <= blksize <= %d)\n", st->blkmin, st->blkmax)); @@ -1413,7 +1407,7 @@ st_mode_select(st, flags) else scsi_select.header.dev_spec |= SMH_DSP_BUFF_MODE_ON; if (st->flags & ST_FIXEDBLOCKS) - lto3b(st->blksize, scsi_select.blk_desc.blklen); + _lto3b(st->blksize, scsi_select.blk_desc.blklen); if (st->page_0_size) bcopy(st->sense_data, scsi_select.sense_data, st->page_0_size); @@ -1531,7 +1525,7 @@ st_space(st, number, what, flags) bzero(&cmd, sizeof(cmd)); cmd.opcode = SPACE; cmd.byte2 = what; - lto3b(number, cmd.number); + _lto3b(number, cmd.number); return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), 0, 0, 0, 900000, NULL, flags); @@ -1570,7 +1564,7 @@ st_write_filemarks(st, number, flags) bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE_FILEMARKS; - lto3b(number, cmd.number); + _lto3b(number, cmd.number); return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), 0, 0, 0, 100000, NULL, flags); @@ -1686,26 +1680,25 @@ st_interpret_sense(xs) /* * Get the sense fields and work out what code */ - if (sense->error_code & SSD_ERRCODE_VALID) { - bcopy(sense->extended_info, &info, sizeof info); - info = ntohl(info); - } else + if (sense->error_code & SSD_ERRCODE_VALID) + info = _4btol(sense->info); + else info = xs->datalen; /* bad choice if fixed blocks */ if ((sense->error_code & SSD_ERRCODE) != 0x70) return -1; /* let the generic code handle it */ if (st->flags & ST_FIXEDBLOCKS) { xs->resid = info * st->blksize; - if (sense->extended_flags & SSD_EOM) { + if (sense->flags & SSD_EOM) { st->flags |= ST_EIO_PENDING; if (bp) bp->b_resid = xs->resid; } - if (sense->extended_flags & SSD_FILEMARK) { + if (sense->flags & SSD_FILEMARK) { st->flags |= ST_AT_FILEMARK; if (bp) bp->b_resid = xs->resid; } - if (sense->extended_flags & SSD_ILI) { + if (sense->flags & SSD_ILI) { st->flags |= ST_EIO_PENDING; if (bp) bp->b_resid = xs->resid; @@ -1739,14 +1732,14 @@ st_interpret_sense(xs) } } else { /* must be variable mode */ xs->resid = xs->datalen; /* to be sure */ - if (sense->extended_flags & SSD_EOM) + if (sense->flags & SSD_EOM) return EIO; - if (sense->extended_flags & SSD_FILEMARK) { + if (sense->flags & SSD_FILEMARK) { if (bp) bp->b_resid = bp->b_bcount; return 0; } - if (sense->extended_flags & SSD_ILI) { + if (sense->flags & SSD_ILI) { if (info < 0) { /* * the record was bigger than the read @@ -1762,7 +1755,7 @@ st_interpret_sense(xs) bp->b_resid = info; } } - key = sense->extended_flags & SSD_KEY; + key = sense->flags & SSD_KEY; if (key == 0x8) { /* diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index 0f8cab34b476..85e14ccd8fc8 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.83 1996/03/17 00:59:41 thorpej Exp $ */ +/* $NetBSD: cd.c,v 1.84 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -553,9 +553,7 @@ cdstart(v) bzero(&cmd_small, sizeof(cmd_small)); cmd_small.opcode = (bp->b_flags & B_READ) ? READ_COMMAND : WRITE_COMMAND; - cmd_small.addr_2 = (blkno >> 16) & 0x1f; - cmd_small.addr_1 = (blkno >> 8) & 0xff; - cmd_small.addr_0 = blkno & 0xff; + _lto3b(blkno, cmd_small.addr); cmd_small.length = nblks & 0xff; cmdlen = sizeof(cmd_small); cmdp = (struct scsi_generic *)&cmd_small; @@ -566,12 +564,8 @@ cdstart(v) bzero(&cmd_big, sizeof(cmd_big)); cmd_big.opcode = (bp->b_flags & B_READ) ? READ_BIG : WRITE_BIG; - cmd_big.addr_3 = (blkno >> 24) & 0xff; - cmd_big.addr_2 = (blkno >> 16) & 0xff; - cmd_big.addr_1 = (blkno >> 8) & 0xff; - cmd_big.addr_0 = blkno & 0xff; - cmd_big.length2 = (nblks >> 8) & 0xff; - cmd_big.length1 = nblks & 0xff; + _lto4b(blkno, cmd_big.addr); + _lto2b(nblks, cmd_big.length); cmdlen = sizeof(cmd_big); cmdp = (struct scsi_generic *)&cmd_big; } @@ -734,9 +728,8 @@ cdioctl(dev, cmd, addr, flag, p) &data, len); if (error) return error; - len = min(len, ((data.header.data_len[0] << 8) + - data.header.data_len[1] + - sizeof(struct cd_sub_channel_header))); + len = min(len, _2btol(data.header.data_len) + + sizeof(struct cd_sub_channel_header)); return copyout(&data, args->data, len); } case CDIOREADTOCHEADER: { @@ -972,14 +965,12 @@ cd_size(cd, flags) 2000, NULL, flags | SCSI_DATA_IN) != 0) return 0; - blksize = (rdcap.length_3 << 24) + (rdcap.length_2 << 16) + - (rdcap.length_1 << 8) + rdcap.length_0; + blksize = _4btol(rdcap.length); if (blksize < 512) blksize = 2048; /* some drives lie ! */ cd->params.blksize = blksize; - size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) + - (rdcap.addr_1 << 8) + rdcap.addr_0 + 1; + size = _4btol(rdcap.addr) + 1; if (size < 100) size = 400000; /* ditto */ cd->params.disksize = size; @@ -1040,12 +1031,8 @@ cd_play(cd, blkno, nblks) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = PLAY; - scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff; - scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff; - scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff; - scsi_cmd.blk_addr[3] = blkno & 0xff; - scsi_cmd.xfer_len[0] = (nblks >> 8) & 0xff; - scsi_cmd.xfer_len[1] = nblks & 0xff; + _lto4b(blkno, scsi_cmd.blk_addr); + _lto2b(nblks, scsi_cmd.xfer_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), 0, 0, CDRETRIES, 200000, NULL, 0); } @@ -1062,14 +1049,8 @@ cd_play_big(cd, blkno, nblks) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = PLAY_BIG; - scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff; - scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff; - scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff; - scsi_cmd.blk_addr[3] = blkno & 0xff; - scsi_cmd.xfer_len[0] = (nblks >> 24) & 0xff; - scsi_cmd.xfer_len[1] = (nblks >> 16) & 0xff; - scsi_cmd.xfer_len[2] = (nblks >> 8) & 0xff; - scsi_cmd.xfer_len[3] = nblks & 0xff; + _lto4b(blkno, scsi_cmd.blk_addr); + _lto4b(nblks, scsi_cmd.xfer_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), 0, 0, CDRETRIES, 20000, NULL, 0); } @@ -1163,8 +1144,7 @@ cd_read_subchannel(cd, mode, format, track, data, len) scsi_cmd.byte3 = SRS_SUBQ; scsi_cmd.subchan_format = format; scsi_cmd.track = track; - scsi_cmd.data_len[0] = (len >> 8) & 0xff; - scsi_cmd.data_len[1] = len & 0xff; + _lto2b(len, scsi_cmd.data_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(struct scsi_read_subchannel), (u_char *)data, len, CDRETRIES, 5000, NULL, SCSI_DATA_IN); @@ -1191,8 +1171,7 @@ cd_read_toc(cd, mode, start, data, len) if (mode == CD_MSF_FORMAT) scsi_cmd.byte2 |= CD_MSF; scsi_cmd.from_track = start; - scsi_cmd.data_len[0] = (ntoc >> 8) & 0xff; - scsi_cmd.data_len[1] = ntoc & 0xff; + _lto2b(ntoc, scsi_cmd.data_len); return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(struct scsi_read_toc), (u_char *)data, len, CDRETRIES, 5000, NULL, SCSI_DATA_IN); diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c index 125a4e918674..e1644af55edf 100644 --- a/sys/scsi/ch.c +++ b/sys/scsi/ch.c @@ -1,4 +1,4 @@ -/* $NetBSD: ch.c,v 1.17 1996/03/17 00:59:44 thorpej Exp $ */ +/* $NetBSD: ch.c,v 1.18 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -312,8 +312,7 @@ ch_getelem(ch, stat, type, from, data, flags) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = READ_ELEMENT_STATUS; scsi_cmd.byte2 = type; - scsi_cmd.starting_element_addr[0] = (from >> 8) & 0xff; - scsi_cmd.starting_element_addr[1] = from & 0xff; + _lto2b(from, scsi_cmd.starting_element_addr); scsi_cmd.number_of_elements[1] = 1; scsi_cmd.allocation_length[2] = 32; @@ -339,12 +338,9 @@ ch_move(ch, stat, chm, from, to, flags) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = MOVE_MEDIUM; - scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff; - scsi_cmd.transport_element_address[1] = chm & 0xff; - scsi_cmd.source_address[0] = (from >> 8) & 0xff; - scsi_cmd.source_address[1] = from & 0xff; - scsi_cmd.destination_address[0] = (to >> 8) & 0xff; - scsi_cmd.destination_address[1] = to & 0xff; + _lto2b(chm, scsi_cmd.transport_element_address); + _lto2b(from, scsi_cmd.source_address); + _lto2b(to, scsi_cmd.destination_address); scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0; error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd, sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags); @@ -366,10 +362,8 @@ ch_position(ch, stat, chm, to, flags) bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.opcode = POSITION_TO_ELEMENT; - scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff; - scsi_cmd.transport_element_address[1] = chm & 0xff; - scsi_cmd.source_address[0] = (to >> 8) & 0xff; - scsi_cmd.source_address[1] = to & 0xff; + _lto2b(chm, scsi_cmd.transport_element_address); + _lto2b(to, scsi_cmd.source_address); scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0; error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd, sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags); diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index 646826c872b4..81eeb7d9bd52 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_all.h,v 1.6 1994/12/28 19:42:54 mycroft Exp $ */ +/* $NetBSD: scsi_all.h,v 1.7 1996/03/19 03:05:15 mycroft Exp $ */ /* * SCSI general interface description @@ -229,58 +229,33 @@ struct scsi_inquiry_data { u_int8_t extra[8]; }; -/* - * This looks bad, and it is. However it fixes padding problems - * caused by using unions. This *needs* to be an array, if this code - * is to work on any architecture. - */ -struct scsi_sense_data { -/* 1*/ u_int8_t error_code; /* same bits as new version */ -#define XXX_unextended_blockhi extended_segment -#define XXX_unextended_blockmed extended_flags -#define XXX_unextended_blocklow extended_info[0] -/* 2*/ u_int8_t extended_segment; -/* 3*/ u_int8_t extended_flags; /* same bits as new version */ -/* 7*/ u_int8_t extended_info[4]; -/* 8*/ u_int8_t extended_extra_len; - /* - * allocate enough room to hold new stuff - * (by increasing 16 to 24 below) - */ -/*32*/ u_int8_t extended_extra_bytes[24]; -}; /* total of 32 bytes */ +struct scsi_sense_data_unextended { +/* 1*/ u_int8_t error_code; +/* 4*/ u_int8_t block[3]; +}; -struct scsi_sense_data_new { +struct scsi_sense_data { /* 1*/ u_int8_t error_code; #define SSD_ERRCODE 0x7F #define SSD_ERRCODE_VALID 0x80 - union { - struct { /* this is deprecated, the standard says "DON'T"*/ -/* 2*/ u_int8_t blockhi; -/* 3*/ u_int8_t blockmed; -/* 4*/ u_int8_t blocklow; - } unextended; - struct { -/* 2*/ u_int8_t segment; -/* 3*/ u_int8_t flags; +/* 2*/ u_int8_t segment; +/* 3*/ u_int8_t flags; #define SSD_KEY 0x0F #define SSD_ILI 0x20 #define SSD_EOM 0x40 #define SSD_FILEMARK 0x80 -/* 7*/ u_int8_t info[4]; -/* 8*/ u_int8_t extra_len; -/*12*/ u_int8_t cmd_spec_info[4]; -/*13*/ u_int8_t add_sense_code; -/*14*/ u_int8_t add_sense_code_qual; -/*15*/ u_int8_t fru; -/*16*/ u_int8_t sense_key_spec_1; -#define SSD_SCS_VALID 0x80 -/*17*/ u_int8_t sense_key_spec_2; -/*18*/ u_int8_t sense_key_spec_3; -/*32*/ u_int8_t extra_bytes[14]; - } extended; - } ext; -}; /* total of 32 bytes */ +/* 7*/ u_int8_t info[4]; +/* 8*/ u_int8_t extra_len; +/*12*/ u_int8_t cmd_spec_info[4]; +/*13*/ u_int8_t add_sense_code; +/*14*/ u_int8_t add_sense_code_qual; +/*15*/ u_int8_t fru; +/*16*/ u_int8_t sense_key_spec_1; +#define SSD_SCS_VALID 0x80 +/*17*/ u_int8_t sense_key_spec_2; +/*18*/ u_int8_t sense_key_spec_3; +/*32*/ u_int8_t extra_bytes[14]; +}; struct scsi_blk_desc { u_int8_t density; diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index b33da12ccb89..0b6ef6ef063e 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_base.c,v 1.33 1996/02/14 21:47:14 christos Exp $ */ +/* $NetBSD: scsi_base.c,v 1.34 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles Hannum. All rights reserved. @@ -194,7 +194,6 @@ scsi_size(sc_link, flags) { struct scsi_read_cap_data rdcap; struct scsi_read_capacity scsi_cmd; - u_long size; /* * make up a scsi command and ask the scsi driver to do @@ -213,13 +212,9 @@ scsi_size(sc_link, flags) sc_print_addr(sc_link); printf("could not get size\n"); return 0; - } else { - size = rdcap.addr_0 + 1; - size += rdcap.addr_1 << 8; - size += rdcap.addr_2 << 16; - size += rdcap.addr_3 << 24; } - return size; + + return _4btol(rdcap.addr) + 1; } /* @@ -625,20 +620,20 @@ scsi_interpret_sense(xs) sense->error_code & SSD_ERRCODE, sense->error_code & SSD_ERRCODE_VALID ? 1 : 0); printf("seg%x key%x ili%x eom%x fmark%x\n", - sense->extended_segment, - sense->extended_flags & SSD_KEY, - sense->extended_flags & SSD_ILI ? 1 : 0, - sense->extended_flags & SSD_EOM ? 1 : 0, - sense->extended_flags & SSD_FILEMARK ? 1 : 0); + sense->segment, + sense->flags & SSD_KEY, + sense->flags & SSD_ILI ? 1 : 0, + sense->flags & SSD_EOM ? 1 : 0, + sense->flags & SSD_FILEMARK ? 1 : 0); printf("info: %x %x %x %x followed by %d extra bytes\n", - sense->extended_info[0], - sense->extended_info[1], - sense->extended_info[2], - sense->extended_info[3], - sense->extended_extra_len); + sense->info[0], + sense->info[1], + sense->info[2], + sense->info[3], + sense->extra_len); printf("extra: "); - for (count = 0; count < sense->extended_extra_len; count++) - printf("%x ", sense->extended_extra_bytes[count]); + for (count = 0; count < sense->extra_len; count++) + printf("%x ", sense->extra_bytes[count]); printf("\n"); } #endif /*SCSIDEBUG */ @@ -660,15 +655,14 @@ scsi_interpret_sense(xs) */ case 0x71: /* delayed error */ sc_print_addr(sc_link); - key = sense->extended_flags & SSD_KEY; + key = sense->flags & SSD_KEY; printf(" DELAYED ERROR, key = 0x%x\n", key); case 0x70: - if ((sense->error_code & SSD_ERRCODE_VALID) != 0) { - bcopy(sense->extended_info, &info, sizeof info); - info = ntohl(info); - } else + if ((sense->error_code & SSD_ERRCODE_VALID) != 0) + info = _4btol(sense->info); + else info = 0; - key = sense->extended_flags & SSD_KEY; + key = sense->flags & SSD_KEY; switch (key) { case 0x0: /* NO SENSE */ @@ -744,11 +738,11 @@ scsi_interpret_sense(xs) printf(", info = %d (decimal)", info); } } - if (sense->extended_extra_len != 0) { + if (sense->extra_len != 0) { int n; printf(", data ="); - for (n = 0; n < sense->extended_extra_len; n++) - printf(" %02x", sense->extended_extra_bytes[n]); + for (n = 0; n < sense->extra_len; n++) + printf(" %02x", sense->extra_bytes[n]); } printf("\n"); } @@ -762,10 +756,10 @@ scsi_interpret_sense(xs) printf("error code %d", sense->error_code & SSD_ERRCODE); if ((sense->error_code & SSD_ERRCODE_VALID) != 0) { + struct scsi_sense_data_unextended *usense = + (struct scsi_sense_data_unextended *)sense; printf(" at block no. %d (decimal)", - (sense->XXX_unextended_blockhi << 16) + - (sense->XXX_unextended_blockmed << 8) + - (sense->XXX_unextended_blocklow)); + _3btol(usense->block)); } printf("\n"); return EIO; @@ -776,36 +770,6 @@ scsi_interpret_sense(xs) * Utility routines often used in SCSI stuff */ -/* - * convert a physical address to 3 bytes, - * MSB at the lowest address, - * LSB at the highest. - */ -void -lto3b(val, bytes) - u_int32_t val; - u_int8_t *bytes; -{ - - *bytes++ = (val >> 16) & 0xff; - *bytes++ = (val >> 8) & 0xff; - *bytes = val & 0xff; -} - -/* - * The reverse of lto3b - */ -u_int32_t -_3btol(bytes) - u_int8_t *bytes; -{ - u_int32_t rc; - - rc = (*bytes++ << 16); - rc += (*bytes++ << 8); - rc += *bytes; - return (rc); -} /* * Print out the scsi_link structure's address info. diff --git a/sys/scsi/scsi_cd.h b/sys/scsi/scsi_cd.h index bbd15676e981..526ef5eaae7f 100644 --- a/sys/scsi/scsi_cd.h +++ b/sys/scsi/scsi_cd.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_cd.h,v 1.5 1994/12/28 19:42:58 mycroft Exp $ */ +/* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:05:15 mycroft Exp $ */ /* * Written by Julian Elischer (julian@tfs.com) @@ -31,117 +31,111 @@ struct scsi_read_capacity_cd { u_int8_t opcode; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_pause { - u_char opcode; - u_char byte2; - u_char unused[6]; - u_char resume; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[6]; + u_int8_t resume; + u_int8_t control; }; #define PA_PAUSE 1 #define PA_RESUME 0 struct scsi_play_msf { - u_char opcode; - u_char byte2; - u_char unused; - u_char start_m; - u_char start_s; - u_char start_f; - u_char end_m; - u_char end_s; - u_char end_f; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused; + u_int8_t start_m; + u_int8_t start_s; + u_int8_t start_f; + u_int8_t end_m; + u_int8_t end_s; + u_int8_t end_f; + u_int8_t control; }; struct scsi_play_track { - u_char opcode; - u_char byte2; - u_char unused[2]; - u_char start_track; - u_char start_index; - u_char unused1; - u_char end_track; - u_char end_index; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t start_track; + u_int8_t start_index; + u_int8_t unused1; + u_int8_t end_track; + u_int8_t end_index; + u_int8_t control; }; struct scsi_play { - u_char opcode; - u_char byte2; - u_char blk_addr[4]; - u_char unused; - u_char xfer_len[2]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t blk_addr[4]; + u_int8_t unused; + u_int8_t xfer_len[2]; + u_int8_t control; }; struct scsi_play_big { - u_char opcode; - u_char byte2; /* same as above */ - u_char blk_addr[4]; - u_char xfer_len[4]; - u_char unused; - u_char control; + u_int8_t opcode; + u_int8_t byte2; /* same as above */ + u_int8_t blk_addr[4]; + u_int8_t xfer_len[4]; + u_int8_t unused; + u_int8_t control; }; struct scsi_play_rel_big { - u_char opcode; - u_char byte2; /* same as above */ - u_char blk_addr[4]; - u_char xfer_len[4]; - u_char track; - u_char control; + u_int8_t opcode; + u_int8_t byte2; /* same as above */ + u_int8_t blk_addr[4]; + u_int8_t xfer_len[4]; + u_int8_t track; + u_int8_t control; }; struct scsi_read_header { - u_char opcode; - u_char byte2; - u_char blk_addr[4]; - u_char unused; - u_char data_len[2]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t blk_addr[4]; + u_int8_t unused; + u_int8_t data_len[2]; + u_int8_t control; }; struct scsi_read_subchannel { - u_char opcode; - u_char byte2; - u_char byte3; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t byte3; #define SRS_SUBQ 0x40 - u_char subchan_format; - u_char unused[2]; - u_char track; - u_char data_len[2]; - u_char control; + u_int8_t subchan_format; + u_int8_t unused[2]; + u_int8_t track; + u_int8_t data_len[2]; + u_int8_t control; }; struct scsi_read_toc { - u_char opcode; - u_char byte2; - u_char unused[4]; - u_char from_track; - u_char data_len[2]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[4]; + u_int8_t from_track; + u_int8_t data_len[2]; + u_int8_t control; }; ; struct scsi_read_cd_capacity { - u_char opcode; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; }; /* @@ -162,33 +156,27 @@ struct scsi_read_cd_capacity { struct scsi_read_cd_cap_data { - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least significant */ - u_char length_3; /* Most significant */ - u_char length_2; - u_char length_1; - u_char length_0; /* Least significant */ + u_int8_t addr[4]; + u_int8_t length[4]; }; union cd_pages { struct audio_page { - u_char page_code; + u_int8_t page_code; #define CD_PAGE_CODE 0x3F #define AUDIO_PAGE 0x0e #define CD_PAGE_PS 0x80 - u_char param_len; - u_char flags; + u_int8_t param_len; + u_int8_t flags; #define CD_PA_SOTC 0x02 #define CD_PA_IMMED 0x04 - u_char unused[2]; - u_char format_lba; + u_int8_t unused[2]; + u_int8_t format_lba; #define CD_PA_FORMAT_LBA 0x0F #define CD_PA_APR_VALID 0x80 - u_char lb_per_sec[2]; + u_int8_t lb_per_sec[2]; struct port_control { - u_char channels; + u_int8_t channels; #define CHANNEL 0x0F #define CHANNEL_0 1 #define CHANNEL_1 2 @@ -196,7 +184,7 @@ union cd_pages { #define CHANNEL_3 8 #define LEFT_CHANNEL CHANNEL_0 #define RIGHT_CHANNEL CHANNEL_1 - u_char volume; + u_int8_t volume; } port[4]; #define LEFT_PORT 0 #define RIGHT_PORT 1 diff --git a/sys/scsi/scsi_changer.h b/sys/scsi/scsi_changer.h index 5161ce8e1664..677237e6a046 100644 --- a/sys/scsi/scsi_changer.h +++ b/sys/scsi/scsi_changer.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_changer.h,v 1.5 1994/12/28 19:42:59 mycroft Exp $ */ +/* $NetBSD: scsi_changer.h,v 1.6 1996/03/19 03:05:15 mycroft Exp $ */ /* * SCSI changer interface description @@ -28,16 +28,16 @@ * SCSI command format */ struct scsi_read_element_status { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRES_ELEM_TYPE_CODE 0x0F #define SRES_ELEM_VOLTAG 0x10 - u_char starting_element_addr[2]; - u_char number_of_elements[2]; - u_char resv1; - u_char allocation_length[3]; - u_char resv2; - u_char control; + u_int8_t starting_element_addr[2]; + u_int8_t number_of_elements[2]; + u_int8_t resv1; + u_int8_t allocation_length[3]; + u_int8_t resv2; + u_int8_t control; }; #define RE_ALL_ELEMENTS 0 #define RE_MEDIUM_TRANSPORT_ELEMENT 1 @@ -46,24 +46,24 @@ struct scsi_read_element_status { #define RE_DATA_TRANSFER_ELEMENT 4 struct scsi_move_medium { - u_char opcode; - u_char byte2; - u_char transport_element_address[2]; - u_char source_address[2]; - u_char destination_address[2]; - u_char rsvd[2]; - u_char invert; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t transport_element_address[2]; + u_int8_t source_address[2]; + u_int8_t destination_address[2]; + u_int8_t rsvd[2]; + u_int8_t invert; + u_int8_t control; }; struct scsi_position_to_element { - u_char opcode; - u_char byte2; - u_char transport_element_address[2]; - u_char source_address[2]; - u_char rsvd[2]; - u_char invert; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t transport_element_address[2]; + u_int8_t source_address[2]; + u_int8_t rsvd[2]; + u_int8_t invert; + u_int8_t control; }; /* @@ -74,20 +74,20 @@ struct scsi_position_to_element { #define READ_ELEMENT_STATUS 0xb8 struct scsi_element_status_data { - u_char first_element_reported[2]; - u_char number_of_elements_reported[2]; - u_char rsvd; - u_char byte_count_of_report[3]; + u_int8_t first_element_reported[2]; + u_int8_t number_of_elements_reported[2]; + u_int8_t rsvd; + u_int8_t byte_count_of_report[3]; }; struct element_status_page { - u_char element_type_code; - u_char flags; + u_int8_t element_type_code; + u_int8_t flags; #define ESP_AVOLTAG 0x40 #define ESP_PVOLTAG 0x80 - u_char element_descriptor_length[2]; - u_char rsvd; - u_char byte_count_of_descriptor_data[3]; + u_int8_t element_descriptor_length[2]; + u_int8_t rsvd; + u_int8_t byte_count_of_descriptor_data[3]; }; #endif /* _SCSI_SCSI_CHANGER_H */ diff --git a/sys/scsi/scsi_disk.h b/sys/scsi/scsi_disk.h index 3b3e3350c886..fd09456a5cf3 100644 --- a/sys/scsi/scsi_disk.h +++ b/sys/scsi/scsi_disk.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_disk.h,v 1.8 1995/10/15 23:32:02 thorpej Exp $ */ +/* $NetBSD: scsi_disk.h,v 1.9 1996/03/19 03:05:15 mycroft Exp $ */ /* * SCSI interface description @@ -57,56 +57,47 @@ #define _SCSI_SCSI_DISK_H 1 struct scsi_reassign_blocks { - u_char opcode; - u_char byte2; - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_rw { - u_char opcode; - u_char addr_2; /* Most significant */ + u_int8_t opcode; + u_int8_t addr[3]; #define SRW_TOPADDR 0x1F /* only 5 bits here */ - u_char addr_1; - u_char addr_0; /* least significant */ - u_char length; - u_char control; + u_int8_t length; + u_int8_t control; }; struct scsi_rw_big { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRWB_RELADDR 0x01 - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* least significant */ - u_char reserved; - u_char length2; - u_char length1; - u_char control; + u_int8_t addr[4]; + u_int8_t reserved; + u_int8_t length[2]; + u_int8_t control; }; struct scsi_read_capacity { - u_char opcode; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t addr[4]; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_start_stop { - u_char opcode; - u_char byte2; - u_char unused[2]; - u_char how; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t how; #define SSS_STOP 0x00 #define SSS_START 0x01 #define SSS_LOEJ 0x02 - u_char control; + u_int8_t control; }; @@ -128,89 +119,60 @@ struct scsi_start_stop { struct scsi_read_cap_data { - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least significant */ - u_char length_3; /* Most significant */ - u_char length_2; - u_char length_1; - u_char length_0; /* Least significant */ + u_int8_t addr[4]; + u_int8_t length[4]; }; struct scsi_reassign_blocks_data { - u_char reserved[2]; - u_char length_msb; - u_char length_lsb; + u_int8_t reserved[2]; + u_int8_t length[2]; struct { - u_char dlbaddr_3; /* defect logical block address (MSB) */ - u_char dlbaddr_2; - u_char dlbaddr_1; - u_char dlbaddr_0; /* defect logical block address (LSB) */ + u_int8_t dlbaddr[4]; } defect_descriptor[1]; }; -union disk_pages { /* this is the structure copied from osf */ - struct page_disk_format { - u_char pg_code; /* page code (should be 3) */ +union disk_pages { #define DISK_PGCODE 0x3F /* only 6 bits valid */ - u_char pg_length; /* page length (should be 0x16) */ - u_char trk_z_1; /* tracks per zone (MSB) */ - u_char trk_z_0; /* tracks per zone (LSB) */ - u_char alt_sec_1; /* alternate sectors per zone (MSB) */ - u_char alt_sec_0; /* alternate sectors per zone (LSB) */ - u_char alt_trk_z_1; /* alternate tracks per zone (MSB) */ - u_char alt_trk_z_0; /* alternate tracks per zone (LSB) */ - u_char alt_trk_v_1; /* alternate tracks per volume (MSB) */ - u_char alt_trk_v_0; /* alternate tracks per volume (LSB) */ - u_char ph_sec_t_1; /* physical sectors per track (MSB) */ - u_char ph_sec_t_0; /* physical sectors per track (LSB) */ - u_char bytes_s_1; /* bytes per sector (MSB) */ - u_char bytes_s_0; /* bytes per sector (LSB) */ - u_char interleave_1;/* interleave (MSB) */ - u_char interleave_0;/* interleave (LSB) */ - u_char trk_skew_1; /* track skew factor (MSB) */ - u_char trk_skew_0; /* track skew factor (LSB) */ - u_char cyl_skew_1; /* cylinder skew (MSB) */ - u_char cyl_skew_0; /* cylinder skew (LSB) */ - u_char flags; /* various */ -#define DISK_FMT_SURF 0x10 -#define DISK_FMT_RMB 0x20 -#define DISK_FMT_HSEC 0x40 -#define DISK_FMT_SSEC 0x80 - u_char reserved2; - u_char reserved3; + struct page_disk_format { + u_int8_t pg_code; /* page code (should be 3) */ + u_int8_t pg_length; /* page length (should be 0x16) */ + u_int8_t trk_z[2]; /* tracks per zone */ + u_int8_t alt_sec[2]; /* alternate sectors per zone */ + u_int8_t alt_trk_z[2]; /* alternate tracks per zone */ + u_int8_t alt_trk_v[2]; /* alternate tracks per volume */ + u_int8_t ph_sec_t[2]; /* physical sectors per track */ + u_int8_t bytes_s[2]; /* bytes per sector */ + u_int8_t interleave[2]; /* interleave */ + u_int8_t trk_skew[2]; /* track skew factor */ + u_int8_t cyl_skew[2]; /* cylinder skew */ + u_int8_t flags; /* various */ +#define DISK_FMT_SURF 0x10 +#define DISK_FMT_RMB 0x20 +#define DISK_FMT_HSEC 0x40 +#define DISK_FMT_SSEC 0x80 + u_int8_t reserved2; + u_int8_t reserved3; } disk_format; struct page_rigid_geometry { - u_char pg_code; /* page code (should be 4) */ - u_char pg_length; /* page length (should be 0x16) */ - u_char ncyl_2; /* number of cylinders (MSB) */ - u_char ncyl_1; /* number of cylinders */ - u_char ncyl_0; /* number of cylinders (LSB) */ - u_char nheads; /* number of heads */ - u_char st_cyl_wp_2; /* starting cyl., write precomp (MSB) */ - u_char st_cyl_wp_1; /* starting cyl., write precomp */ - u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */ - u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/ - u_char st_cyl_rwc_1;/* starting cyl., red. write cur */ - u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/ - u_char driv_step_1; /* drive step rate (MSB) */ - u_char driv_step_0; /* drive step rate (LSB) */ - u_char land_zone_2; /* landing zone cylinder (MSB) */ - u_char land_zone_1; /* landing zone cylinder */ - u_char land_zone_0; /* landing zone cylinder (LSB) */ - u_char sp_sync_ctl; /* spindle synch control */ + u_int8_t pg_code; /* page code (should be 4) */ + u_int8_t pg_length; /* page length (should be 0x16) */ + u_int8_t ncyl[3]; /* number of cylinders */ + u_int8_t nheads; /* number of heads */ + u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */ + u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */ + u_int8_t driv_step[2]; /* drive step rate */ + u_int8_t land_zone[3]; /* landing zone cylinder */ + u_int8_t sp_sync_ctl; /* spindle synch control */ #define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */ #define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */ #define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */ #define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */ #define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */ - u_char rot_offset; /* rotational offset (for spindle synch) */ - u_char reserved1; - u_char rpm_1; /* media rotation speed (MSB) */ - u_char rpm_0; /* media rotation speed (LSB) */ - u_char reserved2; - u_char reserved3; + u_int8_t rot_offset; /* rotational offset (for spindle synch) */ + u_int8_t reserved1; + u_int8_t rpm[2]; /* media rotation speed */ + u_int8_t reserved2; + u_int8_t reserved3; } rigid_geometry; }; diff --git a/sys/scsi/scsi_scanner.h b/sys/scsi/scsi_scanner.h index 0db8028c2f69..7ea6985c44f0 100644 --- a/sys/scsi/scsi_scanner.h +++ b/sys/scsi/scsi_scanner.h @@ -47,62 +47,62 @@ struct scsi_rw_scanner { #define READ 0x08 #define WRITE 0x0a - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRW_FIXED 0x01 - u_char len[3]; - u_char control; + u_int8_t len[3]; + u_int8_t control; }; struct scsi_start_stop { - u_char opcode; - u_char byte2; - u_char unused[2]; - u_char how; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[2]; + u_int8_t how; #define SSS_STOP 0x00 #define SSS_START 0x01 #define SSS_LOEJ 0x02 - u_char control; + u_int8_t control; }; struct scsi_set_window { #define SET_WINDOW 0x24 /* set params of image area and windows */ #define GET_WINDOW 0x25 - u_char opcode; - u_char byte2; - u_char reserved[4]; - u_char len[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t reserved[4]; + u_int8_t len[3]; + u_int8_t control; }; struct scsi_window_header { - u_char reserved[6]; - u_char len[2]; /* MSB-LSB */ + u_int8_t reserved[6]; + u_int8_t len[2]; }; struct scsi_window_data { - u_char window_id; /* must be zero */ - u_char res1:7; - u_char auto_bit:1; - u_char x_res[2]; - u_char y_res[2]; - u_char x_org[4]; - u_char y_org[4]; - u_char width[4]; - u_char length[4]; - u_char brightness; - u_char threshold; - u_char contrast; - u_char image_comp; /* image composition (data type) */ - u_char bits_per_pixel; - u_char halftone_pattern[2]; - u_char rif:1; /* reverse image format (mono negative) */ - u_char res2:4; - u_char pad_type:3; - u_char bit_ordering[2]; - u_char compression_type; - u_char compression_arg; - u_char res3[6]; + u_int8_t window_id; /* must be zero */ + u_int8_t res1:7; + u_int8_t auto_bit:1; + u_int8_t x_res[2]; + u_int8_t y_res[2]; + u_int8_t x_org[4]; + u_int8_t y_org[4]; + u_int8_t width[4]; + u_int8_t length[4]; + u_int8_t brightness; + u_int8_t threshold; + u_int8_t contrast; + u_int8_t image_comp; /* image composition (data type) */ + u_int8_t bits_per_pixel; + u_int8_t halftone_pattern[2]; + u_int8_t rif:1; /* reverse image format (mono negative) */ + u_int8_t res2:4; + u_int8_t pad_type:3; + u_int8_t bit_ordering[2]; + u_int8_t compression_type; + u_int8_t compression_arg; + u_int8_t res3[6]; }; /* mustek scsi commands */ diff --git a/sys/scsi/scsi_tape.h b/sys/scsi/scsi_tape.h index 654b02ac7ec1..eaaf276bc6c0 100644 --- a/sys/scsi/scsi_tape.h +++ b/sys/scsi/scsi_tape.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_tape.h,v 1.7 1996/01/11 03:36:34 thorpej Exp $ */ +/* $NetBSD: scsi_tape.h,v 1.8 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -60,97 +60,93 @@ #define READ 0x08 #define WRITE 0x0a struct scsi_rw_tape { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SRW_FIXED 0x01 - u_char len[3]; - u_char control; + u_int8_t len[3]; + u_int8_t control; }; #define SPACE 0x11 struct scsi_space { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SS_CODE 0x03 #define SP_BLKS 0x00 #define SP_FILEMARKS 0x01 #define SP_SEQ_FILEMARKS 0x02 #define SP_EOM 0x03 - u_char number[3]; - u_char control; + u_int8_t number[3]; + u_int8_t control; }; #define WRITE_FILEMARKS 0x10 struct scsi_write_filemarks { - u_char opcode; - u_char byte2; - u_char number[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t number[3]; + u_int8_t control; }; #define REWIND 0x01 struct scsi_rewind { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SR_IMMED 0x01 - u_char unused[3]; - u_char control; + u_int8_t unused[3]; + u_int8_t control; }; #define LOAD 0x1b struct scsi_load { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SL_IMMED 0x01 - u_char unused[2]; - u_char how; + u_int8_t unused[2]; + u_int8_t how; #define LD_UNLOAD 0x00 #define LD_LOAD 0x01 #define LD_RETENSION 0x02 - u_char control; + u_int8_t control; }; #define ERASE 0x19 struct scsi_erase { - u_char opcode; - u_char byte2; + u_int8_t opcode; + u_int8_t byte2; #define SE_LONG 0x01 #define SE_IMMED 0x02 - u_char unused[3]; - u_char control; + u_int8_t unused[3]; + u_int8_t control; }; #define READ_BLOCK_LIMITS 0x05 struct scsi_block_limits { - u_char opcode; - u_char byte2; - u_char unused[3]; - u_char control; + u_int8_t opcode; + u_int8_t byte2; + u_int8_t unused[3]; + u_int8_t control; }; struct scsi_block_limits_data { - u_char reserved; - u_char max_length_2; /* Most significant */ - u_char max_length_1; - u_char max_length_0; /* Least significant */ - u_char min_length_1; /* Most significant */ - u_char min_length_0; /* Least significant */ + u_int8_t reserved; + u_int8_t max_length[3]; /* Most significant */ + u_int8_t min_length[2]; /* Most significant */ }; /* See SCSI-II spec 9.3.3.1 */ struct scsi_tape_dev_conf_page { - u_char pagecode; /* 0x10 */ - u_char pagelength; /* 0x0e */ - u_char byte2; + u_int8_t pagecode; /* 0x10 */ + u_int8_t pagelength; /* 0x0e */ + u_int8_t byte2; #define SMT_CAP 0x40 /* change active partition */ #define SMT_CAF 0x20 /* change active format */ #define SMT_AFMASK 0x1f /* active format mask */ - u_char active_partition; - u_char wb_full_ratio; - u_char rb_empty_ratio; - u_char wrdelay_time_1; /* MSB */ - u_char wrdelay_time_0; /* LSB */ - u_char byte8; + u_int8_t active_partition; + u_int8_t wb_full_ratio; + u_int8_t rb_empty_ratio; + u_int8_t wrdelay_time[2]; + u_int8_t byte8; #define SMT_DBR 0x80 /* data buffer recovery */ #define SMT_BIS 0x40 /* block identifiers supported */ #define SMT_RSMK 0x20 /* report setmarks */ @@ -158,18 +154,16 @@ struct scsi_tape_dev_conf_page { #define SMT_SOCF_MASK 0xc0 /* stop on consecutive formats */ #define SMT_RBO 0x20 /* recover buffer order */ #define SMT_REW 0x10 /* report early warning */ - u_char gap_size; - u_char byte10; + u_int8_t gap_size; + u_int8_t byte10; #define SMT_EODDEFINED 0xe0 /* EOD defined */ #define SMT_EEG 0x10 /* enable EOD generation */ #define SMT_SEW 0x80 /* synchronize at early warning */ - u_char ew_bufsize_2; /* MSB */ - u_char ew_bufsize_1; /* ... */ - u_char ew_bufsize_0; /* LSB */ - u_char sel_comp_alg; + u_int8_t ew_bufsize[3]; + u_int8_t sel_comp_alg; #define SMT_COMP_NONE 0x00 #define SMT_COMP_DEFAULT 0x01 - u_char reserved; + u_int8_t reserved; }; /* defines for the device specific byte in the mode select/sense header */ @@ -182,11 +176,11 @@ struct scsi_tape_dev_conf_page { /* A special for the CIPHER ST150S(old drive) */ struct block_desc_cipher { - u_char density; - u_char nblocks[3]; - u_char reserved; - u_char blklen[3]; - u_char other; + u_int8_t density; + u_int8_t nblocks[3]; + u_int8_t reserved; + u_int8_t blklen[3]; + u_int8_t other; #define ST150_SEC 0x01 /* soft error count */ #define SR150_AUI 0x02 /* autoload inhibit */ }; diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index efda1dde6bf1..dc94894f8bd1 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.h,v 1.28 1996/02/18 20:32:45 mycroft Exp $ */ +/* $NetBSD: scsiconf.h,v 1.29 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved. @@ -288,8 +288,156 @@ void show_mem __P((u_char *, int)); int scsi_probe_busses __P((int, int, int)); void scsi_strvis __P((u_char *, u_char *, int)); +static __inline void _lto2b __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto3b __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto4b __P((u_int32_t val, u_int8_t *bytes)); +static __inline u_int32_t _2btol __P((u_int8_t *bytes)); +static __inline u_int32_t _3btol __P((u_int8_t *bytes)); +static __inline u_int32_t _4btol __P((u_int8_t *bytes)); -void lto3b __P((u_int32_t val, u_int8_t *bytes)); -u_int32_t _3btol __P((u_int8_t *bytes)); +static __inline void _lto2l __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto3l __P((u_int32_t val, u_int8_t *bytes)); +static __inline void _lto4l __P((u_int32_t val, u_int8_t *bytes)); +static __inline u_int32_t _2ltol __P((u_int8_t *bytes)); +static __inline u_int32_t _3ltol __P((u_int8_t *bytes)); +static __inline u_int32_t _4ltol __P((u_int8_t *bytes)); + +static __inline void +_lto2b(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = (val >> 8) & 0xff; + bytes[1] = val & 0xff; +} + +static __inline void +_lto3b(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = (val >> 16) & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = val & 0xff; +} + +static __inline void +_lto4b(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = (val >> 24) & 0xff; + bytes[1] = (val >> 16) & 0xff; + bytes[2] = (val >> 8) & 0xff; + bytes[3] = val & 0xff; +} + +static __inline u_int32_t +_2btol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = (bytes[0] << 8) | + bytes[1]; + return (rv); +} + +static __inline u_int32_t +_3btol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = (bytes[0] << 16) | + (bytes[1] << 8) | + bytes[2]; + return (rv); +} + +static __inline u_int32_t +_4btol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = (bytes[0] << 24) | + (bytes[1] << 16) | + (bytes[2] << 8) | + bytes[3]; + return (rv); +} + +static __inline void +_lto2l(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; +} + +static __inline void +_lto3l(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; +} + +static __inline void +_lto4l(val, bytes) + u_int32_t val; + u_int8_t *bytes; +{ + + bytes[0] = val & 0xff; + bytes[1] = (val >> 8) & 0xff; + bytes[2] = (val >> 16) & 0xff; + bytes[3] = (val >> 24) & 0xff; +} + +static __inline u_int32_t +_2ltol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8); + return (rv); +} + +static __inline u_int32_t +_3ltol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8) | + (bytes[2] << 16); + return (rv); +} + +static __inline u_int32_t +_4ltol(bytes) + u_int8_t *bytes; +{ + register u_int32_t rv; + + rv = bytes[0] | + (bytes[1] << 8) | + (bytes[2] << 16) | + (bytes[3] << 24); + return (rv); +} #endif /* SCSI_SCSICONF_H */ diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 6125fd68a924..d22ff46cef73 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.90 1996/03/17 02:06:50 pk Exp $ */ +/* $NetBSD: sd.c,v 1.91 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -106,7 +106,6 @@ void sdminphys __P((struct buf *)); void sdgetdisklabel __P((struct sd_softc *)); void sdstart __P((void *)); int sddone __P((struct scsi_xfer *, int)); -u_long sd_size __P((struct sd_softc *, int)); int sd_reassign_blocks __P((struct sd_softc *, u_long)); int sd_get_parms __P((struct sd_softc *, int)); @@ -569,9 +568,7 @@ sdstart(v) bzero(&cmd_small, sizeof(cmd_small)); cmd_small.opcode = (bp->b_flags & B_READ) ? READ_COMMAND : WRITE_COMMAND; - cmd_small.addr_2 = (blkno >> 16) & 0x1f; - cmd_small.addr_1 = (blkno >> 8) & 0xff; - cmd_small.addr_0 = blkno & 0xff; + _lto3b(blkno, cmd_small.addr); cmd_small.length = nblks & 0xff; cmdlen = sizeof(cmd_small); cmdp = (struct scsi_generic *)&cmd_small; @@ -582,12 +579,8 @@ sdstart(v) bzero(&cmd_big, sizeof(cmd_big)); cmd_big.opcode = (bp->b_flags & B_READ) ? READ_BIG : WRITE_BIG; - cmd_big.addr_3 = (blkno >> 24) & 0xff; - cmd_big.addr_2 = (blkno >> 16) & 0xff; - cmd_big.addr_1 = (blkno >> 8) & 0xff; - cmd_big.addr_0 = blkno & 0xff; - cmd_big.length2 = (nblks >> 8) & 0xff; - cmd_big.length1 = nblks & 0xff; + _lto4b(blkno, cmd_big.addr); + _lto2b(nblks, cmd_big.length); cmdlen = sizeof(cmd_big); cmdp = (struct scsi_generic *)&cmd_big; } @@ -805,47 +798,13 @@ sdgetdisklabel(sd) } } -/* - * Find out from the device what it's capacity is - */ -u_long -sd_size(sd, flags) - struct sd_softc *sd; - int flags; -{ - struct scsi_read_cap_data rdcap; - struct scsi_read_capacity scsi_cmd; - u_long size; - - /* - * make up a scsi command and ask the scsi driver to do - * it for you. - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.opcode = READ_CAPACITY; - - /* - * If the command works, interpret the result as a 4 byte - * number of blocks - */ - if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), SDRETRIES, - 2000, NULL, flags | SCSI_DATA_IN) != 0) - return 0; - - size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) + - (rdcap.addr_1 << 8) + rdcap.addr_0 + 1; - - return size; -} - /* * Tell the device to map out a defective block */ int -sd_reassign_blocks(sd, block) +sd_reassign_blocks(sd, blkno) struct sd_softc *sd; - u_long block; + u_long blkno; { struct scsi_reassign_blocks scsi_cmd; struct scsi_reassign_blocks_data rbdata; @@ -854,20 +813,14 @@ sd_reassign_blocks(sd, block) bzero(&rbdata, sizeof(rbdata)); scsi_cmd.opcode = REASSIGN_BLOCKS; - rbdata.length_msb = 0; - rbdata.length_lsb = sizeof(rbdata.defect_descriptor[0]); - rbdata.defect_descriptor[0].dlbaddr_3 = (block >> 24) & 0xff; - rbdata.defect_descriptor[0].dlbaddr_2 = (block >> 16) & 0xff; - rbdata.defect_descriptor[0].dlbaddr_1 = (block >> 8) & 0xff; - rbdata.defect_descriptor[0].dlbaddr_0 = block & 0xff; + _lto2b(sizeof(rbdata.defect_descriptor[0]), rbdata.length); + _lto4b(blkno, rbdata.defect_descriptor[0].dlbaddr); return scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), SDRETRIES, 5000, NULL, SCSI_DATA_OUT); } -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 ) - /* * Get the scsi driver to send a full inquiry to the * device and use the * results to fill out the disk parameter structure. @@ -908,7 +861,7 @@ sd_get_parms(sd, flags) * this depends on which controller (e.g. 1542C is * different. but we have to put SOMETHING here..) */ - sectors = sd_size(sd, flags); + sectors = scsi_size(sd->sc_link, flags); dp->heads = 64; dp->sectors = 32; dp->cyls = sectors / (64 * 32); @@ -919,9 +872,9 @@ sd_get_parms(sd, flags) ("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n", _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2), scsi_sense.pages.rigid_geometry.nheads, - b2tol(scsi_sense.pages.rigid_geometry.st_cyl_wp), - b2tol(scsi_sense.pages.rigid_geometry.st_cyl_rwc), - b2tol(scsi_sense.pages.rigid_geometry.land_zone))); + _2btol(scsi_sense.pages.rigid_geometry.st_cyl_wp), + _2btol(scsi_sense.pages.rigid_geometry.st_cyl_rwc), + _2btol(scsi_sense.pages.rigid_geometry.land_zone))); /* * KLUDGE!! (for zone recorded disks) @@ -930,8 +883,7 @@ sd_get_parms(sd, flags) * can lead to wasted space! THINK ABOUT THIS ! */ dp->heads = scsi_sense.pages.rigid_geometry.nheads; - dp->cyls = - _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2); + dp->cyls = _3btol(scsi_sense.pages.rigid_geometry.ncyl); dp->blksize = _3btol(scsi_sense.blk_desc.blklen); if (dp->heads == 0 || dp->cyls == 0) { @@ -943,7 +895,7 @@ sd_get_parms(sd, flags) if (dp->blksize == 0) dp->blksize = 512; - sectors = sd_size(sd, flags); + sectors = scsi_size(sd->sc_link, flags); dp->disksize = sectors; sectors /= (dp->heads * dp->cyls); dp->sectors = sectors; /* XXX dubious on SCSI */ @@ -1047,12 +999,8 @@ sddump(dev, blkno, va, size) */ bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE_BIG; - cmd.addr_3 = (blkno >> 24) & 0xff; - cmd.addr_2 = (blkno >> 16) & 0xff; - cmd.addr_1 = (blkno >> 8) & 0xff; - cmd.addr_0 = blkno & 0xff; - cmd.length2 = (nwrt >> 8) & 0xff; - cmd.length1 = nwrt & 0xff; + _lto4b(blkno, cmd.addr); + _lto2b(nwrt, cmd.length); /* * Fill out the scsi_xfer structure * Note: we cannot sleep as we may be an interrupt diff --git a/sys/scsi/ss_mustek.c b/sys/scsi/ss_mustek.c index 7be6628fe01f..02249389039c 100644 --- a/sys/scsi/ss_mustek.c +++ b/sys/scsi/ss_mustek.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss_mustek.c,v 1.1 1996/02/18 20:32:47 mycroft Exp $ */ +/* $NetBSD: ss_mustek.c,v 1.2 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved. @@ -277,9 +277,7 @@ mustek_trigger_scanner(ss) struct mustek_set_window_data window_data; struct mustek_start_scan_cmd start_scan_cmd; struct scsi_link *sc_link = ss->sc_link; -#ifndef MUSTEK_INCH_SPEC int pixel_tlx, pixel_tly, pixel_brx, pixel_bry, paperlength; -#endif int error; mustek_compute_sizes(ss); @@ -294,46 +292,29 @@ mustek_trigger_scanner(ss) window_cmd.length = sizeof(window_data); bzero(&window_data, sizeof(window_data)); - window_data.frame_header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC; + window_data.frame.header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC; #ifdef MUSTEK_INCH_SPEC /* the positional values are all 1 byte because 256 / 8 = 32" */ - window_data.frame_tl_x_0 = ss->sio.scan_x_origin / 150; - window_data.frame_tl_x_1 = 0; - window_data.frame_tl_y_0 = ss->sio.scan_y_origin / 150; - window_data.frame_tl_y_1 = 0; - window_data.frame_br_x_0 = (ss->sio.scan_x_origin + - ss->sio.scan_width) / 150; - window_data.frame_br_x_1 = 0; - window_data.frame_br_y_0 = (ss->sio.scan_y_origin + - ss->sio.scan_height) / 150; - window_data.frame_br_y_1 = 0; + pixel_tlx = ss->sio.scan_x_origin / 150; + pixel_tly = ss->sio.scan_y_origin / 150; + pixel_brx = pixel_tlx + ss->sio.scan_width / 150; + pixel_bry = pixel_tly + ss->sio.scan_height / 150; #else pixel_tlx = (ss->sio.scan_x_origin * ss->sio.scan_x_resolution) / 1200; - window_data.frame_tl_x_0 = pixel_tlx & 0xff; - window_data.frame_tl_x_1 = (pixel_tlx >> 8) & 0xff; pixel_tly = (ss->sio.scan_y_origin * ss->sio.scan_y_resolution) / 1200; - window_data.frame_tl_y_0 = pixel_tly & 0xff; - window_data.frame_tl_y_1 = (pixel_tly >> 8) & 0xff; pixel_brx = pixel_tlx + (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200; - window_data.frame_br_x_0 = pixel_brx & 0xff; - window_data.frame_br_x_1 = (pixel_brx >> 8) & 0xff; pixel_bry = pixel_tly + (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200; - window_data.frame_br_y_0 = pixel_bry & 0xff; - window_data.frame_br_y_1 = (pixel_bry >> 8) & 0xff; #endif + _lto2l(pixel_tlx, window_data.frame.tl_x); + _lto2l(pixel_tly, window_data.frame.tl_y); + _lto2l(pixel_brx, window_data.frame.br_x); + _lto2l(pixel_bry, window_data.frame.br_y); #if MUSTEK_WINDOWS >= 1 - window_data.window1_header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC; - window_data.window1_tl_x_0 = window_data.frame_tl_x_0; - window_data.window1_tl_x_1 = window_data.frame_tl_x_1; - window_data.window1_tl_y_0 = window_data.frame_tl_y_0; - window_data.window1_tl_y_1 = window_data.frame_tl_y_1; - window_data.window1_br_x_0 = window_data.frame_br_x_0; - window_data.window1_br_x_1 = window_data.frame_br_x_1; - window_data.window1_br_y_0 = window_data.frame_br_y_0; - window_data.window1_br_y_1 = window_data.frame_br_y_1; + window_data.window1 = window_data.frame; + window_data.window1.header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC; #endif /* send the set window command to the scanner */ @@ -349,7 +330,7 @@ mustek_trigger_scanner(ss) */ bzero(&mode_cmd, sizeof(mode_cmd)); mode_cmd.opcode = MUSTEK_MODE_SELECT; - mode_cmd.length_0 = sizeof(mode_data); + _lto2b(sizeof(mode_data), mode_cmd.length); bzero(&mode_data, sizeof(mode_data)); mode_data.mode = @@ -369,13 +350,11 @@ mustek_trigger_scanner(ss) mode_data.grain = 0; mode_data.velocity = ss->sio.scan_quality / 20 - 1; #ifdef MUSTEK_INCH_SPEC - mode_data.paperlength_0 = 14 * 8; /* 14" */ - mode_data.paperlength_1 = 0; + paperlength = 14 * 8; /* 14" */ #else - paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */ - mode_data.paperlength_0 = paperlength & 0xff; - mode_data.paperlength_1 = (paperlength >> 8) & 0xff; + paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */ #endif + _lto2l(paperlength, mode_data.paperlength); SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n")); /* send the command to the scanner */ @@ -492,9 +471,7 @@ mustek_read(ss, bp) ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8); SC_DEBUG(sc_link, SDEV_DB1, ("mustek_read: read %d lines\n", lines_to_read)); - cmd.length_0 = lines_to_read & 0xff; - cmd.length_1 = (lines_to_read >> 8) & 0xff; - cmd.length_2 = (lines_to_read >> 16) & 0xff; + _lto3b(lines_to_read, cmd.length); /* * go ask the adapter to do all this for us @@ -547,13 +524,8 @@ mustek_get_status(ss, timeout, update) } if (update) { - bytes_per_line = - (data.bytes_per_line_1 << 8) | - data.bytes_per_line_0; - lines = - (data.lines_2 << 16) | - (data.lines_1 << 8) | - data.lines_0; + bytes_per_line = _2ltol(data.bytes_per_line); + lines = _3ltol(data.lines); if (lines != ss->sio.scan_lines) { printf("mustek: lines actual(%d) != computed(%d)\n", lines, ss->sio.scan_lines); diff --git a/sys/scsi/ss_mustek.h b/sys/scsi/ss_mustek.h index c045675077bd..599f129a06f2 100644 --- a/sys/scsi/ss_mustek.h +++ b/sys/scsi/ss_mustek.h @@ -1,4 +1,4 @@ -/* $NetBSD: ss_mustek.h,v 1.1 1996/02/18 20:32:48 mycroft Exp $ */ +/* $NetBSD: ss_mustek.h,v 1.2 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved. @@ -70,104 +70,66 @@ */ struct mustek_set_window_cmd { - u_char opcode; /* 0x04 */ - u_char reserved[3]; - u_char length; /* in bytes */ - u_char control; + u_int8_t opcode; /* 0x04 */ + u_int8_t reserved[3]; + u_int8_t length; /* in bytes */ + u_int8_t control; +}; + +struct mustek_window { + u_int8_t header; /* unit-defines also apply */ + u_int8_t tl_x[2]; /* LSB */ + u_int8_t tl_y[2]; + u_int8_t br_x[2]; + u_int8_t br_y[2]; }; struct mustek_set_window_data { #define MUSTEK_LINEART_BACKGROUND 0x00 #define MUSTEK_HALFTONE_BACKGROUND 0x01 - u_char frame_header; /* unit-defines also apply */ - u_char frame_tl_x_0; - u_char frame_tl_x_1; - u_char frame_tl_y_0; - u_char frame_tl_y_1; - u_char frame_br_x_0; - u_char frame_br_x_1; - u_char frame_br_y_0; - u_char frame_br_y_1; + struct mustek_window frame; #if MUSTEK_WINDOWS >= 1 #define MUSTEK_WINDOW_MASK 0x80 - u_char window1_header; /* unit-defines also apply */ - u_char window1_tl_x_0; - u_char window1_tl_x_1; - u_char window1_tl_y_0; - u_char window1_tl_y_1; - u_char window1_br_x_0; - u_char window1_br_x_1; - u_char window1_br_y_0; - u_char window1_br_y_1; + struct mustek_window window1; #endif #if MUSTEK_WINDOWS >= 2 - u_char window2_header; - u_char window2_tl_x_0; - u_char window2_tl_x_1; - u_char window2_tl_y_0; - u_char window2_tl_y_1; - u_char window2_br_x_0; - u_char window2_br_x_1; - u_char window2_br_y_0; - u_char window2_br_y_1; + struct mustek_window window2; #endif #if MUSTEK_WINDOWS >= 3 - u_char window3_header; - u_char window3_tl_x_0; - u_char window3_tl_x_1; - u_char window3_tl_y_0; - u_char window3_tl_y_1; - u_char window3_br_x_0; - u_char window3_br_x_1; - u_char window3_br_y_0; - u_char window3_br_y_1; + struct mustek_window window3; #endif -#if MUSTEK_WINDOWS == 4 - u_char window4_header; - u_char window4_tl_x_0; - u_char window4_tl_x_1; - u_char window4_tl_y_0; - u_char window4_tl_y_1; - u_char window4_br_x_0; - u_char window4_br_x_1; - u_char window4_br_y_0; - u_char window4_br_y_1; +#if MUSTEK_WINDOWS >= 4 + struct mustek_window window4; #endif }; struct mustek_read_cmd { - u_char opcode; /* 0x08 */ - u_char reserved; - u_char length_2; /* number of LINES to be read (MSB) */ - u_char length_1; /* number of LINES to be read */ - u_char length_0; /* number of LINES to be read (LSB) */ - u_char control; + u_int8_t opcode; /* 0x08 */ + u_int8_t reserved; + u_int8_t length[3]; + u_int8_t control; }; struct mustek_get_status_cmd { - u_char opcode; /* 0x0f */ - u_char reserved[3]; - u_char length; /* 0x06 */ - u_char control; + u_int8_t opcode; /* 0x0f */ + u_int8_t reserved[3]; + u_int8_t length; /* 0x06 */ + u_int8_t control; }; struct mustek_get_status_data { #define MUSTEK_READY 0 #define MUSTEK_BUSY -1 - u_char ready_busy; /* 0 = ready */ - u_char bytes_per_line_0; /* LSB */ - u_char bytes_per_line_1; /* MSB */ - u_char lines_0; /* LSB */ - u_char lines_1; - u_char lines_2; /* MSB */ + u_int8_t ready_busy; /* 0 = ready */ + u_int8_t bytes_per_line[2]; /* LSB */ + u_int8_t lines[3]; /* LSB */ }; struct mustek_mode_select_cmd { - u_char opcode; /* 0x15 */ - u_char reserved[2]; - u_char length_1; /* MSB */ - u_char length_0; /* LSB */ - u_char control; + u_int8_t opcode; /* 0x15 */ + u_int8_t reserved[2]; + u_int8_t length[2]; + u_int8_t control; }; /* @@ -187,20 +149,19 @@ struct mustek_mode_select_data { #define MUSTEK_MODE_MASK 0x83 #define MUSTEK_HT_PATTERN_BUILTIN 0x00 #define MUSTEK_HT_PATTERN_DOWNLOADED 0x10 - u_char mode; - u_char resolution; - u_char brightness; - u_char contrast; - u_char grain; /* 0 = 8x8, ..... 5 = 2x2 */ - u_char velocity; /* 0 = fast, ...., 4 = slow */ - u_char reserved[2]; - u_char paperlength_0; /* LSB */ - u_char paperlength_1; /* MSB */ + u_int8_t mode; + u_int8_t resolution; + u_int8_t brightness; + u_int8_t contrast; + u_int8_t grain; /* 0 = 8x8, ..... 5 = 2x2 */ + u_int8_t velocity; /* 0 = fast, ...., 4 = slow */ + u_int8_t reserved[2]; + u_int8_t paperlength[2]; /* LSB */ }; struct mustek_start_scan_cmd { - u_char opcode; /* 0x1b */ - u_char reserved[3]; + u_int8_t opcode; /* 0x1b */ + u_int8_t reserved[3]; #define MUSTEK_SCAN_STOP 0x00 #define MUSTEK_SCAN_START 0x01 #define MUSTEK_GRAY_FILTER 0x00 @@ -211,8 +172,8 @@ struct mustek_start_scan_cmd { #define MUSTEK_BIT_MODE 0x00 #define MUSTEK_RES_STEP_1 0x00 #define MUSTEK_RES_STEP_10 0x80 - u_char mode; - u_char control; + u_int8_t mode; + u_int8_t control; }; #endif /* _SS_MUSTEK_H_ */ diff --git a/sys/scsi/ss_scanjet.c b/sys/scsi/ss_scanjet.c index 4faebc78a75c..5e2fdd689a5c 100644 --- a/sys/scsi/ss_scanjet.c +++ b/sys/scsi/ss_scanjet.c @@ -1,4 +1,4 @@ -/* $NetBSD: ss_scanjet.c,v 1.1 1996/02/18 20:32:49 mycroft Exp $ */ +/* $NetBSD: ss_scanjet.c,v 1.2 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -240,7 +240,7 @@ scanjet_read(ss, bp) * Handle "fixed-block-mode" tape drives by using the * block count instead of the length. */ - lto3b(bp->b_bcount, cmd.len); + _lto3b(bp->b_bcount, cmd.len); /* * go ask the adapter to do all this for us @@ -278,7 +278,7 @@ scanjet_write(ss, buf, size, flags) return (0); bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE; - lto3b(size, cmd.len); + _lto3b(size, cmd.len); return (scsi_scsi_cmd(ss->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL, flags | SCSI_DATA_OUT)); diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 91e53ae1e67a..1982985952bd 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.63 1996/03/17 00:59:54 thorpej Exp $ */ +/* $NetBSD: st.c,v 1.64 1996/03/19 03:05:15 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -1005,9 +1005,9 @@ ststart(v) */ if (st->flags & ST_FIXEDBLOCKS) { cmd.byte2 |= SRW_FIXED; - lto3b(bp->b_bcount / st->blksize, cmd.len); + _lto3b(bp->b_bcount / st->blksize, cmd.len); } else - lto3b(bp->b_bcount, cmd.len); + _lto3b(bp->b_bcount, cmd.len); /* * go ask the adapter to do all this for us @@ -1254,21 +1254,15 @@ st_read(st, buf, size, flags) cmd.opcode = READ; if (st->flags & ST_FIXEDBLOCKS) { cmd.byte2 |= SRW_FIXED; - lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE), + _lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE), cmd.len); } else - lto3b(size, cmd.len); + _lto3b(size, cmd.len); return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL, flags | SCSI_DATA_IN); } -#ifdef __STDC__ -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0) -#else -#define b2tol(a) (((unsigned)(a/**/_1) << 8) + (unsigned)a/**/_0) -#endif - /* * Ask the drive what it's min and max blk sizes are. */ @@ -1304,8 +1298,8 @@ st_read_block_limits(st, flags) if (error) return error; - st->blkmin = b2tol(block_limits.min_length); - st->blkmax = _3btol(&block_limits.max_length_2); + st->blkmin = _2btol(block_limits.min_length); + st->blkmax = _3btol(block_limits.max_length); SC_DEBUG(sc_link, SDEV_DB3, ("(%d <= blksize <= %d)\n", st->blkmin, st->blkmax)); @@ -1413,7 +1407,7 @@ st_mode_select(st, flags) else scsi_select.header.dev_spec |= SMH_DSP_BUFF_MODE_ON; if (st->flags & ST_FIXEDBLOCKS) - lto3b(st->blksize, scsi_select.blk_desc.blklen); + _lto3b(st->blksize, scsi_select.blk_desc.blklen); if (st->page_0_size) bcopy(st->sense_data, scsi_select.sense_data, st->page_0_size); @@ -1531,7 +1525,7 @@ st_space(st, number, what, flags) bzero(&cmd, sizeof(cmd)); cmd.opcode = SPACE; cmd.byte2 = what; - lto3b(number, cmd.number); + _lto3b(number, cmd.number); return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), 0, 0, 0, 900000, NULL, flags); @@ -1570,7 +1564,7 @@ st_write_filemarks(st, number, flags) bzero(&cmd, sizeof(cmd)); cmd.opcode = WRITE_FILEMARKS; - lto3b(number, cmd.number); + _lto3b(number, cmd.number); return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd, sizeof(cmd), 0, 0, 0, 100000, NULL, flags); @@ -1686,26 +1680,25 @@ st_interpret_sense(xs) /* * Get the sense fields and work out what code */ - if (sense->error_code & SSD_ERRCODE_VALID) { - bcopy(sense->extended_info, &info, sizeof info); - info = ntohl(info); - } else + if (sense->error_code & SSD_ERRCODE_VALID) + info = _4btol(sense->info); + else info = xs->datalen; /* bad choice if fixed blocks */ if ((sense->error_code & SSD_ERRCODE) != 0x70) return -1; /* let the generic code handle it */ if (st->flags & ST_FIXEDBLOCKS) { xs->resid = info * st->blksize; - if (sense->extended_flags & SSD_EOM) { + if (sense->flags & SSD_EOM) { st->flags |= ST_EIO_PENDING; if (bp) bp->b_resid = xs->resid; } - if (sense->extended_flags & SSD_FILEMARK) { + if (sense->flags & SSD_FILEMARK) { st->flags |= ST_AT_FILEMARK; if (bp) bp->b_resid = xs->resid; } - if (sense->extended_flags & SSD_ILI) { + if (sense->flags & SSD_ILI) { st->flags |= ST_EIO_PENDING; if (bp) bp->b_resid = xs->resid; @@ -1739,14 +1732,14 @@ st_interpret_sense(xs) } } else { /* must be variable mode */ xs->resid = xs->datalen; /* to be sure */ - if (sense->extended_flags & SSD_EOM) + if (sense->flags & SSD_EOM) return EIO; - if (sense->extended_flags & SSD_FILEMARK) { + if (sense->flags & SSD_FILEMARK) { if (bp) bp->b_resid = bp->b_bcount; return 0; } - if (sense->extended_flags & SSD_ILI) { + if (sense->flags & SSD_ILI) { if (info < 0) { /* * the record was bigger than the read @@ -1762,7 +1755,7 @@ st_interpret_sense(xs) bp->b_resid = info; } } - key = sense->extended_flags & SSD_KEY; + key = sense->flags & SSD_KEY; if (key == 0x8) { /*