コード例 #1
0
ファイル: Serial.cs プロジェクト: mwoodruff1/MOSA-Project
        /// <summary>
        /// Disables the data received interrupt.
        /// </summary>
        public void DisableDataReceivedInterrupt()
        {
            IER ier = (IER)(ierBase.Read8());

            ier &= ~IER.DR;
            ierBase.Write8((byte)ier);
        }
コード例 #2
0
        /// <summary>
        /// Sets the bit.
        /// </summary>
        /// <param name="bit">The bit.</param>
        protected void SetBit(byte bit)
        {
            switch (bits)
            {
            case 8: ioPort.Write8(SetBit(ioPort.Read8(), bit)); break;

            case 16: ioPort.Write16(SetBit(ioPort.Read16(), bit)); break;

            case 32: ioPort.Write32(SetBit(ioPort.Read32(), bit)); break;
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the palette.
        /// </summary>
        /// <param name="colorIndex">Index of the color.</param>
        /// <returns></returns>
        public Color GetPalette(byte colorIndex)
        {
            Color color = new Color();

            dacPaletteMask.Write8(0xFF);
            dacIndexRead.Write8(colorIndex);
            color.Red   = dacData.Read8();
            color.Green = dacData.Read8();
            color.Blue  = dacData.Read8();

            return(color);
        }
コード例 #4
0
ファイル: VGAText.cs プロジェクト: mwoodruff1/MOSA-Project
        /// <summary>
        /// Writes the settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected void WriteSettings(byte[] settings)
        {
            // Write MISCELLANEOUS reg
            miscellaneousOutputWrite.Write8(settings[0]);

            // Write SEQUENCER regs
            for (byte i = 0; i < 5; i++)
            {
                sequencerAddress.Write8(i);
                sequencerData.Write8(settings[1 + i]);
            }

            // Unlock CRTC registers
            crtControllerIndexColor.Write8(0x03);
            crtControllerDataColor.Write8((byte)(crtControllerData.Read8() | 0x80));
            crtControllerIndexColor.Write8(0x11);
            crtControllerDataColor.Write8((byte)(crtControllerData.Read8() & 0x7F));

            // Make sure they remain unlocked
            settings[0x03] = (byte)(settings[0x03] | 0x80);
            settings[0x11] = (byte)(settings[0x11] & 0x7F);

            // Write CRTC regs
            for (byte i = 0; i < 25; i++)
            {
                crtControllerIndexColor.Write8(i);
                crtControllerDataColor.Write8(settings[6 + i]);
            }

            // Write GRAPHICS CONTROLLER regs
            for (byte i = 0; i < 9; i++)
            {
                graphicsControllerAddress.Write8(i);
                graphicsControllerData.Write8(settings[31 + i]);
            }

            // Write ATTRIBUTE CONTROLLER regs
            for (byte i = 0; i < 21; i++)
            {
                inputStatus1ReadB.Read8();
                attributeAddress.Write8(i);
                attributeAddress.Write8(settings[40 + i]);                 // TODO: Double check
            }

            // Lock 16-color palette and unblank display */
            inputStatus1ReadB.Read8();
            attributeAddress.Write8(0x20);
        }
コード例 #5
0
ファイル: S3Trio64V2.cs プロジェクト: djlw78/Mosa
 /// <summary>
 /// Reads in the sequence register's current value. The register is chosen by
 /// the given index.
 /// </summary>
 /// <param name="index">The index to the register</param>
 /// <returns>The register's value</returns>
 private byte ReadSequenceRegister(byte index)
 {
     // Select register
     seqControllerIndex.Write8(index);
     // Read contained value
     return(seqControllerData.Read8());
 }
コード例 #6
0
ファイル: VGAText.cs プロジェクト: mwoodruff1/MOSA-Project
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            WriteSettings(VGAText80x25);

            colorMode = ((miscellaneousOutput.Read8() & 1) == 1);

            if (colorMode)
            {
                offset                = 0x8000;
                bytePerChar           = 2;
                activeControllerIndex = crtControllerIndexColor;
                activeControllerData  = crtControllerDataColor;
            }
            else
            {
                offset                = 0x0;
                bytePerChar           = 1;
                activeControllerIndex = crtControllerIndex;
                activeControllerData  = crtControllerData;
            }

            width  = GetValue(CRTCommands.HorizontalDisplayEnableEnd);
            height = GetValue(CRTCommands.VerticalDisplayEnableEnd);

            width++;
            height = 25;

            base.deviceStatus = DeviceStatus.Online;
            return(DeviceDriverStartStatus.Started);
        }
コード例 #7
0
        /// <summary>
        /// Reads the scan code from the device
        /// </summary>
        protected void ReadScanCode()
        {
            spinLock.Enter();

            AddToFIFO(commandPort.Read8());

            spinLock.Exit();
        }
コード例 #8
0
        protected void DetectDrives()
        {
            CMOSComand.Write8(0x10);
            byte types = CMOSResponse.Read8();

            floppyDrives[0] = DetermineByType((byte)(types >> 4));
            floppyDrives[1] = DetermineByType((byte)(types & 0xF));
        }
コード例 #9
0
ファイル: CMOS.cs プロジェクト: tralivali1234/MOSA-Project
        /// <summary>
        /// Reads the specified address.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <returns></returns>
        public byte Read(byte address)
        {
            spinLock.Enter();
            commandPort.Write8(address);
            byte b = dataPort.Read8();

            spinLock.Exit();
            return(b);
        }
コード例 #10
0
        /// <summary>
        /// Probes this instance.
        /// </summary>
        /// <returns></returns>
        public bool Probe()
        {
            LBALowPort.Write8(0x88);

            if (LBALowPort.Read8() != 0x88)
            {
                return(false);
            }

            return(true);
        }
コード例 #11
0
        /// <summary>
        /// Turns the on motor.
        /// </summary>
        /// <param name="drive">The drive.</param>
        protected void TurnOnMotor(uint drive)
        {
            byte reg  = commandPort.Read8();
            byte bits = (byte)(DORFlags.MotorShift << (byte)drive | DORFlags.EnableDMA | DORFlags.EnableController | (byte)drive);

            if (reg != bits)
            {
                commandPort.Write8(bits);
                HAL.Sleep(500);                 // 500 msec
            }
        }
コード例 #12
0
        /// <summary>
        /// Reads the scan code from the device
        /// </summary>
        protected void ReadScanCode()
        {
            spinLock.Enter();

            byte v = commandPort.Read8();

            AddToFIFO(v);

            HAL.DebugWrite(" scancode: " + v.ToString() + "   ");

            spinLock.Exit();
        }
コード例 #13
0
        protected void TurnOnMotor(uint drive)
        {
            byte reg  = ControllerCommands.Read8();
            byte bits = (byte)(DORFlags.MotorShift << (byte)drive | DORFlags.EnableDMA | DORFlags.EnableController | (byte)drive);

            if (reg != bits)
            {
                ///TextMode.WriteLine("..Motor On");
                ControllerCommands.Write8(bits);
                Timer.Delay(500);                       // 500 msec
            }
        }
コード例 #14
0
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            vgaEnableController.Write8((byte)(vgaEnableController.Read8() | 0x01));

            // Enable colors
            miscOutputWriter.Write8((byte)(miscOutputReader.Read8() | 0x01));

            // Enable MMIO
            crtcControllerIndex.Write8(0x53);
            crtcControllerData.Write8((byte)(crtcControllerData.Read8() | 0x8));

            // Unlock system registers
            WriteCrtcRegister(0x38, 0x48);
            WriteCrtcRegister(0x39, 0xa5);

            WriteCrtcRegister(0x40, 0x01, 0x01);
            WriteCrtcRegister(0x35, 0x00, 0x30);
            WriteCrtcRegister(0x33, 0x20, 0x72);

            WriteCrtcRegister(0x86, 0x80);
            WriteCrtcRegister(0x90, 0x00);

            // Detect number of MB of installed RAM
            byte[] ramSizes  = new byte[] { 4, 0, 3, 8, 2, 6, 1, 0 };
            int    ramSizeMB = ramSizes[(ReadCrtcRegister(0x36) >> 5) & 0x7];

            // Setup video memory
            memory = base.hardwareResources.GetMemory((byte)(ramSizeMB * 1024 * 1024));

            // Detect current mclk
            WriteSequenceRegister(0x08, 0x06);
            byte m  = (byte)(ReadSequenceRegister(0x11) & 0x7f);
            byte n  = ReadSequenceRegister(0x10);
            byte n1 = (byte)(n & 0x1f);
            byte n2 = (byte)((n >> 5) & 0x03);

            base.deviceStatus = DeviceStatus.Online;
            return(DeviceDriverStartStatus.Started);
        }
コード例 #15
0
        /// <summary>
        /// Waits for register ready.
        /// </summary>
        /// <returns></returns>
        protected bool WaitForReqisterReady()
        {
            // wait for RQM data register to be ready
            while (true)
            {
                uint status = statusPort.Read8();

                if ((status & 0x80) == 0x80)
                {
                    return(true);
                }

                //TODO: add timeout check
            }

            //return false;
        }
コード例 #16
0
ファイル: PIC.cs プロジェクト: mwoodruff1/MOSA-Project
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            byte masterMask;
            byte slaveMask;

            // Save Masks
            masterMask = masterDataPort.Read8();
            slaveMask  = slaveDataPort.Read8();

            // ICW1 - Set Initialize Controller & Expect ICW4
            masterCommandPort.Write8(0x11);

            // ICW2 - interrupt offset
            masterDataPort.Write8(MasterIRQBase);

            // ICW3
            masterDataPort.Write8(0x04);

            // ICW4 - Set 8086 Mode
            masterDataPort.Write8(0x01);

            // ICW1 - Set Initialize Controller & Expect ICW4
            slaveCommandPort.Write8(0x11);

            // ICW2 - interrupt offset
            slaveDataPort.Write8(SlaveIRQBase);

            // ICW3
            slaveDataPort.Write8(0x02);

            // ICW4 - Set 8086 Mode
            slaveDataPort.Write8(0x01);

            // Restore Masks
            masterDataPort.Write8(masterMask);
            slaveDataPort.Write8(slaveMask);

            DisableIRQs();

            base.deviceStatus = DeviceStatus.Online;
            return(DeviceDriverStartStatus.Started);
        }
コード例 #17
0
        public void Initialize()
        {
            spinLock.Enter();

            //IdeIRQ = base.CreateIRQHandler (14);

            for (int drive = 0; drive < DrivesPerConroller; drive++)
            {
                driveInfo[drive].Present = false;
                driveInfo[drive].MaxLBA  = 0;
            }

            TextMode.Write(base.name);
            TextMode.Write(": ");

            LBALowPort.Write8(0x88);

            if (LBALowPort.Read8() != 0x88)
            {
                base.deviceStatus = DeviceStatus.NotFound;

                TextMode.WriteLine("IDE controller not found at 0x" + ((uint)ioBase).ToString("X"));
                return;
            }

            TextMode.WriteLine("IDE controller found at 0x" + ((uint)ioBase).ToString("X"));

            DeviceHeadPort.Write8(0xA0);

            Timer.Delay(1000 / 250);              // wait 1/250th of a second

            if ((StatusPort.Read8() & 0x40) == 0x40)
            {
                driveInfo[0].Present = true;
            }

            DeviceHeadPort.Write8(0xB0);

            Timer.Delay(1000 / 250);              // wait 1/250th of a second

            if ((StatusPort.Read8() & 0x40) == 0x40)
            {
                driveInfo[1].Present = true;
            }

            for (uint drive = 0; drive < DrivesPerConroller; drive++)
            {
                if (driveInfo[drive].Present)
                {
                    if (Open(drive))
                    {
                        TextMode.Write(base.name);
                        TextMode.Write(": Disk #");
                        TextMode.Write((int)drive);
                        TextMode.Write(" - ", (int)(driveInfo[drive].MaxLBA / 1024 / 2));
                        TextMode.Write("MB, LBA=", (int)driveInfo[drive].MaxLBA);
                        TextMode.WriteLine("");

                        DeviceManager.Add(new DiskDevice(this, drive, false));
                    }
                }
            }

            base.deviceStatus = DeviceStatus.Online;
        }
コード例 #18
0
 /// <summary>
 /// Gets the byte.
 /// </summary>
 /// <returns></returns>
 protected byte GetByte()
 {
     WaitForReqisterReady();
     return(dataPort.Read8());
 }
コード例 #19
0
 /// <summary>
 /// Reads from configuraton space
 /// </summary>
 /// <param name="bus">The bus.</param>
 /// <param name="slot">The slot.</param>
 /// <param name="function">The function.</param>
 /// <param name="register">The register.</param>
 /// <returns></returns>
 public byte ReadConfig8(byte bus, byte slot, byte function, byte register)
 {
     configAddress.Write32(GetIndex(bus, slot, function, register));
     return(configData.Read8());
 }
コード例 #20
0
ファイル: Serial.cs プロジェクト: mwoodruff1/MOSA-Project
 /// <summary>
 /// Determines whether this instance can transmit.
 /// </summary>
 /// <returns>
 ///     <c>true</c> if this instance can transmit; otherwise, <c>false</c>.
 /// </returns>
 protected bool CanTransmit()
 {
     return((lsrBase.Read8() & (byte)LSR.THRE) != 0);
 }
コード例 #21
0
ファイル: VGAText.cs プロジェクト: mwoodruff1/MOSA-Project
 /// <summary>
 /// Gets the value.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns></returns>
 protected byte GetValue(byte command)
 {
     activeControllerIndex.Write8(command);
     return(activeControllerData.Read8());
 }