首页 \ 问答 \ 自家种植的内核出现三重故障(Triple fault in home grown kernel)

自家种植的内核出现三重故障(Triple fault in home grown kernel)

我正在尝试编写一个内核,主要用于娱乐目的,而且我遇到了一个问题,因为我认为这是三重故障。 在我尝试启用分页之前一切正常。 破解的代码是这样的:

void switch_page_directory(page_directory_t *dir){

 current_directory = dir;
 asm volatile("mov %0, %%cr3":: "r"(&dir->tablesPhysical));

 u32int cr0;
 asm volatile("mov %%cr0, %0": "=r"(cr0));

 cr0 |= 0x80000000;//enable paging
 asm volatile("mov %0, %%cr0":: "r"(cr0)); //this line breaks


}//switch page directory

为此,我一直在关注各种教程/文档,但是我用于分页的教程是http://www.jamesmolloy.co.uk/tutorial_html/6.-Paging.html 。 我不确定其他代码对于解决这个问题是有用的,但是如果有更多的我应该提供,我会非常乐意这样做。

编辑=====

我相信CS,DS和SS正在选择正确的条目,这里是用于设置它们的代码

global gdt_flush     
extern gp            
gdt_flush:

    lgdt [gp]        ; Load the GDT with our 'gp' which is a special pointer
    mov ax, 0x10      ; 0x10 is the offset in the GDT to our data segment

    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov ss, ax

    jmp 0x08:flush2   ; 0x08 is the offset to our code segment: Far jump!

flush2:
    ret               ; Returns back to the C code!

这里是gdt结构本身

struct gdt_entry{
    unsigned short limit_low;
    unsigned short base_low;
    unsigned char base_middle;
    unsigned char access;
    unsigned char granularity;
    unsigned char base_high;
} __attribute__((packed));

struct gdt_ptr{
    unsigned short limit;
    unsigned int base;
} __attribute__((packed));

struct gdt_entry gdt[5];
struct gdt_ptr gp;

IDT与此非常相似。


I am trying to write a kernel, mostly for entertainment purposes, and I am running into a problem were I believe it is triple faulting. Everything worked before I attempted to enable paging. The code that is breaking is this:

void switch_page_directory(page_directory_t *dir){

 current_directory = dir;
 asm volatile("mov %0, %%cr3":: "r"(&dir->tablesPhysical));

 u32int cr0;
 asm volatile("mov %%cr0, %0": "=r"(cr0));

 cr0 |= 0x80000000;//enable paging
 asm volatile("mov %0, %%cr0":: "r"(cr0)); //this line breaks


}//switch page directory

I have been following a variety of tutorials / documents for this but the one I am using to paging is thus http://www.jamesmolloy.co.uk/tutorial_html/6.-Paging.html . I am not sure what other code will be useful in figuring this out but if there is more I should provide I will be more than happy to do so.

Edit=====

I believe the CS,DS and SS are selecting correct entries here's the code used to set them

global gdt_flush     
extern gp            
gdt_flush:

    lgdt [gp]        ; Load the GDT with our 'gp' which is a special pointer
    mov ax, 0x10      ; 0x10 is the offset in the GDT to our data segment

    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov ss, ax

    jmp 0x08:flush2   ; 0x08 is the offset to our code segment: Far jump!

flush2:
    ret               ; Returns back to the C code!

and here's the gdt struct itself

struct gdt_entry{
    unsigned short limit_low;
    unsigned short base_low;
    unsigned char base_middle;
    unsigned char access;
    unsigned char granularity;
    unsigned char base_high;
} __attribute__((packed));

struct gdt_ptr{
    unsigned short limit;
    unsigned int base;
} __attribute__((packed));

struct gdt_entry gdt[5];
struct gdt_ptr gp;

The IDT is very similar to this.


原文:https://stackoverflow.com/questions/4081246
更新时间:2022-12-28 06:12

最满意答案

为什么不直接扩展Actor ,或者如果你希望非演员也可以收听,那么创建一个ListenableActor来扩展演员的Listenable?

然后你会像上面所做的那样重写Actor中的receive (除非你想调用super.receive ,对吗?) - 你只是想修改传入的函数)。


Why not extend Actor directly, or if you want non-Actors to be Listenable also, create a ListenableActor that extends Actor with Listenable?

You then would override receive in Actor as you've done above (except you'd want to call super.receive also, wouldn't you?--you'd just want to modify the function that's passed in).

相关问答

更多
  • 为什么不直接扩展Actor ,或者如果你希望非演员也可以收听,那么创建一个ListenableActor来扩展演员的Listenable? 然后你会像上面所做的那样重写Actor中的receive (除非你想调用super.receive ,对吗?) - 你只是想修改传入的函数)。 Why not extend Actor directly, or if you want non-Actors to be Listenable also, create a ListenableActor that exte ...
  • 它允许actor在请求是同一个actor调用链的一部分时处理多个请求。 Actor是单线程的,这意味着一个actor一次只能处理一个请求。 没有重入,A - > B - > C - > A就会陷入僵局。 只要您通过单线程规则进行游戏,演员对演员的调用就完全没问题了。 It allows an actor to process more than one request at a time when the requests are part of the same chain of actor calls. ...
  • 尝试对给定的消息作出反应: actor { loop { receive { case s: String => reply(s + " :)") }}} Try reacting to the given message: actor { loop { receive { case s: String => reply(s + " :)") }}}
  • 在那种情况下,我可能会采用第二种方法。 您只能在“已选中”时恢复用户actor的事件。 使这种方法更加方便的原因是用户角色的行为可以根据其状态而改变。 例如,如果用户注册,您肯定不希望多次持续存在相同的“已注册”事件。 或者,如果用户停用其帐户,您当然不希望让他更新他的电子邮件等。此外,所有更改都会保存为一系列事件。 所以没有数据丢失。 另一方面,如果您使用第一种方法,则必须在父级actor恢复时重新创建所有子actor,以便设置其状态,以便您可以避免以前提到的不良行为。 In that case, I w ...
  • 如果我没错,那么Actor的名称在父语境中是唯一的。 因此,如果您创建的actor的两个实例具有不同的名称,那么它们可以使用其他命名的actor。 我有待纠正。 If Im not wrong the name of an Actor is unique in the context of the parent. So if the two instances of the actor you create have different names, then they can use other name ...
  • 是的,这是可能的,一个坚持你所描述的例子是PersistentActor。 http://doc.akka.io/api/akka/2.3.4/#akka.persistence.PersistentActor这是一个Actor的子类型。 在我过去的公司,我们通过扩展HashMap作为状态和一些定义的生命周期状态(如open,close,waitingForAck,termination)来抽象更多的PersistentActor。 Yes that is possible and one example ...
  • 这个怎么样? loop { reactWithin(10000) { case TIMEOUT => // send message to client case work => // do work } } How about this? loop { reactWithin(10000) { case TIMEOUT => // send message to client case work => // do work } }
  • 你的问题在于changex()和changey()方法。 你所拥有的只是返回当前的x或y值。 它应该是: public int changex(int x1){ x = x1; return x; } public int changey(int y1){ y = y1; return y; } Your problem is in the changex() and changey() methods. What you have is literally doin ...
  • 子actor使用隐式上下文创建,该上下文在每个Actor的范围内可用。 因此,在您的情况下,创建的actor的层次结构如下: /user supervisorActor userActor notifyActor Child actors are created using the context implicit that is available within the scope of each Actor. So in your case, the heirarchy of th ...
  • 您可以创建一个actor,它将Identify()消息发送给actor系统中的所有actor,然后计算回复。 需要注意的是,在处理这些识别消息时,可以创建/删除参与者,并且某些参与者可能太忙而无法及时响应。 所以计数需要被视为近似值,这对您的目的来说可能是好的。 下面是一些未编译和未经测试的代码,但它应该给你一个想法: object CounterActor { case class CountRequest(requestId : String, timeout : Timeout) ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)