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

📄 sysata.c

📁 VxWorks的bootloader实现
💻 C
字号:
/* sysAta.c - ATA-2 initialization for sysLib.c *//* Copyright 1984-1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01b,27aug01,dgp  change manual pages to reference entries per SPR 2369801a,01apr99,jkf  written*//* DescriptionThis file contains the sysAtaInit() necessary forinitializing the ATA/EIDE subsystem on the Winbond chip. This file will enable the controller and also set the PIO mode as detected by ataDrv().*//* includes */#include "vxWorks.h"#include "config.h"#ifdef	INCLUDE_ATA#include "drv/hdisk/ataDrv.h"/* defines */#define WB_CTRL_STAT_INDX	0x40		/* IDE ctrl stat reg *//* IDE  Drive x CTRLx reg's */#define WB_DRIVE0_CTRL0_INDX	0x44		/* master / primary   */	#define WB_DRIVE1_CTRL0_INDX	0x48		/* slave  / primary   */#define WB_DRIVE0_CTRL1_INDX	0x4c		/* master / secondary */#define WB_DRIVE1_CTRL1_INDX	0x50		/* slave  / secondary *//* IDE Chip Enable Value */#define WB_CFG_CHIP_ENABLE	0x33		/* Turn on both ports *//* Winbond PIO mode settings */#define WB_PIO_MODE_0	((0x5 << 8) | 0xd)	/* W83C553 setting PIO0 */#define WB_PIO_MODE_1	((0x4 << 8) | 0x7)	/* W83C553 setting PIO1 */#define WB_PIO_MODE_2	((0x3 << 8) | 0x4)	/* W83C553 setting PIO2 */#define WB_PIO_MODE_3	((0x2 << 8) | 0x2)	/* W83C553 setting PIO3 */#define WB_PIO_MODE_4	((0x2 << 8) | 0x1)	/* W83C553 setting PIO4 */#define WB_PIO_MODE_5	((0x1 << 8) | 0x1)	/* W83C553 setting PIO5 */#define DEFAULT_PIOMODE	WB_PIO_MODE_4		/* reset as desired *//* drive ctrl value, note PIO mode is setup in the routine */#define WB_DRIVE_CTRL_VAL	((WB_PCI_CTRL_REG << 4) | pioMode)/* external declarations *//* global declarations *//* locals */LOCAL BOOL 	      sysAtaInstalled = FALSE;/* function declarations *//******************************************************************************** sysAtaInit - initialize the EIDE/ATA interface** Perform the necessary initialization required before starting up the* ATA/EIDE driver on the W83C553.  The first time it is called with * ctrl and drive = 0.   The next time it is called is from ataDrv with* the appropriate controller and drive to determine PIO mode to use* on the drive.  See the ataDrv reference entry.*/void sysAtaInit    (    BOOL ctrl    )    {    UINT16	      tmpInt16;    int		      tmpInt;    int		      pioMode;    ATA_CTRL * 	      pCtrl;    ATA_DRIVE *       pDrive;    /* SETUP ATA */    if (sysAtaInstalled == FALSE)	/* First time run */	{	/* read the WINBOND IDE Device Control register */	pciConfigInWord (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC,			 PCI_CFG_COMMAND, &tmpInt16);	/* enable the IDE I/O decodes */	tmpInt16 |= PCI_CMD_IO_ENABLE;	/* disable bus master mode, memory write and invalidate bits */	tmpInt16 &= ~(PCI_CMD_MASTER_ENABLE | PCI_CMD_WI_ENABLE);	pciConfigOutWord (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC,			  PCI_CFG_COMMAND, tmpInt16);	/* read the Port0 and Port1 Primary/Auxillary Register addresses */	pciConfigInLong (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 PCI_CFG_BASE_ADDRESS_0, &tmpInt);	ataResources[0].resource.ioStart[0] = 			(PCI_MSTR_ISA_IO_LOCAL | (tmpInt & PCI_IOBASE_MASK));	pciConfigInLong (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 PCI_CFG_BASE_ADDRESS_1, &tmpInt);	ataResources[0].resource.ioStart[1] = 		(PCI_MSTR_ISA_IO_LOCAL | ((tmpInt & PCI_IOBASE_MASK) + 2));	pciConfigInLong (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 PCI_CFG_BASE_ADDRESS_2, &tmpInt);	ataResources[1].resource.ioStart[0] = 		(PCI_MSTR_ISA_IO_LOCAL | (tmpInt & PCI_IOBASE_MASK));	pciConfigInLong (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 PCI_CFG_BASE_ADDRESS_3, &tmpInt);	ataResources[1].resource.ioStart[1] = 		(PCI_MSTR_ISA_IO_LOCAL | ((tmpInt & PCI_IOBASE_MASK) + 2));	/*	 * initialize the remainder of the ataRsources structure	 * First, initialize the Controller 0 data structure	 */	ataResources[0].ctrlType 	= IDE_LOCAL;	ataResources[0].drives 		= ATA_CTRL0_DRIVES;	ataResources[0].intVector 	= (int)IDE_CNTRLR0_INT_LVL;	ataResources[0].intLevel 	= (int)IDE_CNTRLR0_INT_LVL;	ataResources[0].configType 	= (ATA_PIO_AUTO | ATA_GEO_PHYSICAL);	ataResources[0].semTimeout 	= 0;	ataResources[0].wdgTimeout 	= 0;	/* Second, initialize the Controller 1 data structure */	ataResources[1].ctrlType 	= IDE_LOCAL;	ataResources[1].drives 		= ATA_CTRL1_DRIVES;	ataResources[1].intVector 	= (int)IDE_CNTRLR1_INT_LVL;	ataResources[1].intLevel 	= (int)IDE_CNTRLR1_INT_LVL;	ataResources[1].configType 	= (ATA_PIO_AUTO | ATA_GEO_PHYSICAL);	ataResources[1].semTimeout 	= 0;	ataResources[1].wdgTimeout 	= 0;	/* Setup ATA RESET/INIT function ptr. from ataDrv */	_func_sysAtaInit = (VOIDFUNCPTR) sysAtaInit; 	/* we only need to do the above one time. */        sysAtaInstalled = TRUE;	}    /*      * Setup the WB PCI control register.     */    pciConfigInLong (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_FUNC, 		     WB_PCI_CTRL_INDX, &tmpInt);    pciConfigOutLong (WB_PCI_BUS, WB_PCI_DEV, WB_PCI_FUNC, 		      WB_PCI_CTRL_INDX, (tmpInt | WB_PCI_CTRL_REG));    /* Setup the appropriate PIO mode of W83C553. */    if (sysAtaInstalled == FALSE)	{	/* First time called, just setup the default */	pioMode = DEFAULT_PIOMODE;	}    else	{	/* Look at ataDrv to see the PIO mode reported */	pCtrl  = &ataCtrl[ctrl];  	for (tmpInt = 0; tmpInt < ATA_MAX_DRIVES; tmpInt++)	    {	    pDrive = &pCtrl->drive[tmpInt];	    	    switch (pDrive->rwMode)	        {	        case (ATA_PIO_W_0):		    pioMode = WB_PIO_MODE_1;		    break;    	        case (ATA_PIO_W_1):		    pioMode = WB_PIO_MODE_2;		    break;  	        case (ATA_PIO_W_2):		    pioMode = WB_PIO_MODE_3;		    break;	        case (ATA_PIO_W_3):		    pioMode = WB_PIO_MODE_4;		    break;	        case (ATA_PIO_W_4):		    pioMode = WB_PIO_MODE_5;		    break; 	        default:		    pioMode = DEFAULT_PIOMODE;		    break;	        } 	    }    	}    if (ctrl == 0)	{	pciConfigInLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			WB_DRIVE0_CTRL0_INDX, &tmpInt);        pciConfigOutLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 WB_DRIVE0_CTRL0_INDX, 			 tmpInt | WB_DRIVE_CTRL_VAL);        pciConfigInLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			WB_DRIVE1_CTRL0_INDX, &tmpInt);        pciConfigOutLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 WB_DRIVE1_CTRL0_INDX, 			 tmpInt | WB_DRIVE_CTRL_VAL);        }    else if ((ctrl == 1) || (sysAtaInstalled == FALSE))	{	pciConfigInLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			WB_DRIVE0_CTRL1_INDX, &tmpInt);        pciConfigOutLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC,			 WB_DRIVE0_CTRL1_INDX,                         			 tmpInt | WB_DRIVE_CTRL_VAL);        pciConfigInLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			WB_DRIVE1_CTRL1_INDX, &tmpInt);        pciConfigOutLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 			 WB_DRIVE1_CTRL1_INDX,			 tmpInt | WB_DRIVE_CTRL_VAL);	}    /* Last, enable IDE Primary and Secondary Channels */    pciConfigInLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 		    WB_CTRL_STAT_INDX, &tmpInt);    pciConfigOutLong(WB_PCI_BUS, WB_PCI_DEV, WB_PCI_IDEFUNC, 		     WB_CTRL_STAT_INDX, (tmpInt | WB_CFG_CHIP_ENABLE));    }#endif /* INCLUDE_ATA */

⌨️ 快捷键说明

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