Пример #1
0
status_t
arch_smp_init(kernel_args *args)
{
	TRACE(("%s: entry\n", __func__));

	if (!apic_available()) {
		// if we don't have an apic we can't do smp
		TRACE(("%s: apic not available for smp\n", __func__));
		return B_OK;
	}

	// setup some globals
	memcpy(sCPUAPICIds, args->arch_args.cpu_apic_id, sizeof(args->arch_args.cpu_apic_id));
	memcpy(sAPICVersions, args->arch_args.cpu_apic_version, sizeof(args->arch_args.cpu_apic_version));

	// set up the local apic on the boot cpu
	arch_smp_per_cpu_init(args, 0);

	if (args->num_cpus > 1) {
		// I/O interrupts start at ARCH_INTERRUPT_BASE, so all interrupts are shifted
		reserve_io_interrupt_vectors(3, 0xfd - ARCH_INTERRUPT_BASE);
		install_io_interrupt_handler(0xfd - ARCH_INTERRUPT_BASE, &x86_ici_interrupt, NULL, B_NO_LOCK_VECTOR);
		install_io_interrupt_handler(0xfe - ARCH_INTERRUPT_BASE, &x86_smp_error_interrupt, NULL, B_NO_LOCK_VECTOR);
		install_io_interrupt_handler(0xff - ARCH_INTERRUPT_BASE, &x86_spurious_interrupt, NULL, B_NO_LOCK_VECTOR);
	}

	return B_OK;
}
Пример #2
0
void
msi_init()
{
	if (!apic_available()) {
		dprintf("disabling msi due to missing apic\n");
		return;
	}

	for (uint16 i = 0; i < kVectorCount; i++)
		sAllocatedVectors[i] = false;

	// the first 24 vectors are addressable with a single ioapic config
	for (uint16 i = 0; i < 24; i++)
		sAllocatedVectors[i] = true;

	// performance testing and syscall interrupts
	sAllocatedVectors[98 - ARCH_INTERRUPT_BASE] = true;
	sAllocatedVectors[99 - ARCH_INTERRUPT_BASE] = true;

	// the upper range is used by apic local (timer) and smp interrupts (ipi)
	for (uint16 i = 251; i < 256; i++)
		sAllocatedVectors[i - ARCH_INTERRUPT_BASE] = true;

	dprintf("msi support enabled\n");
	sMSISupported = true;
}
Пример #3
0
void
msi_init(kernel_args* args)
{
	if (!apic_available()) {
		dprintf("disabling msi due to missing apic\n");
		return;
	}

	dprintf("msi support enabled\n");
	sMSISupported = true;
	sBootCPUAPICId = args->arch_args.cpu_apic_id[0];
}
Пример #4
0
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", &parameter, 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;
}