|
|
@@ -0,0 +1,99 @@
|
|
|
+/* arch/x86/kernel/archx86_mm32.c
|
|
|
+ *
|
|
|
+ * This file is part of evx.
|
|
|
+ *
|
|
|
+ * evx is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
+ * (at your option) any later version.
|
|
|
+ *
|
|
|
+ * evx is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with evx. If not, see <https://www.gnu.org/licenses/>
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include <kernel/init.h>
|
|
|
+#include <kernel/module.h>
|
|
|
+#include <kernel/mm.h>
|
|
|
+
|
|
|
+#include <arch/archinfo.h>
|
|
|
+#include <arch/mm.h>
|
|
|
+#include <arch/string.h>
|
|
|
+
|
|
|
+
|
|
|
+#include <sys/types.h>
|
|
|
+
|
|
|
+
|
|
|
+extern char cano_putc(int);
|
|
|
+
|
|
|
+
|
|
|
+/* the most important work is: get total size of ram,
|
|
|
+ * and initiallize page structures */
|
|
|
+
|
|
|
+int arch_mm_init(void) {
|
|
|
+ struct e820_entry *e;
|
|
|
+ struct zone *z;
|
|
|
+ struct page *p;
|
|
|
+
|
|
|
+ int i;
|
|
|
+
|
|
|
+ __archptr_t addr;
|
|
|
+
|
|
|
+
|
|
|
+ /* put them there, after that, are the page structures. */
|
|
|
+ z = (struct zone *) &_end;
|
|
|
+ p = (struct page *) ((struct zone *) &_end + 5);
|
|
|
+
|
|
|
+
|
|
|
+ memset(z, 0, sizeof(struct zone) * 5);
|
|
|
+
|
|
|
+ z[0].type = ZONETYPE_RAM;
|
|
|
+
|
|
|
+
|
|
|
+ for (i = 1; i < 5; i++)
|
|
|
+ z[i].type = ZONETYPE_OTHER;
|
|
|
+
|
|
|
+
|
|
|
+ for (e = E820_ADDR; e < E820_ADDR + 32; e++) {
|
|
|
+ if (e->type > E820_TYPE_MAX || !e->type)
|
|
|
+ break;
|
|
|
+
|
|
|
+ addr = PAGE_ALIGN(e->addr);
|
|
|
+
|
|
|
+
|
|
|
+ if (z[e->type].start_addr > (void *) addr)
|
|
|
+ z[e->type].start_addr = (void *) addr;
|
|
|
+
|
|
|
+
|
|
|
+ z[e->type].total_pages++;
|
|
|
+
|
|
|
+
|
|
|
+ /* now initiallize page structures */
|
|
|
+
|
|
|
+ for (i = 0; i < PAGE_NR(e->len); i++) {
|
|
|
+ p->pnr = PAGE_NR(addr);
|
|
|
+ p->count = 0;
|
|
|
+ p->next = p + 1;
|
|
|
+
|
|
|
+ ++p;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ cano_putc('O');
|
|
|
+
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+arch_init(arch_mm_init);
|
|
|
+
|
|
|
+
|