📄 comemdevice.h
字号:
//////////////////////////////////////////////////////////////////////
//
// File: comemDevice.h
//
// $Archive: /ComemL/Host/Perf42/comemDevice.h $
//
// Purpose:
// interface for the comemDevice class.
//
// $Author: Tpm $
//
// $History: comemDevice.h $
//
// ***************** Version 1 *****************
// User: Tpm Date: 2/02/99 Time: 5:03p
// Created in $/ComemL/Host/Perf42
//
// ***************** Version 6 *****************
// User: Stevek Date: 11/07/97 Time: 11:06a
// Updated in $/Comem/Mapper
// Added nailBootPage to targetStart.
//
// ***************** Version 5 *****************
// User: Stevek Date: 11/06/97 Time: 4:16p
// Updated in $/Comem/Mapper
// Added exclusive flag so that library calls don't get a "two mappers"
// error.
//
// ***************** Version 4 *****************
// User: Stevek Date: 10/28/97 Time: 9:57a
// Updated in $/Comem/Mapper
// More seperation for seperate library file.
// Removed embeddedSystems stuff.
//
// ***************** Version 3 *****************
// User: Stevek Date: 10/27/97 Time: 1:16p
// Updated in $/Comem/Mapper
// Moved interface functions into the comem_if.lib file.
//
// ***************** Version 2 *****************
// User: Stevek Date: 10/24/97 Time: 3:55p
// Updated in $/Comem/Mapper
// Started to seperate library functions out of mapper files.
// Current code is tested with one comem.
//
// ***************** Version 15 *****************
// User: Stevek Date: 10/22/97 Time: 12:27p
// Updated in $/Comem/Mapper
// Added header blocks to all files at once!
//
// 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 "comem_if.h"
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 mapAll(blockT *block, DWORD comemID); // Dump the entire map to the device.
errcodeE map_block(blockT &block, blockidE block_id, write_fnT, DWORD comemID); // Used to map a block. Sets block options. The linear address must represent a block of the proper length in linear address space.
errcodeE readCfgFile(blockT map[], const char * filename, DWORD comemID); // Initialize map structure with .ini file contents. Returns error if .ini file is not found or if bad elements are found.
errcodeE writeCfgFile(blockT map[], const char * filename = NULL); // Initialize .ini file from map structure. Returns error if cannot open file for write.
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 targetStart(DWORD nailBootPage, DWORD comemID); // Start the target system. Releases reset on the target.
errcodeE targetReset(DWORD comemID); // Reset the target system. Must be called before mapping blocks, etc.
errcodeE writeComem(DWORD addr, DWORD data, DWORD comemID);
DWORD readComem(DWORD addr, DWORD comemID);
errcodeE readEeprom(DWORD addr, unsigned char *blockptr, DWORD size, DWORD comemID);
errcodeE writeEeprom(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 *comemDev[COMEM_MAX_DEVICES];
#endif // !defined(AFX_COMEMDEVICE_H__19BEB661_4C3D_11D1_B9FB_00A024BBE6B5__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -