tlb-common.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Common definitions for the softmmu tlb
  3. *
  4. * Copyright (c) 2003 Fabrice Bellard
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef EXEC_TLB_COMMON_H
  20. #define EXEC_TLB_COMMON_H 1
  21. #define CPU_TLB_ENTRY_BITS (HOST_LONG_BITS == 32 ? 4 : 5)
  22. /* Minimalized TLB entry for use by TCG fast path. */
  23. typedef union CPUTLBEntry {
  24. struct {
  25. uintptr_t addr_read;
  26. uintptr_t addr_write;
  27. uintptr_t addr_code;
  28. /*
  29. * Addend to virtual address to get host address. IO accesses
  30. * use the corresponding iotlb value.
  31. */
  32. uintptr_t addend;
  33. };
  34. /*
  35. * Padding to get a power of two size, as well as index
  36. * access to addr_{read,write,code}.
  37. */
  38. uintptr_t addr_idx[(1 << CPU_TLB_ENTRY_BITS) / sizeof(uintptr_t)];
  39. } CPUTLBEntry;
  40. QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
  41. /*
  42. * Data elements that are per MMU mode, accessed by the fast path.
  43. * The structure is aligned to aid loading the pair with one insn.
  44. */
  45. typedef struct CPUTLBDescFast {
  46. /* Contains (n_entries - 1) << CPU_TLB_ENTRY_BITS */
  47. uintptr_t mask;
  48. /* The array of tlb entries itself. */
  49. CPUTLBEntry *table;
  50. } CPUTLBDescFast QEMU_ALIGNED(2 * sizeof(void *));
  51. #endif /* EXEC_TLB_COMMON_H */