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

[Minios-devel] [UNIKRAFT PATCH 1/2] plat/common: Move IO functions to x86_64 specific header


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Wed, 27 Jun 2018 13:59:08 +0300
  • Cc: Costin Lupu <costin.lup@xxxxxxxxx>, simon.kuenzer@xxxxxxxxx, sharan.santhanam@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Wed, 27 Jun 2018 10:59:22 +0000
  • Ironport-phdr: 9a23:nk4AqhMFru0+eokcvVUl6mtUPXoX/o7sNwtQ0KIMzox0I/X5rarrMEGX3/hxlliBBdydt6oazbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxlJiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSkHKTA37W/ZhM93gq1ZrhKsvABzz5LObY2JLvdyYr/RcNUHTmRBRMZRUClBD5uiYosIFOoBIedYr4/grFUIsBu+HRSsD/7oxzBUgX/2xrE60+UnEQ3c2AwgAsoOsGnPodrpL6ceS/i1zLTTwjnZdfNW3i7w5Y7VeR4iufGBRa98fMXMxUU1FA7Ijk+cpZL7Mz6XzOgAvXCX4/dvWO6ykWIqqAF8riKxysoihITFnJ8Zx1/a+Sh/3Y07P8e3SFRhbt6hCJZQsiaaOJZoTc46WGFovTo6yqUBuZ6mYCgG0JQnyADba/yAa4WI/BfjW/yQITd8nn5qZKm/iwyq8Ui90eLwTNO00FFSoipElNnDqGwN2gTO5sWIV/dx5ESs1DaV2wzN9O1JI1o4mKTDJ54k2LEwl54TsUrZHi/xnUX7lLOZdkI/+ui06uTnZK/qppuBN49slwHzKbghmtelDeQgLwgBRHKX+f671LH75032XK1KjuEqkqneqJ3VOcMbprWlAw9U1IYv8RK/Dyq+0NkDknkHKUhKeBODj4TzJ17OJ/X4B++lg1uwiDdr2+zGPrr5D5XIL3jDlrbhfbFm60JF1QU8085f6IxQCrwaJPLzW1TxtMDDDhMjPA273eDnBM961oMEVmKFGrWZP7/KsV+U+uIvJPGBZJQVuDnnMfgq/fjugWUimVAHe6mpwZsXZ2q+Hvt8JkWUenzsjckdHmcOpAUxV/bmh0OfUTRLfXa9Q7o85i0nCIKhFYrDXYGtgLmG3Ce9BJFWZX1GBU6KEXbpaYqEQewBaCSMLcB9ljwLT6OuR5U/2hGzrAX60aZoLvLI+i0EspLuzNh05/DJlREz7zB0EcOd02WRQGF0nWMIQCE20bt5oUNj1liD1bJ3jOdCGdNN+vMaGjs9YJvdye19EJX+VxzMev+NSU26WZO2DDd3Scg+kPEUZEMoMNK5khHFlw63G6Jdw7eMH4A19OTYwmDsD81mjW7b3u87iA91EYN0KWS6i/snpEDoDInTnhDBmg==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

From: Costin Lupu <costin.lup@xxxxxxxxx>

Some of the functions were already implemented in the CPU header, so
only the missing functions were moved. The include paths for PCI library
were relaxed (from including only the pci directory to including the
whole directory for common includes).

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 plat/common/include/pci/pci_bus.h | 52 ---------------------------------------
 plat/common/include/x86/cpu.h     | 32 ++++++++++++++++++++++++
 plat/common/pci_bus.c             |  3 ++-
 plat/kvm/Makefile.uk              |  7 ++++--
 4 files changed, 39 insertions(+), 55 deletions(-)

diff --git a/plat/common/include/pci/pci_bus.h 
b/plat/common/include/pci/pci_bus.h
index 01385c7..4e02282 100644
--- a/plat/common/include/pci/pci_bus.h
+++ b/plat/common/include/pci/pci_bus.h
@@ -172,56 +172,4 @@ UK_TAILQ_HEAD(pci_device_list, struct pci_device);
 void _pci_register_driver(struct pci_driver *drv);
 
 
-/* TODO: Move these I/O functions to architecture/platform specific
- *       implementation. They are used to interact with the PCI bus.
- *       They work for x86_64 only for now
- */
-static inline uint8_t inb(uint16_t port)
-{
-       uint8_t v;
-
-       __asm__ __volatile__("inb %1,%0" : "=a" (v) : "dN" (port));
-       return v;
-}
-static inline uint16_t inw(uint16_t port)
-{
-       uint16_t v;
-
-       __asm__ __volatile__("inw %1,%0" : "=a" (v) : "dN" (port));
-       return v;
-}
-static inline uint32_t inl(uint16_t port)
-{
-       uint32_t v;
-
-       __asm__ __volatile__("inl %1,%0" : "=a" (v) : "dN" (port));
-       return v;
-}
-
-static inline uint64_t inq(uint16_t port_lo)
-{
-       uint16_t port_hi = port_lo + 4;
-       uint32_t lo, hi;
-
-       __asm__ __volatile__("inl %1,%0" : "=a" (lo) : "dN" (port_lo));
-       __asm__ __volatile__("inl %1,%0" : "=a" (hi) : "dN" (port_hi));
-
-       return ((uint64_t)lo) | ((uint64_t)hi << 32);
-}
-
-static inline void outb(uint16_t port, uint8_t v)
-{
-       __asm__ __volatile__("outb %0,%1" : : "a" (v), "dN" (port));
-}
-
-static inline void outw(uint16_t port, uint16_t v)
-{
-       __asm__ __volatile__("outw %0,%1" : : "a" (v), "dN" (port));
-}
-
-static inline void outl(uint16_t port, uint32_t v)
-{
-       __asm__ __volatile__("outl %0,%1" : : "a" (v), "dN" (port));
-}
-
 #endif /* __UKPLAT_COMMON_PCI_BUS_H__ */
diff --git a/plat/common/include/x86/cpu.h b/plat/common/include/x86/cpu.h
index ce96c1c..104f53e 100644
--- a/plat/common/include/x86/cpu.h
+++ b/plat/common/include/x86/cpu.h
@@ -84,6 +84,33 @@ static inline __u8 inb(__u16 port)
        return v;
 }
 
+static inline __u16 inw(__u16 port)
+{
+       __u16 v;
+
+       __asm__ __volatile__("inw %1,%0" : "=a" (v) : "dN" (port));
+       return v;
+}
+
+static inline __u32 inl(__u16 port)
+{
+       __u32 v;
+
+       __asm__ __volatile__("inl %1,%0" : "=a" (v) : "dN" (port));
+       return v;
+}
+
+static inline __u64 inq(__u16 port_lo)
+{
+       __u16 port_hi = port_lo + 4;
+       __u32 lo, hi;
+
+       __asm__ __volatile__("inl %1,%0" : "=a" (lo) : "dN" (port_lo));
+       __asm__ __volatile__("inl %1,%0" : "=a" (hi) : "dN" (port_hi));
+
+       return ((__u64) lo) | ((__u64) hi << 32);
+}
+
 static inline void outb(__u16 port, __u8 v)
 {
        __asm__ __volatile__("outb %0,%1" : : "a"(v), "dN"(port));
@@ -94,6 +121,11 @@ static inline void outw(__u16 port, __u16 v)
        __asm__ __volatile__("outw %0,%1" : : "a"(v), "dN"(port));
 }
 
+static inline void outl(__u16 port, __u32 v)
+{
+       __asm__ __volatile__("outl %0,%1" : : "a" (v), "dN" (port));
+}
+
 static inline __u64 mul64_32(__u64 a, __u32 b)
 {
        __u64 prod;
diff --git a/plat/common/pci_bus.c b/plat/common/pci_bus.c
index c19545e..df6d1b0 100644
--- a/plat/common/pci_bus.c
+++ b/plat/common/pci_bus.c
@@ -54,7 +54,8 @@
 
 #include <string.h>
 #include <uk/print.h>
-#include <pci_bus.h>
+#include <cpu.h>
+#include <pci/pci_bus.h>
 
 struct pci_bus_handler {
        struct uk_bus b;
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index 9bedb37..c1e79a2 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -14,10 +14,8 @@ $(eval $(call addplatlib_s,kvm,libkvmpci,$(CONFIG_KVM_PCI)))
 ##
 LIBKVMPLAT_ASINCLUDES-y        += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPLAT_ASINCLUDES-y        += -I$(UK_PLAT_COMMON_BASE)/include
-LIBKVMPCI_ASINCLUDES-$(CONFIG_ARCH_X86_64)  += 
-I$(UK_PLAT_COMMON_BASE)/include/pci
 LIBKVMPLAT_CINCLUDES-y         += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPLAT_CINCLUDES-y         += -I$(UK_PLAT_COMMON_BASE)/include
-LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += 
-I$(UK_PLAT_COMMON_BASE)/include/pci
 
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/trace.c|common
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/traps.c|common
@@ -42,4 +40,9 @@ LIBKVMPLAT_SRCS-y              += 
$(LIBKVMPLAT_BASE)/tscclock.c
 LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
 LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
 
+##
+## PCI library definitions
+##
+LIBKVMPCI_ASINCLUDES-$(CONFIG_ARCH_X86_64)  += -I$(UK_PLAT_COMMON_BASE)/include
+LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPCI_SRCS-y                     += $(UK_PLAT_COMMON_BASE)/pci_bus.c|common
-- 
2.11.0


_______________________________________________
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®.