|
@@ -23,6 +23,7 @@
|
|
|
#include <kernel/module.h>
|
|
#include <kernel/module.h>
|
|
|
#include <kernel/mm.h>
|
|
#include <kernel/mm.h>
|
|
|
#include <kernel/kernel.h>
|
|
#include <kernel/kernel.h>
|
|
|
|
|
+#include <kernel/kmlog.h>
|
|
|
|
|
|
|
|
#include <arch/archinfo.h>
|
|
#include <arch/archinfo.h>
|
|
|
#include <arch/mm.h>
|
|
#include <arch/mm.h>
|
|
@@ -33,6 +34,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
static int __init init_mapping_32m(void);
|
|
static int __init init_mapping_32m(void);
|
|
|
|
|
+static int __init init_kmlog_buf(void);
|
|
|
|
|
+
|
|
|
__archptr_t freeptr;
|
|
__archptr_t freeptr;
|
|
|
|
|
|
|
|
void *kernel_end;
|
|
void *kernel_end;
|
|
@@ -44,7 +47,7 @@ void *kernel_end;
|
|
|
int arch_mm_init(void) {
|
|
int arch_mm_init(void) {
|
|
|
struct e820_entry *e;
|
|
struct e820_entry *e;
|
|
|
struct zone *z;
|
|
struct zone *z;
|
|
|
- struct page *p;
|
|
|
|
|
|
|
+ struct page *p, *last;
|
|
|
|
|
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
@@ -53,16 +56,14 @@ int arch_mm_init(void) {
|
|
|
total_pages = 0;
|
|
total_pages = 0;
|
|
|
|
|
|
|
|
init_mapping_32m();
|
|
init_mapping_32m();
|
|
|
|
|
+ init_kmlog_buf();
|
|
|
|
|
+
|
|
|
kernel_end = (void *) (KERNEL_OFFSET | (__archptr_t) &_end);
|
|
kernel_end = (void *) (KERNEL_OFFSET | (__archptr_t) &_end);
|
|
|
|
|
|
|
|
/* put them there, after that, are the page structures. */
|
|
/* put them there, after that, are the page structures. */
|
|
|
z = kmem_zones;
|
|
z = kmem_zones;
|
|
|
- p = kmem_pages;
|
|
|
|
|
-
|
|
|
|
|
- memset(z, 0, sizeof(struct zone) * 2);
|
|
|
|
|
|
|
|
|
|
- z[0].type = ZONETYPE_RAM;
|
|
|
|
|
- z[1].type = ZONETYPE_OTHER;
|
|
|
|
|
|
|
+ memset(z, 0, sizeof(struct zone) * 16);
|
|
|
|
|
|
|
|
|
|
|
|
|
for (e = E820_ADDR; e < E820_ADDR + 32; e++) {
|
|
for (e = E820_ADDR; e < E820_ADDR + 32; e++) {
|
|
@@ -75,27 +76,44 @@ int arch_mm_init(void) {
|
|
|
|
|
|
|
|
addr = PAGE_ALIGN(HIGH_AND_LOW(e->addrh, e->addrl, 32));
|
|
addr = PAGE_ALIGN(HIGH_AND_LOW(e->addrh, e->addrl, 32));
|
|
|
|
|
|
|
|
- if (z[e->type].start_addr > (void *) addr)
|
|
|
|
|
- z[e->type].start_addr = (void *) addr;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
npages = PAGE_NR(HIGH_AND_LOW(e->lenh, e->lenl, 32));
|
|
npages = PAGE_NR(HIGH_AND_LOW(e->lenh, e->lenl, 32));
|
|
|
- z[e->type].total_pages += npages;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ z->start_addr = (void *) addr;
|
|
|
|
|
+ z->type = e->type;
|
|
|
|
|
+ z->total_pages += npages;
|
|
|
|
|
|
|
|
/* any page */
|
|
/* any page */
|
|
|
total_pages += npages;
|
|
total_pages += npages;
|
|
|
|
|
|
|
|
- /* now initiallize page structures */
|
|
|
|
|
|
|
+ if (z->type == ZONETYPE_RAM)
|
|
|
|
|
+ nr_ram_pages += npages;
|
|
|
|
|
+
|
|
|
|
|
+ ++z;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ p = kmem_pages = (struct page *) z;
|
|
|
|
|
+ z = kmem_zones;
|
|
|
|
|
+
|
|
|
|
|
+ for (;;) {
|
|
|
|
|
+ if (z->type != ZONETYPE_RAM && z->type != ZONETYPE_OTHER)
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ z->pages = p;
|
|
|
|
|
|
|
|
- for (i = 0; i < npages; i++) {
|
|
|
|
|
|
|
+ for (i = 0; i < z->total_pages; i++) {
|
|
|
|
|
+ last = p;
|
|
|
p->count = 0;
|
|
p->count = 0;
|
|
|
p->next = p + 1;
|
|
p->next = p + 1;
|
|
|
|
|
|
|
|
- ++p;
|
|
|
|
|
|
|
+ p++;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- first_usable_ram = page_descr(PAGE_ALIGN((__archptr_t) (kmem_pages + total_pages)));
|
|
|
|
|
|
|
+ last->next = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ z++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ first_usable_ram = page_descr(PAGE_ALIGN((__archptr_t) p));
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -144,6 +162,15 @@ static int __init init_mapping_32m(void) {
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static int __init init_kmlog_buf(void) {
|
|
|
|
|
+ kmlog_buf = (char *) freeptr;
|
|
|
|
|
+ freeptr += KMLOG_SIZE;
|
|
|
|
|
+
|
|
|
|
|
+ *kmlog_buf = 0;
|
|
|
|
|
+
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/* stack - 8192 */
|
|
/* stack - 8192 */
|
|
|
#define END 0x8e000
|
|
#define END 0x8e000
|