Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Oct 2004 17:55:43 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 63162 for review
Message-ID:  <200410131755.i9DHthRK026941@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=63162

Change 63162 by jhb@jhb_slimer on 2004/10/13 17:54:58

	IFC @63160.

Affected files ...

.. //depot/projects/smpng/sys/cam/scsi/scsi_da.h#3 integrate
.. //depot/projects/smpng/sys/conf/files#125 integrate
.. //depot/projects/smpng/sys/dev/acpica/acpi.c#74 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-all.c#63 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-queue.c#21 integrate
.. //depot/projects/smpng/sys/dev/cx/if_cx.c#14 integrate
.. //depot/projects/smpng/sys/dev/cx/machdep.h#3 integrate
.. //depot/projects/smpng/sys/dev/dcons/dcons.c#7 integrate
.. //depot/projects/smpng/sys/dev/dcons/dcons.h#3 integrate
.. //depot/projects/smpng/sys/dev/dcons/dcons_crom.c#5 integrate
.. //depot/projects/smpng/sys/dev/dcons/dcons_os.c#1 branch
.. //depot/projects/smpng/sys/dev/dcons/dcons_os.h#1 branch
.. //depot/projects/smpng/sys/dev/ofw/ofw_console.c#20 integrate
.. //depot/projects/smpng/sys/dev/sab/sab.c#23 integrate
.. //depot/projects/smpng/sys/dev/sio/sio.c#51 integrate
.. //depot/projects/smpng/sys/dev/sound/isa/ad1816.c#17 integrate
.. //depot/projects/smpng/sys/dev/sound/isa/ess.c#14 integrate
.. //depot/projects/smpng/sys/dev/sound/isa/mss.c#19 integrate
.. //depot/projects/smpng/sys/dev/sound/isa/sb16.c#18 integrate
.. //depot/projects/smpng/sys/dev/sound/isa/sb8.c#13 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/au88x0.c#9 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/aureal.c#11 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/csapcm.c#11 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/ds1.c#16 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/emu10k1.c#22 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/es137x.c#13 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/fm801.c#15 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/ich.c#31 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/maestro3.c#19 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/solo.c#12 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/t4dwave.c#19 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/via8233.c#14 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/via82c686.c#19 integrate
.. //depot/projects/smpng/sys/dev/uart/uart_tty.c#11 integrate
.. //depot/projects/smpng/sys/dev/usb/ugen.c#30 integrate
.. //depot/projects/smpng/sys/dev/usb/uhci_pci.c#11 integrate
.. //depot/projects/smpng/sys/kern/kern_switch.c#48 integrate
.. //depot/projects/smpng/sys/kern/subr_bus.c#41 integrate
.. //depot/projects/smpng/sys/kern/tty.c#50 integrate
.. //depot/projects/smpng/sys/modules/dcons/Makefile#3 integrate
.. //depot/projects/smpng/sys/modules/dcons_crom/Makefile#2 integrate
.. //depot/projects/smpng/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c#13 integrate
.. //depot/projects/smpng/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_var.h#4 integrate
.. //depot/projects/smpng/sys/pc98/pc98/sio.c#48 integrate

Differences ...

==== //depot/projects/smpng/sys/cam/scsi/scsi_da.h#3 (text+ko) ====

@@ -46,7 +46,7 @@
  *
  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  *
- * $FreeBSD: src/sys/cam/scsi/scsi_da.h,v 1.6 2004/10/12 08:55:02 bms Exp $
+ * $FreeBSD: src/sys/cam/scsi/scsi_da.h,v 1.7 2004/10/13 09:31:04 bms Exp $
  */
 
 #ifndef	_SCSI_SCSI_DA_H
@@ -188,7 +188,7 @@
 struct scsi_read_format_capacities
 {
 	uint8_t	opcode;		/* READ_FORMAT_CAPACITIES */
-	uint8_t	byte2;		/* top 3 bits contain LUN */
+	uint8_t	byte2;
 #define	SRFC_LUN_MASK	0xE0
 	uint8_t	reserved0[5];
 	uint8_t	alloc_length[2];
@@ -198,11 +198,11 @@
 struct scsi_verify
 {
 	uint8_t	opcode;		/* VERIFY */
-	uint8_t	lun;		/* All other bits should be zero */
+	uint8_t	byte2;
+#define	SVFY_LUN_MASK	0xE0
 #define	SVFY_RELADR	0x01
 #define	SVFY_BYTECHK	0x02
 #define	SVFY_DPO	0x10
-#define	SVFY_LUN_MASK	0xE0	/* Top 3 MSBs are LUN */
 	uint8_t	addr[4];	/* LBA to begin verification at */
 	uint8_t	reserved0[1];
 	uint8_t	len[2];		/* number of blocks to verify */
@@ -212,7 +212,7 @@
 struct scsi_write_and_verify
 {
 	uint8_t	opcode;		/* WRITE_AND_VERIFY */
-	uint8_t	byte2;		/* top 3 bits are the LUN */
+	uint8_t	byte2;
 #define	SWVY_LUN_MASK	0xE0
 #define	SWVY_RELADR	0x01
 #define	SWVY_BYTECHK	0x02

==== //depot/projects/smpng/sys/conf/files#125 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.956 2004/10/08 00:24:30 brooks Exp $
+# $FreeBSD: src/sys/conf/files,v 1.957 2004/10/13 05:41:09 simokawa Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -393,6 +393,7 @@
 dev/cy/cy_pci.c		optional cy pci
 dev/dcons/dcons.c	optional dcons
 dev/dcons/dcons_crom.c	optional dcons_crom
+dev/dcons/dcons_os.c	optional dcons
 dev/digi/digi.c		optional digi
 dev/digi/digi_isa.c	optional digi isa
 dev/digi/digi_pci.c	optional digi pci

==== //depot/projects/smpng/sys/dev/acpica/acpi.c#74 (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/dev/acpica/acpi.c,v 1.190 2004/09/21 17:19:38 njl Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.193 2004/10/13 07:29:29 njl Exp $
  */
 
 #include "opt_acpi.h"
@@ -617,6 +617,8 @@
     retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
     retval += resource_list_print_type(rl, "irq",   SYS_RES_IRQ,    "%ld");
     retval += resource_list_print_type(rl, "drq",   SYS_RES_DRQ,    "%ld");
+    if (device_get_flags(child))
+	retval += printf(" flags %#x", device_get_flags(child));
     retval += bus_print_child_footer(bus, child);
 
     return (retval);
@@ -1169,6 +1171,9 @@
     }
 
  out:
+    if (result == 0 && ids->ip_desc)
+	device_set_desc(child, ids->ip_desc);
+
     return_VALUE (result);
 }
 

==== //depot/projects/smpng/sys/dev/ata/ata-all.c#63 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.231 2004/10/10 13:24:39 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.232 2004/10/13 15:16:35 sos Exp $");
 
 #include "opt_ata.h"
 #include <sys/param.h>
@@ -248,6 +248,8 @@
     while (ch->locking(ch, ATA_LF_LOCK) != ch->unit)
 	tsleep(&devices, PRIBIO, "atarint", 1);
 
+    ata_catch_inflight(ch);
+
     /* grap the channel lock no matter what */
     mtx_lock(&ch->state_mtx);
     ch->state = ATA_ACTIVE;
@@ -258,7 +260,6 @@
     else
 	ch->flags |= ATA_IMMEDIATE_MODE;
 
-    ata_catch_inflight(ch);
     devices = ch->devices;
 
     ch->hw.reset(ch);
@@ -270,15 +271,15 @@
     if ((misdev = devices & ~ch->devices)) {
 	if ((misdev & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) &&
 	    ch->device[MASTER].detach) {
+	    ata_fail_requests(ch, &ch->device[MASTER]);
 	    ch->device[MASTER].detach(&ch->device[MASTER]);
-	    ata_fail_requests(ch, &ch->device[MASTER]);
 	    free(ch->device[MASTER].param, M_ATA);
 	    ch->device[MASTER].param = NULL;
 	}
 	if ((misdev & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) &&
 	    ch->device[SLAVE].detach) {
+	    ata_fail_requests(ch, &ch->device[SLAVE]);
 	    ch->device[SLAVE].detach(&ch->device[SLAVE]);
-	    ata_fail_requests(ch, &ch->device[SLAVE]);
 	    free(ch->device[SLAVE].param, M_ATA);
 	    ch->device[SLAVE].param = NULL;
 	}
@@ -291,15 +292,15 @@
     if ((misdev = devices & ~ch->devices)) {
 	if ((misdev & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) &&
 	    ch->device[MASTER].detach) {
+	    ata_fail_requests(ch, &ch->device[MASTER]);
 	    ch->device[MASTER].detach(&ch->device[MASTER]);
-	    ata_fail_requests(ch, &ch->device[MASTER]);
 	    free(ch->device[MASTER].param, M_ATA);
 	    ch->device[MASTER].param = NULL;
 	}
 	if ((misdev & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) &&
 	    ch->device[SLAVE].detach) {
+	    ata_fail_requests(ch, &ch->device[SLAVE]);
 	    ch->device[SLAVE].detach(&ch->device[SLAVE]);
-	    ata_fail_requests(ch, &ch->device[SLAVE]);
 	    free(ch->device[SLAVE].param, M_ATA);
 	    ch->device[SLAVE].param = NULL;
 	}
@@ -391,55 +392,51 @@
 ata_interrupt(void *data)
 {
     struct ata_channel *ch = (struct ata_channel *)data;
-    struct ata_request *request = ch->running;
-    int gotit = 0;
+    struct ata_request *request;
 
-    /* ignore interrupt if there is no running request */
-    if (!request) 
-	return;
+    mtx_lock(&ch->state_mtx);
+    do {
+	/* do we have a running request */
+	if (!(request = ch->running))
+	    break;
 
-    ATA_DEBUG_RQ(request, "interrupt");
+	ATA_DEBUG_RQ(request, "interrupt");
 
-    /* ignore interrupt if device is busy */
-    if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY) {
-    	DELAY(100);
-	if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY)
-	    return;
-    }
+	/* ignore interrupt if device is busy */
+	if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY) {
+	    DELAY(100);
+	    if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY)
+		break;
+	}
 
-    ATA_DEBUG_RQ(request, "interrupt accepted");
-
-    mtx_lock(&ch->state_mtx);
-    if (ch->state == ATA_ACTIVE) {
-	ch->state = ATA_INTERRUPT;
-	gotit = 1;
-    }
-    else
-	ata_printf(ch, -1,
-		   "unexpected state in ata_interrupt 0x%02x\n", ch->state);
-    mtx_unlock(&ch->state_mtx);
-
-    /* if we got our locks finish up this request */
-    if (gotit) {
-	request->flags |= ATA_R_INTR_SEEN;
-	if (ch->hw.end_transaction(request) == ATA_OP_CONTINUES) {
-	    request->flags &= ~ATA_R_INTR_SEEN;
-	    mtx_lock(&ch->state_mtx);
-	    ch->state = ATA_ACTIVE;
-	    mtx_unlock(&ch->state_mtx);
+	/* check for the right state */
+	if (ch->state == ATA_ACTIVE) {
+	    request->flags |= ATA_R_INTR_SEEN;
+	    ch->state = ATA_INTERRUPT;
 	}
 	else {
+	    ata_prtdev(request->device,
+		       "interrupt state=%d unexpected\n", ch->state);
+	    break;
+	}
+
+	if (ch->hw.end_transaction(request) == ATA_OP_FINISHED) {
 	    ch->running = NULL;
-	    mtx_lock(&ch->state_mtx);
 	    if (ch->flags & ATA_IMMEDIATE_MODE)
-	        ch->state = ATA_ACTIVE;
+		ch->state = ATA_ACTIVE;
 	    else
 		ch->state = ATA_IDLE;
 	    mtx_unlock(&ch->state_mtx);
 	    ch->locking(ch, ATA_LF_UNLOCK);
 	    ata_finish(request);
+	    return;
 	}
-    }
+	else {
+	    request->flags &= ~ATA_R_INTR_SEEN;
+	    ch->state = ATA_ACTIVE;
+	}
+    } while (0);
+    mtx_unlock(&ch->state_mtx);
 }
 
 /*

==== //depot/projects/smpng/sys/dev/ata/ata-queue.c#21 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.36 2004/10/06 19:46:08 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.37 2004/10/13 15:16:35 sos Exp $");
 
 #include "opt_ata.h"
 #include <sys/param.h>
@@ -157,7 +157,6 @@
 ata_start(struct ata_channel *ch)
 {
     struct ata_request *request;
-    int gotit = 0;
 
     /* if in immediate mode, just skip start requests (stall queue) */
     if (ch->flags & ATA_IMMEDIATE_MODE)
@@ -174,42 +173,40 @@
 	mtx_lock(&ch->queue_mtx);
     }
 
-    /* if we have work todo, try to grap the ATA HW and start transaction */
+    /* if we have a request on the queue try to get it running */
     if ((request = TAILQ_FIRST(&ch->ata_queue))) {
+
+	/* we need the locking function to get the lock for this channel */
 	if (ch->locking(ch, ATA_LF_LOCK) == ch->unit) {
+
+	    /* check for the right state */
 	    mtx_lock(&ch->state_mtx);
-		if (ch->state == ATA_IDLE) {
-		ch->state = ATA_ACTIVE;
-		gotit = 1;
-	    }
-	    mtx_unlock(&ch->state_mtx);
-	}
-	if (!gotit) {
-	    mtx_unlock(&ch->queue_mtx);
-	    return;
-	}
-	TAILQ_REMOVE(&ch->ata_queue, request, chain);
-	mtx_unlock(&ch->queue_mtx);
-	ATA_DEBUG_RQ(request, "starting");
+	    if (ch->state == ATA_IDLE) {
+		TAILQ_REMOVE(&ch->ata_queue, request, chain);
+		ch->running = request;
+
+		ATA_DEBUG_RQ(request, "starting");
 
-	/* arm timeout */
-	if (!dumping)
-	    callout_reset(&request->callout, request->timeout * hz,
-			  (timeout_t*)ata_timeout, request);
+		if (!dumping)
+		    callout_reset(&request->callout, request->timeout * hz,
+				  (timeout_t*)ata_timeout, request);
 
-	/* kick HW into action */
-	ch->running = request;
-	if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
-	    ch->running = NULL;
-	    mtx_lock(&ch->state_mtx);
-	    ch->state = ATA_IDLE;
+		if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
+		    ch->running = NULL;
+		    ch->state = ATA_IDLE;
+		    mtx_unlock(&ch->queue_mtx);
+		    mtx_unlock(&ch->state_mtx);
+		    ch->locking(ch, ATA_LF_UNLOCK);
+		    ata_finish(request);
+		    return;
+		}
+		else
+		    ch->state = ATA_ACTIVE;
+	    }
 	    mtx_unlock(&ch->state_mtx);
-	    ata_finish(request);
-            ch->locking(ch, ATA_LF_UNLOCK);
 	}
     }
-    else
-	mtx_unlock(&ch->queue_mtx);
+    mtx_unlock(&ch->queue_mtx);
 }
 
 void
@@ -224,12 +221,12 @@
     }
     else {
 	if (request->bio && !(request->flags & ATA_R_TIMEOUT)) {
-	    ATA_DEBUG_RQ(request, "finish via bio_taskqueue");
+	    ATA_DEBUG_RQ(request, "finish bio_taskqueue");
 	    bio_taskqueue(request->bio, (bio_task_t *)ata_completed, request);
 	}
 	else {
 	    TASK_INIT(&request->task, 0, ata_completed, request);
-	    ATA_DEBUG_RQ(request, "finish via taskqueue_thread");
+	    ATA_DEBUG_RQ(request, "finish taskqueue_thread");
 	    taskqueue_enqueue(taskqueue_thread, &request->task);
 	}
     }
@@ -243,19 +240,24 @@
 
     ATA_DEBUG_RQ(request, "completed entered");
 
-    /* did everything go according to plan ? */
+    /* if we had a timeout, reinit channel and deal with the falldown */
     if (request->flags & ATA_R_TIMEOUT) {
+	int error = ata_reinit(ch);
 
-	/* if reinit succeeds and retries still permit, reinject request */
-	if (!ata_reinit(ch) && request->retries-- > 0) {
+	/* if our device disappeared return as cleanup was done already */
+	if (!request->device->param)
+	    return;
+	
+	/* if reinit succeeded and retries still permit, reinject request */
+	if (!error && request->retries-- > 0) {
 	    request->flags &= ~(ATA_R_TIMEOUT | ATA_R_DEBUG);
 	    request->flags |= (ATA_R_IMMEDIATE | ATA_R_REQUEUE);
-	    ATA_DEBUG_RQ(request, "completed reinjecting");
+	    ATA_DEBUG_RQ(request, "completed reinject");
 	    ata_queue_request(request);
 	    return;
 	}
 
-	/* finish with error */
+	/* nothing more to try so finish with error */
 	if (!(request->flags & ATA_R_QUIET))
 	    ata_prtdev(request->device,
 		       "FAILURE - %s timed out\n",
@@ -267,7 +269,7 @@
 	/* untimeout request now we have control back */
 	callout_drain(&request->callout);
 
-	/* do the all the magic for completition evt retry etc etc */
+	/* if this is a soft ECC error warn about it */
 	if ((request->status & (ATA_S_CORR | ATA_S_ERROR)) == ATA_S_CORR) {
 	    ata_prtdev(request->device,
 		       "WARNING - %s soft error (ECC corrected)",
@@ -408,14 +410,12 @@
 ata_timeout(struct ata_request *request)
 {
     struct ata_channel *ch = request->device->channel;
-    int gotit = 0;
 
-    /* mark request as no longer running we'll shoot it down shortly */
-    ch->running = NULL;
+    mtx_lock(&ch->state_mtx);
 
     ATA_DEBUG_RQ(request, "timeout");
 
-    /* if we saw an interrupt before the timeout, shout and re_arm timeout */
+    /* if interrupt has been seen, shout and just rearm timeout */
     if (request->flags & ATA_R_INTR_SEEN) {
         ata_prtdev(request->device,
 		   "WARNING - %s interrupt was seen but timeout fired",
@@ -428,48 +428,47 @@
 	if (!dumping)
 	    callout_reset(&request->callout, request->timeout * hz,
 			  (timeout_t*)ata_timeout, request);
+	mtx_unlock(&ch->state_mtx);
 	return;
     }
 
-    /* report that we timed out if we have any retries left */
-    if (!(request->flags & ATA_R_QUIET) && request->retries > 0) {
-	ata_prtdev(request->device,
-		   "TIMEOUT - %s retrying (%d retr%s left)",
-		   ata_cmd2str(request), request->retries,
-		   request->retries == 1 ? "y" : "ies");
-	if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
-	    printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
-	printf("\n");
-    }
-
     /*
-     * if we are waiting for a commend to complete set ATA_TIMEOUT so
+     * if we are waiting for a command to complete set ATA_TIMEOUT so
      * we wont loose the race with an eventual interrupt arriving late
      */
-    mtx_lock(&ch->state_mtx);
     if (ch->state == ATA_ACTIVE) {
+	request->flags |= ATA_R_TIMEOUT;
         ch->state = ATA_TIMEOUT;
-	gotit = 1;
-    }
-    else
-	ata_printf(ch, -1,
-		   "unexpected state in ata_timeout 0x%02x\n", ch->state);
-    mtx_unlock(&ch->state_mtx);
-    
-    /* we got our locks now try to clean up the situation */
-    if (gotit) {
-	request->flags |= ATA_R_TIMEOUT;
+        ch->running = NULL;
+	if (!(request->flags & ATA_R_QUIET) && request->retries > 0) {
+	    ata_prtdev(request->device,
+		       "TIMEOUT - %s retrying (%d retr%s left)",
+		       ata_cmd2str(request), request->retries,
+		       request->retries == 1 ? "y" : "ies");
+	    if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
+		printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
+	    printf("\n");
+	}
 	ch->hw.end_transaction(request);
+	mtx_unlock(&ch->state_mtx);
 	ata_finish(request);
     }
+    else {
+	mtx_unlock(&ch->state_mtx);
+	ata_prtdev(request->device, "timeout state=%d unexpected\n", ch->state);
+    }
 }
 
 void
 ata_catch_inflight(struct ata_channel *ch)
 {
-    struct ata_request *request = ch->running;
+    struct ata_request *request;
 
+    mtx_lock(&ch->state_mtx);
+    request = ch->running;
     ch->running = NULL;
+    mtx_unlock(&ch->state_mtx);
+
     if (request) {
         callout_drain(&request->callout);
         ata_prtdev(request->device,
@@ -502,10 +501,14 @@
     }
     mtx_unlock(&ch->queue_mtx);
 
+    mtx_lock(&ch->state_mtx);
+    request = ch->running;
+    ch->running = NULL;
+    mtx_unlock(&ch->state_mtx);
+
     /* if we have a request "in flight" fail it as well */
-    if ((request = ch->running) && (!device || request->device == device)){
+    if (request && (!device || request->device == device)) {
 	callout_drain(&request->callout);
-	ch->running = NULL;
 	request->result = ENXIO;
 	if (request->callback)
 	    (request->callback)(request);

==== //depot/projects/smpng/sys/dev/cx/if_cx.c#14 (text+ko) ====

@@ -23,17 +23,10 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cx/if_cx.c,v 1.32 2004/09/23 12:21:11 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cx/if_cx.c,v 1.34 2004/10/13 09:27:18 phk Exp $");
 
 #include <sys/param.h>
 
-#if __FreeBSD_version >= 500000
-#   define NCX 1
-#else
-#   include "cx.h"
-#endif
-
-#if NCX > 0
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
@@ -44,6 +37,7 @@
 #include <sys/socket.h>
 #include <sys/conf.h>
 #include <sys/errno.h>
+#include <sys/serial.h>
 #include <sys/tty.h>
 #include <sys/bus.h>
 #include <machine/bus.h>
@@ -57,14 +51,7 @@
 #include <machine/cpufunc.h>
 #include <machine/cserial.h>
 #include <machine/clock.h>
-#if __FreeBSD_version < 500000
-#   include <machine/ipl.h>
-#   include <i386/isa/isa_device.h>
-#endif
 #include <machine/resource.h>
-#if __FreeBSD_version <= 501000
-#   include <i386/isa/intr_machdep.h>
-#endif
 #include <dev/cx/machdep.h>
 #include <dev/cx/cxddk.h>
 #include <dev/cx/cronyxfw.h>
@@ -76,30 +63,12 @@
 #   include <dev/cx/ng_cx.h>
 #else
 #   include <net/if_types.h>
-#   if __FreeBSD_version < 500000
-#   include "sppp.h"
-#   if NSPPP <= 0
-#	error The device cx requires sppp or netgraph.
-#   endif
-#   endif
 #   include <net/if_sppp.h>
 #   define PP_CISCO IFF_LINK2
-#   if __FreeBSD_version < 500000
-#	include <bpf.h>
-#   endif
 #   include <net/bpf.h>
-#   define NBPFILTER NBPF
 #endif
 
-#if __FreeBSD_version < 502113
-#define ttyld_modem(foo, bar) ((*linesw[(foo)->t_line].l_modem)((foo), (bar)))
-#define ttyld_rint(foo, bar) ((*linesw[(foo)->t_line].l_rint)((bar), (foo)))
-#define ttyld_start(foo) ((*linesw[(foo)->t_line].l_start)((foo)))
-#define ttyld_open(foo, bar) ((*linesw[(foo)->t_line].l_open) ((bar), (foo)))
-#define ttyld_close(foo, bar) ((*linesw[(foo)->t_line].l_close) ((foo), (bar)))
-#define ttyld_read(foo, bar, barf) ((*linesw[(foo)->t_line].l_read) ((foo), (bar), (barf)))
-#define ttyld_write(foo, bar, barf) ((*linesw[(foo)->t_line].l_write) ((foo), (bar), (barf)))
-#endif
+#define NCX	1
 
 /* If we don't have Cronyx's sppp version, we don't have fr support via sppp */
 #ifndef PP_FR
@@ -111,12 +80,6 @@
 #define CX_DEBUG2(d,s)	({if (d->chan->debug>1) {\
 				printf ("%s: ", d->name); printf s;}})
 
-#define UNIT(d)		(minor(d) & 0x3f)
-#define IF_CUNIT(d)	(minor(d) & 0x40)
-#define UNIT_CTL	0x3f
-#define CALLOUT(d)	(minor(d) & 0x80)
-#define CDEV_MAJOR	42
-
 typedef struct _async_q {
 	int beg;
 	int end;
@@ -134,6 +97,9 @@
 static int cx_probe		__P((device_t));
 static int cx_attach		__P((device_t));
 static int cx_detach		__P((device_t));
+static t_open_t			cx_topen;
+static t_modem_t		cx_tmodem;
+static t_close_t		cx_tclose;
 
 static device_method_t cx_isa_methods [] = {
 	DEVMETHOD(device_identify,	cx_identify),
@@ -147,10 +113,8 @@
 	unsigned long	phys;
 	void		*virt;
 	size_t		size;
-#if __FreeBSD_version >= 500000
 	bus_dma_tag_t	dmat;
 	bus_dmamap_t	mapp;
-#endif
 } cx_dma_mem_t;
 
 typedef struct _drv_t {
@@ -177,7 +141,7 @@
 #else
 	struct sppp pp;
 #endif
-	struct cdev *devt[3];
+	struct cdev *devt;
 	async_q aqueue;
 #define CX_READ 1
 #define CX_WRITE 2
@@ -220,15 +184,8 @@
 static void cx_modem (cx_chan_t *c);
 static void cx_up (drv_t *d);
 static void cx_start (drv_t *d);
-#if __FreeBSD_version < 502113
-static void ttyldoptim(struct tty *tp);
-#endif
-#if __FreeBSD_version < 500000
-static swihand_t cx_softintr;
-#else
 static void cx_softintr (void *);
 static void *cx_fast_ih;
-#endif
 static void cx_down (drv_t *d);
 static void cx_watchdog (drv_t *d);
 static void cx_carrier (void *arg);
@@ -335,11 +292,7 @@
 			if (d->tty->t_dev) {
 				d->intr_action |= CX_WRITE;
 				MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 				swi_sched (cx_fast_ih, 0);
-#else
-				setsofttty ();
-#endif
 			}
 			CX_DEBUG (d, ("cx_timeout\n"));
 		}
@@ -579,7 +532,6 @@
 	return 0;
 }
 
-#if __FreeBSD_version >= 500000
 static void
 cx_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error)
 {
@@ -636,28 +588,6 @@
 	bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
 	bus_dma_tag_destroy (dmem->dmat);
 }
-#else
-static int
-cx_bus_dma_mem_alloc (int bnum, int cnum, cx_dma_mem_t *dmem)
-{
-	dmem->virt = contigmalloc (dmem->size, M_DEVBUF, M_WAITOK,
-				   0x100000, 0x1000000, 16, 0);
-	if (dmem->virt == NULL) {
-		if (cnum >= 0)	printf ("cx%d-%d: ", bnum, cnum);
-		else		printf ("cx%d: ", bnum);
-		printf ("couldn't allocate memory for dma memory\n", unit);
- 		return 0;
-	}
-	dmem->phys = vtophys (dmem->virt);
-	return 1;
-}
-
-static void
-cx_bus_dma_mem_free (cx_dma_mem_t *dmem)
-{
-	contigfree (dmem->virt, dmem->size, M_DEVBUF);
-}
-#endif
 
 /*
  * The adapter is present, initialize the driver structures.
@@ -801,8 +731,6 @@
 	printf ("cx%d: <Cronyx-Sigma-%s>\n", b->num, b->name);
 
 	for (c=b->chan; c<b->chan+NCHAN; ++c) {
-		char *dnmt="tty %x";
-		char *dnmc="cua %x";
 		if (c->type == T_NONE)
 			continue;
 		d = &bd->channel[c->num];
@@ -832,21 +760,12 @@
 			cx_bus_dma_mem_free (&d->dmamem);
 			continue;
 		}
-#if __FreeBSD_version >= 500000
 		NG_NODE_SET_PRIVATE (d->node, d);
-#else
-		d->node->private = d;
-#endif
 		sprintf (d->nodename, "%s%d", NG_CX_NODE_TYPE,
 			 c->board->num*NCHAN + c->num);
 		if (ng_name_node (d->node, d->nodename)) {
 			printf ("%s: cannot name node\n", d->nodename);
-#if __FreeBSD_version >= 500000
 			NG_NODE_UNREF (d->node);
-#else
-			ng_rmnode (d->node);
-			ng_unref (d->node);
-#endif
 			channel [b->num*NCHAN + c->num] = 0;
 			c->sys = 0;
 			cx_bus_dma_mem_free (&d->dmamem);
@@ -854,18 +773,11 @@
 		}
 		d->lo_queue.ifq_maxlen = IFQ_MAXLEN;
 		d->hi_queue.ifq_maxlen = IFQ_MAXLEN;
-#if __FreeBSD_version >= 500000
 		mtx_init (&d->lo_queue.ifq_mtx, "cx_queue_lo", NULL, MTX_DEF);
 		mtx_init (&d->hi_queue.ifq_mtx, "cx_queue_hi", NULL, MTX_DEF);
-#endif		
 #else /*NETGRAPH*/
 		d->pp.pp_if.if_softc    = d;
-#if __FreeBSD_version > 501000
 		if_initname (&d->pp.pp_if, "cx", b->num * NCHAN + c->num);
-#else
-		d->pp.pp_if.if_unit	= b->num * NCHAN + c->num;
-		d->pp.pp_if.if_name	= "cx";
-#endif
 		d->pp.pp_if.if_mtu	= PP_MTU;
 		d->pp.pp_if.if_flags	= IFF_POINTOPOINT | IFF_MULTICAST |
 					  IFF_NEEDSGIANT;
@@ -882,16 +794,23 @@
 		bpfattach (&d->pp.pp_if, DLT_PPP, 4);
 #endif /*NETGRAPH*/
 		}
+		d->tty = ttyalloc ();
+		d->tty->t_open = cx_topen;
+		d->tty->t_close = cx_tclose;
+		d->tty->t_param = cx_param;
+		d->tty->t_stop  = cx_stop;
+		d->tty->t_modem  = cx_tmodem;
+		d->tty->t_sc = d;
 		cx_start_chan (c, d->dmamem.virt, d->dmamem.phys);
 		cx_register_receive (c, &cx_receive);
 		cx_register_transmit (c, &cx_transmit);
 		cx_register_error (c, &cx_error);
 		cx_register_modem (c, &cx_modem);
-		dnmt[3] = 'x'+b->num;
-		dnmc[3] = 'x'+b->num;
-		d->devt[0] = make_dev (&cx_cdevsw, b->num*NCHAN + c->num, UID_ROOT, GID_WHEEL, 0644, dnmt, b->num*NCHAN + c->num);
-		d->devt[1] = make_dev (&cx_cdevsw, b->num*NCHAN + c->num + 64, UID_ROOT, GID_WHEEL, 0600, "cx%d", b->num*NCHAN + c->num);
-		d->devt[2] = make_dev (&cx_cdevsw, b->num*NCHAN + c->num + 128, UID_ROOT, GID_WHEEL, 0660, dnmc, b->num*NCHAN + c->num);
+
+		ttycreate(d->tty, NULL, 0, MINOR_CALLOUT,
+		    "x%r%r", b->num, c->num);
+		d->devt = make_dev (&cx_cdevsw, b->num*NCHAN + c->num + 64, UID_ROOT, GID_WHEEL, 0600, "cx%d", b->num*NCHAN + c->num);
+		d->devt->si_drv1 = d;
 	}
 	splx (s);
 
@@ -958,15 +877,12 @@
 		if (!d || d->chan->type == T_NONE)
 			continue;
 			
-#if __FreeBSD_version >= 502113
 		if (d->tty) {
-			ttyrel (d->tty);
+			ttyfree (d->tty);
 			d->tty = NULL;
 		}
-#endif
 
 #ifdef NETGRAPH
-#if __FreeBSD_version >= 500000
 		if (d->node) {
 			ng_rmnode_self (d->node);
 			NG_NODE_UNREF (d->node);
@@ -975,22 +891,14 @@
 		mtx_destroy (&d->lo_queue.ifq_mtx);
 		mtx_destroy (&d->hi_queue.ifq_mtx);
 #else
-		ng_rmnode (d->node);
-		d->node = NULL;
-#endif		
-#else
-#if __FreeBSD_version >= 410000 && NBPFILTER > 0
 		/* Detach from the packet filter list of interfaces. */
 		bpfdetach (&d->pp.pp_if);
-#endif
 		/* Detach from the sync PPP list. */
 		sppp_detach (&d->pp.pp_if);
 
 		if_detach (&d->pp.pp_if);
 #endif		
-		destroy_dev (d->devt[0]);
-		destroy_dev (d->devt[1]);
-		destroy_dev (d->devt[2]);
+		destroy_dev (d->devt);
 	}
 
 	cx_led_off (b);
@@ -1167,11 +1075,7 @@
 			return;
 #ifndef NETGRAPH
 		if (d->pp.pp_if.if_bpf)
-#if __FreeBSD_version >= 500000
 			BPF_MTAP (&d->pp.pp_if, m);
-#else
-			bpf_mtap (&d->pp.pp_if, m);
-#endif
 #endif
 		len = m->m_pkthdr.len;
 		if (! m->m_next)
@@ -1248,11 +1152,7 @@
 		if (d->tty->t_dev) {
 			d->intr_action |= CX_WRITE;
 			MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 			swi_sched (cx_fast_ih, 0);
-#else
-			setsofttty ();
-#endif
 		}
 		return;
 	}
@@ -1274,7 +1174,7 @@
 	drv_t *d = c->sys;
 	struct mbuf *m;
 	char *cc = data;
-#if __FreeBSD_version >= 500000 && defined NETGRAPH
+#if defined NETGRAPH
 	int error;
 #endif
 
@@ -1302,11 +1202,7 @@
 
 			d->intr_action |= CX_READ;
 			MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 			swi_sched (cx_fast_ih, 0);
-#else
-			setsofttty ();
-#endif
 		}
 		return;
 	}
@@ -1325,41 +1221,24 @@
 		printmbuf (m);
 #ifdef NETGRAPH
 	m->m_pkthdr.rcvif = 0;
-#if __FreeBSD_version >= 500000
 	NG_SEND_DATA_ONLY (error, d->hook, m);
 #else
-	ng_queue_data (d->hook, m, 0);
-#endif
-#else
 	++d->pp.pp_if.if_ipackets;
 	m->m_pkthdr.rcvif = &d->pp.pp_if;
 	/* Check if there's a BPF listener on this interface.
 	 * If so, hand off the raw packet to bpf. */
 	if (d->pp.pp_if.if_bpf)
-#if __FreeBSD_version >= 500000
 		BPF_TAP (&d->pp.pp_if, data, len);
-#else
-		bpf_tap (&d->pp.pp_if, data, len);
-#endif
 	sppp_input (&d->pp.pp_if, m);
 #endif
 }
 
-#if __FreeBSD_version < 502113
-#define CONDITION(t,tp) (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))\
-	    && (!(tp->t_iflag & BRKINT) || (tp->t_iflag & IGNBRK))\
-	    && (!(tp->t_iflag & PARMRK)\
-		|| (tp->t_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))\
-	    && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))\
-	    && linesw[tp->t_line].l_rint == ttyinput)
-#else
 #define CONDITION(t,tp) (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))\
 	    && (!(tp->t_iflag & BRKINT) || (tp->t_iflag & IGNBRK))\
 	    && (!(tp->t_iflag & PARMRK)\
 		|| (tp->t_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))\
 	    && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))\
 	    && linesw[tp->t_line]->l_rint == ttyinput)
-#endif
 
 /*
  * Error callback function.
@@ -1384,11 +1263,7 @@
 			AQ_PUSH (q, TTY_FE);
 			d->intr_action |= CX_READ;
 			MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 			swi_sched (cx_fast_ih, 0);
-#else
-			setsofttty ();
-#endif
 		}
 #ifndef NETGRAPH
 		else
@@ -1405,11 +1280,7 @@
 			AQ_PUSH (q, TTY_PE);
 			d->intr_action |= CX_READ;
 			MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 			swi_sched (cx_fast_ih, 0);
-#else
-			setsofttty ();
-#endif
 		}
 #ifndef NETGRAPH
 		else
@@ -1425,11 +1296,7 @@
 			AQ_PUSH (q, TTY_OE);
 			d->intr_action |= CX_READ;
 			MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 			swi_sched (cx_fast_ih, 0);
-#else
-			setsofttty ();
-#endif
 		}
 #endif
 #ifndef NETGRAPH
@@ -1468,11 +1335,7 @@
 			AQ_PUSH (q, TTY_BI);
 			d->intr_action |= CX_READ;
 			MY_SOFT_INTR = 1;
-#if __FreeBSD_version >= 500000
 			swi_sched (cx_fast_ih, 0);
-#else
-			setsofttty ();
-#endif
 		}
 #ifndef NETGRAPH
 		else
@@ -1484,233 +1347,92 @@
 	}
 }
 
-#if __FreeBSD_version < 500000
-static int cx_open (dev_t dev, int flag, int mode, struct proc *p)
-#else
-static int cx_open (struct cdev *dev, int flag, int mode, struct thread *td)
-#endif
+static int cx_topen (struct tty *tp, struct cdev *dev)
 {
-	int unit = UNIT (dev);
 	drv_t *d;
-	int error;
 

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410131755.i9DHthRK026941>