//Sets up this hardware device driver. public bool Setup() { byte portBar = 0; vgaEnableController = new Cosmos.Core.IOPort(Register.VgaEnable, portBar); miscOutputReader = new Cosmos.Core.IOPort(Register.MiscOutRead, portBar); miscOutputWriter = new Cosmos.Core.IOPort(Register.MiscOutWrite, portBar); crtcControllerIndex = new Cosmos.Core.IOPort(Register.CrtcIndex, portBar); crtcControllerData = new Cosmos.Core.IOPort(Register.CrtcData, portBar); seqControllerIndex = new Cosmos.Core.IOPort(Register.SequenceIndex, portBar); seqControllerData = new Cosmos.Core.IOPort(Register.SequenceData, portBar); // Everything went well return(true); }
private static void SetupPower(byte *ptr) { 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 && Compare("RSDT", (byte *)ptr) == 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 (Compare("DSDT", (byte *)facpget(0)) == 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 Cosmos.Core.IOPort((ushort)SMI_CMD); pm1aIO = new Cosmos.Core.IOPort((ushort)PM1a_CNT); pm1bIO = new Cosmos.Core.IOPort((ushort)PM1b_CNT); } } } } ptr += 4; } } }