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

📄 xds510_io.cpp

📁 dsp 仿真器制作 希望对想研究jtag仿真器的朋友有帮助
💻 CPP
字号:
/*
 * xds510 simulator for Wine
 * Copyright (c) 2001 Blaise Gassend (blaise.gassend@m4x.org)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version. This program is
 * distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details. You should have received a
 * copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 * USA.
 * */

#include <stdio.h>
#ifndef _WINDOWS
#include <sys/io.h>
#else
int iopl( int n)
{
	return 0;
}
int inb( unsigned short port)
{
	unsigned short retval;
	__asm {
		mov dx,port
		in ax,dx
		mov retval,ax
	}
	
	return retval;
}
int outb( unsigned short val, unsigned short port)
{
	__asm {
		mov dx,port
		mov ax,val
		out dx,ax
	}

	return val;
}
#endif
#include "xds510_io.h"

#define READ_TDO !(inb(baseport + 1) & 0x80)
#define SET_EMU outb(inb(baseport + 2) & ~0x38, baseport + 2)
#define CLEAR_EMU outb((inb(baseport + 2) | 8) & ~0x30, baseport + 2)
#define SET_TRST outb(inb(baseport + 2) & ~0x31, baseport + 2)
#define CLEAR_TRST outb((inb(baseport + 2) | 1) & ~0x30, baseport + 2)
#define TDI 2
#define TCK 1
#define TMS 4

static int baseport = -1;

int xds510_io_init(int bp)
{
  int io_error = -1;

  if (!iopl(3))
  {
    io_error = 0;
    baseport = bp;
    iopl(0);
  }
  return io_error;
}

static void io_write(char outval)
{
  outb(outval, baseport);
}

static int io_write_cycle(char outval)
{
  int inval = 0;
  if (!iopl(3))
  {
    io_write(outval);
    io_write(outval | TCK);
    inval = READ_TDO;
//  io_write(outval);
    iopl(0);
  }
  return inval;
}

int xds510_io_write_cycle(int tdi, int tms)
{
  int retval = io_write_cycle((tdi ? TDI : 0) | (tms ? TMS : 0));
  return retval;
}

void xds510_io_write_emu(int emu)
{
  if (!iopl(3))
  {
    if (emu)
    {
      SET_EMU;
//    outb(baseport + 2, 0);
//      printf("set\n");
    }
    else
    {
      CLEAR_EMU;
//    outb(baseport + 2, 255);
//      printf("clear\n");
    }
//    printf("Printer output : %02x\n", inb(baseport+2));
    iopl(0);
  }
}

void xds510_io_write_trst(int trst)
{
  if (!iopl(3))
  {
//    printf("trst\n");
    if (trst)
    {
      SET_TRST;
    }
    else
    {
      CLEAR_TRST;
    }
//    printf("Printer output : %02x\n", inb(baseport+2));
    iopl(0);
  }
}

⌨️ 快捷键说明

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