public bool SetMode(int Width, int Height, int BitDepth) { /* As per OSdev wiki, sequence is: * 1) disable VBE extensions * 2) set resolution * 3) re-enable VBE extensions and LFB capability * * We then recheck BAR0 to get the physical address of the LFB * in case it has changed following mode setting */ WriteRegister(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED); WriteRegister(VBE_DISPI_INDEX_XRES, (ushort)Width); WriteRegister(VBE_DISPI_INDEX_YRES, (ushort)Height); WriteRegister(VBE_DISPI_INDEX_BPP, (ushort)BitDepth); WriteRegister(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); /* Read back the current display mode */ int act_Width = ReadRegister(VBE_DISPI_INDEX_XRES); int act_Height = ReadRegister(VBE_DISPI_INDEX_YRES); int act_Bpp = ReadRegister(VBE_DISPI_INDEX_BPP); if (Width != act_Width || Height != act_Height || BitDepth != act_Bpp) { System.Diagnostics.Debugger.Log(0, null, "failed to set mode " + Width.ToString() + "x" + Height.ToString() + "x" + BitDepth.ToString() + " - current mode: " + act_Width.ToString() + "x" + act_Height.ToString() + "x" + act_Bpp.ToString()); return(false); } /* Read LFB address */ var lfb = pciconf.GetBAR(0) as tysos.PhysicalMemoryResource64; if (lfb == null) { System.Diagnostics.Debugger.Log(0, null, "failed to read LFB address from BAR0"); return(false); } lfb.Map(vmem); /* Report success */ System.Diagnostics.Debugger.Log(0, null, "SetMode: successfully set mode: " + Height.ToString() + "x" + Width.ToString() + "x" + BitDepth.ToString() + ", LFB at physical " + lfb.Addr64.ToString("X") + ", virtual " + vmem.Addr64.ToString("X")); read_fbd(); return(true); }
public override bool InitServer() { System.Diagnostics.Debugger.Log(0, "pciide", "PCI IDE driver started"); pciconf = pci.PCIConfiguration.GetPCIConf(root); if (pciconf == null) { System.Diagnostics.Debugger.Log(0, "pciide", "no PCI configuration provided"); return(false); } if (dt == DriverType.Unknown) { /* Get the type from PCI config space */ uint conf_8 = pciconf.ReadConfig(0x8); uint progIF = (conf_8 >> 8) & 0xffU; if ((progIF & 0x5) == 0x5) { dt = DriverType.PCINative; } else { dt = DriverType.Legacy; } } /* Get IO port ranges */ var pri_cmd = pciconf.GetBAR(0); var pri_ctrl = pciconf.GetBAR(1); var sec_cmd = pciconf.GetBAR(2); var sec_ctrl = pciconf.GetBAR(3); /* Get IRQ ports */ tysos.Resources.InterruptLine pri_int = null, sec_int = null; switch (dt) { case DriverType.Legacy: foreach (var r in root) { if (r.Name == "interrupt" && (r.Value is tysos.Resources.InterruptLine)) { var r_int = r.Value as tysos.Resources.InterruptLine; if (r_int.ShortName == "IRQ14") { pri_int = r_int; } else if (r_int.ShortName == "IRQ15") { sec_int = r_int; } } } break; case DriverType.PCINative: foreach (var r in root) { if (r.Name == "interrupt" && (r.Value is tysos.Resources.InterruptLine)) { var r_int = r.Value as tysos.Resources.InterruptLine; if (r_int.ShortName.StartsWith("PCI")) { pri_int = r_int; sec_int = r_int; break; } } } break; } /* Create child devices */ if (pri_cmd.Length64 != 0 && pri_ctrl.Length64 != 0 && pri_int != null) { CreateChannel(0, pri_cmd, pri_ctrl, pri_int); } if (sec_cmd.Length64 != 0 && sec_ctrl.Length64 != 0 && sec_int != null) { CreateChannel(1, sec_cmd, sec_ctrl, sec_int); } root.Add(new File.Property { Name = "class", Value = "bus" }); Tags.Add("class"); return(true); }