changes for 4.4BSD-Lite requested by USL
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 11 Dec 1993 15:38:24 +0000 (07:38 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 11 Dec 1993 15:38:24 +0000 (07:38 -0800)
NOT SEMANTIC SUGAR -- change to exec init, not hand-craft it

SCCS-vsn: sys/sparc/sparc/locore.s 8.4

usr/src/sys/sparc/sparc/locore.s

index 89ae685..01c9087 100644 (file)
@@ -1413,6 +1413,8 @@ syscall:
        ldd     [%sp + CCFSZ + 0], %l0  ! new %psr, new pc
        ldd     [%sp + CCFSZ + 8], %l2  ! new npc, new %y
        wr      %l3, 0, %y
        ldd     [%sp + CCFSZ + 0], %l0  ! new %psr, new pc
        ldd     [%sp + CCFSZ + 8], %l2  ! new npc, new %y
        wr      %l3, 0, %y
+       /* see `dostart' for the reason for this label */
+init_syscall_ret:
        ld      [%sp + CCFSZ + 20], %g1
        ldd     [%sp + CCFSZ + 24], %g2
        ldd     [%sp + CCFSZ + 32], %g4
        ld      [%sp + CCFSZ + 20], %g1
        ldd     [%sp + CCFSZ + 24], %g2
        ldd     [%sp + CCFSZ + 32], %g4
@@ -2275,8 +2277,8 @@ dostart:
        stba    %g0, [%g1] ASI_CONTROL
        wr      %g0, 2, %wim            ! set initial %wim (w1 invalid)
        mov     1, %g1                  ! set pcb_wim (log2(%wim) = 1)
        stba    %g0, [%g1] ASI_CONTROL
        wr      %g0, 2, %wim            ! set initial %wim (w1 invalid)
        mov     1, %g1                  ! set pcb_wim (log2(%wim) = 1)
-       sethi   %hi(_u0 + PCB_WIM), %g2
-       st      %g1, [%g2 + %lo(_u0 + PCB_WIM)]
+       sethi   %hi(_u0 - KERNBASE + PCB_WIM), %g2
+       st      %g1, [%g2 + %lo(_u0 - KERNBASE + PCB_WIM)]
 
        /*
         * Step 1: double map low RAM (addresses [0.._end-start-1])
 
        /*
         * Step 1: double map low RAM (addresses [0.._end-start-1])
@@ -2365,58 +2367,28 @@ dostart:
        nop                             ! paranoia
 
        /*
        nop                             ! paranoia
 
        /*
-        * Bootstrap, call main, and `return' from a fake trap into `icode'.
+        * Ready to run C code; finish bootstrap.
         */
        call    _bootstrap
         nop
         */
        call    _bootstrap
         nop
-       call    _main
-        nop
 
        /*
 
        /*
-        * Return from main means we are process 1 and need to
-        * jump to the `icode' (which appears below) which has
-        * been copied in to address 0x2000 in the new process.
-        *
-        * Our stack & frame pointers are already set up to make it
-        * look like we are currently running in a trap taken from
-        * user mode (there is room for a full blown trapfrape),
-        * so all we need do is set up %l0, %l1, and %l2 and branch
-        * to return_from_trap.
+        * Call main.  This returns to us after loading /sbin/init into
+        * user space.  (If the exec fails, main() does not return.)
         */
         */
-       mov     PSR_S, %l0              ! user psr
-#define XADDR 0x2000 /* XXX */
-       set     XADDR, %l1              ! pc
-       add     %l1, 4, %l2             ! npc
-       b       return_from_trap
-        wr     %l0, 0, %psr            ! just like syscall()
-
-/*
- * Icode is copied out to process 1 to exec init.
- * If the exec fails, process 1 exits.
- *
- * We depend here on the fact that we are copied to address XADDR
- * (but so does the code above).
- */
-       .globl  _icode, _szicode
-_icode:
-       mov     SYS_execve, %g1
-       set     init - _icode + XADDR, %o0      ! actual location of pathname
-       set     argv - _icode + XADDR, %o1      ! ... and of argv
-       clr     %o2                             ! no environment
-       t       ST_SYSCALL
-       mov     SYS_exit, %g1
-       t       ST_SYSCALL
+       call    _main
+        clr    %o0                     ! our frame arg is ignored
 
 
-init:  .ascii  "/sbin/"
-init1: .asciz  "init"
-       ALIGN
-argv:  .word   init1 - _icode + XADDR
-       .word   initflags - _icode + XADDR
-       .word   0
-initflags:
-_szicode:
-       .long   _szicode - _icode
-#undef XADDR
+       /*
+        * Here we finish up as in syscall, but simplified.  We need to
+        * fiddle pc and npc a bit, as execve() / setregs() have only set
+        * npc, in anticipation that trap.c will advance past the trap
+        * instruction; but we bypass that, so we must do it manually.
+        */
+       mov     PSR_S, %l0              ! user psr (no need to load it)
+       ld      [%sp + CCFSZ + 8], %l1  ! pc = npc from execve
+       b       init_syscall_ret
+        add    %l1, 4, %l2             ! npc = pc+4
 
 /*
  * The following code is copied to the top of the user stack when each
 
 /*
  * The following code is copied to the top of the user stack when each