@@ -45,14 +45,71 @@ public IsaBridgeGigabyteController(uint address, Vendor vendor)
4545 /// <returns>true on success</returns>
4646 public bool Enable ( bool enabled )
4747 {
48- // TODO: Intel
4948 return _vendor switch
5049 {
50+ Vendor . Intel => IntelEnable ( enabled ) ,
5151 Vendor . AMD => AmdEnable ( enabled ) ,
5252 _ => false
5353 } ;
5454 }
5555
56+ private bool IntelEnable ( bool enabled )
57+ {
58+ if ( ! Mutexes . WaitPciBus ( 10 ) )
59+ return false ;
60+
61+ bool result = false ;
62+
63+ uint intelIsaBridgeAddress = Ring0 . GetPciAddress ( 0x0 , 0x1F , 0x0 ) ;
64+
65+ const uint ioOrMemoryPortDecodeEnableRegister = 0xD8 ;
66+ const uint romAddressRange2Register = 0x98 ;
67+
68+ uint controllerFanControlAddress = _controllerBaseAddress + ControllerFanControlArea ;
69+
70+ Ring0 . ReadPciConfig ( intelIsaBridgeAddress , ioOrMemoryPortDecodeEnableRegister , out uint originalDecodeEnableRegister ) ;
71+ Ring0 . ReadPciConfig ( intelIsaBridgeAddress , romAddressRange2Register , out uint originalRomAddressRegister ) ;
72+
73+ bool originalMmIoEnabled = false ;
74+ if ( ! enabled )
75+ {
76+ originalMmIoEnabled = ( ( int ) originalDecodeEnableRegister & 1 ) == 0 || ( ( int ) originalRomAddressRegister & 1 ) == 1 ;
77+ }
78+ else
79+ {
80+ originalMmIoEnabled = ( ( int ) originalDecodeEnableRegister & 1 ) == 0 && ( ( int ) originalRomAddressRegister & 1 ) == 1 ;
81+ }
82+
83+ if ( enabled == originalMmIoEnabled )
84+ {
85+ result = Enable ( enabled , new IntPtr ( controllerFanControlAddress ) ) ;
86+ Mutexes . ReleasePciBus ( ) ;
87+ return result ;
88+ }
89+
90+ uint lpcBiosDecodeEnable ;
91+ uint lpcMemoryRange ;
92+ if ( enabled )
93+ {
94+ lpcBiosDecodeEnable = ioOrMemoryPortDecodeEnableRegister & ~ ( uint ) ( 1 << 0 ) ;
95+ lpcMemoryRange = romAddressRange2Register | ( uint ) ( 1 << 0 ) ;
96+ }
97+ else
98+ {
99+ lpcBiosDecodeEnable = Convert . ToUInt32 ( ioOrMemoryPortDecodeEnableRegister | ( uint ) ( 1 << 0 ) ) ;
100+ lpcMemoryRange = Convert . ToUInt32 ( romAddressRange2Register & ~ ( uint ) ( 1 << 0 ) ) ;
101+ }
102+
103+ Ring0 . WritePciConfig ( intelIsaBridgeAddress , ioOrMemoryPortDecodeEnableRegister , lpcBiosDecodeEnable ) ;
104+ Ring0 . WritePciConfig ( intelIsaBridgeAddress , romAddressRange2Register , lpcMemoryRange ) ;
105+
106+ result = Enable ( enabled , new IntPtr ( controllerFanControlAddress ) ) ;
107+
108+ Mutexes . ReleasePciBus ( ) ;
109+
110+ return result ;
111+ }
112+
56113 private bool AmdEnable ( bool enabled )
57114 {
58115 if ( ! Mutexes . WaitPciBus ( 10 ) )
0 commit comments