diff --git a/src/sys/include/ubixos/dma.h b/src/sys/include/ubixos/dma.h index 0caac6f..e3f6ba5 100755 --- a/src/sys/include/ubixos/dma.h +++ b/src/sys/include/ubixos/dma.h @@ -1,8 +1,12 @@ /************************************************************************************** - Copyright (c) 2002 - The UbixOS Project + Copyright (c) 2002 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are prohibited. $Id$ + **************************************************************************************/ #ifndef _DMA_H @@ -10,6 +14,7 @@ #include -int dmaXfer(uChar channel,uLong address,uInt length,uChar read); +void dmaXfer(uChar channel,uLong address,uInt length,uChar read); +void _dmaXfer(uChar dmaChannel,uChar page,uInt offset,uInt length,uChar mode); #endif \ No newline at end of file diff --git a/src/sys/kernel/dma.c b/src/sys/kernel/dma.c index 58a9de9..8288c0e 100755 --- a/src/sys/kernel/dma.c +++ b/src/sys/kernel/dma.c @@ -1,11 +1,54 @@ /************************************************************************************** - Copyright (c) 2002 - The UbixOS Project + Copyright (c) 2002 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are prohibited. $Id$ + **************************************************************************************/ #include +#include +#include -int dmaXfer(uChar channel,uLong address,uInt length,uChar read) { +#define lowByte(x) (x & 0x00FF) +#define highByte(x) ((x & 0xFF00) >> 8) + +uChar maskReg[8] = { 0x0A, 0x0A, 0x0A, 0x0A, 0xD4, 0xD4, 0xD4, 0xD4 }; +uChar clearReg[8] = { 0x0C, 0x0C, 0x0C, 0x0C, 0xD8, 0xD8, 0xD8, 0xD8 }; +uChar modeReg[8] = { 0x0B, 0x0B, 0x0B, 0x0B, 0xD6, 0xD6, 0xD6, 0xD6 }; +uChar addrPort[8] = { 0x00, 0x02, 0x04, 0x06, 0xC0, 0xC4, 0xC8, 0xCC }; +uChar pagePort[8] = { 0x87, 0x83, 0x81, 0x82, 0x8F, 0x8B, 0x89, 0x8A }; +uChar countPort[8] = { 0x01, 0x03, 0x05, 0x07, 0xC2, 0xC6, 0xCA, 0xCE }; + +void dmaXfer(uChar channel,uLong address,uInt length,uChar read) { + unsigned char page=0, mode=0; + unsigned int offset = 0; + if (read) { + mode = 0x48 + channel; + } + else { + mode = 0x44 + channel; + } + page = address >> 16; + offset = address & 0xFFFF; + length--; + _dmaXfer(channel, page, offset, length, mode); } + +void _dmaXfer(uChar dmaChannel,uChar page,uInt offset,uInt length,uChar mode) { + asm("cli"); + outportByte(maskReg[dmaChannel], 0x04 | dmaChannel); + outportByte(clearReg[dmaChannel], 0x00); + outportByte(modeReg[dmaChannel], mode); + outportByte(addrPort[dmaChannel], lowByte(offset)); + outportByte(addrPort[dmaChannel], highByte(offset)); + outportByte(pagePort[dmaChannel], page); + outportByte(countPort[dmaChannel], lowByte(length)); + outportByte(countPort[dmaChannel], highByte(length)); + outportByte(maskReg[dmaChannel], dmaChannel); + asm("sti"); + + } \ No newline at end of file