-1

As far as I understand when we are in x86 Real Mode the first megabyte memory layot looks like that:

enter image description here

Will memory layot be changed once we jump to Protected Mode? I know that we can access video memory by the same address like we did it the Real Mode but what about other regions? Can we overwrite them? I suppose we don't need the IVT and the boot sector anymore. But I'm not sure about others.

daniil_
  • 707
  • 7
  • 26
  • 2
    You don't need IVT after entering protected mode. You create a protected mode IDT and it doesn't have to be at the bottom of memory. One disadvantage to overwriting the real mode IVT is that if you are on a legacy BIOS system you won't be able to switch back to real mode and call BIOS interrupts etc. Do not use the EBDA area or memory between 0xa0000 and the 1MB mark as program/data space. Be aware EBDA is often 1KiB but not always. On legacy BIOS system BDA at 0x413 contains a WORD val representing size in KB from the bottom of memory to the beginning of the EBDA. On many systems that is 639 – Michael Petch Mar 11 '21 at 09:11

1 Answers1

1

Short answer: No.

Long answer: The layout of memory does not change depending on what mode you are in. However, when not in real mode, most of the memory in that region is irrelevant to you, and can be used. However, you must know that a LOT of memory in that region may be IO-mapped, and thus, it is a good idea to load your kernel >1M (2M is the optimal place) and to ignore the first 1M of memory.

Once you implement paging and page allocation, you will want to reserve the first megabyte of memory, thus not allowing it to be allocated.

austanss
  • 271
  • 3
  • 9
  • https://wiki.osdev.org/Memory_Map_(x86) has a more accurate map of what's usable in the low 1MiB. You don't need to reserve the whole 1MiB. You *can* do that on a machine where 1MiB is a drop in the bucket, but if you want there are parts of that space which can be safely used and definitely aren't in the "ISA hole" or used for SMM or whatever else. (And I think there are various interfaces for querying the BIOS about memory regions.) – Peter Cordes Apr 13 '21 at 01:13