| 1 |
|
|---|
| 2 | /*
|
|---|
| 3 | * gcc long pointer support code for HPPA.
|
|---|
| 4 | * Copyright 1998, DIS International, Ltd.
|
|---|
| 5 | * This code is free software; you may redistribute it and/or modify
|
|---|
| 6 | * it under the same terms as Perl itself. (Relicensed for Perl in
|
|---|
| 7 | * in April 2002 by Mark Klein.)
|
|---|
| 8 | */
|
|---|
| 9 | typedef struct {
|
|---|
| 10 | int spaceid;
|
|---|
| 11 | unsigned int offset;
|
|---|
| 12 | } LONGPOINTER, longpointer;
|
|---|
| 13 |
|
|---|
| 14 | /*
|
|---|
| 15 | * gcc long pointer support code for HPPA.
|
|---|
| 16 | * Copyright 1998, DIS International, Ltd.
|
|---|
| 17 | * This code is free software; you may redistribute it and/or modify
|
|---|
| 18 | * it under the same terms as Perl itself. (Relicensed for Perl in
|
|---|
| 19 | * in April 2002 by Mark Klein.)
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | int __perl_mpe_getspaceid(void *source)
|
|---|
| 23 | {
|
|---|
| 24 | int val;
|
|---|
| 25 | /*
|
|---|
| 26 | * Given the short pointer, determine it's space ID.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /*
|
|---|
| 30 | * The colons separate output from input parameters. In this case,
|
|---|
| 31 | * the output of the instruction (output indicated by the "=" in the
|
|---|
| 32 | * constraint) is to a memory location (indicated by the "m"). The
|
|---|
| 33 | * input constraint indicates that the source to the instruction
|
|---|
| 34 | * is a register reference (indicated by the "r").
|
|---|
| 35 | * The general format is:
|
|---|
| 36 | * asm("<instruction template>" : <output> : <input> : <clobbers>);
|
|---|
| 37 | * where <output> and <input> are:
|
|---|
| 38 | * "<constraint>" (<token>)
|
|---|
| 39 | * <instruction template> is the PA-RISC instruction in template fmt.
|
|---|
| 40 | * <clobbers> indicates those registers clobbered by the instruction
|
|---|
| 41 | * and provides hints to the optimizer.
|
|---|
| 42 | *
|
|---|
| 43 | * Refer to the gcc documentation or http://www.dis.com/gnu/gcc_toc.html
|
|---|
| 44 | */
|
|---|
| 45 | __asm__ __volatile__ (
|
|---|
| 46 | " comiclr,= 0,%1,%%r28\n"
|
|---|
| 47 | "\t ldsid (%%r0,%1),%%r28\n"
|
|---|
| 48 | "\t stw %%r28, %0"
|
|---|
| 49 | : "=m" (val) // Output to val
|
|---|
| 50 | : "r" (source) // Source must be gen reg
|
|---|
| 51 | : "%r28"); // Clobbers %r28
|
|---|
| 52 | return (val);
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 | LONGPOINTER __perl_mpe_longaddr(void *source)
|
|---|
| 56 | {
|
|---|
| 57 | LONGPOINTER lptr;
|
|---|
| 58 | /*
|
|---|
| 59 | * Return the long pointer for the address in sr5 space.
|
|---|
| 60 | */
|
|---|
| 61 |
|
|---|
| 62 | __asm__ __volatile__ (
|
|---|
| 63 | " comiclr,= 0,%2,%%r28\n"
|
|---|
| 64 | "\t ldsid (%%r0,%2),%%r28\n"
|
|---|
| 65 | "\t stw %%r28, %0\n"
|
|---|
| 66 | "\t stw %2, %1"
|
|---|
| 67 | : "=m" (lptr.spaceid),
|
|---|
| 68 | "=m" (lptr.offset) // Store to lptr
|
|---|
| 69 | : "r" (source) // Source must be gen reg
|
|---|
| 70 | : "%r28"); // Clobbers %r28
|
|---|
| 71 | return (lptr);
|
|---|
| 72 | };
|
|---|
| 73 |
|
|---|
| 74 | LONGPOINTER __perl_mpe_addtopointer(LONGPOINTER source, // %r26 == source offset
|
|---|
| 75 | // %r25 == source space
|
|---|
| 76 | int len) // %r24 == length in bytes
|
|---|
| 77 | {
|
|---|
| 78 | /*
|
|---|
| 79 | * Increment a longpointer.
|
|---|
| 80 | */
|
|---|
| 81 |
|
|---|
| 82 | __asm__ __volatile__ (
|
|---|
| 83 | " copy %0,%%r28\n" // copy space to r28
|
|---|
| 84 | "\t add %1,%2,%%r29" // Increment the pointer
|
|---|
| 85 | : // No output
|
|---|
| 86 | : "r" (source.spaceid), // Source address
|
|---|
| 87 | "r" (source.offset),
|
|---|
| 88 | "r" (len) // Length
|
|---|
| 89 | : "%r28", // Clobbers
|
|---|
| 90 | "%r29");
|
|---|
| 91 | };
|
|---|
| 92 |
|
|---|
| 93 | void __perl_mpe_longmove(int len, // %r26 == byte length
|
|---|
|
|---|