コード例 #1
0
ファイル: VMWareSVGAII.cs プロジェクト: zawhtut/Cosmos
        public VMWareSVGAII()
        {
            device = (HAL.PCI.GetDevice(HAL.VendorID.VMWare, HAL.DeviceID.SVGAIIAdapter));
            device.EnableMemory(true);
            uint basePort = device.BaseAddressBar[0].BaseAddress;

            IndexPort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Index));
            ValuePort = new IOPort((ushort)(basePort + (uint)IOPortOffset.Value));
            BiosPort  = new IOPort((ushort)(basePort + (uint)IOPortOffset.Bios));
            IRQPort   = new IOPort((ushort)(basePort + (uint)IOPortOffset.IRQ));

            WriteRegister(Register.ID, (uint)ID.V2);
            if (ReadRegister(Register.ID) != (uint)ID.V2)
            {
                return;
            }

            Video_Memory = new MemoryBlock(ReadRegister(Register.FrameBufferStart), ReadRegister(Register.VRamSize));
            capabilities = ReadRegister(Register.Capabilities);
            InitializeFIFO();
        }
コード例 #2
0
        public NVIDIA9500MGS(PCIDevice host) : base(host)
        {
            Label    = "NVIDIA 9500MGS";
            instance = this;
            Settings.EnterVideoMode = EnterGraphicsMode;
            host.EnableMemory(true);

            uint basePort = ((PCIDeviceNormal)host).BaseAddresses[0].BaseAddress();

            IndexPort = ((ushort)(basePort + (uint)IOPortOffset.Index));
            ValuePort = ((ushort)(basePort + (uint)IOPortOffset.Value));
            BiosPort  = ((ushort)(basePort + (uint)IOPortOffset.Bios));
            IRQPort   = ((ushort)(basePort + (uint)IOPortOffset.IRQ));

            WriteRegister(Register.ID, (uint)ID.V2);
            if (ReadRegister(Register.ID) != (uint)ID.V2)
            {
                return;
            }

            VIDEO_MEMORY = new Cosmos.Core.MemoryBlock(ReadRegister(Register.FrameBufferStart), ReadRegister(Register.VRamSize));
            capabilities = ReadRegister(Register.Capabilities);
            InitializeFIFO();
        }
コード例 #3
0
        public VMWareSVGAII()
        {
            Device = PCI.GetDeviceVendorID(misc.PCI_VENDOR_ID_VMWARE, misc.PCI_DEVICE_ID_VMWARE_SVGA2);

            if (Device == null)
            {
                throw new Exception("Device Not Found");
            }

            Device.EnableMemory(true);

            //IO Ports
            var IOBase = Device.BaseAddressBar[0].BaseAddress;

            IndexPort = new IOPort((ushort)(IOBase + (ushort)IOPortOffset.Index));
            ValuePort = new IOPort((ushort)(IOBase + (ushort)IOPortOffset.Value));

            //Memory Block
            FB_Memory   = new MemoryBlock32(Device.BaseAddressBar[1].BaseAddress);
            FIFO_Memory = new MemoryBlock32(Device.BaseAddressBar[2].BaseAddress);

            //Version Check
            VersionID = (UInt32)Versions.SVGA_ID_2;
            do
            {
                WriteRegister(Registers.SVGA_REG_ID, VersionID);
                if (ReadRegister(Registers.SVGA_REG_ID) == VersionID)
                {
                    break;
                }
                else
                {
                    VersionID--;
                }
            }while (VersionID >= (UInt32)Versions.SVGA_ID_0);

            if (VersionID < (UInt32)Versions.SVGA_ID_0)
            {
                throw new Exception("Error negotiating SVGA device version.");
            }

            //Memory Block Length
            FB_Memory.Length   = ReadRegister(Registers.SVGA_REG_FB_SIZE);
            FIFO_Memory.Length = ReadRegister(Registers.SVGA_REG_MEM_SIZE);

            //Memory Block Length Check
            if (FB_Memory.Length < 0x100000)
            {
                throw new Exception("FB size very small, probably incorrect.");
            }

            if (FIFO_Memory.Length < 0x20000)
            {
                throw new Exception("FIFO size very small, probably incorrect.");
            }

            if (VersionID >= (UInt32)Versions.SVGA_ID_1)
            {
                Capabilities = ReadRegister(Registers.SVGA_REG_CAPABILITIES);
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates a new instance of the <see cref="AC97"/> class, with the
        /// given buffer size.
        /// </summary>
        /// <param name="bufferSize">The buffer size in samples to use. This value cannot be an odd number, as per the AC97 specification.</param>
        /// <exception cref="ArgumentException">Thrown when the given buffer size is invalid.</exception>
        /// <exception cref="InvalidOperationException">Thrown when no AC97-compatible sound card is present.</exception>
        private AC97(ushort bufferSize)
        {
            if (bufferSize % 2 != 0)
            {
                // As per the AC97 specification, the buffer size cannot be odd.
                // (1.2.4.2 PCM Buffer Restrictions, Intel document 302349-003)
                throw new ArgumentException("The buffer size must be an even number.", nameof(bufferSize));
            }

            PCIDevice pci = Cosmos.HAL.PCI.GetDeviceClass(
                ClassID.MultimediaDevice, // 0x04
                (SubclassID)0x01          // 0x01
                );

            if (pci == null || !pci.DeviceExists || pci.InterruptLine > 0xF)
            {
                throw new InvalidOperationException("No AC97-compatible device could be found.");
            }

            PCI = pci; // Expose PCI device to the public API

            pci.EnableBusMaster(true);
            pci.EnableMemory(true);
            pci.EnableDevice(); // enable I/O space

            INTs.SetIrqHandler(pci.InterruptLine, HandleInterrupt);

            ushort NAMbar  = (ushort)pci.BaseAddressBar[0].BaseAddress; // Native Audio Mixer
            ushort NABMbar = (ushort)pci.BaseAddressBar[1].BaseAddress; // Native Audio Bus Master

            pTransferControl   = new IOPort((ushort)(NABMbar + 0x1B));
            pMasterVolume      = new IOPort((ushort)(NAMbar + 0x02));
            pPCMOutVolume      = new IOPort((ushort)(NAMbar + 0x18));
            pBufferDescriptors = new IOPort((ushort)(NABMbar + 0x10));
            pTransferStatus    = new IOPort((ushort)(NABMbar + 0x16));
            pLastValidEntry    = new IOPort((ushort)(NABMbar + 0x15));
            pGlobalControl     = new IOPort((ushort)(NABMbar + 0x2C));
            pResetRegister     = new IOPort((ushort)(NAMbar + 0x00));

            // Reset device
            pGlobalControl.Byte  = 0x2;
            pResetRegister.DWord = 0xDEADBEEF; // any value will do here

            // Reset PCM out
            uint polls = 0; // The amount we polled the device for a reset

            pTransferControl.Byte = (byte)(pTransferControl.Byte | TC_TRANSFER_RESET);
            while ((pTransferControl.Byte & TC_TRANSFER_RESET) != 0 && polls < RESET_POLL_LIMIT)
            {
                // Wait until the byte is cleared
                polls++;
            }

            // The device hasn't responded to our reset request. Probably not a fully-compatible AC97 card.
            if (polls >= RESET_POLL_LIMIT)
            {
                throw new InvalidOperationException("No AC97-compatible device could be found - the reset timeout has expired.");
            }

            // Volume
            pMasterVolume.Word = CreateMixerVolumeValue(AC97_VOLUME_MAX, AC97_VOLUME_MAX, false);
            pPCMOutVolume.Word = CreateMixerVolumeValue(AC97_VOLUME_MAX, AC97_VOLUME_MAX, false);

            // Create all needed buffers
            CreateBuffers(bufferSize);

            // Initialization done - driver can now be activated by using Enable()
        }