⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkboot.c

📁 鼎鼎大名的WRS提供的VxWorks下pcPentium BSP开发包
💻 C
📖 第 1 页 / 共 2 页
字号:
    BOOL found		= FALSE;    int offset		= 0;#ifdef INCLUDE_TFFS    int removable	= fdType;#endif /* INCLUDE_TFFS */    switch (device)	{	case VXSYS_FD:            if ((UINT)drive >= FD_MAX_DRIVES)	        {	        printErr ("drive is out of range (0-%d).\n", FD_MAX_DRIVES - 1);	        return (ERROR);	        }            fdRaw.cylinder   = 0;		/* read the boot sector */            fdRaw.head       = 0;            fdRaw.sector     = 1;            fdRaw.pBuf       = bootSec;            fdRaw.nSecs      = 1;            fdRaw.direction  = 0;            fdRawio (drive, fdType, &fdRaw);            if (vxsysBootsec)	        {	        bootSec[0] = 0xeb;		/* modify the boot sector */	        bootSec[1] = 0x3c;	        bootSec[2] = 0x90;                bcopy (VXSYS_ID,  (char *)&bootSec[0x03], DOS_SYS_ID_LEN);                bcopy (bootStrap, (char *)&bootSec[0x3e], sizeof (bootStrap));		bootSec[0x1d2] = 0x00 + drive;	/* drive no. for int 13h */                    fdRaw.direction  = 1;		/* write the boot sector */                fdRawio (drive, fdType, &fdRaw);	        }	    if ((pBlkDev = fdDevCreate (drive, fdType, 0, 0)) == NULL)		{		printErr ("Error during fdDevCreate: %x\n", errnoGet ());		return (ERROR);		}	    break;	case VXSYS_ATA:            if ((UINT)ctrl >= ATA_MAX_CTRLS)	        {	        printErr ("ctrl is out of range (0-%d).\n", ATA_MAX_CTRLS - 1);	        return (ERROR);	        }            if ((UINT)drive >= ATA_MAX_DRIVES)	        {	        printErr ("drive is out of range (0-%d).\n", ATA_MAX_DRIVES - 1);	        return (ERROR);	        }	            ataRaw.cylinder   = 0;	/* read the master partition sector */            ataRaw.head       = 0;            ataRaw.sector     = 1;            ataRaw.pBuf       = partitionSec;            ataRaw.nSecs      = 1;            ataRaw.direction  = 0;            ataRawio (ctrl, drive, &ataRaw);	    pSys	= &partitionSec[DOS_BOOT_SYS_ID];	    pPart	= (DOS_PART_TBL *)&partitionSec[DOS_BOOT_PART_TBL];    	    if ((strncmp(pSys, VXDOS, strlen(VXDOS)) != 0) &&        	(strncmp(pSys, VXEXT, strlen(VXEXT)) != 0))        	{	        for (ix = 0; ix < 4; ix++)		    {		    if (pPart->dospt_status == 0x80)		        if ((pPart->dospt_type == 0x01) ||		            (pPart->dospt_type == 0x04) ||		            (pPart->dospt_type == 0x06))			    {			    found = TRUE;			    break;			    }		    pPart++;		    }	    	        if (!found)		    {                    printErr ("Can't find the primary DOS partition.\n");	            return (ERROR);		    }	        ataRaw.cylinder	= (pPart->dospt_startSec & 0xf0) >> 4;	        ataRaw.head    	= pPart->dospt_startHead;                ataRaw.sector  	= pPart->dospt_startSec & 0x0f;                ataRaw.pBuf	= bootSec;                ataRawio (ctrl, drive, &ataRaw); /* read the boot sector */		offset = pPart->dospt_absSec;		}	                if (vxsysBootsec)	        {	        bootSec[0] = 0xeb;		/* modify the boot sector */	        bootSec[1] = 0x3c;	        bootSec[2] = 0x90;                bcopy (VXSYS_ID,  (char *)&bootSec[0x03], DOS_SYS_ID_LEN);                bcopy (bootStrap, (char *)&bootSec[0x3e], sizeof (bootStrap));	        bootSec[0x1d2] = 0x80 + ctrl;	/* drive "c:" is 0x80 */                    ataRaw.direction  = 1;		/* write the boot sector */                ataRawio (ctrl, drive, &ataRaw);	        }	    if ((pBlkDev = ataDevCreate (ctrl, drive, 0, offset)) == NULL)		{		printErr ("Error during fdDevCreate: %x\n", errnoGet ());		return (ERROR);		}	    break;#ifdef INCLUDE_TFFS	case VXSYS_TFFS:            if ((UINT)drive >= TFFS_MAX_DRIVES)	        {	        printErr ("drive is out of range (0-%d).\n", TFFS_MAX_DRIVES-1);	        return (ERROR);	        }	    /* mount the TFFS */	    if ((pBlkDev = tffsDevCreate (drive, removable)) == NULL)		{		printErr ("Error during fdDevCreate: %x\n", errnoGet ());		return (ERROR);		}            /* read the partition table */            tffsRawio (drive, TFFS_ABS_READ, 0, 1, (int)&partitionSec);	    offset	= 0;	    pSys	= &partitionSec[DOS_BOOT_SYS_ID];	    pPart	= (DOS_PART_TBL *)&partitionSec[DOS_BOOT_PART_TBL];    	    if ((strncmp(pSys, VXDOS, strlen(VXDOS)) != 0) &&        	(strncmp(pSys, VXEXT, strlen(VXEXT)) != 0))        	{	        for (ix = 0; ix < 4; ix++)		    {		    if (pPart->dospt_status == 0x80)		        if ((pPart->dospt_type == 0x01) ||		            (pPart->dospt_type == 0x04) ||		            (pPart->dospt_type == 0x06))			    {			    found = TRUE;			    break;			    }		    pPart++;		    }	    	        if (found)		    offset = pPart->dospt_absSec;		}            /* read the boot sector */            tffsRawio (drive, TFFS_ABS_READ, offset, 1, (int)&bootSec);            if (vxsysBootsec)	        {	        bootSec[0] = 0xeb;		 /* modify the boot sector */	        bootSec[1] = 0x3c;	        bootSec[2] = 0x90;                bcopy (VXSYS_ID,  (char *)&bootSec[0x03], DOS_SYS_ID_LEN);                bcopy (bootStrap, (char *)&bootSec[0x3e], sizeof (bootStrap));	        bootSec[0x1d2] = 0x80;		/* drive "c:" is 0x80 */                    /* write the boot sector */                tffsRawio (drive, TFFS_ABS_WRITE, offset, 1, (int)&bootSec);	        }	    break;#endif /*INCLUDE_TFFS */	default:	    printErr ("unknown device (0-1).\n");	    return (ERROR);	}    if (vxsysBootrom)	{        /* read the header to get a text-size and a data-size */        if ((inFd = open (in, O_RDONLY, 0644)) == ERROR)            {            printErr ("Can't open \"%s\"\n", in);	    return (ERROR);	    }        if ((read (inFd, (char *)&hdr, sizeof(hdr))) == ERROR)	    {	    printErr ("Error during read header: %x\n", errnoGet ());	    return (ERROR);	    }        if (vxsysDebug)            printErr ("text=0x%x data=0x%x\n", hdr.a_text, hdr.a_data);        bytes = hdr.a_text + hdr.a_data;        /* create a DOS file system */        if ((dosFsDevInit (VXSYS_DOSDEV, pBlkDev, NULL)) == NULL)	    {	    printErr ("Error during dosFsDevInit: %x\n", errnoGet ());	    return (ERROR);	    }        if ((outFd = open (VXSYS_FILE, O_CREAT | O_RDWR, 0644)) == ERROR)	    {            close (inFd);            printErr ("Can't open \"%s\"\n", VXSYS_FILE);	    return (ERROR);	    }        if (ioctl (outFd, FIOCONTIG, bytes) == ERROR)	    {	    printErr ("Error during ioctl FIOCONTIG: %x\n", errnoGet ());	    return (ERROR);	    }        /* read text and data, write them to the diskette */        for (ix = 0; ix < bytes; ix += sizeof(bootSec))	    {	    if (read (inFd, bootSec, sizeof(bootSec)) == ERROR)	        {	        printErr ("Error during read file: %x\n", errnoGet ());	        return (ERROR);	        }	    if (write (outFd, bootSec, sizeof(bootSec)) == ERROR)	        {	        printErr ("Error during write fd: %x\n", errnoGet ());	        return (ERROR);	        }	    }        close (inFd);        close (outFd);        iosDevDelete (iosDevFind (VXSYS_DOSDEV, &pSys));        }    return (OK);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -