コード例 #1
0
ファイル: S3Trio64V2.cs プロジェクト: djlw78/Mosa
 /// <summary>
 /// Write a value to the indexed sequence register.
 /// </summary>
 /// <param name="index">The index to the register</param>
 /// <param name="value">Value to write</param>
 private void WriteSequenceRegister(byte index, byte value)
 {
     // Select target register
     seqControllerIndex.Write8(index);
     // Write masked value to register
     seqControllerData.Write8(value);
 }
コード例 #2
0
ファイル: Serial.cs プロジェクト: mwoodruff1/MOSA-Project
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            //TODO: auto detect - otherwise just assume one is there
            //TODO: could use BIOS to help w/ detection; 0x0400-x0403 supply base address for COM1-4

            // Disable all UART interrupts
            ierBase.Write8(0x00);

            // Enable DLAB (set baud rate divisor)
            lcrBase.Write8((byte)LCR.DLAB);

            // Set Baud rate
            int baudRate = 115200;
            int divisor  = 115200 / baudRate;

            dllBase.Write8((byte)(divisor & 0xFF));
            dlmBase.Write8((byte)(divisor >> 8 & 0xFF));

            // Reset DLAB, Set 8 bits, no parity, one stop bit
            lcrBase.Write8((byte)(LCR.CS8 | LCR.ST1 | LCR.PNO));

            // Enable FIFO, clear them, with 14-byte threshold
            fcrBase.Write8((byte)(FCR.Enabled | FCR.CLR_RCVR | FCR.CLR_XMIT | FCR.TL14));

            // IRQs enabled, RTS/DSR set
            mcrBase.Write8((byte)(MCR.DTR | MCR.RTS | MCR.OUT2));

            // Interrupt when data received
            ierBase.Write8((byte)IER.DR);

            return(DeviceDriverStartStatus.Started);
        }
コード例 #3
0
 /// <summary>
 /// Sets the palette.
 /// </summary>
 /// <param name="colorIndex">Index of the color.</param>
 /// <param name="color">The color.</param>
 public void SetPalette(byte colorIndex, Color color)
 {
     dacPaletteMask.Write8(0xFF);
     dacIndexWrite.Write8(colorIndex);
     dacData.Write8(color.Red);
     dacData.Write8(color.Green);
     dacData.Write8(color.Blue);
 }
コード例 #4
0
        /// <summary>
        /// Probes this instance.
        /// </summary>
        /// <returns></returns>
        public bool Probe()
        {
            LBALowPort.Write8(0x88);

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

            return(true);
        }
コード例 #5
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;
            }
        }
コード例 #6
0
ファイル: PIT.cs プロジェクト: tralivali1234/MOSA-Project
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            ushort timerCount = (ushort)(Frequency / Hz);

            // Set to Mode 3 - Square Wave Generator
            modeControlPort.Write8(SquareWave);
            counter0Divisor.Write8((byte)(timerCount & 0xFF));
            counter0Divisor.Write8((byte)((timerCount & 0xFF00) >> 8));

            tickCount = 0;

            base.DeviceStatus = DeviceStatus.Online;
            return(DeviceDriverStartStatus.Started);
        }
コード例 #7
0
        /// <summary>
        /// Performs the LBA28.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="drive">The drive NBR.</param>
        /// <param name="lba">The lba.</param>
        /// <param name="data">The data.</param>
        /// <param name="offset">The offset.</param>
        /// <returns></returns>
        protected bool PerformLBA28(SectorOperation operation, uint drive, uint lba, byte[] data, uint offset)
        {
            if (drive > MaximunDriveCount)
            {
                return(false);
            }

            FeaturePort.Write8(0);
            SectorCountPort.Write8(1);

            LBALowPort.Write8((byte)(lba & 0xFF));
            LBAMidPort.Write8((byte)((lba >> 8) & 0xFF));
            LBAHighPort.Write8((byte)((lba >> 16) & 0xFF));

            DeviceHeadPort.Write8((byte)(0xE0 | (drive << 4) | ((lba >> 24) & 0x0F)));

            if (operation == SectorOperation.Write)
            {
                CommandPort.Write8(IDECommands.WriteSectorsWithRetry);
            }
            else
            {
                CommandPort.Write8(IDECommands.ReadSectorsWithRetry);
            }

            if (!WaitForReqisterReady())
            {
                return(false);
            }

            BinaryFormat sector = new BinaryFormat(data);

            //TODO: Don't use PIO
            if (operation == SectorOperation.Read)
            {
                for (uint index = 0; index < 256; index++)
                {
                    sector.SetUShort(offset + (index * 2), DataPort.Read16());
                }
            }
            else
            {
                for (uint index = 0; index < 256; index++)
                {
                    DataPort.Write16(sector.GetUShort(offset + (index * 2)));
                }
            }

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            for (int drive = 0; drive < DrivesPerController; drive++)
            {
                trackCache[drive].valid    = false;
                lastSeek[drive].calibrated = false;

                // default
                floppyMedia[drive].SectorsPerTrack = 18;
                floppyMedia[drive].TotalTracks     = 80;

                //TODO: for 5.25, Gap1 = 0x2A and Gap2 = 0x50
                floppyMedia[drive].Gap1Length = 0x1B;                   // 27
                floppyMedia[drive].Gap2Length = 0x54;
            }

            ResetController();

            commandPort.Write8(DORFlags.EnableController | DORFlags.EnableDMA);

            SendByte(FIFOCommand.SenseInterrupt);
            GetByte();
            GetByte();

            configPort.Write8(0x00);             // 500 Kb/s (MFM)

            // Set step rate to 3ms & head unload time to 240ms
            SendByte(FIFOCommand.Specify);
            SendByte((((16 - (3)) << 4) | ((240 / 16))));

            // Set head load time to 2ms
            SendByte(0x02);

            SendByte(FIFOCommand.Version);

            if (GetByte() == 0x80)
            {
                enchancedController = false;
            }
            else
            {
                enchancedController = true;
            }

            DetectDrives();

            return(DeviceDriverStartStatus.Started);
        }
コード例 #9
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);
        }
コード例 #10
0
        protected void DetectDrives()
        {
            CMOSComand.Write8(0x10);
            byte types = CMOSResponse.Read8();

            floppyDrives[0] = DetermineByType((byte)(types >> 4));
            floppyDrives[1] = DetermineByType((byte)(types & 0xF));
        }
コード例 #11
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);
        }
コード例 #12
0
ファイル: SerialDevice.cs プロジェクト: willvin313/SharpOS
        public void Initialize()
        {
            try {
                ///TODO: auto detect - otherwise just assume one is there
                ///TODO: could use BIOS to help w/ detection; 0x0400-x0403 supply base address for COM1-4

                TextMode.Write(base.name);
                TextMode.Write(": ");
                TextMode.WriteLine("Serial device found at 0x" + ((uint)ioBase).ToString("X"));

                spinLock.Enter();

                // Disable all UART interrupts
                IERBase.Write8(0x00);

                // Enable DLAB (set baud rate divisor)
                LCRBase.Write8((byte)LCR.DLAB);

                // Set Baud rate
                int baudRate = 115200;
                int divisor  = 115200 / baudRate;
                DLLBase.Write8((byte)(divisor & 0xFF));
                DLMBase.Write8((byte)(divisor >> 8 & 0xFF));

                // Reset DLAB, Set 8 bits, no parity, one stop bit
                LCRBase.Write8((byte)(LCR.CS8 | LCR.ST1 | LCR.PNO));

                // Enable FIFO, clear them, with 14-byte threshold
                FCRBase.Write8((byte)(FCR.Enabled | FCR.CLR_RCVR | FCR.CLR_XMIT | FCR.TL14));

                // IRQs enabled, RTS/DSR set
                MCRBase.Write8((byte)(MCR.DTR | MCR.RTS | MCR.OUT2));

                // Interrupt when data received
                IERBase.Write8((byte)IER.DR);

                serialIRQ.AssignCallBack(this);
            }
            finally {
                spinLock.Exit();
            }
        }
コード例 #13
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);
        }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
0
        protected void ResetController()
        {
            floppyIRQ.ClearInterrupt();

            ControllerCommands.Write8(DORFlags.ResetController);

            Timer.Delay(200);                   // 20 msec

            ControllerCommands.Write8(DORFlags.EnableController);

            floppyIRQ.WaitForInterrupt(3000);

            ControllerCommands.Write8(DORFlags.EnableController | DORFlags.EnableDMA);

            SendByte(FIFOCommand.SenseInterrupt);
            GetByte();
            GetByte();

            ConfigPort.Write8(0x00);              // 500 Kb/s (MFM)

            SendByte(FIFOCommand.Specify);
            SendByte((((16 - (3)) << 4) | ((240 / 16)))); // set step rate to 3ms & head unload time to 240ms
            SendByte(0x02);                               // set head load time to 2ms
        }
コード例 #17
0
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            DeviceHeadPort.Write8(0xA0);

            HAL.Sleep(1000 / 250);             // wait 1/250th of a second

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

            DeviceHeadPort.Write8(0xB0);

            HAL.Sleep(1000 / 250);             // wait 1/250th of a second

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

            return(DeviceDriverStartStatus.Started);
        }
コード例 #18
0
ファイル: VGAText.cs プロジェクト: mwoodruff1/MOSA-Project
 /// <summary>
 /// Sends the command.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="value">The value.</param>
 protected void SendCommand(byte command, byte value)
 {
     activeControllerIndex.Write8(command);
     activeControllerData.Write8(value);
 }
コード例 #19
0
 /// <summary>
 /// Sends the byte.
 /// </summary>
 /// <param name="command">The command.</param>
 protected void SendByte(byte command)
 {
     WaitForReqisterReady();
     dataPort.Write8(command);
 }
コード例 #20
0
 /// <summary>
 /// Writes to configuration 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>
 /// <param name="value">The value.</param>
 public void WriteConfig8(byte bus, byte slot, byte function, byte register, byte value)
 {
     configAddress.Write32(GetIndex(bus, slot, function, register));
     configData.Write8(value);
 }
コード例 #21
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;
        }