/[qemu]/qemu/softmmu_header.h
ViewVC logotype

Diff of /qemu/softmmu_header.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by bellard, Sun Aug 10 23:39:03 2003 UTC revision 1.3 by bellard, Mon Oct 27 21:22:22 2003 UTC
# Line 19  Line 19 
19   */   */
20  #if DATA_SIZE == 8  #if DATA_SIZE == 8
21  #define SUFFIX q  #define SUFFIX q
22    #define USUFFIX q
23  #define DATA_TYPE uint64_t  #define DATA_TYPE uint64_t
24  #elif DATA_SIZE == 4  #elif DATA_SIZE == 4
25  #define SUFFIX l  #define SUFFIX l
26    #define USUFFIX l
27  #define DATA_TYPE uint32_t  #define DATA_TYPE uint32_t
28  #elif DATA_SIZE == 2  #elif DATA_SIZE == 2
29  #define SUFFIX w  #define SUFFIX w
30    #define USUFFIX uw
31  #define DATA_TYPE uint16_t  #define DATA_TYPE uint16_t
32  #define DATA_STYPE int16_t  #define DATA_STYPE int16_t
33  #elif DATA_SIZE == 1  #elif DATA_SIZE == 1
34  #define SUFFIX b  #define SUFFIX b
35    #define USUFFIX ub
36  #define DATA_TYPE uint8_t  #define DATA_TYPE uint8_t
37  #define DATA_STYPE int8_t  #define DATA_STYPE int8_t
38  #else  #else
39  #error unsupported data size  #error unsupported data size
40  #endif  #endif
41    
42  #if MEMUSER == 0  #if ACCESS_TYPE == 0
43  #define MEMSUFFIX _kernel  
44    #define CPU_MEM_INDEX 0
45    #define MMUSUFFIX _mmu
46    
47    #elif ACCESS_TYPE == 1
48    
49    #define CPU_MEM_INDEX 1
50    #define MMUSUFFIX _mmu
51    
52    #elif ACCESS_TYPE == 2
53    
54    #define CPU_MEM_INDEX ((env->hflags & HF_CPL_MASK) == 3)
55    #define MMUSUFFIX _mmu
56    
57    #elif ACCESS_TYPE == 3
58    
59    #define CPU_MEM_INDEX ((env->hflags & HF_CPL_MASK) == 3)
60    #define MMUSUFFIX _cmmu
61    
62  #else  #else
63  #define MEMSUFFIX _user  #error invalid ACCESS_TYPE
64  #endif  #endif
65    
66  #if DATA_SIZE == 8  #if DATA_SIZE == 8
# Line 48  Line 70 
70  #endif  #endif
71    
72    
73  #if MEMUSER == 0  DATA_TYPE REGPARM(1) glue(glue(__ld, SUFFIX), MMUSUFFIX)(unsigned long addr,
74  DATA_TYPE REGPARM(1) glue(glue(__ld, SUFFIX), _mmu)(unsigned long addr);                                                           int is_user);
75  void REGPARM(2) glue(glue(__st, SUFFIX), _mmu)(unsigned long addr, DATA_TYPE v);  void REGPARM(2) glue(glue(__st, SUFFIX), MMUSUFFIX)(unsigned long addr, DATA_TYPE v, int is_user);
 #endif  
76    
77  static inline int glue(glue(ldu, SUFFIX), MEMSUFFIX)(void *ptr)  static inline int glue(glue(ld, USUFFIX), MEMSUFFIX)(void *ptr)
78  {  {
79      int index;      int index;
80      RES_TYPE res;      RES_TYPE res;
81      unsigned long addr, physaddr;      unsigned long addr, physaddr;
82        int is_user;
83    
84      addr = (unsigned long)ptr;      addr = (unsigned long)ptr;
85      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
86      if (__builtin_expect(env->tlb_read[MEMUSER][index].address !=      is_user = CPU_MEM_INDEX;
87        if (__builtin_expect(env->tlb_read[is_user][index].address !=
88                           (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) {                           (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) {
89          res = glue(glue(__ld, SUFFIX), _mmu)(addr);          res = glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, is_user);
90      } else {      } else {
91          physaddr = addr + env->tlb_read[MEMUSER][index].addend;          physaddr = addr + env->tlb_read[is_user][index].addend;
92          res = glue(glue(ldu, SUFFIX), _raw)((uint8_t *)physaddr);          res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)physaddr);
93      }      }
94      return res;      return res;
95  }  }
# Line 75  static inline int glue(glue(lds, SUFFIX) Line 99  static inline int glue(glue(lds, SUFFIX)
99  {  {
100      int res, index;      int res, index;
101      unsigned long addr, physaddr;      unsigned long addr, physaddr;
102        int is_user;
103    
104      addr = (unsigned long)ptr;      addr = (unsigned long)ptr;
105      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
106      if (__builtin_expect(env->tlb_read[MEMUSER][index].address !=      is_user = CPU_MEM_INDEX;
107        if (__builtin_expect(env->tlb_read[is_user][index].address !=
108                           (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) {                           (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) {
109          res = (DATA_STYPE)glue(glue(__ld, SUFFIX), _mmu)(addr);          res = (DATA_STYPE)glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, is_user);
110      } else {      } else {
111          physaddr = addr + env->tlb_read[MEMUSER][index].addend;          physaddr = addr + env->tlb_read[is_user][index].addend;
112          res = glue(glue(lds, SUFFIX), _raw)((uint8_t *)physaddr);          res = glue(glue(lds, SUFFIX), _raw)((uint8_t *)physaddr);
113      }      }
114      return res;      return res;
# Line 92  static inline void glue(glue(st, SUFFIX) Line 119  static inline void glue(glue(st, SUFFIX)
119  {  {
120      int index;      int index;
121      unsigned long addr, physaddr;      unsigned long addr, physaddr;
122        int is_user;
123    
124      addr = (unsigned long)ptr;      addr = (unsigned long)ptr;
125      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);      index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
126      if (__builtin_expect(env->tlb_write[MEMUSER][index].address !=      is_user = CPU_MEM_INDEX;
127        if (__builtin_expect(env->tlb_write[is_user][index].address !=
128                           (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) {                           (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) {
129          glue(glue(__st, SUFFIX), _mmu)(addr, v);          glue(glue(__st, SUFFIX), MMUSUFFIX)(addr, v, is_user);
130      } else {      } else {
131          physaddr = addr + env->tlb_write[MEMUSER][index].addend;          physaddr = addr + env->tlb_write[is_user][index].addend;
132          glue(glue(st, SUFFIX), _raw)((uint8_t *)physaddr, v);          glue(glue(st, SUFFIX), _raw)((uint8_t *)physaddr, v);
133      }      }
134  }  }
# Line 107  static inline void glue(glue(st, SUFFIX) Line 137  static inline void glue(glue(st, SUFFIX)
137  #undef DATA_TYPE  #undef DATA_TYPE
138  #undef DATA_STYPE  #undef DATA_STYPE
139  #undef SUFFIX  #undef SUFFIX
140    #undef USUFFIX
141  #undef DATA_SIZE  #undef DATA_SIZE
142  #undef MEMSUFFIX  #undef CPU_MEM_INDEX
143    #undef MMUSUFFIX

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26