浏览代码

evx: full 'kmalloc' support

rain 4 年之前
父节点
当前提交
89e51e9337
共有 5 个文件被更改,包括 21 次插入 和 16 次删除
  1. 4 3
      arch/x86/kernel/arch_mm.c
  2. 3 1
      arch/x86/vmevx32.lds
  3. 3 1
      arch/x86/vmevx64.lds
  4. 10 1
      include/kernel/mm.h
  5. 1 10
      init/main.c

+ 4 - 3
arch/x86/kernel/arch_mm.c

@@ -32,7 +32,7 @@
 
 
 static int __init init_mapping_32m(void);
-static __archptr_t freeptr;
+__archptr_t freeptr;
 
 
 /* the most important work is: get total size of ram, 
@@ -53,7 +53,6 @@ int arch_mm_init(void) {
 	z = (struct zone *) &_end;
 	p = (struct page *) (z + 2);
 
-	
 	memset(z, 0, sizeof(struct zone) * 2);
 
 	z[0].type = ZONETYPE_RAM;
@@ -125,7 +124,9 @@ static int __init init_mapping_32m(void) {
 			lvl2[j] = addr;
 	}
 
-	freeptr = (__archptr_t) lvl2 + j;
+	/* 16 kib, oh dear, my dear 16 kib :-( */
+
+	freeptr = 0x7000;
 
 	/* no need to invalidate() */
 

+ 3 - 1
arch/x86/vmevx32.lds

@@ -49,6 +49,8 @@ SECTIONS {
 		_erodata = .;
 	}
 
-	_end = .;
+	_end : {
+		_end = .;
+	}
 }
 

+ 3 - 1
arch/x86/vmevx64.lds

@@ -49,6 +49,8 @@ SECTIONS {
 		_erodata = .;
 	}
 
-	_end = _erodata;
+	.end : {
+		_end = .;
+	}
 }
 

+ 10 - 1
include/kernel/mm.h

@@ -67,7 +67,16 @@ struct zone {
 };
 
 #define kmem_zones 	((struct zone *) &_end)
-#define kmem_pages 	
+#define kmem_pages 	((struct page *) (kmem_zones[2]))
+
+
+/* they're really early but fast. actually, most free() did nothing
+ * 
+ * WARNING that you should't use align, because we didn't save old 
+ * freeptr and it will be cracked by it: not freeable */
+
+void 	*early_kmalloc(int nbytes, int align);
+int 	early_free(void *p, int nbytes);
 
 
 #endif

+ 1 - 10
init/main.c

@@ -33,16 +33,7 @@ static int do_init_calls(void);
 
 
 int __init init(void) {
-	u64 npages;
-
-	do_init_calls();
-
-	npages = kmem_zones[ZONETYPE_RAM].total_pages;
-
-	printk("number %p\n", 0x1000);
-	printk("total ram: %d kib\n", npages << PAGE_SHIFT >> 10);
-	
-	return 0;
+	return do_init_calls();
 }