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

📄 comemldv.h

📁 The Lite Evaluation/Demonstration Kit is intended to illustrate use of the AN3042. The AN3042 is c
💻 H
字号:
//////////////////////////////////////////////////////////////////////
//
// File: comemLDv.h 
//
// $Archive: /ComemL/Host/Perf42/comemLDv.h $
// Copyright (c) 1997 Anchor Chips, Inc.  May not be reproduced without
// permission.  See the license agreement for more details.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_COMEMDEVICE_H__19BEB661_4C3D_11D1_B9FB_00A024BBE6B5__INCLUDED_)
#define AFX_COMEMDEVICE_H__19BEB661_4C3D_11D1_B9FB_00A024BBE6B5__INCLUDED_

// Error code return value.  Positive values and 0 are reserved for "good"
// return codes.
enum errcodeE {NO_MAPPER_ERROR=0, 
   GENERIC_ERROR = -1000, 
   ERROR_FIXED,               // Error in value detected and fixed
   ERROR_NO_CHANGE,           // Error in value detected and not fixed
   ERROR_EEPROM_TIMEOUT,      // Timeout on EEPROM operation
   ERROR_EEPROM_MISSED_ACK,   // No ACK received from EEPROM
   ERROR_INV_FILE,			   // invalid file type
   ERROR_BUFF_OVERRUN,		   // buffer overrun -- no longer used, just return the number read and allow multiple reads
   ERROR_MISSING_END_RECORD,  // Missing end record
   ERROR_BAD_CHECKSUM,        // Bad checksum in HEX record
   ERROR_CANT_OPEN_FILE,      // Unable to open file
//   ERROR_NO_DRIVER,			  // Driver not installed
   };

#include "comemLif.h" // TPM Modified for CoMem Lite

class CFillRegion
  {
   public:
     DWORD addr;
     DWORD size;
     CFillRegion *next;
     CFillRegion(DWORD addr_in, DWORD size_in)
        {
        addr = addr_in;
        size = size_in;
        next = NULL;
        };

  };

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

// Flags passed to FillBlockStruct
#define FB_GRANULAR 1   

//////////////////////////////////////////////////////////////////////
// Mapper/loader library
// Most of the features of the mapper/loader application are accessible to the developer by  linking their application to a mapper/loader library.  The library is written in C, and may be linked with C or C++ code.  This library supplies the following functions:

// Public definitions that are used with this class
enum ftypeE   {INTEL_HEX = 1, INTEL_HEX_W_SPACES, SREC, BIN, TICK_H}; // Enum of file types.
enum blockidE  {OPSREG0, DA0, CS0, CS1, BLOCK0, BLOCK1, BLOCK2, BLOCK3, MAX_MAP_ENTRIES};  // Enum of block identifiers in priority order
const int MAX_OPSREG = OPSREG0 + 1;
const int MAX_DA = DA0 + 1;
const int MAX_CS = CS1 + 1;
const int MAX_BLOCK = BLOCK3 + 1;
enum block_typeE {UNUSED, RW_PROG, RO_PROG, RW_DATA, HARDWARE, CS_UNUSED = 0, CS_RDY_INPUT, CS_RDY_COUNT};
const int CS_RDY_MASK = 3;
struct blockT {
   DWORD linear_address;
   DWORD addin_addr;
   DWORD size;
   DWORD allocated;    // Bit 0 on = N/A
   block_typeE type;
	};

typedef struct FillRegion_structure SFillRegion;

struct FillRegion_structure
  {
     DWORD addr;
     DWORD size;
     SFillRegion *next;
  };

//////////////////////////////////////////////////////////////////////
// Public definitions
typedef errcodeE write_fnT(DWORD addr, DWORD data, DWORD comemID);

errcodeE readDataFile(
		const char * filepath, 	 // Path and filename of input file 
		DWORD targetAddress, 	 // Target start address (-1 for "read from file")
		ftypeE *type, 				 // Type of file to input -- may be changed when type is detected
		DWORD endianConversion,    // mask to xor with address for endian conversion (1 for swap within words, 3 for 0123 to 3210.)
		DWORD comemID);

errcodeE readEepromDataFile(const char *filename, 
		DWORD offset,         		// Offset -- set to -1 to get offset from srec or hex file
		ftypeE type,    				// Type of file to input
      DWORD endianConversion,    // Mask for endian conversion
		DWORD comemID);

// Reads a file into a block of device memory. Possible errors:  DOS file errors, block overrun, bad type, error in file. 

errcodeE writeDataFile(
		char * filepath, 			// Path and filename of output file 
		DWORD targetAddress, 		// Target start address 
		ftypeE type, 				// Type of file to output
      DWORD endianConversion, // mask to xor with address for endian conversion (1 for swap within words, 3 for 0123 to 3210.)
		unsigned long length,		// Size of block (bytes) 
		DWORD comemID);
// Writes a file from a block of device memory. Possible errors:  DOS file errors, block overrun, bad type, error in file, file is read-only. 

errcodeE writeComemL(DWORD addr, DWORD data, DWORD comemID);
DWORD readComemL(DWORD addr, DWORD comemID);
errcodeE readEepromL(DWORD addr, unsigned char *blockptr, DWORD size, DWORD comemID); 
errcodeE writeEepromL(DWORD addr, unsigned char *blockptr, DWORD size, DWORD comemID); 

char *get_block_name(int row, int col);
errcodeE check_value(DWORD &value, DWORD min, DWORD max, DWORD mask, char *);
//////////////////////////////////////////////////////////////////////
// class CComemDevice  
//
// Function:
//		Represents the co-memory device to the program
//		Performs checking on i/o to the device.
// 
//////////////////////////////////////////////////////////////////////
class CComemDevice  
{
public:
	CComemDevice(DWORD comemID);
	virtual ~CComemDevice();

   void get_block_string(char *buffer, int row, int column);
   char *get_block_string(int row, int col);
   errcodeE setBlockData(char *buffer, int row, int col);
   errcodeE checkBlockData(DWORD &value, int row, int col);

   PCI_CONFIG_HEADER_0 pciRegs;
   DWORD linBAR[COMEM_MAX_BARS];
   DWORD nfcmd;
   DWORD lctl;
   DWORD lint;
   DWORD lhdata;
   DWORD hctl;
   DWORD hint;
   DWORD hldata;
   DWORD hmbase;
   DWORD hmsize;
   DWORD pfaddr;

   // Internal properties
    blockT mapdata[MAX_MAP_ENTRIES];		// Our version of the mapping registers
	DWORD	nailBootPage;					// Page to nail on startup.  -1 = no nail
	DWORD	endianFlag;
	DWORD	venID, devID;
	DWORD	physPage;
	DWORD	linPage;
	DWORD	comemID;

   void FillBlockStruct(CFillRegion *blocks[], blockT *locMapdata, DWORD &low_addr, DWORD &hi_addr, DWORD &blockCount, DWORD flags = 0);
   void CheckForOverlap();
   void SetRegVal(char *buffer, int addr);
   void SetRegVal(char *buffer, int row, int col);
   void readRegVal(char *prompt, DWORD addr, const char *filename = NULL);
//   errcodeE writeCfgFile(blockT *block, const char *filename = NULL);
//   errcodeE readCfgFile(blockT *blockArray, const char *filename = NULL);
};

extern CComemDevice *comemDevL[COMEM_MAX_DEVICES];

#endif // !defined(AFX_COMEMDEVICE_H__19BEB661_4C3D_11D1_B9FB_00A024BBE6B5__INCLUDED_)

⌨️ 快捷键说明

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