diff options
Diffstat (limited to 'src/mesa/glapi')
-rw-r--r-- | src/mesa/glapi/glapi.c | 55 | ||||
-rw-r--r-- | src/mesa/glapi/glsparcasm.py | 14 |
2 files changed, 63 insertions, 6 deletions
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index b2a10133b25..e9887551f9a 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -1,4 +1,4 @@ -/* $Id: glapi.c,v 1.54 2001/05/29 15:23:49 brianp Exp $ */ +/* $Id: glapi.c,v 1.55 2001/06/05 23:54:00 davem69 Exp $ */ /* * Mesa 3-D graphics library @@ -52,7 +52,9 @@ #include "glapitable.h" #include "glthread.h" - +#ifdef USE_SPARC_ASM +#include "SPARC/sparc.h" +#endif /***** BEGIN NO-OP DISPATCH *****/ @@ -1754,6 +1756,55 @@ generate_entrypoint(GLuint functionOffset) *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4; } return code; +#elif defined(USE_SPARC_ASM) + +#ifdef __sparc_v9__ + static const unsigned int insn_template[] = { + 0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */ + 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */ + 0x8410a000, /* or %g2, %ulo(_glapi_Dispatch), %g2 */ + 0x82106000, /* or %g1, %lo(_glapi_Dispatch), %g1 */ + 0x8528b020, /* sllx %g2, 32, %g2 */ + 0xc2584002, /* ldx [%g1 + %g2], %g1 */ + 0x05000000, /* sethi %hi(8 * glapioffset), %g2 */ + 0x8410a000, /* or %g2, %lo(8 * glapioffset), %g2 */ + 0xc6584002, /* ldx [%g1 + %g2], %g3 */ + 0x81c0c000, /* jmpl %g3, %g0 */ + 0x01000000 /* nop */ + }; +#else + static const unsigned int insn_template[] = { + 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */ + 0xc2006000, /* ld [%g1 + %lo(_glapi_Dispatch)], %g1 */ + 0xc6006000, /* ld [%g1 + %lo(4*glapioffset)], %g3 */ + 0x81c0c000, /* jmpl %g3, %g0 */ + 0x01000000 /* nop */ + }; +#endif + unsigned int *code = malloc(sizeof(insn_template)); + unsigned long glapi_addr = (unsigned long) &_glapi_Dispatch; + if (code) { + memcpy(code, insn_template, sizeof(insn_template)); + +#ifdef __sparc_v9__ + code[0] |= (glapi_addr >> (32 + 10)); + code[1] |= ((glapi_addr & 0xffffffff) >> 10); + _mesa_sparc_icache_flush(&code[0]); + code[2] |= ((glapi_addr >> 32) & ((1 << 10) - 1)); + code[3] |= (glapi_addr & ((1 << 10) - 1)); + _mesa_sparc_icache_flush(&code[2]); + code[6] |= ((functionOffset * 8) >> 10); + code[7] |= ((functionOffset * 8) & ((1 << 10) - 1)); + _mesa_sparc_icache_flush(&code[6]); +#else + code[0] |= (glapi_addr >> 10); + code[1] |= (glapi_addr & ((1 << 10) - 1)); + _mesa_sparc_icache_flush(&code[0]); + code[2] |= (functionOffset * 4); + _mesa_sparc_icache_flush(&code[2]); +#endif + } + return code; #else return NULL; #endif diff --git a/src/mesa/glapi/glsparcasm.py b/src/mesa/glapi/glsparcasm.py index 3d01e81fb3f..b1cdf9e0213 100644 --- a/src/mesa/glapi/glsparcasm.py +++ b/src/mesa/glapi/glsparcasm.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# $Id: glsparcasm.py,v 1.1 2001/06/05 04:30:03 davem69 Exp $ +# $Id: glsparcasm.py,v 1.2 2001/06/05 23:54:00 davem69 Exp $ # Mesa 3-D graphics library # Version: 3.5 @@ -51,15 +51,21 @@ def PrintHead(): print ' * sethi/or instruction sequences below at library init time.' print ' */' print '' - print '.text' + print '.data' print '.align 64' print '' + print '.globl _mesa_sparc_glapi_begin' + print '_mesa_sparc_glapi_begin:' + print '' return #endif def PrintTail(): print '\t nop' print '' + print '.globl _mesa_sparc_glapi_end' + print '_mesa_sparc_glapi_end:' + print '' #endif @@ -73,13 +79,13 @@ def GenerateDispatchCode(name, offset): print '\tor\t%g2, %lo(0x00000000), %g2' print '\tor\t%g1, %lo(0x00000000), %g1' print '\tsllx\t%g2, 32, %g2' - print '\tor\t%g1, %g2, %g1' + print '\tldx\t[%g1 + %g2], %g1' print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (offset) print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (offset) print '\tldx\t[%g1 + %g2], %g3' print '#else' print '\tsethi\t%hi(0x00000000), %g1' - print '\tor\t%g1, %lo(0x00000000), %g1' + print '\tld\t[%g1 + %lo(0x00000000)], %g1' print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (offset) print '#endif' print '\tjmpl\t%g3, %g0' |