- moved the int86 code out of the 2nd stage boot loader code, and into a
[bootcensus] / src / mem.h
index f571d17..c28136b 100644 (file)
--- a/src/mem.h
+++ b/src/mem.h
@@ -18,6 +18,25 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #ifndef MEM_H_
 #define MEM_H_
 
+#define ADDR_TO_PAGE(x)                        ((uint32_t)(x) >> 12)
+#define PAGE_TO_ADDR(x)                        ((uint32_t)(x) << 12)
+#define PAGE_TO_PTR(x)                 ((void*)PAGE_TO_ADDR(x))
+
+#define BYTES_TO_PAGES(x)              (((uint32_t)(x) + 4095) >> 12)
+
 void init_mem(void);
 
+int alloc_ppage(void);
+void free_ppage(int pg);
+
+/* allocate a number of consecutive pages */
+int alloc_ppages(int count);
+void free_ppages(int pg0, int count);
+
+/* allocate a specific range of pages.
+ * Fails (and returns -1) if any page in the requested range is not free.
+ */
+int alloc_ppage_range(int start, int size);
+int free_ppage_range(int start, int size);
+
 #endif /* MEM_H_ */