|
@@ -28,7 +28,7 @@
|
|
|
#include <kernel/errno.h>
|
|
#include <kernel/errno.h>
|
|
|
#include <kernel/types.h>
|
|
#include <kernel/types.h>
|
|
|
|
|
|
|
|
-#include <kernel/graphic.h>
|
|
|
|
|
|
|
+#include <modules/tty.h>
|
|
|
#include <kernel/int.h>
|
|
#include <kernel/int.h>
|
|
|
#include <kernel/mm.h>
|
|
#include <kernel/mm.h>
|
|
|
|
|
|
|
@@ -64,7 +64,7 @@ void mm_init(void) {
|
|
|
if (!e->type || e->type >= E820_INV)
|
|
if (!e->type || e->type >= E820_INV)
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- printk(0x00ffffff, 0x00000000, "address %q, length %q KB, type %d\n", e->addr, e->len >> 10, e->type);
|
|
|
|
|
|
|
+ printk(white, "address %q, length %q KB, type %d\n", e->addr, e->len >> 10, e->type);
|
|
|
|
|
|
|
|
/* create a `struct zone` for this */
|
|
/* create a `struct zone` for this */
|
|
|
|
|
|
|
@@ -88,10 +88,10 @@ void mm_init(void) {
|
|
|
e++;
|
|
e++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- printk(0x00ffffff, 0x00000000, "total usable ram: %d MB. \n", total_ram >> 20);
|
|
|
|
|
- printk(0x00ffffff, 0x00000000, "total pages: %d (includes unusable pages) = %d MB\n", mm->total_pages, mm->total_pages << PAGE_SHIFT >> 20);
|
|
|
|
|
|
|
+ printk(white, "total usable ram: %d MB. \n", total_ram >> 20);
|
|
|
|
|
+ printk(white, "total pages: %d (includes unusable pages) = %d MB\n", mm->total_pages, mm->total_pages << PAGE_SHIFT >> 20);
|
|
|
|
|
|
|
|
- printk(0x00ffffff, 0x00000000, "total zones: %d\n", mm->total_zones);
|
|
|
|
|
|
|
+ printk(white, "total zones: %d\n", mm->total_zones);
|
|
|
|
|
|
|
|
/* setup page bitmap */
|
|
/* setup page bitmap */
|
|
|
|
|
|
|
@@ -257,8 +257,6 @@ void *kmalloc(struct mempool *pool, __uint64_t size) {
|
|
|
return pool->page + (i << POOL_ENTRY_SHIFT);
|
|
return pool->page + (i << POOL_ENTRY_SHIFT);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- printk(0x00ffffff, 0x00000000, "need %d points. \n", points);
|
|
|
|
|
-
|
|
|
|
|
/* it's not so good... */
|
|
/* it's not so good... */
|
|
|
|
|
|
|
|
for (i = 0; i < pool->entries; i++) {
|
|
for (i = 0; i < pool->entries; i++) {
|
|
@@ -290,7 +288,7 @@ repeat:
|
|
|
|
|
|
|
|
panic:
|
|
panic:
|
|
|
|
|
|
|
|
- printk(0x00ff0000, 0x00000000, "kmalloc: no enough memory (total %d KB, %d bytes used, requested %d bytes)\n",
|
|
|
|
|
|
|
+ printk(yellow, "kmalloc: no enough memory (total %d KB, %d bytes used, requested %d bytes)\n",
|
|
|
pool->size >> 10, pool->used << 6, points << 6);
|
|
pool->size >> 10, pool->used << 6, points << 6);
|
|
|
|
|
|
|
|
return NULL;
|
|
return NULL;
|
|
@@ -313,11 +311,11 @@ void kfree(struct mempool *pool, void *p, __uint64_t size) {
|
|
|
|
|
|
|
|
|
|
|
|
|
void trace_mm(void) {
|
|
void trace_mm(void) {
|
|
|
- printk(0x0000ff00, 0x00000000, "tracing system memory: \n");
|
|
|
|
|
|
|
+ printk(yellow, "tracing system memory: \n");
|
|
|
|
|
|
|
|
__uint64_t *cr3 = (__uint64_t *) get_cr3();
|
|
__uint64_t *cr3 = (__uint64_t *) get_cr3();
|
|
|
|
|
|
|
|
- printk(0x0000ff00, 0x00000000, "pml4: 0x%q pdp: 0x%q pt: 0x%q\n",
|
|
|
|
|
|
|
+ printk(yellow, "pml4: 0x%q pdp: 0x%q pt: 0x%q\n",
|
|
|
cr3, *cr3 & ~0xff, *(__uint64_t *) (*cr3 & ~0xff) & ~0xff);
|
|
cr3, *cr3 & ~0xff, *(__uint64_t *) (*cr3 & ~0xff) & ~0xff);
|
|
|
|
|
|
|
|
__uint64_t *pt = (__uint64_t *) (*(__uint64_t *) (*cr3 & ~0xff) & ~0xff);
|
|
__uint64_t *pt = (__uint64_t *) (*(__uint64_t *) (*cr3 & ~0xff) & ~0xff);
|
|
@@ -325,7 +323,7 @@ void trace_mm(void) {
|
|
|
|
|
|
|
|
for (i = 0; i < 512; i++) {
|
|
for (i = 0; i < 512; i++) {
|
|
|
if (pt[i])
|
|
if (pt[i])
|
|
|
- printk(0x0000ff00, 0x00000000, "%q -> %q\n", i << PAGE_SHIFT, pt[i] & ~0xff);
|
|
|
|
|
|
|
+ printk(yellow, "%q -> %q\n", i << PAGE_SHIFT, pt[i] & ~0xff);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|