Lab2: Mailbox
CPU透過呼叫VideoCoreIV(GPU) routine來設定peripheral像是clock rate及framebuffer,Mailbox充當CPU和VideoCoreIV之間的橋。
目標:用Mailbox
- 取得board revision及VC Core base address
- 設定UART clock,並取代PL011 UART為mini UART
- 設定framebuffer,啟動時顯示splash image
Accessing Mailbox
參考Raspberry pi官方文件及mbox.c取得詳細流程。
Write
- Read the status register until the full flag is not set
- Write the data (shifted into the upper 28 bits) combined with the channel (in the lower four bits) to the write register
因為4 bit作為channel number用,作為傳遞的地址必須對齊16bytes。
Read
- Read the status register until the empty flag is not set
- Read data from the read register
- If the lower four bits do not match the channel number desired then repeat from 1
除了property channel外,傳遞address需考慮到VC看到的bus address。
With the exception of the property tags mailbox channel, when passing memory addresses as the data part of a mailbox message, the addresses should be bus addresses as seen from the VC.
mbox.c
1 | int mbox_call(unsigned char ch) { |
Get Board revision及Get Board revision使用channel 8進行操作
- Channel 8: Request from ARM for response by VC
- Channel 9: Request from VC for response by ARM (none currently defined)
Ref: Mailbox property interface
Get Board revision
1 | void get_board_revision() { |
Get VC Core Base Address
1 | void get_vc_mem() { |