gdth.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:166k
- (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock))
- continue;
- }
- if (firsttime) {
- if (gdth_test_busy(hanum)) { /* controller busy ? */
- TRACE(("gdth_next() controller %d busy !n",hanum));
- if (!gdth_polling) {
- GDTH_UNLOCK_HA(ha, flags);
- return;
- }
- while (gdth_test_busy(hanum))
- gdth_delay(1);
- }
- firsttime = FALSE;
- }
- #if LINUX_VERSION_CODE >= 0x010300
- if (nscp->done != gdth_scsi_done || nscp->cmnd[0] != 0xff)
- #endif
- {
- if (nscp->SCp.phase == -1) {
- nscp->SCp.phase = CACHESERVICE; /* default: cache svc. */
- if (nscp->cmnd[0] == TEST_UNIT_READY) {
- TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %dn",
- b, t, nscp->lun));
- /* TEST_UNIT_READY -> set scan mode */
- if ((ha->scan_mode & 0x0f) == 0) {
- if (b == 0 && t == 0 && nscp->lun == 0) {
- ha->scan_mode |= 1;
- TRACE2(("Scan mode: 0x%xn", ha->scan_mode));
- }
- } else if ((ha->scan_mode & 0x0f) == 1) {
- if (b == 0 && ((t == 0 && nscp->lun == 1) ||
- (t == 1 && nscp->lun == 0))) {
- nscp->SCp.sent_command = GDT_SCAN_START;
- nscp->SCp.phase = ((ha->scan_mode & 0x10 ? 1:0) << 8)
- | SCSIRAWSERVICE;
- ha->scan_mode = 0x12;
- TRACE2(("Scan mode: 0x%x (SCAN_START)n",
- ha->scan_mode));
- } else {
- ha->scan_mode &= 0x10;
- TRACE2(("Scan mode: 0x%xn", ha->scan_mode));
- }
- } else if (ha->scan_mode == 0x12) {
- if (b == ha->bus_cnt && t == ha->tid_cnt-1) {
- nscp->SCp.phase = SCSIRAWSERVICE;
- nscp->SCp.sent_command = GDT_SCAN_END;
- ha->scan_mode &= 0x10;
- TRACE2(("Scan mode: 0x%x (SCAN_END)n",
- ha->scan_mode));
- }
- }
- }
- if (b == ha->virt_bus && nscp->cmnd[0] != INQUIRY &&
- nscp->cmnd[0] != READ_CAPACITY && nscp->cmnd[0] != MODE_SENSE &&
- (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) {
- /* always GDT_CLUST_INFO! */
- nscp->SCp.sent_command = GDT_CLUST_INFO;
- }
- }
- }
- if (nscp->SCp.sent_command != -1) {
- if ((nscp->SCp.phase & 0xff) == CACHESERVICE) {
- if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t)))
- this_cmd = FALSE;
- next_cmd = FALSE;
- } else if ((nscp->SCp.phase & 0xff) == SCSIRAWSERVICE) {
- if (!(cmd_index=gdth_fill_raw_cmd(hanum,nscp,BUS_L2P(ha,b))))
- this_cmd = FALSE;
- next_cmd = FALSE;
- } else {
- memset((char*)nscp->sense_buffer,0,16);
- nscp->sense_buffer[0] = 0x70;
- nscp->sense_buffer[2] = NOT_READY;
- nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
- if (!nscp->SCp.have_data_in)
- nscp->SCp.have_data_in++;
- else {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- }
- } else
- #if LINUX_VERSION_CODE >= 0x010300
- if (nscp->done == gdth_scsi_done && nscp->cmnd[0] == 0xff) {
- if (!(cmd_index=gdth_special_cmd(hanum,nscp)))
- this_cmd = FALSE;
- next_cmd = FALSE;
- } else
- #endif
- if (b != ha->virt_bus) {
- if (ha->raw[BUS_L2P(ha,b)].io_cnt[t] >= GDTH_MAX_RAW ||
- !(cmd_index=gdth_fill_raw_cmd(hanum,nscp,BUS_L2P(ha,b))))
- this_cmd = FALSE;
- else
- ha->raw[BUS_L2P(ha,b)].io_cnt[t]++;
- } else if (t >= MAX_HDRIVES || !ha->hdr[t].present || nscp->lun != 0) {
- TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNOREn",
- nscp->cmnd[0], b, t, nscp->lun));
- nscp->result = DID_BAD_TARGET << 16;
- if (!nscp->SCp.have_data_in)
- nscp->SCp.have_data_in++;
- else {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- } else {
- switch (nscp->cmnd[0]) {
- case TEST_UNIT_READY:
- case INQUIRY:
- case REQUEST_SENSE:
- case READ_CAPACITY:
- case VERIFY:
- case START_STOP:
- case MODE_SENSE:
- TRACE(("cache cmd %x/%x/%x/%x/%x/%xn",nscp->cmnd[0],
- nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
- nscp->cmnd[4],nscp->cmnd[5]));
- if (ha->hdr[t].media_changed && nscp->cmnd[0] != INQUIRY) {
- /* return UNIT_ATTENTION */
- TRACE2(("cmd 0x%x target %d: UNIT_ATTENTIONn",
- nscp->cmnd[0], t));
- ha->hdr[t].media_changed = FALSE;
- memset((char*)nscp->sense_buffer,0,16);
- nscp->sense_buffer[0] = 0x70;
- nscp->sense_buffer[2] = UNIT_ATTENTION;
- nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
- if (!nscp->SCp.have_data_in)
- nscp->SCp.have_data_in++;
- else {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- } else if (gdth_internal_cache_cmd(hanum,nscp)) {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- break;
- case ALLOW_MEDIUM_REMOVAL:
- TRACE(("cache cmd %x/%x/%x/%x/%x/%xn",nscp->cmnd[0],
- nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
- nscp->cmnd[4],nscp->cmnd[5]));
- if ( (nscp->cmnd[4]&1) && !(ha->hdr[t].devtype&1) ) {
- TRACE(("Prevent r. nonremov. drive->do nothingn"));
- nscp->result = DID_OK << 16;
- nscp->sense_buffer[0] = 0;
- if (!nscp->SCp.have_data_in)
- nscp->SCp.have_data_in++;
- else {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- } else {
- nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0;
- TRACE(("Prevent/allow r. %d rem. drive %dn",
- nscp->cmnd[4],nscp->cmnd[3]));
- if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t)))
- this_cmd = FALSE;
- }
- break;
-
- case RESERVE:
- case RELEASE:
- TRACE2(("cache cmd %sn",nscp->cmnd[0] == RESERVE ?
- "RESERVE" : "RELEASE"));
- if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t)))
- this_cmd = FALSE;
- break;
-
- case READ_6:
- case WRITE_6:
- case READ_10:
- case WRITE_10:
- if (ha->hdr[t].media_changed) {
- /* return UNIT_ATTENTION */
- TRACE2(("cmd 0x%x target %d: UNIT_ATTENTIONn",
- nscp->cmnd[0], t));
- ha->hdr[t].media_changed = FALSE;
- memset((char*)nscp->sense_buffer,0,16);
- nscp->sense_buffer[0] = 0x70;
- nscp->sense_buffer[2] = UNIT_ATTENTION;
- nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
- if (!nscp->SCp.have_data_in)
- nscp->SCp.have_data_in++;
- else {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- } else if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t)))
- this_cmd = FALSE;
- break;
- default:
- TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknownn",nscp->cmnd[0],
- nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
- nscp->cmnd[4],nscp->cmnd[5]));
- printk("GDT: Unknown SCSI command 0x%x to cache service !n",
- nscp->cmnd[0]);
- nscp->result = DID_ABORT << 16;
- if (!nscp->SCp.have_data_in)
- nscp->SCp.have_data_in++;
- else {
- GDTH_UNLOCK_HA(ha,flags);
- /* io_request_lock already active ! */
- nscp->scsi_done(nscp);
- GDTH_LOCK_HA(ha,flags);
- }
- break;
- }
- }
- if (!this_cmd)
- break;
- if (nscp == ha->req_first)
- ha->req_first = pscp = (Scsi_Cmnd *)nscp->SCp.ptr;
- else
- pscp->SCp.ptr = nscp->SCp.ptr;
- if (!next_cmd)
- break;
- }
- if (ha->cmd_cnt > 0) {
- gdth_release_event(hanum);
- }
- GDTH_UNLOCK_HA(ha, flags);
- if (gdth_polling && ha->cmd_cnt > 0) {
- if (!gdth_wait(hanum,cmd_index,POLL_TIMEOUT))
- printk("GDT: Controller %d: Command %d timed out !n",
- hanum,cmd_index);
- }
- }
-
- static void gdth_copy_internal_data(Scsi_Cmnd *scp,char *buffer,ushort count)
- {
- ushort cpcount,i;
- ushort cpsum,cpnow;
- struct scatterlist *sl;
- cpcount = count<=(ushort)scp->bufflen ? count:(ushort)scp->bufflen;
- if (scp->use_sg) {
- sl = (struct scatterlist *)scp->request_buffer;
- for (i=0,cpsum=0; i<scp->use_sg; ++i,++sl) {
- cpnow = (ushort)sl->length;
- TRACE(("copy_internal() now %d sum %d count %d %dn",
- cpnow,cpsum,cpcount,(ushort)scp->bufflen));
- if (cpsum+cpnow > cpcount)
- cpnow = cpcount - cpsum;
- cpsum += cpnow;
- memcpy((char*)sl->address,buffer,cpnow);
- if (cpsum == cpcount)
- break;
- buffer += cpnow;
- }
- } else {
- TRACE(("copy_internal() count %dn",cpcount));
- memcpy((char*)scp->request_buffer,buffer,cpcount);
- }
- }
- static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
- {
- register gdth_ha_str *ha;
- unchar t;
- gdth_inq_data inq;
- gdth_rdcap_data rdc;
- gdth_sense_data sd;
- gdth_modep_data mpd;
- ha = HADATA(gdth_ctr_tab[hanum]);
- t = scp->target;
- TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %dn",
- scp->cmnd[0],t));
- switch (scp->cmnd[0]) {
- case TEST_UNIT_READY:
- case VERIFY:
- case START_STOP:
- TRACE2(("Test/Verify/Start hdrive %dn",t));
- break;
- case INQUIRY:
- TRACE2(("Inquiry hdrive %d devtype %dn",
- t,ha->hdr[t].devtype));
- inq.type_qual = (ha->hdr[t].devtype&4) ? TYPE_ROM:TYPE_DISK;
- /* you can here set all disks to removable, if you want to do
- a flush using the ALLOW_MEDIUM_REMOVAL command */
- inq.modif_rmb = 0x00;
- if ((ha->hdr[t].devtype & 1) ||
- (ha->hdr[t].cluster_type & CLUSTER_DRIVE))
- inq.modif_rmb = 0x80;
- inq.version = 2;
- inq.resp_aenc = 2;
- inq.add_length= 32;
- if (ha->oem_id == OEM_ID_INTEL)
- strcpy(inq.vendor,"Intel ");
- else
- strcpy(inq.vendor,"ICP ");
- sprintf(inq.product,"Host Drive #%02d",t);
- strcpy(inq.revision," ");
- gdth_copy_internal_data(scp,(char*)&inq,sizeof(gdth_inq_data));
- break;
- case REQUEST_SENSE:
- TRACE2(("Request sense hdrive %dn",t));
- sd.errorcode = 0x70;
- sd.segno = 0x00;
- sd.key = NO_SENSE;
- sd.info = 0;
- sd.add_length= 0;
- gdth_copy_internal_data(scp,(char*)&sd,sizeof(gdth_sense_data));
- break;
- case MODE_SENSE:
- TRACE2(("Mode sense hdrive %dn",t));
- memset((char*)&mpd,0,sizeof(gdth_modep_data));
- mpd.hd.data_length = sizeof(gdth_modep_data);
- mpd.hd.dev_par = (ha->hdr[t].devtype&2) ? 0x80:0;
- mpd.hd.bd_length = sizeof(mpd.bd);
- mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16;
- mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8;
- mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff);
- gdth_copy_internal_data(scp,(char*)&mpd,sizeof(gdth_modep_data));
- break;
- case READ_CAPACITY:
- TRACE2(("Read capacity hdrive %dn",t));
- rdc.last_block_no = ntohl(ha->hdr[t].size-1);
- rdc.block_length = ntohl(SECTOR_SIZE);
- gdth_copy_internal_data(scp,(char*)&rdc,sizeof(gdth_rdcap_data));
- break;
- default:
- TRACE2(("Internal cache cmd 0x%x unknownn",scp->cmnd[0]));
- break;
- }
- scp->result = DID_OK << 16;
- scp->sense_buffer[0] = 0;
- if (!scp->SCp.have_data_in)
- scp->SCp.have_data_in++;
- else
- return 1;
- return 0;
- }
-
- static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive)
- {
- register gdth_ha_str *ha;
- register gdth_cmd_str *cmdp;
- struct scatterlist *sl;
- ushort i, cnt;
- ulong32 no;
- int cmd_index, read_write;
- ha = HADATA(gdth_ctr_tab[hanum]);
- cmdp = ha->pccb;
- TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %dn",
- scp->cmnd[0],scp->cmd_len,hdrive));
- if (ha->type==GDT_EISA && ha->cmd_cnt>0)
- return 0;
- cmdp->Service = CACHESERVICE;
- cmdp->RequestBuffer = scp;
- /* search free command index */
- if (!(cmd_index=gdth_get_cmd_index(hanum))) {
- TRACE(("GDT: No free command index foundn"));
- return 0;
- }
- /* if it's the first command, set command semaphore */
- if (ha->cmd_cnt == 0)
- gdth_set_sema0(hanum);
- /* fill command */
- read_write = FALSE;
- if (scp->SCp.sent_command != -1)
- cmdp->OpCode = scp->SCp.sent_command; /* special cache cmd. */
- else if (scp->cmnd[0] == RESERVE)
- cmdp->OpCode = GDT_RESERVE_DRV;
- else if (scp->cmnd[0] == RELEASE)
- cmdp->OpCode = GDT_RELEASE_DRV;
- else if (scp->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
- if (scp->cmnd[4] & 1) /* prevent ? */
- cmdp->OpCode = GDT_MOUNT;
- else if (scp->cmnd[3] & 1) /* removable drive ? */
- cmdp->OpCode = GDT_UNMOUNT;
- else
- cmdp->OpCode = GDT_FLUSH;
- } else if (scp->cmnd[0] == WRITE_6 || scp->cmnd[0] == WRITE_10) {
- read_write = TRUE;
- if (gdth_write_through || ((ha->hdr[hdrive].rw_attribs & 1) &&
- (ha->cache_feat & GDT_WR_THROUGH)))
- cmdp->OpCode = GDT_WRITE_THR;
- else
- cmdp->OpCode = GDT_WRITE;
- } else {
- read_write = TRUE;
- cmdp->OpCode = GDT_READ;
- }
-
- cmdp->BoardNode = LOCALBOARD;
- cmdp->u.cache.DeviceNo = hdrive;
- cmdp->u.cache.BlockNo = 1;
- cmdp->u.cache.sg_canz = 0;
- if (read_write) {
- if (scp->cmd_len != 6) {
- memcpy(&no, &scp->cmnd[2], sizeof(ulong32));
- cmdp->u.cache.BlockNo = ntohl(no);
- memcpy(&cnt, &scp->cmnd[7], sizeof(ushort));
- cmdp->u.cache.BlockCnt = (ulong32)ntohs(cnt);
- } else {
- memcpy(&no, &scp->cmnd[0], sizeof(ulong32));
- cmdp->u.cache.BlockNo = ntohl(no) & 0x001fffffUL;
- cmdp->u.cache.BlockCnt= scp->cmnd[4]==0 ? 0x100 : scp->cmnd[4];
- }
- if (scp->use_sg) {
- cmdp->u.cache.DestAddr= 0xffffffff;
- sl = (struct scatterlist *)scp->request_buffer;
- for (i=0; i<scp->use_sg; ++i,++sl) {
- cmdp->u.cache.sg_lst[i].sg_ptr = virt_to_bus(sl->address);
- cmdp->u.cache.sg_lst[i].sg_len = (ulong32)sl->length;
- }
- cmdp->u.cache.sg_canz = (ulong32)i;
- #ifdef GDTH_STATISTICS
- if (max_sg < (ulong32)i) {
- max_sg = (ulong32)i;
- TRACE3(("GDT: max_sg = %dn",i));
- }
- #endif
- if (i<GDTH_MAXSG)
- cmdp->u.cache.sg_lst[i].sg_len = 0;
- } else {
- if (ha->cache_feat & SCATTER_GATHER) {
- cmdp->u.cache.DestAddr = 0xffffffff;
- cmdp->u.cache.sg_canz = 1;
- cmdp->u.cache.sg_lst[0].sg_ptr =
- virt_to_bus(scp->request_buffer);
- cmdp->u.cache.sg_lst[0].sg_len = scp->request_bufflen;
- cmdp->u.cache.sg_lst[1].sg_len = 0;
- } else {
- cmdp->u.cache.DestAddr = virt_to_bus(scp->request_buffer);
- cmdp->u.cache.sg_canz= 0;
- }
- }
- }
- TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %xn",
- cmdp->u.cache.DestAddr,cmdp->u.cache.sg_canz,
- cmdp->u.cache.sg_lst[0].sg_ptr,
- cmdp->u.cache.sg_lst[0].sg_len));
- TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %dn",
- cmdp->OpCode,cmdp->u.cache.BlockNo,cmdp->u.cache.BlockCnt));
- /* evaluate command size, check space */
- ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) +
- (ushort)cmdp->u.cache.sg_canz * sizeof(gdth_sg_str);
- if (ha->cmd_len & 3)
- ha->cmd_len += (4 - (ha->cmd_len & 3));
- if (ha->cmd_cnt > 0) {
- if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
- ha->ic_all_size) {
- TRACE2(("gdth_fill_cache() DPMEM overflown"));
- ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND;
- return 0;
- }
- }
- /* copy command */
- gdth_copy_command(hanum);
- return cmd_index;
- }
- static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
- {
- register gdth_ha_str *ha;
- register gdth_cmd_str *cmdp;
- struct scatterlist *sl;
- ushort i;
- int cmd_index;
- unchar t,l;
- ha = HADATA(gdth_ctr_tab[hanum]);
- t = scp->target;
- l = scp->lun;
- cmdp = ha->pccb;
- TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %dn",
- scp->cmnd[0],b,t,l));
- if (ha->type==GDT_EISA && ha->cmd_cnt>0)
- return 0;
- cmdp->Service = SCSIRAWSERVICE;
- cmdp->RequestBuffer = scp;
- /* search free command index */
- if (!(cmd_index=gdth_get_cmd_index(hanum))) {
- TRACE(("GDT: No free command index foundn"));
- return 0;
- }
- /* if it's the first command, set command semaphore */
- if (ha->cmd_cnt == 0)
- gdth_set_sema0(hanum);
- /* fill command */
- if (scp->SCp.sent_command != -1) {
- cmdp->OpCode = scp->SCp.sent_command; /* special raw cmd. */
- cmdp->BoardNode = LOCALBOARD;
- cmdp->u.raw.direction = (scp->SCp.phase >> 8);
- TRACE2(("special raw cmd 0x%x param 0x%xn",
- cmdp->OpCode, cmdp->u.raw.direction));
- /* evaluate command size */
- ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst);
- } else {
- cmdp->OpCode = GDT_WRITE; /* always */
- cmdp->BoardNode = LOCALBOARD;
- cmdp->u.raw.reserved = 0;
- cmdp->u.raw.mdisc_time = 0;
- cmdp->u.raw.mcon_time = 0;
- cmdp->u.raw.clen = scp->cmd_len;
- cmdp->u.raw.target = t;
- cmdp->u.raw.lun = l;
- cmdp->u.raw.bus = b;
- cmdp->u.raw.priority = 0;
- cmdp->u.raw.link_p = 0;
- cmdp->u.raw.sdlen = scp->request_bufflen;
- cmdp->u.raw.sense_len = 16;
- cmdp->u.raw.sense_data = virt_to_bus(scp->sense_buffer);
- cmdp->u.raw.direction =
- gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN;
- memcpy(cmdp->u.raw.cmd,scp->cmnd,12);
- if (scp->use_sg) {
- cmdp->u.raw.sdata = 0xffffffff;
- sl = (struct scatterlist *)scp->request_buffer;
- for (i=0; i<scp->use_sg; ++i,++sl) {
- cmdp->u.raw.sg_lst[i].sg_ptr = virt_to_bus(sl->address);
- cmdp->u.raw.sg_lst[i].sg_len = (ulong32)sl->length;
- }
- cmdp->u.raw.sg_ranz = (ulong32)i;
- #ifdef GDTH_STATISTICS
- if (max_sg < (ulong32)i) {
- max_sg = (ulong32)i;
- TRACE3(("GDT: max_sg = %dn",i));
- }
- #endif
- if (i<GDTH_MAXSG)
- cmdp->u.raw.sg_lst[i].sg_len = 0;
- } else {
- if (ha->raw_feat & SCATTER_GATHER) {
- cmdp->u.raw.sdata = 0xffffffff;
- cmdp->u.raw.sg_ranz= 1;
- cmdp->u.raw.sg_lst[0].sg_ptr = virt_to_bus(scp->request_buffer);
- cmdp->u.raw.sg_lst[0].sg_len = scp->request_bufflen;
- cmdp->u.raw.sg_lst[1].sg_len = 0;
- } else {
- cmdp->u.raw.sdata = virt_to_bus(scp->request_buffer);
- cmdp->u.raw.sg_ranz= 0;
- }
- }
- TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %xn",
- cmdp->u.raw.sdata,cmdp->u.raw.sg_ranz,
- cmdp->u.raw.sg_lst[0].sg_ptr,
- cmdp->u.raw.sg_lst[0].sg_len));
- /* evaluate command size */
- ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) +
- (ushort)cmdp->u.raw.sg_ranz * sizeof(gdth_sg_str);
- }
- /* check space */
- if (ha->cmd_len & 3)
- ha->cmd_len += (4 - (ha->cmd_len & 3));
- if (ha->cmd_cnt > 0) {
- if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
- ha->ic_all_size) {
- TRACE2(("gdth_fill_raw() DPMEM overflown"));
- ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND;
- return 0;
- }
- }
- /* copy command */
- gdth_copy_command(hanum);
- return cmd_index;
- }
- static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp)
- {
- register gdth_ha_str *ha;
- register gdth_cmd_str *cmdp;
- int cmd_index;
- ha = HADATA(gdth_ctr_tab[hanum]);
- cmdp= ha->pccb;
- TRACE2(("gdth_special_cmd(): "));
- if (ha->type==GDT_EISA && ha->cmd_cnt>0)
- return 0;
- memcpy( cmdp, scp->request_buffer, sizeof(gdth_cmd_str));
- cmdp->RequestBuffer = scp;
- /* search free command index */
- if (!(cmd_index=gdth_get_cmd_index(hanum))) {
- TRACE(("GDT: No free command index foundn"));
- return 0;
- }
- /* if it's the first command, set command semaphore */
- if (ha->cmd_cnt == 0)
- gdth_set_sema0(hanum);
- /* evaluate command size, check space */
- if (cmdp->OpCode == GDT_IOCTL) {
- TRACE2(("IOCTLn"));
- ha->cmd_len =
- GDTOFFSOF(gdth_cmd_str,u.ioctl.p_param) + sizeof(ulong32);
- } else if (cmdp->Service == CACHESERVICE) {
- TRACE2(("cache command %dn",cmdp->OpCode));
- ha->cmd_len =
- GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) + sizeof(gdth_sg_str);
- } else if (cmdp->Service == SCSIRAWSERVICE) {
- TRACE2(("raw command %d/%dn",cmdp->OpCode,cmdp->u.raw.cmd[0]));
- ha->cmd_len =
- GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) + sizeof(gdth_sg_str);
- }
- if (ha->cmd_len & 3)
- ha->cmd_len += (4 - (ha->cmd_len & 3));
- if (ha->cmd_cnt > 0) {
- if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
- ha->ic_all_size) {
- TRACE2(("gdth_special_cmd() DPMEM overflown"));
- ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND;
- return 0;
- }
- }
- /* copy command */
- gdth_copy_command(hanum);
- return cmd_index;
- }
- /* Controller event handling functions */
- static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, ushort source,
- ushort idx, gdth_evt_data *evt)
- {
- gdth_evt_str *e;
- struct timeval tv;
- /* no GDTH_LOCK_HA() ! */
- TRACE2(("gdth_store_event() source %d idx %dn", source, idx));
- if (source == 0) /* no source -> no event */
- return 0;
- if (ebuffer[elastidx].event_source == source &&
- ebuffer[elastidx].event_idx == idx &&
- ((evt->size != 0 && ebuffer[elastidx].event_data.size != 0 &&
- !memcmp((char *)&ebuffer[elastidx].event_data.eu,
- (char *)&evt->eu, evt->size)) ||
- (evt->size == 0 && ebuffer[elastidx].event_data.size == 0 &&
- !strcmp((char *)&ebuffer[elastidx].event_data.event_string,
- (char *)&evt->event_string)))) {
- e = &ebuffer[elastidx];
- do_gettimeofday(&tv);
- e->last_stamp = tv.tv_sec;
- ++e->same_count;
- } else {
- if (ebuffer[elastidx].event_source != 0) { /* entry not free ? */
- ++elastidx;
- if (elastidx == MAX_EVENTS)
- elastidx = 0;
- if (elastidx == eoldidx) { /* reached mark ? */
- ++eoldidx;
- if (eoldidx == MAX_EVENTS)
- eoldidx = 0;
- }
- }
- e = &ebuffer[elastidx];
- e->event_source = source;
- e->event_idx = idx;
- do_gettimeofday(&tv);
- e->first_stamp = e->last_stamp = tv.tv_sec;
- e->same_count = 1;
- e->event_data = *evt;
- e->application = 0;
- }
- return e;
- }
- static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr)
- {
- gdth_evt_str *e;
- int eindex;
- ulong flags;
- TRACE2(("gdth_read_event() handle %dn", handle));
- GDTH_LOCK_HA(ha, flags);
- if (handle == -1)
- eindex = eoldidx;
- else
- eindex = handle;
- estr->event_source = 0;
- if (eindex >= MAX_EVENTS) {
- GDTH_UNLOCK_HA(ha, flags);
- return eindex;
- }
- e = &ebuffer[eindex];
- if (e->event_source != 0) {
- if (eindex != elastidx) {
- if (++eindex == MAX_EVENTS)
- eindex = 0;
- } else {
- eindex = -1;
- }
- memcpy(estr, e, sizeof(gdth_evt_str));
- }
- GDTH_UNLOCK_HA(ha, flags);
- return eindex;
- }
- static void gdth_readapp_event(gdth_ha_str *ha,
- unchar application, gdth_evt_str *estr)
- {
- gdth_evt_str *e;
- int eindex;
- ulong flags;
- unchar found = FALSE;
- TRACE2(("gdth_readapp_event() app. %dn", application));
- GDTH_LOCK_HA(ha, flags);
- eindex = eoldidx;
- for (;;) {
- e = &ebuffer[eindex];
- if (e->event_source == 0)
- break;
- if ((e->application & application) == 0) {
- e->application |= application;
- found = TRUE;
- break;
- }
- if (eindex == elastidx)
- break;
- if (++eindex == MAX_EVENTS)
- eindex = 0;
- }
- if (found)
- memcpy(estr, e, sizeof(gdth_evt_str));
- else
- estr->event_source = 0;
- GDTH_UNLOCK_HA(ha, flags);
- }
- static void gdth_clear_events()
- {
- TRACE(("gdth_clear_events()"));
- eoldidx = elastidx = 0;
- ebuffer[0].event_source = 0;
- }
- /* SCSI interface functions */
- #if LINUX_VERSION_CODE >= 0x010346
- static void gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs)
- #else
- static void gdth_interrupt(int irq,struct pt_regs *regs)
- #endif
- {
- register gdth_ha_str *ha;
- gdt6m_dpram_str *dp6m_ptr;
- gdt6_dpram_str *dp6_ptr;
- gdt2_dpram_str *dp2_ptr;
- Scsi_Cmnd *scp;
- int hanum, rval, i;
- unchar IStatus;
- ushort Service;
- ulong flags = 0;
- TRACE(("gdth_interrupt() IRQ %dn",irq));
- /* if polling and not from gdth_wait() -> return */
- if (gdth_polling) {
- if (!gdth_from_wait) {
- return;
- }
- }
- if (!gdth_polling)
- GDTH_LOCK_HA((gdth_ha_str *)dev_id,flags);
- wait_index = 0;
- /* search controller */
- if ((hanum = gdth_get_status(&IStatus,irq)) == -1) {
- /* spurious interrupt */
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- return;
- }
- #ifdef GDTH_STATISTICS
- ++act_ints;
- #endif
-
- ha = HADATA(gdth_ctr_tab[hanum]);
- if (ha->type == GDT_EISA) {
- if (IStatus & 0x80) { /* error flag */
- IStatus &= ~0x80;
- ha->status = inw(ha->bmic + MAILBOXREG+8);
- TRACE2(("gdth_interrupt() error %d/%dn",IStatus,ha->status));
- } else /* no error */
- ha->status = S_OK;
- ha->info = inl(ha->bmic + MAILBOXREG+12);
- ha->service = inw(ha->bmic + MAILBOXREG+10);
- ha->info2 = inl(ha->bmic + MAILBOXREG+4);
- outb(0xff, ha->bmic + EDOORREG); /* acknowledge interrupt */
- outb(0x00, ha->bmic + SEMA1REG); /* reset status semaphore */
- } else if (ha->type == GDT_ISA) {
- dp2_ptr = (gdt2_dpram_str *)ha->brd;
- if (IStatus & 0x80) { /* error flag */
- IStatus &= ~0x80;
- ha->status = gdth_readw(&dp2_ptr->u.ic.Status);
- TRACE2(("gdth_interrupt() error %d/%dn",IStatus,ha->status));
- } else /* no error */
- ha->status = S_OK;
- ha->info = gdth_readl(&dp2_ptr->u.ic.Info[0]);
- ha->service = gdth_readw(&dp2_ptr->u.ic.Service);
- ha->info2 = gdth_readl(&dp2_ptr->u.ic.Info[1]);
- gdth_writeb(0xff, &dp2_ptr->io.irqdel); /* acknowledge interrupt */
- gdth_writeb(0, &dp2_ptr->u.ic.Cmd_Index); /* reset command index */
- gdth_writeb(0, &dp2_ptr->io.Sema1); /* reset status semaphore */
- } else if (ha->type == GDT_PCI) {
- dp6_ptr = (gdt6_dpram_str *)ha->brd;
- if (IStatus & 0x80) { /* error flag */
- IStatus &= ~0x80;
- ha->status = gdth_readw(&dp6_ptr->u.ic.Status);
- TRACE2(("gdth_interrupt() error %d/%dn",IStatus,ha->status));
- } else /* no error */
- ha->status = S_OK;
- ha->info = gdth_readl(&dp6_ptr->u.ic.Info[0]);
- ha->service = gdth_readw(&dp6_ptr->u.ic.Service);
- ha->info2 = gdth_readl(&dp6_ptr->u.ic.Info[1]);
- gdth_writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */
- gdth_writeb(0, &dp6_ptr->u.ic.Cmd_Index); /* reset command index */
- gdth_writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */
- } else if (ha->type == GDT_PCINEW) {
- if (IStatus & 0x80) { /* error flag */
- IStatus &= ~0x80;
- ha->status = inw(PTR2USHORT(&ha->plx->status));
- TRACE2(("gdth_interrupt() error %d/%dn",IStatus,ha->status));
- } else
- ha->status = S_OK;
- ha->info = inl(PTR2USHORT(&ha->plx->info[0]));
- ha->service = inw(PTR2USHORT(&ha->plx->service));
- ha->info2 = inl(PTR2USHORT(&ha->plx->info[1]));
- outb(0xff, PTR2USHORT(&ha->plx->edoor_reg));
- outb(0x00, PTR2USHORT(&ha->plx->sema1_reg));
- } else if (ha->type == GDT_PCIMPR) {
- dp6m_ptr = (gdt6m_dpram_str *)ha->brd;
- if (IStatus & 0x80) { /* error flag */
- IStatus &= ~0x80;
- ha->status = gdth_readw(&dp6m_ptr->i960r.status);
- TRACE2(("gdth_interrupt() error %d/%dn",IStatus,ha->status));
- } else /* no error */
- ha->status = S_OK;
- ha->info = gdth_readl(&dp6m_ptr->i960r.info[0]);
- ha->service = gdth_readw(&dp6m_ptr->i960r.service);
- ha->info2 = gdth_readl(&dp6m_ptr->i960r.info[1]);
- /* event string */
- if (IStatus == ASYNCINDEX) {
- if (ha->service != SCREENSERVICE &&
- (ha->fw_vers & 0xff) >= 0x1a) {
- ha->dvr.severity =
- gdth_readb(&((gdt6m_dpram_str *)ha->brd)->i960r.severity);
- for (i = 0; i < 256; ++i) {
- ha->dvr.event_string[i] = gdth_readb
- (&((gdt6m_dpram_str *)ha->brd)->i960r.evt_str[i]);
- if (ha->dvr.event_string[i] == 0)
- break;
- }
- }
- }
- gdth_writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
- gdth_writeb(0, &dp6m_ptr->i960r.sema1_reg);
- } else {
- TRACE2(("gdth_interrupt() unknown controller typen"));
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- return;
- }
- TRACE(("gdth_interrupt() index %d stat %d info %dn",
- IStatus,ha->status,ha->info));
- if (gdth_from_wait) {
- wait_hanum = hanum;
- wait_index = (int)IStatus;
- }
- if (IStatus == ASYNCINDEX) {
- TRACE2(("gdth_interrupt() async. eventn"));
- gdth_async_event(hanum);
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- gdth_next(hanum);
- return;
- }
- if (IStatus == SPEZINDEX) {
- TRACE2(("Service unknown or not initialized !n"));
- ha->dvr.size = sizeof(ha->dvr.eu.driver);
- ha->dvr.eu.driver.ionode = hanum;
- gdth_store_event(ha, ES_DRIVER, 4, &ha->dvr);
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- return;
- }
- scp = ha->cmd_tab[IStatus-2].cmnd;
- Service = ha->cmd_tab[IStatus-2].service;
- ha->cmd_tab[IStatus-2].cmnd = UNUSED_CMND;
- if (scp == UNUSED_CMND) {
- TRACE2(("gdth_interrupt() index to unused command (%d)n",IStatus));
- ha->dvr.size = sizeof(ha->dvr.eu.driver);
- ha->dvr.eu.driver.ionode = hanum;
- ha->dvr.eu.driver.index = IStatus;
- gdth_store_event(ha, ES_DRIVER, 1, &ha->dvr);
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- return;
- }
- if (scp == INTERNAL_CMND) {
- TRACE(("gdth_interrupt() answer to internal commandn"));
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- return;
- }
- TRACE(("gdth_interrupt() sync. statusn"));
- rval = gdth_sync_event(hanum,Service,IStatus,scp);
- if (!gdth_polling)
- GDTH_UNLOCK_HA((gdth_ha_str *)dev_id,flags);
- if (rval == 2) {
- gdth_putq(hanum,scp,scp->SCp.this_residual);
- } else if (rval == 1) {
- GDTH_LOCK_SCSI_DONE(flags);
- scp->scsi_done(scp);
- GDTH_UNLOCK_SCSI_DONE(flags);
- }
- gdth_next(hanum);
- }
- static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
- {
- register gdth_ha_str *ha;
- gdth_msg_str *msg;
- gdth_cmd_str *cmdp;
- unchar b;
- ha = HADATA(gdth_ctr_tab[hanum]);
- cmdp = ha->pccb;
- TRACE(("gdth_sync_event() serv %d status %dn",
- service,ha->status));
- if (service == SCREENSERVICE) {
- msg = (gdth_msg_str *)ha->pscratch;
- ha->scratch_busy = FALSE;
- TRACE(("len: %d, answer: %d, ext: %d, alen: %dn",
- msg->msg_len,msg->msg_answer,msg->msg_ext,msg->msg_alen));
- if (msg->msg_len)
- if (!(msg->msg_answer && msg->msg_ext)) {
- msg->msg_text[msg->msg_len] = ' ';
- printk("%s",msg->msg_text);
- }
- if (msg->msg_ext && !msg->msg_answer) {
- while (gdth_test_busy(hanum))
- gdth_delay(0);
- cmdp->Service = SCREENSERVICE;
- cmdp->RequestBuffer = SCREEN_CMND;
- gdth_get_cmd_index(hanum);
- gdth_set_sema0(hanum);
- cmdp->OpCode = GDT_READ;
- cmdp->BoardNode = LOCALBOARD;
- cmdp->u.screen.reserved = 0;
- cmdp->u.screen.su.msg.msg_handle= msg->msg_handle;
- cmdp->u.screen.su.msg.msg_addr = virt_to_bus(msg);
- ha->scratch_busy = TRUE;
- ha->cmd_offs_dpmem = 0;
- ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
- + sizeof(ulong32);
- ha->cmd_cnt = 0;
- gdth_copy_command(hanum);
- gdth_release_event(hanum);
- return 0;
- }
- if (msg->msg_answer && msg->msg_alen) {
- /* default answers (getchar() not possible) */
- if (msg->msg_alen == 1) {
- msg->msg_alen = 0;
- msg->msg_len = 1;
- msg->msg_text[0] = 0;
- } else {
- msg->msg_alen -= 2;
- msg->msg_len = 2;
- msg->msg_text[0] = 1;
- msg->msg_text[1] = 0;
- }
- msg->msg_ext = 0;
- msg->msg_answer = 0;
- while (gdth_test_busy(hanum))
- gdth_delay(0);
- cmdp->Service = SCREENSERVICE;
- cmdp->RequestBuffer = SCREEN_CMND;
- gdth_get_cmd_index(hanum);
- gdth_set_sema0(hanum);
- cmdp->OpCode = GDT_WRITE;
- cmdp->BoardNode = LOCALBOARD;
- cmdp->u.screen.reserved = 0;
- cmdp->u.screen.su.msg.msg_handle= msg->msg_handle;
- cmdp->u.screen.su.msg.msg_addr = virt_to_bus(msg);
- ha->scratch_busy = TRUE;
- ha->cmd_offs_dpmem = 0;
- ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
- + sizeof(ulong32);
- ha->cmd_cnt = 0;
- gdth_copy_command(hanum);
- gdth_release_event(hanum);
- return 0;
- }
- printk("n");
- } else {
- b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel;
- if (scp->SCp.sent_command == -1 && b != ha->virt_bus) {
- ha->raw[BUS_L2P(ha,b)].io_cnt[scp->target]--;
- }
- /* cache or raw service */
- if (ha->status == S_OK) {
- scp->SCp.Status = S_OK;
- scp->SCp.Message = ha->info;
- if (scp->SCp.sent_command != -1) {
- TRACE2(("gdth_sync_event(): special cmd 0x%x OKn",
- scp->SCp.sent_command));
- /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */
- if (scp->SCp.sent_command == GDT_CLUST_INFO) {
- ha->hdr[scp->target].cluster_type = (unchar)ha->info;
- if (!(ha->hdr[scp->target].cluster_type &
- CLUSTER_MOUNTED)) {
- /* NOT MOUNTED -> MOUNT */
- scp->SCp.sent_command = GDT_MOUNT;
- if (ha->hdr[scp->target].cluster_type &
- CLUSTER_RESERVED) {
- /* cluster drive RESERVED (on the other node) */
- scp->SCp.phase = -2; /* reservation conflict */
- }
- } else {
- scp->SCp.sent_command = -1;
- }
- } else {
- if (scp->SCp.sent_command == GDT_MOUNT) {
- ha->hdr[scp->target].cluster_type |= CLUSTER_MOUNTED;
- ha->hdr[scp->target].media_changed = TRUE;
- } else if (scp->SCp.sent_command == GDT_UNMOUNT) {
- ha->hdr[scp->target].cluster_type &= ~CLUSTER_MOUNTED;
- ha->hdr[scp->target].media_changed = TRUE;
- }
- scp->SCp.sent_command = -1;
- }
- /* retry */
- scp->SCp.this_residual = HIGH_PRI;
- return 2;
- } else {
- /* RESERVE/RELEASE ? */
- if (scp->cmnd[0] == RESERVE) {
- ha->hdr[scp->target].cluster_type |= CLUSTER_RESERVED;
- } else if (scp->cmnd[0] == RELEASE) {
- ha->hdr[scp->target].cluster_type &= ~CLUSTER_RESERVED;
- }
- scp->result = DID_OK << 16;
- scp->sense_buffer[0] = 0;
- }
- } else if (ha->status == S_BSY) {
- TRACE2(("Controller busy -> retry !n"));
- scp->SCp.Status = S_BSY;
- scp->SCp.Message = ha->info;
- if (scp->SCp.sent_command == GDT_MOUNT)
- scp->SCp.sent_command = GDT_CLUST_INFO;
- /* retry */
- return 2;
- } else {
- scp->SCp.Status = ha->status;
- scp->SCp.Message = ha->info;
- if (scp->SCp.sent_command != -1) {
- TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%xn",
- scp->SCp.sent_command, ha->status));
- if (scp->SCp.sent_command == GDT_SCAN_START ||
- scp->SCp.sent_command == GDT_SCAN_END) {
- scp->SCp.sent_command = -1;
- /* retry */
- scp->SCp.this_residual = HIGH_PRI;
- return 2;
- }
- memset((char*)scp->sense_buffer,0,16);
- scp->sense_buffer[0] = 0x70;
- scp->sense_buffer[2] = NOT_READY;
- scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
- } else if (service == CACHESERVICE) {
- if (ha->status == S_CACHE_UNKNOWN &&
- (ha->hdr[scp->target].cluster_type &
- CLUSTER_RESERVE_STATE) == CLUSTER_RESERVE_STATE) {
- /* bus reset -> force GDT_CLUST_INFO */
- ha->hdr[scp->target].cluster_type &= ~CLUSTER_RESERVED;
- }
- memset((char*)scp->sense_buffer,0,16);
- scp->sense_buffer[0] = 0x70;
- scp->sense_buffer[2] = NOT_READY;
- scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
- #if LINUX_VERSION_CODE >= 0x010300
- if (scp->done != gdth_scsi_done)
- #endif
- {
- ha->dvr.size = sizeof(ha->dvr.eu.sync);
- ha->dvr.eu.sync.ionode = hanum;
- ha->dvr.eu.sync.service = service;
- ha->dvr.eu.sync.status = ha->status;
- ha->dvr.eu.sync.info = ha->info;
- ha->dvr.eu.sync.hostdrive = scp->target;
- if (ha->status >= 0x8000)
- gdth_store_event(ha, ES_SYNC, 0, &ha->dvr);
- else
- gdth_store_event(ha, ES_SYNC, service, &ha->dvr);
- }
- } else {
- /* sense buffer filled from controller firmware (DMA) */
- if (ha->status != S_RAW_SCSI || ha->info >= 0x100) {
- scp->result = DID_BAD_TARGET << 16;
- } else {
- scp->result = (DID_OK << 16) | ha->info;
- }
- }
- }
- if (!scp->SCp.have_data_in)
- scp->SCp.have_data_in++;
- else
- return 1;
- }
- return 0;
- }
- static char *async_cache_tab[] = {
- /* 0*/ "