Ticket #9807: 0001-MSI-Use-the-effective-APIC-id-of-the-boot-CPU-for-th.patch

File 0001-MSI-Use-the-effective-APIC-id-of-the-boot-CPU-for-th.patch, 3.1 KB (added by korli, 8 years ago)

msi patch destination

  • headers/private/kernel/arch/x86/msi.h

    From d67fefd0258d59f205ff3d2f2b4922cfdd98e88f Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
    Date: Fri, 26 Jul 2013 17:58:55 +0200
    Subject: [PATCH] MSI: Use the effective APIC id of the boot CPU for the
     address destination.
    
    * This should only affect systems where the CPU ids aren't sequential (mostly
    non Intel).
    ---
     headers/private/kernel/arch/x86/msi.h      |  1 -
     headers/private/kernel/arch/x86/msi_priv.h | 12 ++++++++++++
     src/system/kernel/arch/x86/arch_int.cpp    |  4 ++--
     src/system/kernel/arch/x86/msi.cpp         |  6 ++++--
     4 files changed, 18 insertions(+), 5 deletions(-)
     create mode 100644 headers/private/kernel/arch/x86/msi_priv.h
    
    diff --git a/headers/private/kernel/arch/x86/msi.h b/headers/private/kernel/arch/x86/msi.h
    index d0cec5b..18685cb 100644
    a b  
    2424#define MSI_DELIVERY_MODE_EXT_INT       0x00000700
    2525
    2626
    27 void        msi_init();
    2827bool        msi_supported();
    2928status_t    msi_allocate_vectors(uint8 count, uint8 *startVector,
    3029                uint64 *address, uint16 *data);
  • new file headers/private/kernel/arch/x86/msi_priv.h

    diff --git a/headers/private/kernel/arch/x86/msi_priv.h b/headers/private/kernel/arch/x86/msi_priv.h
    new file mode 100644
    index 0000000..236c173
    - +  
     1/*
     2 * Copyright 2010-2011, Michael Lotz, mmlr@mlotz.ch. All Rights Reserved.
     3 * Distributed under the terms of the MIT license.
     4 */
     5#ifndef _KERNEL_ARCH_x86_MSI_PRIV_H
     6#define _KERNEL_ARCH_x86_MSI_PRIV_H
     7
     8
     9void msi_init(kernel_args* args);
     10
     11
     12#endif // _KERNEL_ARCH_x86_MSI_PRIV_H
  • src/system/kernel/arch/x86/arch_int.cpp

    diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp
    index e183636..1fabe85 100644
    a b  
    2424
    2525#include <arch/x86/apic.h>
    2626#include <arch/x86/descriptors.h>
    27 #include <arch/x86/msi.h>
     27#include <arch/x86/msi_priv.h>
    2828
    2929#include <stdio.h>
    3030
    arch_int_init_post_vm(kernel_args* args)  
    411411status_t
    412412arch_int_init_io(kernel_args* args)
    413413{
    414     msi_init();
     414    msi_init(args);
    415415    ioapic_init(args);
    416416    return B_OK;
    417417}
  • src/system/kernel/arch/x86/msi.cpp

    diff --git a/src/system/kernel/arch/x86/msi.cpp b/src/system/kernel/arch/x86/msi.cpp
    index 67b2422..54f4cff 100644
    a b  
    1212
    1313
    1414static bool sMSISupported = false;
     15static uint32 sBootCPUAPICId = 0;
    1516
    1617
    1718void
    18 msi_init()
     19msi_init(kernel_args* args)
    1920{
    2021    if (!apic_available()) {
    2122        dprintf("disabling msi due to missing apic\n");
    msi_init()  
    2425
    2526    dprintf("msi support enabled\n");
    2627    sMSISupported = true;
     28    sBootCPUAPICId = args->arch_args.cpu_apic_id[0];
    2729}
    2830
    2931
    msi_allocate_vectors(uint8 count, uint8 *startVector, uint64 *address,  
    5254    }
    5355
    5456    *startVector = (uint8)vector;
    55     *address = MSI_ADDRESS_BASE | (0 << MSI_DESTINATION_ID_SHIFT)
     57    *address = MSI_ADDRESS_BASE | (sBootCPUAPICId << MSI_DESTINATION_ID_SHIFT)
    5658        | MSI_NO_REDIRECTION | MSI_DESTINATION_MODE_PHYSICAL;
    5759    *data = MSI_TRIGGER_MODE_EDGE | MSI_DELIVERY_MODE_FIXED
    5860        | ((uint16)vector + ARCH_INTERRUPT_BASE);