mm.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* arch/x86/include/arch/mm.h
  2. *
  3. * This file is part of evx.
  4. *
  5. * evx is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * evx is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with evx. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __ARCH_MM_H
  19. #define __ARCH_MM_H
  20. #ifndef __ASSEMBLER__
  21. #include <arch/archinfo.h>
  22. #include <config.h>
  23. #define E820_ADDR ((struct e820_entry *) 0x90000)
  24. #define E820_TYPE_RAM 1
  25. #define E820_TYPE_ROM 2
  26. #define E820_TYPE_MAX 5
  27. struct e820_entry {
  28. __uint32_t addrl, addrh;
  29. __uint32_t lenl, lenh;
  30. __uint32_t type;
  31. } __attribute__ ((packed));
  32. #define LVL1_PT ((__archptr_t *) 0)
  33. /* rwup */
  34. #define DEFAULT_PAGE_ATTR 7
  35. void *mapto(void *src, void *dest);
  36. #if CONFIG_64BIT
  37. static inline u64 HIGH_AND_LOW(u32 high, u32 low, int bits) {
  38. u64 res = (u64) high;
  39. res <<= bits;
  40. res += low;
  41. return res;
  42. }
  43. #else
  44. #define HIGH_AND_LOW(high, low, bits) (low)
  45. #endif
  46. #if CONFIG_64BIT
  47. #define invalidate() __asm__ volatile ("movq %%cr3, %%rax;movq %%rax, %%cr3;" ::: "ax")
  48. #else
  49. #define invalidate() __asm__ volatile ("movl %%cr3, %%eax;movl %%eax, %%cr3;" ::: "ax")
  50. #endif
  51. #define real_addr(a) ((a) & ~KERNEL_OFFSET)
  52. #define page_descr(addr) (kmem_pages + PAGE_NR(real_addr(addr) & ~PAGE_MASK))
  53. #define page_nr(page) ((page) - kmem_pages)
  54. #define page_addr(p) ((void *) (page_nr(p) << PAGE_SHIFT))
  55. #endif
  56. #endif