[Solved]Load trampoline code
Posted: Tue Aug 28, 2012 9:50 pm
I decided to try to make my OS support more than one processor. So I started reading the Intel manuals and some doubts appeared along the way.
As far as I could understand, at some point I'll have to send a SIPI from the BSP to the APs with the vector value "pointing" to the trampoline code, in order to set the GDT and switch the AP to pmode. If I understood correctly, when I send the SIPI, I must set the vector value, so the AP will execute the code located at the physical addres 000V V000H (where VV is the 8-bit vector value).
Because the APs are in real mode, I believe the trampoline code must be below the 1mb mark. But I can't load code under the 1mb mark using GRUB. So I'm thinking of a way to accomplish that.
I thought I could create the trampoline code, and use a linker script to generate a raw binary executable under the 1mb mark. Then I could load it as a GRUB module to a random position, and then move it (the entire module) to the 1mb below mark. Once the code was linked to run under this mark, it should work.
But I'm not pretty sure it will work. So I wonder if there's a better way to do it.
As far as I could understand, at some point I'll have to send a SIPI from the BSP to the APs with the vector value "pointing" to the trampoline code, in order to set the GDT and switch the AP to pmode. If I understood correctly, when I send the SIPI, I must set the vector value, so the AP will execute the code located at the physical addres 000V V000H (where VV is the 8-bit vector value).
Because the APs are in real mode, I believe the trampoline code must be below the 1mb mark. But I can't load code under the 1mb mark using GRUB. So I'm thinking of a way to accomplish that.
I thought I could create the trampoline code, and use a linker script to generate a raw binary executable under the 1mb mark. Then I could load it as a GRUB module to a random position, and then move it (the entire module) to the 1mb below mark. Once the code was linked to run under this mark, it should work.
But I'm not pretty sure it will work. So I wonder if there's a better way to do it.