mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-08 17:22:28 +00:00
This commit is contained in:
parent
d7158849ef
commit
675a6d6a74
3 changed files with 82 additions and 58 deletions
|
|
@ -3,32 +3,27 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Cosmos.Hardware;
|
using Cosmos.Hardware;
|
||||||
|
using Cosmos.Hardware.Audio.Devices.ES1370.Register;
|
||||||
namespace Cosmos.Hardware.Audio.Devices.ES1370
|
namespace Cosmos.Hardware.Audio.Devices.ES1370
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Driver for the soundcard Ensoniq 1370 AudioPCI (testing for QEMU audio emulation)
|
/// Driver for the soundcard Ensoniq 1370 AudioPCI (testing for QEMU audio emulation)
|
||||||
/// It should work also in Ensoniq 1371 all revision.
|
/// It should work also in Ensoniq 1371 all revision.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ENS1370
|
public class ES1370
|
||||||
{
|
{
|
||||||
#region Construction
|
#region Construction
|
||||||
|
|
||||||
private PCIDevice pciCard;
|
private PCIDevice pciCard;
|
||||||
private Cosmos.Kernel.MemoryAddressSpace mem;
|
private Cosmos.Kernel.MemoryAddressSpace mem;
|
||||||
//private Register.ValueTypeRegisters valueReg;
|
|
||||||
//private Register.InterruptMaskRegister imr;
|
|
||||||
//private Register.InterruptStatusRegister isr;
|
|
||||||
|
|
||||||
public ENS1370(PCIDevice device)
|
public ES1370(PCIDevice device)
|
||||||
{
|
{
|
||||||
if (device == null)
|
if (device == null)
|
||||||
throw new ArgumentException("PCI Device is null. Unable to get ENS1370 card");
|
throw new ArgumentException("PCI Device is null. Unable to get ES1370 card");
|
||||||
|
|
||||||
pciCard = device;
|
pciCard = device;
|
||||||
mem = device.GetAddressSpace(1) as Cosmos.Kernel.MemoryAddressSpace;
|
mem = device.GetAddressSpace(1) as Cosmos.Kernel.MemoryAddressSpace;
|
||||||
//valueReg = Register.ValueTypeRegisters.Load(mem);
|
|
||||||
//imr = Register.InterruptMaskRegister.Load(mem);
|
|
||||||
//isr = Register.InterruptStatusRegister.Load(mem);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -36,15 +31,15 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370
|
||||||
/// Retrieve all Ensoniq AudioPCI 1370 cards found on computer.
|
/// Retrieve all Ensoniq AudioPCI 1370 cards found on computer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static List<ENS1370> FindAll()
|
public static List<ES1370> FindAll()
|
||||||
{
|
{
|
||||||
List<ENS1370> found = new List<ENS1370>();
|
List<ES1370> found = new List<ES1370>();
|
||||||
|
|
||||||
foreach (PCIDevice device in Cosmos.Hardware.PCIBus.Devices)
|
foreach (PCIDevice device in Cosmos.Hardware.PCIBus.Devices)
|
||||||
{
|
{
|
||||||
Console.WriteLine("VendorID: " + device.VendorID + " - DeviceID: " + device.DeviceID);
|
Console.WriteLine("VendorID: " + device.VendorID + " - DeviceID: " + device.DeviceID);
|
||||||
if (device.VendorID == 0x10EC && device.DeviceID == 0x8139)
|
if (device.VendorID == 0x10EC && device.DeviceID == 0x8139)
|
||||||
found.Add(new ENS1370(device));
|
found.Add(new ES1370(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
|
|
@ -52,34 +47,31 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370
|
||||||
#region Power and Initilization
|
#region Power and Initilization
|
||||||
public void InitializeDriver()
|
public void InitializeDriver()
|
||||||
{
|
{
|
||||||
|
//Enable IRQ Interrupt
|
||||||
|
InitIRQMaskRegister();
|
||||||
|
Cosmos.Hardware.Interrupts.IRQ05 = new Cosmos.Hardware.Interrupts.InterruptDelegate(this.HandleNetworkInterrupt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Enable()
|
public bool Enable()
|
||||||
{
|
{
|
||||||
return true;
|
var control = ControlRegister.Load(mem);
|
||||||
|
control.PowerEnabled=true;
|
||||||
|
return control.PowerEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Disable()
|
public bool Disable()
|
||||||
{
|
{
|
||||||
return false;
|
var control = ControlRegister.Load(mem);
|
||||||
|
control.PowerEnabled = false;
|
||||||
|
return control.PowerEnabled;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "Generic ENS1370 Audio device"; }
|
get { return "Generic ES1370 Audio device"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string HardwareRevision
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
//var tcr = Register.TransmitConfigurationRegister.Load(mem);
|
|
||||||
//return Register.TransmitConfigurationRegister.GetHardwareRevision(tcr.GetHWVERID());
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
private set { ;}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PCIDevice PCICard { get { return pciCard; } private set { ;} }
|
public PCIDevice PCICard { get { return pciCard; } private set { ;} }
|
||||||
#region Interrupt (IRQ)
|
#region Interrupt (IRQ)
|
||||||
|
|
@ -170,13 +162,8 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370
|
||||||
|
|
||||||
public void DumpRegisters()
|
public void DumpRegisters()
|
||||||
{
|
{
|
||||||
/*
|
Console.WriteLine("Control Register: " + Register.ControlRegister.Load(mem).ToString());
|
||||||
Console.WriteLine("Command Register: " + Register.CommandRegister.Load(mem).ToString());
|
Console.WriteLine("Status Register: " + Register.InterruptStatusRegister.Load(mem).ToString());
|
||||||
Console.WriteLine("Config1 Register: " + Register.ConfigurationRegister1.Load(mem).ToString());
|
|
||||||
Console.WriteLine("Media S Register: " + Register.MediaStatusRegister.Load(mem).ToString());
|
|
||||||
Console.WriteLine("Interrupt Mask R: " + Register.InterruptMaskRegister.Load(mem).ToString());
|
|
||||||
Console.WriteLine("Interrupt Status: " + Register.InterruptStatusRegister.Load(mem).ToString());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Cosmos.Hardware;
|
using Cosmos.Hardware;
|
||||||
|
using Cosmos.Hardware.PC.Bus;
|
||||||
|
using Cosmos.Kernel;
|
||||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||||
{
|
{
|
||||||
class ControlRegister
|
class ControlRegister
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return GetBit(BitPosition.SERRDis);
|
return !GetBit(BitPosition.SERRDis);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
@ -164,8 +164,7 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
//return this.CONTROL.ToBinary(8);
|
return this.CONTROL.ToBinary(8);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using Cosmos.Hardware;
|
||||||
using System.Text;
|
using Cosmos.Hardware.PC.Bus;
|
||||||
|
using Cosmos.Kernel;
|
||||||
|
|
||||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||||
{
|
{
|
||||||
|
|
@ -22,61 +23,84 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||||
{
|
{
|
||||||
xMem = aMem;
|
xMem = aMem;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public UInt16 ISR
|
public UInt16 ISR
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return xMem.Read16((UInt32)Register.MainRegister.Bit.IntrStatus);
|
return xMem.Read16((UInt32)Register.MainRegister.Bit.Status);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
xMem.Write16((UInt32)Register.MainRegister.Bit.IntrStatus, value);
|
xMem.Write16((UInt32)Register.MainRegister.Bit.Status, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return this.ISR.ToBinary(16);
|
return this.ISR.ToBinary(16);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Data
|
#region Data
|
||||||
|
public bool DAC1InterruptEnabled
|
||||||
/*
|
|
||||||
public bool SoftwareInterrupt
|
|
||||||
{
|
{
|
||||||
get { return GetBit(BitPosition.SWINT); }
|
get { return GetBit(BitPosition.DAC1IntEn); }
|
||||||
set { SetBit(BitValue.SWINT, value); }
|
set { SetBit(BitValue.DAC1IntEn, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DAC2InterruptEnabled
|
||||||
public bool SystemError
|
|
||||||
{
|
{
|
||||||
get { return GetBit(BitPosition.SERR); }
|
get { return GetBit(BitPosition.DAC2IntEn); }
|
||||||
set { SetBit(BitValue.SERR, value); }
|
set { SetBit(BitValue.DAC2IntEn, value); }
|
||||||
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
|
public bool UARTInterruptEnabled
|
||||||
|
{
|
||||||
|
get { return GetBit(BitPosition.UARTIntEn); }
|
||||||
|
set { SetBit(BitValue.UARTIntEn, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CodecWriteInProgressEnabled
|
||||||
|
{
|
||||||
|
get { return GetBit(BitPosition.CodecWIPIntEn); }
|
||||||
|
set { SetBit(BitValue.CodecWIPIntEn, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CodecBusyIntEnabled
|
||||||
|
{
|
||||||
|
get { return GetBit(BitPosition.CodecBusyIntEn); }
|
||||||
|
set { SetBit(BitValue.CodecBusyIntEn, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CodecStatusIntEnabled
|
||||||
|
{
|
||||||
|
get { return GetBit(BitPosition.CodecStatIntEn); }
|
||||||
|
set { SetBit(BitValue.CodecStatIntEn, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MCCBIntEnabled
|
||||||
|
{
|
||||||
|
get { return GetBit(BitPosition.MCCBIntEn); }
|
||||||
|
set { SetBit(BitValue.MCCBIntEn, value); }
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Accessors
|
#region Accessors
|
||||||
|
|
||||||
private bool GetBit(BitPosition bit)
|
private bool GetBit(BitPosition bit)
|
||||||
{
|
{
|
||||||
//return BinaryHelper.CheckBit(this.ISR, (byte)bit);
|
return BinaryHelper.CheckBit(this.ISR, (byte)bit);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetBit(BitValue bit, bool value)
|
private void SetBit(BitValue bit, bool value)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (value)
|
if (value)
|
||||||
this.ISR = (byte)(this.ISR | (byte)bit);
|
this.ISR = (byte)(this.ISR | (byte)bit);
|
||||||
else
|
else
|
||||||
this.ISR = (byte)(this.ISR & ~(byte)bit);
|
this.ISR = (byte)(this.ISR & ~(byte)bit);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -86,10 +110,24 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum BitPosition : byte
|
public enum BitPosition : byte
|
||||||
{
|
{
|
||||||
|
DAC2IntEn=1,
|
||||||
|
DAC1IntEn=2,
|
||||||
|
UARTIntEn=3,
|
||||||
|
MCCBIntEn=4,
|
||||||
|
CodecWIPIntEn=8,
|
||||||
|
CodecBusyIntEn=9,
|
||||||
|
CodecStatIntEn=10
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BitValue : uint
|
public enum BitValue : uint
|
||||||
{
|
{
|
||||||
|
DAC2IntEn = BinaryHelper.BitPos.BIT1,
|
||||||
|
DAC1IntEn = BinaryHelper.BitPos.BIT2,
|
||||||
|
UARTIntEn = BinaryHelper.BitPos.BIT3,
|
||||||
|
MCCBIntEn = BinaryHelper.BitPos.BIT4,
|
||||||
|
CodecWIPIntEn = BinaryHelper.BitPos.BIT8,
|
||||||
|
CodecBusyIntEn = BinaryHelper.BitPos.BIT9,
|
||||||
|
CodecStatIntEn = BinaryHelper.BitPos.BIT10
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue