OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to use multiboot structure if I have paging enabled?
PostPosted: Wed Jun 08, 2022 10:13 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 293
In my higher half kernel, I enable paging, but since the multiboot info struct is usually located below 1 mb and outside of my kernel data, I can't safely take information from it.
I see two ways out:
1. Map the first 1 MB each time when you need to get data from the structure.
2. Copy multiboot info struct once and use the copied data.
But both ways have problems:
1. It is not particularly safe and may cause problems in the future.
2. Copying all the information that the structure contains and its various parts is very difficult, it is necessary to manually copy all its parts (for example mmap).

How can I solve this problem?


Top
 Profile  
 
 Post subject: Re: How to use multiboot structure if I have paging enabled?
PostPosted: Wed Jun 08, 2022 10:28 am 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
Here is one way to do it (it seems simple enough):

Bootloader:
1) Identity map the first 4 GB of memory
2) Map the kernel in high-address space
3) Enable paging
4) Jump to the kernel, pass a pointer to the multiboot info

Kernel:
5) Extract / copy all the desired information out of the multiboot structure
6) Unmap the first 4 GB of memory

Alternatively you could parse the multiboot info in the bootloader (and you probably want to do that anyways to know where the memory and framebuffer are). Then build you own data structure with what you need "struct BootData" and pass it to the kernel. The above still applies.

I think the key here is to not try to copy the multiboot info as-is. Instead walk that info and store what you need in your own data structures.

_________________
https://github.com/kiznit/rainbow-os


Last edited by kzinti on Wed Jun 08, 2022 10:58 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to use multiboot structure if I have paging enabled?
PostPosted: Wed Jun 08, 2022 10:32 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
So, after you have set up paging, the address given for the multiboot info is a physical address. How do you access physical addresses? You map them to virtual addresses!

Essentially, you need to change your viewpoint: The address GRUB has given you is a physical address, as are all the addresses contained in the multiboot data. If you must access the information after enabling paging, you must do so like all other info present at some physical address.

_________________
Carpe diem!


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 56 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