kern_intr.c (71fad9fdeefd5d874768802125f98ea6450cfa5c) kern_intr.c (e3b6e33c07b11798e5e24baaa7d596902debdcba)
1/*
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 43 unchanged lines hidden (view full) ---

52
53#include <net/netisr.h> /* prototype for legacy_setsoftnet */
54
55struct int_entropy {
56 struct proc *proc;
57 int vector;
58};
59
1/*
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 43 unchanged lines hidden (view full) ---

52
53#include <net/netisr.h> /* prototype for legacy_setsoftnet */
54
55struct int_entropy {
56 struct proc *proc;
57 int vector;
58};
59
60void *net_ih;
61void *vm_ih;
62void *softclock_ih;
63struct ithd *clk_ithd;
64struct ithd *tty_ithd;
65
66static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads");
67
68static void ithread_update(struct ithd *);
69static void ithread_loop(void *);
70static void start_softintr(void *);
60void *vm_ih;
61void *softclock_ih;
62struct ithd *clk_ithd;
63struct ithd *tty_ithd;
64
65static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads");
66
67static void ithread_update(struct ithd *);
68static void ithread_loop(void *);
69static void start_softintr(void *);
71static void swi_net(void *);
72
73u_char
74ithread_priority(enum intr_type flags)
75{
76 u_char pri;
77
78 flags &= (INTR_TYPE_TTY | INTR_TYPE_BIO | INTR_TYPE_NET |
79 INTR_TYPE_CAM | INTR_TYPE_MISC | INTR_TYPE_CLK | INTR_TYPE_AV);

--- 486 unchanged lines hidden (view full) ---

566
567/*
568 * Start standard software interrupt threads
569 */
570static void
571start_softintr(void *dummy)
572{
573
70
71u_char
72ithread_priority(enum intr_type flags)
73{
74 u_char pri;
75
76 flags &= (INTR_TYPE_TTY | INTR_TYPE_BIO | INTR_TYPE_NET |
77 INTR_TYPE_CAM | INTR_TYPE_MISC | INTR_TYPE_CLK | INTR_TYPE_AV);

--- 486 unchanged lines hidden (view full) ---

564
565/*
566 * Start standard software interrupt threads
567 */
568static void
569start_softintr(void *dummy)
570{
571
574 if (swi_add(NULL, "net", swi_net, NULL, SWI_NET, 0, &net_ih) ||
575 swi_add(&clk_ithd, "clock", softclock, NULL, SWI_CLOCK,
572 if (swi_add(&clk_ithd, "clock", softclock, NULL, SWI_CLOCK,
576 INTR_MPSAFE, &softclock_ih) ||
577 swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, 0, &vm_ih))
578 panic("died while creating standard software ithreads");
579
580 PROC_LOCK(clk_ithd->it_td->td_proc);
581 clk_ithd->it_td->td_proc->p_flag |= P_NOLOAD;
582 PROC_UNLOCK(clk_ithd->it_td->td_proc);
583}
584SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL)
585
573 INTR_MPSAFE, &softclock_ih) ||
574 swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, 0, &vm_ih))
575 panic("died while creating standard software ithreads");
576
577 PROC_LOCK(clk_ithd->it_td->td_proc);
578 clk_ithd->it_td->td_proc->p_flag |= P_NOLOAD;
579 PROC_UNLOCK(clk_ithd->it_td->td_proc);
580}
581SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL)
582
586void
587legacy_setsoftnet(void)
588{
589 swi_sched(net_ih, 0);
590}
591
592/*
593 * XXX: This should really be in the network code somewhere and installed
594 * via a SI_SUB_SOFINTR, SI_ORDER_MIDDLE sysinit.
595 */
596void (*netisrs[32])(void);
597volatile unsigned int netisr; /* scheduling bits for network */
598
599int
600register_netisr(num, handler)
601 int num;
602 netisr_t *handler;
603{
604
605 if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) {
606 printf("register_netisr: bad isr number: %d\n", num);
607 return (EINVAL);
608 }
609 netisrs[num] = handler;
610 return (0);
611}
612
613int
614unregister_netisr(num)
615 int num;
616{
617
618 if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) {
619 printf("unregister_netisr: bad isr number: %d\n", num);
620 return (EINVAL);
621 }
622 netisrs[num] = NULL;
623 return (0);
624}
625
626#ifdef DEVICE_POLLING
627 void netisr_pollmore(void);
628#endif
629
630static void
631swi_net(void *dummy)
632{
633 u_int bits;
634 int i;
635
636#ifdef DEVICE_POLLING
637 for (;;) {
638 int pollmore;
639#endif
640 bits = atomic_readandclear_int(&netisr);
641#ifdef DEVICE_POLLING
642 if (bits == 0)
643 return;
644 pollmore = bits & (1 << NETISR_POLL);
645#endif
646 while ((i = ffs(bits)) != 0) {
647 i--;
648 if (netisrs[i] != NULL)
649 netisrs[i]();
650 else
651 printf("swi_net: unregistered isr number: %d.\n", i);
652 bits &= ~(1 << i);
653 }
654#ifdef DEVICE_POLLING
655 if (pollmore)
656 netisr_pollmore();
657 }
658#endif
659}
660
661/*
662 * Sysctls used by systat and others: hw.intrnames and hw.intrcnt.
663 * The data for this machine dependent, and the declarations are in machine
664 * dependent code. The layout of intrnames and intrcnt however is machine
665 * independent.
666 *
667 * We do not know the length of intrcnt and intrnames at compile time, so
668 * calculate things at run time.

--- 20 unchanged lines hidden ---
583/*
584 * Sysctls used by systat and others: hw.intrnames and hw.intrcnt.
585 * The data for this machine dependent, and the declarations are in machine
586 * dependent code. The layout of intrnames and intrcnt however is machine
587 * independent.
588 *
589 * We do not know the length of intrcnt and intrnames at compile time, so
590 * calculate things at run time.

--- 20 unchanged lines hidden ---