00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <sys/dma.h>
00031 #include <sys/io.h>
00032 #include <ubixos/types.h>
00033
00034 #define lowByte(x) (x & 0x00FF)
00035 #define highByte(x) ((x & 0xFF00) >> 8)
00036
00037 static uInt8 maskReg[8] = { 0x0A, 0x0A, 0x0A, 0x0A, 0xD4, 0xD4, 0xD4, 0xD4 };
00038 static uInt8 clearReg[8] = { 0x0C, 0x0C, 0x0C, 0x0C, 0xD8, 0xD8, 0xD8, 0xD8 };
00039 static uInt8 modeReg[8] = { 0x0B, 0x0B, 0x0B, 0x0B, 0xD6, 0xD6, 0xD6, 0xD6 };
00040 static uInt8 addrPort[8] = { 0x00, 0x02, 0x04, 0x06, 0xC0, 0xC4, 0xC8, 0xCC };
00041 static uInt8 pagePort[8] = { 0x87, 0x83, 0x81, 0x82, 0x8F, 0x8B, 0x89, 0x8A };
00042 static uInt8 countPort[8] = { 0x01, 0x03, 0x05, 0x07, 0xC2, 0xC6, 0xCA, 0xCE };
00043
00044 void dmaXfer(uInt8 channel,uInt32 address,uInt length,uInt8 read) {
00045 unsigned char page=0, mode=0;
00046 unsigned int offset = 0;
00047 if (read) {
00048 mode = 0x48 + channel;
00049 }
00050 else {
00051 mode = 0x44 + channel;
00052 }
00053 page = address >> 16;
00054 offset = address & 0xFFFF;
00055 length--;
00056 _dmaXfer(channel, page, offset, length, mode);
00057 }
00058
00059 void _dmaXfer(uInt8 dmaChannel,uInt8 page,uInt offset,uInt length,uInt8 mode) {
00060
00061 outportByte(maskReg[dmaChannel], 0x04 | dmaChannel);
00062 outportByte(clearReg[dmaChannel], 0x00);
00063 outportByte(modeReg[dmaChannel], mode);
00064 outportByte(addrPort[dmaChannel], lowByte(offset));
00065 outportByte(addrPort[dmaChannel], highByte(offset));
00066 outportByte(pagePort[dmaChannel], page);
00067 outportByte(countPort[dmaChannel], lowByte(length));
00068 outportByte(countPort[dmaChannel], highByte(length));
00069 outportByte(maskReg[dmaChannel], dmaChannel);
00070
00071 }
00072
00073
00074
00075