Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Nov 1997 00:10:28 +1030
From:      Mike Smith <mike@smith.net.au>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        freebsd-mobile@FreeBSD.ORG
Subject:   Re: Libretto 50 - US Version and PAO 
Message-ID:  <199711061340.AAA00574@word.smith.net.au>
In-Reply-To: Your message of "Thu, 06 Nov 1997 13:41:32 BST." <478.878820092@critter.freebsd.dk> 

next in thread | previous in thread | raw e-mail | index | archive | help
> >Alright, let's try something even more ugly.
> >
> >/* 
> > * pnpcall(int dseg, int coffs, int cseg,
> > *	   int retoffs, int retseg, u_int_16 stack[PNP_MAXSTACK])
> > * pass (retoffs) and (retseg) in as junk.
> > */
> >ENTRY(pnpcall)
> >	movl	%cs,%di
> >	movl	%di,(5*4)(%esp)
> >	movl	pnpret,(4*4)(%esp)
> >	popl	%di
> >	movl	%di,%ds
> >	lret
> >pnpret:		/* fossick return value etc. */
> >
> >About all I can see here is that we don't save any registers across
> >the call, which might be Bad.
> >
> >Comments?
> 
> Uhm, the "popl %di" comes from the wrong stack, right ?

Argh, yes the return address for the caller is still on top.

OK, is anyone going to shoot me if I hardcode the various
selector numbers into this?  I can't see any other way of doing 
this cleanly...

/* 
 * int pnpcall(int dseg, int coffs, int cseg,
 *	       int retoffs, int retseg, u_int_16 stack[PNP_MAXSTACK])
 * pass (retoffs) and (retseg) in as junk.
 */
#define LCALL(x,y)	.byte 0x9a ; .long y ; .word x

	.data
disave:	.long	0
caller:	.long	0

	.text
ENTRY(pnpcall)
	movl	%di,disave
	popl	%di
	movl	%di,caller

	movl	$GCODE_SEL,(5*4)(%esp)
	movl	$pnpret,(4*4)(%esp)

	popl	%di		/* get data segement selector for PnP */
	movl	%di,%ds
	lret			/* intersegment call */
	
pnpret: movl	$GDATA_SEL,%di
	movl	%di,%ds

/* carry flag should be OK still; how do I return a value?! (%eax?) */

	movl	caller,%di
	pushl	%di
	movl	disave,%di
	ret

Any better?

mike





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711061340.AAA00574>