private void Remap(byte masterStart, byte masterMask, byte slaveStart, byte slaveMask) { #region consts // source: osdev.org #pragma warning disable const byte ICW1_ICW4 = 0x01; // ICW4 (not) needed const byte ICW1_SINGLE = 0x02; // Single (cascade) mode const byte ICW1_INTERVAL4 = 0x04; // Call address interval 4 (8) const byte ICW1_LEVEL = 0x08; // Level triggered (edge) mode const byte ICW1_INIT = 0x10; const byte ICW4_8086 = 0x01; // 8086/88 mode const byte ICW4_AUTO = 0x02; // auto (normal) EOI const byte ICW4_BUF_SLAVE = 0x08; // buffered mode/slave const byte ICW4_BUF_MASTER = 0x0C; // buffered mode/master const byte ICW4_SFNM = 0x10; // special fully nested (not) #pragma warning restore #endregion var xOldMasterMask = Master.Data.Byte; var xOldSlaveMask = Slave.Data.Byte; Master.Cmd.Byte = ICW1_INIT + ICW1_ICW4; IOPort.Wait(); Slave.Cmd.Byte = ICW1_INIT + ICW1_ICW4; IOPort.Wait(); Master.Data.Byte = masterStart; IOPort.Wait(); Slave.Data.Byte = slaveStart; IOPort.Wait(); // magic: Master.Data.Byte = 4; IOPort.Wait(); Slave.Data.Byte = 2; IOPort.Wait(); // set modes: Master.Data.Byte = ICW4_8086; IOPort.Wait(); Slave.Data.Byte = ICW4_8086; IOPort.Wait(); // set masks: Master.Data.Byte = masterMask; IOPort.Wait(); //Slave.Data.Byte = slaveMask; //IOPort.Wait(); }
protected void Init(IOGroup.PIC aPIC, byte aBase, byte aIDunno, byte aMask) { // We need to remap the PIC interrupt lines to the CPU. The BIOS sets // them in a way compatible for 16 bit mode, but in a way that causes problems // for 32 bit mode. // The only way to remap them however is to completely reinitialize the PICs. byte xOldMask = aPIC.Data.Byte; //#define ICW1_ICW4 0x01 /* ICW4 (not) needed */ //#define ICW1_SINGLE 0x02 /* Single (cascade) mode */ //#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */ //#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */ Master.Cmd.Byte = (byte)Cmd.Init | 0x01; IOPort.Wait(); // ICW2 Master.Data.Byte = aBase; IOPort.Wait(); // ICW3 // Somehow tells them about master/slave relationship Master.Data.Byte = aIDunno; IOPort.Wait(); //#define ICW4_AUTO 0x02 /C:\Data\Cosmos\source2\Kernel\System\Hardware\Core\Cosmos.Core\CPU.cs* Auto (normal) EOI */ //#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */ //#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */ //#define ICW4_SFNM 0x10 /* Special fully nested (not) */ //0x01 8086/88 (MCS-80/85) mode Master.Data.Byte = 0x01; IOPort.Wait(); // Set mask Master.Data.Byte = aMask; IOPort.Wait(); }