Page 1 of 1

What defines the 32 CPU interrupt logic?

Posted: Sat Dec 12, 2020 12:47 pm
by itarato
Apology for noob question. I'm following an OS from scratch tutorial and got to the point of memory management: https://wiki.osdev.org/Detecting_Memory_(x86) I want to know my available and detected memory space. The page explains using INT 0x12 or INT 0x15.
My confusion is around these interrupts. In an earlier phase I defined the base 32 CPU interrupts as explained in https://wiki.osdev.org/Interrupt_Descriptor_Table - including 0x12 and 0x15. Now obviously calling INT 0x12 or the other will go to my routines.

In case of memory detection (INT 0x12) - am I correct that it's my responsibility to write the code that detects the memory and sets the size in AX? Which would leave me a question - how do I really detect the memory?

Re: What defines the 32 CPU interrupt logic?

Posted: Sat Dec 12, 2020 4:14 pm
by Gigasoft
What? No. You have to call the function provided by the BIOS, in real mode. It just happens that BIOS software interrupt numbers overlap with exception numbers, since these exceptions did not exist on the 8086 used in early PCs.

Re: What defines the 32 CPU interrupt logic?

Posted: Sat Dec 12, 2020 4:27 pm
by PeterX
If you have to deal with a Legacy BIOS PC, you detect memory by using the mentioned BIOS interrupts in the real mode part of the bootloader. Then you hand over the memory "table" to the protected mode kernel. The interrupts in the protected mode kernel are unrelated to the BIOS interrupts.

If you have to deal with an UEFI PC, you repeatedly use the UEFI function GetMemoryMap() to detect memory usage.

Greetings
Peter

Re: What defines the 32 CPU interrupt logic?

Posted: Sun Dec 13, 2020 12:41 am
by itarato
Gigasoft wrote:What? No. You have to call the function provided by the BIOS, in real mode. It just happens that BIOS software interrupt numbers overlap with exception numbers, since these exceptions did not exist on the 8086 used in early PCs.
Aaaah. Just tried it and it looks promising. Much appreciated. Also the explanation makes sense, much appreciated!