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

📄 usrata.c

📁 ppc 8245 可编译bsp 包括 uart
💻 C
字号:
/* usrAta.c - ATA initialization *//* Copyright 1992-1997 Wind River Systems, Inc. *//*modification history--------------------01d,30oct97,db   added call to ATA_SWAP in usrAtaPartition. 01c,30oct97,dat  added #include pccardLib.h and ataDrv.h01b,14jul97,dgp  doc: update to match hard-copy01a,11may95,hdn  re-written for ATA driver.*//*DESCRIPTIONThis file is used to configure and initialize the VxWorks ATA support.This file is included by bootConfig.c and usrConfig.c.SEE ALSO: usrExtra.cNOMANUAL*/#ifndef  __INCusrAta#define  __INCusrAta#include "drv/pcmcia/pccardLib.h"#include "drv/hdisk/ataDrv.h"#define VXDOS				"VXDOS"#define VXEXT				"VXEXT" /* forward declaration *//********************************************************************************* usrAtaConfig - mount a DOS file system from an ATA hard disk** This routine mounts a DOS file system from an ATA hard disk. Parameters:** .iP <drive> * the drive number of the hard disk; 0 is `C:' and 1 is `D:'.* .iP <fileName>* the mount point, for example, `/ata0/'.* .LP** NOTE: Because VxWorks does not support partitioning, hard disks formatted* and initialized on VxWorks are not compatible with DOS machines.  This* routine does not refuse to mount a hard disk that was initialized on* VxWorks.  The hard disk is assumed to have only one partition with a* partition record in sector 0.** RETURNS: OK or ERROR.** SEE ALSO:* `src/config/usrAta.c',* .pG "I/O System, Local File Systems, Intel i386/i486/Pentium"*/STATUS usrAtaConfig    (    int     ctrl,	/* 0: primary address, 1: secondary address */    int     drive,	/* drive number of hard disk (0 or 1) */    char *  fileName	/* mount point */    )    {    BLK_DEV *pBlkDev;    char bootDir [BOOT_FILE_LEN];    char buffer [1024];    int offset = 0;    ATA_RAW ataRaw;    char *pSys;    DOS_PART_TBL *pPart;    if ((UINT)drive >= ATA_MAX_DRIVES)	{	printErr ("drive is out of range (0-%d).\n", ATA_MAX_DRIVES - 1);	return (ERROR);	}    /* split off boot device from boot file */    devSplit (fileName, bootDir);    /* read the master partition sector */    ataRaw.cylinder	= 0;    ataRaw.head		= 0;    ataRaw.sector	= 1;    ataRaw.pBuf		= buffer;    ataRaw.nSecs	= 1;    ataRaw.direction	= 0;    ataRawio (ctrl, drive, &ataRaw);    /* get an offset if it is formated by MSDOS */    pSys	= &buffer[DOS_BOOT_SYS_ID];    pPart	= (DOS_PART_TBL *)&buffer[DOS_BOOT_PART_TBL];    if ((strncmp(pSys, VXDOS, strlen(VXDOS)) != 0) &&	(strncmp(pSys, VXEXT, strlen(VXEXT)) != 0))	{	offset = usrAtaPartition (ctrl, drive, pPart);	}      if ((pBlkDev = ataDevCreate(ctrl, drive, 0, offset)) == (BLK_DEV *)NULL)        {        printErr ("Error during ataDevCreate: %x\n", errno);        return (ERROR);        }    /* Make DOS file system */    if (dosFsDevInit(bootDir, pBlkDev, NULL) == (DOS_VOL_DESC *)NULL)        {	printErr ("Error during dosFsDevInit: %x\n", errno);        return (ERROR);        }    return (OK);    }/********************************************************************************* usrAtaPartition - get an offset to the first partition of the drive** This routine gets an offset to the first partition of the drive.* The value of offset is passed to the macro ATA_SWAP for endianess * adjustment.* For the <drive> parameter, 0 is `C:' and 1 is `D:'.* * RETURNS: The offset to the partition**/int usrAtaPartition    (    int     ctrl,	/* 0: primary address, 1: secondary address */    int     drive,	/* drive number of hard disk (0 or 1) */    DOS_PART_TBL *pPart	/* pointer to the partition table */    )    {    DOS_PART_TBL *pTemp	= pPart;    int offset		= 0;    int ix;    char buffer[1024];    ATA_RAW ataRaw;    for (ix = 0; ix < 4; ix++)		/* active primary DOS partition */	{	if (pPart->dospt_status == 0x80)	    if ((pPart->dospt_type == 0x01) ||	        (pPart->dospt_type == 0x04) ||	        (pPart->dospt_type == 0x06))		{	        offset = pPart->dospt_absSec;		return (ATA_SWAP(offset));		}	pPart++;	}	    pPart = pTemp;    for (ix = 0; ix < 4; ix++)		/* primary DOS partition */	{	if ((pPart->dospt_type == 0x01) ||	    (pPart->dospt_type == 0x04) ||	    (pPart->dospt_type == 0x06))	    {	    offset = pPart->dospt_absSec;	    return (ATA_SWAP(offset));	    }	pPart++;	}    pPart = pTemp;    for (ix = 0; ix < 4; ix++)		/* extended DOS partition */	{	if (pPart->dospt_type == 0x05)	    {	    ataRaw.cylinder	= (pPart->dospt_startSec & 0xf0) >> 4;	    ataRaw.head		= pPart->dospt_startHead;	    ataRaw.sector	= pPart->dospt_startSec & 0x0f;	    ataRaw.pBuf		= buffer;	    ataRaw.nSecs	= 1;	    ataRaw.direction	= 0;	    ataRawio (ctrl, drive, &ataRaw);	    pPart = (DOS_PART_TBL *)&buffer[DOS_BOOT_PART_TBL];	    offset = usrAtaPartition (ctrl, drive, pPart);	    return (offset);	    }	pPart++;	}    return (offset);    }#endif /* __INCusrAta */

⌨️ 快捷键说明

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