将精灵条目添加到gnu efi中的功能中

发布于 2025-01-25 12:48:19 字数 1040 浏览 2 评论 0原文

如何将ELF64_EHDR.E_ENTRY施加到功能中?

例如:void(*kernel_function)()=(void(*)())*kernel_entry_point;

当前代码: (标题是ELF64_EHDR) |所包含的Elf.h的版本与/usr/include/elf.h

EFI_PHYSICAL_ADDRESS* kernel_entry_point;

// get entry
*kernel_entry_point = (&header)->e_entry;
//cast into a usable function
void (*kernel_function)() = (void (*)())*kernel_entry_point;

//call the casted function
kernel_function();

我尝试过,但是在内核可以编写字符串之前,EFI应用程序退出。 (在这种情况下是“ Hello World!”)

如果有人可以帮助我,我会很感激。

edit

忘记包括内核代码,所以这里是

#include <stdint.h>

void write_string( int colour, const char *string )
{
    volatile char *video = (volatile char*)0xB8000;
    while( *string != 0 )
    {
        *video++ = *string++;
        *video++ = colour;
    }
}

extern "C" void _start()
{
    write_string(15, "Hello world! \n");    

    return;
}

How would I cast a Elf64_Ehdr.e_entry into a function?

eg: void (*kernel_function)() = (void (*)())*kernel_entry_point;

Current code:
(header is a Elf64_Ehdr)
| The version of elf.h included is identical to /usr/include/elf.h

EFI_PHYSICAL_ADDRESS* kernel_entry_point;

// get entry
*kernel_entry_point = (&header)->e_entry;
//cast into a usable function
void (*kernel_function)() = (void (*)())*kernel_entry_point;

//call the casted function
kernel_function();

I've tried this but the EFI application exits before the kernel can write a string. (which in this case is "Hello World!")

If anyone can help me with this I'd appreciate it.

EDIT:

Forgot to include kernel code, so here it is

#include <stdint.h>

void write_string( int colour, const char *string )
{
    volatile char *video = (volatile char*)0xB8000;
    while( *string != 0 )
    {
        *video++ = *string++;
        *video++ = colour;
    }
}

extern "C" void _start()
{
    write_string(15, "Hello world! \n");    

    return;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文