Source file: /~heha/basteln/PC/fx2/fx2ata-200917.zip/globals.h

//-----------------------------------------------------------------------------
//   File:      globals.h
//   Contents:   global variables used by the firmware
//
//-----------------------------------------------------------------------------
extern volatile BYTE   AlternateSetting;   // Alternate settings
extern volatile BYTE   Configuration;      // Current configuration
extern xdata BYTE   eepromAddr;         // EEPROM address -- Could be one of two possibilities 0x52 or 0x54
extern xdata BYTE   CSMSerial[20];      // CSM serial number

extern WORD wPacketSize;
// Globals for storing per-LUN information.  Data about each LUN (Logical Unit) is stored
// in two different places:  1) A struct in DATA space for storing drive geometry, capacity,
// etc., 2) a bit field in the BIT DATA area for storing device flags that we need to access
// efficiently.  For each request (CBW), the firmware will swap in the appropriate LUN
// information

#ifdef __SDCC
# define BITBYTE(name,addr) __data __at(addr) BYTE name;	// SDCC: put bytes containing bits at fixed addresses
# define BITBIT(name,bytename,addr) __bit __at(addr) name;
#else
# define BITBYTE(name,addr) extern BYTE bdata name;	// Keil C: Resolve at link time
# define BITBIT(name,bytename,addr) extern bit name;
#endif

// The flags for the LUN that is currently being accessed.
BITBYTE(ActiveLunBits,0x2F)
// bit defines for the active LUN
  BITBIT(bDevicePresent,ActiveLunBits,0x78)
  BITBIT(bMasterSlave,ActiveLunBits,0x79)   // 0 == device0 (master), 1 == device1 (slave)
  BITBIT(bScsi,ActiveLunBits,0x7B)
  BITBIT(bExtAddrSupport,ActiveLunBits,0x7C)
  BITBIT(bCompactFlash,ActiveLunBits,0x7D)
  BITBIT(bWriteCacheDisabled,ActiveLunBits,0x7E)   // Active low so it starts out active when we set ActiveLunBits to 0
// Storage area for LUN0 and LUN1 flags
BITBYTE(LunBitsH,0x2A)
BITBYTE(LunBitsL,0x2B)
extern BYTE sensePtrs[2];

// bit defines for the active LUN

extern BYTE currentLunNum;

// Device info for the Active LUN
extern idata DEVICE_CONFIG_DATA ActiveLunConfigData;
// Sorage area for the LUN0 and LUN1 device info
extern idata DEVICE_CONFIG_DATA DeviceConfigData[];

// this variable is used to store the number of devices attached to the IDE bus.  This is what
// we will use to forumlate our response to the GET MAX LUN Mass Storage Class request.
extern BYTE deviceCount;

extern bit  bSkipPinReset;
extern bit  bFirstTime;
extern bit  bSwitchToHighSpeed;
extern bit  bHighSpeedEnabled;
#ifdef __SDCC
__xdata BYTE __at(0xE000) halfKBuffer[BUFFER_SIZE];
#else
extern xdata BYTE halfKBuffer[BUFFER_SIZE];
#endif

extern WORD cbwTagLow;          // Tag from the most recent CBW packet
extern WORD cbwTagHi;
extern BYTE currentState;

extern DWORD dataTransferLen;
extern volatile BYTE seconds;
extern volatile BYTE hertz61ticks;

extern bit noFlashMedia;
extern bit ejected;
extern bit directionIn;
extern bit phaseErrorState;
//extern bit bNewAt2pinout;

extern bit bUseUdma;
extern bit bShortPacketSent;
extern bit bScsiRegsPreloaded;
extern BYTE udmaErrorCount;
extern BYTE IOEShadow;

extern bit Sleep;
extern bit driveIsInStandby;

BITBYTE(miscConfig,0x2C)
  BITBIT(bATA_UDMA_ENABLE,miscConfig,0x67)
  BITBIT(bATAPI_UDMA_ENABLE,miscConfig,0x66)
  BITBIT(bENABLE_WRITE_CACHE_MODE_PAGE,miscConfig,0x65)
  BITBIT(bCOMPLIANCE_MODE,miscConfig,0x64)	// Compliance mode uses the INTRQ pin less, but it will pass the BOT tests.
  BITBIT(bWAIT_FOR_BUSY_BIT,miscConfig,0x63)
  BITBIT(bSHORT_PACKET_BEFORE_STALL,miscConfig,0x62)
  BITBIT(bSRST_ENABLE,miscConfig,0x61)
  BITBIT(bSKIP_PIN_RESET,miscConfig,0x60)
BITBYTE(miscConfig2,0x2D)
  BITBIT(bCF_USES_UDMA,miscConfig2,0x6B)
  BITBIT(b2LUN_SET_BY_EEPROM,miscConfig2,0x6A)
  BITBIT(b1LUN_SET_BY_EEPROM,miscConfig2,0x69)
  BITBIT(bSEARCH_ATA_ON_WAKEUP,miscConfig2,0x68)
BITBYTE(pinConfig,0x2E)
  BITBIT(bBUTTON_PINOUT,pinConfig,0x77)
  BITBIT(bATA_ENABLED,pinConfig,0x76)
  BITBIT(bBIG_PACKAGE,pinConfig,0x75)
  BITBIT(bATA_EN,pinConfig,0x74)
  BITBIT(bNewAt2pinout,pinConfig,0x73)
  BITBIT(bHS_INDICATOR,pinConfig,0x72)
  BITBIT(bDRVPWRVLD_POLARITY,pinConfig,0x71)
  BITBIT(bDRVPWRVLD_ENABLE,pinConfig,0x70)

extern bit bDISKRDY_POLARITY;

extern BYTE report[2];
extern BOOL receivedReport_Flag;
extern BYTE oldButtons;

//extern BYTE HIDIntrfcDscrOffset;
//extern BYTE CSMIntrfcDscrOffset;

#undef BITBYTE
#undef BITBIT
Detected encoding: ASCII (7 bit)2