getconfig_utils.c
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 629 行 · 第 1/2 页
C
629 行
* Return Values: None. *****************************************************************/check_connection(pname, pnumber, nexus, index)char *pname;int pnumber;int nexus;int index;{ int i, nodeindex; /* * Search through the alive device linked list looking * for the connection point of the given DEVICE passed * in as "pname" and "pnumber". If the connection point * is itself at a VAXBI or XMI connection then we need * to set the node number for this VAXBI or XMI connection. */ for(i = 0; i < ADLINDEX; i++) { /* Check if this is the DEVICE'S connection point */ if((strcmp(devtbl[adltbl[i].device_index].devname, pname) == 0) && (adltbl[i].device_unit == pnumber)) { /* * If the DEVICE's final connection point is itself * at a VAXBI or XMI connection then patch the node * number. */ nodeindex = match_node_name(adltbl[i].conn_name); if(nodeindex != -1 && (nodetbl[nodeindex].nodetype == VAXBINODE) || (nodetbl[nodeindex].nodetype == XMINODE)) { adltbl[i].node_index = nodeindex; adltbl[i].node_number = nexus; } else if(nodeindex == -1 && strcmp(adltbl[i].conn_name, "nexus") == 0) { nodeindex = match_node_name(pname); if(nodeindex != -1 && (nodetbl[nodeindex].nodetype == VAXBINODE) || (nodetbl[nodeindex].nodetype == XMINODE)) { adltbl[index].node_index = nodeindex; adltbl[index].node_number = nexus; } } /* * If the DEVICE's final connection point is not * attached to the UNIBUS ADAPTER then make sure * the CSR is set equal to -1. */ if(strcmp(adltbl[i].conn_name, "uba") != 0 && strcmp(adltbl[index].conn_name, "uba") != 0) adltbl[index].csr = -1; break; } }}/***************************************************************** Name: get_config_adpt ** ** Abstract: Get entry from "config_adpt" structure. This ** routine reads a CONFIG ADAPTER structure entry ** from kernel memory. ** ** Inputs: None. ** ** Outputs: ** adpt The "config_adpt" structure entry. ** ** Return Values: ** 1 More "config_adpt" structures to read. ** 0 No more "config_adpt" structures to read. *****************************************************************/get_config_adpt(adpt)struct config_adpt *adpt;{ /* Read "config_adpt" structure entry from kernel memory */ adapter_offset = lseek(kmem,adapter_offset + adapter_cnt,0); adapter_cnt = read(kmem,adpt,sizeof(*adpt)); /* Read the pname field from the "config_adpt" structure */ lseek(kmem,adpt->p_name,0); pname[0] = NULL; adpt->p_name = &pname[0]; read(kmem,adpt->p_name,DEVNAMESIZE); /* Read the cname field from the "config_adpt" structure */ lseek(kmem,adpt->c_name,0); cname[0] = NULL; adpt->c_name = &cname[0]; read(kmem,adpt->c_name,DEVNAMESIZE); /* Read in UNIBUS CONTROLLER information */ if(adpt->c_type == 'C' && adpt->c_ptr != NULL) { lseek(kmem,adpt->c_ptr,0); read(kmem,&ubctlr,sizeof(ubctlr)); adpt->c_ptr = (char *)&ubctlr; /* Read the UNIBUS CONTROLLER name */ lseek(kmem,ubctlr.um_ctlrname,0); ubctlr.um_ctlrname = &ubcname[0]; read(kmem,ubctlr.um_ctlrname,DEVNAMESIZE); } /* Read in UNIBUS DEVICE information */ else if(adpt->c_type == 'D' && adpt->c_ptr != NULL) { lseek(kmem,adpt->c_ptr,0); read(kmem,&ubdevice,sizeof(ubdevice)); adpt->c_ptr = (char *)&ubdevice; /* Read the UNIBUS DEVICE name */ lseek(kmem,ubdevice.ui_devname,0); ubdevice.ui_devname = &ubdname[0]; read(kmem,ubdevice.ui_devname, DEVNAMESIZE); } /* Have we finished reading the "config_adpt" list */ return((adpt->p_name[0] != NULL) ? 1 : 0);}/***************************************************************** Name: get_uba_device ** ** Abstract: Get "uba_device" entry from "ubdinit" structure.** This routine reads a UNIBUS device structure ** from kernel memory. ** ** Inputs: None. ** ** Outputs: ** device The "uba_device" device structure entry. ** ** Return Values: ** 1 More "uba_device" structures to read. ** 0 No more "uba_device" structures to read. *****************************************************************/get_uba_device(device)struct uba_device *device;{ /* Read "uba_device" structure entry from kernel memory */ udevice_offset = lseek(kmem, udevice_offset + udevice_cnt, 0); udevice_cnt = read(kmem, device, sizeof(*device)); /* Read the device name from the "uba_device" structure */ lseek(kmem, device->ui_devname, 0); device->ui_devname = &ubdname[0]; read(kmem, device->ui_devname, DEVNAMESIZE); /* Have we finished reading the "uba_device" list */ return((device->ui_driver != NULL) ? 1 : 0);}/***************************************************************** Name: get_nummbas ** ** Abstract: Get the number of MASSBUS ADAPTERS in the ** system. ** ** Inputs: None. ** ** Outputs: None. ** ** Return Values: ** count Returns the number of MASSBUS ADAPTERS used. *****************************************************************/get_nummbas(){ long offset; int number, i, count; struct mba_hd mbhead; /* Read the number of MASSBUS ADAPTERS configured */ offset = reset_anythg(NL_nummbas); lseek(kmem, offset, 0); read(kmem, &number, sizeof(number)); /* Now figure out how many MASSBUS ADAPTERS are used */ offset = reset_anythg(NL_mbhead); for(i=0, count=0; i<number; i++) { /* Read a "mba_hd" structure from kernel memory */ lseek(kmem, offset, 0); read(kmem, &mbhead, sizeof(mbhead)); offset += sizeof(mbhead); /* Is this MASSBUS ADAPTER being used */ if(mbhead.mh_ndrive && mbhead.mh_mba && mbhead.mh_physmba) count++; } return(count);}/***************************************************************** Name: get_mba_slave ** ** Abstract: Get "mba_slave" entry from "mbsinit" structure. ** This routine reads a MASSBUS slave device ** structure from kernel memory. ** ** Inputs: None. ** ** Outputs: ** sdevice The "mba_slave" slave device structure entry. ** ** Return Values: ** 1 More "mba_slave" structures to read. ** 0 No more "mba_slave" structures to read. *****************************************************************/get_mba_slave(sdevice)struct mba_slave *sdevice;{ /* Read "mba_slave" structure entry from kernel memory */ mslave_offset = lseek(kmem, mslave_offset + mslave_cnt, 0); mslave_cnt = read(kmem, sdevice, sizeof(*sdevice)); /* Get the "mba_driver" structure that this is pointed to */ lseek(kmem, sdevice->ms_driver, 0); read(kmem, &mbdriver, sizeof(mbdriver)); /* Read the device name from the "mba_driver" structure */ lseek(kmem, mbdriver.md_dname, 0); mbdriver.md_dname = &mbdname[0]; read(kmem, mbdriver.md_dname, DEVNAMESIZE); /* Read the slave name from the "mba_driver" structure */ lseek(kmem, mbdriver.md_sname, 0); mbdriver.md_sname = &mbsname[0]; read(kmem, mbdriver.md_sname, DEVNAMESIZE); /* Have we finished reading the "mba_slave" list */ if(sdevice->ms_driver == NULL) return(0); else { sdevice->ms_driver = &mbdriver; return(1); }}/***************************************************************** Name: get_mba_device ** ** Abstract: Get "mba_device" entry from "mbdinit" structure.** This routine reads a MASSBUS device structure ** from kernel memory. ** ** Inputs: None. ** ** Outputs: ** mdevice The "mba_device" device structure entry. ** ** Return Values: ** 1 More "mba_device" structures to read. ** 0 No more "mba_device" structures to read. *****************************************************************/get_mba_device(mdevice)struct mba_device *mdevice;{ /* Read "mba_device" structure entry from kernel memory */ mdevice_offset = lseek(kmem, mdevice_offset + mdevice_cnt, 0); mdevice_cnt = read(kmem, mdevice, sizeof(*mdevice)); /* Get the "mba_driver" structure that this is pointed to */ lseek(kmem, mdevice->mi_driver, 0); read(kmem, &mbdriver, sizeof(mbdriver)); /* Read the device name from the "mba_driver" structure */ lseek(kmem, mbdriver.md_dname, 0); mbdriver.md_dname = &mbdname[0]; read(kmem, mbdriver.md_dname, DEVNAMESIZE); /* Read the slave name from the "mba_driver" structure */ lseek(kmem, mbdriver.md_sname, 0); mbdriver.md_sname = &mbsname[0]; read(kmem, mbdriver.md_sname, DEVNAMESIZE); /* Have we finished reading the "mba_device" list */ if(mdevice->mi_driver == NULL) return(0); else { mdevice->mi_driver = &mbdriver; return(1); }}/***************************************************************** Name: init_adl_entry ** ** Abstract: Initialize an alive device table entry to its ** default settings. ** ** Inputs: ** i The current index in the alive device table. ** ** Outputs: None. ** ** Return Values: None. *****************************************************************/init_adl_entry(i)int i;{ adltbl[i].bus_type = -1; adltbl[i].device_index = -1; adltbl[i].device_unit = -1; adltbl[i].device_drive = -1; adltbl[i].conn_name[0] = NULL; adltbl[i].conn_number = -1; adltbl[i].node_number = -1; adltbl[i].node_index = -1; adltbl[i].rctlr = -1; adltbl[i].csr = -1; adltbl[i].alive_unit = 1;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?