[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 04/17] plat/common: Common x86 CPU interrupt flag handling


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Wed, 4 Apr 2018 16:53:55 +0300
  • Cc: simon.kuenzer@xxxxxxxxx
  • Delivery-date: Wed, 04 Apr 2018 13:54:24 +0000
  • Ironport-phdr: 9a23:CILJ1BYbsZizfHqgEuurMG7/LSx+4OfEezUN459isYplN5qZr8y8bnLW6fgltlLVR4KTs6sC17KN9fi4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCazbL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPCTQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjmk8qxlSgLniD0fOjA57m/Zl8J+gqFcrh2jqRxy2JLYbJ2POfZiZK7RYc8WSGxcVchRTSxBBYa8YpMRAuoGJuZYs4j9p10TphW4GAmsHP7vwSJPi3Dq2q06yPghEQDA3AA6G9IOrWzUrMjuOagOSuC51rHIzSjYYP9Mwzf975HFfxY8qv+PRbJ9adfdxEYyGw/fjVidqZbpMy2L2ukPqWSW4fJsWf+ghmI6sQ18oTiiyt0yhoTHiI8Z0E3I+CpnzIszONa2UlR0YcS+H5tVryyaMox2Td48TGxwoyY6z6EGuYa8fCgX1JQr3x7fZOKDc4iP+h/jSuORLi15hHJhYr6wmw2y/VK4yu3hTca4ykxKri1dntnNsHACyQDT59CaRvZy40utwzWC2gDJ5u1aP0w5l7DXJpA5zr41jJUTsEDDHiHsmEXxia+bblkr+u+z6+T7Y7XmoIWQN4tpigHmL6QjgdCwAf8iPggWQmiU4v6w1Kfk/UHhWrVFkuU2krXFsJDdPckbo6+5AwlU0oYk8BazFiqp38oGnXYZKFJIYxaHj4nyO1HSO/D0F/i+jEqqkDtxwPDGJLLhCI3XLnffiLfhYap960lExQoozNBf4pVUCrcbLPLwR0/+qtrYDx4nPAyu2OvnDsty2Z8aWW2VGaCVKr3dsULbrt4oduyNYo4So3PxJuYo49bqjGQlghkNcK/v2oEYO16iGfEzCEKCfXvqyvMcCXpC6gE5V/DrjhuGTCZOT32pGboh7HchD9T1Xs/4WomxjenZj2+AFZpMazUeBw==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

Introducing new header for native interrupt flag functions.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 plat/common/include/x86/irq.h  | 87 ++++++++++++++++++++++++++++++++++++++++++
 plat/xen/include/xen-x86/irq.h | 55 ++------------------------
 2 files changed, 91 insertions(+), 51 deletions(-)
 create mode 100644 plat/common/include/x86/irq.h

diff --git a/plat/common/include/x86/irq.h b/plat/common/include/x86/irq.h
new file mode 100644
index 0000000..a0f01f8
--- /dev/null
+++ b/plat/common/include/x86/irq.h
@@ -0,0 +1,87 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Port from Mini-OS: include/x86/os.h
+ */
+/*
+ * Copyright (c) 2009 Citrix Systems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef __PLAT_CMN_X86_IRQ_H__
+#define __PLAT_CMN_X86_IRQ_H__
+
+#include <x86/cpu_defs.h>
+
+#ifdef __X64_32__
+#define __SZ  "l"
+#define __REG "e"
+#else
+#define __SZ  "q"
+#define __REG "r"
+#endif
+
+#define __cli() \
+({ \
+       asm volatile("cli" : : : "memory"); \
+})
+
+#define __sti() \
+({ \
+       asm volatile("sti" : : : "memory"); \
+})
+
+#define __save_flags(x) \
+       do { \
+               unsigned long __f; \
+               asm volatile("pushf" __SZ " ; pop" __SZ " %0" : "=g"(__f)); \
+               x = (__f & X86_EFLAGS_IF) ? 1 : 0; \
+       } while (0)
+
+#define __restore_flags(x) \
+       do { \
+               if (x) \
+                       __sti(); \
+               else \
+                       __cli(); \
+       } while (0)
+
+#define __save_and_cli(x) \
+       do { \
+               __save_flags(x); \
+               __cli(); \
+       } while (0)
+
+static inline int irqs_disabled(void)
+{
+       int flag;
+
+       __save_flags(flag);
+       return !flag;
+}
+
+#define local_irq_save(x)        __save_and_cli(x)
+#define local_irq_restore(x)     __restore_flags(x)
+#define local_save_flags(x)      __save_flags(x)
+#define local_irq_disable()      __cli()
+#define local_irq_enable()       __sti()
+
+#endif /* __PLAT_CMN_X86_IRQ_H__ */
diff --git a/plat/xen/include/xen-x86/irq.h b/plat/xen/include/xen-x86/irq.h
index 4a095fd..bac3620 100644
--- a/plat/xen/include/xen-x86/irq.h
+++ b/plat/xen/include/xen-x86/irq.h
@@ -100,61 +100,14 @@
 #define irqs_disabled()                                                        
\
        HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].evtchn_upcall_mask
 
-#else
-
-#ifdef __X64_32__
-#define __SZ "l"
-#define __REG "e"
-#else
-#define __SZ "q"
-#define __REG "r"
-#endif
-
-#define __cli() \
-({ \
-       asm volatile("cli" : : : "memory"); \
-})
-
-#define __sti() \
-({ \
-       asm volatile("sti" : : : "memory"); \
-})
-
-#define __save_flags(x)                                                        
\
-       do {                                                                   \
-               unsigned long __f;                                             \
-               asm volatile("pushf" __SZ " ; pop" __SZ " %0" : "=g"(__f));    \
-               x = (__f & X86_EFLAGS_IF) ? 1 : 0;                             \
-       } while (0)
-
-#define __restore_flags(x)                                                     
\
-       do {                                                                   \
-               if (x)                                                         \
-                       __sti();                                               \
-               else                                                           \
-                       __cli();                                               \
-       } while (0)
-
-#define __save_and_cli(x)                                                      
\
-       do {                                                                   \
-               __save_flags(x);                                               \
-               __cli();                                                       \
-       } while (0)
-
-static inline int irqs_disabled(void)
-{
-       int flag;
-
-       __save_flags(flag);
-       return !flag;
-}
-
-#endif
-
 #define local_irq_save(x)        __save_and_cli(x)
 #define local_irq_restore(x)     __restore_flags(x)
 #define local_save_flags(x)      __save_flags(x)
 #define local_irq_disable()      __cli()
 #define local_irq_enable()       __sti()
 
+#else
+#include <x86/irq.h>
+#endif
+
 #endif /* PLAT_XEN_INCLUDE_XEN_X86_IRQ_H_ */
-- 
2.1.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.