OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:14 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How to enable the graphic mode by grub2?
PostPosted: Wed Jun 29, 2022 2:27 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
I'm sorry my English is poor, but I will try my best to express the problem clearly.
This is my multiboot2 header, but it doesn't work

Code:
struct os_header {
    struct multiboot_header header;
#ifdef VBE_ENABLE
    struct multiboot_header_tag_framebuffer framebuffer;
#endif
    struct multiboot_header_tag end;
} __attribute__((packed));

struct os_header OS_HEADER __attribute__((section(".multiboot"))) = {
    .header = {
        .magic    = MULTIBOOT2_HEADER_MAGIC,
        .architecture = MULTIBOOT_ARCHITECTURE_I386,
        .header_length = sizeof (struct tayhuang_header),
        .checksum = -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + sizeof(struct tayhuang_header)),
    },
#ifdef VBE_ENABLE
    #define FRAMEBUFFER_WIDTH 1024
    #define FRAMEBUFFER_HEIGHT 768
    #define FRAMEBUFFER_BPP 24
    //FIXME: Error here
    .framebuffer = {
        .type = MULTIBOOT_HEADER_TAG_FRAMEBUFFER,
        .flags = MULTIBOOT_HEADER_TAG_OPTIONAL,
        .size = sizeof (struct multiboot_header_tag_framebuffer),
        .width = FRAMEBUFFER_WIDTH,
        .height = FRAMEBUFFER_HEIGHT,
        .depth = FRAMEBUFFER_BPP
    },

#endif
    .end = {
        .type = MULTIBOOT_HEADER_TAG_END,
        .flags = 0,
        .size = sizeof (struct multiboot_header_tag)
    }
};


It works well.

When I insert the following line to enable the graphic mode
Code:
#define VBE_ENABLE

I get "error: unsupported tag 0x8"

what's wrong with it

_________________
I'm a new man to develop operating system.


Top
 Profile  
 
 Post subject: Re: How to enable the graphic mode by grub2?
PostPosted: Wed Jun 29, 2022 3:16 am 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
There are two framebuffer tags, one for your request to the bootloader, and one for the bootloader's response to your request.

8 is the ID for the latter. You want 5 for the former.

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: How to enable the graphic mode by grub2?
PostPosted: Wed Jun 29, 2022 3:24 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
klange wrote:
There are two framebuffer tags, one for your request to the bootloader, and one for the bootloader's response to your request.

8 is the ID for the latter. You want 5 for the former.


I know.
I‘ve changed
.type = MULTIBOOT_HEADER_TAG_FRAMEBUFFER
into
.type = 5

It still doesn't work
And I still get "error: unsupported tag 0x8"

_________________
I'm a new man to develop operating system.


Top
 Profile  
 
 Post subject: Re: How to enable the graphic mode by grub2?
PostPosted: Wed Jun 29, 2022 4:24 am 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
Your tags probably aren't aligned correctly, then. Your struct doesn't look like it will do the right thing for that - building the multiboot structs in C is unorthodox, they're usually done in assembly.

Someone else had a similar issue several years ago: viewtopic.php?f=1&t=27602

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: How to enable the graphic mode by grub2?
PostPosted: Wed Jun 29, 2022 5:19 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
klange wrote:
Your tags probably aren't aligned correctly, then. Your struct doesn't look like it will do the right thing for that - building the multiboot structs in C is unorthodox, they're usually done in assembly.

Someone else had a similar issue several years ago: viewtopic.php?f=1&t=27602

I've add the __attribute__((packed)). So I think they're aligned correctly
But I will check it, thank you

_________________
I'm a new man to develop operating system.


Top
 Profile  
 
 Post subject: Re: How to enable the graphic mode by grub2?
PostPosted: Wed Jun 29, 2022 5:29 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
klange wrote:
Your tags probably aren't aligned correctly, then. Your struct doesn't look like it will do the right thing for that - building the multiboot structs in C is unorthodox, they're usually done in assembly.

Someone else had a similar issue several years ago: viewtopic.php?f=1&t=27602


Thank you
I insert the
Code:
multiboot_uint32_t reserved0;

under the
Code:
struct multiboot_header_tag_framebuffer framebuffer;


And it works pretty good

Thank you very much

_________________
I'm a new man to develop operating system.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot], Google [Bot] and 82 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group