📄 drive42.cpp
字号:
//////////////////////////////////////////////////////////////////////
//
// File: dma42.cpp
//
// Purpose: Host-side test for 3042 (CO-MEM Lite) chips.
//
// $Author: Tpm $
//
// $History: drive42.cpp $
//
// ***************** Version 1 *****************
// User: Tpm Date: 2/02/99 Time: 5:03p
// Created in $/ComemL/Host/Perf42
//
//
// Borrowed from the following code:
// User: Stevek Date: 11/10/97 Time: 3:30p
// Created in $/Comem/comemDemo
//
// Copyright (c) 1997 Anchor Chips, Inc. May be modified or copied only
// to evaluate or produce products using Anchor Chips' products. See the license
// agreement for more details.
//
//
// ??? means needs further checking or testing.
// E??? means a proposed enhancement.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <direct.h> // For directory handling routines.
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> // For report_error()
#include <conio.h> // for getch()
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/locking.h>
#include <io.h>
#include <fcntl.h>
#include <share.h>
#include <sys/timeb.h>
typedef unsigned long DWORD;
// #include "comemDevice.h"
// #include "memory_Mgmt.h"
#include "comemLdv.h"
#include "drive42.h"
void report_error(const char *fmt, ...);
void reportErrorCode(DWORD status, char * whereAmI);
void doTheApp(DWORD comemID);
DWORD verifyComemConfig(DWORD comemID);
#define SMbase 0x4000
// #define SMsize 0x4000
#define DMA_COMPLETE_BIT 0x00000020 // indicates DMA is comlete
DWORD g_linBAR[COMEM_MAX_BARS];
// This structure MUST be designated 'volatile' for the VC++ 'Release' version (as opposed to the 'Debug' version).
// Without 'volatile', optimizers destroy the intent of certain code below.
volatile struct op_regs_struct_42_zerobased_t * g_regp;
DWORD g_lin;
DWORD g_phys;
DWORD * g_hostLin;
DWORD * g_hostPhys;
DWORD linBAR[COMEM_MAX_BARS];
DWORD linPage;
DWORD physPage;
// #define printf
// #define reportErrorCode
// AllocBlockAll allData[COMEM_MAX_DEVICES];
// ********************************************************
// 3042 Defines and Structures
// I2O Registers
// All I2O stuff is still not done!!! ???
#define I2O_HOST_INTERRUPT_STATUS_REG 0x30
#define I2O_HOST_INTERRUPT_MASK_REG 0x34
#define I2O_IOP_INTERRUPT_STATUS_REG 0x38
#define I2O_IOP_INTERRUPT_MASK_REG 0x3C
#define I2O_INBOUND_POST_FIFO_REG 0x40 // W
#define I2O_INBOUND_FREE_FIFO_REG 0x40 // R
#define I2O_OUTBOUND_POST_FIFO_REG 0x44 // W
#define I2O_OUTBOUND_FREE_FIFO_REG 0x44 // W
#define I2O_INBOUND_POST_FIFO_DEBUG_REG 0x48 // R
#define I2O_INBOUND_FREE_FIFO_DEBUG_REG 0x48 // W
#define I2O_OUTBOUND_POST_FIFO_DEBUG_REG 0x4C // R
#define I2O_OUTBOUND_FREE_FIFO_DEBUG_REG 0x4C // R
typedef struct op_regs_struct_42_zerobased_t
{
DWORD unused_i2o_below[0xD];
DWORD i2ohimr; // 0x034
DWORD unused_i2o_gap[0x10A];
DWORD dahbase; // 0x460
DWORD unused_464;
DWORD unused_468;
DWORD unused_46c;
DWORD unused_470; // 0x470
DWORD unused_474;
DWORD unused_478;
DWORD unused_47c;
DWORD unused_480; // 0x480
DWORD unused_484;
DWORD unused_488;
DWORD unused_48c;
DWORD unused_490; // 0x490
DWORD unused_494;
DWORD unused_498;
DWORD unused_49c;
DWORD nvcmd; // 0x4A0
DWORD nvread;
DWORD nvstat;
DWORD unused_4Ac;
DWORD dmalbase; // 0x4B0
DWORD dmahbase;
DWORD dmasize;
// DWORD dmactl_dword;
union dmactl_t {
DWORD dmactl_dword;
unsigned char dmactl_bytes[4];
} dmactl_v;
DWORD unused_4C0; // 0x4C0
DWORD unused_4C4;
DWORD unused_4C8;
DWORD unused_4Cc;
DWORD unused_4D0; // 0x4D0
DWORD unused_4D4;
DWORD unused_4D8;
DWORD unused_4Dc;
DWORD hctl; // 0x4E0
DWORD hint;
DWORD hldata;
DWORD unused_4Ec;
DWORD unused_4F0; // 0x4F0
DWORD lint;
DWORD lhdata;
DWORD lbuscfg;
} op_regs_struct_42_zerobased_v;
// volatile struct op_regs_struct_42_t * regp;
// Log file stuff
FILE * logFilePtr = 0;
DWORD globalErrorCnt = 0;
DWORD passNum = 0;
char logFileName [100];
DWORD locPCI;
DWORD locLocal;
//// DMA stuff
#define physAddrMsk ( 0xFFFFf000L ) // Mask in bits 12 to 31.
#define DMAcompleteBit ( 0x00000020L )
//// Mutha Shared Mem Test stuff
enum Side {PCI, Local, Unused};
enum ExpectErrs {MUSTpass, ERRORSok};
enum DoComplement {trueData, complementData};
struct block_descrip_struct {
enum Side side;
DWORD size;
DWORD start;
enum ExpectErrs expecterrs;
};
struct block_descrip_struct muthaBlock[] =
{
// Side Size(bytes) Start(byte addr) Expect Errors?
{ PCI, 64, 0x0000, MUSTpass }, // 0x0
{ Local, 64, 0x0040, MUSTpass }, // 0x1
{ PCI, 64, 0x0080, ERRORSok }, // 0x2
{ Local, 60, 0x00c0, MUSTpass }, // 0x3
{ Unused, 4, 0x00fc, MUSTpass }, // 0x4
{ PCI, 60, 0x0100, MUSTpass }, // 0x5
{ Unused, 4, 0x013c, MUSTpass }, // 0x6
{ Local, 60, 0x0140, MUSTpass }, // 0x7
{ Unused, 4, 0x017c, MUSTpass }, // 0x8
{ PCI, 4, 0x0180, MUSTpass }, // 0x9
{ Unused, 52, 0x0184, MUSTpass }, // 0xa
{ Local, 4, 0x01b8, MUSTpass }, // 0xb
{ Unused, 4, 0x01bc, MUSTpass }, // 0xc
{ PCI, 4, 0x01c0, MUSTpass }, // 0xd
{ Unused, 52, 0x01c4, MUSTpass }, // 0xe
{ Local, 4, 0x01f8, MUSTpass }, // 0xf
{ Unused, 4, 0x01fc, MUSTpass }, // 0x10
{ PCI, 4, 0x0200, MUSTpass }, // 0x11
{ Unused, 508, 0x0204, MUSTpass }, // 0x12
{ Local, 1028, 0x0400, MUSTpass }, // 0x13
{ Unused, 892, 0x0804, MUSTpass }, // 0x14
{ PCI, 128, 0x0b80, MUSTpass }, // 0x15
// { Unused, 0, 0xxxxx, MUSTpass },
{ Local, 60, 0x0c00, MUSTpass }, // 0x16
{ Unused, 4, 0x0c3c, MUSTpass }, // 0x17
{ PCI, 60, 0x0c40, MUSTpass }, // 0x18
{ Unused, 4, 0x0c7c, MUSTpass }, // 0x19
{ Local, 60, 0x0c80, MUSTpass }, // 0x1a
{ Unused, 4, 0x0cbc, MUSTpass }, // 0x1b
{ PCI, 4, 0x0cc0, MUSTpass }, // 0x1c
{ Unused, 1204, 0x0cc4, MUSTpass }, // 0x1d
{ Local, 4, 0x1178, MUSTpass }, // 0x1e
{ Unused, 4, 0x117c, MUSTpass }, // 0x1f
{ PCI, 4, 0x1180, MUSTpass }, // 0x20
{ Unused, 52, 0x1184, MUSTpass }, // 0x21
{ Local, 4, 0x11b8, MUSTpass }, // 0x22
{ Unused, 4, 0x11bc, MUSTpass }, // 0x23
{ PCI, 4, 0x11c0, MUSTpass }, // 0x24
{ Unused, 188, 0x11c4, MUSTpass }, // 0x25
{ Local, 124, 0x1280, MUSTpass }, // 0x26
{ Unused, 4, 0x12fc, MUSTpass },
{ PCI, 124, 0x1300, MUSTpass },
{ Unused, 4, 0x137c, MUSTpass },
{ Local, 124, 0x1380, MUSTpass },
{ Unused, 4, 0x13fc, MUSTpass },
{ PCI, 1028, 0x1400, MUSTpass },
{ Unused, 892, 0x1804, MUSTpass },
{ Local, 128, 0x1b80, MUSTpass },
{ Unused, 56, 0x1c00, MUSTpass },
{ PCI, 4, 0x1c38, MUSTpass },
{ Unused, 4, 0x1c3c, MUSTpass },
{ Local, 4, 0x1c40, MUSTpass },
{ Unused, 52, 0x1c44, MUSTpass },
{ PCI, 4, 0x1c78, MUSTpass },
{ Unused, 4, 0x1c7c, MUSTpass },
{ Local, 4, 0x1c80, MUSTpass },
{ Unused, 700, 0x1c84, MUSTpass },
{ PCI, 64, 0x1f40, MUSTpass },
{ Local, 64, 0x1f80, MUSTpass },
{ PCI, 64, 0x1fc0, ERRORSok },
// The second half of the Shared Mem...
// Side Size(bytes) Start(byte addr) Expect Errors?
{ Local, 64, 0x2000, MUSTpass },
{ PCI, 64, 0x2040, ERRORSok },
{ Local, 60, 0x2080, MUSTpass },
{ Unused, 4, 0x20bc, MUSTpass },
{ PCI, 60, 0x20c0, MUSTpass },
{ Unused, 4, 0x20fc, MUSTpass },
{ Local, 60, 0x2100, MUSTpass },
{ Unused, 4, 0x213c, MUSTpass },
{ PCI, 60, 0x2140, MUSTpass },
{ Unused, 4, 0x217c, MUSTpass },
{ Local, 4, 0x2180, MUSTpass },
{ Unused, 52, 0x2184, MUSTpass },
{ PCI, 4, 0x21b8, MUSTpass },
{ Unused, 4, 0x21bc, MUSTpass },
{ Local, 4, 0x21c0, MUSTpass },
{ Unused, 52, 0x21c4, MUSTpass },
{ PCI, 4, 0x21f8, MUSTpass },
{ Unused, 4, 0x21fc, MUSTpass },
{ Local, 4, 0x2200, MUSTpass },
{ Unused, 508, 0x2204, MUSTpass },
{ PCI, 1028, 0x2400, MUSTpass },
{ Unused, 892, 0x2804, MUSTpass },
{ Local, 124, 0x2b80, MUSTpass },
{ Unused, 4, 0x2bfc, MUSTpass },
{ PCI, 60, 0x2c00, MUSTpass },
{ Unused, 4, 0x2c3c, MUSTpass },
{ Local, 60, 0x2c40, MUSTpass },
{ Unused, 4, 0x2c7c, MUSTpass },
{ PCI, 60, 0x2c80, MUSTpass },
{ Unused, 4, 0x2cbc, MUSTpass },
{ Local, 4, 0x2cc0, MUSTpass },
{ Unused, 1204, 0x2cc4, MUSTpass },
{ PCI, 4, 0x3178, MUSTpass },
{ Unused, 4, 0x317c, MUSTpass },
{ Local, 4, 0x3180, MUSTpass },
{ Unused, 52, 0x3184, MUSTpass },
{ PCI, 4, 0x31b8, MUSTpass },
{ Unused, 4, 0x31bc, MUSTpass },
{ Local, 4, 0x31c0, MUSTpass },
{ Unused, 188, 0x31c4, MUSTpass },
{ PCI, 124, 0x3280, MUSTpass },
{ Unused, 4, 0x32fc, MUSTpass },
{ Local, 124, 0x3300, MUSTpass },
{ Unused, 4, 0x337c, MUSTpass },
{ PCI, 124, 0x3380, MUSTpass },
{ Unused, 4, 0x33fc, MUSTpass },
{ Local, 1028, 0x3400, MUSTpass },
{ Unused, 892, 0x3804, MUSTpass },
{ PCI, 128, 0x3b80, MUSTpass },
{ Unused, 56, 0x3c00, MUSTpass },
{ Local, 4, 0x3c38, MUSTpass },
{ Unused, 4, 0x3c3c, MUSTpass },
{ PCI, 4, 0x3c40, MUSTpass },
{ Unused, 52, 0x3c44, MUSTpass },
{ Local, 4, 0x3c78, MUSTpass },
{ Unused, 4, 0x3c7c, MUSTpass },
{ PCI, 4, 0x3c80, MUSTpass },
{ Unused, 700, 0x3c84, MUSTpass },
{ Local, 64, 0x3f40, MUSTpass },
{ PCI, 64, 0x3f80, ERRORSok },
{ Local, 64, 0x3fc0, MUSTpass },
};
DWORD NUMtestBLOCKS = sizeof(muthaBlock)/sizeof(muthaBlock[0]) ;
// Patterns
#define LOCALduringTEST 0xA55A0000
#define PCIduringTEST 0x96690000
#define UNUSEDblockFROMlocal 0x3CC30000
#define UNUSEDblockFROMhost 0x12340000
// End 3042 Defines and Structures
// ********************************************************
const int CHIP3041 = 0x3041;
const int CHIP3042 = 0x3042;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -