vendor.c

来自「AMD公司官方版FLASH文件系统。有详细说明文档和Windows仿真测试环境。」· C语言 代码 · 共 82 行

C
82
字号
/**
 *    ven.c
 */

#include <windows.h>
#include <conio.h>
#include "Vendor.h"
#include "FlashCard/FlashDll.h"

int dms_lVendorSetupBasePointer(void);
static WORD *lpFlashBasePointer = NULL;

/*
 *  dms_VendorMapChip
 *
 * This function translates the address into the
 * starting address of the flash chip.
 */
void *dms_VendorMapChip(DWORD dwAddress)
{
  /*
   * The flash card only supports one flash chip.
   */
  return dms_VendorMapPage(0);
}

/**
 *  dms_VendorMapPage
 *
 *  DESCRIPTION
 *  This function maps region on the DL-Demo board into
 *  DRAM and returns a pointer to that region. 
 */
void *dms_VendorMapPage(DWORD dwAddress)
{
  if(lpFlashBasePointer == NULL && !dms_lVendorSetupBasePointer()){
      return NULL;
  }
  return (void*) (((BYTE*)lpFlashBasePointer) + dwAddress);
}

int dms_lVendorSetupBasePointer(void)
{
  int iErrorCode;  
  char buffer[200];
  if(lpFlashBasePointer == NULL) 
  {
    iErrorCode = InitPCIDataSpace();
    if (iErrorCode != 0){
      FormatMessage( 
          FORMAT_MESSAGE_FROM_SYSTEM,
          NULL,
          iErrorCode % 1000,
          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
          buffer,
          200,
          NULL 
      );
      return 0;
    }
    SetWordMode();
    iErrorCode = GetDeviceID(0);
    if (iErrorCode < 0){
      return 0;
    }
    lpFlashBasePointer =  GetBaseFlashWordPointer();    
  }
  return 1;
}

/**
 *  dms_VendorFinalize
 */
void dms_VendorFinalize(void)
{
  if (lpFlashBasePointer == NULL){
    FreePCIDataSpace();
    lpFlashBasePointer = NULL;
  }
}

⌨️ 快捷键说明

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