在 Grub2 中启动自定义内核 [英] Booting custom kernel in Grub2

查看:50
本文介绍了在 Grub2 中启动自定义内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 Grub2 启动一个自定义内核.我使用了旧的(grub 1)多重引导头:

I want to boot a custom kernel with Grub2. I used old (grub 1) multiboot header:

.set flags, 0x0
.set magic, 0x1badb002
.set checksum, -(magic + flags)

.align 4
.long magic
.long flags
.long checksum

...

movl %eax, magic

但它不适用于 Grub2,所以我搜索了新的 Multiboot 规范并找到了它:http://bzr.savannah.gnu.org/lh/grub/branches/multiboot2/annotate/head:/doc/multiboot2.h(它不是真正的规范,它只是一个头文件)

But it doesn't work with Grub2, so I've searched for new Multiboot specification and found it: http://bzr.savannah.gnu.org/lh/grub/branches/multiboot2/annotate/head:/doc/multiboot2.h (it's not a real specification, it's just a header file)

所以,现在我正在使用这个多重引导头:

So, now I am using this multiboot header:

.set flags, 0x0
.set magic, 0xe85250d6
.set magic_the_second, 0x36d76289
.set checksum, -(magic + flags)

.align 4
.long magic
.long flags
.long checksum

...

movl %eax, magic_the_second

但它也不起作用:没有多重引导头

But it also doesn't work: No multiboot header

有什么建议吗?

谢谢!

推荐答案

Multiboot 2 使用与原始多重引导不同的结构(即,它使用标签结构).

Multiboot 2 uses a different structure than the original multiboot (namely, it uses tag structures).

这是我的一个旧项目的示例标题:

Here's an example header from one of my older projects:

    # multiboot 2 header (see http://download-mirror.savannah.gnu.org/releases/grub/phcoder/multiboot.pdf)
    .balign 8
mbhdr:
    .long 0xe85250d6 # magic
    .long 0 # architecture (i386, 32-bit)
    .long .LhdrEnd-mbhdr # header length
    .long -(.LhdrEnd-mbhdr+0xe85250d6) # checksum
    # tags
    # module align
    .word 6 # type
    .word 0 # flags
    .long 8 # size in bytes (spec says 12?)
    .balign 8
    # loader entry
    .word 3
    .word 0
    .long 12
    .long entry
    .balign 8
    # console flags
    .word 4
    .word 0
    .long 12
    .long 0x03 # EGA text support, require console
    .balign 8
    # info request 
    .word 1
    .word 0
    .long 4*6+8
    .long 5 # BIOS boot device
    .long 1 # command line
    .long 3 # modules
    .long 9 # ELF symbols
    .long 6 # memory map
    .long 10 # APM table
    .balign 8
    # address info
    .word 2 # type
    .word 0 # flags
    .long 24 # size
    .long mbhdr # header load addr
    .long 0x100000 # load addr
    .long 0 # load end addr (entire file)
    .long 0 # BSS end addr (no BSS)
    .balign 8
    # terminating tag
    .word 0
    .word 0
    .long 8
.LhdrEnd:

这篇关于在 Grub2 中启动自定义内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆