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

📄 ide.lst

📁 cypress 68013a-56pvxc usb2.0
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.10   IDE                                                                   05/28/2007 19:12:32 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE IDE
OBJECT MODULE PLACED IN .\_Oput\ide.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\ide.c ROM(COMPACT) OPTIMIZE(9,SPEED) BROWSE ORDER DEFINE(GPIF=0,FLAS
                    -H=0,DEVICE_TYPE_IS_SCSI=1,DEVICE_TYPE_IS_IDE=1,VBUS_DETECT=1) DEBUG OBJECTEXTEND CODE PRINT(.\_List\ide.lst) OBJECT(.\_O
                    -put\ide.obj)

line level    source

   1          //-----------------------------------------------------------------------------
   2          //  Copyright (c) 1999 Cypress Semiconductor, Inc. All rights reserved
   3          //-----------------------------------------------------------------------------
   4          //
   5          // This file contains the IDE specific portions of the code.  In ATAPI
   6          // or SCSI applications, this file should not be needed.
   7          //
   8          // $Archive: /USB/atapifx2/software/ide.c $
   9          // $Date: 1/23/02 9:35a $
  10          // $Revision: 53 $
  11          //-----------------------------------------------------------------------------
  12          #include "Fx2.h"
  13          #include "Fx2regs.h"
  14          #include "gpif.h"
  15          #include "scsi.h"
  16          
  17          static bit ideReadCommand(bit verify);
  18          static bit ideWriteCommand();
  19          bit ideUdmaWriteCommand();
  20          static void IDEnop();
  21          static bit checkForMedia();
  22          static DWORD dwLBA;     // This is global to help the optimizer
  23          void dwLBAtoLBARegs();      // Stuff the LBA registers
  24          
  25          
  26          // From SCSI spec SPC (SCSI primary commands)
  27          // Byte 0 -- 70 = Current error
  28          // Byte 1 -- Segment number
  29          // Byte 2 -- Sense key
  30          // Byte 3-6 -- Information (not used)
  31          // Byte 7 -- add'l sense length 
  32          // byte 8-11 -- Command specific information
  33          // byte 12 -- ASC (Add'l sense code)
  34          // byte 13 -- ASQ (Add'l sense qualifier)
  35          //                                                       Key                                              
             -           ASC   ASQ
  36          //                                             0     1     2     3     4     5     6     7     8     9    
             -10    11    12    13    14    15
  37          const char code senseCRCError[] =          {0x70, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x
             -00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00};   
  38          const char code senseInvalidFieldInCDB[] = {0x70, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x
             -00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00};   
  39          const char code senseOk[] =                {0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x
             -00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};   
  40          char code * sensePtr;
  41          
  42          extern char NumCylindersMSB; // global #Cyl MSB
  43          extern char NumCylindersLSB; // global #Cyl LSB
  44          extern char NumHeads;        // global #Heads
  45          extern char NumSectPerTrack; // global #SectorsPerTrack
  46          
  47          /////////////////////////////////////////////////////////////////////////////////
  48          #if DEVICE_TYPE_IS_IDE
C51 COMPILER V7.10   IDE                                                                   05/28/2007 19:12:32 PAGE 2   

  49          /////////////////////////////////////////////////////////////////////////////////
  50          
  51          bit generalIDEInCommand()
  52          {
  53   1         BYTE cmd;
  54   1         WORD packetLen;
  55   1         bit status;
  56   1         
  57   1         cmd = EP2FIFOBUF[0xf];  
  58   1         
  59   1         switch (cmd)
  60   1         {
  61   2            // Minimum processing for a case in this switch statement:
  62   2            case INQUIRY:
  63   2            {
  64   3               sensePtr = senseOk;
  65   3               packetLen = min(dataTransferLen, (WORD) sizeof(SCSIInquiryData));
  66   3               
  67   3               // relinquish control of the bulk buffer occupied by the CBW
  68   3               EP2BCL = 0x80;     
  69   3      
  70   3               // Send out our stored inquiry data
  71   3               waitForInBuffer();
  72   3               mymemmovexx(EP8FIFOBUF, SCSIInquiryData_, packetLen);   // NOTE: may not be needed anymore since 
             -FIFO in AUTOIN 
  73   3               
  74   3               if (packetLen)
  75   3               {
  76   4                  EP8BCH = MSB(packetLen);
  77   4                  EP8BCL = LSB(packetLen);
  78   4               
  79   4                  dataTransferLen -= packetLen;
  80   4               }
  81   3               
  82   3               return(USBS_PASSED);
  83   3            }
  84   2                  
  85   2            case READ_10:
  86   2            {
  87   3               sensePtr = senseOk;
  88   3               checkForMedia();
  89   3      
  90   3               if (sensePtr == senseOk)
  91   3               {
  92   4                  return(ideReadCommand(0));   
  93   4               }
  94   3               else
  95   3               {
  96   4                  // relinquish control of the bulk buffer occupied by the CBW
  97   4                  EP2BCL = 0x80;     
  98   4                  
  99   4                  failedIn();         
 100   4                  return(USBS_FAILED);
 101   4               }
 102   3            }
 103   2                      
 104   2            case VERIFY_10:
 105   2            {
 106   3               sensePtr = senseOk;
 107   3               checkForMedia();
 108   3               if (sensePtr == senseOk)
 109   3                  return(ideReadCommand(1));   // ideReadCommand sets the OUT2BC = 0
C51 COMPILER V7.10   IDE                                                                   05/28/2007 19:12:32 PAGE 3   

 110   3               else
 111   3               {
 112   4                  // relinquish control of the bulk buffer occupied by the CBW
 113   4                  EP2BCL = 0x80;     
 114   4                  
 115   4                  failedIn();         
 116   4                  return(USBS_FAILED);
 117   4               }
 118   3            }            
 119   2            case SEEK_10:
 120   2            {
 121   3               sensePtr = senseOk;
 122   3               checkForMedia();
 123   3      
 124   3               // relinquish control of the bulk buffer occupied by the CBW
 125   3               EP2BCL = 0x80;     
 126   3                  
 127   3               if (sensePtr == senseOk)
 128   3               {
 129   4                  return(USBS_PASSED);
 130   4               }
 131   3               else
 132   3               {
 133   4                  failedIn();         
 134   4                  return(USBS_FAILED);
 135   4               }
 136   3            }                
 137   2      
 138   2            case READ_FORMAT_CAPACITIES:
 139   2            case READ_CAPACITY:
 140   2            {
 141   3               BYTE cap_hdr_offset = 0;
 142   3               BYTE num_dwords = 2;
 143   3      
 144   3               // relinquish control of the bulk buffer occupied by the CBW
 145   3               EP2BCL = 0x80;     
 146   3               
 147   3               sensePtr = senseOk;
 148   3               checkForMedia();
 149   3                       
 150   3               waitForInBuffer();
 151   3               if (sensePtr == senseOk)
 152   3               {
 153   4                  if(cmd == READ_FORMAT_CAPACITIES) // add 4 byte capacity list header
 154   4                  {
 155   5                     EP8FIFOBUF[0] = 0x0;
 156   5                     EP8FIFOBUF[1] = 0x0;
 157   5                     EP8FIFOBUF[2] = 0x0;
 158   5                     EP8FIFOBUF[3] = 0x08;
 159   5                     cap_hdr_offset = 4;
 160   5                     num_dwords = 3;
 161   5                  }
 162   4                  EP8FIFOBUF[0+cap_hdr_offset] = ((BYTE *) &driveCapacity)[0];
 163   4                  EP8FIFOBUF[1+cap_hdr_offset] = ((BYTE *) &driveCapacity)[1];
 164   4                  EP8FIFOBUF[2+cap_hdr_offset] = ((BYTE *) &driveCapacity)[2];
 165   4                  EP8FIFOBUF[3+cap_hdr_offset] = ((BYTE *) &driveCapacity)[3];
 166   4                  EP8FIFOBUF[4+cap_hdr_offset] = (ATA_SECTOR_SIZE >> 24) & 0xff;
 167   4                  EP8FIFOBUF[5+cap_hdr_offset] = (ATA_SECTOR_SIZE >> 16) & 0xff;
 168   4                  EP8FIFOBUF[7+cap_hdr_offset] = (ATA_SECTOR_SIZE >>  0) & 0xff;
 169   4                  EP8FIFOBUF[6+cap_hdr_offset] = (ATA_SECTOR_SIZE >>  8) & 0xff;
 170   4                  
 171   4                  packetLen = min(sizeof(DWORD) * num_dwords, dataTransferLen);
C51 COMPILER V7.10   IDE                                                                   05/28/2007 19:12:32 PAGE 4   

 172   4                  if (packetLen)
 173   4                  {
 174   5                     EP8BCH = MSB(packetLen);
 175   5                     EP8BCL = LSB(packetLen);
 176   5                     dataTransferLen -= packetLen;
 177   5                  }
 178   4                  status = USBS_PASSED;
 179   4               }
 180   3               else
 181   3               {
 182   4                  failedIn();
 183   4                  status = USBS_FAILED;
 184   4               }
 185   3      
 186   3               return(status);
 187   3            }
 188   2      
 189   2            case TEST_UNIT_READY:
 190   2            case PREVENT_ALLOW_MEDIUM_REMOVAL:
 191   2            {
 192   3            // relinquish control of the bulk buffer occupied by the CBW
 193   3               EP2BCL = 0x80;     
 194   3               
 195   3               if (dataTransferLen)    // This command shouldn't have any data!
 196   3                  failedIn();         
 197   3               
 198   3               checkForMedia();
 199   3               
 200   3               if (sensePtr == senseOk)
 201   3                  return(USBS_PASSED);
 202   3               else
 203   3                  return(USBS_FAILED);
 204   3            }                
 205   2            case REQUEST_SENSE:
 206   2            {
 207   3               // relinquish control of the bulk buffer occupied by the CBW
 208   3               EP2BCL = 0x80;     
 209   3         
 210   3               waitForInBuffer();
 211   3      
 212   3               mymemmovexx(EP8FIFOBUF, (char xdata *) sensePtr, sizeof(senseOk));
 213   3      
 214   3               packetLen = min(sizeof(senseOk), dataTransferLen);   
 215   3               if (packetLen)
 216   3               {
 217   4                  EP8BCH = MSB(packetLen);
 218   4                  EP8BCL = LSB(packetLen);
 219   4      
 220   4                  dataTransferLen -= packetLen;
 221   4               }
 222   3               sensePtr = senseOk;
 223   3               return(USBS_PASSED);
 224   3            }
 225   2      
 226   2            case MODE_SENSE_10:
 227   2            {               
 228   3               BYTE pagenum;
 229   3               
 230   3               pagenum = EP2FIFOBUF[CBW_DATA_START+2] & 0x3F; // identify page (see p.141 SCSI 2ed.)
 231   3         
 232   3               EP2BCL = 0x80; // relinquish control of the bulk buffer occupied by the CBW
 233   3               
C51 COMPILER V7.10   IDE                                                                   05/28/2007 19:12:32 PAGE 5   

 234   3               waitForInBuffer();
 235   3               
 236   3               if((pagenum != 0x05) && (pagenum != 0x3F)
 237   3                   && (pagenum != 0x01) && (pagenum != 0x08) && (pagenum != 0x1B))
 238   3               { // only respond to requests for certain pages (the mandatory ones plus page 5)
 239   4                  sensePtr = senseInvalidFieldInCDB;
 240   4                  failedIn();
 241   4                  return(USBS_FAILED);
 242   4               }
 243   3         
 244   3               // If one of the supported pages is requested, return the 8 byte Mode Parameter Header
 245   3               // plus a single 12 byte page. Only the Mode Data length (LSB) is significant in the
 246   3               // Mode Parameter Header. It has a Vendor Specific Medium Type Code in byte 2, and
 247   3               // a 1 bit WP Write Protect bit in byte 3 that are not initialized here.
 248   3               // Pages 0x01, and 0x08 do not have significant data - they are spoofed.
 249   3               // Page 0x1B has a TLUN field in byte 3 that is initialized to 1 (as per ISD).
 250   3               // Page 0x05 does contain information that is needed to boot to HDD and CDROM.
 251   3               // Page 0x3F, All Pages, is also responded to, I just return the single page 5 though.

⌨️ 快捷键说明

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