File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,30 @@ public struct IRQContext {
239239 /// </summary>
240240 private static IRQDelegate [ ] mIRQ_Handlers = new IRQDelegate [ 256 ] ;
241241
242+ /// Masks or Un-Masks an interupt address.
243+ /// Source: https://wiki.osdev.org/8259_PIC
244+ /// </summary>
245+ /// <param name="aIRQLine">Interupt to unmask.</param>
246+ /// <param name="aDoMask">True = Mask, False = Unmask.</param>
247+ public static void SetIRQMaskState ( byte aIRQLine , bool aDoMask )
248+ {
249+ ushort Port = ( ushort ) ( aIRQLine < 8 ? 0x21 : 0xA1 ) ;
250+
251+ if ( aIRQLine >= 8 )
252+ {
253+ aIRQLine -= 8 ;
254+ }
255+
256+ if ( aDoMask )
257+ {
258+ IOPort . Write8 ( Port , ( byte ) ( IOPort . Read8 ( Port ) | ( 1 << aIRQLine ) ) ) ;
259+ }
260+ else
261+ {
262+ IOPort . Write8 ( Port , ( byte ) ( IOPort . Read8 ( Port ) & ~ ( 1 << aIRQLine ) ) ) ;
263+ }
264+ }
265+
242266 // We used to use:
243267 //Interrupts.IRQ01 += HandleKeyboardInterrupt;
244268 // But at one point we had issues with multi cast delegates, so we changed to this single cast option.
You can’t perform that action at this time.
0 commit comments