Read/Write x86 Registers

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
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Read/Write x86 Registers

Post by FunnyGuy9796 »

I am currently implementing APIC but have come across a minor issue where I cannot quite figure out how to read or write to registers. I know this is a basic question but I just can't figure it out.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Read/Write x86 Registers

Post by devc1 »

this is how you setup the apic : https://wiki.osdev.org/APIC

after that, you will have the physical lapic address that you can just read/write to like normal RAM.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Read/Write x86 Registers

Post by Octocontrabass »

FunnyGuy9796 wrote:I am currently implementing APIC but have come across a minor issue where I cannot quite figure out how to read or write to registers.
Which registers are you talking about? There are a lot of those!

If you mean the APIC registers, by default they're ordinary MMIO. The ACPI MADT will tell you the address. If you enable x2APIC mode, they're MSRs instead, and you can access them using RDMSR and WRMSR.
Post Reply