(hardware) reserved memory & GDT question

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
makuc9
Member
Member
Posts: 33
Joined: Sun Mar 03, 2013 3:27 pm

Re: (hardware) reserved memory & GDT question

Post by makuc9 »

m12: Than I don't really know why you wrote that comment (about assuming too much) in the first place ... But let's head back to the topic.

I have re-written the function from scratch and now I have been wondering (before I post the hex dump), does calling E820h always return the same size in CL register? (Just so I do not implement any complex mechanism for storing each CL as well ... :D )
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: (hardware) reserved memory & GDT question

Post by Combuster »

makuc9 wrote:does always
Assumption is the mother of all (...)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: (hardware) reserved memory & GDT question

Post by AJ »

Hi,
makuc9 wrote:Just so I do not implement any complex mechanism for storing each CL as well ...
Why is storing CL complex?

Cheers,
Adam
makuc9
Member
Member
Posts: 33
Joined: Sun Mar 03, 2013 3:27 pm

Re: (hardware) reserved memory & GDT question

Post by makuc9 »

Well, storing each returned CL and associating it with entry it was returned with can be (altough not necessarily, but I could start complicating things without any real purpose and discovering an easier method later...). That's why I was asking. Is there any point in saving every CL (MM entry size) I get returned? (if not, don't you think that would be pointless memory loss?)
One CL would be saved anyway...
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: (hardware) reserved memory & GDT question

Post by bluemoon »

If you provided 24 bytes zero for it, there are 5 possibilities:
1. return ECX < 20, something is seriously wrong with the BIOS
2. return ECX=20, the last 4 bytes is not touch and you automatically have zero for the supposed ACPI field.
3. ECX=21,22,23. something is seriously wrong with the BIOS
4. ECX=24, good, check if acpi bit is set, clear the field if otherwise
5. ECX>24, something is seriously wrong with the BIOS

I don't see why you need to store CL (or ECX)
makuc9
Member
Member
Posts: 33
Joined: Sun Mar 03, 2013 3:27 pm

Re: (hardware) reserved memory & GDT question

Post by makuc9 »

Thank you, bluemoon. That helped.
And now, here is the (i guess) correct memory map (presented hex-dump):
Image
So, is it correct this time? (i am still working on function to display it better properly, but for some reason it is never the same as reversed this by hand ...). I will update this post once I finish. Last for bytes are trash (uncleaned memory, since function only returns 20 bytes. It would notify me if it is 24 or give error if anything else. I made all the tests as bluemoon said there should be).
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: (hardware) reserved memory & GDT question

Post by dozniak »

bluemoon wrote: you provided 24 bytes zero for it
4. ECX=24, good, check if acpi bit is set, clear the field if otherwise
Other than that, the map looks better now.
Learn to read.
makuc9
Member
Member
Posts: 33
Joined: Sun Mar 03, 2013 3:27 pm

Re: (hardware) reserved memory & GDT question

Post by makuc9 »

Thank you for your feedback. Will be fixing this little issue shortly and afterwards finally move forward. :D
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: (hardware) reserved memory & GDT question

Post by Combuster »

bluemoon wrote:If you provided 24 bytes zero for it
And if you do provide garbage, some bioses will refuse to clear it up and leave the garbage where you'd expect zeroes.

In other words, zeroing the destination memory is mandatory.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply