chyyuu / os_kernel_lab Goto Github PK
View Code? Open in Web Editor NEWOS kernel labs based on Rust/C Lang & RISC-V 64/X86-32
Home Page: https://rcore-os.github.io/rCore-Tutorial-Book-v3/index.html
License: GNU General Public License v3.0
OS kernel labs based on Rust/C Lang & RISC-V 64/X86-32
Home Page: https://rcore-os.github.io/rCore-Tutorial-Book-v3/index.html
License: GNU General Public License v3.0
您好,我参考readme中讲述的,
brew install i386-elf-gdb
brew install i386-elf-gcc
每个大概都花了一小时左右,但是当我再执行make的时候,同样遇到了一下提示:
/bin/sh: i386-elf-gcc: command not found
make: *** Deleting file `obj/boot/bootmain.d'
xxxxx
应该是i386-elf-gcc的问题,是我brew install 失败了 还是应该加一个 alias这样的别名或者ln -s 这样的命令? 刚学习这门课程,实在有点搞不懂这里,希望能指导一下,谢谢了
我直接运行lab5_answer(没有改动任何代码)都会报这个错误——然而这个错误在lab6里面也产生了(之后的lab我还没有做,应该也有这个问题)。
我经过检查之后,发现确实是源代码的一个bug导致的。因此在这里将其说明原因及解决方案(但我不确定是否有人发现并解决了他,至少master和几个pull request我粗略看了,好像并没有)。
在pmm.c中的check_boot_pgdir()函数中,虽然最后将pgdir[0]等等做了清理,但是在系统的快表TLB中依然存在着0x100这个地址对应的页表。而不巧的是,在vmm.c中,check_pgfault()函数中也用到了这个0x100地址,所以在这段代码运行的时候,因为关于这个地址的快表没有被清理掉,从而导致没有发生页中断,缺少了一些处理,从而在free page的时候,报这个错误——这个错误确实存在,但并不一定产生,因为快表的替换机制问题,很有可能跑到vmm.c这行代码的时候,这页快表已经被替换掉了。
解决方案就是在check_boot_pgdir()函数的末尾加上两行。
tlb_invalidate(boot_pgdir, 0x100);
tlb_invalidate(boot_pgdir, 0x100+PGSIZE);
另外,这里面check的地方很多,我不确定其他地方是否会由于TLB的问题导致同样的错误。
如果有什么问题,请联系[email protected]
Macos按照说明书安装后执行make qemu出现问题
执行之后出现以下日志:
make qemu ─╯
WARNING: Image format was not specified for 'bin/ucore.img' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
弹出了qemu黑框框,但是会卡住没有输出
为什么会明确定义到头部位置是处于0x10000?这个地址有特殊含义吗?
https://github.com/chyyuu/ucore_os_lab/blob/29a36eb9863092511eeae39c2afffd49143af72f/labcodes/lab1/boot/bootmain.c#L34
// LAB2 EXERCISE 1: YOUR CODE
// you should rewrite functions:default_init
,default_init_memmap
,default_alloc_pages
,default_free_pages
.
但是这四个函数已经被实现了
This is the output of make
make[1]: Entering directory '/home/lin/workspace/clone/os_kernel_lab/user'
Installing rcore-fs-fuse
Updating git repository `https://github.com/rcore-os/rcore-fs`
Installing rcore-fs-fuse v0.1.0 (https://github.com/rcore-os/rcore-fs#6df6cd24)
Updating crates.io index
Compiling libc v0.2.101
Compiling log v0.4.14
Compiling winapi-build v0.1.1
Compiling proc-macro2 v1.0.29
Compiling cfg-if v1.0.0
Compiling proc-macro2 v0.4.30
Compiling unicode-xid v0.2.2
Compiling unicode-xid v0.1.0
Compiling winapi v0.2.8
Compiling syn v1.0.75
Compiling syn v0.15.44
Compiling proc-macro-hack v0.5.19
Compiling spin v0.5.2
Compiling unicode-width v0.1.8
Compiling unicode-segmentation v1.8.0
Compiling either v1.6.1
Compiling radium v0.3.0
Compiling utf8-ranges v0.1.3
Compiling ansi_term v0.11.0
Compiling static_assertions v0.3.4
Compiling strsim v0.8.0
Compiling vec_map v0.8.2
Compiling bitflags v1.3.2
Compiling regex-syntax v0.3.9
Compiling textwrap v0.11.0
Compiling bitvec v0.17.4
Compiling kernel32-sys v0.2.2
Compiling heck v0.3.3
Compiling log v0.3.9
Compiling quote v0.6.13
Compiling quote v1.0.9
Compiling thread-id v2.0.0
Compiling rcore-fs v0.1.0 (/home/lin/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/6df6cd2/rcore-fs)
Compiling memchr v0.1.11
Compiling atty v0.2.14
Compiling time v0.1.44
Compiling thread_local v0.2.7
Compiling aho-corasick v0.5.3
Compiling clap v2.33.3
Compiling rcore-fs-sfs v0.1.0 (/home/lin/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/6df6cd2/rcore-fs-sfs)
Compiling rcore-fs-ramfs v0.1.0 (/home/lin/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/6df6cd2/rcore-fs-ramfs)
error[E0658]: `if` is not allowed in a `const fn`
--> /home/lin/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.3/src/app/settings.rs:7:1
|
7 | / bitflags! {
8 | | struct Flags: u64 {
9 | | const SC_NEGATE_REQS = 1;
10 | | const SC_REQUIRED = 1 << 1;
... |
51 | | }
52 | | }
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: `if` is not allowed in a `const fn`
--> /home/lin/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.3/src/args/settings.rs:6:1
|
6 | / bitflags! {
7 | | struct Flags: u32 {
8 | | const REQUIRED = 1;
9 | | const MULTIPLE = 1 << 1;
... |
28 | | }
29 | | }
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Compiling rcore-fs-sefs v0.1.0 (/home/lin/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/6df6cd2/rcore-fs-sefs)
Compiling regex v0.1.80
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.
error: could not compile `clap`.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `rcore-fs-fuse v0.1.0 (https://github.com/rcore-os/rcore-fs#6df6cd24)`, intermediate artifacts can be found at `/tmp/cargo-installAwAzA7`
Caused by:
build failed
make[1]: *** [Makefile:23: dependency] Error 101
make[1]: Leaving directory '/home/lin/workspace/clone/os_kernel_lab/user'
make: *** [Makefile:2: run] Error 2
zhu@ubuntu:~/qemu-4.2.0/rCore-Tutorial$ sudo make
make[1]: 进入目录“/home/zhu/qemu-4.2.0/rCore-Tutorial/user”
Installing rcore-fs-fuse
Updating git repository https://github.com/rcore-os/rcore-fs
Installing rcore-fs-fuse v0.1.0 (https://github.com/rcore-os/rcore-fs#6df6cd24)
Updating crates.io index
Compiling libc v0.2.79
Compiling log v0.4.11
Compiling winapi-build v0.1.1
Compiling cfg-if v0.1.10
Compiling proc-macro2 v1.0.24
Compiling proc-macro2 v0.4.30
Compiling unicode-xid v0.1.0
Compiling winapi v0.2.8
Compiling unicode-xid v0.2.1
Compiling syn v1.0.42
Compiling syn v0.15.44
Compiling spin v0.5.2
Compiling bitflags v1.2.1
Compiling unicode-width v0.1.8
Compiling unicode-segmentation v1.6.0
Compiling either v1.6.1
Compiling radium v0.3.0
Compiling utf8-ranges v0.1.3
Compiling strsim v0.8.0
Compiling proc-macro-hack v0.5.18
Compiling regex-syntax v0.3.9
Compiling vec_map v0.8.2
Compiling static_assertions v0.3.4
Compiling ansi_term v0.11.0
Compiling kernel32-sys v0.2.2
Compiling textwrap v0.11.0
Compiling heck v0.3.1
Compiling bitvec v0.17.4
Compiling log v0.3.9
Compiling quote v1.0.7
Compiling rcore-fs v0.1.0 (/home/zhu/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/6df6cd2/rcore-fs)
error[E0554]: #![feature]
may not be used on the stable release channel
--> rcore-fs/src/lib.rs:2:1
|
2 | #![feature(async_closure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try rustc --explain E0554
.
error: could not compile rcore-fs
.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile rcore-fs-fuse v0.1.0 (https://github.com/rcore-os/rcore-fs#6df6cd24)
, intermediate artifacts can be found at /tmp/cargo-installunMg5N
Caused by:
build failed
Makefile:22: recipe for target 'dependency' failed
make[1]: *** [dependency] Error 101
make[1]: 离开目录“/home/zhu/qemu-4.2.0/rCore-Tutorial/user”
Makefile:2: recipe for target 'run' failed
make: *** [run] Error 2
genew@genew-Acer:/github/ucore_os_lab/labcodes/lab1$ gdb16.5) 7.11.1
GNU gdb (Ubuntu 7.11.1-0ubuntu1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file bin/kernel
Reading symbols from bin/kernel...done.
(gdb) target remote :1234
Remote debugging using :1234
0x0000fff0 in ?? ()
(gdb) set arch i8086
warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB. Attempting to continue with the default i8086 settings.
The target architecture is assumed to be i8086
(gdb) b *0x7c00
Breakpoint 1 at 0x7c00
(gdb) c
Continuing.
Breakpoint 1, 0x00007c00 in ?? ()
(gdb) n
Cannot find bounds of current function
(gdb) step
Cannot find bounds of current function
(gdb) c
Continuing.
for (i = 0; i < memmap->nr_map; i ++) {
uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;
cprintf(" memory: %08llx, [%08llx, %08llx], type = %d.\n",
memmap->map[i].size, begin, end - 1, memmap->map[i].type);
if (memmap->map[i].type == E820_ARM) {
if (maxpa < end && begin < KMEMSIZE) {
maxpa = end;
}
}
}
if (maxpa > KMEMSIZE) {
maxpa = KMEMSIZE;
}
extern char end[];
npage = maxpa / PGSIZE;
pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
static void
add_entry(struct sfs_fs *sfs, struct cache_inode *current, struct cache_inode *file, const char *name) {
static struct sfs_entry __entry, *entry = &__entry;
assert(current->inode.type == SFS_TYPE_DIR && strlen(name) <= SFS_MAX_FNAME_LEN);
entry->ino = file->ino, strcpy(entry->name, name);
uint32_t entry_ino = sfs_alloc_ino(sfs);
//这里为什么是sizeof(entry->name),不应该是sizeof(sfs_entry)
write_block(sfs, entry, sizeof(entry->name), entry_ino);
append_block(sfs, current, sizeof(entry->name), entry_ino, name);
file->inode.nlinks ++;
}
When running make qemu
for lab 3, it fails with the following error
+++ switch to user mode +++
page fault at 0xc0100210: U/R [protection fault].
not valid addr c0100210, and can not find it in vma
trapframe at 0xc0122fb4
edi 0x0000807c
esi 0x00010074
ebp 0xc0122fa8
oesp 0xc0122fd4
ebx 0x00010074
edx 0xc0108f27
ecx 0x00000000
eax 0x0000001e
ds 0x----0023
es 0x----0023
fs 0x----0023
gs 0x----0023
trap 0x0000000e Page Fault
err 0x00000005
eip 0xc0100210
cs 0x----001b
flag 0x00003286 PF,SF,IF,IOPL=3
esp 0x0000003f
ss 0x----0023
kernel panic at kern/trap/trap.c:209:
handle pgfault failed. invalid parameter
This happens when lab1_switch_test()
is invoked. I noticed that in lab answers lab1_switch_test
is commented. I wonder why switching between user/kernel mode cause error in lab 3.
BTW, in order to make sure that the problem is not caused by my own lab 3 code, I completed the kernel/user mode switch part in lab 2 answer code. The same error occurs.
static int
_fifo_swap_out_victim(struct mm_struct *mm, struct Page ** ptr_page, int in_tick)
{
list_entry_t *head=(list_entry_t*) mm->sm_priv;
assert(head != NULL);
assert(in_tick==0);
/* Select the victim */
/*LAB3 EXERCISE 2: YOUR CODE*/
//(1) unlink the earliest arrival page in front of pra_list_head qeueue
//(2) set the addr of addr of this page to ptr_page
return 0;
}
the code above is in /labcodes/lab3/kern/mm/swap_fifo.c. It is puzzle to me for the comments set the addr of addr of this page to ptr_page
. The comment is a little misleading, I think.
We should change the value of *ptr_page instead of the ptr_page. So I think the comment set the addr of addr of this page to ptr_page
should be changed to set the addr of this page to *ptr_page
.
what is your opinion about this?
如果你的机型是64位,但是无法新建64位,都是32位的,可以尝试如下:
1:开机重启,按f12.
2:进入BIOS中,高级选项,选择virtualization,设定其为enable。
我刚开始没找到virtualization,然后我直接搜索的,如果可以直接搜索,会更方便。
Lab0保护模式和分段机制
最后一段
比如,你可以使用RPL=3的段描述符来确保给定的操作所使用的段可以在用户模式中访问。
应该是DPL=3?
如题,新版本的ubuntu系统(特指Ubuntu 17 18)都有类似的问题,以下为clean后执行 make V=
的log:
+ cc kern/init/init.c
gcc -Ikern/init/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/init/init.c -o obj/kern/init/init.o
+ cc kern/libs/stdio.c
gcc -Ikern/libs/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/libs/stdio.c -o obj/kern/libs/stdio.o
+ cc kern/libs/readline.c
gcc -Ikern/libs/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/libs/readline.c -o obj/kern/libs/readline.o
+ cc kern/debug/panic.c
gcc -Ikern/debug/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/debug/panic.c -o obj/kern/debug/panic.o
kern/debug/panic.c: In function ‘__panic’:
kern/debug/panic.c:27:5: warning: implicit declaration of function ‘print_stackframe’; did you mean ‘print_trapframe’? [-Wimplicit-function-declaration]
print_stackframe();
^~~~~~~~~~~~~~~~
print_trapframe
+ cc kern/debug/kdebug.c
gcc -Ikern/debug/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/debug/kdebug.c -o obj/kern/debug/kdebug.o
+ cc kern/debug/kmonitor.c
gcc -Ikern/debug/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/debug/kmonitor.c -o obj/kern/debug/kmonitor.o
+ cc kern/driver/clock.c
gcc -Ikern/driver/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/driver/clock.c -o obj/kern/driver/clock.o
+ cc kern/driver/console.c
gcc -Ikern/driver/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/driver/console.c -o obj/kern/driver/console.o
+ cc kern/driver/picirq.c
gcc -Ikern/driver/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/driver/picirq.c -o obj/kern/driver/picirq.o
+ cc kern/driver/intr.c
gcc -Ikern/driver/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/driver/intr.c -o obj/kern/driver/intr.o
+ cc kern/trap/trap.c
gcc -Ikern/trap/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/trap/trap.c -o obj/kern/trap/trap.o
+ cc kern/trap/vectors.S
gcc -Ikern/trap/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/trap/vectors.S -o obj/kern/trap/vectors.o
+ cc kern/trap/trapentry.S
gcc -Ikern/trap/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/trap/trapentry.S -o obj/kern/trap/trapentry.o
+ cc kern/mm/pmm.c
gcc -Ikern/mm/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -c kern/mm/pmm.c -o obj/kern/mm/pmm.o
+ cc libs/string.c
gcc -Ilibs/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -c libs/string.c -o obj/libs/string.o
+ cc libs/printfmt.c
gcc -Ilibs/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -c libs/printfmt.c -o obj/libs/printfmt.o
+ ld bin/kernel
ld -m elf_i386 -nostdlib -T tools/kernel.ld -o bin/kernel obj/kern/init/init.o obj/kern/libs/stdio.o obj/kern/libs/readline.o obj/kern/debug/panic.o obj/kern/debug/kdebug.o obj/kern/debug/kmonitor.o obj/kern/driver/clock.o obj/kern/driver/console.o obj/kern/driver/picirq.o obj/kern/driver/intr.o obj/kern/trap/trap.o obj/kern/trap/vectors.o obj/kern/trap/trapentry.o obj/kern/mm/pmm.o obj/libs/string.o obj/libs/printfmt.o
+ cc boot/bootasm.S
gcc -Iboot/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Os -nostdinc -c boot/bootasm.S -o obj/boot/bootasm.o
+ cc boot/bootmain.c
gcc -Iboot/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Os -nostdinc -c boot/bootmain.c -o obj/boot/bootmain.o
+ cc tools/sign.c
gcc -Itools/ -g -Wall -O2 -c tools/sign.c -o obj/sign/tools/sign.o
gcc -g -Wall -O2 obj/sign/tools/sign.o -o bin/sign
+ ld bin/bootblock
ld -m elf_i386 -nostdlib -N -e start -Ttext 0x7C00 obj/boot/bootasm.o obj/boot/bootmain.o -o obj/bootblock.o
'obj/bootblock.out' size: 600 bytes
600 >> 510!!
Makefile:152: recipe for target 'bin/bootblock' failed
make: *** [bin/bootblock] Error 255
我使用的是无图形化的Ubuntu18
lab1时,在终端输入make lab1-mon 出现下列报错:
root@******:~/ucore_os_lab/labcodes_answer/lab1_result# make lab1-mon
/bin/sh: 1: gnome-terminal: not found
Makefile:202: recipe for target 'lab1-mon' failed
make: *** [lab1-mon] Error 127
请问是因为无法建立新终端的问题么
macos 10.12.4,make debug
在断点处无法停止。看到Q/A中有说关闭kvm,但是查看发现并没有开启。在ubuntu虚拟机上调试出现同样错误。但是lab1并没有问题。希望老师和同学告知解决方式,感谢!
在lab6中sched_class_proc_tick是static函数,但是需要在trap.c中调用.
我将会在lab6中修改该函数的定义(去掉static并加入sched.h).同时在lab6_result的trap.c中加入该函数,使其正确.
感觉老师或同学能适当堆内联汇编部分的输入输出操作数增加一点解释,目前的版本略有点晦涩,解释的语句很多专有名词,较为抽象。如果能将这些操作数存在的原因稍作解释就好理解很多
看到makefile qemu的命令并没有设定内存的大小,也就是128MB。尝试加大内存的时候会导致page的数量变大,溢出最开始的4MB地址。还有一个问题是LAB2中将0x00000000 - 0x38000000映射到了0xC0000000 - 0xF8000000, 但是物理内存只有128MB。尝试访问了一下映射中不合理的内存区域,没有报错,但是无论怎么改不合理的内存区域中的值,结果都是0。这样直接映射是合理的吗?
我直接在Centos上运行时,执行make qemu 会提示:
Error: Coun‘t find a working QEMU executable
Is the directory containing the qemu binary in your PATH
在kdebug.c 的print_stackframe(void) 方法中,第6行有这样一段注释描述:// (3.2) (uint32_t)calling arguments [0..4] = the contents in address (uint32_t)ebp +2 [0..4]
但是实验指导书中, 所显示的args数目是4个。所以这里的 [0..4]
应该都改为[0..3]
您好,我在init.c里面看到这一行代码
memset(edata, 0, end - edata);
我个人理解是初始化全局变量用的。不知道对不对。。
但是我感觉这样初始化全局变量会导致default_pmm.c里面设置的manager的函数指针被清空导致pmm_init继续不下去(>=lab2)?
我在我机器上(ubuntu 17.04 64位)试的时候就会这个问题。
不知道是不是我哪里看错了或者编译参数没有设置对所以想请教一下。。
谢谢!
应该检测是否形成了一个完整的双向链表结构
le = &free_list;
while ((le == list_next(le)) != &free_list) {
assert(le->next->prev == le && le->prev->next == le); // 用这个来进行判断链表结构是否正确
struct Page *p = le2page(le, page_link);
count--; total -= p->property;
}
assert(count == 0);
assert(total == 0);
执行make grade,出现
: not found.sh: 2: tools/grade.sh:
tools/grade.sh: 157: tools/grade.sh: Syntax error: ")" unexpected (expecting "then")
make: *** [grade] Error 2
等报错
password是多少,安装的时候好像没有设置password
"forktree" is a user space program in lab6 for tesing. When one forked process is executing cprint("aaaa\n"), chances are that the OS reschedule this process, because of timeout, to another process which will execute cprint("bbbb\n"), resulting an output like the following:
aabbbb
cccc
dddd
aa
eeee
This output should be correct, considering there isn't any lock in the user space cprint to make it atomic.
Unfortunately, the current "grade.sh" script is asking for a full match for “aaaa”.
So i'm considering rewriting this grading script. Is it worth the trouble? Or some workaround will do the trick?
+ ld bin/bootblock ld -m elf_i386 -nostdlib -N -e start -Ttext 0x7C00 obj/boot/bootasm.o obj/boot/bootmain.o -o obj/bootblock.o 'obj/bootblock.out' size: 620 bytes 620 >> 510!! Makefile:152: recipe for target 'bin/bootblock' failed make: *** [bin/bootblock] Error 255
The size of bootloader.out is larger than 510B.
陈渝老师您好 ,为了这个项目 我花了一年学c/c++和操作系统原理,对汇编不太懂,请问这个项目用的是什么汇编?
arm的还是x86的呢? 如果是x86则是intel的还是at&t的?我现在刚学完8086的,对这些不太懂, 我想知道接下来怎么学
I've tried running make grade
for lab 1 - lab 3 (the lab codes_answers, not my own code), and they all fails with Error 1.
Platform: macOs Catalina
Check Output: (1.0s)
-check ring 0: no $qemu_out
-check switch to ring 3: no $qemu_out
-check switch to ring 0: no $qemu_out
-check ticks: no $qemu_out
Total Score: 0/40
make: *** [grade] Error 1
Check PMM: (1.0s)
-check pmm: no $qemu_out
-check page table: no $qemu_out
-check ticks: no $qemu_out
Total Score: 0/50
make: *** [grade] Error 1
Check SWAP: (1.0s)
-check pmm: no $qemu_out
-check page table: no $qemu_out
-check vmm: no $qemu_out
-check swap page fault: no $qemu_out
-check ticks: no $qemu_out
Total Score: 0/45
make: *** [grade] Error 1
after add brew tap,I get some error and don't know how to fix:
`
➜ lab1 git:(master) ✗ brew tap altkatz/homebrew-gcc_cross_compilers
Updating Homebrew...
==> Tapping altkatz/gcc_cross_compilers
Cloning into '/usr/local/Homebrew/Library/Taps/altkatz/homebrew-gcc_cross_compilers'...
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 17 (delta 10), reused 6 (delta 4), pack-reused 0
Unpacking objects: 100% (17/17), done.
Checking connectivity... done.
Tapped 15 formulae (53 files, 43.8KB)
➜ lab1 git:(master) ✗ brew install i386-elf-gcc
==> Installing i386-elf-gcc from altkatz/gcc_cross_compilers
Error: altkatz/gcc_cross_compilers/i386-elf-gcc contains conflicting version recursive dependencies:
gmp, gmp@4, mpfr, mpfr@2, libmpc, [email protected]
View these with 'brew deps --tree altkatz/gcc_cross_compilers/i386-elf-gcc'.
`
May be the tap need to fix ?
Makefile Line 158/172 有重复的create_target
。
Line 172 的 create_target
是否应当改为
$(call create_target,kernel_nopage)
或者干脆删除?
最初使用virtualbox,但是Mac下使用似乎不能全屏,看着特别难受,后来看到可以在mac下配置,于是进行尝试。
在Mac上配置实验环境时,安装i386-elf-gcc时遇到如下报错:
brew install i386-elf-gcc
'
Updating Homebrew...
==> Installing dependencies for i386-elf-gcc: i386-elf-binutils
==> Installing i386-elf-gcc dependency: i386-elf-binutils
==> Downloading http://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz
Already downloaded: /Users/limingfang/Library/Caches/Homebrew/downloads/87d8faaf2f879e82403ebbed6f4b1c137258f9b9ad2ae0808246515ed53c8d93--binutils-2.23.tar.gz
==> ../configure --disable-nls --target=i386-elf --disable-werror --enable-gold=yes --prefix=/usr
==> make all
Last 15 lines from /Users/limingfang/Library/Logs/Homebrew/i386-elf-binutils/02.make:
checking for _FILE_OFFSET_BITS value needed for large files... none required
checking how to run the C preprocessor... /usr/local/bin/cpp-4.9
unknown
checking for _LARGE_FILES value needed for large files... configure: error: in/private/tmp/i386-elf-binutils-20200305-88849-6u99jn/binutils-2.23/build/intl': configure: error: C preprocessor "/usr/local/bin/cpp-4.9" fails sanity check See
config.log' for more details.
unknown
checking how to run the C preprocessor... /usr/local/bin/cpp-4.9
make[1]: *** [configure-intl] Error 1
make[1]: *** Waiting for unfinished jobs....
configure: error: in/private/tmp/i386-elf-binutils-20200305-88849-6u99jn/binutils-2.23/build/libiberty': configure: error: C preprocessor "/usr/local/bin/cpp-4.9" fails sanity check See
config.log' for more details.
make[1]: *** [configure-libiberty] Error 1
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
Traceback (most recent call last):
28: from /usr/local/Homebrew/Library/Homebrew/build.rb:196:in<main>' 27: from /usr/local/Homebrew/Library/Homebrew/build.rb:114:in
install'
26: from /usr/local/Homebrew/Library/Homebrew/utils.rb:478:inwith_env' 25: from /usr/local/Homebrew/Library/Homebrew/build.rb:117:in
block in install'
24: from /usr/local/Homebrew/Library/Homebrew/formula.rb:1128:inbrew' 23: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2052:in
stage'
22: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/forwardable.rb:230:instage' 21: from /usr/local/Homebrew/Library/Homebrew/resource.rb:75:in
stage'
20: from /usr/local/Homebrew/Library/Homebrew/resource.rb:95:inunpack' 19: from /usr/local/Homebrew/Library/Homebrew/resource.rb:171:in
mktemp'
18: from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:57:inrun' 17: from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:57:in
chdir'
16: from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:57:inblock in run' 15: from /usr/local/Homebrew/Library/Homebrew/resource.rb:172:in
block in mktemp'
14: from /usr/local/Homebrew/Library/Homebrew/resource.rb:100:inblock in unpack' 13: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2076:in
block in stage'
12: from /usr/local/Homebrew/Library/Homebrew/utils.rb:478:inwith_env' 11: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2077:in
block (2 levels) in stage'
10: from /usr/local/Homebrew/Library/Homebrew/formula.rb:1133:inblock in brew' 9: from /usr/local/Homebrew/Library/Homebrew/build.rb:146:in
block (2 levels) in install'
8: from /usr/local/Homebrew/Library/Taps/phantom-fan/homebrew-gcc_cross_compilers.git/i386-elf-binutils.rb:16:ininstall' 7: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2003:in
mkdir'
6: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/fileutils.rb:128:incd' 5: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/fileutils.rb:128:in
chdir'
4: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2004:inblock in mkdir' 3: from /usr/local/Homebrew/Library/Taps/phantom-fan/homebrew-gcc_cross_compilers.git/i386-elf-binutils.rb:21:in
block in install'
2: from /usr/local/Homebrew/Library/Homebrew/formula.rb:1880:insystem' 1: from /usr/local/Homebrew/Library/Homebrew/formula.rb:1880:in
open'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1943:inblock in system': Failed executing: make all (BuildError) 9: from /usr/local/Homebrew/Library/Homebrew/brew.rb:38:in
8: from /usr/local/Homebrew/Library/Homebrew/brew.rb:143:inrescue in <main>' 7: from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:413:in
dump'
6: from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:359:inissues' 5: from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:363:in
fetch_issues'
4: from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:305:inissues_for_formula' 3: from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:291:in
search_issues'
2: from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:400:insearch' 1: from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:225:in
open_api'
/usr/local/Homebrew/Library/Homebrew/utils/github.rb:273:in `raise_api_error': curl failed! % Total % Received % Xferd Average Speed Time Time Time Current (GitHub::Error)
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to api.github.com port 443: Connection refused
额,有知道的小伙伴可以看一看吗?谢谢
_binary_obj___user_hello_out_start:hello执行码的起始位置
_binary_obj___user_hello_out_size中:hello执行码的大小
实验指导书中说是在ld加载时定义的,可以具体说说是怎么一个定义过程吗
https://objectkuan.gitbooks.io/ucore-docs/content/lab1/lab1_3_2_1_protection_mode.html
这一章说到:
如果是4k字节为单位, 所表示的范围应该是4G吧.
谢了!
lab1中使用make debug命令调试os时,执行至/labcodes/lab1/kern/mm/pmm.c的lgdt函数的第62行,反汇编代码mov gs, eax处,当前CS值为0x8,EIP为0x102C67。使用stepi执行下一条指令后,CS、EIP的值分别变为0xF000、0xE05B(跳转到了刚启动的状态),无法继续执行lgdt函数。gcc版本为7.3.0、ubuntu版本为Ubuntu 18.04.2 LTS。
grade.sh
uses expr substr
to cut string, which cannot be use in macos.
This problem exists from lab5 to lab8 (also in the corresponding lab_result folder), which can be solved by change one line into this
# example code in lab5, grade.sh, line 256
select=`echo $1 | cut -c 2-${#1}`
Just a notice :-) .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.