Simplified savectx() a little and fixed a bug that caused it to return
garbage in the child process rather than "1" like it is supposed to. Reviewed by: bde
This commit is contained in:
parent
21759429e4
commit
2924d49169
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13580
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: swtch.s,v 1.24 1995/12/21 19:20:58 davidg Exp $
|
||||
* $Id: swtch.s,v 1.25 1996/01/03 21:41:29 wollman Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h" /* for NNPX */
|
||||
@ -506,14 +506,18 @@ ENTRY(mvesp)
|
||||
ret
|
||||
|
||||
/*
|
||||
* savectx(pcb, altreturn)
|
||||
* Update pcb, saving current processor state and arranging
|
||||
* for alternate return ala longjmp in cpu_switch if altreturn is true.
|
||||
* savectx(pcb)
|
||||
* Update pcb, saving current processor state.
|
||||
*/
|
||||
ENTRY(savectx)
|
||||
/* PCB */
|
||||
movl 4(%esp),%ecx
|
||||
|
||||
/* caller's return address - child won't execute this routine */
|
||||
movl (%esp),%eax
|
||||
movl %eax,PCB_EIP(%ecx)
|
||||
|
||||
movl $1,PCB_EAX(%ecx) /* return 1 in child */
|
||||
movl %ebx,PCB_EBX(%ecx)
|
||||
movl %esp,PCB_ESP(%ecx)
|
||||
movl %ebp,PCB_EBP(%ecx)
|
||||
@ -555,25 +559,8 @@ ENTRY(savectx)
|
||||
call _bcopy
|
||||
addl $12,%esp
|
||||
popl %ecx
|
||||
1:
|
||||
#endif /* NNPX > 0 */
|
||||
|
||||
cmpl $0,8(%esp)
|
||||
je 1f
|
||||
movl %esp,%edx /* relocate current sp relative to pcb */
|
||||
subl $_kstack,%edx /* (sp is relative to kstack): */
|
||||
addl %edx,%ecx /* pcb += sp - kstack; */
|
||||
movl %eax,(%ecx) /* write return pc at (relocated) sp@ */
|
||||
|
||||
/* this mess deals with replicating register state gcc hides */
|
||||
movl 12(%esp),%eax
|
||||
movl %eax,12(%ecx)
|
||||
movl 16(%esp),%eax
|
||||
movl %eax,16(%ecx)
|
||||
movl 20(%esp),%eax
|
||||
movl %eax,20(%ecx)
|
||||
movl 24(%esp),%eax
|
||||
movl %eax,24(%ecx)
|
||||
1:
|
||||
xorl %eax,%eax /* return 0 */
|
||||
ret
|
||||
|
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.170 1996/01/19 03:57:38 dyson Exp $
|
||||
* $Id: machdep.c,v 1.171 1996/01/21 20:57:03 joerg Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -927,7 +927,7 @@ boot(howto)
|
||||
} else {
|
||||
if (howto & RB_DUMP) {
|
||||
if (!cold) {
|
||||
savectx(&dumppcb, 0);
|
||||
savectx(&dumppcb);
|
||||
dumppcb.pcb_ptd = rcr3();
|
||||
dumpsys();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: swtch.s,v 1.24 1995/12/21 19:20:58 davidg Exp $
|
||||
* $Id: swtch.s,v 1.25 1996/01/03 21:41:29 wollman Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h" /* for NNPX */
|
||||
@ -506,14 +506,18 @@ ENTRY(mvesp)
|
||||
ret
|
||||
|
||||
/*
|
||||
* savectx(pcb, altreturn)
|
||||
* Update pcb, saving current processor state and arranging
|
||||
* for alternate return ala longjmp in cpu_switch if altreturn is true.
|
||||
* savectx(pcb)
|
||||
* Update pcb, saving current processor state.
|
||||
*/
|
||||
ENTRY(savectx)
|
||||
/* PCB */
|
||||
movl 4(%esp),%ecx
|
||||
|
||||
/* caller's return address - child won't execute this routine */
|
||||
movl (%esp),%eax
|
||||
movl %eax,PCB_EIP(%ecx)
|
||||
|
||||
movl $1,PCB_EAX(%ecx) /* return 1 in child */
|
||||
movl %ebx,PCB_EBX(%ecx)
|
||||
movl %esp,PCB_ESP(%ecx)
|
||||
movl %ebp,PCB_EBP(%ecx)
|
||||
@ -555,25 +559,8 @@ ENTRY(savectx)
|
||||
call _bcopy
|
||||
addl $12,%esp
|
||||
popl %ecx
|
||||
1:
|
||||
#endif /* NNPX > 0 */
|
||||
|
||||
cmpl $0,8(%esp)
|
||||
je 1f
|
||||
movl %esp,%edx /* relocate current sp relative to pcb */
|
||||
subl $_kstack,%edx /* (sp is relative to kstack): */
|
||||
addl %edx,%ecx /* pcb += sp - kstack; */
|
||||
movl %eax,(%ecx) /* write return pc at (relocated) sp@ */
|
||||
|
||||
/* this mess deals with replicating register state gcc hides */
|
||||
movl 12(%esp),%eax
|
||||
movl %eax,12(%ecx)
|
||||
movl 16(%esp),%eax
|
||||
movl %eax,16(%ecx)
|
||||
movl 20(%esp),%eax
|
||||
movl %eax,20(%ecx)
|
||||
movl 24(%esp),%eax
|
||||
movl %eax,24(%ecx)
|
||||
1:
|
||||
xorl %eax,%eax /* return 0 */
|
||||
ret
|
||||
|
@ -38,7 +38,7 @@
|
||||
*
|
||||
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
|
||||
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
|
||||
* $Id: vm_machdep.c,v 1.50 1996/01/05 20:12:23 wollman Exp $
|
||||
* $Id: vm_machdep.c,v 1.51 1996/01/19 03:57:43 dyson Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -591,7 +591,7 @@ cpu_fork(p1, p2)
|
||||
* Arrange for a non-local goto when the new process
|
||||
* is started, to resume here, returning nonzero from setjmp.
|
||||
*/
|
||||
if (savectx(&up->u_pcb, 1)) {
|
||||
if (savectx(&up->u_pcb)) {
|
||||
/*
|
||||
* Return 1 in child.
|
||||
*/
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
|
||||
* $Id: pcb.h,v 1.8 1994/12/03 10:02:55 bde Exp $
|
||||
* $Id: pcb.h,v 1.9 1995/08/17 11:30:03 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef _I386_PCB_H_
|
||||
@ -80,7 +80,7 @@ struct md_coredump {
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct pcb *curpcb; /* our current running pcb */
|
||||
int savectx __P((struct pcb*,int));
|
||||
int savectx __P((struct pcb*));
|
||||
#endif
|
||||
|
||||
#endif /* _I386_PCB_H_ */
|
||||
|
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.170 1996/01/19 03:57:38 dyson Exp $
|
||||
* $Id: machdep.c,v 1.171 1996/01/21 20:57:03 joerg Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -927,7 +927,7 @@ boot(howto)
|
||||
} else {
|
||||
if (howto & RB_DUMP) {
|
||||
if (!cold) {
|
||||
savectx(&dumppcb, 0);
|
||||
savectx(&dumppcb);
|
||||
dumppcb.pcb_ptd = rcr3();
|
||||
dumpsys();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: swtch.s,v 1.24 1995/12/21 19:20:58 davidg Exp $
|
||||
* $Id: swtch.s,v 1.25 1996/01/03 21:41:29 wollman Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h" /* for NNPX */
|
||||
@ -506,14 +506,18 @@ ENTRY(mvesp)
|
||||
ret
|
||||
|
||||
/*
|
||||
* savectx(pcb, altreturn)
|
||||
* Update pcb, saving current processor state and arranging
|
||||
* for alternate return ala longjmp in cpu_switch if altreturn is true.
|
||||
* savectx(pcb)
|
||||
* Update pcb, saving current processor state.
|
||||
*/
|
||||
ENTRY(savectx)
|
||||
/* PCB */
|
||||
movl 4(%esp),%ecx
|
||||
|
||||
/* caller's return address - child won't execute this routine */
|
||||
movl (%esp),%eax
|
||||
movl %eax,PCB_EIP(%ecx)
|
||||
|
||||
movl $1,PCB_EAX(%ecx) /* return 1 in child */
|
||||
movl %ebx,PCB_EBX(%ecx)
|
||||
movl %esp,PCB_ESP(%ecx)
|
||||
movl %ebp,PCB_EBP(%ecx)
|
||||
@ -555,25 +559,8 @@ ENTRY(savectx)
|
||||
call _bcopy
|
||||
addl $12,%esp
|
||||
popl %ecx
|
||||
1:
|
||||
#endif /* NNPX > 0 */
|
||||
|
||||
cmpl $0,8(%esp)
|
||||
je 1f
|
||||
movl %esp,%edx /* relocate current sp relative to pcb */
|
||||
subl $_kstack,%edx /* (sp is relative to kstack): */
|
||||
addl %edx,%ecx /* pcb += sp - kstack; */
|
||||
movl %eax,(%ecx) /* write return pc at (relocated) sp@ */
|
||||
|
||||
/* this mess deals with replicating register state gcc hides */
|
||||
movl 12(%esp),%eax
|
||||
movl %eax,12(%ecx)
|
||||
movl 16(%esp),%eax
|
||||
movl %eax,16(%ecx)
|
||||
movl 20(%esp),%eax
|
||||
movl %eax,20(%ecx)
|
||||
movl 24(%esp),%eax
|
||||
movl %eax,24(%ecx)
|
||||
1:
|
||||
xorl %eax,%eax /* return 0 */
|
||||
ret
|
||||
|
@ -38,7 +38,7 @@
|
||||
*
|
||||
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
|
||||
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
|
||||
* $Id: vm_machdep.c,v 1.50 1996/01/05 20:12:23 wollman Exp $
|
||||
* $Id: vm_machdep.c,v 1.51 1996/01/19 03:57:43 dyson Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -591,7 +591,7 @@ cpu_fork(p1, p2)
|
||||
* Arrange for a non-local goto when the new process
|
||||
* is started, to resume here, returning nonzero from setjmp.
|
||||
*/
|
||||
if (savectx(&up->u_pcb, 1)) {
|
||||
if (savectx(&up->u_pcb)) {
|
||||
/*
|
||||
* Return 1 in child.
|
||||
*/
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
|
||||
* $Id: pcb.h,v 1.8 1994/12/03 10:02:55 bde Exp $
|
||||
* $Id: pcb.h,v 1.9 1995/08/17 11:30:03 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef _I386_PCB_H_
|
||||
@ -80,7 +80,7 @@ struct md_coredump {
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct pcb *curpcb; /* our current running pcb */
|
||||
int savectx __P((struct pcb*,int));
|
||||
int savectx __P((struct pcb*));
|
||||
#endif
|
||||
|
||||
#endif /* _I386_PCB_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user