public IOGroup(PCIDeviceNormal device) { RegisterAddress = new IOPort((ushort)device.BaseAddresses[0].BaseAddress(), 0x14); RegisterData = new IOPort((ushort)device.BaseAddresses[0].BaseAddress(), 0x10); BusData = new IOPort((ushort)device.BaseAddresses[0].BaseAddress(), 0x1C); MAC1 = new IOPortRead((ushort)device.BaseAddresses[0].BaseAddress(), 0x00); MAC2 = new IOPortRead((ushort)device.BaseAddresses[0].BaseAddress(), 0x04); }
public void Halt() { } // Plugged public void Reboot() { // Disable all interrupts DisableInterrupts(); var myPort = new IOPort(0x64); while ((myPort.Byte & 0x02) != 0) { } myPort.Byte = 0xFE; Halt(); // If it didn't work, Halt the CPU }
public override void Initialize() { device = (PCIDeviceNormal)Cosmos.Core.PCI.GetDevice(0x15AD, 0x0405); device.EnableMemory(true); uint basePort = device.BaseAddresses[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)); InitializeFIFO(); }
internal static bool Init() { byte *ptr = (byte *)RSDPAddress(); int addr = 0; for (int i = 19; i >= 16; i--) { addr += (*((byte *)ptr + i)); addr = (i == 16) ? addr : addr << 8; } ptr = (byte *)addr; ptr += 4; addr = 0; for (int i = 3; i >= 0; i--) { addr += (*((byte *)ptr + i)); addr = (i == 0) ? addr : addr << 8; } int length = addr; ptr -= 4; if (ptr != null && acpiCheckHeader((byte *)ptr, "RSDT") == 0) { addr = 0; int entrys = length; entrys = (entrys - 36) / 4; ptr += 36; byte *yeuse; while (0 < entrys--) { for (int i = 3; i >= 0; i--) { addr += (*((byte *)ptr + i)); addr = (i == 0) ? addr : addr << 8; } yeuse = (byte *)addr; Facp = (byte *)yeuse; if (Compare("FACP", Facp) == 0) { if (acpiCheckHeader((byte *)facpget(0), "DSDT") == 0) { byte *S5Addr = (byte *)facpget(0) + 36; int dsdtLength = *(facpget(0) + 1) - 36; while (0 < dsdtLength--) { if (Compare("_S5_", (byte *)S5Addr) == 0) { break; } S5Addr++; } if (dsdtLength > 0) { if ((*(S5Addr - 1) == 0x08 || (*(S5Addr - 2) == 0x08 && *(S5Addr - 1) == '\\')) && *(S5Addr + 4) == 0x12) { S5Addr += 5; S5Addr += ((*S5Addr & 0xC0) >> 6) + 2; if (*S5Addr == 0x0A) { S5Addr++; } SLP_TYPa = (short)(*(S5Addr) << 10); S5Addr++; if (*S5Addr == 0x0A) { S5Addr++; } SLP_TYPb = (short)(*(S5Addr) << 10); SMI_CMD = facpget(1); ACPI_ENABLE = facpbget(0); ACPI_DISABLE = facpbget(1); PM1a_CNT = facpget(2); PM1b_CNT = facpget(3); PM1_CNT_LEN = facpbget(3); SLP_EN = 1 << 13; SCI_EN = 1; smiIO = new IOPort((ushort)SMI_CMD); pm1aIO = new IOPort((ushort)PM1a_CNT); pm1bIO = new IOPort((ushort)PM1b_CNT); return(true); } } } } ptr += 4; } } return(false); }
/// <summary> /// Writes a 16 bit word /// </summary> /// <param name="port"></param> /// <param name="data"></param> public static void OutW(ushort port, ushort data) { var io = new IOPort(port); io.Word = data; }
/// <summary> /// Writes a 32 bit word /// </summary> /// <param name="port"></param> /// <param name="data"></param> public static void OutD(ushort port, uint data) { var io = new IOPort(port); io.DWord = data; }
/// <summary> /// Writes a byte /// </summary> /// <param name="port"></param> /// <param name="data"></param> public static void OutB(ushort port, byte data) { var io = new IOPort(port); io.Byte = data; }
/// <summary> /// Reads a 16 bit word /// </summary> /// <param name="port"></param> /// <returns></returns> public static ushort InW(ushort port) { var io = new IOPort(port); return(io.Word); }
/// <summary> /// Reads a 32 bit word /// </summary> /// <param name="port"></param> /// <returns></returns> public static uint InD(ushort port) { var io = new IOPort(port); return(io.DWord); }
/// <summary> /// Reads a byte /// </summary> /// <param name="port"></param> /// <returns></returns> public static byte InB(ushort port) { var io = new IOPort(port); return(io.Byte); }
public VMWareSVGAII() { device = (PCIDeviceNormal)(Cosmos.HAL.PCI.GetDevice(0x15AD, 0x0405)); device.EnableMemory(true); uint basePort = device.BaseAddresses[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(); }
/// <summary> /// Disable ACPI. /// </summary> public static void Disable() { smiIO = new IOPort(ACPI_DISABLE); }
/// <summary> /// Enable ACPI. /// </summary> public static void Enable() { smiIO = new IOPort(ACPI_ENABLE); }
public static bool Init() { byte *ptr = (byte *)RSDPAddress(); int addr = 0; for (int i = 19; i >= 16; i--) { addr += (*((byte *)ptr + i)); addr = (i == 16) ? addr : addr << 8; } ptr = (byte *)addr; ptr += 4; addr = 0; for (int i = 3; i >= 0; i--) { addr += (*((byte *)ptr + i)); addr = (i == 0) ? addr : addr << 8; } int length = addr; ptr -= 4; // check if address is correct ( if acpi is available on pc ) if (ptr != null && acpiCheckHeader((byte *)ptr, "RSDT") == 0) { addr = 0; // the RSDT contains an unknown number of pointers to acpi tables int entrys = length; entrys = (entrys - 36) / 4; ptr += 36; // skip header information byte *yeuse; while (0 < entrys--) { for (int i = 3; i >= 0; i--) { addr += (*((byte *)ptr + i)); addr = (i == 0) ? addr : addr << 8; } yeuse = (byte *)addr; // check if the desired table is reached Facp = (byte *)yeuse; if (Compare("FACP", Facp) == 0) { if (acpiCheckHeader((byte *)facpget(0), "DSDT") == 0) { // search the \_S5 package in the DSDT byte *S5Addr = (byte *)facpget(0) + 36; // skip header int dsdtLength = *(facpget(0) + 1) - 36; while (0 < dsdtLength--) { if (Compare("_S5_", (byte *)S5Addr) == 0) { break; } S5Addr++; } // check if \_S5 was found if (dsdtLength > 0) { // check for valid AML structure if ((*(S5Addr - 1) == 0x08 || (*(S5Addr - 2) == 0x08 && *(S5Addr - 1) == '\\')) && *(S5Addr + 4) == 0x12) { S5Addr += 5; S5Addr += ((*S5Addr & 0xC0) >> 6) + 2; // calculate PkgLength size if (*S5Addr == 0x0A) { S5Addr++; // skip byteprefix } SLP_TYPa = (short)(*(S5Addr) << 10); S5Addr++; if (*S5Addr == 0x0A) { S5Addr++; // skip byteprefix } SLP_TYPb = (short)(*(S5Addr) << 10); SMI_CMD = facpget(1); ACPI_ENABLE = facpbget(0); ACPI_DISABLE = facpbget(1); PM1a_CNT = facpget(2); PM1b_CNT = facpget(3); PM1_CNT_LEN = facpbget(3); SLP_EN = 1 << 13; SCI_EN = 1; smiIO = new IOPort((ushort)SMI_CMD); pm1aIO = new IOPort((ushort)PM1a_CNT); pm1bIO = new IOPort((ushort)PM1b_CNT); return(true); } else { //Console.Write("\\_S5 parse error.\n"); } } else { // Console.Write("\\_S5 not present.\n"); } } else { // Console.Write("DSDT invalid.\n"); } } ptr += 4; } //Console.Write("no valid FACP present.\n"); } return(false); }