PeterLemon / RaspberryPi

Raspberry Pi Bare Metal Assembly Programming
447 stars 67 forks source link

Mailbox Usage #16

Open quantumdude836 opened 6 years ago

quantumdude836 commented 6 years ago

Many of your examples make use of the TAGS channel of the mailbox interface. In particular, you set up the framebuffer in a FB_Init loop. While this does work, this is not technically correct.

The issue is that you don't properly wait for a response from the VC to indicate it's finished processing the tags list (and thus written the response). This is why immediately reading the FB_POINTER field yields zero, as the VC hasn't finished processing.

The correct mailbox usage is to write the structure address + channel to the mailbox, then enter a loop waiting for the MAIL_EMPTY bit (bit 30) of the status register (offset 0x18) to be clear. Then, read from the read register (offset 0) to clear the mailbox. At this point, the VC has fully processed the tags list and written the response. This should eliminate the need for the FB_Init loop.

PeterLemon commented 5 years ago

Hi quantumdude836,

Sorry for the very late reply :(

Thanks so much for pointing this out to me, as I will be doing some more work on the R-Pi soon, I will make sure to check this out & fix it in my demos. Thanks for the help with this =D