Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ieee1394 Checkpoint checkin:



details:   https://anonhg.NetBSD.org/src/rev/f68425020364
branches:  trunk
changeset: 540021:f68425020364
user:      jmc <jmc%NetBSD.org@localhost>
date:      Sun Dec 01 12:09:56 2002 +0000

description:
Checkpoint checkin:
1. Clean up some debugging and trigger some on only extreme debugging needs
2. Comment alloc data mapping a bit better and fix some of the bugs here
(note..there still are some so for now the free method is never called while
I track these down)
3. Fix the copying logic in data_resp. It was calculating negative offsets
which blew up memcpy.

At this point I can probe, inquire and get through the findroot steps of a
boot:

sd0 at scsibus0 target 0 lun 0: <Maxtor, 1394 storage, 60> disk fixed
sd0: mode sense (4) returned nonsense; using fictitious geometry
sd0: 76293 MB, 76293 cyl, 64 head, 32 sec, 512 bytes/sect x 156250000 sectors
sd0: mode sense (4) returned nonsense; using fictitious geometry
sd0: no disk label
findroot: can't open dev sd0a (6)

NOTE: This will panic my machine right now with a simple disklabel -r sd0.
Also, since the free mappings routines are if (0)'d out at the moment do not
use this code for anything except experiments and then only on a machine
you don't mind panic'ing.

Fixing the mapping routines will be the next step and then finally chasing
down the proper mode sense these drives understand.

diffstat:

 sys/dev/ieee1394/sbp2.c |  26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diffs (97 lines):

diff -r cecb9c210b32 -r f68425020364 sys/dev/ieee1394/sbp2.c
--- a/sys/dev/ieee1394/sbp2.c   Sun Dec 01 12:05:11 2002 +0000
+++ b/sys/dev/ieee1394/sbp2.c   Sun Dec 01 12:09:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbp2.c,v 1.3 2002/11/30 06:18:54 jmc Exp $     */
+/*     $NetBSD: sbp2.c,v 1.4 2002/12/01 12:09:56 jmc Exp $     */
 
 /*
  * Copyright (c) 2001,2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbp2.c,v 1.3 2002/11/30 06:18:54 jmc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbp2.c,v 1.4 2002/12/01 12:09:56 jmc Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -831,7 +831,7 @@
                     abuf->ab_length));
 
 #ifdef SBP2_DEBUG
-        if (sbp2debug > 2) {
+        if ((sbp2debug > 3) && orb->lun) {
                orb->lun->status.ab_addr = 
                    orb->lun->cmdreg + SBP2_CMDREG_AGENT_STATE;
                orb->lun->status.ab_cb = sbp2_agent_status;
@@ -990,7 +990,7 @@
        simple_lock(&orb->orb_lock);
 
        addr = orb->data_map.laddr;
-       offset = orb->data_map.fwaddr - abuf->ab_addr;
+       offset = abuf->ab_addr - orb->data_map.fwaddr;
        switch (abuf->ab_tcode) {
        case IEEE1394_TCODE_WRITE_REQ_BLOCK:
                memcpy(addr + offset, abuf->ab_data, abuf->ab_retlen);
@@ -1102,10 +1102,10 @@
 {
        simple_lock(&orb->orb_lock);
        if (orb->data_map.laddr) {
-               orb->sbp2->sc->sc1394_callback.sc1394_unreg(&orb->data, 1);
-               sbp2_free_data_mapping(orb->sbp2, &orb->data_map);
+               if (0) orb->sbp2->sc->sc1394_callback.sc1394_unreg(&orb->data, 1);
+               if (0) sbp2_free_data_mapping(orb->sbp2, &orb->data_map);
        }
-       sbp2_free_addr(orb->sbp2, orb->cmd.ab_addr);
+       if (0) sbp2_free_addr(orb->sbp2, orb->cmd.ab_addr);
 
        simple_lock(&sbp2_freeorbs_lock);
        memset(orb->cmd.ab_data, 0, SBP2_MAX_ORB);
@@ -1130,7 +1130,8 @@
        unsigned char bit;
        
        size = datalen / SBP_DATA_BLOCK_SIZE;
-       size++;
+       if (datalen % SBP_DATA_BLOCK_SIZE)
+               size++;
 
        map->laddr = data;
        map->size = datalen;
@@ -1160,6 +1161,8 @@
        }
 
        /* Gets a little complicated to handle crossing bytes on the ends. */
+       
+       /* Handle the bits on the front end if they start in the middle */
        if (startbit) {
                if (size < CHAR_BIT) 
                        count = CHAR_BIT - (size - 1);
@@ -1172,6 +1175,8 @@
                }
                startbyte++;
        }
+
+       /* Allocate bytes at a time */
        if (size) {
                for (byte = startbyte; byte < (size / CHAR_BIT); byte++) {
                        for (bitpos = 0; bitpos < CHAR_BIT; bitpos++) {
@@ -1180,6 +1185,7 @@
                                sbp2->map->datamap[byte] |= bit;
                        }
                }
+               /* If any bits are left allocate them out of the next byte */
                if (size) {
                        for (bitpos = 0; bitpos < size; bitpos++) {
                                bit = 0x1 << bitpos;
@@ -1187,6 +1193,10 @@
                        }
                }
        }
+
+       sbp2->map->next_data = startbyte;
+
+       /* Adjust back one if the bits started 1 byte back */
        if (startbit)
                startbyte--;
        map->fwaddr = SBP_DATA_BEG +



Home | Main Index | Thread Index | Old Index