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
|
|
24 | 24 | #define MSI_DELIVERY_MODE_EXT_INT 0x00000700 |
25 | 25 | |
26 | 26 | |
27 | | void msi_init(); |
28 | 27 | bool msi_supported(); |
29 | 28 | status_t msi_allocate_vectors(uint8 count, uint8 *startVector, |
30 | 29 | uint64 *address, uint16 *data); |
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 | |
| 9 | void msi_init(kernel_args* args); |
| 10 | |
| 11 | |
| 12 | #endif // _KERNEL_ARCH_x86_MSI_PRIV_H |
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
|
|
24 | 24 | |
25 | 25 | #include <arch/x86/apic.h> |
26 | 26 | #include <arch/x86/descriptors.h> |
27 | | #include <arch/x86/msi.h> |
| 27 | #include <arch/x86/msi_priv.h> |
28 | 28 | |
29 | 29 | #include <stdio.h> |
30 | 30 | |
… |
… |
arch_int_init_post_vm(kernel_args* args)
|
411 | 411 | status_t |
412 | 412 | arch_int_init_io(kernel_args* args) |
413 | 413 | { |
414 | | msi_init(); |
| 414 | msi_init(args); |
415 | 415 | ioapic_init(args); |
416 | 416 | return B_OK; |
417 | 417 | } |
diff --git a/src/system/kernel/arch/x86/msi.cpp b/src/system/kernel/arch/x86/msi.cpp
index 67b2422..54f4cff 100644
a
|
b
|
|
12 | 12 | |
13 | 13 | |
14 | 14 | static bool sMSISupported = false; |
| 15 | static uint32 sBootCPUAPICId = 0; |
15 | 16 | |
16 | 17 | |
17 | 18 | void |
18 | | msi_init() |
| 19 | msi_init(kernel_args* args) |
19 | 20 | { |
20 | 21 | if (!apic_available()) { |
21 | 22 | dprintf("disabling msi due to missing apic\n"); |
… |
… |
msi_init()
|
24 | 25 | |
25 | 26 | dprintf("msi support enabled\n"); |
26 | 27 | sMSISupported = true; |
| 28 | sBootCPUAPICId = args->arch_args.cpu_apic_id[0]; |
27 | 29 | } |
28 | 30 | |
29 | 31 | |
… |
… |
msi_allocate_vectors(uint8 count, uint8 *startVector, uint64 *address,
|
52 | 54 | } |
53 | 55 | |
54 | 56 | *startVector = (uint8)vector; |
55 | | *address = MSI_ADDRESS_BASE | (0 << MSI_DESTINATION_ID_SHIFT) |
| 57 | *address = MSI_ADDRESS_BASE | (sBootCPUAPICId << MSI_DESTINATION_ID_SHIFT) |
56 | 58 | | MSI_NO_REDIRECTION | MSI_DESTINATION_MODE_PHYSICAL; |
57 | 59 | *data = MSI_TRIGGER_MODE_EDGE | MSI_DELIVERY_MODE_FIXED |
58 | 60 | | ((uint16)vector + ARCH_INTERRUPT_BASE); |