Procházet zdrojové kódy

Makefile:: add tags options; vmm.[ch] fix bug in find_vma Function, and update check_vma_struct Funciton from lab3-lab8

main
chyyuu před 11 roky
rodič
revize
0c99c48257
21 změnil soubory, kde provedl 240 přidání a 96 odebrání
  1. +4
    -0
      .gitignore
  2. +8
    -2
      code/lab1/Makefile
  3. +9
    -3
      code/lab2/Makefile
  4. +8
    -2
      code/lab3/Makefile
  5. +24
    -10
      code/lab3/kern/mm/vmm.c
  6. +4
    -3
      code/lab3/kern/mm/vmm.h
  7. +8
    -2
      code/lab4/Makefile
  8. +24
    -10
      code/lab4/kern/mm/vmm.c
  9. +4
    -3
      code/lab4/kern/mm/vmm.h
  10. +8
    -2
      code/lab5/Makefile
  11. +24
    -10
      code/lab5/kern/mm/vmm.c
  12. +4
    -3
      code/lab5/kern/mm/vmm.h
  13. +8
    -2
      code/lab6/Makefile
  14. +24
    -10
      code/lab6/kern/mm/vmm.c
  15. +4
    -3
      code/lab6/kern/mm/vmm.h
  16. +8
    -2
      code/lab7/Makefile
  17. +24
    -10
      code/lab7/kern/mm/vmm.c
  18. +4
    -3
      code/lab7/kern/mm/vmm.h
  19. +11
    -3
      code/lab8/Makefile
  20. +24
    -10
      code/lab8/kern/mm/vmm.c
  21. +4
    -3
      code/lab8/kern/mm/vmm.h

+ 4
- 0
.gitignore Zobrazit soubor

@ -3,3 +3,7 @@ obj/
bin/
.gdb.in
.qemu.out
cscope.*
ncscope.*
tags
*swp

+ 8
- 2
code/lab1/Makefile Zobrazit soubor

@ -233,9 +233,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -248,3 +248,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 9
- 3
code/lab2/Makefile Zobrazit soubor

@ -260,9 +260,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean distclean handin
.PHONY: clean distclean handin tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
$(V)$(RM) -r $(OBJDIR) $(BINDIR)
distclean: clean
@ -272,4 +272,10 @@ handin: distclean
$(V)$(TAR) -cf - `find . -type f -o -type d | grep -v '^\.$$' | grep -v '/CVS/' \
| grep -v '/\.git/' | grep -v '/\.svn/' | grep -v "$(HANDIN)"` \
| $(ZIP) > $(HANDIN)
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 8
- 2
code/lab3/Makefile Zobrazit soubor

@ -254,9 +254,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -269,3 +269,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 24
- 10
code/lab3/kern/mm/vmm.c Zobrazit soubor

@ -80,7 +80,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
list_entry_t *list = &(mm->mmap_list), *le = list;
while ((le = list_next(le)) != list) {
vma = le2vma(le, list_link);
if (addr < vma->vm_end) {
if (vma->vm_start<=addr && addr < vma->vm_end) {
found = 1;
break;
}
@ -181,7 +181,7 @@ check_vma_struct(void) {
int step1 = 10, step2 = step1 * 10;
int i;
for (i = step1; i >= 0; i --) {
for (i = step1; i >= 1; i --) {
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
assert(vma != NULL);
insert_vma_struct(mm, vma);
@ -195,21 +195,35 @@ check_vma_struct(void) {
list_entry_t *le = list_next(&(mm->mmap_list));
for (i = 0; i <= step2; i ++) {
for (i = 1; i <= step2; i ++) {
assert(le != &(mm->mmap_list));
struct vma_struct *mmap = le2vma(le, list_link);
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
le = list_next(le);
}
for (i = 0; i < 5 * step2 + 2; i ++) {
struct vma_struct *vma = find_vma(mm, i);
assert(vma != NULL);
int j = i / 5;
if (i >= 5 * j + 2) {
j ++;
for (i = 5; i <= 5 * step2; i +=5) {
struct vma_struct *vma1 = find_vma(mm, i);
assert(vma1 != NULL);
struct vma_struct *vma2 = find_vma(mm, i+1);
assert(vma2 != NULL);
struct vma_struct *vma3 = find_vma(mm, i+2);
assert(vma3 == NULL);
struct vma_struct *vma4 = find_vma(mm, i+3);
assert(vma4 == NULL);
struct vma_struct *vma5 = find_vma(mm, i+4);
assert(vma5 == NULL);
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
}
for (i =4; i>=0; i--) {
struct vma_struct *vma_below_5= find_vma(mm,i);
if (vma_below_5 != NULL ) {
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
}
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
assert(vma_below_5 == NULL);
}
mm_destroy(mm);

+ 4
- 3
code/lab3/kern/mm/vmm.h Zobrazit soubor

@ -9,11 +9,12 @@
//pre define
struct mm_struct;
// the virtual continuous memory area(vma)
// the virtual continuous memory area(vma), [vm_start, vm_end),
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
struct vma_struct {
struct mm_struct *vm_mm; // the set of vma using the same PDT
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
uint32_t vm_flags; // flags of vma
list_entry_t list_link; // linear list link which sorted by start addr of vma
};

+ 8
- 2
code/lab4/Makefile Zobrazit soubor

@ -258,9 +258,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -273,3 +273,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 24
- 10
code/lab4/kern/mm/vmm.c Zobrazit soubor

@ -81,7 +81,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
list_entry_t *list = &(mm->mmap_list), *le = list;
while ((le = list_next(le)) != list) {
vma = le2vma(le, list_link);
if (addr < vma->vm_end) {
if (vma->vm_start<=addr && addr < vma->vm_end) {
found = 1;
break;
}
@ -180,7 +180,7 @@ check_vma_struct(void) {
int step1 = 10, step2 = step1 * 10;
int i;
for (i = step1; i >= 0; i --) {
for (i = step1; i >= 1; i --) {
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
assert(vma != NULL);
insert_vma_struct(mm, vma);
@ -194,21 +194,35 @@ check_vma_struct(void) {
list_entry_t *le = list_next(&(mm->mmap_list));
for (i = 0; i <= step2; i ++) {
for (i = 1; i <= step2; i ++) {
assert(le != &(mm->mmap_list));
struct vma_struct *mmap = le2vma(le, list_link);
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
le = list_next(le);
}
for (i = 0; i < 5 * step2 + 2; i ++) {
struct vma_struct *vma = find_vma(mm, i);
assert(vma != NULL);
int j = i / 5;
if (i >= 5 * j + 2) {
j ++;
for (i = 5; i <= 5 * step2; i +=5) {
struct vma_struct *vma1 = find_vma(mm, i);
assert(vma1 != NULL);
struct vma_struct *vma2 = find_vma(mm, i+1);
assert(vma2 != NULL);
struct vma_struct *vma3 = find_vma(mm, i+2);
assert(vma3 == NULL);
struct vma_struct *vma4 = find_vma(mm, i+3);
assert(vma4 == NULL);
struct vma_struct *vma5 = find_vma(mm, i+4);
assert(vma5 == NULL);
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
}
for (i =4; i>=0; i--) {
struct vma_struct *vma_below_5= find_vma(mm,i);
if (vma_below_5 != NULL ) {
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
}
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
assert(vma_below_5 == NULL);
}
mm_destroy(mm);

+ 4
- 3
code/lab4/kern/mm/vmm.h Zobrazit soubor

@ -9,11 +9,12 @@
//pre define
struct mm_struct;
// the virtual continuous memory area(vma)
// the virtual continuous memory area(vma), [vm_start, vm_end),
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
struct vma_struct {
struct mm_struct *vm_mm; // the set of vma using the same PDT
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
uint32_t vm_flags; // flags of vma
list_entry_t list_link; // linear list link which sorted by start addr of vma
};

+ 8
- 2
code/lab5/Makefile Zobrazit soubor

@ -306,9 +306,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -321,3 +321,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 24
- 10
code/lab5/kern/mm/vmm.c Zobrazit soubor

@ -84,7 +84,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
list_entry_t *list = &(mm->mmap_list), *le = list;
while ((le = list_next(le)) != list) {
vma = le2vma(le, list_link);
if (addr < vma->vm_end) {
if (vma->vm_start<=addr && addr < vma->vm_end) {
found = 1;
break;
}
@ -270,7 +270,7 @@ check_vma_struct(void) {
int step1 = 10, step2 = step1 * 10;
int i;
for (i = step1; i >= 0; i --) {
for (i = step1; i >= 1; i --) {
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
assert(vma != NULL);
insert_vma_struct(mm, vma);
@ -284,21 +284,35 @@ check_vma_struct(void) {
list_entry_t *le = list_next(&(mm->mmap_list));
for (i = 0; i <= step2; i ++) {
for (i = 1; i <= step2; i ++) {
assert(le != &(mm->mmap_list));
struct vma_struct *mmap = le2vma(le, list_link);
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
le = list_next(le);
}
for (i = 0; i < 5 * step2 + 2; i ++) {
struct vma_struct *vma = find_vma(mm, i);
assert(vma != NULL);
int j = i / 5;
if (i >= 5 * j + 2) {
j ++;
for (i = 5; i <= 5 * step2; i +=5) {
struct vma_struct *vma1 = find_vma(mm, i);
assert(vma1 != NULL);
struct vma_struct *vma2 = find_vma(mm, i+1);
assert(vma2 != NULL);
struct vma_struct *vma3 = find_vma(mm, i+2);
assert(vma3 == NULL);
struct vma_struct *vma4 = find_vma(mm, i+3);
assert(vma4 == NULL);
struct vma_struct *vma5 = find_vma(mm, i+4);
assert(vma5 == NULL);
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
}
for (i =4; i>=0; i--) {
struct vma_struct *vma_below_5= find_vma(mm,i);
if (vma_below_5 != NULL ) {
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
}
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
assert(vma_below_5 == NULL);
}
mm_destroy(mm);

+ 4
- 3
code/lab5/kern/mm/vmm.h Zobrazit soubor

@ -9,11 +9,12 @@
//pre define
struct mm_struct;
// the virtual continuous memory area(vma)
// the virtual continuous memory area(vma), [vm_start, vm_end),
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
struct vma_struct {
struct mm_struct *vm_mm; // the set of vma using the same PDT
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
uint32_t vm_flags; // flags of vma
list_entry_t list_link; // linear list link which sorted by start addr of vma
};

+ 8
- 2
code/lab6/Makefile Zobrazit soubor

@ -306,9 +306,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -321,3 +321,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 24
- 10
code/lab6/kern/mm/vmm.c Zobrazit soubor

@ -84,7 +84,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
list_entry_t *list = &(mm->mmap_list), *le = list;
while ((le = list_next(le)) != list) {
vma = le2vma(le, list_link);
if (addr < vma->vm_end) {
if (vma->vm_start<=addr && addr < vma->vm_end) {
found = 1;
break;
}
@ -270,7 +270,7 @@ check_vma_struct(void) {
int step1 = 10, step2 = step1 * 10;
int i;
for (i = step1; i >= 0; i --) {
for (i = step1; i >= 1; i --) {
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
assert(vma != NULL);
insert_vma_struct(mm, vma);
@ -284,21 +284,35 @@ check_vma_struct(void) {
list_entry_t *le = list_next(&(mm->mmap_list));
for (i = 0; i <= step2; i ++) {
for (i = 1; i <= step2; i ++) {
assert(le != &(mm->mmap_list));
struct vma_struct *mmap = le2vma(le, list_link);
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
le = list_next(le);
}
for (i = 0; i < 5 * step2 + 2; i ++) {
struct vma_struct *vma = find_vma(mm, i);
assert(vma != NULL);
int j = i / 5;
if (i >= 5 * j + 2) {
j ++;
for (i = 5; i <= 5 * step2; i +=5) {
struct vma_struct *vma1 = find_vma(mm, i);
assert(vma1 != NULL);
struct vma_struct *vma2 = find_vma(mm, i+1);
assert(vma2 != NULL);
struct vma_struct *vma3 = find_vma(mm, i+2);
assert(vma3 == NULL);
struct vma_struct *vma4 = find_vma(mm, i+3);
assert(vma4 == NULL);
struct vma_struct *vma5 = find_vma(mm, i+4);
assert(vma5 == NULL);
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
}
for (i =4; i>=0; i--) {
struct vma_struct *vma_below_5= find_vma(mm,i);
if (vma_below_5 != NULL ) {
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
}
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
assert(vma_below_5 == NULL);
}
mm_destroy(mm);

+ 4
- 3
code/lab6/kern/mm/vmm.h Zobrazit soubor

@ -9,11 +9,12 @@
//pre define
struct mm_struct;
// the virtual continuous memory area(vma)
// the virtual continuous memory area(vma), [vm_start, vm_end),
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
struct vma_struct {
struct mm_struct *vm_mm; // the set of vma using the same PDT
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
uint32_t vm_flags; // flags of vma
list_entry_t list_link; // linear list link which sorted by start addr of vma
};

+ 8
- 2
code/lab7/Makefile Zobrazit soubor

@ -306,9 +306,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -321,3 +321,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 24
- 10
code/lab7/kern/mm/vmm.c Zobrazit soubor

@ -84,7 +84,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
list_entry_t *list = &(mm->mmap_list), *le = list;
while ((le = list_next(le)) != list) {
vma = le2vma(le, list_link);
if (addr < vma->vm_end) {
if (vma->vm_start<=addr && addr < vma->vm_end) {
found = 1;
break;
}
@ -270,7 +270,7 @@ check_vma_struct(void) {
int step1 = 10, step2 = step1 * 10;
int i;
for (i = step1; i >= 0; i --) {
for (i = step1; i >= 1; i --) {
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
assert(vma != NULL);
insert_vma_struct(mm, vma);
@ -284,21 +284,35 @@ check_vma_struct(void) {
list_entry_t *le = list_next(&(mm->mmap_list));
for (i = 0; i <= step2; i ++) {
for (i = 1; i <= step2; i ++) {
assert(le != &(mm->mmap_list));
struct vma_struct *mmap = le2vma(le, list_link);
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
le = list_next(le);
}
for (i = 0; i < 5 * step2 + 2; i ++) {
struct vma_struct *vma = find_vma(mm, i);
assert(vma != NULL);
int j = i / 5;
if (i >= 5 * j + 2) {
j ++;
for (i = 5; i <= 5 * step2; i +=5) {
struct vma_struct *vma1 = find_vma(mm, i);
assert(vma1 != NULL);
struct vma_struct *vma2 = find_vma(mm, i+1);
assert(vma2 != NULL);
struct vma_struct *vma3 = find_vma(mm, i+2);
assert(vma3 == NULL);
struct vma_struct *vma4 = find_vma(mm, i+3);
assert(vma4 == NULL);
struct vma_struct *vma5 = find_vma(mm, i+4);
assert(vma5 == NULL);
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
}
for (i =4; i>=0; i--) {
struct vma_struct *vma_below_5= find_vma(mm,i);
if (vma_below_5 != NULL ) {
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
}
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
assert(vma_below_5 == NULL);
}
mm_destroy(mm);

+ 4
- 3
code/lab7/kern/mm/vmm.h Zobrazit soubor

@ -11,11 +11,12 @@
//pre define
struct mm_struct;
// the virtual continuous memory area(vma)
// the virtual continuous memory area(vma), [vm_start, vm_end),
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
struct vma_struct {
struct mm_struct *vm_mm; // the set of vma using the same PDT
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
uint32_t vm_flags; // flags of vma
list_entry_t list_link; // linear list link which sorted by start addr of vma
};

+ 11
- 3
code/lab8/Makefile Zobrazit soubor

@ -1,8 +1,10 @@
PROJ := 5
PROJ := 8
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
SLASH := /
V := @
# try to infer the correct GCCPREFX
ifndef GCCPREFIX
GCCPREFIX := $(shell if i386-ucore-elf-objdump -i 2>&1 | grep '^elf32-i386$$' >/dev/null 2>&1; \
@ -353,9 +355,9 @@ touch:
print-%:
@echo $($(shell echo $(patsubst print-%,%,$@) | $(TR) [a-z] [A-Z]))
.PHONY: clean dist-clean handin packall
.PHONY: clean dist-clean handin packall tags
clean:
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) $(SFSBINS)
$(V)$(RM) $(GRADE_GDB_IN) $(GRADE_QEMU_OUT) $(SFSBINS) cscope* tags
-$(RM) -r $(OBJDIR) $(BINDIR)
dist-clean: clean
@ -368,3 +370,9 @@ packall: clean
@$(RM) -f $(HANDIN)
@tar -czf $(HANDIN) `find . -type f -o -type d | grep -v '^\.*$$' | grep -vF '$(HANDIN)'`
tags:
@echo TAGS ALL
$(V)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(V)find . -type f -name "*.[chS]" >cscope.files
$(V)cscope -bq
$(V)ctags -L cscope.files

+ 24
- 10
code/lab8/kern/mm/vmm.c Zobrazit soubor

@ -84,7 +84,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
list_entry_t *list = &(mm->mmap_list), *le = list;
while ((le = list_next(le)) != list) {
vma = le2vma(le, list_link);
if (addr < vma->vm_end) {
if (vma->vm_start<=addr && addr < vma->vm_end) {
found = 1;
break;
}
@ -270,7 +270,7 @@ check_vma_struct(void) {
int step1 = 10, step2 = step1 * 10;
int i;
for (i = step1; i >= 0; i --) {
for (i = step1; i >= 1; i --) {
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
assert(vma != NULL);
insert_vma_struct(mm, vma);
@ -284,21 +284,35 @@ check_vma_struct(void) {
list_entry_t *le = list_next(&(mm->mmap_list));
for (i = 0; i <= step2; i ++) {
for (i = 1; i <= step2; i ++) {
assert(le != &(mm->mmap_list));
struct vma_struct *mmap = le2vma(le, list_link);
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
le = list_next(le);
}
for (i = 0; i < 5 * step2 + 2; i ++) {
struct vma_struct *vma = find_vma(mm, i);
assert(vma != NULL);
int j = i / 5;
if (i >= 5 * j + 2) {
j ++;
for (i = 5; i <= 5 * step2; i +=5) {
struct vma_struct *vma1 = find_vma(mm, i);
assert(vma1 != NULL);
struct vma_struct *vma2 = find_vma(mm, i+1);
assert(vma2 != NULL);
struct vma_struct *vma3 = find_vma(mm, i+2);
assert(vma3 == NULL);
struct vma_struct *vma4 = find_vma(mm, i+3);
assert(vma4 == NULL);
struct vma_struct *vma5 = find_vma(mm, i+4);
assert(vma5 == NULL);
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
}
for (i =4; i>=0; i--) {
struct vma_struct *vma_below_5= find_vma(mm,i);
if (vma_below_5 != NULL ) {
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
}
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
assert(vma_below_5 == NULL);
}
mm_destroy(mm);

+ 4
- 3
code/lab8/kern/mm/vmm.h Zobrazit soubor

@ -11,11 +11,12 @@
//pre define
struct mm_struct;
// the virtual continuous memory area(vma)
// the virtual continuous memory area(vma), [vm_start, vm_end),
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
struct vma_struct {
struct mm_struct *vm_mm; // the set of vma using the same PDT
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma
uintptr_t vm_start; // start addr of vma
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
uint32_t vm_flags; // flags of vma
list_entry_t list_link; // linear list link which sorted by start addr of vma
};

Načítá se…
Zrušit
Uložit