vm.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
  3. * The President and Fellows of Harvard College.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. #ifndef _MIPS_VM_H_
  30. #define _MIPS_VM_H_
  31. /*
  32. * Machine-dependent VM system definitions.
  33. */
  34. #define PAGE_SIZE 4096 /* size of VM page */
  35. #define PAGE_FRAME 0xfffff000 /* mask for getting page number from addr */
  36. /*
  37. * MIPS-I hardwired memory layout:
  38. * 0xc0000000 - 0xffffffff kseg2 (kernel, tlb-mapped)
  39. * 0xa0000000 - 0xbfffffff kseg1 (kernel, unmapped, uncached)
  40. * 0x80000000 - 0x9fffffff kseg0 (kernel, unmapped, cached)
  41. * 0x00000000 - 0x7fffffff kuseg (user, tlb-mapped)
  42. *
  43. * (mips32 is a little different)
  44. */
  45. #define MIPS_KUSEG 0x00000000
  46. #define MIPS_KSEG0 0x80000000
  47. #define MIPS_KSEG1 0xa0000000
  48. #define MIPS_KSEG2 0xc0000000
  49. /*
  50. * The first 512 megs of physical space can be addressed in both kseg0 and
  51. * kseg1. We use kseg0 for the kernel. This macro returns the kernel virtual
  52. * address of a given physical address within that range. (We assume we're
  53. * not using systems with more physical space than that anyway.)
  54. *
  55. * N.B. If you, say, call a function that returns a paddr or 0 on error,
  56. * check the paddr for being 0 *before* you use this macro. While paddr 0
  57. * is not legal for memory allocation or memory management (it holds
  58. * exception handler code) when converted to a vaddr it's *not* NULL, *is*
  59. * a valid address, and will make a *huge* mess if you scribble on it.
  60. */
  61. #define PADDR_TO_KVADDR(paddr) ((paddr)+MIPS_KSEG0)
  62. /*
  63. * The top of user space. (Actually, the address immediately above the
  64. * last valid user address.)
  65. */
  66. #define USERSPACETOP MIPS_KSEG0
  67. /*
  68. * The starting value for the stack pointer at user level. Because
  69. * the stack is subtract-then-store, this can start as the next
  70. * address after the stack area.
  71. *
  72. * We put the stack at the very top of user virtual memory because it
  73. * grows downwards.
  74. */
  75. #define USERSTACK USERSPACETOP
  76. /*
  77. * Interface to the low-level module that looks after the amount of
  78. * physical memory we have.
  79. *
  80. * ram_getsize returns the lowest valid physical address, and one past
  81. * the highest valid physical address. (Both are page-aligned.) This
  82. * is the memory that is available for use during operation, and
  83. * excludes the memory the kernel is loaded into and memory that is
  84. * grabbed in the very early stages of bootup.
  85. *
  86. * ram_stealmem can be used before ram_getsize is called to allocate
  87. * memory that cannot be freed later. This is intended for use early
  88. * in bootup before VM initialization is complete.
  89. */
  90. void ram_bootstrap(void);
  91. paddr_t ram_stealmem(unsigned long npages);
  92. void ram_getsize(paddr_t *lo, paddr_t *hi);
  93. // VM stuffs
  94. struct coremap
  95. {
  96. paddr_t start;
  97. int framecount;
  98. int next;
  99. int * num;
  100. };
  101. struct coremap map;
  102. /*
  103. * TLB shootdown bits.
  104. *
  105. * We'll take up to 16 invalidations before just flushing the whole TLB.
  106. */
  107. struct tlbshootdown {
  108. /*
  109. * Change this to what you need for your VM design.
  110. */
  111. struct addrspace *ts_addrspace;
  112. vaddr_t ts_vaddr;
  113. };
  114. #define TLBSHOOTDOWN_MAX 16
  115. #endif /* _MIPS_VM_H_ */