qemu/include/exec/cpu_ldst_useronly_template.h
<<
>>
Prefs
   1/*
   2 *  User-only accessor function support
   3 *
   4 * Generate inline load/store functions for one data size.
   5 *
   6 * Generate a store function as well as signed and unsigned loads.
   7 *
   8 * Not used directly but included from cpu_ldst.h.
   9 *
  10 *  Copyright (c) 2015 Linaro Limited
  11 *
  12 * This library is free software; you can redistribute it and/or
  13 * modify it under the terms of the GNU Lesser General Public
  14 * License as published by the Free Software Foundation; either
  15 * version 2 of the License, or (at your option) any later version.
  16 *
  17 * This library is distributed in the hope that it will be useful,
  18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20 * Lesser General Public License for more details.
  21 *
  22 * You should have received a copy of the GNU Lesser General Public
  23 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  24 */
  25
  26#if !defined(CODE_ACCESS)
  27#include "trace-root.h"
  28#endif
  29
  30#include "trace/mem.h"
  31
  32#if DATA_SIZE == 8
  33#define SUFFIX q
  34#define USUFFIX q
  35#define DATA_TYPE uint64_t
  36#elif DATA_SIZE == 4
  37#define SUFFIX l
  38#define USUFFIX l
  39#define DATA_TYPE uint32_t
  40#elif DATA_SIZE == 2
  41#define SUFFIX w
  42#define USUFFIX uw
  43#define DATA_TYPE uint16_t
  44#define DATA_STYPE int16_t
  45#elif DATA_SIZE == 1
  46#define SUFFIX b
  47#define USUFFIX ub
  48#define DATA_TYPE uint8_t
  49#define DATA_STYPE int8_t
  50#else
  51#error unsupported data size
  52#endif
  53
  54#if DATA_SIZE == 8
  55#define RES_TYPE uint64_t
  56#else
  57#define RES_TYPE uint32_t
  58#endif
  59
  60static inline RES_TYPE
  61glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
  62{
  63#if !defined(CODE_ACCESS)
  64    trace_guest_mem_before_exec(
  65        ENV_GET_CPU(env), ptr,
  66        trace_mem_build_info(DATA_SIZE, false, MO_TE, false));
  67#endif
  68    return glue(glue(ld, USUFFIX), _p)(g2h(ptr));
  69}
  70
  71static inline RES_TYPE
  72glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
  73                                                  target_ulong ptr,
  74                                                  uintptr_t retaddr)
  75{
  76    RES_TYPE ret;
  77    helper_retaddr = retaddr;
  78    ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
  79    helper_retaddr = 0;
  80    return ret;
  81}
  82
  83#if DATA_SIZE <= 2
  84static inline int
  85glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
  86{
  87#if !defined(CODE_ACCESS)
  88    trace_guest_mem_before_exec(
  89        ENV_GET_CPU(env), ptr,
  90        trace_mem_build_info(DATA_SIZE, true, MO_TE, false));
  91#endif
  92    return glue(glue(lds, SUFFIX), _p)(g2h(ptr));
  93}
  94
  95static inline int
  96glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
  97                                                  target_ulong ptr,
  98                                                  uintptr_t retaddr)
  99{
 100    int ret;
 101    helper_retaddr = retaddr;
 102    ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
 103    helper_retaddr = 0;
 104    return ret;
 105}
 106#endif
 107
 108#ifndef CODE_ACCESS
 109static inline void
 110glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
 111                                      RES_TYPE v)
 112{
 113#if !defined(CODE_ACCESS)
 114    trace_guest_mem_before_exec(
 115        ENV_GET_CPU(env), ptr,
 116        trace_mem_build_info(DATA_SIZE, false, MO_TE, true));
 117#endif
 118    glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
 119}
 120
 121static inline void
 122glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
 123                                                  target_ulong ptr,
 124                                                  RES_TYPE v,
 125                                                  uintptr_t retaddr)
 126{
 127    helper_retaddr = retaddr;
 128    glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
 129    helper_retaddr = 0;
 130}
 131#endif
 132
 133#undef RES_TYPE
 134#undef DATA_TYPE
 135#undef DATA_STYPE
 136#undef SUFFIX
 137#undef USUFFIX
 138#undef DATA_SIZE
 139