Giter Site home page Giter Site logo

hurlex-doc's Issues

请问 使用的qemu 是什么版本呀

qemu 运行无输入,如果设置 -nographic 则完全卡住,只能手动kill 进程;
ubuntu16.04 apt install 的版本上是2.5;也手动编译了4.1.0,结果一样

第10章的程序无法正确执行

在使用以下命令编译运行第10章时

sudo make
sudo make qemu

grub 选中操作系统后显示如下,并停滞在此界面:
image

objdump 输出:

$ objdump -h hx_kernel 

hx_kernel:     file format elf32-i386

section:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .init.text    00001000  00100000  00100000  00001000  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .init.data    00001000  00101000  00101000  00002000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .text         00003000  c0102000  00102000  00003000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  3 .text.__x86.get_pc_thunk.ax 00000004  c0105000  00105000  00006000  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .text.__x86.get_pc_thunk.bx 00000004  c0105004  00105004  00006004  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  5 .note.gnu.property 0000001c  c0105008  00105008  00006008  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .data         00000fdc  c0105024  00105024  00006024  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  7 .got.plt      0000000c  c0106000  00106000  00007000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  8 .bss          00105020  c0107000  00107000  0000700c  2**12
                  ALLOC
  9 .stab         00005fe0  c020c020  0020c020  0010d020  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 .stabstr      00002000  c0212000  00212000  00113000  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

环境:

$ gcc --version
gcc (GCC) 8.2.1 20181127

$ ld --version
GNU ld (GNU Binutils) 2.31.1

$ nasm --version
NASM version 2.14 compiled on Nov 15 2018

$ uname -a
Linux TwicesManjaro 4.19.16-1-MANJARO #1 SMP PREEMPT Fri Jan 18 17:03:05 UTC 2019 x86_64 GNU/Linux

floppy.img其实是ext2的

在mac上用-t msdos怎么都挂载不上,常使用fuse-ext2挂载成功了,在linux上挂载之后用mount也可以看到type ext2。本来想试着改一下,发现怎么都模仿不出你的语言风格……所以有空你自己看下吧……抱歉

第12章代码有小误&解决方案

在我的ubuntu上面用make编辑,结果为(略去成功的……部分):

编译代码文件 init/entry.c ...
gcc -c -Wall -m32 -ggdb -gstabs+ -nostdinc -fno-builtin -fno-stack-protector -I include init/entry.c -o init/entry.o
In file included from init/entry.c:30:0:
include/common.h:37:13: warning: inline function ‘disable_intr’ declared but never defined
inline void disable_intr();
^
include/common.h:34:13: warning: inline function ‘enable_intr’ declared but never defined
inline void enable_intr();
^
链接内核文件...
ld -T scripts/kernel.ld -m elf_i386 -nostdlib ./idt/idt_s.o ./gdt/gdt_s.o ./kernel/sched/switch_to.o ./boot/boot.o ./libs/common.o ./libs/string.o ./idt/idt.o ./mm/heap.o ./mm/pmm.o ./mm/vmm.o ./mm/page_fault.o ./gdt/gdt.o ./drivers/timer.o ./drivers/console.o ./kernel/task/task.o ./kernel/sched/sched.o ./kernel/debug/elf.o ./kernel/debug/printk.o ./kernel/debug/debug.o ./init/entry.o -o hx_kernel
./init/entry.o: In function kern_init': ********/hurlex-doc-master/code/chapt12/init/entry.c:133: undefined reference to enable_intr'
Makefile:37: recipe for target 'link' failed
make: *** [link] Error 1

这里我了解到inline函数最好在头文件中被定义。我看了看common.h,发现恰好只有dis和en函数的声明被写了inline。
最终我的解决方法是把这两个inline给删掉了。我也尝试过直接把common.c的那两段函数剪过来,但是还是发现没有用。其实我对c语言的编译链接绝对不了解所以我打算就这样?_(:з」∠)_放issue而不是pull的原因是因为我也有点想知道对于这种问题怎样子做更好。。。。。

大大写出来的东西对我在操作系统方面的学习上有着很大的帮助,支持大大!

enadle_intr和disable_intr链接未定义

common.h里两个函数声明去掉inline关键字、

inline关键字在GCC参考文档中仅有对其使用在函数定义(Definition)上的描述,而没有提到其是否能用于函数声明(Declare)

关于chap3修改了entry.c后并无变化

博主你好,很感谢这一版Tutorial。现在跟着做到了chap3末尾,改entry.c后重新编译,并使用-nographic参数启动虚拟机并没有看到有字符输出。这是否与QEMU版本有关呢?
这是结果:
image

这是我的QEMU版本:
image

第五章 文章描述的一点疑惑

在你的文章第五章第516行有此描述

举个例子,一个函数想使用ebx寄存器那么必须在返回前恢复ebp原先的值,而使用edx寄存器就无需暂存和恢复

我想咨询的就是,为什么想使用ebx寄存器那么必须在返回前恢复ebp原先的值,而不是恢复ebx寄存器自身的值。

ubuntu18.10bug

10章开始的代码在ubuntu18.10上出现bug,经测试ubuntu16.04正常,先说出来防止大家踩坑

使用grub可能不是个好主意

想要自己制作操作系统的人应该都是极具好奇心的,想知道所有的一切,而使用grub会导致一种错觉,“这个操作系统底下还有秘密”。

從實模式進入保護模式

以下這段程式碼, 沒有設置 cr0 算是進入保護模式了嘛

gdt_flush:
    mov eax, [esp+4]  ; 参数存入 eax 寄存器
    lgdt [eax]        ; 加载到 GDTR [修改原先GRUB设置]

    mov ax, 0x10      ; 加载我们的数据段描述符
    mov ds, ax        ; 更新所有可以更新的段寄存器
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov ss, ax
    jmp 0x08:.flush   ; 远跳转, 0x08 是我们的代码段描述符
              ; 远跳目的是清空流水线并串行化处理器
.flush:
    ret

heap.c中split_chunk()函数中指针操作的疑问

split_chunk()函数缺少了
next_chunck->next->prev = next_chunck;
如果不这样的话 newchunk->next->pre永远指向 chunk 而不是 newchunk。
是否应该添加这样的代码

if(newchunck->next) {
    newchunck->next->prev = newchunck;
}

Error 13: Invalid or unsupported executable format

作者您好,

我是一名新手,刚刚开始根据您的《x86架构操作系统内核的实现》进行一个简单的实现,目前在第三章这里出现了一个对我来说不是很友好的问题。

环境

Mac OSX 下 使用 VMware Fusion 虚拟机,系统为Ubuntu 14.04 64bit,在虚拟机配置中已开启虚拟化。

出现问题的步骤

1.根据您的教程:hurlex <三> 裸机上运行的 Hello OS Kernel 编写相关程序等(说是编写,其实只是基于您的代码添加了些许注释)。

2.编译:

make 
make qemu

3.Grub提示错误:

Error 13: Invalid or unsupported executable format

一些尝试

在谷歌了相关资料之后,目前可能存在的情况有两种:

第一种解释是:

The GNU Multiboot Specification requires the Multiboot Header to be aligned on a 4 byte boundary within the first 8 KB of the kernel executable file. should your kernel's image not fit this description, GrUB will promptly issue an Error 13.

第二种解释是需要对grub进行升级。

我想请教下您如何解决这个问题呢?谢谢!

对heap.c中split_chunk()的疑问。

Hi, hurley:

在heap.c中,分割内存块的函数split_chunk(header_t *chunk, uint32_t len),其中len是期望获得的chunk的长度,那么分割出来的newchunk的长度不应该是
newchunk = chunk + len吗?

mm/heap.c line 137 function split_chunk()

if (chunk->length - len > sizeof (header_t)) {
-       header_t *newchunk = (header_t *)((uint32_t)chunk + chunk->length);
+       header_t *newchunk = (header_t *)((uint32_t)chunk + len);
                ... ... 
}

不知道我的想法有没有错,望解答 :)

第5章的strcmp实现有点小问题&修改建议

源代码libs/string.c中实现strcmp函数时的源代码是:

inline int strcmp(const char *str1, const char *str2)
{
    while (*str1 && *str2 && (*str1++ == *str2++))
    ;
    if (*str1 == '\0' && *str2 == '\0') {
           return 0;
    }

    if (*str1 == '\0') {
      return -1;
    }
    return 1;
}

这样如果两个字符串长度相等但字符串不同时,检测出来的结果就不对,大神应该当时没有注意到,算是一个小瑕疵吧。修正代码:

inline int strcmp(const char *str1, const char *str2)
{
    while(*str1 == *str2)
    {
	    if(*str1 == '\0')
		    return 0;
	    str1++;
	    str2++;
    }
    return *str1 - *str2;
}

同时感谢大神的文档,比看《Orange's 一个操作系统的实现》要简易很多。

可能是手误

hurley,你好啊
【第八章】
时钟中断对于操作系统内核来说很重要的一种中断,它使得CPU无论在执行任何用户或者内核的程序时,都能定义的将执行权利

难道是“都能定时的将执行权利”。如果不是手误请改成容易理解一点的方式。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.