Annotation of cci/usr/src/lib/libc/tahoe/csu.ucb/crt0.c, revision 1.1.1.1

1.1       root        1: /* Tahoe version 3/28/84 (unused yet) */
                      2: 
                      3: /*
                      4:  *     C start up routine.
                      5:  *     Robert Henry, UCB, 20 Oct 81
                      6:  *
                      7:  *     We make the following (true) assumptions:
                      8:  *     1) when the kernel calls start, it does a jump to location 2,
                      9:  *     and thus avoids the register save mask.  We are NOT called
                     10:  *     with a calls!  see sys1.c:setregs().
                     11:  *     2) The only register variable that we can trust is sp,
                     12:  *     which points to the base of the kernel calling frame.
                     13:  *     Do NOT believe the documentation in exec(2) regarding the
                     14:  *     values of fp and ap.
                     15:  *     3) We can allocate as many register variables as we want,
                     16:  *     and don't have to save them for anybody.
                     17:  *     4) Because of the ways that asm's work, we can't have
                     18:  *     any automatic variables allocated on the stack, because
                     19:  *     we must catch the value of sp before any automatics are
                     20:  *     allocated.
                     21:  */
                     22: 
                     23: char **environ = (char **)0;
                     24: 
                     25: asm("#define _start start");
                     26: asm("#define _eprol eprol");
                     27: extern unsigned char   etext;
                     28: extern unsigned char   eprol;
                     29: start()
                     30: {
                     31:        struct kframe {
                     32:                int     kargc;
                     33:                char    *kargv[1];      /* size depends on kargc */
                     34:                char    kargstr[1];     /* size varies */
                     35:                char    kenvstr[1];     /* size varies */
                     36:        };
                     37:        /*
                     38:         *      ALL REGISTER VARIABLES!!!
                     39:         */
                     40:        register int r12;               /* dummy */
                     41:        register int r11;               /* needed for init */
                     42:        register struct kframe *kfp;    /* r10 */
                     43:        register char **targv;
                     44:        register char **argv;
                     45: 
                     46: #ifdef lint
                     47:        kfp = 0;
                     48:        initcode = initcode = 0;
                     49: #else not lint
                     50:        asm("   movl    sp,r10");       /* catch it quick */
                     51: #endif not lint
                     52:        for (argv = targv = &kfp->kargv[0]; *targv++; /* void */)
                     53:                /* void */ ;
                     54:        if (targv >= (char **)(*argv))
                     55:                --targv;
                     56:        environ = targv;
                     57: asm("eprol:");
                     58: #ifdef MCRT0
                     59:        monstartup(&eprol, &etext);
                     60: #endif MCRT0
                     61:        exit(main(kfp->kargc, argv, environ));
                     62: }
                     63: asm("#undef _start");
                     64: asm("#undef _eprol");
                     65: 
                     66: #ifdef MCRT0
                     67: /*ARGSUSED*/
                     68: exit(code)
                     69:        int code;       /* 4(fp) */
                     70: {
                     71:        monitor(0);
                     72:        _cleanup();
                     73:        asm("   movl 4(fp),r0");
                     74:        asm("   chmk $1");
                     75: }
                     76: #endif MCRT0
                     77: 
                     78: #ifdef CRT0
                     79: /*
                     80:  * null mcount and moncontrol,
                     81:  * just in case some routine is compiled for profiling
                     82:  */
                     83: moncontrol(val)
                     84:        int val;
                     85: {
                     86: 
                     87: }
                     88: asm("  .globl  mcount");
                     89: asm("mcount:   ret");
                     90: #endif CRT0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.