Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Apr 2000 22:29:10 -0500 (CDT)
From:      Steve Price <sprice@hiwaay.net>
To:        freebsd-alpha@freebsd.org
Subject:   need help porting JDK2 to alpha
Message-ID:  <Pine.OSF.4.21.0004222217380.16038-200000@fly.HiWAAY.net>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Evening UberHackers,

I'm working on porting JDK2 to FreeBSD/Alpha.  I've run into two
stumbling blocks that are well beyond my skills as a programmer
to overcome.  The first one should be relatively easy for someone
that knows their way around the Alpha architecture so I'll include
the details in this message.  The other one requires a bit of
assembly language programming skills.  If you are interested in
that, contact me off-list and I'll fill you in on the details.

In the JDK there is a method, initContext, for initializing the
state of a context switch.  I've attached the code that we use
on the i386, and my first cut at the alpha code.  Any and all
suggestions/patches are most welcome. :)

Thanks.

-steve

[-- Attachment #2 --]
#ifdef __FreeBSD__
#if defined(i386)
void
initContext(lj_ucontext_t *uc, gstack_t *stack, unsigned int pc,
         void (*death_func)(void), unsigned int arg)
{
    unsigned char *sp, *limit;
    int *p;
    char *fdata;

    limit = (unsigned char *)stack->base - stack->size;
    sp = (unsigned char *) stack->base;
    sp -= sizeof(sys_thread_t *);
    /* Force sp to be double aligned! */
    sp = (unsigned char *)((unsigned long)(sp) & 0xfffffff8);
    /* for x86 the args to death_func are passed on the stack */
    p = (int *)sp;
    *--p = (int)arg;	/* arg 2 */
    *--p = (int)pc;	/* arg 1 */
    *--p = (int)0;	/* return PC */
    *--p = (int)0;	/* __FreeBSD__ */

    memset(uc, 0, sizeof(lj_ucontext_t));
    fdata = (char *)uc->floatbuf;
    __asm__("fsave %0"::"m" (*fdata));
    __asm__("fwait");

    uc->jmpbuf->_sjb[3] = (int)(char *)p;
    uc->jmpbuf->_sjb[2] = (int)(char *)p;
    uc->jmpbuf->_sjb[0] = (int)death_func;
    uc->jmpbuf->_sjb[FBSD_FPU_MASK] = 0x127f;		/* FPU mask */
}
#elif defined(alpha)
void
initContext(lj_ucontext_t *uc, gstack_t *stack, unsigned int pc,
         void (*death_func)(void), unsigned int arg)
{
    unsigned char *sp;

    memset(uc, 0, sizeof(lj_ucontext_t));

    sp = (unsigned char *)stack->base;
    sp -= sizeof(sys_thread_t *);
    /* Force sp to be double aligned! */
    sp = (unsigned char *)((unsigned long)(sp) & ~7L);

    /*
     * XXX IMPLEMENT ME!!!
     *
     * We still need to determine where in the sigjmp_buf structure to stuff
     * death_func, pc, and arg to make this actually work.
     */
    uc->jmpbuf->_sjb[FBSD_STACK_POINTER] = (long)sp;
}
#else
#error architecture unsupported
#endif
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSF.4.21.0004222217380.16038-200000>