Subject: wierd ADB init stuff
To: None <macbsd-development@NetBSD.ORG>
From: Daniel Risacher <>
List: macbsd-development
Date: 05/28/1995 14:37:12
As most of you know, the IIsi ADB will now initialize, but
only with MRG_DEBUG defined.  I thought that this was a timing
problem, but now I'm not so sure.  I'm looking for some

In my efforts to clean up the IIsi ADB init code I have winnowed 
down the MRG_DEBUG print statements to two printf's in
mrg_aline_super(), and those statements only are called when the
trap is 0xa71e.  Both printf statements can be printing NULL 
strings, and it will still work, but there must be *two* of them.
If there is only one printf statement, then the ADB won't initialize,
and interestingly, that one printf doesn't actually happen.

This makes me believe that it is some sort of wierd stack thing.
If any would care to speculate on this I would really like to 
hear it, because I'm totally puzzled. The code is included below.

-Dan Risacher

void mrg_aline_super(struct frame *frame)
        caddr_t trapaddr;
        u_short trapword;
        int isOStrap;
        int trapnum;
        int a0passback;
        u_long a0bucket, d0bucket;
        int danprint =0;

        trapword = *(u_short *)frame->f_pc;
        if (trapword == 0xa71e)
          danprint = 1;

        isOStrap = ! TRAP_TOOLBOX(trapword);
        trapnum = TRAP_NUM(trapword);

#if defined(MRG_DEBUG) || 1
        if (danprint)
	   /* DRR - Without these print statements, ADBReInit fails */
            printf(""); printf("");

        /* Only OS Traps come to us; _alinetrap takes care of ToolBox
          traps, which are a horrible Frankenstein-esque abomination. */

        trapaddr = mrg_OStraps[trapnum];
        if(trapaddr == NULL){
                printf("unknown %s trap 0x%x, no trap address available\n",
                        isOStrap ? "OS" : "ToolBox", trapword);
        a0passback = TRAP_PASSA0(trapword);

/*      put trapword in d1 */
/*      put trapaddr in a1 */
/*      put a0 in a0 */
/*      put d0 in d0 */
/* save a6 */
/*      call the damn routine */
/* restore a6 */
/*      store d0 in d0bucket */
/*      store a0 in d0bucket */
/* This will change a1,d1,d0,a0 and possibly a6 */

                movl    %2, a1
                movw    %3, d1
                movl    %4, d0
                movl    %5, a0
                jbsr    a1@
                movl    a0, %0
                movl    d0, %1"

                : "=g" (a0bucket), "=g" (d0bucket)

                : "g" (trapaddr), "g" (trapword),
                        "m" (frame->f_regs[0]), "m" (frame->f_regs[8])

                : "d0", "d1", "a0", "a1", "a6"


#if defined(MRG_TRACE)
#if defined(MRG_DEBUG) 
        printf(" bk");

        frame->f_regs[0] = d0bucket;
                frame->f_regs[8] = a0bucket;

        frame->f_pc += 2;       /* skip offending instruction */

#if defined(MRG_DEBUG)
        printf(" exit\n");