mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 14:02:19 +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.Text;
|
||||
using Cosmos.Hardware;
|
||||
using Cosmos.Hardware.Audio.Devices.ES1370.Register;
|
||||
namespace Cosmos.Hardware.Audio.Devices.ES1370
|
||||
{
|
||||
/// <summary>
|
||||
/// Driver for the soundcard Ensoniq 1370 AudioPCI (testing for QEMU audio emulation)
|
||||
/// It should work also in Ensoniq 1371 all revision.
|
||||
/// </summary>
|
||||
public class ENS1370
|
||||
public class ES1370
|
||||
{
|
||||
#region Construction
|
||||
|
||||
private PCIDevice pciCard;
|
||||
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)
|
||||
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;
|
||||
mem = device.GetAddressSpace(1) as Cosmos.Kernel.MemoryAddressSpace;
|
||||
//valueReg = Register.ValueTypeRegisters.Load(mem);
|
||||
//imr = Register.InterruptMaskRegister.Load(mem);
|
||||
//isr = Register.InterruptStatusRegister.Load(mem);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -36,15 +31,15 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370
|
|||
/// Retrieve all Ensoniq AudioPCI 1370 cards found on computer.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
Console.WriteLine("VendorID: " + device.VendorID + " - DeviceID: " + device.DeviceID);
|
||||
if (device.VendorID == 0x10EC && device.DeviceID == 0x8139)
|
||||
found.Add(new ENS1370(device));
|
||||
found.Add(new ES1370(device));
|
||||
}
|
||||
|
||||
return found;
|
||||
|
|
@ -52,34 +47,31 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370
|
|||
#region Power and Initilization
|
||||
public void InitializeDriver()
|
||||
{
|
||||
//Enable IRQ Interrupt
|
||||
InitIRQMaskRegister();
|
||||
Cosmos.Hardware.Interrupts.IRQ05 = new Cosmos.Hardware.Interrupts.InterruptDelegate(this.HandleNetworkInterrupt);
|
||||
}
|
||||
|
||||
public bool Enable()
|
||||
{
|
||||
return true;
|
||||
var control = ControlRegister.Load(mem);
|
||||
control.PowerEnabled=true;
|
||||
return control.PowerEnabled;
|
||||
}
|
||||
|
||||
public bool Disable()
|
||||
{
|
||||
return false;
|
||||
var control = ControlRegister.Load(mem);
|
||||
control.PowerEnabled = false;
|
||||
return control.PowerEnabled;
|
||||
}
|
||||
#endregion
|
||||
|
||||
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 { ;} }
|
||||
#region Interrupt (IRQ)
|
||||
|
|
@ -170,13 +162,8 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370
|
|||
|
||||
public void DumpRegisters()
|
||||
{
|
||||
/*
|
||||
Console.WriteLine("Command Register: " + Register.CommandRegister.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());
|
||||
*/
|
||||
Console.WriteLine("Control Register: " + Register.ControlRegister.Load(mem).ToString());
|
||||
Console.WriteLine("Status Register: " + Register.InterruptStatusRegister.Load(mem).ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.Hardware;
|
||||
using Cosmos.Hardware.PC.Bus;
|
||||
using Cosmos.Kernel;
|
||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||
{
|
||||
class ControlRegister
|
||||
|
|
@ -43,7 +43,7 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
|||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.SERRDis);
|
||||
return !GetBit(BitPosition.SERRDis);
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
@ -164,8 +164,7 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
//return this.CONTROL.ToBinary(8);
|
||||
return null;
|
||||
return this.CONTROL.ToBinary(8);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.Hardware;
|
||||
using Cosmos.Hardware.PC.Bus;
|
||||
using Cosmos.Kernel;
|
||||
|
||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||
{
|
||||
|
|
@ -22,61 +23,84 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
|||
{
|
||||
xMem = aMem;
|
||||
}
|
||||
/*
|
||||
|
||||
public UInt16 ISR
|
||||
{
|
||||
get
|
||||
{
|
||||
return xMem.Read16((UInt32)Register.MainRegister.Bit.IntrStatus);
|
||||
return xMem.Read16((UInt32)Register.MainRegister.Bit.Status);
|
||||
}
|
||||
set
|
||||
{
|
||||
xMem.Write16((UInt32)Register.MainRegister.Bit.IntrStatus, value);
|
||||
xMem.Write16((UInt32)Register.MainRegister.Bit.Status, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.ISR.ToBinary(16);
|
||||
}*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
|
||||
/*
|
||||
public bool SoftwareInterrupt
|
||||
public bool DAC1InterruptEnabled
|
||||
{
|
||||
get { return GetBit(BitPosition.SWINT); }
|
||||
set { SetBit(BitValue.SWINT, value); }
|
||||
get { return GetBit(BitPosition.DAC1IntEn); }
|
||||
set { SetBit(BitValue.DAC1IntEn, value); }
|
||||
}
|
||||
|
||||
|
||||
public bool SystemError
|
||||
public bool DAC2InterruptEnabled
|
||||
{
|
||||
get { return GetBit(BitPosition.SERR); }
|
||||
set { SetBit(BitValue.SERR, value); }
|
||||
|
||||
}*/
|
||||
get { return GetBit(BitPosition.DAC2IntEn); }
|
||||
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
|
||||
|
||||
#region Accessors
|
||||
|
||||
private bool GetBit(BitPosition bit)
|
||||
{
|
||||
//return BinaryHelper.CheckBit(this.ISR, (byte)bit);
|
||||
return false;
|
||||
return BinaryHelper.CheckBit(this.ISR, (byte)bit);
|
||||
}
|
||||
|
||||
private void SetBit(BitValue bit, bool value)
|
||||
{
|
||||
/*
|
||||
if (value)
|
||||
this.ISR = (byte)(this.ISR | (byte)bit);
|
||||
else
|
||||
this.ISR = (byte)(this.ISR & ~(byte)bit);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -86,10 +110,24 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
|||
[Flags]
|
||||
public enum BitPosition : byte
|
||||
{
|
||||
DAC2IntEn=1,
|
||||
DAC1IntEn=2,
|
||||
UARTIntEn=3,
|
||||
MCCBIntEn=4,
|
||||
CodecWIPIntEn=8,
|
||||
CodecBusyIntEn=9,
|
||||
CodecStatIntEn=10
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue