📄 isa_dma.c
字号:
/*
//*************************************************************************
//
// P H I L I P S P R O P R I E T A R Y
//
// COPYRIGHT (c) 2000 BY PHILIPS SINGAPORE.
// -- ALL RIGHTS RESERVED --
//
// Project: ISP1581 EVA board
// File Name: ISA_DMA.C
// Author: Qian Jiang
// Created: Sept. 1, 2000
// Modified:
// Revision: 0.0
//
//
// This file contents the configuration of DMA controller, which locates on
// PC side;
//
//*************************************************************************
*/
#include <stdio.h>
#include <bios.h>
#include <dos.h>
#include <mem.h>
#include "chap_9.h"
#include "BasicTyp.h"
#include "common.h"
#include "ISP1581.H"
#include "mainloop.h"
#include "verify.h"
#define DMA37MD_SINGLE 0x40 /* single pass mode */
#define DMA37MD_BLOCK 0x80 /* single pass mode */
#define DMA37MD_AUTO 0x10 /* autoinitialise single pass mode */
#define DMA37MD_DEMAND 0x00 /* demand mode */
#define DMA37MD_WRITE 0x04 /* read the device, write memory operation */
#define DMA37MD_READ 0x08 /* write the device, read memory operation */
/*
** Register definitions for DMA controller 1 (channels 0..3):
*/
#define DMA1_CHN(c) (2*(c)) /* addr reg for channel c */
#define DMA1_CMD (8) /* command register */
#define DMA1_SMSK (10) /* single mask register */
//#define DMA1_MODE (11) /* mode register */
#define DMA1_MODE (0xd6) /* mode register */
#define DMA1_FFC (12) /* clear first/last FF */
extern ISP1581FLAGS bISP1581flags;
extern unsigned long dmaBuffer;
extern IO_REQUEST idata ioRequest;
extern GLOBE_VARIABLE globe_variable;
void dma_start(PIO_REQUEST pio)
{
// static short pageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a };
unsigned short dmaport, l;
unsigned long offset, buf_phy_addr;
unsigned char i, ch;
outportb(DMA1_CMD, 0x0); // clear DMA first
offset = (((unsigned long)pio->bAddressH)<<16)
+ pio->uAddressL;
buf_phy_addr = dmaBuffer + offset;
ch = 0x03; // for channel 7 or 3, depends on mode register address;
//DMA ch7 if ((ch & 4) == 0) {
// Disable DMA before configurate it
// outportb(DMA1_CMD, 0x04);
outportb(0xde,0x08);
inportb(0xd0);
if (globe_variable.xfer_dir)
{
#ifdef dma_on_local
#ifdef debug
// cprintf(" dma_on_local program_ISA ");
#endif
outportb(DMA1_MODE, DMA37MD_DEMAND|DMA37MD_WRITE|ch);
#else
#ifdef debug
cprintf(" dma_on_isa ");
#endif
outportb(DMA1_MODE, DMA37MD_DEMAND|DMA37MD_READ|ch);
// outportb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_READ|ch);
#endif
}
else
{
outportb(DMA1_MODE, DMA37MD_DEMAND|DMA37MD_WRITE|ch);
// outportb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|ch);
}
// outportb(DMA1_FFC, 0);
/* send start address */
// dmaport = DMA1_CHN(ch);
// outportb(dmaport, buf_phy_addr);
// outportb(dmaport, buf_phy_addr>>8);
// outportb(pageport[ch], buf_phy_addr>>16);
outportb(0xd8, 0x00);
outportb(0xcc, buf_phy_addr>>1);
outportb(0xcc, buf_phy_addr>>9);
outportb(0x8a, buf_phy_addr>>16);
/* send count */
// outportb(DMA1_FFC, 0);
// outportb(dmaport + 1, --nbytes);
// outportb(dmaport + 1, nbytes>>8);
outportb(0xce, (unsigned char)globe_variable.isa_dma_counterset);
outportb(0xce, (unsigned char)(globe_variable.isa_dma_counterset>>8));
// outportb(DMA1_CMD, 0x0);
/* unmask channel */
// outportb(DMA1_SMSK, ch);
outportb(0xd4, 0x03);
// }
//Print counter value
// l = dma_getcount(3);
#ifdef debug
// cprintf("DMA count from %lx \r\n", l);
#endif
// i = inportb(DMA1_CMD);
}
int dma_getcount(int ch)
{
unsigned short dmaport;
unsigned short highbyte, lowbyte;
dmaport = DMA1_CHN(ch);
outportb(DMA1_FFC, 0);
lowbyte = inportb(dmaport + 1);
highbyte = inportb(dmaport + 1);
highbyte <<= 8;
highbyte += lowbyte;
return highbyte;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -