Port-mac68k archive

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

Re: NetBSD-current on Quadra 610



And here is the patch from mlestv (with bugs added by me) I talked about.

Martin
? compile/MAC-BETH
? compile/MAC-BETH_nossp
? conf/MAC-BETH
Index: dev/adb_direct.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/dev/adb_direct.c,v
retrieving revision 1.66
diff -u -p -r1.66 adb_direct.c
--- dev/adb_direct.c    25 Oct 2013 21:19:56 -0000      1.66
+++ dev/adb_direct.c    17 Aug 2014 16:35:02 -0000
@@ -385,7 +385,7 @@ adb_cuda_tickle(void)
  * called when when an adb interrupt happens
  *
  * Cuda version of adb_intr
- * TO DO: do we want to add some calls to intr_dispatch() here to
+ * TO DO: do we want to add some calls to intr_dispatch_serial() here to
  * grab serial interrupts?
  */
 void
@@ -721,7 +721,7 @@ adb_intr_II(void *arg)
 
        delay(ADB_DELAY);       /* yuck (don't remove) */
 
-       (void)intr_dispatch(0x70); /* grab any serial interrupts */
+       intr_dispatch_serial(); /* grab any serial interrupts */
 
        if (ADB_INTR_IS_ON)
                intr_on = 1;    /* save for later */
@@ -769,7 +769,7 @@ switch_start:
                        adbActionState = ADB_ACTION_IN;
                }
                delay(ADB_DELAY);
-               (void)intr_dispatch(0x70); /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
                goto switch_start;
                break;
        case ADB_ACTION_IDLE:
@@ -1263,7 +1263,7 @@ switch_start:
                ADB_SET_STATE_ACKON();  /* start ACK to ADB chip */
                delay(ADB_DELAY);       /* delay */
                ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */
-               (void)intr_dispatch(0x70); /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
                break;
 
        case ADB_ACTION_IN:
@@ -1277,7 +1277,7 @@ switch_start:
                ADB_SET_STATE_ACKON();  /* start ACK to ADB chip */
                delay(ADB_DELAY);       /* delay */
                ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */
-               (void)intr_dispatch(0x70); /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
 
                if (1 == ending) {      /* end of message? */
                        ADB_SET_STATE_INACTIVE();       /* signal end of frame 
*/
@@ -1324,7 +1324,7 @@ switch_start:
                                adbActionState = ADB_ACTION_OUT;        /* set 
next state */
 
                                delay(ADB_DELAY);       /* delay */
-                               (void)intr_dispatch(0x70); /* grab any serial 
interrupts */
+                               intr_dispatch_serial(); /* grab any serial 
interrupts */
 
                                if (ADB_INTR_IS_ON) {   /* ADB intr low during
                                                         * write */
@@ -1365,13 +1365,13 @@ switch_start:
                        adbWriteDelay = 1;      /* must retry when done with
                                                 * read */
                        delay(ADB_DELAY);       /* delay */
-                       (void)intr_dispatch(0x70); /* grab any serial 
interrupts */
+                       intr_dispatch_serial(); /* grab any serial interrupts */
                        goto switch_start;      /* process next state right
                                                 * now */
                        break;
                }
                delay(ADB_DELAY);       /* required delay */
-               (void)intr_dispatch(0x70); /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
 
                if (adbOutputBuffer[0] == adbSentChars) {       /* check for 
done */
                        if (0 == adb_cmd_result(adbOutputBuffer)) {     /* do 
we expect data
Index: dev/pm_direct.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/dev/pm_direct.c,v
retrieving revision 1.29
diff -u -p -r1.29 pm_direct.c
--- dev/pm_direct.c     25 Oct 2013 20:49:38 -0000      1.29
+++ dev/pm_direct.c     17 Aug 2014 16:35:02 -0000
@@ -297,7 +297,7 @@ pm_wait_busy(int xdelay)
 {
        while (PM_IS_ON) {
 #ifdef PM_GRAB_SI
-               (void)intr_dispatch(0x70);      /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
 #endif
                if ((--xdelay) < 0)
                        return 1;       /* timeout */
@@ -314,7 +314,7 @@ pm_wait_free(int xdelay)
 {
        while (PM_IS_OFF) {
 #ifdef PM_GRAB_SI
-               (void)intr_dispatch(0x70);      /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
 #endif
                if ((--xdelay) < 0)
                        return 0;       /* timeout */
@@ -1051,7 +1051,7 @@ pm_adb_op(u_char *buffer, void *compRout
                        break;
                }
 #ifdef PM_GRAB_SI
-               (void)intr_dispatch(0x70);      /* grab any serial interrupts */
+               intr_dispatch_serial(); /* grab any serial interrupts */
 #endif
                if ((--xdelay) < 0) {
                        splx(s);
Index: include/autoconf.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/include/autoconf.h,v
retrieving revision 1.12
diff -u -p -r1.12 autoconf.h
--- include/autoconf.h  4 Mar 2007 06:00:08 -0000       1.12
+++ include/autoconf.h  17 Aug 2014 16:35:02 -0000
@@ -63,6 +63,7 @@ void  setstatclockrate(int);
 void   disablertclock(void);
 void   mac68k_calibrate_delay(void);
 void   startrtclock(void);
+void   rtclock_intr(void *);
 
 /* macrom.c */
 void   mrg_init(void);
Index: include/intr.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/include/intr.h,v
retrieving revision 1.31
diff -u -p -r1.31 intr.h
--- include/intr.h      17 Jul 2008 16:13:33 -0000      1.31
+++ include/intr.h      17 Aug 2014 16:35:02 -0000
@@ -87,13 +87,16 @@ splraiseipl(ipl_cookie_t icookie)
 #include <sys/spl.h>
 
 /* intr.c */
+struct clockframe;
 void   intr_init(void);
 void   intr_establish(int (*)(void *), void *, int);
 void   intr_disestablish(int);
-void   intr_dispatch(int);
+void   intr_dispatch(struct clockframe*);
+void   intr_dispatch_serial(void);
 
 /* locore.s */
 int    spl0(void);
+void   mrg_VBLQueue(void);
 #endif /* _KERNEL */
 
 #endif /* _MAC68K_INTR_H_ */
Index: mac68k/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/clock.c,v
retrieving revision 1.49
diff -u -p -r1.49 clock.c
--- mac68k/clock.c      8 Feb 2011 20:20:18 -0000       1.49
+++ mac68k/clock.c      17 Aug 2014 16:35:02 -0000
@@ -103,7 +103,6 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
 int    clock_debug = 0;
 #endif
 
-void   rtclock_intr(void);
 static int mac68k_gettime(todr_chip_handle_t, struct timeval *);
 static int mac68k_settime(todr_chip_handle_t, struct timeval *);
 static u_int via1_t2_get_timecount(struct timecounter *);
@@ -195,6 +194,17 @@ disablertclock(void)
        via_reg(VIA1, vIER) = V1IF_T1;
 }
 
+void rtclock_intr(void *arg)
+{
+       struct clockframe *frame = (struct clockframe *)arg;
+       int s;
+
+       s = splclock();
+       hardclock(frame);
+       mrg_VBLQueue();
+       splx(s);
+}
+
 static u_int
 via1_t2_get_timecount(struct timecounter *tc)
 {
Index: mac68k/intr.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/intr.c,v
retrieving revision 1.29
diff -u -p -r1.29 intr.c
--- mac68k/intr.c       20 Dec 2010 00:25:36 -0000      1.29
+++ mac68k/intr.c       17 Aug 2014 16:35:02 -0000
@@ -206,12 +206,13 @@ intr_disestablish(int ipl)
  * XXX Note: see the warning in intr_establish()
  */
 void
-intr_dispatch(int evec)                /* format | vector offset */
+intr_dispatch(struct clockframe *frame)
 {
        int ipl, vec;
+       void *arg;
 
        idepth++;
-       vec = (evec & 0xfff) >> 2;
+       vec = (frame->vo & 0xfff) >> 2;
 #ifdef DIAGNOSTIC
        if ((vec < ISRLOC) || (vec >= (ISRLOC + NISR)))
                panic("intr_dispatch: bad vec 0x%x", vec);
@@ -221,11 +222,30 @@ intr_dispatch(int evec)           /* format | vec
        intrcnt[ipl]++;
        curcpu()->ci_data.cpu_nintr++;
 
-       (void)(*intr_func[ipl])(intr_arg[ipl]);
+       /*
+        * intr_func only has one argument but hardclock needs the
+        * clock frame.
+        */
+       if (ipl == mac68k_machine.via1_ipl)
+               arg = (void*)frame;
+       else
+               arg = intr_arg[ipl];
+
+       (void)(*intr_func[ipl])(arg);
        idepth--;
 }
 
 /*
+ * poll serial interrupt from adb_direct or pm_direct
+ */
+void
+intr_dispatch_serial(void)
+{
+       struct clockframe F;
+       intr_dispatch(&F);
+}
+
+/*
  * Default interrupt handler:  do nothing.
  */
 static int
Index: mac68k/locore.s
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/locore.s,v
retrieving revision 1.170
diff -u -p -r1.170 locore.s
--- mac68k/locore.s     15 Mar 2014 12:11:23 -0000      1.170
+++ mac68k/locore.s     17 Aug 2014 16:35:02 -0000
@@ -763,8 +763,8 @@ ENTRY_NOPROFILE(spurintr)
 
 ENTRY_NOPROFILE(intrhand)
        INTERRUPT_SAVEREG
-       movw    %sp@(22),%sp@-          | push exception vector info
-       clrw    %sp@-
+       lea     %sp@(16),%a0            | push exception frame
+       movel   %a0,%sp@-
        jbsr    _C_LABEL(intr_dispatch) | call dispatch routine
        addql   #4,%sp
        INTERRUPT_RESTOREREG
@@ -783,34 +783,6 @@ ENTRY_NOPROFILE(lev7intr)
        addql   #8,%sp                  | pop SSP and align word
        jra     _ASM_LABEL(rei)
 
-/* 
- * We could tweak rtclock_intr and gain 12 cycles on the 020 and 030 by
- * saving the status register directly to the stack, but this would lose
- * badly on the 040.  Aligning the stack takes 10 more cycles than this
- * code does, so it's a good compromise.
- */
-ENTRY_NOPROFILE(rtclock_intr)
-       movl    %d2,%sp@-               | save %d2
-       movw    %sr,%d2                 | save SPL
-       movw    _C_LABEL(ipl2psl_table)+IPL_CLOCK*2,%sr
-                                       | raise SPL to splclock()
-       movl    %a6@,%a1                | unwind to frame in intr_dispatch
-       lea     %a1@(28),%a1            | push pointer to interrupt frame
-       movl    %a1,%sp@-                       | 28 = 16 for regs in intrhand,
-                                       |    + 4 for args to intr_dispatch
-                                       |    + 4 for return address to intrhand
-                                       |    + 4 for value of %A6
-       jbsr    _C_LABEL(hardclock)     | call generic clock int routine
-       addql   #4,%sp                  | pop param
-       jbsr    _C_LABEL(mrg_VBLQueue)  | give programs in the VBLqueue a chance
-       addql   #1,_C_LABEL(intrcnt)+32 | record a clock interrupt
-       INTERRUPT_SAVEREG
-       CPUINFO_INCREMENT(CI_NINTR)
-       INTERRUPT_RESTOREREG
-       movw    %d2,%sr                 | restore SPL
-       movl    %sp@+,%d2               | restore %d2
-       rts                             | go back from whence we came
-
 /*
  * Emulation of VAX REI instruction.
  *
Index: mac68k/via.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/via.c,v
retrieving revision 1.75
diff -u -p -r1.75 via.c
--- mac68k/via.c        11 Dec 2005 12:18:03 -0000      1.75
+++ mac68k/via.c        17 Aug 2014 16:35:02 -0000
@@ -262,7 +262,10 @@ via1_intr(void *intr_arg)
        bitnum = 0;
        do {
                if (intbits & mask) {
-                       via1itab[bitnum](via1iarg[bitnum]);
+                       /* pass clockframe through to rtclock_intr,
+                        * otherwise use registered arg */
+                       via1itab[bitnum](bitnum == 6 ? intr_arg
+                           : via1iarg[bitnum]);
                        /* via_reg(VIA1, vIFR) = mask; */
                }
                mask <<= 1;


Home | Main Index | Thread Index | Old Index