Skip to content

Instantly share code, notes, and snippets.

@ao-kenji
Created November 9, 2014 12:16
Show Gist options
  • Select an option

  • Save ao-kenji/d978bcd0dd65b5bdd33c to your computer and use it in GitHub Desktop.

Select an option

Save ao-kenji/d978bcd0dd65b5bdd33c to your computer and use it in GitHub Desktop.
Nov 15 02:28:02 rhea ntpd[20606]: adjusting local clock by 26.095063s
Index: include/board.h
===================================================================
RCS file: /cvs/src/sys/arch/luna88k/include/board.h,v
retrieving revision 1.12
diff -u -r1.12 board.h
--- include/board.h 6 Jan 2014 21:28:53 -0000 1.12
+++ include/board.h 9 Nov 2014 12:14:57 -0000
@@ -105,8 +105,13 @@
#define INT_ST_MASK2 U(0x65000008) /* interrupt status register CPU 2 */
#define INT_ST_MASK3 U(0x6500000C) /* interrupt status register CPU 3 */
#define INT_LEVEL 8 /* # of interrupt level + 1 */
+#if 0
#define INT_SET_LV7 U(0x00000000) /* disable interrupts */
#define INT_SET_LV6 U(0x00000000) /* enable level 7 */
+#else
+#define INT_SET_LV7 U(0x00000000) /* disable interrupts */
+#define INT_SET_LV6 U(0x84000000) /* enable level 7 */
+#endif
#define INT_SET_LV5 U(0x84000000) /* enable level 7-6 */
#define INT_SET_LV4 U(0xC4000000) /* enable level 7-5 */
#define INT_SET_LV3 U(0xE4000000) /* enable level 7-4 */
Index: luna88k/clock.c
===================================================================
RCS file: /cvs/src/sys/arch/luna88k/luna88k/clock.c,v
retrieving revision 1.10
diff -u -r1.10 clock.c
--- luna88k/clock.c 27 Sep 2014 19:50:10 -0000 1.10
+++ luna88k/clock.c 9 Nov 2014 12:14:58 -0000
@@ -52,8 +52,10 @@
#include <sys/evcount.h>
#include <sys/timetc.h>
+#include <machine/asm_macro.h> /* {get,set}_psr() */
#include <machine/board.h>
#include <machine/cpu.h>
+#include <machine/frame.h> /* struct trapframe */
#include <dev/clock_subr.h>
#include <luna88k/luna88k/clockvar.h>
@@ -226,27 +228,44 @@
(u_int32_t *)OBIO_CLOCK3
};
+int pending_ticks[] = {
+ 0, 0, 0, 0
+};
+
/*
* Clock interrupt routine
*/
int
-clockintr(void *eframe)
+clockintr(void *arg)
{
+ struct trapframe *eframe = arg;
#ifdef MULTIPROCESSOR
struct cpu_info *ci = curcpu();
u_int cpu = ci->ci_cpuid;
#else
u_int cpu = cpu_number();
#endif
+ *clock_reg[cpu] = 0xffffffff;
+ pending_ticks[cpu]++;
+ if (!clockinitted)
+ return 0;
+
+ if (eframe->tf_mask < IPL_CLOCK) {
+#if 0
+ if (pending_ticks[cpu] > 2)
+ printf("cpu%d: pending ticks = %d\n",
+ cpu, pending_ticks[cpu]);
+#endif
+ while(pending_ticks[cpu] > 0) {
#ifdef MULTIPROCESSOR
- if (CPU_IS_PRIMARY(ci))
+ if (CPU_IS_PRIMARY(ci))
#endif
- clockevc->ec_count++;
-
- *clock_reg[cpu] = 0xffffffff;
- if (clockinitted)
- hardclock(eframe);
+ clockevc->ec_count++;
+ hardclock(arg);
+ pending_ticks[cpu]--;
+ }
+ }
return 1;
}
Index: luna88k/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/luna88k/luna88k/machdep.c,v
retrieving revision 1.113
diff -u -r1.113 machdep.c
--- luna88k/machdep.c 5 Oct 2014 02:12:19 -0000 1.113
+++ luna88k/machdep.c 9 Nov 2014 12:14:58 -0000
@@ -814,6 +814,14 @@
uvmexp.intrs++;
+ /*
+ * Check timer first
+ */
+ if (cur_int_level == 6) {
+ clockintr((void *)eframe);
+ goto out;
+ }
+
#ifdef MULTIPROCESSOR
/*
* Handle unmaskable IPIs immediately, so that we can reenable
@@ -823,24 +831,16 @@
*
* On luna88k, IPL_SOFTINT (level 1 interrupt) is used as IPI.
*/
- while (cur_int_level == IPL_SOFTINT) {
+ if (cur_int_level == IPL_SOFTINT) {
luna88k_ipi_handler(eframe);
-
- cur_isr = *int_mask_reg[cpu];
- cur_int_level = cur_isr >> 29;
- }
- if (cur_int_level == 0)
goto out;
+ }
#endif
-#ifdef MULTIPROCESSOR
- if (old_spl < IPL_SCHED)
- __mp_lock(&kernel_lock);
-#endif
/*
* Service the highest interrupt, in order.
*/
- do {
+ while (cur_int_level != 0) {
level = (cur_int_level > old_spl ? cur_int_level : old_spl);
setipl(level);
@@ -857,13 +857,20 @@
case 4:
case 3:
#ifdef MULTIPROCESSOR
- if (CPU_IS_PRIMARY(ci)) {
+ if (old_spl < IPL_SCHED)
+ __mp_lock(&kernel_lock);
#endif
- isrdispatch_autovec(cur_int_level);
+ isrdispatch_autovec(cur_int_level);
#ifdef MULTIPROCESSOR
- }
+ if (old_spl < IPL_SCHED)
+ __mp_unlock(&kernel_lock);
#endif
break;
+#ifdef MULTIPROCESSOR
+ case 1:
+ luna88k_ipi_handler(eframe);
+ break;
+#endif
default:
printf("%s: cpu%d level %d interrupt.\n",
__func__, cpu, cur_int_level);
@@ -872,12 +879,12 @@
cur_isr = *int_mask_reg[cpu];
cur_int_level = cur_isr >> 29;
- } while (cur_int_level != 0);
-
-#ifdef MULTIPROCESSOR
- if (old_spl < IPL_SCHED)
- __mp_unlock(&kernel_lock);
-#endif
+ /*
+ * Check timer again
+ */
+ if (cur_int_level != 0)
+ printf("cpu%d: more intr = %d\n", cpu, cur_int_level);
+ }
out:
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment