<html><body><div>-----<br><br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>index c6133df..70bc01d 100644<br>--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>@@ -43,6 +43,7 @@ include_bsp_HEADERS += ../shared/include/arm-release-id.h<br> include_bsp_HEADERS += include/irq.h<br> include_bsp_HEADERS += include/mmu.h<br> include_bsp_HEADERS += include/usart.h<br>+include_bsp_HEADERS += include/mailbox.h<br> include_bsp_HEADERS += include/raspberrypi.h<br> <br> include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \<br>@@ -123,6 +124,9 @@ libbsp_a_SOURCES += misc/timer.c<br> <br> # I2C<br> <br>+# Mailbox<br>+libbsp_a_SOURCES += misc/mailbox.c<br>+<br> # Cache<br> libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c<br> libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h<br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h b/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h<br>new file mode 100644<br>index 0000000..abdb258<br>--- /dev/null<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h<br>@@ -0,0 +1,7 @@<br>+#ifndef MAILBOX_H<br>+#define MAILBOX_H<br>+<br>+extern unsigned int readmailbox(unsigned int channel);<br>+extern void writemailbox(unsigned int channel, unsigned int data);<br>+<br>+#endif /* MAILBOX_H */<br>\ No newline at end of file<br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h<br>index c33e22a..e4ce18f 100644<br>--- a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h<br>@@ -208,6 +208,52 @@<br> <br> /** @} */<br> <br>+ /**<br>+ * @name Mailbox Registers<br>+ *<br>+ * @{<br>+ */<br>+<br>+/**<br>+ * NOTE: <br>+ */<br>+#define BCM2835_MBOX_BASE (RPI_PERIPHERAL_BASE+0xB880)<br>+<br>+#define BCM2835_MBOX_PEEK (BCM2835_MBOX_BASE+0x10)<br>+#define BCM2835_MBOX_READ (BCM2835_MBOX_BASE+0x00)<br>+#define BCM2835_MBOX_WRITE (BCM2835_MBOX_BASE+0x20)<br>+#define BCM2835_MBOX_STATUS (BCM2835_MBOX_BASE+0x18)<br>+#define BCM2835_MBOX_SENDER (BCM2835_MBOX_BASE+0x14)<br>+#define BCM2835_MBOX_CONFIG (BCM2835_MBOX_BASE+0x1C)<br>+<br>+/* Power Manager channel */<br>+#define BCM2835_MBOX_CHANNEL_PM 0<br>+/* Framebuffer channel */<br>+#define BCM2835_MBOX_CHANNEL_FB 1<br>+ /* Virtual UART channel */<br>+#define BCM2835_MBOX_CHANNEL_VUART 2<br>+ /* VCHIQ channel */<br>+#define BCM2835_MBOX_CHANNEL_VCHIQ 3<br>+ /* LEDs channel */<br>+#define BCM2835_MBOX_CHANNEL_LED 4<br>+ /* Button channel */<br>+#define BCM2835_MBOX_CHANNEL_BUTTON 5<br>+ /* Touch screen channel */<br>+#define BCM2835_MBOX_CHANNEL_TOUCHS 6<br>+/* Property tags (ARM <-> Video Core) channel */<br>+#define BCM2835_MBOX_CHANNEL_PROP_AVC 8<br>+ /* Property tags (Video Core <-> ARM) channel */<br>+#define BCM2835_MBOX_CHANNEL_PROP_VCA 9<br>+<br>+#define BCM2835_MBOX_SUCCESS (BCM2835_MBOX_BASE+0x80000000)<br>+<br>+#define BCM2835_MBOX_FULL (BCM2835_MBOX_BASE+0x80000000)<br>+#define BCM2835_MBOX_EMPTY (BCM2835_MBOX_BASE+0x40000000)<br>+<br>+<br>+<br>+/** @} */<br>+<br> <br> /** @} */<br> <br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c<br>new file mode 100644<br>index 0000000..7bfb7e3<br>--- /dev/null<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c<br>@@ -0,0 +1,22 @@<br>+#include <stdint.h><br>+#include <bsp/raspberrypi.h><br>+#include <bsp/mailbox.h><br>+unsigned int readmailbox ( unsigned int channel )<br>+{<br>+ unsigned int data;<br>+ unsigned int read_channel;<br>+<br>+ while ( 1 )<br>+ {<br>+ while ( BCM2835_REG ( BCM2835_MBOX_STATUS ) & BCM2835_MBOX_EMPTY );<br>+ data = BCM2835_REG ( BCM2835_MBOX_READ );<br>+ read_channel = ( unsigned int ) ( data & 0xF );<br>+ if ( read_channel == channel )<br>+ return ( data & 0xFFFFFFF0 );<br>+ }<br>+}<br>+void writemailbox( unsigned int channel, unsigned int data )<br>+{<br>+ while ( BCM2835_REG ( BCM2835_MBOX_STATUS ) & BCM2835_MBOX_FULL );<br>+ BCM2835_REG (BCM2835_MBOX_WRITE) = ( data & 0xFFFFFFF0 ) | (unsigned int) ( channel & 0xF );<br>+}<br>\ No newline at end of file<br>diff --git a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am<br>index 70259e2..4cb7ed6 100644<br>--- a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am<br>+++ b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am<br>@@ -126,6 +126,10 @@ $(PROJECT_INCLUDE)/bsp/usart.h: include/usart.h $(PROJECT_INCLUDE)/bsp/$(dirstam<br> $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/usart.h<br> PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/usart.h<br> <br>+$(PROJECT_INCLUDE)/bsp/mailbox.h: include/mailbox.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)<br>+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mailbox.h<br>+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mailbox.h<br>+<br> $(PROJECT_INCLUDE)/bsp/raspberrypi.h: include/raspberrypi.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)<br> $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/raspberrypi.h<br> PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/raspberrypi.h<br><br><br>-----<br><br>Here is a patch for rpi bsp which include the operation and chanel defininitions for mailbox and its implementations.<br><br>I've only tested the framebuffer with it and it works well : set the screen size and get the informations.<br>Andre used it for sd card reading. I've checked it out and added full channel definitions.<br>Please point it out if further tests should be done.<br><br>YANG QIAO<br></div></body></html>