[PATCH] Delete ffs and strrchr prototypes.

2023-01-14 Thread Flavio Cruz
We use __builtin_ffs instead of ffs. strrchr is not used.

Also removed the commented out memset implementation since it is
implemented in arch-specific code.
---
 include/string.h |  4 
 kern/strings.c   | 21 -
 2 files changed, 25 deletions(-)

diff --git a/include/string.h b/include/string.h
index cddcbeb9..91c5fe46 100644
--- a/include/string.h
+++ b/include/string.h
@@ -42,8 +42,6 @@ extern char *strcpy (char *dest, const char *src);
 
 extern char *strncpy (char *dest, const char *src, size_t n);
 
-extern char *strrchr (const char *s, int c);
-
 extern char *strsep (char **strp, const char *delim);
 
 extern int strcmp (const char *s1, const char *s2) __attribute__ ((pure));
@@ -54,6 +52,4 @@ extern size_t strlen (const char *s) __attribute__ ((pure));
 
 extern char *strstr(const char *haystack, const char *needle);
 
-extern int ffs(int i);
-
 #endif /* _MACH_SA_SYS_STRING_H_ */
diff --git a/kern/strings.c b/kern/strings.c
index 71c99050..7e7fda02 100644
--- a/kern/strings.c
+++ b/kern/strings.c
@@ -173,27 +173,6 @@ strlen(
return string - 1 - ret;
 }
 
-/*
- * Abstract:
- * memset writes value "c" in the "n" bytes starting at address "s".
- * The return value is a pointer to the "s" string.
- */
-
-#if 0
-void *
-memset(
-   void *_s, int c, size_t n)
-{
-   char *s = _s;
-   size_t i;
-
-   for (i = 0; i < n ; i++)
-   s[i] = c;
-
-   return _s;
-}
-#endif
-
 /*
  * Abstract:
  * strchr returns a pointer to the first occurrence of the character
-- 
2.39.0




[PATCH rumpkernel] pci-userspace: Add acpi lookup of irqs with fallback

2023-01-14 Thread Damien Zammit
This adds support for looking up IRQ numbers via hurd's acpi translator.
It falls back to the existing IRQ number if acpi cannot provide it.

---
 debian/patches/acpi.diff | 76 
 debian/patches/series|  1 +
 2 files changed, 77 insertions(+)
 create mode 100644 debian/patches/acpi.diff

diff --git a/debian/patches/acpi.diff b/debian/patches/acpi.diff
new file mode 100644
index 0..2788dad22
--- /dev/null
+++ b/debian/patches/acpi.diff
@@ -0,0 +1,76 @@
+--- a/pci-userspace/src-gnu/Makefile.inc
 b/pci-userspace/src-gnu/Makefile.inc
+@@ -3,7 +3,7 @@
+ PCIDIR:=  ${.PARSEDIR}
+ .PATH:${PCIDIR}
+
+-RUMPCOMP_USER_SRCS=   pci_user-gnu.c mach_debugUser.c
++RUMPCOMP_USER_SRCS=   pci_user-gnu.c mach_debugUser.c acpiUser.c
+ RUMPCOMP_USER_CPPFLAGS+=-I${PCIDIR} -I${DESTDIR}/usr/include
+ RUMPCOMP_CPPFLAGS+=   -I${PCIDIR} -I${DESTDIR}/usr/include
+ CPPFLAGS+=-I${PCIDIR}
+@@ -16,3 +16,11 @@
+   -user mach_debugUser.c \
+   -server /dev/null \
+   -header mach_debug_U.h
++
++acpiUser.c:
++  echo '#include ' \
++  | ${CC} -E -x c - -o - \
++  | mig -cc cat - /dev/null -subrprefix __ \
++  -user acpiUser.c \
++  -server /dev/null \
++  -header acpi_U.h
+--- a/pci-userspace/src-gnu/pci_user-gnu.c
 b/pci-userspace/src-gnu/pci_user-gnu.c
+@@ -67,6 +67,7 @@
+ #include 
+ #include 
+ #include "mach_debug_U.h"
++#include "acpi_U.h"
+ #include 
+ #include 
+
+@@ -90,6 +91,7 @@
+ static mach_port_t master_host;
+ static mach_port_t master_device;
+ static device_t irq_dev;
++static device_t acpi_dev;
+
+ #define PCI_CFG1_START 0xcf8
+ #define PCI_CFG1_END   0xcff
+@@ -130,6 +132,11 @@
+   if (device_open (master_device, D_READ, "irq", &irq_dev))
+   err(2, "device_open irq");
+
++  /* Optional */
++  if (device_open (master_device, D_READ, "acpi", &acpi_dev)) {
++  MACH_PRINT("device_open acpi failed... continue\n");
++  }
++
+   pci_system_init ();
+   struct pci_device_iterator *dev_iter;
+   struct pci_device *pci_dev;
+@@ -363,6 +370,7 @@
+ rumpcomp_pci_irq_map(unsigned bus, unsigned dev, unsigned fun,
+   int intrline, unsigned cookie)
+ {
++  int ret;
+   struct irq *irq;
+   irq = malloc(sizeof(*irq));
+   if (irq == NULL)
+@@ -372,7 +380,13 @@
+   irq->bus = bus;
+   irq->dev = dev;
+   irq->fun = fun;
+-  irq->intrline = intrline;
++
++  /* We can do better by reading irq from acpi device, but with fallback 
*/
++  ret = acpi_get_pci_irq (acpi_dev, bus, dev, fun, &irq->intrline);
++  if (ret) {
++  irq->intrline = intrline;
++  MACH_PRINT("acpi_get_pci_irq failed, continue with intrline\n");
++  }
+
+   pthread_mutex_lock(&genericmtx);
+   LIST_INSERT_HEAD(&irqs, irq, entries);
diff --git a/debian/patches/series b/debian/patches/series
index 5654d3549..adbc5acb9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -14,3 +14,4 @@ pci-userspace-rump.diff
 rumpuser-evcnt.diff
 ps-comm.diff
 idtype_t.diff
+acpi.diff
--
2.34.1