SMP Cache Cogerency and More understanding of interrupts
Posted: Sat Nov 29, 2014 4:35 am
Hi,
I have a hobby OS that I am experimenting with. I have followed James Molly tutorial as a guide.
I was able to reach the following:
Boot from my custom boot loader.
Switch to long mode directly, following the OSDev tutorial.
Setup a video driver
Mapping the whole memory using Page Map Level 4
Configure PIC and plug in service routines for PIT and RTC
Till here everything is working fine. I decided to start working on SMP. I was able to parse the APIC data strucutre, and start the APs either through broadcast of one by one.
Now, I started to focus on booting up one core to be able to test with.
I was able to initiate IIPI and SIPI successfully to boot up a core AP. I was also able to jump to my normal code that I have booted the BSP with, and reach my C Kernel main function. I was also able to point the new AP CR3 to the PML4 initialized by the BSP.
I have reserved a page of memory at address 0xA000 as a memory area which I can exchange data between the two cores. My problem is that whatever I write at memory location 0xA000 with the AP second core cannot be seen by the BSP. The BSP always see the old values, and the AP sees the new values it wrote.
My second question is that, at this point of time the PIC is enabled and is firing interrupts to the BSP. I read on OSDev that I should disable PIC and enable APIC! Why do I have to disable it? And if I disable it where should I connect the interrupt service routines? This is kind of vague to me and I don't have a clear understanding on how to continue from where I am right now.
Kindly, if you can point out any possible actions that I can take or investigate to solve my first problem that will be greate. Also I appreciate if any one can explain to me how to disable PIC and enable APIC and move my already existing service toutines to the APIC.
Thanks,
Karim.
I have a hobby OS that I am experimenting with. I have followed James Molly tutorial as a guide.
I was able to reach the following:
Boot from my custom boot loader.
Switch to long mode directly, following the OSDev tutorial.
Setup a video driver
Mapping the whole memory using Page Map Level 4
Configure PIC and plug in service routines for PIT and RTC
Till here everything is working fine. I decided to start working on SMP. I was able to parse the APIC data strucutre, and start the APs either through broadcast of one by one.
Now, I started to focus on booting up one core to be able to test with.
I was able to initiate IIPI and SIPI successfully to boot up a core AP. I was also able to jump to my normal code that I have booted the BSP with, and reach my C Kernel main function. I was also able to point the new AP CR3 to the PML4 initialized by the BSP.
I have reserved a page of memory at address 0xA000 as a memory area which I can exchange data between the two cores. My problem is that whatever I write at memory location 0xA000 with the AP second core cannot be seen by the BSP. The BSP always see the old values, and the AP sees the new values it wrote.
My second question is that, at this point of time the PIC is enabled and is firing interrupts to the BSP. I read on OSDev that I should disable PIC and enable APIC! Why do I have to disable it? And if I disable it where should I connect the interrupt service routines? This is kind of vague to me and I don't have a clear understanding on how to continue from where I am right now.
Kindly, if you can point out any possible actions that I can take or investigate to solve my first problem that will be greate. Also I appreciate if any one can explain to me how to disable PIC and enable APIC and move my already existing service toutines to the APIC.
Thanks,
Karim.