# PaCkAgE DaTaStReAm O5hbasamp 1 186 # end of header 0707010000000000008092000000000000000000000001000000000000000f000000000000000000000000000000000000001200000000/tmp/._xAtTr_19254 1:acl 2:priv 070701000237f9000081a40000000000000003000000013764a852000000bd00001dff0000000100000000000000000000001200000000O5hbasamp/pkginfoARCH=IA32 CATEGORY=application CLASSES=none DESC=Sample HBA driver source and tools for SCO OpenServer 5.0X NAME=SRAM sample driver PKG=O5hbasamp PSTAMP=9905251425 VENDOR=SCO VERSION=7.1.0 070701000237fa000081a40000000000000003000000013764a852000004f600001dff0000000100000000000000000000001100000000O5hbasamp/pkgmap: 1 186 1 i copyright 55 4342 925516783 1 i pkginfo 189 14809 929397570 1 d none usr 0755 bin bin 1 d none usr/src 0755 bin bin 1 d none usr/src/O5hdk 0755 bin bin 1 d none usr/src/O5hdk/samples 0755 bin bin 1 d none usr/src/O5hdk/samples/Sram 0755 bin bin 1 f none usr/src/O5hdk/samples/Sram/Driver.o 0644 bin bin 8559 34158 929397569 1 f none usr/src/O5hdk/samples/Sram/Makefile 0644 bin bin 812 64181 920664349 1 f none usr/src/O5hdk/samples/Sram/README 0444 bin bin 2084 48879 920664340 1 f none usr/src/O5hdk/samples/Sram/Sram.c 0644 bin bin 27711 54631 927667365 1 f none usr/src/O5hdk/samples/Sram/Sram.h 0644 bin bin 4908 32914 920664343 1 l none usr/src/O5hdk/samples/Sram/Sram.o=usr/src/O5hdk/samples/Sram/Driver.o 1 f none usr/src/O5hdk/samples/Sram/adSram 0755 bin bin 8597 4544 920664487 1 f none usr/src/O5hdk/samples/Sram/boot.entry 0644 bin bin 31 2616 920664487 1 f none usr/src/O5hdk/samples/Sram/boot5.entry 0644 bin bin 21 1824 920664488 1 f none usr/src/O5hdk/samples/Sram/mscsi.entry 0644 bin bin 378 31024 920664502 1 l none usr/src/O5hdk/samples/Sram/rmSram=usr/src/O5hdk/samples/Sram/adSram 1 f none usr/src/O5hdk/samples/Sram/scsi.h 0444 bin bin 18375 41968 920664519 1 f none usr/src/O5hdk/samples/Sram/space.c 0644 bin bin 843 5579 920664519 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000b00000000TRAILER!!!0707010000000000008092000000000000000000000001000000000000000f000000000000000000000000000000000000001200000000/tmp/._xAtTr_19274 1:acl 2:priv 070701000237f9000081a40000000000000003000000013764a852000000bd00001dff0000000100000000000000000000000800000000pkginfoARCH=IA32 CATEGORY=application CLASSES=none DESC=Sample HBA driver source and tools for SCO OpenServer 5.0X NAME=SRAM sample driver PKG=O5hbasamp PSTAMP=9905251425 VENDOR=SCO VERSION=7.1.0 070701000237fa000081a40000000000000003000000013764a852000004f600001dff0000000100000000000000000000000700000000pkgmap: 1 186 1 i copyright 55 4342 925516783 1 i pkginfo 189 14809 929397570 1 d none usr 0755 bin bin 1 d none usr/src 0755 bin bin 1 d none usr/src/O5hdk 0755 bin bin 1 d none usr/src/O5hdk/samples 0755 bin bin 1 d none usr/src/O5hdk/samples/Sram 0755 bin bin 1 f none usr/src/O5hdk/samples/Sram/Driver.o 0644 bin bin 8559 34158 929397569 1 f none usr/src/O5hdk/samples/Sram/Makefile 0644 bin bin 812 64181 920664349 1 f none usr/src/O5hdk/samples/Sram/README 0444 bin bin 2084 48879 920664340 1 f none usr/src/O5hdk/samples/Sram/Sram.c 0644 bin bin 27711 54631 927667365 1 f none usr/src/O5hdk/samples/Sram/Sram.h 0644 bin bin 4908 32914 920664343 1 l none usr/src/O5hdk/samples/Sram/Sram.o=usr/src/O5hdk/samples/Sram/Driver.o 1 f none usr/src/O5hdk/samples/Sram/adSram 0755 bin bin 8597 4544 920664487 1 f none usr/src/O5hdk/samples/Sram/boot.entry 0644 bin bin 31 2616 920664487 1 f none usr/src/O5hdk/samples/Sram/boot5.entry 0644 bin bin 21 1824 920664488 1 f none usr/src/O5hdk/samples/Sram/mscsi.entry 0644 bin bin 378 31024 920664502 1 l none usr/src/O5hdk/samples/Sram/rmSram=usr/src/O5hdk/samples/Sram/adSram 1 f none usr/src/O5hdk/samples/Sram/scsi.h 0444 bin bin 18375 41968 920664519 1 f none usr/src/O5hdk/samples/Sram/space.c 0644 bin bin 843 5579 920664519 070701000237f8000081a4000000000000000300000001372970ff0000003700001dff0000000100000000000000000000001200000000install/copyrightCopyright (C) 1992-1999 The Santa Cruz Operation, Inc. 07070100023804000081a40000000000000003000000013764a8510000216f00001dff0000000100000000000000000000002a00000000reloc/usr/src/O5hdk/samples/Sram/Driver.oL K7>>.textt p .datat t X( "6@.bss L.commentU3W}ft=uh h 3G(=h _]Ðh vh bh vNh b:h N&h, :h< &hT hd ht h h h h uh eh zUh jEh Z5h J%h :3G(=+w$ GPh$ GSPh8 _]ÐUW=(PL|L_ J$ ]ÐUȡ(u%E( QB r]Ð U(Ґ3UWVSEMx pH&H%@S@tE@S=AtE t&=t;=uMU R щT6E U R щTE U R щTE@(%== E3ۋP;sZup]] \QPERlYPe UMMЋUUBUU;rUR A [^_]ËE3ۋP;sԉup]] \ERQYPP M‹UUȋE@EM;rxE@%l3U W}VSGS] @O&O%t =At3G(tH== tU=J=%jWRdir = 0x%x req_p->hacmd = 0x%x SCO AHDK SCSI sampleSraminit: memget(K) returned no mem. adaptertype=Sram Pseudo SCSI Host Adapter@(#) Sram.c 77.1 99/03/05 @(#) param.h 58.1 96/10/12 @(#) types.h 26.3 95/11/30 @(#) fdmac.h 26.1 95/11/30 @(#) sysmacros.h 25.6 94/09/22 @(#) systm.h 25.9 94/11/10 @(#) buf.h 26.2 95/12/08 @(#) cilock.h 25.7 94/09/22 @(#) iobuf.h 25.1 94/09/22 @(#) conf.h 60.1 97/02/05 @(#) dir.h 23.1 91/03/03 @(#) s5dir.h 25.2 94/09/22 @(#) signal.h 62.2 97/03/17 @(#) siginfo.h 26.2 95/11/30 @(#) errno.h 26.1 95/11/30 @(#) seg.h 26.1 96/02/28 @(#) page.h 23.1 91/03/03 @(#) user.h 61.1 97/02/24 @(#) regset.h 26.1 95/11/30 @(#) immu.h 60.2 97/01/31 @(#) dio.h 58.2 96/09/25 @(#) disk.h 25.3 95/04/11 @(#) devreg.h 25.9 94/12/06 @(#) arch.h 25.1 94/03/24 @(#) select.h 26.2 95/11/30 @(#) cmn_err.h 25.3 94/08/15 @(#) debug.h 25.5 94/04/07 @(#) mount.h 58.1 96/10/12 @(#) cram.h 23.3 91/10/28 @(#) dma.h 25.1 94/09/22 @(#) scsi.h 65.1 97/06/26 @(#) cidriver.h 25.1 94/09/22 @(#) ciintr.h 25.9 94/09/22 @(#) Sram.h 99/02/22 acomp: Release 5.1.0Ha 25Apr97optim: Release 5.1.0Ha 25Apr97+).+AFK+Y^+fmr+z+++++++ +!&+.5:+BIN+V]b+mr+}+++++++,!,',2,?Mb-k,w,}.,5Wb2323P\23/Gb2i3q23242OT3_d3ot33%2i2pu323676H6eox-.8  +! 4- 9 > C 9H M 9R W 9] ,      ;        & , 2 : @ F K <P ` e =                      $ ( , 0 4 8 < @ D H L P T X \ ` d h l p t x |          .filegSram.c&$pull_reqhD0`$L;$ `$< $ Sramopen$,$$HSramintr`$,Srampoll$DSraminit$.textt .datat X6.bss L.commentt   opened htag otag stag ntag index printfrl_array(spl5splxJ Xfubcopybzero ususerregit SramcfgprintcfgSram_cap_inforeq_readyfrom_pollprint_reqinsert_reqprocess_sg_reqSram_tape_ptrSram_disk_ptrSram_disk_ptr2_phystokvprocess_reqSram_entrySram_infoSramcloseSramioctlgetcpagesscsi_swap4Sharegister07070100023805000081a400000000000000030000000136df581d0000032c00001dff0000000100000000000000000000002a00000000reloc/usr/src/O5hdk/samples/Sram/Makefile# # @(#) Sram.mk 77.1 99/03/05 # # The information in this file is provided for the exclusive use of the # licensees of The Santa Cruz Operation, Inc. Such users have the right # to use, modify, and incorporate this code into other products for purposes # authorized by the license agreement, provided they include this notice # and the associated copyright notice with any such product. The # information in this file is provided "AS IS" without warranty. # # # # Makefile for Sram.c # # #COMPFLAGS = -Olt -Gs COMPFLAGS = -O1 COMPNAMES = -DM_I386 -DM_UNIX -D_INKERNEL -DM_S_UNIX -D_IBCS2 -DKPRF -DVPIX -DWEITEK -DSCO_VAL_ADDED -DSCO_ONLY -DSecureWare -DFFS -DMERGE386 -D_INKERNEL -D_SVID3 -D_NBREAD CFLAGS = ${COMPFLAGS} ${COMPNAMES} CPP = /lib/cpp Sram.o: Sram.c Sram.h cc $(CFLAGS) Sram.c -c 07070100023807000081a400000000000000030000000136df58140000082400001dff0000000100000000000000000000002800000000reloc/usr/src/O5hdk/samples/Sram/README/* * Copyright (C) 1992-1999 The Santa Cruz Operation, Inc. * * The information in this file is provided for the exclusive use of the * licensees of The Santa Cruz Operation, Inc. Such users have the right * to use, modify, and incorporate this code into other products for purposes * authorized by the license agreement, provided they include this notice * and the associated copyright notice with any such product. The * information in this file is provided "AS IS" without warranty. */ This is a sample SCSI host adapter driver. It spoofs the SCO Disk driver into thinking that it is talking to two small disks. They are in fact two small RAM disks. It is fairly well documented and one should pay special attention to the section on scatter gather. It has lots of comments. It can be run on a machine with or with- out a real SCSI subsystem. Once linked in, the user can run mkdev hd to setup each of the small drives. Also included are two shell scripts that are infact one that is linked to two names. This script will add/remove the driver to/from the kernel and relink from the current directory. So to get started you just need to copy these files to a directory of choice and run adSram. The shell scripts can be copied and modified for your own use. They are great for doing driver mods and relinks. Good luck. README This File Driver.o The compiled Sram driver module. Sram.o Same Makefile Used by the make command to compile sram driver. Sram.c SCSI RAM disk driver source. Sram.h SCSI RAM disk driver header file. space.c SCSI RAM disk driver space file. adSram Shell script that adds sram to OSR5 system. rmSram Shell script that removes sram from system. Both of these files are links to each other. boot.entry Text file for /etc/default/boot additions Upgrade installs. boot5.entry Text file for /etc/default/boot additions Standard installs for /stand. mscsi.entry Text file for /etc/conf/cf.d/mscsi additions Not used, reference only scsi.h A copy of the SCSI defines. 0707010002380a000081a4000000000000000300000001374a41b500006c3f00001dff0000000100000000000000000000002800000000reloc/usr/src/O5hdk/samples/Sram/Sram.c#pragma comment(exestr, "@(#) Sram.c 77.2 99/05/25 ") /* * * Copyright (C) 1992-1999 The Santa Cruz Operation, Inc. * * The information in this file is provided for the exclusive use of the * licensees of The Santa Cruz Operation, Inc. Such users have the right * to use, modify, and incorporate this code into other products for purposes * authorized by the license agreement, provided they include this notice * and the associated copyright notice with any such product. The * information in this file is provided "AS IS" without warranty. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Sram.h" /* * NOTE: The use of printf is not rcomended in a driver however * this is for DEBUG purposes only. */ print_req(req_p) REQ_IO *req_p; { switch (req_p->req_type) { case SCSI_SEND: printf("SCSI_SEND :"); break; case SCSI_SG: printf("SCSI_SG :"); break; } if ( 255 == req_p->scsi_cmd.six.opcode ) { printf("CMD_INVALID\n"); return; } /* printf(" dblt=%d ",lbolt); */ switch (req_p->scsi_cmd.six.opcode) { case TEST_CMD :printf("TEST_CMD "); break; case SENSE_CMD :printf("SENSE_CMD "); break; case 0x07 :printf("REASSIGN_CMD or RD_BACK_CMD "); break; /* case REASSIGN_IND:printf("REASSIGN_IND ");break; */ case READ_CMD :printf("READ_CMD "); break; case WRITE_CMD :printf("WRITE_CMD ");break; case REWIND_CMD :printf("REWIND_CMD ");break; case 0x0b :printf("SEEK_CMD or SETTRK_CMD "); break; case FORMAT_CMD :printf("FORMAT_CMD ");break; case INQUIRY_CMD :printf("INQUIRY_CMD ");break; case MODESELECT_CMD:printf("MODESELECT_CMD ");break; case MODESENSE_CMD:printf("MODESENSE_CMD ");break; case READ_CAP_CMD:printf("READ_CAP_CMD ");break; case READTEN_CMD :printf("READTEN_CMD ");break; case WRITETEN_CMD:printf("WRITETEN_CMD ");break; case SEEKTEN_CMD :printf("SEEKTEN_CMD ");break; case TP_RDB :printf("TP_RDB ");break; case TP_WFM :printf("TP_WFM ");break; case TP_SP :printf("TP_SP ");break; case TP_LOAD :printf("TP_LOAD ");break; case TP_ERASE :printf("TP_ERASE ");break; } printf("req_p->dir = 0x%x ",req_p->dir); printf("req_p->hacmd = 0x%x \n",req_p->hacmd); /* printf("req_p->sense_len = 0x%x ",req_p->sense_len); printf("req_p->req_id = 0x%x ",req_p->req_id); printf("req_p->cmdlen = %d \n",req_p->cmdlen); */ /* printf("req_p->id = %d \n",req_p->id); printf("req_p->lun = %d \n",req_p->lun); printf("req_p->ha_num = %d \n",req_p->ha_num); */ } /* * Return a req_io pointer for a request that has been satisfied. * Don't worry about spl here because it was set before being called. * The poll routine sets it and then calls the intr function which * calls the pull_req before calling the io_intr function. */ REQ_IO * pull_req() { int i; REQ_IO *req_p; req_p = rl_array[0]; for ( i = 0; i < 9; i++){ rl_array[i] = rl_array[i+1]; } rl_array[9] = ( REQ_IO * ) 0; index--; return(req_p); } /* * Insert req_p into a list of io reqs * Not doing any array bounds checking. Only two devices * and the request is served instantly. */ insert_req(req_p) REQ_IO *req_p; { int s; s = spl5(); if ( rl_array[0] == (REQ_IO *) 0 ){ rl_array[0] = req_p; index++; } else { rl_array[index] = req_p; index++; } splx(s); } /* * Handle a Scatter Gather (SG/linked cmd) request. When you * receive a SG request there are four fields that you have to * worry about. * * req_p->data_ptr = The address of an array of physical memory * locations in which to transfer data. These * are your kernel io bufs. An array of long. * req_p->link_ptr = The address of an array of lengths of each io * request. This is an array of type long. 1K ea. * req_p->data_len = The total length in bytes of ALL the SG requests * added together. A sum total. * req_p->data_blk = This is the offset into the media (disk) that * the SG request will start from. This is in * blocks. This example is 512 byte blocks. */ static process_sg_req(req_p, target) REQ_IO *req_p; char target; { unsigned char *offset_ptr[NDRIVES]; int bttl, /* byte total */ sumttl; /* sum total # of transfers */ long *t_len; /* individual transfer length pointer */ paddr_t *d_ptr; /* individual data block pointer */ char *tag; t_len = ( long * ) req_p->link_ptr; d_ptr = ( paddr_t * ) req_p->data_ptr; req_p->target_sts = 0; req_p->host_sts = 0; sumttl = 0; tag = ntag; if (req_p->hacmd & SCSI_TAG_CMD){ switch ( req_p->hacmd ) { case SCSI_TAG_HEAD : tag = htag; break; case SCSI_TAG_ORDER : tag = otag; break; case SCSI_TAG_SIMPLE : tag = stag; break; } } /*printf("Sram: ID %d ",( int ) target); */ switch (target) { case 0: offset_ptr[target] = Sram_disk_ptr+req_p->data_blk*S_sec_size; break; case 1: offset_ptr[target] = Sram_disk_ptr2+req_p->data_blk*S_sec_size; break; case 2: offset_ptr[target] = Sram_tape_ptr+req_p->data_blk*S_sec_size; break; } switch (req_p->scsi_cmd.six.opcode) { case WRITE_CMD : /* printf("Write: "); */ for ( bttl = 0; bttl < req_p->data_len; t_len++, d_ptr++ ){ bcopy(ptok(*d_ptr), offset_ptr[target], *t_len); /*printf("Blk %d, Len %dK",sumttl,*t_len/1024); */ offset_ptr[target] += *t_len; bttl += (*t_len); sumttl++; } /* printf("%dK transfer Scatter Gather %s\n", sumttl, tag); */ break; case READ_CMD : /* printf("Read: "); */ for ( bttl = 0; bttl < req_p->data_len; t_len++, d_ptr++ ){ bcopy(offset_ptr[target],ptok(*d_ptr), *t_len); /*printf("Blk %d, Len %dK",sumttl,*t_len/1024); */ offset_ptr[target] += *t_len; bttl += (*t_len); sumttl++; } /* printf("%dK transfer Scatter Gather %s\n", sumttl, tag);*/ break; default : req_p->host_sts = 1; } /* put the io_req on a queue to be passed back */ insert_req(req_p);/* by the interrupt function. */ req_ready++; /* tell the poll routine that we have done one */ } /* * Don't worry about the host adapter number. * This function actually does the data transfer to and from * the ram disks. Remember that the byte order on the intel * platform is b0, b1, b2, and b3, with the LSB first. Just the * opposite for the SCSI spec. B3, b2, b1, & b0 with the MSB * first. */ static process_req(req_p, target) REQ_IO *req_p; char target; { unsigned char *offset_ptr[NDRIVES]; char *tag; /* used two places */ /* print_req(req_p); */ req_p->target_sts = 0; req_p->host_sts = 0; tag = ntag; if (req_p->hacmd & SCSI_TAG_CMD){ switch ( req_p->hacmd ) { case SCSI_TAG_HEAD : tag = htag; break; case SCSI_TAG_ORDER : tag = otag; break; case SCSI_TAG_SIMPLE : tag = stag; break; } } switch (req_p->scsi_cmd.six.opcode) { case WRITE_CMD : switch (target){ case 0: offset_ptr[target] = Sram_disk_ptr+req_p->data_blk*S_sec_size; break; case 1: offset_ptr[target] = Sram_disk_ptr2+req_p->data_blk*S_sec_size; break; case 2: offset_ptr[target] = Sram_tape_ptr+req_p->data_blk*S_sec_size; break; } bcopy(ptok(req_p->data_ptr), offset_ptr[target], req_p->data_len); /* * Remember that with each printf a copy gets written to disk. * ( /usr/adm/messages ) * This can chew up alot of real disk space. * To get around this you can kill syslogd */ /* printf("Sram: ID %d Write: %dK transfer %s\n", target,req_p->data_len/1024, tag); */ break; /* end case Write Cmd */ /* data_blk = sector offfset */ case READ_CMD : /* data_len = length of request in bytes*/ /* data_ptr = physical addr of buffer */ switch (target){ case 0: offset_ptr[target] = Sram_disk_ptr+req_p->data_blk*S_sec_size; break; case 1: offset_ptr[target] = Sram_disk_ptr2+req_p->data_blk*S_sec_size; break; case 2: offset_ptr[target] = Sram_tape_ptr+req_p->data_blk*S_sec_size; break; } bcopy(offset_ptr[target],ptok(req_p->data_ptr), req_p->data_len); /* printf("Sram: ID %d Read : %dK transfer %s\n", target,req_p->data_len/1024, tag); */ break; /* end case read cmd */ /* case START_STOP_CMD: */ /* break; */ case READ_CAP_CMD: /* load in addr of last block and */ /* size of blocks (512) for BPSCTR */ bcopy(&Sram_cap_info[target],ptok(req_p->data_ptr),8); break; /* Zero out the inquiry data */ case INQUIRY_CMD: /* data_len = INQUIRY_LEN */ bzero(ptok(req_p->data_ptr), req_p->data_len); if ( target < 2 ){ /* ie if a disk and not tape */ tag = (char *) ptok(req_p->data_ptr); tag+=2; *tag |= 0x2; /* We are SCSI II */ tag+=1; *tag |= 0x2; /* Response data fmt SCSI II*/ tag+=4; *tag |= 0x02; /* Yes we do TAGS */ *tag |= 0x04; /* Yes we do Linked CMDS */ *tag |= 0x06; /* Yes we do Synchronous */ tag+=1; /* byte 8-15 Vendor ID */ bcopy("SCO " , tag, 8); tag+=8; /* byte 16-31 product ID */ bcopy("AHDK SCS" , tag, 8); tag+=8; /* byte 32-35 Revision */ bcopy("I sa" , tag, 4); tag+=4; /* byte 36-39 V.U. */ bcopy("mple" , tag, 4); } break; case TEST_CMD : /* Test unit ready command */ break; default: req_p->target_sts = 1; } /* put the io_req on a queue to be passed back */ insert_req(req_p);/* by the interrupt function. */ req_ready++; /* tell the poll routine that we have done one */ } /* * Receive an io request (req io) from a peripheral driver. * For version 2 of SCO Unix 3.2.2 the peripheral driver does * not look at the return value. If you can't handle a request * put a 1 in the host_sts field. It would be advisable to * implement buffered commands real quick. */ Sram_entry(req_p) REQ_IO *req_p; { unsigned long total_blks = 0; scsi_disk_info *sdiptr; scsi_max_config_info Sram_limitInfo; HAINFO *ha_info_ptr; /* * Safety net for only 2 devices. Target 0, and 1. * Not the best way, but this is a sample. */ if ( req_p->id >= 2 || req_p->lun > 0 ) { req_p->host_sts = 1; return(-1); } switch (req_p->req_type){ case SCSI_SG: /* You don't need to split the SEND and SG func */ /* It's Done here for clarity only. */ case SCSI_SG_NC:/* We are only a ram disk, don't worry */ process_sg_req(req_p, req_p->id ); break; case SCSI_SEND: case SCSI_SEND_NC: /* since we are a ram disk, don't worry */ process_req(req_p, req_p->id ); /* only one host adapter */ /* don't worry about ha_num */ break; case SCSI_INIT: switch(req_p->hacmd){ case SCSI_VER_INFO: if ( req_p->ext_p ){ sdiptr = (scsi_disk_info *) req_p->ext_p->data; sdiptr->magic = SCSI_V3_MAGIC; sdiptr->v_maj = SCSI_V3_VERSION; sdiptr->v_min = 0; } break; case SCSI_DISK_INFO: /* printf("Sram: req_type = SCSI_INIT: hacmd = SCSI_DISK_INFO\n");*/ req_p->ext_p->type = SCSI_DISK_INFO; req_p->ext_p->next =(struct exten *) NULL; /* * Feature of 5.04 and later releases of OpenServer * * Using the sdiptr->capacity * (512 << sdiptr->blksz) * fields the programmer can select the correct disk * geometry for individual drive sizes without the need * send an additional SCSI read capacity command. * Please note however that the SCO install will run * dparam which writes the disk geom to the drive media. * Moving the disk to a differrent HBA will have no effect * on it's geom. The SCO disk.c lib will use the params * stored on the drive over these provided here. */ /* #define REAL */ #ifdef REAL if ( sdiptr->capacity > 0 ) { printf("Values passed in, disk blocksize= %d, and capacity= %d\n", 512 << sdiptr->blksz, sdiptr->capacity); total_blks = (sdiptr->capacity + 1) * (1 << sdiptr->blksz); } sdiptr->cylin = 0; /* * Get the Size in sectors of the target drive. * and provide the corresponding hds and sctrs * values. Note that *Size* in sectors in the * total number of addressable blocks returned * from the scsi READ_CAP cmd plus 1. * All Values Must Match the BIOS !! */ if ( 0 != total_blks ) { if ( total_blks <= 2097152 ) { /* 1 GB */ req_p->ext_p->data[1] = 64; req_p->ext_p->data[2] = 32; } else if ( total_blks <= 4194304 ){ /* 2 GB */ req_p->ext_p->data[1] = 128; req_p->ext_p->data[2] = 32; } else if ( total_blks <= 8388608){ /* 4 GB */ req_p->ext_p->data[1] = 255; req_p->ext_p->data[2] = 32; } else { /* > 4 GB */ req_p->ext_p->data[1] = 255; req_p->ext_p->data[2] = 63; } } #else if sdiptr->cylin = 0; /* * Pre 5.04 ie 5.02 5.00 ... * Fake BIOS-compatability Geometry. * Note: If there is none, ie the card returns * the actual parameters, then you have to * query the drive. */ switch ( req_p->id ) { /* switch on target id for demo */ case 0: sdiptr->heads = S_heads; /* Hds */ sdiptr->sectors = S_sectors; /* Sctrs*/ break; case 1: sdiptr->heads = S_heads2; sdiptr->sectors = S_sectors2; break; } #endif /* REAL */ break; case SCSI_TAPE_INFO: /* printf("Sram: req_type = SCSI_INIT: SCSI_TAPE_INFO\n");*/ break; default: /* No Error here */ break; } break; case SCSI_INFO: /* Copy the host adapter capabilities. */ /* Ie let the Sdsk driver know what the host */ /* can do. Tagged commands scater gather... */ /* Look below at the init function. */ /* printf("Sram: req_type = SCSI_INFO\n"); */ bcopy(&Sram_info, ptok(req_p->data_ptr), req_p->data_len); break; case SCSI_GET_LIMITS: /* limit the sconf scan during install */ Sram_limitInfo.num_buses = 1; Sram_limitInfo.num_ids = 2; ha_info_ptr =(HAINFO *) ((caddr_t)phystokv(req_p->data_ptr)); bcopy(&Sram_limitInfo, ha_info_ptr, req_p->data_len); break; default: break; } return 0; } /* * Use this function to get a file descriptor for ioctl. You * may want to make this exclusive if there is a chance that * you are adjusting functionality. If you do add static flags * remember to add a close function that will allow you to * get back in after you close the file descriptor. * If you don't do anything special in open You don't need it. * Just delete the open and close functions. */ Sramopen(dev,flag,id) dev_t dev; int flag, id; { int minor_num; minor_num = minor( dev ); if ( opened ){ u.u_error = EBUSY; return(-1); } opened++; return(0); } /* * Called on last close. */ Sramclose(dev,flag) dev_t dev; int flag; { int minor_num; minor_num = minor( dev ); opened--; return(0); } /* * Remember to use the Character device for ioctl's. * If you don't need this just delete it. It's not * required for the SCSI HBA interface. */ Sramioctl(dev,cmd,arg,mode) dev_t dev; int cmd, mode; caddr_t arg; { int minor_num; minor_num = minor( dev ); if (!suser()) { u.u_error = EPERM; return(-1); } switch ( cmd ) { case 0: break; case 1: break; default: u.u_error = EINVAL; return(-1); } return(0); } /* * This function calls the peripheral driver's interrupt rountine * when there is a request that is ready to be sent back. * * Remember this isn't a real driver, it's a little backwards when * compared to actual HW. When the request comes through it's done * imediately. The interrupt sumulation is just to get everything * back in sync. */ Sramintr(vec_num) int vec_num; /* interrupt vector */ { REQ_IO *req_p; if ( from_poll ) { /* Gaurd against spurious interrupts. */ from_poll = 0; /* Reset flag from Srampoll. */ req_p = pull_req(); (*req_p->io_intr)(req_p); } return(0); } /* * * This function is provided in an attempt to provide a better * skeleton in which to base a real driver. The Srampoll routine * will be called with every clock tic. If there is an IO REQ * that has been passed off to the Sram_entry function, on the next * clock tic the Srampoll routine will call Sramintr. * In turn the interrupt function will act like there was a real * interrupt and it will call the peripheral's interrupt function via * the (*req_p->io_intr)(req_p) pointer. So what I'm tring to say is * that if you toss the poll routine you have a *simple* realistic * model. * */ Srampoll(pps) int pps; /* Previous process spl, not current spl. */ { /* Current spl will be 6. The clock spl. */ int s; if ( pps >= 4 ) /* Prevent rentry when we lower the spl */ return; /* Normally a No No! */ if ( req_ready ){ /* Is there a request ready to service ? */ req_ready--; /* */ from_poll = 1; /* Flag the intr routine that we have one */ s=spl5(); /* 5 is the disk spl value */ Sramintr(15); /* Fake 15, taken from the install script */ splx(s); /* Reset the previous spl level */ } return; } /* * XXinit function that gets called from kernel main io_init[]. */ Sraminit(){ /* * Use getcpages to grab a whole lot of memory. S_Mem_Size is defined in * Sram.h and it may be more than one target. Then set the area to zeros. * memget attempts to grab mem below 16 MB and it's a valued resource. * requests for 3MB can fail. */ Sram_disk_ptr = (unsigned char *) getcpages(btoc(S_Mem_Size), NOSLEEP); if ( (unsigned char *)0== Sram_disk_ptr ) { printf("Sraminit: getcpages(K) returned no mem.\n"); return; } bzero(Sram_disk_ptr, S_Mem_Size); Sram_disk_ptr2 = Sram_disk_ptr + S_Disk_Size1;/*set ptr to begin of 2*/ Sram_tape_ptr = Sram_disk_ptr2 + S_Disk_Size2;/*set ptr to begin tape*/ /* printf("drive 0 capacity = %d 512 byte sectors\n",Sram_cap_info[0].last); */ /* printf("drive 1 capacity = %d 512 byte sectors\n",Sram_cap_info[1].last); */ /* * Switch the byte order for the disk capacity. * The function is a scsi bulit-in. Bytes per sector are all ready * swapped in the header file. */ scsi_swap4(&Sram_cap_info[0].last); scsi_swap4(&Sram_cap_info[1].last); scsi_swap4(&Sram_cap_info[2].last); rl_array[0] = ( REQ_IO * ) 0; /* * Provide information about the Host to the Peripheral * in the "xx_info" struct. Note that if you need to * be able to specify that the host driver can accept * commands at interrupt time, you must specify that * v_maj = SCSI_V3_VERSION. See the entry function. */ Sram_info.do_sg = 1; /* If 1 can accept scatter requests. */ /* Need to set Sdsk_no_sg to 0 in */ /* pack.d/Sdsk/space.c */ Sram_info.do_buffer = 1; /* If 1 driver buffers commands, no */ /* sleep in entry function. */ /* Also need to set Sdsk_sleep_option */ /* to 0 in pack.d/Sdsk/space.c */ Sram_info.do_tagged = 1; /* If 1 supports tagged queueing. */ /* Need to set Sdsk_no_tag to 0 in */ /* pack.d/Sdsk/space.c. Only works if */ /* the drive also supports tags. */ /* inquiry[7] & 2 = device does tag */ /* SCSI_TAG_SIMPLE only */ /* hacmd = SCSI_TAG_SIMPLE */ Sram_info.do_resource = 0; /* Corolllary Host Driver only. */ /* You will not need */ Sram_info.do_xtd_sense = 0; /* Supports extended xxxx sense */ /* Not currently used. */ Sram_info.do_drive32 = 1; /* Can accept 32 bit address for DMA */ Sram_info.do_nomaps = 1; /* Driver requires No remapping for */ /* io buffers. No copy buffers. */ /* New for Open Server Release 5.0 */ Sram_info.do_reset = 0; /* Driver supports bus reset */ Sram_info.do_abort = 0; /* Driver supports cmd abort */ Sram_info.do_cache_ctl = 1; /* Driver supports the ability to */ /* bypass controller cache if equipped*/ /* Force Unit Access (FUA) bit */ /* If set then the driver must be able*/ /* to accept SCSI_SEND_NC & SCSI_SG_NC*/ /* commands. */ Sram_info.has_cache = 1; /* Host adapter is equipped with cache*/ /* The has_cache = 1 and do_cache_ctl */ /* = 0 will generate a no FUA support */ /* warning. */ /* * features printed by Sdsk driver are as follows. * s = scatter gather * t = tagged commands * d = drives 32 * n = no maps * b = do buffer * */ /* * Verify it's there and register the driver with the SCSI subsystem. * This is a uni-processor model. */ regit.forw = ( struct Shareg *) 0; regit.back = ( struct Shareg *) 0; regit.entry = Sram_entry; regit.intr = Sramintr; regit.version = SHAREG_VERSION; regit.root_id = 0; if ( Sramcfg[0].ha_base == 0 ) regit.in_use = 0; else regit.in_use = 1; regit.int_vec = Sram_Vec; regit.route = IROUTE_GLOBAL; regit.weight = 5; regit.mode = IMODE_EXCLUSIVE; regit.processor_mask = 1; regit.iosaddr = 0; regit.ioeaddr = 0; regit.bus = 0; Sharegister(®it); printcfg("adapter",0xC90, 15, Sram_Vec, -1,"type=Sram Pseudo SCSI Host Adapter"); } 0707010002380b000081a400000000000000030000000136df58170000132c00001dff0000000100000000000000000000002800000000reloc/usr/src/O5hdk/samples/Sram/Sram.h#pragma comment(exestr, "@(#) Sram.h 77.1 99/03/05 ") /* * Header file Sram.h for Sram.c, a "Pseudo SCSI Host Driver" * * Copyright (C) 1992-1999 The Santa Cruz Operation, Inc. * * The information in this file is provided for the exclusive use of the * licensees of The Santa Cruz Operation, Inc. Such users have the right * to use, modify, and incorporate this code into other products for purposes * authorized by the license agreement, provided they include this notice * and the associated copyright notice with any such product. The * information in this file is provided "AS IS" without warranty. * */ #define Sram_Vec 10 /* This will be our irq */ #define SCSI_NO_INFO 0xff #define START_STOP_CMD 0x1b /* sent by Sdsk after inquiry command */ #define NDRIVES 3 /* Number of simulated target drives */ #define THREE_MEG 3145728 /* A 2 megabyte max for memget */ /* * Lets define the RAM Disk geometry for both drives. */ #define S_sec_size 512 /* bytes per sector */ /* DRIVE NUMBER 1 ID 0 */ #define S_sectors 16 /* sectors per track */ #define S_heads 2 /* number of Read Write heads */ #define S_cylinders 96 /* number of cylinders on the disk */ /* DRIVE NUMBER 2 ID 1 */ #define S_sectors2 8 /* sectors per track */ #define S_heads2 4 /* number of Read Write heads */ #define S_cylinders2 96 /* number of cylinders on the disk */ /* total size in bytes for both drives */ /* defined in the mscsi file for Sram */ #define S_Disk_Size1 (S_sec_size*S_sectors*S_heads*S_cylinders ) #define S_Disk_Size2 (S_sec_size*S_sectors2*S_heads2*S_cylinders2) #define S_Tape_Size (THREE_MEG - S_Disk_Size1 - S_Disk_Size2)/* not used*/ /* Used for memget() */ #define S_Mem_Size (S_Disk_Size1 + S_Disk_Size2 + S_Tape_Size ) /* * Now if we need the absolute offsets for each unit for * direct access into the RAM area. */ #define S_sctrs S_sec_size #define S_hds S_sec_size * S_sectors /* Drive 1 */ #define S_cyl S_sec_size * S_sectors * S_heads #define S_hds2 S_sec_size * S_sectors2 /* Drive 2 */ #define S_cyl2 S_sec_size2 * S_sectors2 * S_heads2 /* * For example lets say we want the cyl 10, head 1, and sector 5. * The triplet would be [ 10 ] [ 1 ] [ 5 ]. * The offset from the begining would be * * (10 * S_cyl) + ( 1 * S_hds ) + ( 5 * S_sctrs ) * * The Sdsk driver does not use this, it gives logical offsets * so we don't need this. */ /* * provided for the read capacity command */ #define S_cap1 (S_sectors * S_heads * S_cylinders) #define S_cap2 (S_sectors2 * S_heads2 * S_cylinders2) #define S_cap3 (S_Tape_Size / S_sec_size) /* not used*/ /* Provide the capacity of the disk. SCSI says return the address of the */ /* last block which will be one less than the capacity. I.E. 10 blocks */ /* total would be blocks 0 through 9. The capacity cmd returns 9. */ /* The Sdsk Driver uses (capacity + 1)/(heads * sectors) for cylinders. */ /* The Sdsk Driver is expecting reverse byte order. So we switch them. */ /* The last block info is set at init time and sector size never changes.*/ static struct READ_CAP_INFO { long last; /* address of the last block on device */ long bytes_per_sector; /* size in bytes of each block */ } Sram_cap_info[NDRIVES]={S_cap1-1,0x00020000, /* 3072 and 512 1536K */ S_cap2-1,0x00020000, /* 3072 and 512 1536K */ S_cap3-1,0x00020000};/* 000 and 512 0K */ /* Total = 3072K */ static unsigned char *Sram_disk_ptr; static unsigned char *Sram_disk_ptr2; static unsigned char *Sram_tape_ptr; /* not used*/ struct scsi_ha_cfg Sramcfg[1]; /* local define */ static struct Shareg_ex regit; /* Used for the Sharegister() call */ static HAINFO Sram_info; static int req_ready = 0; /* used by poll routine to see if there are */ /* any outstanding requests that need service */ static int from_poll = 0; /* flag to check if the Sramintr function was */ /* called from the poll routine. */ static int opened = 0; static char htag[] = "SCSI_TAG_HEAD"; static char otag[] = "SCSI_TAG_ORDER"; static char stag[] = "SCSI_TAG_SIMPLE"; static char ntag[] = ""; REQ_IO *rl_array[10]; static int index = 0; 07070100023801000081a400000000000000030000000136df58a70000219500001dff0000000100000000000000000000002800000000reloc/usr/src/O5hdk/samples/Sram/adSram: # # Copyright (C) 1992-1999 The Santa Cruz Operation, Inc. # # The information in this file is provided for the exclusive use of the # licensees of The Santa Cruz Operation, Inc. Such users have the right # to use, modify, and incorporate this code into other products for purposes # authorized by the license agreement, provided they include this notice # and the associated copyright notice with any such product. The # information in this file is provided "AS IS" without warranty. # # # # This shell script adds and removes the driver specified by the # PREF variable to and from the SCO UNIX kernel. It provides this # feature from your work directory without having to cd up and down # the file system. If the driver is already installed it allows the # user to copy the new driver.o to the LINK kit pack.d/PREF/Driver.o. # Hopefully it saves the user some time. # With a driver prefix of xx, the shell script should be called # "adxx" with a link to rmxx. The object will be refered to as xx.o. # Please see the ln(C) command for more info on file links. If you # dont make the new kernal the default, the next time you # boot you can select it by typing "sram" at the "boot:" prompt. # To do this add the line from either boot.entry or boot5.entry to # your /etc/default/boot file. # # In case you don't know about it, you will find the SCO OpenServer # kernel debugger very usefull. To use it just turn it on with # your next relink. ( change /etc/conf/sdvice.d/scodb N -> Y ) # Control x gets you in and q returns you to the kernel. You # may also set it up to break into the debugger at kernel main # by changing a filed in /etc/conf/pack.d/scodb/tune.h. Please # refer to the sco man pages for details. man scodb(ADM) # PATH=/bin:/etc:/usr/bin SHELL=/bin/sh export PATH SHELL OK=0 FAIL=1 PREF="Sram" # Driver prefix NOTE: this is hard coded in a few places. PREFL="sram" # Lower case HERE=`pwd` # Current build directory # # This is a demo/help script not a production tool. # This script uses an old interface to add the sample driver. # Users should use idinstall instead of the xenix configure # command. Please see man idinstall(ADM). # # Also note that this driver although it is a HBA sample # it specifies an IRQ in it's sdevice file. /etc/conf/sdevice.d # Sram. The mkdev hd script will prompt the user for changes. # If you have a pci device you will want to put a 0 in this field. # SPL="5" # Kernel SPL that is set when driver is called. VECTOR="15" # Otherwise known as interrupt ( faked ) IOADDR="c90 c9f" # I/O adresses that board uses FUNCTIONS="${PREF}init ${PREF}poll ${PREF}intr ${PREF}ioctl ${PREF}open ${PREF}close" ############################################################################## # # Prompt for yes or no answer - returns non-zero for no # getyn(){ while echo "$* (y/n)? \c" >&2 do read yn rest case $yn in [Yy]) return $OK ;; [Nn]) return $FAIL ;; *) echo "\n\tPlease answer y or n" >&2 ;; esac done } ############################################################################## # # Add the $PREF scsi host dummy driver to the kernel. # # Driver is allready installed in kernel. # Copy the Driver.o or Pref.o as well as any space.c and stubs.c # addvr(){ cd /etc/conf/cf.d [ -d /etc/conf/pack.d/${PREF} ] || mkdir /etc/conf/pack.d/${PREF} if [ -f "${HERE}/${PREF}.o" ] ; then cp /${HERE}/${PREF}.o /etc/conf/pack.d/${PREF}/Driver.o fi if [ -f "${HERE}/Driver.o" ] ; then cp /${HERE}/Driver.o /etc/conf/pack.d/${PREF}/Driver.o fi if [ -f "${HERE}/space.c" ] ; then cp /${HERE}/space.c /etc/conf/pack.d/${PREF}/space.c fi if [ -f "${HERE}/stubs.c" ] ; then cp /${HERE}/stubs.c /etc/conf/pack.d/${PREF}/stubs.c fi # # The Sdsk driver is currently off. Turn it on! # Note that we aren't going to turn it off again # when we remove the driver. # if [ -z "`grep Y /etc/conf/sdevice.d/Sdsk`" ] ; then sed 's/N/Y/' /etc/conf/sdevice.d/Sdsk > /tmp/out$$ mv /tmp/out$$ /etc/conf/sdevice.d/Sdsk fi MJNUM="`./configure -j $PREF 2>&1`" if [ "${MJNUM}" != "No such device" ] ; then echo "\n\t$PREF driver already installed. Use rm${PREF} to remove it" getyn "\tWould you like to copy the new ${PREF}.o to Driver.o" && { cp /${HERE}/${PREF}.o /etc/conf/pack.d/${PREF}/Driver.o if [ -f "${HERE}/space.c" ] ; then cp /${HERE}/space.c /etc/conf/pack.d/${PREF}/space.c fi getyn "\n\tRelink a new kernel" && { ./link_unix <<-DONE n DONE echo "" if [ "$STANDDIR" ] ; then umount /dev/boot mount /dev/boot /stand cp ./unix /stand/unix.sram umount /dev/boot mount -r /dev/boot /stand fi } } exit 0 fi ################################### # # Driver needs to be added # MJNUM="`./configure -jNEXTMAJOR 2>&1`" echo "\n\t$PREF driver using major number $MJNUM" ./configure -c -q -m $MJNUM -v ${VECTOR} -l ${SPL} -I ${IOADDR} \ -a ${FUNCTIONS} 2>&1 # # If we pop these into mscsi then the device.dat file and Sdsk/space.c # files get messed up. # # [ -z "`grep $PREF mscsi`" ] && { # echo "\n\tAdding mscsi entry for $PREF devices" # cat ${HERE}/mscsi.entry >> ./mscsi # } # [ -z "`grep -i $PREF /etc/default/boot`" ] && { echo "\n\tAdding /etc/default/boot entry. The next time" echo "\tyou reboot the kernel, type \"sram\" at the \"boot:\"" echo "\tprompt. This will bring up either unix.sram or " echo "\t/etc/conf/cf.d/unix. \n" if [ "$STANDDIR" ] ; then cat ${HERE}/boot5.entry >> /etc/default/boot else cat ${HERE}/boot.entry >> /etc/default/boot fi } getyn "\n\tRelink a new kernel" && { echo "\n\tThis will not be the default kernel.\n" ./link_unix <<-DONE n DONE echo "" if [ "$STANDDIR" ] ; then umount /dev/boot mount /dev/boot /stand cp ./unix /stand/unix.sram umount /dev/boot mount -r /dev/boot /stand fi echo "\n\tNow you must reboot the new kernel and then" echo "\trun mkdev hd to add the disk entry to the kernel." echo "\tThis will require yet another relink of the kernel" echo "\tDon't make this the default boot kernel. If you" echo "\thave a /stand, this script moves it to /stand/unix.sram." echo "\tIt performs a: btmnt -w" echo "\t cp /etc/conf/cf.d/unix /stand/unix.sram" echo "\t btmnt -r" echo "\tIf you have done an upgrade then leave it in" echo "\t/etc/conf/cf.d." echo "\tEither way you can type sram at the boot prompt to" echo "\tyour new kernel." echo "\nDone !\n" } } ############################################################################## # # Remove the $PREF scsi host dummy driver from the kernel. # removedvr(){ cd /etc/conf/cf.d MJNUM="`./configure -j $PREF 2>&1`" if [ "$MJNUM" = "No such device" ] then echo "\n\t$PREF driver not installed, use ad$PREF to add it." exit 0 fi echo "\tRemoving the ${PREF} driver from the kernel configuration" ./configure -d -m $MJNUM -c 2>&1 [ -z "`grep ${PREF} mscsi`" ] || { echo "\tRemoving mscsi entry for ${PREF} devices" mv mscsi mscsi.old sed /\^Sram/d mscsi.old > mscsi chmod 644 mscsi chgrp sys mscsi rm mscsi.old } # # NOTE: The labels in /etc/default/boot are lower case # Remember that /etc/default/boot will be copied to /stand # [ ! -z "`grep -i $PREF /etc/default/boot`" ] && { echo "\tRemoving entry from etc/default/boot" mv /etc/default/boot /etc/default/boot.old sed /\^sram/d /etc/default/boot.old > /etc/default/boot chmod 644 /etc/default/boot chown bin /etc/default/boot chgrp bin /etc/default/boot rm /etc/default/boot.old } if [ "$STANDDIR" ] ; then echo "\tRemoving /stand/unix.sram" umount /dev/boot mount /dev/boot /stand rm /stand/unix.sram umount /dev/boot mount -r /dev/boot /stand fi rm -rf /etc/conf/pack.d/$PREF getyn "\n\tRelink a new kernel" && ./link_unix echo "\nDone !" } ############################################################################## # # Main. # STANDDIR="" if [ -b /dev/boot ] ; then STANDDIR="YES" fi IAM=`basename $0` case $IAM in "ad${PREF}") getyn "\n\tAdd the $PREF driver" && { addvr } ;; "rm${PREF}") getyn "\n\tRemove the $PREF driver" && { removedvr } ;; *) esac exit 0 07070100023802000081a400000000000000030000000136df58a70000001f00001dff0000000100000000000000000000002c00000000reloc/usr/src/O5hdk/samples/Sram/boot.entrysram=hd(40)/etc/conf/cf.d/unix 07070100023803000081a400000000000000030000000136df58a80000001500001dff0000000100000000000000000000002d00000000reloc/usr/src/O5hdk/samples/Sram/boot5.entrysram=hd(40)unix.sram 07070100023806000081a400000000000000030000000136df58b60000017a00001dff0000000100000000000000000000002d00000000reloc/usr/src/O5hdk/samples/Sram/mscsi.entry# # These two entries below are what will be # added to the /etc/conf/cf.d/mscsi file # after you have done a mkdev hd to add the # two RAM disks. If you brute force them # the Sdsk space.c file may get out of sync # with the system and you will get link # warnings. If you are just testing and this # is a scratch system, go for it. # Sram Sdsk 0 0 0 0 Sram Sdsk 0 1 0 0 07070100023808000081a400000000000000030000000136df58c7000047c700001dff0000000100000000000000000000002800000000reloc/usr/src/O5hdk/samples/Sram/scsi.h#ifndef _SYS_SCSI_H #define _SYS_SCSI_H #ifdef __STDC__ #pragma comment(exestr, "@(#) scsi.h 68.1 98/01/30 ") #else #ident "@(#) scsi.h 68.1 98/01/30 " #endif /* * Copyright (C) 1988-1999 The Santa Cruz Operation, Inc. * All Rights Reserved. * The information in this file is provided for the exclusive use of * the licensees of The Santa Cruz Operation, Inc. Such users have the * right to use, modify, and incorporate this code into other products * for purposes authorized by the license agreement provided they include * this notice and the associated copyright notice with any such product. * The information in this file is provided "AS IS" without warranty. */ /* * Portions Copyright (C) Corollary, Inc., 1986-1991. * All Rights Reserved. * This Module contains Proprietary Information of * Corollary, Inc., and should be treated as Confidential. */ #ifdef _M_I386 #pragma pack(4) #else #pragma pack(2) #endif #define SCSI_MAXDEVS 16 /* maximum number of each device type supported under SCSI */ #define SCSI_MAX_SG NBCLUSTER /* from sys/param.h */ #define SCSI_CMD_LEN 14 /* Maximum SCSI command length */ #define INQUIRY_LEN 40 /* 2 bytes of data required */ #define MODE_LEN 200 /* 200 bytes of data required */ #define READ_CAP_LEN 8 #define SCSI_SEND 0 /* types of adapter calls */ #define SCSI_INIT 1 /* SCO gets 0 - 50 */ #define SCSI_DEV_RESET 2 /* reset a specific target ID */ #define SCSI_SG 3 /* do scatter-gather command */ #define SCSI_INFO 4 /* return info about capabilities */ #define SCSI_RESERVE 5 /* reserve resources at task time */ #define SCSI_ABORT 6 /* abort last command issued */ #define SCSI_SEND_NC 7 /* Normal command - do not cache */ #define SCSI_SG_NC 8 /* scatter-gather - do not cache */ #define SCSI_GET_LIMITS 9 /* return info about config limits */ #define SCSI_ATAPI_MLUN 10 /* ask for multiple LUNs, ATAPI only*/ #define SCSI_IO 0 /* type of transaction */ #define SCSI_HA_CMD 1 #define SCSI_GO 1 /* start */ #define SCSI_IN 1 /* transfer direction */ #define SCSI_OUT 2 #define SCSI_UNITNO 0x0000FFFF /* peripheral physical unit number */ #define SCSI_DEVERR 0x00030000 /* when to print sense errors: */ /** 0x00000000 ** cannot use - backwards compat */ #define SCSI_PR_ALWAYS 0x00010000 /* string & always numbers */ #define SCSI_PR_UNKNOWN 0x00020000 /* num only if no string */ #define SCSI_PR_NEVER 0x00030000 /* nothing */ /* * Values for internal field of REQ_IO structure * */ #define SCSI_REQ_NOTINT 0 /* Not staged by driver */ #define SCSI_REQ_INTERNAL 1 /* SCSI command staged by driver */ #define SCSI_REQ_PARTCMD 2 /* Partialy complete command */ /* * Values for 'hacmd' field * */ #define SCSI_VER_INFO -1 /* adapter drvr info */ #define SCSI_DISK_INFO 0 /* adapter disk info */ #define SCSI_TAPE_INFO 1 /* adapter tape info */ #define SCSI_SET_ASYNC 2 /* ensure async xfer */ /* tagged request values */ #define SCSI_TAG_CMD 0x40 /* test for tagged request */ #define SCSI_TAG_HEAD (SCSI_TAG_CMD|0x01) /* request to head of queue */ #define SCSI_TAG_ORDER (SCSI_TAG_CMD|0x02) /* use request in order sent */ #define SCSI_TAG_SIMPLE (SCSI_TAG_CMD|0x03) /* use request in any order */ #define NADAPTERS 2 /* number of adapters supported */ #define NADCTLS 16 /* this many controllers */ #define NAD 4 /* this many devices per ctlr */ #define CMDLENGTH 14 /* MAX SCSI command length */ #define SENSE_LEN 14 /* length of sense data */ #define EXTD_SENSE_LEN 255 /* length of extended sense data*/ #define NADDEVICES (NAD * NADCTLS) /* total possible devices */ #define NADRETRY 4 /* max software retry count */ #define OUTBOARD 2 /* used for getablk calls */ /* sense bit definitions */ #define SS_FM 0x80 /* file mark detected */ #define SS_EOM 0x40 /* end-of-media */ #define SS_ILI 0x20 /* illegal length indicator */ #define SS_SKEY 0x0F /* sense key mask */ /* sense key definitions */ #define SS_NONE 0x0 /* no sense */ #define SS_SOFT 0x1 /* recoverable error */ #define SS_NOTRDY 0x2 /* drive not ready */ #define SS_MEDERR 0x3 /* media error */ #define SS_HARDERR 0x4 /* hardware error */ #define SS_ILLREQ 0x5 /* illegal request */ #define SS_UATT 0x6 /* unit attention */ #define SS_WPROT 0x7 /* write protected */ #define SS_BLANK 0x8 /* blank check */ #define SS_COPYAB 0xA /* copy aborted */ #define SS_CMDAB 0xB /* command aborted */ #define SS_VOFLOW 0xD /* volume overflow */ #define LTHIB(x) ( (x >> 24) & 0xff) #define LTMSB(x) ( (x >> 16) & 0xff) #define LTMID(x) ( (x >> 8) & 0xff) #define LTLSB(x) ( x & 0xff) #define LTBLKS(x) ( x >> 9) /* driver issued commands */ #define CMD_INVALID 0xFF /* invalid command */ #define TEST_CMD 0x00 #define SENSE_CMD 0x03 #define REASSIGN_CMD 0x07 #define REASSIGN_IND 0xFF /* special case, see adioctl */ #define RD_BACK_CMD 0x07 #define READ_CMD 0x08 #define WRITE_CMD 0x0A #define REWIND_CMD 0x01 /* also a recal */ #define SEEK_CMD 0x0B #define SETTRK_CMD 0x0B #define FORMAT_CMD 0x04 #define INQUIRY_CMD 0x12 #define MODESELECT_CMD 0x15 #define MODESENSE_CMD 0x1A #define MODESENSE10_CMD 0x5A #define READ_CAP_CMD 0x25 #define READTEN_CMD 0x28 #define WRITETEN_CMD 0x2A #define SEEKTEN_CMD 0x2B #define SYNCHRONIZE_CMD 0x35 #define MM_LOAD_CMD 0xA6 /* MultiMedia load/unload */ #define MEC_STATUS_CMD 0xB8 /* MultiMedia mechanism status */ /* specific device commands */ #define TP_RDB 0x0F #define TP_WFM 0x10 #define TP_SP 0x11 #define TP_LOAD 0x1B #define TP_ERASE 0x19 /* command specific option bits */ #define CCS_FORMAT 0x01 /* inquiry data in CCS format */ #define VENDOR_BITS 0x00 /* always zero */ #define FLAG_LINK 0x00 /* no linked commands */ #define WRTLENCHK 0x10 /* outbound lengths checked */ #define RDLENCHK 0x08 /* inbound lengths checked */ #define MODE_SP 0x01 /* save parameters bit */ #define FIXED 0x01 /* fixed size blocks */ #define IMMED 0x01 /* immediate status */ #define SILI_BIT 0x02 /* suppress incorrect length */ #define PCF 0x00 /* request current values */ #define PAGE_CODE_ERR 0x01 /* r/w error recovery */ #define PAGE_CODE_CON 0x02 /* disconnect & reconnect */ #define PAGE_CODE_FMT 0x03 /* DA format parameters (RO) */ #define PAGE_CODE_GEO 0x04 /* geometry parameters (RO) */ #define PAGE_CODE_DCP 0x39 /* Quatum DCP */ #define PAGE_CODE_ALL 0x3f /* request all fields */ #define FMTDAT_BIT 0x00 /* data list follows cmd */ #define CMPLST_BIT 0x00 /* list is not complete */ #define DEFECT_LST_FMT 0x00 /* grown list saved */ #define FMT_FLAGS (FMTDAT_BIT | CMPLST_BIT | DEFECT_LST_FMT) #define DATAPATTERN 0xEB /* format data pattern */ #define DEF_INTERL 0x10 /* default interleave */ #define FMT_OPTIONS 0x00 /* with Quantum in mind */ #define FUA_BIT 0x8 /* Force Unit Access bit */ #define RCD_BIT 0x01 /* Page 8, read cache disable bit */ /* sense keys */ #define SCSI_NO_SENSE 0 #define SCSI_REC_ERROR 1 #define SCSI_NOT_READY 2 #define SCSI_MED_ERROR 3 #define SCSI_HARD_ERROR 4 #define SCSI_ILL_REQ 5 #define SCSI_UNIT_ATTN 6 #define SCSI_DATA_PROT 7 #define SCSI_BLANK_CHK 8 #define SCSI_VEND_UNIQ 9 #define SCSI_COPY_ABORT 10 #define SCSI_CMD_ABORT 11 #define SCSI_EQUAL 12 #define SCSI_VOL_OVF 13 #define SCSI_MISCOMPARE 14 #define SCSI_RESERVED 15 #define REQ_DONE 0x01 /* command completed OK */ #define REQ_ABORTED_OK 0x02 /* command aborted by host */ #define REQ_ABORTED_BAD 0x03 /* aborted command not found */ #define REQ_DONE_ERROR 0x04 /* command completed w/ errors */ #define REQ_LINKED_OK 0x0A /* linked cmd completed OK */ #define REQ_LINKED_BAD 0x0B /* linked cmd completed BAD */ #define REQ_TIMEOUT 0x11 /* selection time out */ #define REQ_OVERRUN 0x12 /* data overrun */ #define REQ_BUS_FREE 0x13 /* unexpected bus free */ #define REQ_BUS_PHASE 0x14 /* target bus phase seq. error */ #define REQ_COMMAND 0x15 /* command is not allowed */ /* * Used by bootstring functions to hold errors until after os/bs.c * has completed successfully */ #define SCSI_BOOT_EDEV 1 #define SCSI_BOOT_EHA 2 #define SCSI_BOOT_EDPARM 4 #define SCSI_BOOT_EHPARM 8 #define SCSI_BOOT_EDNPARM 16 /* * Magic Numbers for struct exten "type" field */ #define MAGIC_BUS 0xdeadbabe struct exten { /* extension structre */ int type; /* type of extension */ struct exten *next; /* pointer to next extension */ char data[20]; /* most adapters do byte I/O */ }; typedef struct exten EXTENSION; struct scsi_dev_cfg { int index; char *dev_name; /* device prefix */ dev_t devnum; /* device number */ unsigned char ha_num; /* host adapter number (0, 1, 2, ...) */ unsigned char id; /* SCSI priority and address */ unsigned char lun; /* logical unit number of device */ unsigned char distributed; /* used for multiprocessing purposes */ int (*adapter_entry)(); /* host adapter entry point */ struct exten *dext; /* extensions to SCSI spec */ }; typedef struct scsi_dev_cfg DEVCFG; struct scsi_ha_cfg { paddr_t ha_base; /* host adapter base address */ char *ha_name; /* host adapter prefix */ unsigned char ha_num; /* host adapter number (0, 1, 2, ...) */ unsigned char dmach; /* dma channel */ unsigned char vec; /* interrupt channel */ int (*adapter_entry)(); /* host adapter entry point */ struct exten *hext; /* extensions to SCSI spec */ }; typedef struct scsi_ha_cfg HACFG; struct scsi_ha_vect { char *name; /* driver name from mdevice */ HACFG *cfgp; /* pointer to SCSI ha cfg array */ int (*init)(); /* xxinit routine */ int (*start)(); /* xxstart routine */ int (*intr)(); /* xxintr routine */ int (*halt)(); /* xxhalt routine */ }; typedef struct scsi_ha_vect HAVECT; #pragma pack(1) struct inq_data { char dev_type; /* device type */ char rmb_dtq; /* RMD & dev type qualifier */ char vers; /* version */ char rdf; /* response data format */ char len; /* length of additional data */ char add_data; /* optional data area */ } ; typedef struct inq_data INQ_DATA; /* mode sense/select data structures */ struct scsi_block_descr { char density; char num_blks[3]; char reserved; char blk_len[3]; }; struct scsi_mode_sense { unsigned char data_len; unsigned char medium; unsigned char speed:4; unsigned char buffered:3; unsigned char wprot:1; unsigned char bdescr_len; struct scsi_block_descr bdescr; }; struct scsi_sense { unsigned char error:7; unsigned char valid:1; unsigned char segno; unsigned char key:4; unsigned char reserved:1; unsigned char ili:1; unsigned char eom:1; unsigned char filemark:1; long info; unsigned char addl_len; unsigned long cmdinfo; unsigned char addl_code; unsigned char addl_qual; /* unsigned char fruc; unsigned char key_specific[3];*/ }; struct scsi_x_sense { unsigned char error:7; unsigned char valid:1; unsigned char segno; unsigned char key:4; unsigned char reserved:1; unsigned char ili:1; unsigned char eom:1; unsigned char filemark:1; long info; unsigned char addl_len; unsigned long cmdinfo; unsigned char addl_code; unsigned char addl_qual; unsigned char fruc; union { unsigned char key_specific[3]; struct scsi_x_sense_fpb { /* Field Pointer Bytes */ unsigned char sksv:1; unsigned char cd:1; /* Command/Data */ unsigned char resvd:2; /* Reserved */ unsigned char bpv:1; /* Bit Pointer Valid */ unsigned char bp:3; /* Bit Pointer */ unsigned char fp[2]; /* Field Pointer */ } fp_b; struct scsi_x_sense_arc { /* Actual Retry Count Bytes */ unsigned char sksv:1; unsigned char resvd:7; unsigned char arc[2]; /* Actual Retry Count */ } arc_b; struct scsi_x_sense_fpi { /* Format Progress Indication */ unsigned char sksv:1; unsigned char resvd:7; unsigned char pi[2]; /* Progress Indicator */ } pi_b; } ks; }; union scsi_cdb { struct SixCmd { unsigned char opcode; unsigned char misc:5; unsigned char lun:3; unsigned char data[3]; unsigned char control; } six; struct TenCmd { unsigned char opcode; unsigned char misc:5; unsigned char lun:3; unsigned long block; unsigned char reserved; unsigned short length; unsigned char control; } ten; struct TwelveCmd { unsigned char opcode; unsigned char misc:5; unsigned char lun:3; unsigned long block; unsigned long length; unsigned char reserved; unsigned char control; } twelve; unsigned char raw[12+sizeof(struct scsi_sense)]; }; #ifdef _M_I386 #pragma pack(4) #else #pragma pack(2) #endif struct scsi_io_req { /* scsi io request block */ unsigned short req_type; /* one of the classes of calls to the adapter driver module */ struct scsi_io_req *req_forw; /* forward pointer to next scsi_io request block */ struct exten *ext_p; /* normally reserved, ptr to SCSI extensions structure */ char opcode; char id; char lun; char ha_num; /* host adapter number */ char dir; char cmdlen; /* CMDLENGTH */ paddr_t data_len; /* data length */ paddr_t data_ptr; /* data pointer */ paddr_t data_blk; /* logical block */ paddr_t link_ptr; /* link pointer */ char link_id; char host_sts; char target_sts; char bus_num; /* 3.2.5 multibus support */ union scsi_cdb scsi_cmd; char sense_len; paddr_t scsi_sense; paddr_t req_id; /* request block's id */ /* below is only used by each driver */ char use_flag; /* zero if available */ char internal; /* driver internal request if non-zero */ char jq; /* job queue index */ char ctlr; /* controller address */ char req_status; /* req blk status at intr time */ char adapter; /* adapter base address */ char r_count; /* retry count */ char hacmd; /* host adapter command */ struct buf * rbuf; /* request per this buf if non zero */ int (*io_intr)(); /* device driver intr handler */ char *s1; /* for use by drivers */ char *s2; }; typedef struct scsi_io_req REQ_IO; struct scsi_sg_list { unsigned int length; paddr_t data; }; struct scsi_ha_info { u_int do_sg:1; /* adapter does scatter/gather */ u_int do_buffer:1; /* adapter buffers cmds */ u_int do_tagged:1; /* adapter supports tagged cmds */ u_int do_resource:1; /* must reserve resources */ u_int do_xtd_sense:1; /* supports extended sense */ u_int do_drive32:1; /* adapter drives 32-bit addresses */ u_int do_nomaps:1; /* does not require Corollary maps */ u_int do_reset:1; /* supports SCSI_DEV_RESET command */ u_int do_abort:1; /* supports SCSI_ABORT command */ u_int do_cache_ctl:1; /* supports cache control */ u_int has_cache:1; /* adapter has a cache */ u_int do_get_limits:1; /* adapter can return config limits */ u_int reserved:20; /* reserved for future use */ }; typedef struct scsi_ha_info HAINFO; struct scsi_inq_data { unsigned char dev :5; unsigned char qual :3; unsigned char dev_qual :7; unsigned char rmb :1; unsigned char ansi :3; unsigned char ecma :3; unsigned char iso :2; unsigned char response :4; unsigned char reserved :3; unsigned char aenc :1; unsigned char addl_len; unsigned char reserved2[2]; unsigned char stuff; unsigned char vendor_id[8]; unsigned char product_id[16]; unsigned char product_level[4]; }; #ifdef _INKERNEL /* Hide from normal users (especially C++) */ # if defined(__STDC__) && !defined(_NO_PROTOTYPE) extern void scsi_mkadr3( /* convert 4 byte address to 3 byte address */ void *, /* 3 byte field */ void * /* 4 byte field MSB not used... */ ); extern caddr_t scsi_stok(void *); /* scsi 3 byte adr to kernel */ extern long scsi_s3tol(void *); /* scsi 3 byte value to 4 byte */ extern long scsi_stol(void *); /* scsi 4 byte value to 4 byte */ extern void scsi_perror(REQ_IO *, char *, char *); # if 0 /*** slight problem with variable argument lists in 3.2v4 ... ***/ extern void scsi_deverr( REQ_IO *, /* I/O request (may be NULL) */ char *, /* Peripheral driver (e.g., "Stp") */ char *, /* Error message format (may be NULL) */ char *, /* Peripheral type (e.g., "tape") */ unsigned, /* Physical unit num + SCSI_PR_... */ dev_t, /* UNIX device number (may be NODEV) */ ... /* printf(K) args, msg is format */ ); # endif extern void scsi_prsense(int, unsigned, REQ_IO *); extern int scsi_sense_error(char *, uchar_t, uchar_t, uchar_t, uchar_t, uchar_t); # else extern void scsi_mkadr3(); /* convert 4 byte address to 3 byte address */ extern caddr_t scsi_stok(); /* scsi 3 byte adr to kernel */ extern long scsi_s3tol(); /* scsi 3 byte value to 4 byte */ extern long scsi_stol(); /* scsi 4 byte value to 4 byte */ extern void scsi_perror(); extern void scsi_deverr(); extern void scsi_prsense(); extern int scsi_sense_error(); # endif #endif /* _INKERNEL */ struct scsi_oemtab { char *name; char *model; int (*init_fn)(); }; #define F_OPEN 1 #define F_CLOSE 2 #define F_IOCTL 3 #define F_CMD 4 #define SCSI_V3_MAGIC 0xfeedface typedef struct { u_char cylin; u_char heads; u_char sectors; u_char blksz; /* Natural Disk block size = 512 << blksz */ u_long capacity; /* Always passed in 512 byte blocks */ u_long magic; u_char v_maj; u_char v_min; } scsi_disk_info; typedef struct { u_short cylin; u_short heads; u_short sectors; u_short bytes; u_long magic; u_char v_maj; u_char v_min; } scsi_xdisk_info; typedef struct { u_char pad[8]; u_long magic; u_char v_maj; u_char v_min; } scsi_dev_info; #define SCSI_MAGIC_LIMITS 0xa5b4c3d2 typedef struct { u_long magic; u_char num_buses; u_char num_ids; u_char pad[8]; } scsi_max_config_info; #define SCSI_V3_VERSION 3 #define SCSI_IPL 5 #define SCSI1 1 #define SCSI2 2 #pragma pack() #endif /* _SYS_SCSI_H */ 07070100023809000081a400000000000000030000000136df58c70000034b00001dff0000000100000000000000000000002900000000reloc/usr/src/O5hdk/samples/Sram/space.c#ident "@(#) space.c 77.1 99/03/05 " /* * Copyright (C) 1990-1999 The Santa Cruz Operation, Inc. * All Rights Reserved. * The information in this file is provided for the exclusive use of * the licensees of The Santa Cruz Operation, Inc. Such users have the * right to use, modify, and incorporate this code into other products * for purposes authorized by the license agreement provided they include * this notice and the associated copyright notice with any such product. * The information in this file is provided "AS IS" without warranty. */ /* * Sample space.c file. This example shows the * include for the link time config file * /etc/conf/cf.d/config.h. * * If you need to put globals in this file be sure * they *ALL* have the same prefix as your driver. * In this case it would be "Sram". */ #include 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000b00000000TRAILER!!!