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

📄 ide.lst

📁 linux下数据下载器的设计与实现
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   IDE                                                                   10/12/2007 17:05:44 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE IDE
OBJECT MODULE PLACED IN ide.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ide.c OBJECTADVANCED OPTIMIZE(11,SIZE) REGFILE(.\nand_fw2k.ORC) BROWSE ORDE
                    -R INCDIR(c:\cypress\usb\target\inc) DEFINE(NAND_2K) DEBUG

line level    source

   1          //-----------------------------------------------------------------------------
   2          // IDE.c
   3          // This file contains the IDE specific portions of the code.
   4          //
   5          // Format:  indent 3.  NO TABS!
   6          //
   7          
   8          //--------------------------------------------------------------------------
   9          
  10          //--------------------------------------------------------------------------
  11          
  12          #include "globals.h"
  13          
  14          void loadEP4BC(WORD dataLen);
  15          
  16          void cMedia() { if (bEject) sensePtr = senseNoMedia; else sensePtr=senseOk; }
  17          
  18          // This command is only used for removable DRIVES, not removable media
  19          // An example of removable drive is Compact Flash 
  20          #define checkForMedia(x) cMedia()
  21          
  22          
  23          // From SCSI spec SPC (SCSI primary commands)
  24          // Byte 0 -- 70 = Current error
  25          // Byte 1 -- Segment number
  26          // Byte 2 -- Sense key (SPC table 107)
  27          //             5 = ILLEGAL REQUEST. Indicates that there was an illegal parameter in 
  28          //                 the CDB or in the additional parameters supplied as data for some commands
  29          //             B = ABORTED COMMAND. Indicates that the device server aborted the command.
  30          //                 The application client may be able to recover by trying the command again.
  31          //             E = MISCOMPARE. Indicates that the source data did not match the data read 
  32          //                 from the medium.
  33          // Byte 3-6  -- Information (not used)
  34          // Byte 7    -- add'l sense length 
  35          // byte 8-11 -- Command specific information
  36          // byte 12   -- ASC (Add'l sense code)
  37          // byte 13   -- ASQ (Add'l sense qualifier)
  38          //                                                Key                                                     
             -   ASC   ASQ
  39          //                                    0     1     2     3     4     5     6     7     8     9    10    11 
             -   12    13    14    15
  40          //const char code senseTemplate[]= {0x70,  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0
             -0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};   
  41          //                                                SK    ASC   ASQ
  42          
  43          const char code senseArray[senseWriteProtected+1][3] = 
  44          {{0x0b, 0x08, 0x03},   // senseCRCError               0 // Set on CRC error.  Causes host to retry  
  45          {0x05, 0x24, 0x00},    // senseInvalidFieldInCDB      1 
  46          {0x00, 0x00, 0x00},    // senseOk                     2
  47          {0x02, 0x3a, 0x00},    // senseNoMedia                3
  48          {0x03, 0x03, 0x00},    // senseWriteFault             4
  49          {0x03, 0x11, 0x00},    // senseReadError              5
  50          {0x03, 0x12, 0x00},    // senseAddrNotFound           6
  51          {0x05, 0x20, 0x00},    // senseInvalidOpcode          7
C51 COMPILER V7.50   IDE                                                                   10/12/2007 17:05:44 PAGE 2   

  52          {0x05, 0x21, 0x00},    // senseInvalidLBA             8
  53          {0x05, 0x26, 0x00},    // senseInvalidParameter       9
  54          {0x05, 0x53, 0x02},    // senseCantEject              0xa
  55          {0x06, 0x28, 0x00},    // senseMediaChanged           0xb
  56          {0x06, 0x29, 0x00},    // senseDeviceReset            0xc 
  57          {0x07, 0x27, 0x00}};   // senseWriteProtected         0xd
  58          
  59          char sensePtr;
  60          
  61          /////////////////////////////////////////////////////////////////////////////////
  62          //
  63          // Called when we have received a valid CBW from the host
  64          //
  65          // Input:
  66          //    EP2FIFOBUF -- Contains CBW
  67          //   
  68          // Output:
  69          //    EP4FIFOBUF -- Used to send the data phase of the command back to the host.
  70          //    Returns a byte to be sent as the CSW status byte.
  71          //////////////////////////////////////////////////////////////////////////////////
  72          bit IDECommand()
  73          {
  74   1         BYTE cmd;
  75   1      
  76   1         bShortPacketSent = !directionIn;
  77   1         
  78   1         cmd = EP2FIFOBUF[0xf]; 
  79   1      
  80   1      #ifndef NO_WP
  81   1         ////////////////////////////////////////////////////////////////////////////////////////////////////
  82   1         // Check for WP status changed.  If the WP status has changed, fail ANY command that comes in and
  83   1         // set the status to "media changed"
  84   1         if (bWriteProtectEnable)
  85   1         {
  86   2            if ((bWPSwitchState != NAND_WP_SWITCH) )
  87   2               {
  88   3               // Free the OUT buffer containing the command, load the error pointer, store new switch value and
             - fail the command   
  89   3               OUTPKTEND = 0x82;
  90   3               bWPSwitchState = NAND_WP_SWITCH;
  91   3               sensePtr = senseMediaChanged; 
  92   3               if (directionIn) failedIn();
  93   3               else stallEP2OUT();
  94   3               //bEject = 0;  // toggle the switch will enable device again
  95   3               return(USBS_FAILED);
  96   3               }
  97   2         }
  98   1      #endif
  99   1      
 100   1         switch (cmd)
 101   1         {
 102   2      /// IN Command
 103   2            //////////////////////////////////////////////////////////////////////////////////
 104   2            // Good example of the processing required for a case in this switch statement.
 105   2            // -- Gives OUT bulk buffer back to the host
 106   2            // -- Loads IN buffer with a response
 107   2            // -- Adjusts dataTransferLen (inside loadEP4BC)
 108   2            // -- Returns PASSED or FAILED
 109   2            case INQUIRY:
 110   2            {
 111   3               OUTPKTEND = 0x82;
 112   3               // Send out our stored inquiry data
C51 COMPILER V7.50   IDE                                                                   10/12/2007 17:05:44 PAGE 3   

 113   3               waitForInBuffer();
 114   3               AUTOPTRL2 = LSB(EP4FIFOBUF);
 115   3      #ifdef USE_2LUN
                       if (!bLUN1) P_XAUTODAT2 = 0; else P_XAUTODAT2 = cDriveType;
              #else
 118   3               P_XAUTODAT2 = 0;
 119   3      #endif
 120   3      
 121   3      #ifndef NO_WP
 122   3               if (bWriteProtectEnable) P_XAUTODAT2 = SCSI_INQUIRY_REMOVABLE_BIT;
 123   3               else P_XAUTODAT2 = 0;
 124   3      #else
                       P_XAUTODAT2 = SCSI_INQUIRY_REMOVABLE_BIT;
              #endif
 127   3               P_XAUTODAT2 = 0;
 128   3               P_XAUTODAT2 = 0;
 129   3               P_XAUTODAT2 = 0x1F;
 130   3               P_XAUTODAT2 = 0;
 131   3               P_XAUTODAT2 = 0;
 132   3               P_XAUTODAT2 = 0;
 133   3               // copy SCSI Inquiry string
 134   3               mymemmovexx(EP4FIFOBUF+8, halfKBuffer+cHALF_BUFF_OFFSET, cINQUIRY_LENGTH); 
 135   3               loadEP4BC(0x1F+5);
 136   3               sensePtr = senseOk;
 137   3               return(USBS_PASSED);
 138   3            }
 139   2      
 140   2            case NAND_SCSI_CMD_VENDOR_CBW: return handleVendorCBW();
 141   2      
 142   2            // This command is "spoofed".  We tell the host that the command has succeeded but
 143   2            // don't actually do anything.
 144   2            case SYNCHRONIZE_CACHE:
 145   2            case SEEK_10:
 146   2            {
 147   3                  // relinquish control of the bulk buffer occupied by the CBW
 148   3                  OUTPKTEND = 0x82;
 149   3                  return(USBS_PASSED);
 150   3            }                
 151   2      
 152   2            case READ_FORMAT_CAPACITIES:
 153   2            case READ_CAPACITY:
 154   2            {
 155   3               BYTE num_bytes = 8;
 156   3      
 157   3               // Nand Mfg support
 158   3               GetNandCfg();
 159   3               // add this for 30ns cycle support
 160   3               if (b30nsCycle && EZUSB_HIGHSPEED())
 161   3               {
 162   4                    GPIF_40();
 163   4                    b30nsCycle = 0;  // load only one time
 164   4               }
 165   3               // relinquish control of the bulk buffer occupied by the CBW
 166   3               OUTPKTEND = 0x82;       
 167   3               checkForMedia(1);
 168   3                       
 169   3               waitForInBuffer();
 170   3               if (sensePtr == senseOk)
 171   3               {
 172   4                  AUTOPTRL2 = LSB(EP4FIFOBUF);
 173   4                  if(cmd == READ_FORMAT_CAPACITIES) // add 4 byte capacity list header
 174   4                  {
C51 COMPILER V7.50   IDE                                                                   10/12/2007 17:05:44 PAGE 4   

 175   5                     P_XAUTODAT2 = 0x0;
 176   5                     P_XAUTODAT2 = 0x0;
 177   5                     P_XAUTODAT2 = 0x0;
 178   5                     P_XAUTODAT2 = 0x08;
 179   5                     num_bytes = 12;
 180   5                  }
 181   4      #ifdef USE_2LUN
                          if (bLUN1)
                          {
                             P_XAUTODAT2 = (cLUN1_Capacity >> 24);
                             P_XAUTODAT2 = (cLUN1_Capacity >> 16);
                             P_XAUTODAT2 = (cLUN1_Capacity >>  8);
                             P_XAUTODAT2 = (cLUN1_Capacity >>  0);
                          }
                          else
                          {
                             P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[0];
                             P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[1];
                             P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[2];
                             P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[3];
                          }
              #else
 197   4                  P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[0];
 198   4                  P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[1];
 199   4                  P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[2];
 200   4                  P_XAUTODAT2 = ((BYTE *) &gDriveCapacity)[3];
 201   4      #endif
 202   4                  if(cmd == READ_FORMAT_CAPACITIES) 
 203   4                     P_XAUTODAT2 = ((NAND_ATA_SECTOR_SIZE >> 24) & 0xff) | 2;     // Report media type -- Format
             -ted
 204   4                  else
 205   4                     P_XAUTODAT2 = (NAND_ATA_SECTOR_SIZE >> 24) & 0xff;
 206   4                  P_XAUTODAT2 = (NAND_ATA_SECTOR_SIZE >> 16) & 0xff;
 207   4                  P_XAUTODAT2 = (NAND_ATA_SECTOR_SIZE >>  8) & 0xff;
 208   4                  P_XAUTODAT2 = (NAND_ATA_SECTOR_SIZE >>  0) & 0xff;
 209   4      
 210   4                  loadEP4BC(num_bytes);
 211   4                  return(USBS_PASSED);
 212   4               }
 213   3               else
 214   3               {
 215   4                  failedIn();
 216   4                  return(USBS_FAILED);
 217   4               }
 218   3            }
 219   2      
 220   2            case TEST_UNIT_READY:
 221   2            case VERIFY_10:
 222   2            case FORMAT_UNIT:
 223   2            {
 224   3               // relinquish control of the bulk buffer occupied by the CBW
 225   3               OUTPKTEND = 0x82;
 226   3               if (dataTransferLen)
 227   3               {
 228   4                  if (directionIn) failedIn(); else stallEP2OUT();
 229   4               }
 230   3               checkForMedia(1);
 231   3               
 232   3               if (sensePtr == senseOk)
 233   3                  return(USBS_PASSED);
 234   3               else
 235   3                  return(USBS_FAILED);
C51 COMPILER V7.50   IDE                                                                   10/12/2007 17:05:44 PAGE 5   

 236   3            }                
 237   2            case REQUEST_SENSE:

⌨️ 快捷键说明

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