You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/25 16:00:10 UTC

(nuttx) branch master updated (737d4bf418 -> 381e7f225d)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 737d4bf418 risc-v/mpfs: emmcsd: enforce HS DDR mode
     new 5668a3e283 x86_64_pci.c: x86_64_pci_read/write_io memory support
     new 381e7f225d pci.c: add pci_read/write_io_qword support

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/x86_64/src/common/x86_64_pci.c | 42 ++++++++++++++++++++++++-------------
 include/nuttx/pci/pci.h             | 19 +++++++++++++++++
 2 files changed, 46 insertions(+), 15 deletions(-)


(nuttx) 01/02: x86_64_pci.c: x86_64_pci_read/write_io memory support

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 5668a3e283bdeecd415d63adb2325d9e3f706ad1
Author: wangyongrong <wa...@xiaomi.com>
AuthorDate: Thu May 9 14:56:41 2024 +0800

    x86_64_pci.c: x86_64_pci_read/write_io memory support
    
    Signed-off-by: wangyongrong <wa...@xiaomi.com>
---
 arch/x86_64/src/common/x86_64_pci.c | 42 ++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/arch/x86_64/src/common/x86_64_pci.c b/arch/x86_64/src/common/x86_64_pci.c
index 4d1b456c12..9502c97360 100644
--- a/arch/x86_64/src/common/x86_64_pci.c
+++ b/arch/x86_64/src/common/x86_64_pci.c
@@ -37,12 +37,28 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define PCI_CFG_ADDR      0xcf8
-#define PCI_DATA_ADDR     0xcfc
-#define PCI_CFG_EN        (1 << 31)
+#define PCI_CFG_ADDR         0xcf8
+#define PCI_DATA_ADDR        0xcfc
+#define PCI_CFG_EN           (1 << 31)
 
-#define X86_64_MAR_DEST    0xfee00000
-#define X86_64_MDR_TYPE    0x4000
+#define X86_64_MAR_DEST      0xfee00000
+#define X86_64_MDR_TYPE      0x4000
+
+#define X86_64_IO_ADDR_LIMIT 0xffff
+
+#define readb(addr)          ((addr) > X86_64_IO_ADDR_LIMIT ? \
+                              *((volatile uint8_t *)(addr)) : inb(addr))
+#define readw(addr)          ((addr) > X86_64_IO_ADDR_LIMIT ? \
+                              *((volatile uint16_t *)(addr)) : inw(addr))
+#define readl(addr)          ((addr) > X86_64_IO_ADDR_LIMIT ? \
+                              *((volatile uint32_t *)(addr)) : inl(addr))
+
+#define writeb(addr, val)    ((addr) > X86_64_IO_ADDR_LIMIT ? \
+                              *((volatile uint8_t *)(addr)) = (val) : outb(val, addr))
+#define writew(addr, val)    ((addr) > X86_64_IO_ADDR_LIMIT ? \
+                              *((volatile uint16_t *)(addr)) = (val) : outw(val, addr))
+#define writel(addr, val)    ((addr) > X86_64_IO_ADDR_LIMIT ? \
+                              *((volatile uint32_t *)(addr)) = (val) : outl(val, addr))
 
 /****************************************************************************
  * Private Functions Definitions
@@ -208,18 +224,16 @@ static int x86_64_pci_read(struct pci_bus_s *bus, unsigned int devfn,
 static int x86_64_pci_read_io(struct pci_bus_s *bus, uintptr_t addr,
                               int size, uint32_t *val)
 {
-  uint16_t portaddr = (uint16_t)addr;
-
   switch (size)
   {
     case 1:
-      *val = (uint32_t)inb(portaddr);
+      *val = readb(addr);
       break;
     case 2:
-      *val = (uint32_t)inw(portaddr);
+      *val = readw(addr);
       break;
     case 4:
-      *val = (uint32_t)inl(portaddr);
+      *val = readl(addr);
       break;
     default:
       *val = 0;
@@ -251,18 +265,16 @@ static int x86_64_pci_read_io(struct pci_bus_s *bus, uintptr_t addr,
 static int x86_64_pci_write_io(struct pci_bus_s *bus, uintptr_t addr,
                                int size, uint32_t val)
 {
-  uint16_t portaddr = (uint16_t)addr;
-
   switch (size)
   {
     case 1:
-      outb((uint8_t)val, portaddr);
+      writeb(addr, val);
       break;
     case 2:
-      outw((uint16_t)val, portaddr);
+      writew(addr, val);
       break;
     case 4:
-      outl((uint32_t)val, portaddr);
+      writel(addr, val);
       break;
     default:
       pcierr("Invalid write size %d\n", size);


(nuttx) 02/02: pci.c: add pci_read/write_io_qword support

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 381e7f225d66a0241aaac51006194e8334db4b90
Author: wangyongrong <wa...@xiaomi.com>
AuthorDate: Thu May 9 16:55:45 2024 +0800

    pci.c: add pci_read/write_io_qword support
    
    Signed-off-by: wangyongrong <wa...@xiaomi.com>
---
 include/nuttx/pci/pci.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/nuttx/pci/pci.h b/include/nuttx/pci/pci.h
index 43c4ef1f04..80660c3bdf 100644
--- a/include/nuttx/pci/pci.h
+++ b/include/nuttx/pci/pci.h
@@ -161,6 +161,17 @@
 #define pci_read_io_dword(dev, addr, val) \
   pci_bus_read_io_dword((dev)->bus, addr, val)
 
+#define pci_read_io_qword(dev, addr, val) \
+  do \
+    { \
+      uint32_t valhi; \
+      uint32_t vallo; \
+      pci_bus_read_io_dword((dev)->bus, addr, &vallo); \
+      pci_bus_read_io_dword((dev)->bus, (uintptr_t)(addr) + sizeof(uint32_t), &valhi); \
+      *(val) = ((uint64_t)valhi << 32) | (uint64_t)vallo; \
+    } \
+  while (0)
+
 #define pci_write_io_byte(dev, addr, val) \
   pci_bus_write_io_byte((dev)->bus, addr, val)
 
@@ -170,6 +181,14 @@
 #define pci_write_io_dword(dev, addr, val) \
   pci_bus_write_io_dword((dev)->bus, addr, val)
 
+#define pci_write_io_qword(dev, addr, val) \
+  do \
+    { \
+      pci_bus_write_io_dword((dev)->bus, addr, (uint32_t)(val)); \
+      pci_bus_write_io_dword((dev)->bus, (uintptr_t)(addr) + sizeof(uint32_t), (val) >> 32); \
+    } \
+  while (0)
+
 #define pci_write_mmio_byte(dev, addr, val)  \
   (*((FAR volatile uint8_t *)(addr))) = val