Skip to content

Instantly share code, notes, and snippets.

@imbushuo
Last active November 17, 2020 10:13
Show Gist options
  • Save imbushuo/b072dcacbf1edc47b3f623a9ef50a2b1 to your computer and use it in GitHub Desktop.
Save imbushuo/b072dcacbf1edc47b3f623a9ef50a2b1 to your computer and use it in GitHub Desktop.
Third party Windows interrupt controller support if you are brave enough

Extracted from Windows public symbol, with a bit guessing. Function prototypes are not fully understood yet.

You still need your own way to hook your things into HAL.dll, as interrupt controller extension is never exposed.

typedef struct _SOC_INITIALIZATION_HEADER {
    ULONG TableVersion;
    ULONG TableSize;
} SOC_INITIALIZATION_HEADER, *PSOC_INITIALIZATION_HEADER;

typedef enum _KNOWN_CONTROLLER_TYPE
{
  InterruptControllerInvalid = 0,
  InterruptControllerPic = 1,
  InterruptControllerApic = 2,
  InterruptControllerGic = 3,
  InterruptControllerGicV3 = 4,
  InterruptControllerGicV4 = 5,
  InterruptControllerBcm = 6,
  InterruptControllerUnknown = 4096,
} KNOWN_CONTROLLER_TYPE, *PKNOWN_CONTROLLER_TYPE;

typedef struct _INTERRUPT_FUNCTION_TABLE
{
  /* 0x0000 */ void* InitializeLocalUnit /* function */;
  /* 0x0008 */ void* InitializeIoUnit /* function */;
  /* 0x0010 */ void* SetPriority /* function */;
  /* 0x0018 */ void* GetLocalUnitError /* function */;
  /* 0x0020 */ void* ClearLocalUnitError /* function */;
  /* 0x0028 */ void* GetLogicalId /* function */;
  /* 0x0030 */ void* SetLogicalId /* function */;
  /* 0x0038 */ void* AcceptAndGetSource /* function */;
  /* 0x0040 */ void* EndOfInterrupt /* function */;
  /* 0x0048 */ void* FastEndOfInterrupt /* function */;
  /* 0x0050 */ void* SetLineState /* function */;
  /* 0x0058 */ void* RequestInterrupt /* function */;
  /* 0x0060 */ void* StartProcessor /* function */;
  /* 0x0068 */ void* GenerateMessage /* function */;
  /* 0x0070 */ void* ConvertId /* function */;
  /* 0x0078 */ void* SaveLocalInterrupts /* function */;
  /* 0x0080 */ void* ReplayLocalInterrupts /* function */;
  /* 0x0088 */ void* DeinitializeLocalUnit /* function */;
  /* 0x0090 */ void* DeinitializeIoUnit /* function */;
  /* 0x0098 */ void* QueryAndGetSource /* function */;
  /* 0x00a0 */ void* DeactivateInterrupt /* function */;
} INTERRUPT_FUNCTION_TABLE, *PINTERRUPT_FUNCTION_TABLE; /* size: 0x00a8 */

typedef struct _INTERRUPT_CONTROLLER_INITIALIZATION_BLOCK {
  /* 0 */ SOC_INITIALIZATION_HEADER Header;
  /* 8 */ INTERRUPT_FUNCTION_TABLE InterruptFunctions;
  /* 176 */ void* InternalData;
  /* 184 */ unsigned int InternalDataSize;
  /* 188 */ KNOWN_CONTROLLER_TYPE InterruptControllerType;
  /* 192 */ unsigned int UnitId;
  /* 196 */ unsigned int Capabilities;
  /* 200 */ unsigned int MaxPriority;
  /* 204 */ unsigned int MaxClusterSize;
  /* 208 */ unsigned int MaxClusters;
  /* 212 */ unsigned int InterruptReplayDataSize;
} INTERRUPT_CONTROLLER_INITIALIZATION_BLOCK, *PINTERRUPT_CONTROLLER_INITIALIZATION_BLOCK;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment