Raspberry Pi GPU 编程

要把我的操作系统移植到Raspberry Pi 上了,所以最近一直在看ARM的东西。找来找去只找到一个有点用的 http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ 剑桥大学的一份教程,虽然离一个完整的内核还差得很远,但对我还算是有点用。之前一直担心的GPU的问题也解决了,也是我找到的唯一一份和Raspberry Pi GPU编程相关的东西了。

这次用到的是 2bit的 High Color — Use 16 bits to store each pixel, the first 5 bit representing the intensity of the red channel, the next 6 bits representing the intensity of the green channel and the final 5 bits representing the intensity of the blue channel

<!– [if IE 6]>

<link rel="stylesheet" href="../../../../style/ie6.css" type="text/css" media="screen" /><script type="text/javascript" src="http://www.cam.ac.uk/global/js/minmax.js"></script><![endif]--><!-- [if IE 7]>
<link rel="stylesheet" href="../../../../style/ie7.css" type="text/css" media="screen" /><![endif]--><script src="//www.google-analytics.com/analytics.js" async=""></script><script src="script.js" type="text/javascript" language="javascript"></script><script>// <![CDATA[

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);
ga(‘create’, ‘UA-47341509-1’, ‘cam.ac.uk’);
ga(‘send’, ‘pageview’);
// ]]>

这么奇怪的启动方式。加电后GPU先启动,然后 ARM核才启动,两个处理器通过“邮件”的方式通信,详见

The Raspberry Pi has a very special and rather odd relationship with it’s graphics processor. On the Raspberry Pi, the graphics processor actually runs first, and is responsible for starting up the main processor. This is very unusual. Ultimately it doesn’t make too much difference, but in many interactions, it often feels like the processor is secondary, and the graphics processor is the most important. The two communicate on the Raspberry Pi by what is called the ‘mailbox’. Each can deposit mail for the other, which will be collected at some future point and then dealt with. We shall use the mailbox to ask the graphics processor for an address. The address will be a location to which we can write the pixel colour information for the screen, called a frame buffer, and the graphics card will regularly check this location, and update the pixels on the screen appropriately.

<!– [if IE 6]>

<link rel="stylesheet" href="../../../../style/ie6.css" type="text/css" media="screen" /><script type="text/javascript" src="http://www.cam.ac.uk/global/js/minmax.js"></script><![endif]--><!-- [if IE 7]>
<link rel="stylesheet" href="../../../../style/ie7.css" type="text/css" media="screen" /><![endif]--><script src="//www.google-analytics.com/analytics.js" async="" type="mce-no/type"></script><script src="script.js" type="mce-text/javascript" language="javascript"></script><script type="mce-no/type">// <![CDATA[

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);
ga(‘create’, ‘UA-47341509-1’, ‘cam.ac.uk’);
ga(‘send’, ‘pageview’);
// ]]>

Table - Mailbox Addresses

Address

Size / Bytes

Name

Description

Read / Write

2000B880

4

Read

Receiving mail.

R

2000B890

4

Poll

Receive without retrieving.

R

2000B894

4

Sender

Sender information.

R

2000B898

4

Status

Information.

R

2000B89C

4

Configuration

Settings.

RW

2000B8A0

4

Write

Sending mail.

W



 

发送:

  1. The sender waits until the Status field has a 0 in the top bit.
  2. The sender writes to Write such that the lowest 4 bits are the mailbox to write to, and the upper 28 bits are the message to write.
    接收:

  3. The receiver waits until the Status field has a 0 in the 30th bit.

  4. The receiver reads from Read.
  5. The receiver confirms the message is for the correct mailbox, and tries again if not.



















<!– [if IE 6]>

<![endif]–>