int _init(void) { int error = EBUSY; int status; extern int (*acpi_fp_setwake)(); extern kmutex_t cpu_map_lock; mutex_init(&acpica_module_lock, NULL, MUTEX_DRIVER, NULL); mutex_init(&cpu_map_lock, NULL, MUTEX_SPIN, (ddi_iblock_cookie_t)ipltospl(DISP_LEVEL)); if ((error = mod_install(&modlinkage)) != 0) { mutex_destroy(&acpica_module_lock); goto load_error; } AcpiGbl_EnableInterpreterSlack = (acpica_enable_interpreter_slack != 0); /* global ACPI CA initialization */ if (ACPI_FAILURE(status = AcpiInitializeSubsystem())) cmn_err(CE_WARN, "!AcpiInitializeSubsystem failed: %d", status); /* initialize table manager */ if (ACPI_FAILURE(status = AcpiInitializeTables(NULL, 0, 0))) cmn_err(CE_WARN, "!AcpiInitializeTables failed: %d", status); acpi_fp_setwake = acpica_ddi_setwake; load_error: return (error); }
PRIVATE ACPI_STATUS init_acpica(void) { ACPI_STATUS status; status = AcpiInitializeSubsystem(); if (ACPI_FAILURE(status)) return status; status = AcpiInitializeTables(NULL, 16, FALSE); if (ACPI_FAILURE(status)) return status; status = AcpiLoadTables(); if (ACPI_FAILURE(status)) return status; status = AcpiEnableSubsystem(0); if (ACPI_FAILURE(status)) return status; status = AcpiInitializeObjects(0); if (ACPI_FAILURE(status)) return status; set_machine_mode(); pci_scan_devices(); return AE_OK; }
/* * This function would be called after the kernel is initialized and * dynamic/virtual memory is available. It completes the initialization of * the ACPICA subsystem. */ ACPI_STATUS InitializeAcpi ( void) { ACPI_STATUS Status; /* Initialize the ACPICA subsystem */ AcpiGbl_OverrideDefaultRegionHandlers = TRUE; Status = AcpiInitializeSubsystem (); if (ACPI_FAILURE (Status)) { return (Status); } /* Copy the root table list to dynamic memory */ Status = AcpiReallocateRootTable (); if (ACPI_FAILURE (Status)) { return (Status); } /* Install local handlers */ Status = InstallHandlers (); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While installing handlers")); return (Status); } /* Initialize the ACPI hardware */ Status = AcpiEnableSubsystem (ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE (Status)) { return (Status); } /* Create the ACPI namespace from ACPI tables */ Status = AcpiLoadTables (); if (ACPI_FAILURE (Status)) { return (Status); } /* Complete the ACPI namespace object initialization */ Status = AcpiInitializeObjects (ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE (Status)) { return (Status); } return (AE_OK); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; int j; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Init debug globals and ACPICA */ AcpiDbgLevel = ACPI_LV_TABLES; AcpiDbgLayer = 0xFFFFFFFF; Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { return (-1); } printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); if (argc < 2) { usage (); return (0); } /* Get the command line options */ while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'v': /* -v: (Version): signon already emitted, just exit */ return (0); case '?': case 'h': default: usage(); return (0); } /* * The next argument is the filename for the DSDT or SSDT. * Open the file, build namespace and dump it. */ return (NsDumpEntireNamespace (argv[AcpiGbl_Optind])); }
NTSTATUS Bus_StartFdo ( PFDO_DEVICE_DATA FdoData, PIRP Irp ) { NTSTATUS status = STATUS_SUCCESS; POWER_STATE powerState; ACPI_STATUS AcpiStatus; PAGED_CODE (); FdoData->Common.DevicePowerState = PowerDeviceD0; powerState.DeviceState = PowerDeviceD0; PoSetPowerState ( FdoData->Common.Self, DevicePowerState, powerState ); SET_NEW_PNP_STATE(FdoData->Common, Started); AcpiStatus = AcpiInitializeSubsystem(); if(ACPI_FAILURE(AcpiStatus)){ DPRINT1("Unable to AcpiInitializeSubsystem\n"); return STATUS_UNSUCCESSFUL; } AcpiStatus = AcpiInitializeTables(NULL, 16, 0); if (ACPI_FAILURE(status)){ DPRINT1("Unable to AcpiInitializeSubsystem\n"); return STATUS_UNSUCCESSFUL; } AcpiStatus = AcpiLoadTables(); if(ACPI_FAILURE(AcpiStatus)){ DPRINT1("Unable to AcpiLoadTables\n"); AcpiTerminate(); return STATUS_UNSUCCESSFUL; } DPRINT("Acpi subsystem init\n"); /* Initialize ACPI bus manager */ AcpiStatus = acpi_init(); if (!ACPI_SUCCESS(AcpiStatus)) { DPRINT1("acpi_init() failed with status 0x%X\n", AcpiStatus); AcpiTerminate(); return STATUS_UNSUCCESSFUL; } status = ACPIEnumerateDevices(FdoData); return status; }
void acpi_init(void) { ACPI_STATUS result; result = AcpiInitializeSubsystem(); if(ACPI_FAILURE(result)) { acpi_perror("AcpiInitializeSubsystem", result); return; } else { kprintf("Acpi subsystem initialised\n"); } result = AcpiReallocateRootTable(); if(ACPI_FAILURE(result)) { acpi_perror("AcpiReallocateRootTable", result); } else { kprintf("Acpi root tables copied\n"); } result = AcpiLoadTables(); if(ACPI_FAILURE(result)) { acpi_perror("AcpiLoadTables", result); } else { kprintf("Acpi tables loaded\n"); } _acpi_tables_loaded = true; /* do stuff */ #ifdef ENABLE_ACPI_MODE result = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); if(ACPI_FAILURE(result)) { acpi_perror("AcpiEnableSubsystem", result); } else { kprintf("Acpi hardware initialized\n"); } result = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION); if(ACPI_FAILURE(result)) { acpi_perror("AcpiInitializeObjects", result); } else { kprintf("Acpi namespace objects initialized\n"); } #endif }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; int j; printf (ACPI_COMMON_SIGNON ("ACPI Namespace Dump Utility")); if (argc < 2) { usage (); return (0); } /* Init globals and ACPICA */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; AcpiDbgLayer = 0xFFFFFFFF; Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); /* Get the command line options */ while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch(j) { case '?': case 'h': default: usage(); return (0); } /* * The next argument is the filename for the DSDT or SSDT. * Open the file, build namespace and dump it. */ return (NsDumpEntireNamespace (argv[AcpiGbl_Optind])); }
static status_t acpi_std_ops(int32 op,...) { switch (op) { case B_MODULE_INIT: { ACPI_OBJECT arg; ACPI_OBJECT_LIST parameter; void *settings; bool acpiDisabled = false; AcpiGbl_CopyDsdtLocally = true; settings = load_driver_settings("kernel"); if (settings != NULL) { acpiDisabled = !get_driver_boolean_parameter(settings, "acpi", true, true); unload_driver_settings(settings); } if (!acpiDisabled) { // check if safemode settings disable ACPI settings = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS); if (settings != NULL) { acpiDisabled = get_driver_boolean_parameter(settings, B_SAFEMODE_DISABLE_ACPI, false, false); unload_driver_settings(settings); } } if (acpiDisabled) { ERROR("ACPI disabled\n"); return ENOSYS; } if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task", B_URGENT_DISPLAY_PRIORITY + 1) != B_OK) { ERROR("failed to create os execution queue\n"); return B_ERROR; } #ifdef ACPI_DEBUG_OUTPUT AcpiDbgLevel = ACPI_DEBUG_ALL | ACPI_LV_VERBOSE; AcpiDbgLayer = ACPI_ALL_COMPONENTS; #endif if (checkAndLogFailure(AcpiInitializeSubsystem(), "AcpiInitializeSubsystem failed")) goto err; if (checkAndLogFailure(AcpiInitializeTables(NULL, 0, TRUE), "AcpiInitializeTables failed")) goto err; if (checkAndLogFailure(AcpiLoadTables(), "AcpiLoadTables failed")) goto err; /* Install the default address space handlers. */ if (checkAndLogFailure(AcpiInstallAddressSpaceHandler( ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL), "Could not initialise SystemMemory handler:")) goto err; if (checkAndLogFailure(AcpiInstallAddressSpaceHandler( ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL), "Could not initialise SystemIO handler:")) goto err; if (checkAndLogFailure(AcpiInstallAddressSpaceHandler( ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL), "Could not initialise PciConfig handler:")) goto err; arg.Integer.Type = ACPI_TYPE_INTEGER; arg.Integer.Value = apic_available() ? APIC_MODE : PIC_MODE; parameter.Count = 1; parameter.Pointer = &arg; AcpiEvaluateObject(NULL, "\\_PIC", ¶meter, NULL); if (checkAndLogFailure(AcpiEnableSubsystem( ACPI_FULL_INITIALIZATION), "AcpiEnableSubsystem failed")) goto err; if (checkAndLogFailure(AcpiInitializeObjects( ACPI_FULL_INITIALIZATION), "AcpiInitializeObjects failed")) goto err; //TODO: Walk namespace init ALL _PRW's #ifdef ACPI_DEBUG_OUTPUT checkAndLogFailure( AcpiInstallGlobalEventHandler(globalGPEHandler, NULL), "Failed to install global GPE-handler."); checkAndLogFailure(AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, ACPI_ALL_NOTIFY, globalNotifyHandler, NULL), "Failed to install global Notify-handler."); #endif checkAndLogFailure(AcpiEnableAllRuntimeGpes(), "Failed to enable all runtime Gpes"); checkAndLogFailure(AcpiUpdateAllGpes(), "Failed to update all Gpes"); TRACE("ACPI initialized\n"); return B_OK; err: return B_ERROR; } case B_MODULE_UNINIT: { if (checkAndLogFailure(AcpiTerminate(), "Could not bring system out of ACPI mode. Oh well.")); gDPC->delete_dpc_queue(gDPCHandle); gDPCHandle = NULL; break; } default: return B_ERROR; } return B_OK; }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; UINT32 InitFlags; ACPI_TABLE_HEADER *Table = NULL; UINT32 TableCount; AE_TABLE_DESC *TableDesc; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ signal (SIGINT, AeCtrlCHandler); /* Init debug globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* Init ACPICA and start debugger thread */ Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; } printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); if (argc < 2) { usage (); (void) AcpiOsTerminate (); return (0); } /* Get the command line options */ if (AeDoOptions (argc, argv)) { goto ErrorExit; } /* The remaining arguments are filenames for ACPI tables */ if (!argv[AcpiGbl_Optind]) { goto EnterDebugger; } AcpiGbl_DbOpt_tables = TRUE; AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */ TableCount = 0; /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Get one entire table */ Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get table from file %s, %s\n", argv[AcpiGbl_Optind], AcpiFormatException (Status)); goto ErrorExit; } /* Ignore non-AML tables, we can't use them. Except for an FADT */ if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && !AcpiUtIsAmlTable (Table)) { ACPI_INFO ((AE_INFO, "Table [%4.4s] is not an AML table, ignoring", Table->Signature)); AcpiOsFree (Table); } else { /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); TableDesc->Table = Table; TableDesc->Next = AeTableListHead; AeTableListHead = TableDesc; TableCount++; } AcpiGbl_Optind++; } printf ("\n"); /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (TableCount, AeTableListHead); if (ACPI_FAILURE (Status)) { goto ErrorExit; } Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install most of the handlers. * Override some default region handlers, especially SystemMemory */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto EnterDebugger; } /* Setup initialization flags for ACPICA */ InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); if (!AcpiGbl_DbOpt_ini_methods) { InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* * Main initialization for ACPICA subsystem * TBD: Need a way to call this after the ACPI table "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install handlers for "device driver" space IDs (EC,SMBus, etc.) * and fixed event handlers */ AeInstallLateHandlers (); /* Finish the ACPICA initialization */ Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } AeMiscellaneousTests (); EnterDebugger: /* Exit if error above and we are in one of the batch modes */ if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) { goto ErrorExit; } /* Run a batch command or enter the command loop */ switch (AcpiGbl_ExecutionMode) { default: case AE_MODE_COMMAND_LOOP: AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); break; case AE_MODE_BATCH_MULTIPLE: AcpiDbRunBatchMode (); break; case AE_MODE_BATCH_SINGLE: AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); Status = AcpiTerminate (); break; } return (0); ErrorExit: (void) AcpiOsTerminate (); return (-1); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; int j; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Init debug globals and ACPICA */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; AcpiDbgLayer = 0xFFFFFFFF; /* Set flags so that the interpreter is not used */ Status = AcpiInitializeSubsystem (); ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { return (-1); } printf (ACPI_COMMON_SIGNON (AN_UTILITY_NAME)); if (argc < 2) { usage (); return (0); } /* Get the command line options */ while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j) { case 'l': AcpiGbl_NsLoadOnly = TRUE; break; case 'v': switch (AcpiGbl_Optarg[0]) { case '^': /* -v: (Version): signon already emitted, just exit */ exit (0); case 'd': printf (ACPI_COMMON_BUILD_TIME); return (0); default: printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); return (-1); } break; case 'x': AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); break; case '?': case 'h': default: usage(); return (0); } /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Get all ACPI AML tables in this file */ Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { return (-1); } AcpiGbl_Optind++; } printf ("\n"); /* * The next argument is the filename for the DSDT or SSDT. * Open the file, build namespace and dump it. */ return (AnDumpEntireNamespace (ListHead)); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; UINT32 InitFlags; int ExitCode = 0; ACPI_DEBUG_INITIALIZE (); /* For debug version only */ signal (SIGINT, AeCtrlCHandler); /* Init debug globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* * Initialize ACPICA and start debugger thread. * * NOTE: After ACPICA initialization, AcpiTerminate MUST be called * before this procedure exits -- otherwise, the console may be * left in an incorrect state. */ Status = AcpiInitializeSubsystem (); ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; } /* ACPICA runtime configuration */ AcpiGbl_MaxLoopIterations = 400; /* Initialize the AML debugger */ Status = AcpiInitializeDebugger (); ACPI_CHECK_OK (AcpiInitializeDebugger, Status); if (ACPI_FAILURE (Status)) { goto ErrorExit; } printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME)); if (argc < 2) { usage (); goto NormalExit; } /* Get the command line options */ ExitCode = AeDoOptions (argc, argv); if (ExitCode) { if (ExitCode > 0) { ExitCode = 0; } goto ErrorExit; } /* The remaining arguments are filenames for ACPI tables */ if (!argv[AcpiGbl_Optind]) { goto EnterDebugger; } AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */ /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Get all ACPI AML tables in this file */ Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind], ACPI_GET_ALL_TABLES, &ListHead); if (ACPI_FAILURE (Status)) { ExitCode = -1; goto ErrorExit; } AcpiGbl_Optind++; } printf ("\n"); /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (ListHead); if (ACPI_FAILURE (Status)) { goto ErrorExit; } /* Install all of the ACPI tables */ Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not install ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install most of the handlers (Regions, Notify, Table, etc.) * Override the default region handlers, especially SystemMemory, * which is simulated in this utility. */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto EnterDebugger; } /* Setup initialization flags for ACPICA */ InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); if (AcpiGbl_DbOpt_NoIniMethods) { InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* * Main initialization for ACPICA subsystem * TBD: Need a way to call this after the ACPI table "LOAD" command? * * NOTE: This initialization does not match the _Lxx and _Exx methods * to individual GPEs, as there are no real GPEs when the hardware * is simulated - because there is no namespace until AeLoadTables is * executed. This may have to change if AcpiExec is ever run natively * on actual hardware (such as under UEFI). */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } Status = AeLoadTables (); /* * Exit namespace initialization for the "load namespace only" option. * No control methods will be executed. However, still enter the * the debugger. */ if (AcpiGbl_AeLoadOnly) { goto EnterDebugger; } if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install handlers for "device driver" space IDs (EC,SMBus, etc.) * and fixed event handlers */ AeInstallLateHandlers (); /* Finish the ACPICA initialization */ Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } AeMiscellaneousTests (); EnterDebugger: /* Exit if error above and we are in one of the batch modes */ if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) { goto ErrorExit; } /* Run a batch command or enter the command loop */ switch (AcpiGbl_ExecutionMode) { default: case AE_MODE_COMMAND_LOOP: AcpiRunDebugger (NULL); break; case AE_MODE_BATCH_MULTIPLE: AcpiRunDebugger (BatchBuffer); break; case AE_MODE_BATCH_SINGLE: AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); break; } /* Shut down the debugger and ACPICA */ AcpiTerminateDebugger (); NormalExit: ExitCode = 0; ErrorExit: (void) AcpiOsTerminate (); return (ExitCode); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { ACPI_STATUS Status; UINT32 InitFlags; ACPI_TABLE_HEADER *Table = NULL; UINT32 TableCount; AE_TABLE_DESC *TableDesc; char **WildcardList; char *Filename; char *Directory; char *FullPathname; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif printf (ACPI_COMMON_SIGNON ("AML Execution/Debug Utility")); if (argc < 2) { usage (); return (0); } signal (SIGINT, AeCtrlCHandler); /* Init globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* Init ACPI and start debugger thread */ Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { return (-1); } /* Get the command line options */ if (AeDoOptions (argc, argv)) { return (-1); } /* The remaining arguments are filenames for ACPI tables */ if (argv[AcpiGbl_Optind]) { AcpiGbl_DbOpt_tables = TRUE; TableCount = 0; /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Split incoming path into a directory/filename combo */ Status = FlSplitInputPathname (argv[AcpiGbl_Optind], &Directory, &Filename); if (ACPI_FAILURE (Status)) { return (-1); } /* Expand wildcards (Windows only) */ WildcardList = AsDoWildcard (Directory, Filename); if (!WildcardList) { return (-1); } while (*WildcardList) { FullPathname = AcpiOsAllocate ( strlen (Directory) + strlen (*WildcardList) + 1); /* Construct a full path to the file */ strcpy (FullPathname, Directory); strcat (FullPathname, *WildcardList); /* Get one table */ Status = AcpiDbReadTableFromFile (FullPathname, &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get input table %s, %s\n", FullPathname, AcpiFormatException (Status)); goto EnterDebugger; } AcpiOsFree (FullPathname); AcpiOsFree (*WildcardList); *WildcardList = NULL; WildcardList++; /* Ignore non-AML tables, we can't use them. Except for an FADT */ if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && !AcpiUtIsAmlTable (Table)) { ACPI_WARNING ((AE_INFO, "Table %4.4s is not an AML table, ignoring", Table->Signature)); AcpiOsFree (Table); continue; } /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); TableDesc->Table = Table; TableDesc->Next = AeTableListHead; AeTableListHead = TableDesc; TableCount++; } AcpiGbl_Optind++; } /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (TableCount, AeTableListHead); if (ACPI_FAILURE (Status)) { return (-1); } Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install most of the handlers. * Override some default region handlers, especially SystemMemory */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto EnterDebugger; } /* Setup initialization flags for ACPICA */ InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); if (!AcpiGbl_DbOpt_ini_methods) { InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* * Main initialization for ACPICA subsystem * TBD: Need a way to call this after the ACPI table "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); goto EnterDebugger; } /* * Install handlers for "device driver" space IDs (EC,SMBus, etc.) * and fixed event handlers */ AeInstallLateHandlers (); AeMiscellaneousTests (); } EnterDebugger: /* Exit if error above and we are in one of the batch modes */ if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) { return (-1); } /* Run a batch command or enter the command loop */ switch (AcpiGbl_ExecutionMode) { default: case AE_MODE_COMMAND_LOOP: AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); break; case AE_MODE_BATCH_MULTIPLE: AcpiDbRunBatchMode (); break; case AE_MODE_BATCH_SINGLE: AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); break; } return (0); }
void kmain2() { kprintf("Initializing SDI... "); sdInit(); kprintf("%$\x02" "Done%#\n"); initMount(); initSymtab(); kprintf("Initializing ACPICA...\n"); ACPI_STATUS status = AcpiInitializeSubsystem(); if (ACPI_FAILURE(status)) { panic("AcpiInitializeSubsystem failed"); }; status = AcpiInitializeTables(NULL, 16, FALSE); if (ACPI_FAILURE(status)) { panic("AcpiInitializeTables failed"); }; status = AcpiLoadTables(); if (ACPI_FAILURE(status)) { panic("AcpiLoadTables failed"); }; status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE(status)) { panic("AcpiEnableSubsystem failed"); }; status = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE(status)) { panic("AcpiInitializeObjects failed"); }; if (AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON, onPowerButton, NULL) != AE_OK) { panic("failed to register power button event"); }; pciInitACPI(); kprintf("Initializing the RTC... "); initRTC(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the network interface... "); ipreasmInit(); initNetIf(); kprintf("%$\x02" "Done%#\n"); kprintf("Starting the spawn process... "); MachineState state; void *spawnStack = kmalloc(0x1000); state.rip = (uint64_t) &spawnProc; state.rsp = (uint64_t) spawnStack + 0x1000 - 16; ((uint64_t*)state.rsp)[0] = 0; ((uint64_t*)state.rsp)[1] = 0; state.rdi = (uint64_t) spawnStack; state.rbp = 0; Regs regs; regs.cs = 8; regs.ds = 16; regs.rflags = getFlagsRegister() | (1 << 9); regs.ss = 0; threadClone(®s, 0, &state); // "Done" is displayed by the spawnProc() and that's our job done pretty much. // Mark this thread as waiting so that it never wastes any CPU time. getCurrentThread()->flags = THREAD_WAITING; };
void acpi_secondary_init(void) { ACPI_STATUS Status; ACPI_STATUS DisplayOneDevice (ACPI_HANDLE, UINT32, void *, void **); /* Complete the ACPICA initialization sequence */ Status = AcpiInitializeSubsystem (); if (ACPI_FAILURE (Status)) { DLOG_COM1 ("Failed to initialize ACPI.\n"); } Status = AcpiReallocateRootTable (); if (ACPI_FAILURE (Status)) { DLOG_COM1 ("Failed: AcpiReallocateRootTable %d.\n", Status); } Status = AcpiLoadTables (); if (ACPI_FAILURE (Status)) { DLOG_COM1 ("Failed: AcpiLoadTables.\n"); } Status = AcpiEnableSubsystem (ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE (Status)) { DLOG_COM1 ("Failed: AcpiEnableSubsystem.\n"); } Status = AcpiInitializeObjects (ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE (Status)) { DLOG_COM1 ("Failed: AcpiInitializeObjects.\n"); } /* Must enable IOAPIC before checking any PCI routing tables. */ acpi_enable_IOAPIC (); /* Install System Control Interrupt */ u8 vector = find_unused_vector (MINIMUM_VECTOR_PRIORITY); if (vector) { u64 flags = IOAPIC_DELIVERY_FIXED | IOAPIC_DESTINATION_LOGICAL; u8 gsi = acpi_sci_irq; /* SCI defaults to LEVEL/LOW in IO-APIC mode. */ if ((acpi_sci_flags & ACPI_MADT_POLARITY_MASK) == ACPI_MADT_POLARITY_ACTIVE_HIGH) flags |= IOAPIC_POLARITY_HIGH; else flags |= IOAPIC_POLARITY_LOW; if ((acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) == ACPI_MADT_TRIGGER_EDGE) flags |= IOAPIC_TRIGGER_EDGE; else flags |= IOAPIC_TRIGGER_LEVEL; if (IOAPIC_map_GSI (gsi, vector, 0x0100000000000000ULL | flags) != -1) { set_vector_handler (vector, acpi_irq_handler); DLOG ("ACPI: mapped GSI 0x%X to vector 0x%X (%s, %s)\n", gsi, vector, flags & IOAPIC_TRIGGER_LEVEL ? "level" : "edge", flags & IOAPIC_POLARITY_LOW ? "low" : "high"); } else DLOG ("ACPI: failed to map GSI\n"); } else DLOG ("ACPI: failed to find unused vector\n"); DLOG ("AcpiEnableEvent returned %d\n", AcpiEnableEvent (ACPI_EVENT_POWER_BUTTON, 0)); DLOG ("AcpiInstallFixedEventHandler returned %d\n", AcpiInstallFixedEventHandler (ACPI_EVENT_POWER_BUTTON, acpi_power_button, NULL)); DLOG ("AcpiInstallNotifyHandler returned %d\n", AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, acpi_notify_handler, NULL)); DLOG ("AcpiInstallNotifyHandler returned %d\n", AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, acpi_notify_handler, NULL)); extern u8 AcpiGbl_OsiData; AcpiGbl_OsiData=0; /* Walk the System Bus "\_SB_" and output info about each object * found. */ #if 0 ACPI_HANDLE SysBusHandle; AcpiGetHandle (ACPI_ROOT_OBJECT, ACPI_NS_SYSTEM_BUS, &SysBusHandle); AcpiWalkNamespace (ACPI_TYPE_ANY, SysBusHandle, INT_MAX, DisplayOneDevice, NULL, NULL); #else AcpiGetDevices (NULL, DisplayOneDevice, NULL, NULL); #endif }
static ACPI_STATUS InitializeFullAcpi (void) { ACPI_STATUS Status; /* Initialize the ACPICA subsystem */ Status = AcpiInitializeSubsystem (); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While initializing ACPICA")); return (Status); } /* Initialize the ACPICA Table Manager and get all ACPI tables */ Status = AcpiInitializeTables (NULL, 0, FALSE); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While initializing Table Manager")); return (Status); } /* Create the ACPI namespace from ACPI tables */ Status = AcpiLoadTables (); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While loading ACPI tables")); return (Status); } /* Install local handlers */ Status = InstallHandlers (); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While installing handlers")); return (Status); } /* Initialize the ACPI hardware */ Status = AcpiEnableSubsystem (ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While enabling ACPICA")); return (Status); } /* Complete the ACPI namespace object initialization */ Status = AcpiInitializeObjects (ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While initializing ACPICA objects")); return (Status); } return (AE_OK); }
void main(int argc, char *argv[]) { int set = -1, enable = -1; int seg = 0, bus = 0, dev = 2, fn = 0, pin = 0; ACPI_STATUS status; int verbose = 0; AcpiDbgLevel = 0; ARGBEGIN{ case 'v': AcpiDbgLevel = ACPI_LV_VERBOSITY1; verbose++; break; case 's': set = open("#P/irqmap", OWRITE); if (set < 0) sysfatal("%r"); break; default: sysfatal("usage: acpi/irq [-v] [-s]"); break; }ARGEND; status = AcpiInitializeSubsystem(); if (ACPI_FAILURE(status)) { sysfatal("Error %d\n", status); } status = AcpiInitializeTables(NULL, 0, FALSE); if (ACPI_FAILURE(status)) sysfatal("can't set up acpi tables: %d", status); if (verbose) print("init dables\n"); status = AcpiLoadTables(); if (ACPI_FAILURE(status)) sysfatal("Can't load ACPI tables: %d", status); /* from acpi: */ /* If the Hardware Reduced flag is set, machine is always in acpi mode */ AcpiGbl_ReducedHardware = 1; if (verbose) print("LOADED TABLES.\n"); status = AcpiEnableSubsystem(0); if (ACPI_FAILURE(status)) print("Probably does not matter: Can't enable ACPI subsystem"); if (verbose) print("enabled subsystem.\n"); status = AcpiInitializeObjects(0); if (ACPI_FAILURE(status)) sysfatal("Can't Initialize ACPI objects"); int picmode; status = FindIOAPICs(&picmode); if (picmode == 0) sysfatal("PANIC: Can't handle picmode 0!"); ACPI_STATUS ExecuteOSI(int pic_mode); if (verbose) print("FindIOAPICs returns status %d picmode %d\n", status, picmode); status = ExecuteOSI(picmode); CHECK_STATUS("ExecuteOSI"); failed: if (verbose) print("inited objects.\n"); if (verbose) AcpiDbgLevel |= ACPI_LV_VERBOSITY1 | ACPI_LV_FUNCTIONS; status = AcpiInitializeDebugger(); if (ACPI_FAILURE(status)) { sysfatal("Error %d\n", status); } int GetPRT(); status = GetPRT(); if (ACPI_FAILURE(status)) { sysfatal("Error %d\n", status); } while (1) { if (scanf("%x %x", &bus, &dev) < 0) break; ACPI_STATUS RouteIRQ(ACPI_PCI_ID* device, int pin, int* irq); AcpiDbgLevel = 0; ACPI_PCI_ID id = (ACPI_PCI_ID){seg, bus, dev, fn}; status = AcpiOsReadPciConfiguration (&id, 0x3d, &pin, 8); if (!ACPI_SUCCESS(status)){ printf("Can't read pin for bus %d dev %d\n", bus, dev); continue; } print("ROUTE {%d, %d, %d, %d}, pin %d\n", seg, bus, dev, fn, pin); int irq; status = RouteIRQ(&id, pin, &irq); print("status %d, irq %d\n", status, irq); AcpiDbgLevel = 0; print("echo %d %d %d %d 0x%x > /dev/irqmap", seg, bus, dev, fn, irq); //ACPI_STATUS PrintDevices(void); //status = PrintDevices(); if (set > -1) fprint(set, "%d %d %d %d 0x%x", seg, bus, dev, fn, irq); } /* we're done. Enable the IRQs we might have set up. */ enable = open("/dev/irqenable", OWRITE); if (enable < 0) sysfatal("/dev/irqenable: %r"); if (write(enable, "", 1) < 1) sysfatal("Write irqenable: %r"); exits(0); }
int ACPI_SYSTEM_XFACE main ( int argc, char **argv) { int j; ACPI_STATUS Status; UINT32 InitFlags; ACPI_TABLE_HEADER *Table = NULL; UINT32 TableCount; AE_TABLE_DESC *TableDesc; char **WildcardList; char *Filename; char *Directory; char *FullPathname; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif printf (ACPI_COMMON_SIGNON ("AML Execution/Debug Utility")); if (argc < 2) { usage (); return (0); } signal (SIGINT, AeCtrlCHandler); /* Init globals */ AcpiDbgLevel = ACPI_NORMAL_DEFAULT; AcpiDbgLayer = 0xFFFFFFFF; /* Init ACPI and start debugger thread */ Status = AcpiInitializeSubsystem (); AE_CHECK_OK (AcpiInitializeSubsystem, Status); /* Get the command line options */ while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch(j) { case 'b': if (strlen (AcpiGbl_Optarg) > 127) { printf ("**** The length of command line (%u) exceeded maximum (127)\n", (UINT32) strlen (AcpiGbl_Optarg)); return (-1); } AcpiGbl_BatchMode = 1; strcpy (BatchBuffer, AcpiGbl_Optarg); break; case 'd': switch (AcpiGbl_Optarg[0]) { case 'a': AcpiGbl_IgnoreErrors = TRUE; break; case 'i': AcpiGbl_DbOpt_ini_methods = FALSE; break; case 'o': AcpiGbl_DbOpt_NoRegionSupport = TRUE; break; case 'r': AcpiGbl_DisableAutoRepair = TRUE; break; case 't': #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiGbl_DisableMemTracking = TRUE; #endif break; default: printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); return (-1); } break; case 'e': switch (AcpiGbl_Optarg[0]) { case 'f': #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiGbl_DisplayFinalMemStats = TRUE; #endif break; case 'm': AcpiGbl_AllMethodsSerialized = TRUE; printf ("Enabling AML Interpreter serialized mode\n"); break; case 's': AcpiGbl_EnableInterpreterSlack = TRUE; printf ("Enabling AML Interpreter slack mode\n"); break; case 't': AcpiGbl_DebugTimeout = TRUE; break; default: printf ("Unknown option: -e%s\n", AcpiGbl_Optarg); return (-1); } break; case 'f': AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); break; case 'g': AcpiGbl_DbOpt_tables = TRUE; AcpiGbl_DbFilename = NULL; break; case 'm': AcpiGbl_BatchMode = 2; switch (AcpiGbl_Optarg[0]) { case '^': strcpy (BatchBuffer, "MAIN"); break; default: strcpy (BatchBuffer, AcpiGbl_Optarg); break; } break; case 'o': AcpiGbl_DbOpt_disasm = TRUE; AcpiGbl_DbOpt_stats = TRUE; break; case 'v': AcpiDbgLevel |= ACPI_LV_INIT_NAMES; break; case 'x': AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0); AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel; printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); break; case '?': case 'h': default: usage(); return (-1); } InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); if (!AcpiGbl_DbOpt_ini_methods) { InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* The remaining arguments are filenames for ACPI tables */ if (argv[AcpiGbl_Optind]) { AcpiGbl_DbOpt_tables = TRUE; TableCount = 0; /* Get each of the ACPI table files on the command line */ while (argv[AcpiGbl_Optind]) { /* Split incoming path into a directory/filename combo */ Status = FlSplitInputPathname (argv[AcpiGbl_Optind], &Directory, &Filename); if (ACPI_FAILURE (Status)) { return (Status); } /* Expand wildcards (Windows only) */ WildcardList = AsDoWildcard (Directory, Filename); if (!WildcardList) { return (-1); } while (*WildcardList) { FullPathname = AcpiOsAllocate ( strlen (Directory) + strlen (*WildcardList) + 1); /* Construct a full path to the file */ strcpy (FullPathname, Directory); strcat (FullPathname, *WildcardList); /* Get one table */ Status = AcpiDbReadTableFromFile (FullPathname, &Table); if (ACPI_FAILURE (Status)) { printf ("**** Could not get input table %s, %s\n", FullPathname, AcpiFormatException (Status)); goto enterloop; } AcpiOsFree (FullPathname); AcpiOsFree (*WildcardList); *WildcardList = NULL; WildcardList++; /* * Ignore an FACS or RSDT, we can't use them. */ if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS) || ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDT)) { AcpiOsFree (Table); continue; } /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); TableDesc->Table = Table; TableDesc->Next = AeTableListHead; AeTableListHead = TableDesc; TableCount++; } AcpiGbl_Optind++; } /* Build a local RSDT with all tables and let ACPICA process the RSDT */ Status = AeBuildLocalTables (TableCount, AeTableListHead); if (ACPI_FAILURE (Status)) { return (-1); } Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); goto enterloop; } /* * Install most of the handlers. * Override some default region handlers, especially SystemMemory */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto enterloop; } /* * TBD: Need a way to call this after the "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); goto enterloop; } Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); goto enterloop; } /* * Install handlers for "device driver" space IDs (EC,SMBus, etc.) * and fixed event handlers */ AeInstallLateHandlers (); AeMiscellaneousTests (); } enterloop: if (AcpiGbl_BatchMode == 1) { AcpiDbRunBatchMode (); } else if (AcpiGbl_BatchMode == 2) { AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); } else { /* Enter the debugger command loop */ AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); } return (0); }
void initializeBasicSystem() { ACPICA_CHECK(AcpiInitializeSubsystem()); ACPICA_CHECK(AcpiInitializeTables(nullptr, 16, FALSE)); ACPICA_CHECK(AcpiLoadTables()); frigg::infoLogger() << "thor: ACPICA initialized." << frigg::endLog; dumpMadt(); ACPI_TABLE_HEADER *madt; ACPICA_CHECK(AcpiGetTable(const_cast<char *>("APIC"), 0, &madt)); // Configure all interrupt controllers. // TODO: This should be done during thor's initialization in order to avoid races. frigg::infoLogger() << "thor: Configuring I/O APICs." << frigg::endLog; size_t offset = sizeof(ACPI_TABLE_HEADER) + sizeof(MadtHeader); while(offset < madt->Length) { auto generic = (MadtGenericEntry *)((uint8_t *)madt + offset); if(generic->type == 1) { // I/O APIC auto entry = (MadtIoEntry *)generic; assert(!entry->systemIntBase); setupIoApic(entry->mmioAddress); } offset += generic->length; } // Determine IRQ override configuration. for(int i = 0; i < 16; i++) irqOverrides[i].initialize(); offset = sizeof(ACPI_TABLE_HEADER) + sizeof(MadtHeader); while(offset < madt->Length) { auto generic = (MadtGenericEntry *)((uint8_t *)madt + offset); if(generic->type == 2) { // interrupt source override auto entry = (MadtIntOverrideEntry *)generic; // ACPI defines only ISA IRQ overrides. assert(entry->bus == 0); assert(entry->sourceIrq < 16); IrqLine line; line.gsi = entry->systemInt; auto trigger = entry->flags & OverrideFlags::triggerMask; auto polarity = entry->flags & OverrideFlags::polarityMask; if(trigger == OverrideFlags::triggerDefault && polarity == OverrideFlags::polarityDefault) { line.configuration.trigger = TriggerMode::edge; line.configuration.polarity = Polarity::high; }else{ assert(trigger != OverrideFlags::triggerDefault); assert(polarity != OverrideFlags::polarityDefault); switch(trigger) { case OverrideFlags::triggerEdge: line.configuration.trigger = TriggerMode::edge; break; case OverrideFlags::triggerLevel: line.configuration.trigger = TriggerMode::level; break; default: frigg::panicLogger() << "Illegal IRQ trigger mode in MADT" << frigg::endLog; } switch(polarity) { case OverrideFlags::polarityHigh: line.configuration.polarity = Polarity::high; break; case OverrideFlags::polarityLow: line.configuration.polarity = Polarity::low; break; default: frigg::panicLogger() << "Illegal IRQ polarity in MADT" << frigg::endLog; } } assert(!(*irqOverrides[entry->sourceIrq])); *irqOverrides[entry->sourceIrq] = line; } offset += generic->length; } // Initialize the HPET. frigg::infoLogger() << "thor: Setting up HPET." << frigg::endLog; ACPI_TABLE_HEADER *hpet_table; ACPICA_CHECK(AcpiGetTable(const_cast<char *>("HPET"), 0, &hpet_table)); auto hpet_entry = (HpetEntry *)((uintptr_t)hpet_table + sizeof(ACPI_TABLE_HEADER)); assert(hpet_entry->address.SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY); setupHpet(hpet_entry->address.Address); }