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

📄 nwsysata.c

📁 ks8695的ide硬盘程序
💻 C
字号:
/* sysAta.c - Motorola MVME2600 series ATA-2 initialization for sysLib.c */

/* Copyright 1984-1998 Wind River Systems, Inc. */
/* Copyright 1997,1998 Motorola, Inc. All Rights Reserved */

/*
modification history
--------------------
02a,28sep05,zhangfm fixed for atp865 pci->ata controller
01d,27apr98,dat  fixed compiler warning about chipEnable not used.
01c,13jan98,srr  updated copyright dates to 1998.
01b,11dec97,srr  Added support for VIA chip on MCP750.
01a,11jul97,tb   written
*/

/* 
Description

This file contains the sysAtaInit() necessary for
initializing the ATA/EIDE subsystem. 
*/

/* includes */

#include "config.h"
#include "nwAtaDrv.h"
#include "pciConfigLib.h"
/*#include "pciIntLib.h"*/
#include "ks8695p.h"
#include "../Vxworks2Linux/Vxworks2Linux.h"

/* local defines */

#define PCI_TARGET_MASK		0xFFFFFFFC	/* mask out AD[1:0] */

#define PCI_CFG_CHIP_ENABLE_ADR	0x40		/* IDE Chip Enable Register */
#define PCI_CFG_CHIP_ENABLE	0x03		/* IDE Chip Enable Value */

#define PCI_ATA_VENDOR_ID    ATA_ATP86X_VENID
#define PCI_ATA_DEVICE_ID1   ATA_ATP865_DEVID1
#define PCI_ATA_DEVICE_ID2   ATA_ATP865_DEVID2

int atp865_fd=0;

/* external declarations */
extern int ataDmaConfig(int ctrl,UINT32 regAddr );
/* global declarations */

/* function declarations */
void sysAtaInit(int pciBusNo, int pciDevNo, int pciFuncNo);


LOCAL int sysPciGetAtaIrqNo(char i)
{
	char tempData =0;
	return tempData;
}


/******************************************************************************
*
* sysAtaInit - initialize the EIDE/ATA interface
*
* Perform the necessary initialization required before starting up the
* ATA/EIDE driver.
*/

void sysAtaInit
    (
    int         pciBusNo,
    int         pciDevNo,
    int         pciFuncNo
    )
    {
    unsigned int         baseAddr;
    UINT8 byTmp;
    unsigned int dataRegister =0;
    /*
     * Disable PCI device by clearing its control (command) register
     * in its configuration header.
     */
  	if((atp865_fd = open ("/dev/atp865_ide_dev", O_RDWR)) < 0)
		{
			printf("Can't open dev dm642dev");
    	return;
  	}

		/*配置外部中断1为输入模式,且为下降沿触发*/
    KS8695P_REG_BIT_CLR (REG_GPIO_MODE, 0x02);
    KS8695P_REG_READ(REG_GPIO_CTRL, dataRegister);
    dataRegister |= 0x00c0;
		KS8695P_REG_WRITE(REG_GPIO_CTRL, dataRegister);


    /* Get and save Base Address of Command Reg for Primary Controller */

    ataResources[0].resource.ioStart[0] = ioctl(atp865_fd,5,0);
		printf("baseAddr0=0x%x\n",baseAddr);

    ataResources[0].resource.ioStart[1] = ioctl(atp865_fd,5,1);
		printf("baseAddr1=0x%x\n",baseAddr);

    /*
     * Initialize the remainder of the ataResources structure for the
     * Primary Controller
     */
    ataResources[0].ctrlType = IDE_LOCAL;
    ataResources[0].drives = 2;
    ataResources[0].intVector = (int)sysPciGetAtaIrqNo(0);
    ataResources[0].intLevel = (int)sysPciGetAtaIrqNo(0);
    ataResources[0].configType = (ATA_GEO_PHYSICAL | ATA_PIO_AUTO | ATA_DMA_AUTO);
    ataResources[0].semTimeout = 0;
    ataResources[0].wdgTimeout = 0;

    /* Get and save Base Address of Command Reg for Secondary Controller */
    ataResources[1].resource.ioStart[0] = ioctl(atp865_fd,5,2);
		printf("baseAddr2=0x%x\n",baseAddr);
		/*( CPU_PCI_ISA_IO_ADRS | (baseAddr & PCI_TARGET_MASK)); masked by zfm*/

    /*
     * Get and save an adjusted Base Address of Control Reg for
     * Secondary Controller
     */

    ataResources[1].resource.ioStart[1] = ioctl(atp865_fd,5,3);
		printf("baseAddr3=0x%x\n",baseAddr);
		/*( CPU_PCI_ISA_IO_ADRS | ((baseAddr & PCI_TARGET_MASK) + 2));masked by zfm*/

    /*
     * Initialize the remainder of the ataResources structure for the
     * Secondary Controller
     */

    ataResources[1].ctrlType = IDE_LOCAL;
    ataResources[1].drives = 2;
    ataResources[1].intVector = (int)sysPciGetAtaIrqNo(1);
    ataResources[1].intLevel = (int)sysPciGetAtaIrqNo(1);
    ataResources[1].configType = (ATA_GEO_PHYSICAL | ATA_PIO_AUTO | ATA_DMA_AUTO);
    ataResources[1].semTimeout = 0;
    ataResources[1].wdgTimeout = 0;

		printf("baseAddr4=0x%x\n",baseAddr);
    baseAddr &= ioctl(atp865_fd,5,4);
	
    /* add by wangb for ultra dma 2005-11-2 15:20 */
		ataDmaConfig(0,baseAddr);
    }


/******************************************************************************
*
* sysAtaGetIntStatus - get the INT val of PCI-ATA device 
*
* return 0=have irq/other=none
*/
/*  add by wangb 2005-10-18 14:26 */
LOCAL UINT8 EpldGetAtp865IntStatus(UINT8 byDevId)
{
	return 0;
}
/* end */
UINT8 sysAtaGetIntStatus(UINT8 byDevId)
    {
    return EpldGetAtp865IntStatus(byDevId);
    }
    
    
/******************************************************************************
*
* sysAtaIntEnable - enable corresponding interrupt bits  
*
* input: level = interrupt level 
* return OK or ERROR.
*/

/* add by wangb 2005-10-18 14:27 */
void EpldClearAtp865IntMask()
{
	;
}
/* end by wangb 2005-10-18 14:28 */
int sysAtaIntEnable(int  level)
    {
    /*EpldClearAtp865IntMask();
    intEnable (level);*/
    
    return OK;
    }


/******************************************************************************
*
* sysAtaIntConnect - connect the interrupt handler to the PCI interrupt.  
*
* input: level = interrupt level 
* return OK or ERROR.
*/

int sysAtaIntConnect
    (
    VOIDFUNCPTR * vector,   /* interrupt vector to attach to */
    VOIDFUNCPTR   routine,  /* routine to be called */
    int           parameter /* parameter to be passed to routine */
    )
    {
     /*EpldClearAtp865IntMask();

     if ( ERROR == pciIntConnect(vector, routine, parameter) );
     {
     	return ERROR;
     }*/
     
     return OK;
}

⌨️ 快捷键说明

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