sleep doesn't need spl0 (idle does it)
[unix-history] / usr / src / sys / kern / subr_prof.c
index 4ad1702..eed20b5 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
  *
  *
- *     @(#)subr_prof.c 7.5 (Berkeley) %G%
+ * %sccs.include.redist.c%
+ *
+ *     @(#)subr_prof.c 7.10 (Berkeley) %G%
  */
 
 #ifdef GPROF
  */
 
 #ifdef GPROF
@@ -19,12 +20,7 @@ int  profiling = 3;
 u_short        *froms;
 struct tostruct *tos = 0;
 long   tolimit = 0;
 u_short        *froms;
 struct tostruct *tos = 0;
 long   tolimit = 0;
-#if defined(vax)
-char   *s_lowpc = (char *)0x80000000;
-#endif
-#if defined(tahoe)
-char   *s_lowpc = (char *)0xc0000000;
-#endif
+char   *s_lowpc = (char *)KERNBASE;
 extern char etext;
 char   *s_highpc = &etext;
 u_long s_textsize = 0;
 extern char etext;
 char   *s_highpc = &etext;
 u_long s_textsize = 0;
@@ -55,14 +51,14 @@ kmstartup()
        }
        bzero(sbuf, ssiz);
        fromssize = s_textsize / HASHFRACTION;
        }
        bzero(sbuf, ssiz);
        fromssize = s_textsize / HASHFRACTION;
-       froms = (u_short *)malloc(fromssize, M_GPROF, M_WAITOK);
+       froms = (u_short *)malloc(fromssize, M_GPROF, M_NOWAIT);
        if (froms == 0) {
                printf("No space for monitor buffer(s)\n");
                free(sbuf, M_GPROF);
                sbuf = 0;
                return;
        }
        if (froms == 0) {
                printf("No space for monitor buffer(s)\n");
                free(sbuf, M_GPROF);
                sbuf = 0;
                return;
        }
-       bzero(froms, fromsize);
+       bzero(froms, fromssize);
        tolimit = s_textsize * ARCDENSITY / 100;
        if (tolimit < MINARCS)
                tolimit = MINARCS;
        tolimit = s_textsize * ARCDENSITY / 100;
        if (tolimit < MINARCS)
                tolimit = MINARCS;
@@ -82,13 +78,6 @@ kmstartup()
        ((struct phdr *)sbuf)->hpc = s_highpc;
        ((struct phdr *)sbuf)->ncnt = ssiz;
        kcount = (u_short *)(((int)sbuf) + sizeof (struct phdr));
        ((struct phdr *)sbuf)->hpc = s_highpc;
        ((struct phdr *)sbuf)->ncnt = ssiz;
        kcount = (u_short *)(((int)sbuf) + sizeof (struct phdr));
-#ifdef notdef
-       /*
-        * Profiling is what mcount checks to see if
-        * all the data structures are ready!!!
-        */
-       profiling = 0;          /* patch by hand when you're ready */
-#endif
 }
 
 /*
 }
 
 /*
@@ -121,6 +110,26 @@ mcount()
        frompcindex = 0;
 #else
        ;                               /* avoid label botch */
        frompcindex = 0;
 #else
        ;                               /* avoid label botch */
+#ifdef __GNUC__
+#if defined(vax)
+       Fix Me!!
+#endif
+#if defined(tahoe)
+       Fix Me!!
+#endif
+#if defined(hp300)
+       /*
+        * selfpc = pc pushed by mcount jsr,
+        * frompcindex = pc pushed by jsr into self.
+        * In GCC the caller's stack frame has already been built so we
+        * have to chase a6 to find caller's raddr.  This assumes that all
+        * routines we are profiling were built with GCC and that all
+        * profiled routines use link/unlk.
+        */
+       asm("movl a6@(4),%0" : "=r" (selfpc));
+       asm("movl a6@(0)@(4),%0" : "=r" (frompcindex));
+#endif
+#else
 #if defined(vax)
        asm("   movl (sp), r11");       /* selfpc = ... (jsb frame) */
        asm("   movl 16(fp), r10");     /* frompcindex =     (calls frame) */
 #if defined(vax)
        asm("   movl (sp), r11");       /* selfpc = ... (jsb frame) */
        asm("   movl 16(fp), r10");     /* frompcindex =     (calls frame) */
@@ -130,13 +139,22 @@ mcount()
        asm("   movl (fp),r11");
        asm("   movl -8(r11),r11");     /* frompcindex = 1 callf frame back */
 #endif
        asm("   movl (fp),r11");
        asm("   movl -8(r11),r11");     /* frompcindex = 1 callf frame back */
 #endif
+#if defined(hp300)
+       Fix Me!!
 #endif
 #endif
+#endif /* not __GNUC__ */
+#endif /* not lint */
        /*
         * Insure that we cannot be recursively invoked.
         * this requires that splhigh() and splx() below
         * do NOT call mcount!
         */
        /*
         * Insure that we cannot be recursively invoked.
         * this requires that splhigh() and splx() below
         * do NOT call mcount!
         */
+#if defined(hp300)
+       asm("movw       sr,%0" : "=g" (s));
+       asm("movw       #0x2700,sr");
+#else
        s = splhigh();
        s = splhigh();
+#endif
        /*
         * Check that frompcindex is a reasonable pc value.
         * For example: signal catchers get called from the stack,
        /*
         * Check that frompcindex is a reasonable pc value.
         * For example: signal catchers get called from the stack,
@@ -214,7 +232,11 @@ mcount()
 
        }
 done:
 
        }
 done:
+#if defined(hp300)
+       asm("movw       %0,sr" : : "g" (s));
+#else
        splx(s);
        splx(s);
+#endif
        /* and fall through */
 out:
 #if defined(vax)
        /* and fall through */
 out:
 #if defined(vax)