自家种植的内核出现三重故障(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
最满意答案
为什么不直接扩展
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 callsuper.receive
also, wouldn't you?--you'd just want to modify the function that's passed in).
相关问答
更多-
组成演员(Composing actors)[2022-04-28]
为什么不直接扩展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. ...
-
斯卡拉演员的问题(Problems with Scala actors)[2022-06-23]
尝试对给定的消息作出反应: 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 ...
-
akka的多个儿童演员(Multiple child Actors in akka)[2023-07-30]
如果我没错,那么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 ... -
在akka演员中使用继承(using inheritance in akka actors)[2023-04-08]
是的,这是可能的,一个坚持你所描述的例子是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 ... -
在演员中实现超时(Implement timeout in actors)[2021-11-03]
这个怎么样? 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 } } -
如何处理演员(How to process actors)[2023-04-12]
你的问题在于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 ...
-
阿卡:获得演员总数(Akka: Get total number of actors)[2023-10-08]
您可以创建一个actor,它将Identify()消息发送给actor系统中的所有actor,然后计算回复。 需要注意的是,在处理这些识别消息时,可以创建/删除参与者,并且某些参与者可能太忙而无法及时响应。 所以计数需要被视为近似值,这对您的目的来说可能是好的。 下面是一些未编译和未经测试的代码,但它应该给你一个想法: object CounterActor { case class CountRequest(requestId : String, timeout : Timeout) ...