亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ctrl_atapi.c

?? STi5518機頂盒ATAPI源代碼!絕對超值!
?? C
字號:
/************************************************************************Source file name : ctrl_atapi.cDescription: Implementation of the ATA Control Interface and Device/Protocol            setup  intermediate modules following the API Design Document             v0.9.0 of the ATAPI driver.             COPYRIGHT (C) STMicroelectronics  2000************************************************************************//*Includes-------------------------------------------------------------*/#include <string.h>#include "stlite.h"#include "stcommon.h"#include "statapi.h"#include "hal_atapi.h"#include "ata.h"/*Private Types--------------------------------------------------------*//*Private Constants----------------------------------------------------*/#define HARD_RESET_TIMEOUT_SECONDS  10/*Private Variables----------------------------------------------------*//*Private Macros-------------------------------------------------------*//*Private functions prototypes-----------------------------------------*//*Functions------------------------------------------------------------*/ /************************************************************************Name: ata_ctrl_SelectDeviceDescription: Attempts to select the device by writing to the Device/Header reg.             Also delays the mandatory 400 ns to ensure subsequent device access is             safeParameters: Two params:            Ata_p : Pointer to the ATA control block            Device: number identifying the device (0,1)            ************************************************************************/BOOL ata_ctrl_SelectDevice(ata_ControlBlock_t *Ata_p, U8 Device){    U8 data;                  /* First wait for not busy (BSY=0)... */    if(WaitForBit(Ata_p->HalHndl,ATA_REG_STATUS,BSY_BIT_MASK,0))    {         Ata_p->LastExtendedErrorCode=0x11;         return TRUE;    }            /* ..then wait for DRQ=0 */    if(WaitForBit(Ata_p->HalHndl,ATA_REG_STATUS,DRQ_BIT_MASK,0))    {         Ata_p->LastExtendedErrorCode=0x12;         return TRUE;    }                 data= hal_RegInByte(Ata_p->HalHndl,ATA_REG_DEVHEAD);    if(Device==DEVICE_0) data= data & ~BIT_4;    else          data= data | BIT_4;        hal_RegOutByte(Ata_p->HalHndl,ATA_REG_DEVHEAD,data);    WAIT400NS;                /* First wait for not busy (BSY=0)... */   if(WaitForBit(Ata_p->HalHndl,ATA_REG_STATUS,BSY_BIT_MASK,0))    {         Ata_p->LastExtendedErrorCode=0x11;         return TRUE;    }        /* ...then wait for DRQ=0 */    if(WaitForBit(Ata_p->HalHndl,ATA_REG_STATUS,DRQ_BIT_MASK,0))    {         Ata_p->LastExtendedErrorCode=0x12;         return TRUE;    }         return FALSE;}/************************************************************************Name: ata_ctrl_SoftResetDescription: Pulses the SRST bit in the DeviceCtrl register high for 400 ns and             then low. Delays for mandatory 400ns afterwardsParameters: Two params:            Ata_p : Pointer to the ATA control block            Device: number identifying the device (0,1)            ************************************************************************/BOOL ata_ctrl_SoftReset(ata_ControlBlock_t *Ata_p){    S32 TimeOut=ATA_TIMEOUT;    U8  sc,sn;        /* Assert SRST and disable interrupts */    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_CONTROL,SRST_SET|nIEN_SET);        /* Wait t > 2ms */    task_delay(TWO_MS);        /*Deassert SRTS and enable interrupts if necessary*/#if ATAPI_USING_INTERRUPTS    hal_RegOutByte(Ata_p->HalHndl, ATA_REG_CONTROL, 0x00);#else        hal_RegOutByte(Ata_p->HalHndl, ATA_REG_CONTROL, 0x02);#endif        WAIT400NS;    /*RESET DONE. This causes device 0 be selected.*/    /* If there is a device 0, wait for device 0 to set BSY=0.*/    if(Ata_p->DevInBus[0] != NONE_DEVICE)    {        if(WaitForBit(Ata_p->HalHndl, ATA_REG_STATUS, BSY_BIT_MASK, 0))        {            Ata_p->LastExtendedErrorCode = 0x01;            return TRUE;        }    }        /* If there is a device 1, wait until device 1 allows       register access.*/           if(Ata_p->DevInBus[1] != NONE_DEVICE)    {          /* Select the device */        hal_RegOutByte(Ata_p->HalHndl, ATA_REG_DEVHEAD, DEVHEAD_DEV1);        WAIT400NS;                while(TimeOut >= 0)        {            sn = hal_RegInByte(Ata_p->HalHndl, ATA_REG_SECNUM);            sc = hal_RegInByte(Ata_p->HalHndl, ATA_REG_SECCOUNT);            if ((sn == 0x01) && (sc == 0x01))                break;            TimeOut--;        }                   if(TimeOut<0)         {            Ata_p->LastExtendedErrorCode = 0x02;            return TRUE;        }                /* Now wait for device 1 to set BSY=0 */        if(WaitForBit(Ata_p->HalHndl, ATA_REG_STATUS, BSY_BIT_MASK, 0))        {            Ata_p->LastExtendedErrorCode = 0x03;            return TRUE;        }    }       return FALSE;}/************************************************************************Name: ata_ctrl_ProbeDescription: Probes the ATA bus to determine the number of devices attached and             their type (ATA or ATAPI)Parameter:  Ata_p : Pointer to the ATA control block            ************************************************************************/BOOL ata_ctrl_Probe(ata_ControlBlock_t *Ata_p){    U8 error=0;    volatile U8 sc,sn,cl,ch,st;           Ata_p->DevInBus[0]=NONE_DEVICE;    Ata_p->DevInBus[1]=NONE_DEVICE;        /* lets see if there is a device 0*/        hal_RegOutByte(Ata_p->HalHndl,ATA_REG_DEVHEAD,DEVHEAD_DEV0);    WAIT400NS;    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECCOUNT ,0x55);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECNUM ,0xaa);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECCOUNT ,0xaa);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECNUM ,0x55);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECCOUNT ,0x55);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECNUM ,0xaa);         sc = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECCOUNT);   sn = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECNUM);    if ( ( sc == 0x55 ) && ( sn == 0xaa ) )      Ata_p->DevInBus[0]= UNKNOWN_DEVICE;    /* lets see if there is a device 1*/        hal_RegOutByte(Ata_p->HalHndl,ATA_REG_DEVHEAD,DEVHEAD_DEV1);    WAIT400NS;    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECCOUNT ,0x55);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECNUM ,0xaa);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECCOUNT ,0xaa);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECNUM ,0x55);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECCOUNT ,0x55);    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_SECNUM ,0xaa);          sc = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECCOUNT);   sn = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECNUM);   if ( ( sc == 0x55 ) && ( sn == 0xaa ) )      Ata_p->DevInBus[1]= UNKNOWN_DEVICE;    /*   now we think we know which devices, if any are there,        so lets try a soft reset (ignoring any errors).*/        /*Assert SRST and disable interrupts */    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_CONTROL,SRST_SET|nIEN_SET);    /* Wait t > 2ms */    task_delay(TWO_MS);    /*Deassert SRTS and enable interrupts if necessary*/   #if ATAPI_USING_INTERRUPTS         hal_RegOutByte(Ata_p->HalHndl,ATA_REG_CONTROL,0x08);    #else             hal_RegOutByte(Ata_p->HalHndl,ATA_REG_CONTROL,0x00);    #endif             WaitForBit(Ata_p->HalHndl,ATA_REG_STATUS,BSY_BIT_MASK,0);       /*RESET DONE. This causes device 0 be selected.*/       sc = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECCOUNT);   sn = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECNUM);   if ( ( sc == 0x01 ) && ( sn == 0x01 ) )   {      Ata_p->DevInBus[0]= UNKNOWN_DEVICE;      ch = hal_RegInByte(Ata_p->HalHndl,ATA_REG_CYLHIGH);      cl = hal_RegInByte(Ata_p->HalHndl,ATA_REG_CYLLOW);      st = hal_RegInByte(Ata_p->HalHndl,ATA_REG_STATUS);            if ( ( cl == 0x14 ) && ( ch == 0xeb ) )         Ata_p->DevInBus[0] = ATAPI_DEVICE;      else         if ( ( cl == 0x00 ) && ( ch == 0x00 ) && ( st != 0x00 ) )            Ata_p->DevInBus[0] = ATA_DEVICE;   }    /*Now for the device 1*/    hal_RegOutByte(Ata_p->HalHndl,ATA_REG_DEVHEAD,DEVHEAD_DEV1);    WAIT400NS;       sc = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECCOUNT);   sn = hal_RegInByte(Ata_p->HalHndl,ATA_REG_SECNUM);   if ( ( sc == 0x01 ) && ( sn == 0x01 ) )   {      Ata_p->DevInBus[1]= UNKNOWN_DEVICE;      cl = hal_RegInByte(Ata_p->HalHndl,ATA_REG_CYLHIGH);      ch = hal_RegInByte(Ata_p->HalHndl,ATA_REG_CYLLOW);      st = hal_RegInByte(Ata_p->HalHndl,ATA_REG_STATUS);            if ( ( cl == 0x14 ) && ( ch == 0xeb ) )         Ata_p->DevInBus[1] = ATAPI_DEVICE;      else         if ( ( cl == 0x00 ) && ( ch == 0x00 ) && ( st != 0x00 ) )            Ata_p->DevInBus[1] = ATA_DEVICE;   }             return error;    }/************************************************************************Name: ata_ctrl_HardResetDescription: Probes the ATA bus to determine the number of devices attached and             their type (ATA or ATAPI)Parameter:  Ata_p : Pointer to the ATA control block            ************************************************************************/BOOL ata_ctrl_HardReset(ata_ControlBlock_t *Ata_p){    volatile U8 Dummy;    clock_t     timeout;    U32         TimeoutTicks;    TimeoutTicks = HARD_RESET_TIMEOUT_SECONDS * ST_GetClocksPerSecond();    hal_HardReset(Ata_p->HalHndl);        timeout = time_plus(time_now(), TimeoutTicks);         /* Wait for BSY=0 or timeout */    while(TRUE)    {        WAIT400NS;        Dummy=hal_RegInByte(Ata_p->HalHndl,ATA_REG_STATUS);        if ((Dummy & BSY_BIT_MASK) == 0)             break;        /* Returns 1 if first time is after the second */        if (time_after(time_now(), timeout) == 1)            break;    }        /* Check */    if ((Dummy & BSY_BIT_MASK) == 0)        return FALSE;    else        return TRUE;}/************************************************************************Name: ata_bus_AcquireDescription: Obtains the bus check semaphore and checks the bus busy flag (SW             flag). If not set the bus busy flag is set. Releases the bus check             semaphoreParameter:  Ata_p : Pointer to the ATA control block            ************************************************************************/BOOL ata_bus_Acquire(ata_ControlBlock_t *Ata_p){    /* Semaphore needs to protect check, as well as any set */    semaphore_wait ( &Ata_p->BusMutexSemaphore );    if(Ata_p->BusBusy==FALSE)    {        Ata_p->BusBusy=TRUE;        semaphore_signal ( &Ata_p->BusMutexSemaphore );         return FALSE;    }    semaphore_signal ( &Ata_p->BusMutexSemaphore );     return TRUE;}/************************************************************************Name: ata_bus_ReleaseDescription: Obtains the bus check semaphore and checks the bus busy flag (SW             flag). If set the bus busy flag is cleared. Releases the bus check             semaphoreParameter:  Ata_p : Pointer to the ATA control block            ************************************************************************/BOOL ata_bus_Release(ata_ControlBlock_t *Ata_p){    /* Semaphore needs to protect check, as well as any set */    semaphore_wait ( &Ata_p->BusMutexSemaphore );    if(Ata_p->BusBusy == TRUE)    {        Ata_p->BusBusy=FALSE;        semaphore_signal ( &Ata_p->BusMutexSemaphore );         return FALSE;    }    semaphore_signal ( &Ata_p->BusMutexSemaphore );     return TRUE;}/************************************************************************Name: WaitForBitDescription: Wait for a bit to be setParameters: Three params:            HalHndl : Pointer to the HAL control block            regNo: Register number            bitNo: mask with the bit to test            expected_val: expected value of the register after applying a mask to            use only the relevant bits            ************************************************************************/BOOL WaitForBit(hal_Handle_t *HalHndl,ATA_Register_t regNo,U8 bitNo,U8 expected_val){    U32 i;    volatile U8 dummy;        for (i=0;i<ATA_TIMEOUT;i++)    {        WAIT400NS;        dummy=hal_RegInByte(HalHndl,regNo);                        if( (dummy & bitNo)== expected_val)             return FALSE;    }     return TRUE;}/************************************************************************Name: WaitForBitPktDescription: Wait for a bit to be set.Version for the packet command interface.we need a different verion because of the longer delay of the ATAPI devicesParameters: Three params:            HalHndl : Pointer to the HAL control block            regNo: Register number            bitNo: mask with the bit to test            expected_val: expected value of the register after applying a mask to            use only the relevant bits            ************************************************************************/BOOL WaitForBitPkt(hal_Handle_t *HalHndl,ATA_Register_t regNo,U8 bitNo,U8 expected_val){    U32 i;    volatile U8 dummy;        for (i=0;i<ATAPI_TIMEOUT;i++)    {        WAIT400NS;        dummy=hal_RegInByte(HalHndl,regNo);                        if( (dummy & bitNo)== expected_val)             return FALSE;    }     return TRUE;}/*end of ctrl_atapi.c --------------------------------------------------*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲婷婷国产精品电影人久久| 夫妻av一区二区| 国产精品自在欧美一区| 91免费精品国自产拍在线不卡| 欧美高清你懂得| 一区二区三区在线观看网站| 国产久卡久卡久卡久卡视频精品| 欧美区视频在线观看| 亚洲人成网站在线| 岛国精品一区二区| 久久久久久久一区| 久久精品久久99精品久久| 欧美性色欧美a在线播放| 国产精品乱人伦中文| 激情文学综合网| 日韩免费观看高清完整版在线观看| 玉米视频成人免费看| 成人精品视频一区二区三区尤物| 日韩三级视频在线观看| 婷婷激情综合网| 欧美中文一区二区三区| 亚洲天堂av老司机| 丁香桃色午夜亚洲一区二区三区| 日韩一级成人av| 奇米888四色在线精品| 欧美日本在线看| 午夜精品久久久久久久久久 | 久久精品久久99精品久久| 欧洲精品在线观看| 一区二区在线免费观看| 91免费视频网| 亚洲成人一区二区在线观看| 欧洲色大大久久| 偷拍自拍另类欧美| 日韩一级二级三级精品视频| 日韩电影在线观看电影| 欧美一区二区播放| 久久国产夜色精品鲁鲁99| 26uuu另类欧美| 国产成人无遮挡在线视频| 国产农村妇女精品| av成人老司机| 亚洲自拍偷拍网站| 制服丝袜激情欧洲亚洲| 久久精品国产精品亚洲综合| 日韩午夜在线影院| 国产一区二区影院| 国产精品二三区| 在线免费观看一区| 麻豆精品久久精品色综合| 精品国产电影一区二区| 福利电影一区二区三区| 亚洲女同一区二区| 欧美精品v国产精品v日韩精品| 蜜桃91丨九色丨蝌蚪91桃色| 久久精品亚洲一区二区三区浴池 | 97se亚洲国产综合自在线观| 亚洲精品自拍动漫在线| 欧美一卡二卡三卡四卡| 国产不卡高清在线观看视频| 亚洲欧美日本韩国| 欧美一级专区免费大片| 国产成人99久久亚洲综合精品| 国产精品伦理在线| 91麻豆精品国产综合久久久久久| 国产一区二区三区四| 一片黄亚洲嫩模| 久久夜色精品国产噜噜av | 欧美日韩精品一区视频| 狠狠色伊人亚洲综合成人| 亚洲人精品午夜| 日韩区在线观看| 91亚洲精品久久久蜜桃网站| 天天影视涩香欲综合网| 国产色综合久久| 欧美日韩精品电影| 高清久久久久久| 麻豆精品一二三| 亚洲一区影音先锋| 日本一区二区三区国色天香 | 99久久精品国产麻豆演员表| 日本vs亚洲vs韩国一区三区二区| 久久九九影视网| 欧美另类高清zo欧美| 成人av手机在线观看| 免费在线成人网| 亚洲一区二区三区四区五区中文| 国产三级一区二区| 欧美一区二区视频观看视频| aa级大片欧美| 国产伦理精品不卡| 久久国产视频网| 日本不卡一区二区三区| 亚洲午夜精品网| 亚洲人妖av一区二区| 欧美国产一区视频在线观看| 日韩欧美国产wwwww| 欧美日韩一二三| 在线这里只有精品| 91视频免费看| 97久久久精品综合88久久| 国产成人免费网站| 国产传媒久久文化传媒| 日韩电影在线免费看| 亚洲国产一区二区视频| 亚洲欧美另类综合偷拍| 国产欧美日产一区| 国产欧美精品一区aⅴ影院 | 国产午夜一区二区三区| 精品国产99国产精品| 日韩欧美国产1| 精品久久99ma| 久久综合九色综合97婷婷女人| 日韩欧美国产1| 精品久久久久香蕉网| 亚洲精品一区在线观看| 精品日韩99亚洲| 26uuu欧美日本| 欧美激情艳妇裸体舞| 国产女同互慰高潮91漫画| 日本一区免费视频| 自拍偷拍亚洲欧美日韩| 中文字幕一区二区在线观看| 亚洲人精品午夜| 亚洲成a人片在线不卡一二三区 | 欧美精品少妇一区二区三区| 欧美日韩一区三区四区| 91精品国产色综合久久久蜜香臀| 91精品国产综合久久精品图片| 日韩一区和二区| 久久精品亚洲乱码伦伦中文| 中文成人av在线| 亚洲欧美另类小说| 日本视频免费一区| 国产成人在线看| 91麻豆国产精品久久| 91精品国产高清一区二区三区 | 美女视频网站久久| 国产福利视频一区二区三区| 成人av第一页| 欧美日韩亚洲综合一区| 精品久久久久一区| 1024成人网| 丝袜亚洲精品中文字幕一区| 激情文学综合网| 91在线观看视频| 91精品欧美久久久久久动漫| 久久久久久久久久看片| 亚洲中国最大av网站| 久久国产精品99久久久久久老狼| 成人18精品视频| 日韩情涩欧美日韩视频| 成人欧美一区二区三区1314 | 在线成人小视频| 国产亚洲一本大道中文在线| 亚洲乱码中文字幕综合| 激情小说欧美图片| 在线区一区二视频| 国产日韩亚洲欧美综合| 午夜久久电影网| 91在线porny国产在线看| 91精品国产综合久久小美女 | 久久综合精品国产一区二区三区| 亚洲欧美日韩国产一区二区三区| 久久国产麻豆精品| 欧美午夜在线观看| 国产精品久久久久影院| 激情欧美一区二区| 精品视频免费在线| 亚洲乱码精品一二三四区日韩在线| 国产麻豆视频一区二区| 欧美精品久久久久久久多人混战| 国产精品久久久久久久久久免费看| 日韩成人伦理电影在线观看| 91影院在线免费观看| 久久久99精品久久| 蜜臀av一区二区三区| 欧美日韩亚洲高清一区二区| 国产精品美女一区二区三区 | 欧美精彩视频一区二区三区| 日本sm残虐另类| 欧美日韩综合在线| 亚洲同性同志一二三专区| 国产成人免费视频一区| 91精品国产一区二区三区香蕉| 亚洲久草在线视频| 日本韩国一区二区| 自拍偷拍欧美精品| jizzjizzjizz欧美| 中文一区二区在线观看| 国模套图日韩精品一区二区| 日韩视频在线永久播放| 日本在线不卡一区| 日韩一区二区三区在线| 香蕉久久夜色精品国产使用方法| 一本高清dvd不卡在线观看| 亚洲视频狠狠干| 91福利在线导航| 天堂av在线一区| 欧美日高清视频|