VFLUSHO -> VDISCARD
[unix-history] / usr / src / sys / kern / subr_prof.c
index 4ad1702..cf6b88c 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.8 (Berkeley) %G%
  */
 
 #ifdef GPROF
  */
 
 #ifdef GPROF
@@ -25,6 +26,9 @@ char  *s_lowpc = (char *)0x80000000;
 #if defined(tahoe)
 char   *s_lowpc = (char *)0xc0000000;
 #endif
 #if defined(tahoe)
 char   *s_lowpc = (char *)0xc0000000;
 #endif
+#if defined(hp300)
+char   *s_lowpc = (char *)0x00000000;
+#endif
 extern char etext;
 char   *s_highpc = &etext;
 u_long s_textsize = 0;
 extern char etext;
 char   *s_highpc = &etext;
 u_long s_textsize = 0;
@@ -62,7 +66,7 @@ kmstartup()
                sbuf = 0;
                return;
        }
                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,15 +86,16 @@ 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
 }
 
 }
 
+/*
+ * Special, non-profiled versions
+ */
+#if defined(hp300) && !defined(__GNUC__)
+#define splhigh        _splhigh
+#define splx   _splx
+#endif
+
 /*
  * This routine is massaged so that it may be jsb'ed to on vax.
  */
 /*
  * This routine is massaged so that it may be jsb'ed to on vax.
  */
@@ -121,6 +126,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 +155,25 @@ 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)
+       asm("   .text");                /* make sure we're in text space */
+       asm("   movl a6@(4),a5");       /* selfpc = pc pushed by mcount jsr */
+       asm("   movl a6@(8),a4");       /* frompcindex = pc pushed by jsr into
+                                          self, stack frame not yet built */
 #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) && defined(__GNUC__)
+       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 +251,11 @@ mcount()
 
        }
 done:
 
        }
 done:
+#if defined(hp300) && defined(__GNUC__)
+       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)