[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/6] Make linux drivers optional
From: |
Damien Zammit |
Subject: |
[PATCH 1/6] Make linux drivers optional |
Date: |
Sun, 28 Mar 2021 17:03:15 +1100 |
Defaults to build with linux drivers.
To build without linux drivers, use:
--enable-block-group=no --enable-net-group=no
--enable-scsi-group=no --enable-wireless-group=no --enable-pcmcia-group=no
---
device/intr.c | 91 +++++++++++++++++++++++++++++++++++++++++++++
linux/configfrag.ac | 32 ++++++++++------
2 files changed, 111 insertions(+), 12 deletions(-)
diff --git a/device/intr.c b/device/intr.c
index fbb9f495..7cf991de 100644
--- a/device/intr.c
+++ b/device/intr.c
@@ -12,6 +12,7 @@
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*/
+#include <kern/assert.h>
#include <device/intr.h>
#include <device/device_types.h>
#include <device/device_port.h>
@@ -26,6 +27,18 @@
queue_head_t main_intr_queue;
static boolean_t deliver_intr (int id, ipc_port_t dst_port);
+#ifndef LINUX_DEV
+#define SA_SHIRQ 0x04000000
+#define EBUSY 16
+
+struct intr_list {
+ user_intr_t *user_intr;
+ unsigned long flags;
+ struct intr_list *next;
+};
+static struct intr_list *user_intr_handlers;
+#endif
+
static user_intr_t *
search_intr (struct irqdev *dev, ipc_port_t dst_port)
{
@@ -147,6 +160,84 @@ out:
return ret;
}
+#ifndef LINUX_DEV
+
+static void
+user_irq_handler (int id)
+{
+ struct intr_list *handler_list = user_intr_handlers;
+ user_intr_t *e;
+ spl_t s;
+
+ s = splhigh();
+
+ while (handler_list)
+ {
+ e = handler_list->user_intr;
+ if (e->id == id)
+ deliver_user_intr(&irqtab, id, e);
+ handler_list = handler_list->next;
+ }
+ splx(s);
+}
+
+int
+install_user_intr_handler (struct irqdev *dev, int id, unsigned long flags,
+ user_intr_t *user_intr)
+{
+ unsigned int irq = dev->irq[id];
+ struct intr_list *old = user_intr_handlers;
+ struct intr_list *new;
+ spl_t s;
+
+ assert (irq < NINTR);
+
+ while (old)
+ {
+ /* Try to find an irq handler that has been already set on the same pin
*/
+ if (old->user_intr->dst_port && old->user_intr->id == user_intr->id)
+ break;
+ old = old->next;
+ }
+
+ if (old)
+ {
+ mach_print("Duplicate handler\n");
+ new = (struct intr_list *)kalloc (sizeof (struct intr_list));
+ new->user_intr = user_intr;
+ new->flags = flags;
+
+ /* Duplicated, so test if sharing allowed */
+ if (!(old->flags & new->flags & SA_SHIRQ))
+ {
+ mach_print ("EBUSY! (no sharing)\n");
+ return EBUSY;
+ }
+ /* Fine, insert new handler */
+ old->next = new;
+ }
+ else
+ {
+ /* First entry */
+ mach_print ("First handler\n");
+ old = (struct intr_list *)kalloc (sizeof (struct intr_list));
+ old->user_intr = user_intr;
+ old->flags = flags;
+ old->next = NULL;
+ user_intr_handlers = old;
+ }
+
+ s = splhigh();
+
+ ivect[irq] = user_irq_handler;
+ iunit[irq] = (int)irq;
+ unmask_irq (irq);
+
+ splx(s);
+ return 0;
+}
+#endif
+
void
intr_thread (void)
{
diff --git a/linux/configfrag.ac b/linux/configfrag.ac
index 78b59d7f..6fb60935 100644
--- a/linux/configfrag.ac
+++ b/linux/configfrag.ac
@@ -33,6 +33,8 @@ dnl USE OF THIS SOFTWARE.
'')
# No group.
:;;
+ block)
+ device_driver_group_block=selected;;
net)
device_driver_group_net=selected;;
pcmcia)
@@ -75,7 +77,7 @@ fi
case $host_platform:$host_cpu in
at:i?86)
case $enable_device_drivers:'$2' in
- default:*by\ default* | qemu:*for\ qemu*)
+ default:*by\ default*)
enableval=${enableval-yes};;
*)
enableval=${enableval-no};;
@@ -129,10 +131,6 @@ AC_DEFUN([AC_Linux_DRIVER], [
AC_OPTION_Linux_ix86_at([$1], [Linux device driver for $2; on ix86-at
enabled]
[by default], [$3], [$4])
])
-AC_DEFUN([AC_Linux_DRIVER_qemu], [
- AC_OPTION_Linux_ix86_at([$1], [Linux device driver for $2; on ix86-at
enabled]
- [by default and for qemu], [$3], [$4])
-])
AC_DEFUN([AC_Linux_DRIVER_nodef], [
AC_OPTION_Linux_ix86_at_nodef([$1], [Linux device driver for $2], [$3], [$4])
])
@@ -141,13 +139,17 @@ AC_DEFUN([AC_Linux_DRIVER_nodef], [
# Configuration options.
#
-AC_Linux_DRIVER_qemu([floppy],
- [PC floppy],
- [CONFIG_BLK_DEV_FD])
+dnl Block drivers.
+AC_OPTION_Linux_group([block], [Block drivers])
-AC_Linux_DRIVER_qemu([ide],
+AC_Linux_DRIVER([floppy],
+ [PC floppy],
+ [CONFIG_BLK_DEV_FD],
+ [block])
+AC_Linux_DRIVER([ide],
[IDE disk controllers],
- [CONFIG_BLK_DEV_IDE])
+ [CONFIG_BLK_DEV_IDE],
+ [block])
AC_ARG_ENABLE([ide-forcedma],
AS_HELP_STRING([--enable-ide-forcedma], [enable forced use of DMA on IDE]),
@@ -431,7 +433,7 @@ AC_Linux_DRIVER([natsemi],
[Ethernet controller National Semiconductor DP8381x series PCI Ethernet],
[CONFIG_NATSEMI],
[net])
-AC_Linux_DRIVER_qemu([ne],
+AC_Linux_DRIVER([ne],
[Ethernet controller NE2000/NE1000 ISA (ne, ne1000, ne2000)],
[CONFIG_NE2000],
[net])
@@ -582,7 +584,13 @@ AC_Linux_DRIVER([orinoco_cs],
# that get brought in, need special symbols defined, etc.
#
-[if [ x"$device_driver_group_net" = xselected ]; then]
+[if [ x"$device_driver_group_block" = xselected ]; then]
+ AC_DEFINE([CONFIG_BLOCK], [1], [CONFIG_BLOCK])
+ AM_CONDITIONAL([device_driver_group_block], [true])
+[else] AM_CONDITIONAL([device_driver_group_block], [false])
+[fi
+
+if [ x"$device_driver_group_net" = xselected ]; then]
AC_DEFINE([CONFIG_INET], [1], [CONFIG_INET])
AM_CONDITIONAL([device_driver_group_net], [true])
[else] AM_CONDITIONAL([device_driver_group_net], [false])
--
2.30.1
- [PATCH v2 gnumach] - IOAPIC and LAPIC support, Damien Zammit, 2021/03/28
- [PATCH 2/6] fixup acpi base table search, Damien Zammit, 2021/03/28
- [PATCH 1/6] Make linux drivers optional,
Damien Zammit <=
- [PATCH 3/6] Don't allow writing to acpi table in memory, Damien Zammit, 2021/03/28
- [PATCH 4/6] Existing SMP apic code improvements, Damien Zammit, 2021/03/28
- [PATCH 5/6] Move PIC interrupt vector base from 0x40 to 0x20, Damien Zammit, 2021/03/28
- [PATCH 6/6] ioapic support switchable back to pic, Damien Zammit, 2021/03/28