PERFORCE change 85846 for review
John Baldwin
jhb at FreeBSD.org
Tue Oct 25 13:20:17 PDT 2005
http://perforce.freebsd.org/chv.cgi?CH=85846
Change 85846 by jhb at jhb_slimer on 2005/10/25 20:19:31
IFC @85845 - loop back intr_event stuff.
Affected files ...
.. //depot/projects/smpng/sys/alpha/alpha/interrupt.c#36 integrate
.. //depot/projects/smpng/sys/alpha/isa/isa.c#15 integrate
.. //depot/projects/smpng/sys/amd64/amd64/intr_machdep.c#13 integrate
.. //depot/projects/smpng/sys/amd64/include/intr_machdep.h#5 integrate
.. //depot/projects/smpng/sys/amd64/isa/atpic.c#10 integrate
.. //depot/projects/smpng/sys/amd64/pci/pci_cfgreg.c#8 integrate
.. //depot/projects/smpng/sys/arm/arm/intr.c#11 integrate
.. //depot/projects/smpng/sys/boot/ofw/libofw/devicename.c#9 integrate
.. //depot/projects/smpng/sys/boot/ofw/libofw/ofw_disk.c#11 integrate
.. //depot/projects/smpng/sys/conf/kern.post.mk#48 integrate
.. //depot/projects/smpng/sys/conf/kmod.mk#51 integrate
.. //depot/projects/smpng/sys/dev/fe/if_fe_pccard.c#17 integrate
.. //depot/projects/smpng/sys/dev/hme/if_hme.c#27 integrate
.. //depot/projects/smpng/sys/dev/hme/if_hmereg.h#7 integrate
.. //depot/projects/smpng/sys/dev/hme/if_hmevar.h#9 integrate
.. //depot/projects/smpng/sys/dev/if_ndis/if_ndis.c#35 integrate
.. //depot/projects/smpng/sys/dev/if_ndis/if_ndisvar.h#17 integrate
.. //depot/projects/smpng/sys/dev/pci/pci.c#62 integrate
.. //depot/projects/smpng/sys/dev/sio/sio.c#57 integrate
.. //depot/projects/smpng/sys/dev/uart/uart_kbd_sun.c#6 integrate
.. //depot/projects/smpng/sys/dev/uart/uart_tty.c#15 integrate
.. //depot/projects/smpng/sys/i386/i386/intr_machdep.c#15 integrate
.. //depot/projects/smpng/sys/i386/include/intr_machdep.h#7 integrate
.. //depot/projects/smpng/sys/i386/isa/atpic.c#13 integrate
.. //depot/projects/smpng/sys/i386/pci/pci_cfgreg.c#29 integrate
.. //depot/projects/smpng/sys/ia64/ia64/interrupt.c#32 integrate
.. //depot/projects/smpng/sys/kern/kern_clock.c#43 integrate
.. //depot/projects/smpng/sys/kern/kern_intr.c#72 integrate
.. //depot/projects/smpng/sys/kern/subr_taskqueue.c#26 integrate
.. //depot/projects/smpng/sys/kern/subr_witness.c#142 integrate
.. //depot/projects/smpng/sys/modules/sound/driver/Makefile#6 integrate
.. //depot/projects/smpng/sys/powerpc/include/intr_machdep.h#6 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/intr_machdep.c#7 integrate
.. //depot/projects/smpng/sys/sparc64/conf/NOTES#18 integrate
.. //depot/projects/smpng/sys/sparc64/include/intr_machdep.h#12 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/intr_machdep.c#24 integrate
.. //depot/projects/smpng/sys/sys/interrupt.h#17 integrate
.. //depot/projects/smpng/sys/sys/proc.h#154 integrate
.. //depot/projects/smpng/sys/sys/unistd.h#13 integrate
.. //depot/projects/smpng/sys/ufs/ufs/ufs_bmap.c#15 integrate
Differences ...
==== //depot/projects/smpng/sys/alpha/alpha/interrupt.c#36 (text+ko) ====
@@ -33,7 +33,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
/* __KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.23 1998/02/24 07:38:01 thorpej Exp $");*/
-__FBSDID("$FreeBSD: src/sys/alpha/alpha/interrupt.c,v 1.87 2005/09/29 19:12:44 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/alpha/interrupt.c,v 1.88 2005/10/25 19:48:45 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -325,8 +325,9 @@
struct alpha_intr {
LIST_ENTRY(alpha_intr) list; /* chain handlers in this hash bucket */
uintptr_t vector; /* vector to match */
- struct ithd *ithd; /* interrupt thread */
+ struct intr_event *ie; /* interrupt event structure */
volatile long *cntp; /* interrupt counter */
+ void (*disable)(uintptr_t);
};
static struct mtx alpha_intr_hash_lock;
@@ -338,7 +339,7 @@
ithds_init(void *dummy)
{
- mtx_init(&alpha_intr_hash_lock, "ithread table lock", NULL, MTX_SPIN);
+ mtx_init(&alpha_intr_hash_lock, "intr table", NULL, MTX_SPIN);
}
SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
@@ -371,8 +372,9 @@
return ENOMEM;
i->vector = vector;
i->cntp = cntp;
- errcode = ithread_create(&i->ithd, vector, 0, disable, enable,
- "intr:");
+ i->disable = disable;
+ errcode = intr_event_create(&i->ie, (void *)vector, 0,
+ (void (*)(void *))enable, "intr:");
if (errcode) {
free(i, M_DEVBUF);
return errcode;
@@ -384,44 +386,49 @@
}
/* Second, add this handler. */
- return (ithread_add_handler(i->ithd, name, handler, arg,
- ithread_priority(flags), flags, cookiep));
+ return (intr_event_add_handler(i->ie, name, handler, arg,
+ intr_priority(flags), flags, cookiep));
}
int
alpha_teardown_intr(void *cookie)
{
- return (ithread_remove_handler(cookie));
+ return (intr_event_remove_handler(cookie));
}
+/*
+ * XXX: Alpha doesn't count stray interrupts like some of the other archs.
+ */
void
alpha_dispatch_intr(void *frame, unsigned long vector)
{
int h = HASHVEC(vector);
struct alpha_intr *i;
- struct ithd *ithd; /* our interrupt thread */
- struct intrhand *ih;
- int error;
+ struct intr_event *ie;
+ struct intr_handler *ih;
+ int error, thread;
/*
* Walk the hash bucket for this vector looking for this vector's
- * interrupt thread.
+ * interrupt structure.
*/
for (i = LIST_FIRST(&alpha_intr_hash[h]); i && i->vector != vector;
i = LIST_NEXT(i, list))
; /* nothing */
+
+ /* No interrupt structure for this vector. */
if (i == NULL)
- return; /* no ithread for this vector */
+ return;
- ithd = i->ithd;
- KASSERT(ithd != NULL, ("interrupt vector without a thread"));
+ ie = i->ie;
+ KASSERT(ie != NULL, ("interrupt structure without an event"));
/*
- * As an optimization, if an ithread has no handlers, don't
+ * As an optimization, if an event has no handlers, don't
* schedule it to run.
*/
- if (TAILQ_EMPTY(&ithd->it_handlers))
+ if (TAILQ_EMPTY(&ie->ie_handlers))
return;
atomic_add_long(i->cntp, 1);
@@ -433,25 +440,32 @@
*/
sched_pin();
+ /* Execute all fast interrupt handlers directly. */
+ thread = 0;
+ critical_enter();
+ TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
+ if (!(ih->ih_flags & IH_FAST)) {
+ thread = 1;
+ continue;
+ }
+ CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
+ ih->ih_handler, ih->ih_argument, ih->ih_name);
+ ih->ih_handler(ih->ih_argument);
+ }
+ critical_exit();
+
/*
- * Handle a fast interrupt if there is no actual thread for this
- * interrupt by calling the handler directly without Giant. Note
- * that this means that any fast interrupt handler must be MP safe.
+ * If the ithread needs to run, disable the source and schedule the
+ * thread.
*/
- ih = TAILQ_FIRST(&ithd->it_handlers);
- if ((ih->ih_flags & IH_FAST) != 0) {
- critical_enter();
- ih->ih_handler(ih->ih_argument);
- critical_exit();
- } else {
- if (ithd->it_disable) {
+ if (thread) {
+ if (i->disable) {
CTR1(KTR_INTR,
"alpha_dispatch_intr: disabling vector 0x%x",
i->vector);
- ithd->it_disable(ithd->it_vector);
+ i->disable(i->vector);
}
-
- error = ithread_schedule(ithd);
+ error = intr_event_schedule_thread(ie);
KASSERT(error == 0, ("got an impossible stray interrupt"));
}
sched_unpin();
==== //depot/projects/smpng/sys/alpha/isa/isa.c#15 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/isa/isa.c,v 1.37 2005/09/25 19:34:54 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/isa/isa.c,v 1.38 2005/10/25 19:48:45 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -389,14 +389,14 @@
struct resource *irq, void *cookie)
{
struct isa_intr *ii = cookie;
- struct intrhand *ih, *handler = (struct intrhand *)ii->ih;
- struct ithd *ithread = handler->ih_ithread;
+ struct intr_handler *ih, *handler = (struct intr_handler *)ii->ih;
+ struct intr_event *ie = handler->ih_event;
int num_handlers = 0;
- mtx_lock(&ithread->it_lock);
- TAILQ_FOREACH(ih, &ithread->it_handlers, ih_next)
+ mtx_lock(&ie->ie_lock);
+ TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next)
num_handlers++;
- mtx_unlock(&ithread->it_lock);
+ mtx_unlock(&ie->ie_lock);
/*
* Only disable the interrupt in hardware if there are no
==== //depot/projects/smpng/sys/amd64/amd64/intr_machdep.c#13 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/amd64/amd64/intr_machdep.c,v 1.15 2005/06/24 00:45:01 peter Exp $
+ * $FreeBSD: src/sys/amd64/amd64/intr_machdep.c,v 1.16 2005/10/25 19:48:45 jhb Exp $
*/
/*
@@ -57,7 +57,7 @@
#define MAX_STRAY_LOG 5
-typedef void (*mask_fn)(uintptr_t vector);
+typedef void (*mask_fn)(void *);
static int intrcnt_index;
static struct intsrc *interrupt_sources[NUM_IO_INTS];
@@ -81,15 +81,14 @@
vector = isrc->is_pic->pic_vector(isrc);
if (interrupt_sources[vector] != NULL)
return (EEXIST);
- error = ithread_create(&isrc->is_ithread, (uintptr_t)isrc, 0,
- (mask_fn)isrc->is_pic->pic_disable_source,
+ error = intr_event_create(&isrc->is_event, isrc, 0,
(mask_fn)isrc->is_pic->pic_enable_source, "irq%d:", vector);
if (error)
return (error);
mtx_lock_spin(&intr_table_lock);
if (interrupt_sources[vector] != NULL) {
mtx_unlock_spin(&intr_table_lock);
- ithread_destroy(isrc->is_ithread);
+ intr_event_destroy(isrc->is_event);
return (EEXIST);
}
intrcnt_register(isrc);
@@ -115,8 +114,8 @@
isrc = intr_lookup_source(vector);
if (isrc == NULL)
return (EINVAL);
- error = ithread_add_handler(isrc->is_ithread, name, handler, arg,
- ithread_priority(flags), flags, cookiep);
+ error = intr_event_add_handler(isrc->is_event, name, handler, arg,
+ intr_priority(flags), flags, cookiep);
if (error == 0) {
intrcnt_updatename(isrc);
isrc->is_pic->pic_enable_intr(isrc);
@@ -130,7 +129,7 @@
{
int error;
- error = ithread_remove_handler(cookie);
+ error = intr_event_remove_handler(cookie);
#ifdef XXX
if (error == 0)
intrcnt_updatename(/* XXX */);
@@ -153,12 +152,11 @@
intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
{
struct thread *td;
- struct ithd *it;
- struct intrhand *ih;
- int error, vector;
+ struct intr_event *ie;
+ struct intr_handler *ih;
+ int error, vector, thread;
td = curthread;
- td->td_intr_nesting_level++;
/*
* We count software interrupts when we process them. The
@@ -169,11 +167,7 @@
(*isrc->is_count)++;
PCPU_LAZY_INC(cnt.v_intr);
- it = isrc->is_ithread;
- if (it == NULL)
- ih = NULL;
- else
- ih = TAILQ_FIRST(&it->it_handlers);
+ ie = isrc->is_event;
/*
* XXX: We assume that IRQ 0 is only used for the ISA timer
@@ -183,40 +177,12 @@
if (vector == 0)
clkintr_pending = 1;
- if (ih != NULL && ih->ih_flags & IH_FAST) {
- /*
- * Execute fast interrupt handlers directly.
- * To support clock handlers, if a handler registers
- * with a NULL argument, then we pass it a pointer to
- * a trapframe as its argument.
- */
- critical_enter();
- TAILQ_FOREACH(ih, &it->it_handlers, ih_next) {
- MPASS(ih->ih_flags & IH_FAST);
- CTR3(KTR_INTR, "%s: executing handler %p(%p)",
- __func__, ih->ih_handler,
- ih->ih_argument == NULL ? iframe :
- ih->ih_argument);
- if (ih->ih_argument == NULL)
- ih->ih_handler(iframe);
- else
- ih->ih_handler(ih->ih_argument);
- }
- isrc->is_pic->pic_eoi_source(isrc);
- error = 0;
- critical_exit();
- } else {
- /*
- * For stray and threaded interrupts, we mask and EOI the
- * source.
- */
+ /*
+ * For stray interrupts, mask and EOI the source, bump the
+ * stray count, and log the condition.
+ */
+ if (ie == NULL || TAILQ_EMPTY(&ie->ie_handlers)) {
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
- if (ih == NULL)
- error = EINVAL;
- else
- error = ithread_schedule(it);
- }
- if (error == EINVAL) {
(*isrc->is_straycount)++;
if (*isrc->is_straycount < MAX_STRAY_LOG)
log(LOG_ERR, "stray irq%d\n", vector);
@@ -225,6 +191,46 @@
"too many stray irq %d's: not logging anymore\n",
vector);
}
+
+ /*
+ * Execute fast interrupt handlers directly.
+ * To support clock handlers, if a handler registers
+ * with a NULL argument, then we pass it a pointer to
+ * an intrframe as its argument.
+ */
+ td->td_intr_nesting_level++;
+ thread = 0;
+ critical_enter();
+ TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
+ if (!(ih->ih_flags & IH_FAST)) {
+ thread = 1;
+ continue;
+ }
+ CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
+ ih->ih_handler, ih->ih_argument == NULL ? iframe :
+ ih->ih_argument, ih->ih_name);
+ if (ih->ih_argument == NULL)
+ ih->ih_handler(iframe);
+ else
+ ih->ih_handler(ih->ih_argument);
+ }
+
+ /*
+ * If there are any threaded handlers that need to run,
+ * mask the source as well as sending it an EOI. Otherwise,
+ * just send it an EOI but leave it unmasked.
+ */
+ if (thread)
+ isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
+ else
+ isrc->is_pic->pic_eoi_source(isrc);
+ critical_exit();
+
+ /* Schedule the ithread if needed. */
+ if (thread) {
+ error = intr_event_schedule_thread(ie);
+ KASSERT(error == 0, ("bad stray interrupt"));
+ }
td->td_intr_nesting_level--;
}
@@ -266,7 +272,7 @@
intrcnt_updatename(struct intsrc *is)
{
- intrcnt_setname(is->is_ithread->it_td->td_proc->p_comm, is->is_index);
+ intrcnt_setname(is->is_event->ie_fullname, is->is_index);
}
static void
@@ -275,7 +281,7 @@
char straystr[MAXCOMLEN + 1];
/* mtx_assert(&intr_table_lock, MA_OWNED); */
- KASSERT(is->is_ithread != NULL, ("%s: isrc with no ithread", __func__));
+ KASSERT(is->is_event != NULL, ("%s: isrc with no event", __func__));
is->is_index = intrcnt_index;
intrcnt_index += 2;
snprintf(straystr, MAXCOMLEN + 1, "stray irq%d",
@@ -325,6 +331,6 @@
db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
if (*isrc != NULL)
- db_dump_ithread((*isrc)->is_ithread, verbose);
+ db_dump_intr_event((*isrc)->is_event, verbose);
}
#endif
==== //depot/projects/smpng/sys/amd64/include/intr_machdep.h#5 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/amd64/include/intr_machdep.h,v 1.5 2005/01/21 06:01:20 peter Exp $
+ * $FreeBSD: src/sys/amd64/include/intr_machdep.h,v 1.6 2005/10/25 19:48:46 jhb Exp $
*/
#ifndef __MACHINE_INTR_MACHDEP_H__
@@ -75,7 +75,7 @@
*/
struct intsrc {
struct pic *is_pic;
- struct ithd *is_ithread;
+ struct intr_event *is_event;
u_long *is_count;
u_long *is_straycount;
u_int is_index;
==== //depot/projects/smpng/sys/amd64/isa/atpic.c#10 (text+ko) ====
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/isa/atpic.c,v 1.15 2005/01/21 06:01:20 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/isa/atpic.c,v 1.16 2005/10/25 19:48:46 jhb Exp $");
#include "opt_auto_eoi.h"
#include "opt_isa.h"
@@ -472,10 +472,10 @@
isrc = &atintrs[vec].at_intsrc;
/*
- * If we don't have an ithread, see if this is a spurious
+ * If we don't have an event, see if this is a spurious
* interrupt.
*/
- if (isrc->is_ithread == NULL && (vec == 7 || vec == 15)) {
+ if (isrc->is_event == NULL && (vec == 7 || vec == 15)) {
int port, isr;
/*
==== //depot/projects/smpng/sys/amd64/pci/pci_cfgreg.c#8 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_cfgreg.c,v 1.108 2005/01/21 05:56:41 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_cfgreg.c,v 1.109 2005/10/25 04:53:29 wpaul Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -139,11 +139,15 @@
{
switch (cfgmech) {
case 1:
- outl(CONF1_ADDR_PORT, 0);
+ /*
+ * Do nothing for the config mechanism 1 case.
+ * Writing a 0 to the address port can apparently
+ * confuse some bridges and cause spurious
+ * access failures.
+ */
break;
case 2:
outb(CONF2_ENABLE_PORT, 0);
- outb(CONF2_FORWARD_PORT, 0);
break;
}
}
==== //depot/projects/smpng/sys/arm/arm/intr.c#11 (text+ko) ====
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/arm/intr.c,v 1.10 2005/10/03 14:17:16 cognet Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/arm/intr.c,v 1.11 2005/10/25 19:48:46 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/syslog.h>
@@ -50,7 +50,7 @@
#include <machine/intr.h>
#include <machine/cpu.h>
-static struct ithd *ithreads[NIRQ];
+static struct intr_event *intr_events[NIRQ];
static int intrcnt_tab[NIRQ];
static int intrcnt_index = 0;
static int last_printed = 0;
@@ -61,18 +61,18 @@
arm_setup_irqhandler(const char *name, void (*hand)(void*), void *arg,
int irq, int flags, void **cookiep)
{
- struct ithd *cur_ith;
+ struct intr_event *event;
int error;
if (irq < 0 || irq >= NIRQ)
return;
- cur_ith = ithreads[irq];
- if (cur_ith == NULL) {
- error = ithread_create(&cur_ith, irq, 0, arm_mask_irq,
- arm_unmask_irq, "intr%d:", irq);
+ event = intr_events[irq];
+ if (event == NULL) {
+ error = intr_event_create(&event, (void *)irq, 0,
+ (void (*)(void *))arm_unmask_irq, "intr%d:", irq);
if (error)
return;
- ithreads[irq] = cur_ith;
+ intr_events[irq] = event;
last_printed +=
snprintf(intrnames + last_printed,
MAXCOMLEN + 1,
@@ -82,14 +82,14 @@
intrcnt_index++;
}
- ithread_add_handler(cur_ith, name, hand, arg,
- ithread_priority(flags), flags, cookiep);
+ intr_event_add_handler(event, name, hand, arg,
+ intr_priority(flags), flags, cookiep);
}
int
arm_remove_irqhandler(void *cookie)
{
- return (ithread_remove_handler(cookie));
+ return (intr_event_remove_handler(cookie));
}
void dosoftints(void);
@@ -101,28 +101,34 @@
void
arm_handler_execute(void *frame, int irqnb)
{
- struct ithd *ithd;
- int i;
- struct intrhand *ih;
+ struct intr_event *event;
+ struct intr_handler *ih;
struct thread *td = curthread;
+ int i, thread;
td->td_intr_nesting_level++;
while ((i = arm_get_next_irq()) != -1) {
arm_mask_irq(i);
intrcnt[intrcnt_tab[i]]++;
- ithd = ithreads[i];
- if (!ithd)
+ event = intr_events[i];
+ if (!event || TAILQ_EMPTY(&event->ie_handlers))
continue;
- ih = TAILQ_FIRST(&ithd->it_handlers);
- if (ih && ih->ih_flags & IH_FAST) {
- TAILQ_FOREACH(ih, &ithd->it_handlers,
- ih_next) {
+
+ /* Execute fast handlers. */
+ thread = 0;
+ TAILQ_FOREACH(ih, &event->ie_handlers, ih_next) {
+ if (!(ih->ih_flags & IH_FAST))
+ thread = 1;
+ else
ih->ih_handler(ih->ih_argument ?
ih->ih_argument : frame);
- }
+ }
+
+ /* Schedule thread if needed. */
+ if (thread)
+ intr_event_schedule_thread(event);
+ else
arm_unmask_irq(i);
- } else if (ih)
- ithread_schedule(ithd);
}
td->td_intr_nesting_level--;
}
==== //depot/projects/smpng/sys/boot/ofw/libofw/devicename.c#9 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/ofw/libofw/devicename.c,v 1.15 2004/01/04 23:27:31 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/ofw/libofw/devicename.c,v 1.16 2005/10/25 12:49:56 marius Exp $");
#include <stand.h>
#include "libofw.h"
@@ -99,9 +99,13 @@
return(ENOENT);
found:
- if (*s != '\0')
+ if (path != NULL && *s != '\0')
*path = s;
idev = malloc(sizeof(struct ofw_devdesc));
+ if (idev == NULL) {
+ printf("ofw_parsedev: malloc failed\n");
+ return ENOMEM;
+ }
strcpy(idev->d_path, name);
idev->d_dev = dv;
idev->d_type = dv->dv_type;
==== //depot/projects/smpng/sys/boot/ofw/libofw/ofw_disk.c#11 (text+ko) ====
@@ -24,13 +24,14 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/ofw/libofw/ofw_disk.c,v 1.12 2005/01/05 22:16:58 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/ofw/libofw/ofw_disk.c,v 1.13 2005/10/25 12:51:49 marius Exp $");
/*
* Disk I/O routines using Open Firmware
*/
#include <sys/param.h>
+#include <sys/queue.h>
#include <netinet/in.h>
@@ -60,9 +61,18 @@
ofwd_print
};
+struct opened_dev {
+ ihandle_t handle;
+ u_int count;
+ SLIST_ENTRY(opened_dev) link;
+};
+
+SLIST_HEAD(, opened_dev) opened_devs = SLIST_HEAD_INITIALIZER(opened_dev);
+
static int
ofwd_init(void)
{
+
return 0;
}
@@ -73,7 +83,6 @@
struct ofw_devdesc *dp = (struct ofw_devdesc *)devdata;
daddr_t pos;
int n;
- int i, j;
pos = dblk * 512;
do {
@@ -90,18 +99,47 @@
static int
ofwd_open(struct open_file *f, ...)
{
+ char path[256];
struct ofw_devdesc *dp;
- phandle_t handle;
+ struct opened_dev *odp;
va_list vl;
va_start(vl, f);
dp = va_arg(vl, struct ofw_devdesc *);
va_end(vl);
- if ((handle = OF_open(dp->d_path)) == -1) {
+ /*
+ * We're not guaranteed to be able to open a device more than once
+ * simultaneously and there is no OFW standard method to determine
+ * whether a device is already opened. Opening a device more than
+ * once happens to work with most OFW block device drivers but
+ * triggers a trap with at least the driver for the on-board SCSI
+ * controller in Sun Ultra 1. Upper layers and MI code expect to
+ * be able to open a device more than once however. As a workaround
+ * keep track of the opened devices and reuse the instance handle
+ * when asked to open an already opened device.
+ */
+ SLIST_FOREACH(odp, &opened_devs, link) {
+ if (OF_instance_to_path(odp->handle, path, sizeof(path)) == -1)
+ continue;
+ if (strcmp(path, dp->d_path) == 0) {
+ odp->count++;
+ dp->d_handle = odp->handle;
+ return 0;
+ }
+ }
+ odp = malloc(sizeof(struct opened_dev));
+ if (odp == NULL) {
+ printf("ofwd_open: malloc failed\n");
+ return ENOMEM;
+ }
+ if ((odp->handle = OF_open(dp->d_path)) == -1) {
printf("ofwd_open: Could not open %s\n", dp->d_path);
- return 1;
+ free(odp);
+ return ENOENT;
}
- dp->d_handle = handle;
+ odp->count = 1;
+ SLIST_INSERT_HEAD(&opened_devs, odp, link);
+ dp->d_handle = odp->handle;
return 0;
}
@@ -109,8 +147,20 @@
ofwd_close(struct open_file *f)
{
struct ofw_devdesc *dev = f->f_devdata;
+ struct opened_dev *odp;
- OF_close(dev->d_handle);
+ SLIST_FOREACH(odp, &opened_devs, link) {
+ if (odp->handle == dev->d_handle) {
+ odp->count--;
+ if (odp->count == 0) {
+ SLIST_REMOVE(&opened_devs, odp, opened_dev,
+ link);
+ OF_close(odp->handle);
+ free(odp);
+ }
+ break;
+ }
+ }
return 0;
}
@@ -124,4 +174,5 @@
static void
ofwd_print(int verbose)
{
+
}
==== //depot/projects/smpng/sys/conf/kern.post.mk#48 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/kern.post.mk,v 1.84 2005/09/11 00:22:21 obrien Exp $
+# $FreeBSD: src/sys/conf/kern.post.mk,v 1.86 2005/10/25 09:05:07 ru Exp $
# Part of a unified Makefile for building kernels. This part includes all
# the definitions that need to be after all the % directives except %RULES
@@ -63,9 +63,14 @@
.endif
.endif
-.if defined(DEBUG)
+.if !defined(DEBUG)
+FULLKERNEL= ${KERNEL_KO}
+.else
+FULLKERNEL= ${KERNEL_KO}.debug
+${KERNEL_KO}: ${FULLKERNEL}
+ ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
install.debug reinstall.debug: gdbinit
- cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG ${.TARGET:R}
+ cd ${.CURDIR}; ${MAKE} ${.TARGET:R}
# Install gdbinit files for kernel debugging.
gdbinit:
@@ -78,7 +83,7 @@
.endif
.endif
-${KERNEL_KO}: ${SYSTEM_DEP} vers.o
+${FULLKERNEL}: ${SYSTEM_DEP} vers.o
@rm -f ${.TARGET}
@echo linking ${.TARGET}
${SYSTEM_LD}
@@ -104,7 +109,7 @@
kernel-clean:
rm -f *.o *.so *.So *.ko *.s eddep errs \
- ${KERNEL_KO} linterrs makelinks tags vers.c \
+ ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks tags vers.c \
vnode_if.c vnode_if.h vnode_if_newproto.h vnode_if_typedef.h \
${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
${CLEAN}
@@ -181,7 +186,7 @@
.endif
kernel-install:
- @if [ ! -f ${KERNEL_KO} ] ; then \
+ @if [ ! -f ${FULLKERNEL} ] ; then \
echo "You must build a kernel first." ; \
exit 1 ; \
fi
@@ -200,11 +205,19 @@
fi
.endif
mkdir -p ${DESTDIR}${KODIR}
+.if defined(DEBUG) && !defined(INSTALL_NODEBUG)
+ ${INSTALL} -p -m 555 -o root -g wheel ${FULLKERNEL} ${DESTDIR}${KODIR}/${KERNEL_KO}
+.else
${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO} ${DESTDIR}${KODIR}
+.endif
kernel-reinstall:
@-chflags -R noschg ${DESTDIR}${KODIR}
+.if defined(DEBUG) && !defined(INSTALL_NODEBUG)
+ ${INSTALL} -p -m 555 -o root -g wheel ${FULLKERNEL} ${DESTDIR}${KODIR}/${KERNEL_KO}
+.else
${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO} ${DESTDIR}${KODIR}
+.endif
config.o env.o hints.o vers.o vnode_if.o:
${NORMAL_C}
==== //depot/projects/smpng/sys/conf/kmod.mk#51 (text+ko) ====
@@ -1,5 +1,5 @@
# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
-# $FreeBSD: src/sys/conf/kmod.mk,v 1.196 2005/10/14 15:13:36 ru Exp $
+# $FreeBSD: src/sys/conf/kmod.mk,v 1.197 2005/10/25 09:05:07 ru Exp $
#
# The include file <bsd.kmod.mk> handles building and installing loadable
# kernel modules.
@@ -236,21 +236,17 @@
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
.endfor
-.if !target(install.debug) && defined(DEBUG_FLAGS)
-install.debug:
- cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG install
-.endif
-
.if !target(realinstall)
realinstall: _kmodinstall
.ORDER: beforeinstall _kmodinstall
_kmodinstall:
-.if defined(DEBUG_FLAGS) && defined(INSTALL_DEBUG)
+.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG)
${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
- ${_INSTALLFLAGS} ${FULLPROG} ${DESTDIR}${KMODDIR}
+ ${_INSTALLFLAGS} ${FULLPROG} ${DESTDIR}${KMODDIR}/${PROG}
.else
${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
+.endif
.include <bsd.links.mk>
@@ -264,7 +260,6 @@
kldxref ${DESTDIR}${KMODDIR}; \
fi
.endif
-.endif
.endif # !target(realinstall)
.endif # !target(install)
==== //depot/projects/smpng/sys/dev/fe/if_fe_pccard.c#17 (text+ko) ====
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fe/if_fe_pccard.c,v 1.30 2005/09/22 05:52:54 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fe/if_fe_pccard.c,v 1.31 2005/10/25 03:49:24 imp Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -64,6 +64,7 @@
struct pccard_product mpp_product;
int mpp_flags;
#define MPP_MBH10302 1
+#define MPP_ANYFUNC 2
} fe_pccard_products[] = {
/* These need to be first */
{ PCMCIA_CARD(FUJITSU2, FMV_J181), MPP_MBH10302 },
@@ -81,31 +82,32 @@
{ PCMCIA_CARD(FUJITSU, LA10S), 0 },
{ PCMCIA_CARD(FUJITSU, NE200T), MPP_MBH10302 },/* Sold by Eagle */
{ PCMCIA_CARD(RATOC, REX_R280), 0 },
+ { PCMCIA_CARD(XIRCOM, CE), MPP_ANYFUNC },
{ { NULL } }
};
static int
fe_pccard_probe(device_t dev)
{
- const struct pccard_product *pp;
int error;
uint32_t fcn = PCCARD_FUNCTION_UNSPEC;
+ const struct fe_pccard_product *pp;
- /* Make sure we're a network function */
- error = pccard_get_function(dev, &fcn);
- if (error != 0)
- return (error);
- if (fcn != PCCARD_FUNCTION_NETWORK)
- return (ENXIO);
-
- if ((pp = pccard_product_lookup(dev,
+ if ((pp = (const struct fe_pccard_product *)pccard_product_lookup(dev,
(const struct pccard_product *)fe_pccard_products,
sizeof(fe_pccard_products[0]), NULL)) != NULL) {
- if (pp->pp_name != NULL)
- device_set_desc(dev, pp->pp_name);
- return 0;
+ if (pp->mpp_product.pp_name != NULL)
+ device_set_desc(dev, pp->mpp_product.pp_name);
+ if (pp->mpp_flags & MPP_ANYFUNC)
+ return (0);
+ /* Make sure we're a network function */
+ error = pccard_get_function(dev, &fcn);
+ if (error != 0)
+ return (error);
+ if (fcn != PCCARD_FUNCTION_NETWORK)
+ return (ENXIO);
}
- return EIO;
+ return (ENXIO);
}
static device_method_t fe_pccard_methods[] = {
@@ -248,6 +250,40 @@
return 0;
}
+static int
+sn_pccard_xircom_mac(const struct pccard_tuple *tuple, void *argp)
+{
+ uint8_t *enaddr = argp;
+ int i;
+
+#if 1
+ /*
+ * We fail to map the CIS twice, for reasons unknown. We
+ * may fix this in the future by loading the CIS with a sane
+ * CIS from userland.
+ */
+ static uint8_t defaultmac[ETHER_ADDR_LEN] = {
+ 0x00, 0x80, 0xc7, 0xed, 0x16, 0x7b};
+
+ /* Copy the MAC ADDR and return success */
+ for (i = 0; i < ETHER_ADDR_LEN; i++)
+ enaddr[i] = defaultmac[i];
+#else
+ /* FUNCE is not after FUNCID, so we gotta go find it */
+ if (tuple->code != 0x22)
+ return (0);
+
+ /* Make sure this is a sane node */
+ if (tuple->length < ETHER_ADDR_LEN + 3)
+ return (0);
+
+ /* Copy the MAC ADDR and return success */
+ for (i = 0; i < ETHER_ADDR_LEN; i++)
+ enaddr[i] = pccard_tuple_read_1(tuple, i + 3);
+#endif
+ return (1);
+}
+
/*
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list