~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to target-ppc/op_helper.c

  • Committer: Bazaar Package Importer
  • Author(s): Riku Voipio, Josh Triplett, Riku Voipio
  • Date: 2009-07-29 13:28:05 UTC
  • mfrom: (1.4.1 upstream)
  • mto: (12.1.1 sid) (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090729132805-cau7rfexh7dawyb8
Tags: 0.10.50+git20090729-1
[ Josh Triplett ]
* Remove myself from Uploaders.

[ Riku Voipio ]
* new upstream RC version
* nuke all linux-user patches (applied upstream)
  06_exit_segfault
  12_signal_powerpc_support
  21_net_soopts
  30_syscall_ipc
  32_syscall_sysctl
  35_syscall_sockaddr
  48_signal_terminate
  55_unmux_socketcall
* nuke all other applied-upstream patches
  01_nostrip (better version upstream)
  07_i386_exec_name (can be reintroduced in debian/rules)
  50_linuxbios_isa_bios_ram (shouldn't be needed anymore)
  51_linuxbios_piix_ram_size (applied)
  56_dhcp (crap)
  60_ppc_ld (reintroduce if needed)
  64_ppc_asm_constraints (ditto)
  66_tls_ld.patch (ditto)
  81_compile_dtb.patch (applied upstream)
  82_qemu-img_decimal (ditto)
* move to git
* simplify build rules
* Correct my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * Lesser General Public License for more details.
15
15
 *
16
16
 * You should have received a copy of the GNU Lesser General Public
17
 
 * License along with this library; if not, write to the Free Software
18
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
 
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19
18
 */
20
19
#include <string.h>
21
20
#include "exec.h"
54
53
}
55
54
 
56
55
/*****************************************************************************/
57
 
/* Registers load and stores */
58
 
target_ulong helper_load_cr (void)
59
 
{
60
 
    return (env->crf[0] << 28) |
61
 
           (env->crf[1] << 24) |
62
 
           (env->crf[2] << 20) |
63
 
           (env->crf[3] << 16) |
64
 
           (env->crf[4] << 12) |
65
 
           (env->crf[5] << 8) |
66
 
           (env->crf[6] << 4) |
67
 
           (env->crf[7] << 0);
68
 
}
69
 
 
70
 
void helper_store_cr (target_ulong val, uint32_t mask)
71
 
{
72
 
    int i, sh;
73
 
 
74
 
    for (i = 0, sh = 7; i < 8; i++, sh--) {
75
 
        if (mask & (1 << sh))
76
 
            env->crf[i] = (val >> (sh * 4)) & 0xFUL;
77
 
    }
78
 
}
79
 
 
80
 
/*****************************************************************************/
81
56
/* SPR accesses */
82
57
void helper_load_dump_spr (uint32_t sprn)
83
58
{
1671
1646
void helper_rfi (void)
1672
1647
{
1673
1648
    do_rfi(env->spr[SPR_SRR0], env->spr[SPR_SRR1],
1674
 
           ~((target_ulong)0xFFFF0000), 1);
 
1649
           ~((target_ulong)0x0), 1);
1675
1650
}
1676
1651
 
1677
1652
#if defined(TARGET_PPC64)
1678
1653
void helper_rfid (void)
1679
1654
{
1680
1655
    do_rfi(env->spr[SPR_SRR0], env->spr[SPR_SRR1],
1681
 
           ~((target_ulong)0xFFFF0000), 0);
 
1656
           ~((target_ulong)0x0), 0);
1682
1657
}
1683
1658
 
1684
1659
void helper_hrfid (void)
1685
1660
{
1686
1661
    do_rfi(env->spr[SPR_HSRR0], env->spr[SPR_HSRR1],
1687
 
           ~((target_ulong)0xFFFF0000), 0);
 
1662
           ~((target_ulong)0x0), 0);
1688
1663
}
1689
1664
#endif
1690
1665
#endif
1946
1921
 
1947
1922
/*****************************************************************************/
1948
1923
/* Altivec extension helpers */
1949
 
#if defined(WORDS_BIGENDIAN)
 
1924
#if defined(HOST_WORDS_BIGENDIAN)
1950
1925
#define HI_IDX 0
1951
1926
#define LO_IDX 1
1952
1927
#else
1954
1929
#define LO_IDX 0
1955
1930
#endif
1956
1931
 
1957
 
#if defined(WORDS_BIGENDIAN)
 
1932
#if defined(HOST_WORDS_BIGENDIAN)
1958
1933
#define VECTOR_FOR_INORDER_I(index, element)            \
1959
1934
    for (index = 0; index < ARRAY_SIZE(r->element); index++)
1960
1935
#else
1998
1973
SATCVT(sh, sb, int16_t, int8_t, INT8_MIN, INT8_MAX, 1, 1)
1999
1974
SATCVT(sw, sh, int32_t, int16_t, INT16_MIN, INT16_MAX, 1, 1)
2000
1975
SATCVT(sd, sw, int64_t, int32_t, INT32_MIN, INT32_MAX, 1, 1)
2001
 
SATCVT(uh, ub, uint16_t, uint8_t, 0, UINT8_MAX, 0, 1)
 
1976
 
 
1977
/* Work around gcc problems with the macro version */
 
1978
static always_inline uint8_t cvtuhub(uint16_t x, int *sat)
 
1979
{
 
1980
    uint8_t r;
 
1981
 
 
1982
    if (x > UINT8_MAX) {
 
1983
        r = UINT8_MAX;
 
1984
        *sat = 1;
 
1985
    } else {
 
1986
        r = x;
 
1987
    }
 
1988
    return r;
 
1989
}
 
1990
//SATCVT(uh, ub, uint16_t, uint8_t, 0, UINT8_MAX, 0, 1)
2002
1991
SATCVT(uw, uh, uint32_t, uint16_t, 0, UINT16_MAX, 0, 1)
2003
1992
SATCVT(ud, uw, uint64_t, uint32_t, 0, UINT32_MAX, 0, 1)
2004
1993
SATCVT(sh, ub, int16_t, uint8_t, 0, UINT8_MAX, 1, 1)
2066
2055
 
2067
2056
void helper_mtvscr (ppc_avr_t *r)
2068
2057
{
2069
 
#if defined(WORDS_BIGENDIAN)
 
2058
#if defined(HOST_WORDS_BIGENDIAN)
2070
2059
    env->vscr = r->u32[3];
2071
2060
#else
2072
2061
    env->vscr = r->u32[0];
2433
2422
        }                                                               \
2434
2423
        *r = result;                                                    \
2435
2424
    }
2436
 
#if defined(WORDS_BIGENDIAN)
 
2425
#if defined(HOST_WORDS_BIGENDIAN)
2437
2426
#define MRGHI 0
2438
2427
#define MRGLO 1
2439
2428
#else
2594
2583
    int i;
2595
2584
    VECTOR_FOR_INORDER_I (i, u8) {
2596
2585
        int s = c->u8[i] & 0x1f;
2597
 
#if defined(WORDS_BIGENDIAN)
 
2586
#if defined(HOST_WORDS_BIGENDIAN)
2598
2587
        int index = s & 0xf;
2599
2588
#else
2600
2589
        int index = 15 - (s & 0xf);
2608
2597
    *r = result;
2609
2598
}
2610
2599
 
2611
 
#if defined(WORDS_BIGENDIAN)
 
2600
#if defined(HOST_WORDS_BIGENDIAN)
2612
2601
#define PKBIG 1
2613
2602
#else
2614
2603
#define PKBIG 0
2617
2606
{
2618
2607
    int i, j;
2619
2608
    ppc_avr_t result;
2620
 
#if defined(WORDS_BIGENDIAN)
 
2609
#if defined(HOST_WORDS_BIGENDIAN)
2621
2610
    const ppc_avr_t *x[2] = { a, b };
2622
2611
#else
2623
2612
    const ppc_avr_t *x[2] = { b, a };
2734
2723
    }
2735
2724
}
2736
2725
 
2737
 
#if defined(WORDS_BIGENDIAN)
 
2726
#if defined(HOST_WORDS_BIGENDIAN)
2738
2727
#define LEFT 0
2739
2728
#define RIGHT 1
2740
2729
#else
2747
2736
#define VSHIFT(suffix, leftp)                                           \
2748
2737
    void helper_vs##suffix (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)   \
2749
2738
    {                                                                   \
2750
 
        int shift = b->u8[LO_IDX*0x15] & 0x7;                           \
 
2739
        int shift = b->u8[LO_IDX*15] & 0x7;                             \
2751
2740
        int doit = 1;                                                   \
2752
2741
        int i;                                                          \
2753
2742
        for (i = 0; i < ARRAY_SIZE(r->u8); i++) {                       \
2794
2783
    int i;
2795
2784
    ppc_avr_t result;
2796
2785
 
2797
 
#if defined(WORDS_BIGENDIAN)
 
2786
#if defined(HOST_WORDS_BIGENDIAN)
2798
2787
    for (i = 0; i < ARRAY_SIZE(r->u8); i++) {
2799
2788
        int index = sh + i;
2800
2789
        if (index > 0xf) {
2820
2809
{
2821
2810
  int sh = (b->u8[LO_IDX*0xf] >> 3) & 0xf;
2822
2811
 
2823
 
#if defined (WORDS_BIGENDIAN)
 
2812
#if defined (HOST_WORDS_BIGENDIAN)
2824
2813
  memmove (&r->u8[0], &a->u8[sh], 16-sh);
2825
2814
  memset (&r->u8[16-sh], 0, sh);
2826
2815
#else
2831
2820
 
2832
2821
/* Experimental testing shows that hardware masks the immediate.  */
2833
2822
#define _SPLAT_MASKED(element) (splat & (ARRAY_SIZE(r->element) - 1))
2834
 
#if defined(WORDS_BIGENDIAN)
 
2823
#if defined(HOST_WORDS_BIGENDIAN)
2835
2824
#define SPLAT_ELEMENT(element) _SPLAT_MASKED(element)
2836
2825
#else
2837
2826
#define SPLAT_ELEMENT(element) (ARRAY_SIZE(r->element)-1 - _SPLAT_MASKED(element))
2888
2877
{
2889
2878
  int sh = (b->u8[LO_IDX*0xf] >> 3) & 0xf;
2890
2879
 
2891
 
#if defined (WORDS_BIGENDIAN)
 
2880
#if defined (HOST_WORDS_BIGENDIAN)
2892
2881
  memmove (&r->u8[sh], &a->u8[0], 16-sh);
2893
2882
  memset (&r->u8[0], 0, sh);
2894
2883
#else
2912
2901
    ppc_avr_t result;
2913
2902
    int sat = 0;
2914
2903
 
2915
 
#if defined(WORDS_BIGENDIAN)
 
2904
#if defined(HOST_WORDS_BIGENDIAN)
2916
2905
    upper = ARRAY_SIZE(r->s32)-1;
2917
2906
#else
2918
2907
    upper = 0;
2936
2925
    ppc_avr_t result;
2937
2926
    int sat = 0;
2938
2927
 
2939
 
#if defined(WORDS_BIGENDIAN)
 
2928
#if defined(HOST_WORDS_BIGENDIAN)
2940
2929
    upper = 1;
2941
2930
#else
2942
2931
    upper = 0;
3008
2997
    }
3009
2998
}
3010
2999
 
3011
 
#if defined(WORDS_BIGENDIAN)
 
3000
#if defined(HOST_WORDS_BIGENDIAN)
3012
3001
#define UPKHI 1
3013
3002
#define UPKLO 0
3014
3003
#else
3752
3741
/* Segment registers load and store */
3753
3742
target_ulong helper_load_sr (target_ulong sr_num)
3754
3743
{
 
3744
#if defined(TARGET_PPC64)
 
3745
    if (env->mmu_model & POWERPC_MMU_64)
 
3746
        return ppc_load_sr(env, sr_num);
 
3747
#endif
3755
3748
    return env->sr[sr_num];
3756
3749
}
3757
3750
 
3767
3760
    return ppc_load_slb(env, slb_nr);
3768
3761
}
3769
3762
 
3770
 
void helper_store_slb (target_ulong slb_nr, target_ulong rs)
 
3763
void helper_store_slb (target_ulong rb, target_ulong rs)
3771
3764
{
3772
 
    ppc_store_slb(env, slb_nr, rs);
 
3765
    ppc_store_slb(env, rb, rs);
3773
3766
}
3774
3767
 
3775
3768
void helper_slbia (void)