Memory detection. Something wrong?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
rgmf
Posts: 17
Joined: Wed Sep 28, 2016 1:45 pm

Memory detection. Something wrong?

Post by rgmf »

Hello.

I read http://wiki.osdev.org/Memory_Map_(x86)#Overview where you can see that from 0x00000000 to 0x000003FF we have IVT.

But I have written a memory detection code (INT 15h, EAX=e820) that I execute in the Bochs VM and I get these entries:

Code: Select all

Base Address                Length                    Type
------------------------------------------------------------
0x0000000000000000          0x000000000009f000         1
0x000000000009f000          0x0000000000001000         2
0x00000000000e8000          0x0000000000018000         2
0x0000000000100000          0x0000000001ef0000         1
0x0000000001ff0000          0x0000000000010000         3
0x00000000fffc0000          0x0000000000040000         2
How is it possible? I mean, I have free memory from 0x0 to 0x9f000 but there we have the IVT, isn't it?

Thank you.
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Memory detection. Something wrong?

Post by Nable »

IVT (interrupt vector table - table with addresses of interrupt handlers in real mode) is only needed when you want interrupts in so-called real mode. When you leave this legacy mode, you can use this memory area for any general purpose. There are some exceptions (when you are going to use BIOS calls instead of some native drivers or when SMM handler is badly written and corrupts low memory) but most of the time this is just usual a memory region with nothing special about it.
User avatar
jojo
Member
Member
Posts: 138
Joined: Mon Apr 18, 2016 9:50 am
Libera.chat IRC: jojo
Location: New York New York

Re: Memory detection. Something wrong?

Post by jojo »

The IVT isn't the only thing there. Everything below the first 1MB of physical address space, particularly the first 64K, is encumbered with legacy memory areas that the BIOS memory detection call assumes you know about due to the fact that every PC since the IBM 5150 has had the same memory scheme in the area from 0x0000 to 0xFFFF, which includes the BIOS ROM, peripheral option ROMs, legacy video memory, BIOS shadow memory and working memory, and a million other things.

Long story short: That table that you linked to (http://wiki.osdev.org/Memory_Map_(x86)#Overview) is always existent in every PC and non-negotiable. The BIOS memory detection interrupt is just there to tell you how all of the *other* memory is organized, because there's no standard for that like there is for the low memory area.
rgmf
Posts: 17
Joined: Wed Sep 28, 2016 1:45 pm

Re: Memory detection. Something wrong?

Post by rgmf »

Nable wrote:IVT (interrupt vector table - table with addresses of interrupt handlers in real mode) is only needed when you want interrupts in so-called real mode. When you leave this legacy mode, you can use this memory area for any general purpose. There are some exceptions (when you are going to use BIOS calls instead of some native drivers or when SMM handler is badly written and corrupts low memory) but most of the time this is just usual a memory region with nothing special about it.
jojo wrote:The IVT isn't the only thing there. Everything below the first 1MB of physical address space, particularly the first 64K, is encumbered with legacy memory areas that the BIOS memory detection call assumes you know about due to the fact that every PC since the IBM 5150 has had the same memory scheme in the area from 0x0000 to 0xFFFF, which includes the BIOS ROM, peripheral option ROMs, legacy video memory, BIOS shadow memory and working memory, and a million other things.

Long story short: That table that you linked to (http://wiki.osdev.org/Memory_Map_(x86)#Overview) is always existent in every PC and non-negotiable. The BIOS memory detection interrupt is just there to tell you how all of the *other* memory is organized, because there's no standard for that like there is for the low memory area.
Ok. My doubt is solved because I was thinking I had done something wrong with memory detection :oops: . Thanks for comment.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Memory detection. Something wrong?

Post by SpyderTL »

The IVT memory area is probably not marked in the memory map as reserved because it is perfectly legal, and in most cases necessary for you to write to that area.

All of the other memory map area types are off limits to the OS, in some fashion.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Post Reply