English 中文(简体)
C/C++中的装货罐?
原标题:Bootloader in C/C++?

在C或C++不使用某种种类的议会(最好不使用__asm)的情况下,能否创建一个箱子? 我撰写一个操作系统,希望在C和C++中填写。

问题回答

That s pretty system dependent. In most cases, the answer is going to be no - you will need to write some custom assembly to set up the C runtime before you start running your C code. There are some exceptions, however. The ARM Cortex-M0, for example, can run C code straight out of reset.

简言之,你不再使用M0,因此,你需要写一些集会。 同样,它依赖系统/芯片,但你可能能够放弃简单的东西:

reset_vector:
    mov  sp, SOME_KNOWN_GOOD_STACK_ADDRESS
    call c_entry_point

这只是先入住脚点,把我们的C方案放在切入点。 当然,这种简单的设置取决于您的心灵,即有一个支持它的复发病媒/病媒表,而区域援助团(或像区域援助团)是在重新启动病媒之前启动的,等等。 早期系统启动时往往有许多“障碍”。

Prepare to get pretty friendly with your compiler, assembler, and linker documentation - generating a flat binary that you can flash down as a first stage bootloader is often a big pain in and of itself.

亲爱!

假设是x86,如果你有正确的编造者选择,并设法使boot部门的布局与适当的连接者魔法保持一致,那么你可能获得16个轨道模式的something

但是,你赢得了远近的光线(C(或C++):你需要掩饰真正的快速中断,因此没有<代码>C功能。 需要议会。

对大多数其他结构来说,这大概相同:C和C++根本不具备这些特征(有些编汇的延伸可能有助于你)。

http://wiki.osdev.org/“rel=“nofollow”>OSDev。

Assuming x86 protected mode:

我认为答案是No,因为你需要做这样的事情才能转向受保护的方式:

    lgdt[GDTR]
    jmp CODESEL:FLUSH
FLUSH:
    ...

我不认为,在纯粹的C/C++中采用“<>jmp指示的方法,尽管我可能错。 (我绝不是这里的一位专家;我只提一下我以前曾做过过的boot装机。)

否,它不可能有“纯”C,至少是x86......。 除了X86机器将安装在16轨实时(要求汇编者生成16比而不是32比方代码)之外,你还需要能够掩饰打断、编组部分登记册、从硬件装置(即软盘)中装载密码、设置一个排 st、进入I/O港等,所有这些平台都要求在x86和其他平台上查阅CPU的登记册和(或)特定组装指挥部。

第二,对于C++来说,如果你决定确定任何类别,那么你将需要有某种人工配置和操作的“建筑”,以积累记忆,使你最初的班级实际上能够生存......你也获得了任何例外。 基本上,你试图使用的任何C++具体特征都将是无用的,因为这些高层次的数据记录需要本组织日常运作本身的适当支持,而这种支持必须使用组合和C编码加以设置。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?