Example #1
0
		private static byte ToValue (DMATransferType transfertype)
		{
			switch (transfertype) {
				case DMATransferType.OnDemand: return DMATransferTypeValue.OnDemand;
				case DMATransferType.Block: return DMATransferTypeValue.Block;
				case DMATransferType.Single: return DMATransferTypeValue.Single;
				case DMATransferType.CascadeMode: return DMATransferTypeValue.CascadeMode;
				default: return 0;
			}
		}
Example #2
0
        private static byte ToValue(DMATransferType transfertype)
        {
            switch (transfertype)
            {
            case DMATransferType.OnDemand: return(DMATransferTypeValue.OnDemand);

            case DMATransferType.Block: return(DMATransferTypeValue.Block);

            case DMATransferType.Single: return(DMATransferTypeValue.Single);

            case DMATransferType.CascadeMode: return(DMATransferTypeValue.CascadeMode);

            default: return(0);
            }
        }
Example #3
0
        /// <summary>
        /// Setups the channel.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="count">The count.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="type">The type.</param>
        /// <param name="auto">if set to <c>true</c> [auto].</param>
        /// <returns></returns>
        public bool SetupChannel(byte channel, uint count, DMAMode mode, DMATransferType type, bool auto)
        {
            IWriteOnlyIOPort dmaAddress;
            IWriteOnlyIOPort dmaCount;
            IWriteOnlyIOPort dmaPage;
            IMemory memory;

            switch (channel) {
                case 0: dmaAddress = channel0Address; dmaCount = channel0Count; dmaPage = channel0Page; memory = memory0; break;
                case 1: dmaAddress = channel1Address; dmaCount = channel1Count; dmaPage = channel1Page; memory = memory1; break;
                case 2: dmaAddress = channel2Address; dmaCount = channel2Count; dmaPage = channel2Page; memory = memory2; break;
                case 3: dmaAddress = channel3Address; dmaCount = channel3Count; dmaPage = channel3Page; memory = memory3; break;
                default: return false;
            }

            uint address = memory.Address;

            // Disable DMA Controller
            channelMaskRegister.Write8((byte)((byte)channel | 4));

            // Clear any current transfers
            byteWordRegister.Write8((byte)0xFF);	// reset flip-flop

            // Set Address
            dmaAddress.Write8((byte)(address & 0xFF)); // low byte
            dmaAddress.Write8((byte)((address >> 8) & 0xFF)); // high byte
            dmaPage.Write8((byte)((address >> 16) & 0xFF)); // page

            // Clear any current transfers
            byteWordRegister.Write8((byte)0xFF);	// reset flip-flop

            // Set Count
            dmaCount.Write8((byte)((count - 1) & 0xFF)); // low
            dmaCount.Write8((byte)(((count - 1) >> 8) & 0xFF)); // high

            byte value = channel;

            if (auto)
                value = (byte)(value | DMAAutoValue.Auto);
            else
                value = (byte)(value | DMAAutoValue.NoAuto);

            if (mode == DMAMode.ReadFromMemory)
                value = (byte)(value | DMAModeValue.ReadFromMemory);
            else
                value = (byte)(value | DMAModeValue.WriteToMemory);

            switch (type) {
                case DMATransferType.Block: value = (byte)(value | DMATransferTypeValue.Block); break;
                case DMATransferType.CascadeMode: value = (byte)(value | DMATransferTypeValue.CascadeMode); break;
                case DMATransferType.OnDemand: value = (byte)(value | DMATransferTypeValue.OnDemand); break;
                case DMATransferType.Single: value = (byte)(value | DMATransferTypeValue.Single); break;
                default: break;
            }

            // Set DMA Channel to write
            modeRegister.Write8(value);

            // Enable DMA Controller
            channelMaskRegister.Write8((byte)(channel));

            return true;
        }
Example #4
0
		public void SetupChannel (DMAMode mode, DMATransferType type, bool auto, uint count)
		{
			DMA.SetupChannel (channel, count, mode, type, auto);
		}
Example #5
0
        /// <summary>
        /// Setups the channel.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="count">The count.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="type">The type.</param>
        /// <param name="auto">if set to <c>true</c> [auto].</param>
        /// <returns></returns>
        public bool SetupChannel(byte channel, uint count, DMAMode mode, DMATransferType type, bool auto)
        {
            IWriteOnlyIOPort dmaAddress;
            IWriteOnlyIOPort dmaCount;
            IWriteOnlyIOPort dmaPage;
            IMemory          memory;

            switch (channel)
            {
            case 0: dmaAddress = channel0Address; dmaCount = channel0Count; dmaPage = channel0Page; memory = memory0; break;

            case 1: dmaAddress = channel1Address; dmaCount = channel1Count; dmaPage = channel1Page; memory = memory1; break;

            case 2: dmaAddress = channel2Address; dmaCount = channel2Count; dmaPage = channel2Page; memory = memory2; break;

            case 3: dmaAddress = channel3Address; dmaCount = channel3Count; dmaPage = channel3Page; memory = memory3; break;

            default: return(false);
            }

            uint address = memory.Address;

            // Disable DMA Controller
            channelMaskRegister.Write8((byte)((byte)channel | 4));

            // Clear any current transfers
            byteWordRegister.Write8((byte)0xFF);                // reset flip-flop

            // Set Address
            dmaAddress.Write8((byte)(address & 0xFF));             // low byte
            dmaAddress.Write8((byte)((address >> 8) & 0xFF));      // high byte
            dmaPage.Write8((byte)((address >> 16) & 0xFF));        // page

            // Clear any current transfers
            byteWordRegister.Write8((byte)0xFF);                // reset flip-flop

            // Set Count
            dmaCount.Write8((byte)((count - 1) & 0xFF));             // low
            dmaCount.Write8((byte)(((count - 1) >> 8) & 0xFF));      // high

            byte value = channel;

            if (auto)
            {
                value = (byte)(value | DMAAutoValue.Auto);
            }
            else
            {
                value = (byte)(value | DMAAutoValue.NoAuto);
            }

            if (mode == DMAMode.ReadFromMemory)
            {
                value = (byte)(value | DMAModeValue.ReadFromMemory);
            }
            else
            {
                value = (byte)(value | DMAModeValue.WriteToMemory);
            }

            switch (type)
            {
            case DMATransferType.Block: value = (byte)(value | DMATransferTypeValue.Block); break;

            case DMATransferType.CascadeMode: value = (byte)(value | DMATransferTypeValue.CascadeMode); break;

            case DMATransferType.OnDemand: value = (byte)(value | DMATransferTypeValue.OnDemand); break;

            case DMATransferType.Single: value = (byte)(value | DMATransferTypeValue.Single); break;

            default: break;
            }

            // Set DMA Channel to write
            modeRegister.Write8(value);

            // Enable DMA Controller
            channelMaskRegister.Write8((byte)(channel));

            return(true);
        }
Example #6
0
		public static unsafe bool SetupChannel (byte channel, uint count, DMAMode mode, DMATransferType type, bool auto)
		{
			IO.Port dma_page;
			IO.Port dma_address;
			IO.Port dma_count;

			if (count > (1024 * 64))
				return false;

			switch (channel) {
				case 1:
					dma_page = IO.Port.DMA_Channel1Page;
					dma_address = IO.Port.DMA_Channel1Address;
					dma_count = IO.Port.DMA_Channel1Count;
					break;
				case 2:
					dma_page = IO.Port.DMA_Channel2Page;
					dma_address = IO.Port.DMA_Channel2Address;
					dma_count = IO.Port.DMA_Channel2Count;
					break;
				case 3:
					dma_page = IO.Port.DMA_Channel3Page;
					dma_address = IO.Port.DMA_Channel3Address;
					dma_count = IO.Port.DMA_Channel3Count;
					break;
				default:
					// TODO: throw an exception when we have exception support
					return false;
			}

			uint address = (uint)GetDMATranserAddress (channel);

			Barrier.Enter ();
			// Disable DMA Controller
			IO.WriteByte (IO.Port.DMA_ChannelMaskRegister, (byte)((byte)channel | 4));

			// Clear any current transfers
			IO.WriteByte (IO.Port.DMA_ClearBytePointerFlipFlop, (byte)0xFF);	// reset flip-flop

			// Set Address	
			IO.WriteByte (dma_address, (byte)(address & 0xFF)); // low byte
			IO.WriteByte (dma_address, (byte)((address >> 8) & 0xFF)); // high byte
			IO.WriteByte (dma_page, (byte)((address >> 16) & 0xFF)); // page

			// Clear any current transfers
			IO.WriteByte (IO.Port.DMA_ClearBytePointerFlipFlop, (byte)0xFF);	// reset flip-flop

			// Set Count
			IO.WriteByte (dma_count, (byte)((count - 1) & 0xFF)); // low
			IO.WriteByte (dma_count, (byte)(((count - 1) >> 8) & 0xFF)); // high

			byte value = (byte)(channel | (auto ? DMAAutoValue.Auto : DMAAutoValue.NoAuto) | ToValue (type));
			value = (byte)(value | (mode == DMAMode.ReadFromMemory ? DMAModeValue.ReadFromMemory : DMAModeValue.WriteToMemory));

			// Set DMA_Channel to write
			IO.WriteByte (IO.Port.DMA_ModeRegister, value);

			// Enable DMA Controller
			IO.WriteByte (IO.Port.DMA_ChannelMaskRegister, (byte)(channel));

			Barrier.Exit ();

			return true;
		}
Example #7
0
 public void SetupChannel(DMAMode mode, DMATransferType type, bool auto, uint count)
 {
     DMA.SetupChannel(channel, count, mode, type, auto);
 }
Example #8
0
        public static unsafe bool SetupChannel(byte channel, uint count, DMAMode mode, DMATransferType type, bool auto)
        {
            IO.Port dma_page;
            IO.Port dma_address;
            IO.Port dma_count;

            if (count > (1024 * 64))
            {
                return(false);
            }

            switch (channel)
            {
            case 1:
                dma_page    = IO.Port.DMA_Channel1Page;
                dma_address = IO.Port.DMA_Channel1Address;
                dma_count   = IO.Port.DMA_Channel1Count;
                break;

            case 2:
                dma_page    = IO.Port.DMA_Channel2Page;
                dma_address = IO.Port.DMA_Channel2Address;
                dma_count   = IO.Port.DMA_Channel2Count;
                break;

            case 3:
                dma_page    = IO.Port.DMA_Channel3Page;
                dma_address = IO.Port.DMA_Channel3Address;
                dma_count   = IO.Port.DMA_Channel3Count;
                break;

            default:
                // TODO: throw an exception when we have exception support
                return(false);
            }

            uint address = (uint)GetDMATranserAddress(channel);

            Barrier.Enter();
            // Disable DMA Controller
            IO.WriteByte(IO.Port.DMA_ChannelMaskRegister, (byte)((byte)channel | 4));

            // Clear any current transfers
            IO.WriteByte(IO.Port.DMA_ClearBytePointerFlipFlop, (byte)0xFF);                     // reset flip-flop

            // Set Address
            IO.WriteByte(dma_address, (byte)(address & 0xFF));              // low byte
            IO.WriteByte(dma_address, (byte)((address >> 8) & 0xFF));       // high byte
            IO.WriteByte(dma_page, (byte)((address >> 16) & 0xFF));         // page

            // Clear any current transfers
            IO.WriteByte(IO.Port.DMA_ClearBytePointerFlipFlop, (byte)0xFF);                     // reset flip-flop

            // Set Count
            IO.WriteByte(dma_count, (byte)((count - 1) & 0xFF));              // low
            IO.WriteByte(dma_count, (byte)(((count - 1) >> 8) & 0xFF));       // high

            byte value = (byte)(channel | (auto ? DMAAutoValue.Auto : DMAAutoValue.NoAuto) | ToValue(type));

            value = (byte)(value | (mode == DMAMode.ReadFromMemory ? DMAModeValue.ReadFromMemory : DMAModeValue.WriteToMemory));

            // Set DMA_Channel to write
            IO.WriteByte(IO.Port.DMA_ModeRegister, value);

            // Enable DMA Controller
            IO.WriteByte(IO.Port.DMA_ChannelMaskRegister, (byte)(channel));

            Barrier.Exit();

            return(true);
        }