printk("module 0x%08x - 0x%08x size %u cmdline %s\n", m->mod_start, m->mod_end, m->size, m->cmdline);
boot_params.boot_module_begin = (void *)m->mod_start;
boot_params.boot_module_end = (void *)m->mod_end;
-#if 0
+#if 1
const uint32_t mod_magic = *(uint32_t *)(mod_start + 0);
const uint32_t mod_head_size = *(uint32_t *)(mod_start + 4);
const uint32_t mod_timestamp = *(uint32_t *)(mod_start + 8);
printk("%02X ", c);
}
printk("\n");
-
}
#endif
break;
set pagination off
+display/z $ss
+
+set disassemble-next-line on
+
#b init_serial
#b init_system_info
uint32_t vm_flags;
- struct vma *vm_next;
+ struct vm_area *vm_next;
} vm_area_t;
#ifndef ASM
#include <fs.h>
#include <list.h>
+#include <mm.h>
#include <page.h>
#include <processor.h>
#include <system.h>
path_t root;
path_t pwd;
+ vm_area_t *vma_list;
+
list_head_t list; // 所有进程串成一个链表
list_head_t pend; // 某些条件串成一个链表
root_task.reason = "root";
root_task.priority = 7;
root_task.ticks = root_task.priority;
+ root_task.vma_list = NULL;
root_task.turn = 0;
root_task.need_resched = 0;
root_task.sched_cnt = 0;
kernel_task("tskC", taskC_entry, NULL);
#endif
-#if 1
+#if 0
void *mod_start = pa2va(boot_params.boot_module_begin);
mod_start = (void *)va2pa(mod_start);
LoadCR3(current->cr3);
asm("sysexit;" ::"d"(mod_start), "c"(mod_start + PAGE_SIZE - 4));
-#else
+#endif
+#if 0
void *mod_start = pa2va(boot_params.boot_module_begin);
printk("RING3 ENTRY %x\n", mod_start);
}
void init_rootfs() {
-#if 0
+#if 1
void *mod_start = pa2va(boot_params.boot_module_begin);
const uint32_t mod_magic = *(uint32_t *)(mod_start + 0);
#include <printk.h>
#include <string.h>
#include <system.h>
+#include <task.h>
#include <types.h>
extern char etext, edata, end;
extern void init_ttys();
+kmem_cache_t *g_vma_kmem_cache = NULL;
+
void init_mm() {
printk("init bootmem alloc...\n");
extern void init_bootmem();
init_kmem_caches();
printk("memory init finished...\n");
boot_delay(DEFAULT_BOOT_DELAY_TICKS);
+
+ g_vma_kmem_cache = kmem_cache_create("vma", sizeof(vm_area_t), 4);
+ assert(g_vma_kmem_cache != NULL);
+}
+
+vm_area_t *vma_alloc() {
+ vm_area_t *vma = kmem_cache_alloc(g_vma_kmem_cache, 0);
+ vma->vm_bgn = 0;
+ vma->vm_end = 0;
+ vma->vm_flags = 0;
+ vma->vm_next = NULL;
+ return vma;
+}
+
+void vma_insert(task_t *tsk, vm_area_t *vma_new) {
+ //
+ vm_area_t **p = &tsk->vma_list;
+
+ while (*p != NULL) {
+ vm_area_t *v = *p;
+
+ assert(v->vm_bgn < v->vm_end);
+ assert(vma_new->vm_bgn < vma_new->vm_end);
+ assert(vma_new->vm_bgn < v->vm_bgn || vma_new->vm_bgn > v->vm_end);
+ assert(vma_new->vm_end < v->vm_bgn || vma_new->vm_end > v->vm_end);
+
+ if (vma_new->vm_end < v->vm_bgn) {
+ break;
+ }
+
+ p = &v->vm_next;
+ }
+
+ vma_new->vm_next = *p;
+ *p = vma_new;
+}
+
+vm_area_t *vma_find(task_t *tsk, vm_area_t *vma, uint32_t addr) {
+ vm_area_t **p = &tsk->vma_list;
+ while (*p != NULL) {
+ vm_area_t *v = *p;
+
+ if (addr <= v->vm_end) {
+ break;
+ }
+
+ p = &v->vm_next;
+ }
+
+ return *p;
}
#set gfxpayload=1024x768x32
#insmod all_video
multiboot2 /boot/Kernel root=hda7 delay=2
- #module2 /boot/rootfs rootfs
- module2 /boot/init init
+ module2 /boot/rootfs rootfs
+ #module2 /boot/init init
boot
}