[PATCH 1/3] Mailbox : Adding functionality to get board serial

Mudit Jain muditjain18011995 at gmail.com
Sat Aug 20 13:25:07 UTC 2016


From: Mudit Jain <muditj at nvidia.com>

---
 c/src/lib/libbsp/arm/raspberrypi/include/vc.h      |  7 +++++++
 c/src/lib/libbsp/arm/raspberrypi/misc/vc.c         | 24 ++++++++++++++++++++++
 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 11 ++++++++++
 3 files changed, 42 insertions(+)

diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
index 00414ff..d3408f9 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
@@ -135,6 +135,13 @@ int bcm2835_mailbox_get_board_model( bcm2835_get_board_spec_entries *_entries );
 
 int bcm2835_mailbox_get_board_revision(
   bcm2835_get_board_spec_entries *_entries );
+
+typedef struct {
+  uint64_t board_serial;
+} bcm2835_get_board_serial_entries;
+
+int bcm2835_mailbox_get_board_serial(
+  bcm2835_get_board_serial_entries *_entries );
 /** @} */
 
 #endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
index 0bec0c2..53ac1e8 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
@@ -398,3 +398,27 @@ int bcm2835_mailbox_get_board_revision(
 
   return 0;
 }
+
+int bcm2835_mailbox_get_board_serial(
+  bcm2835_get_board_serial_entries *_entries )
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_get_board_serial get_board_serial;
+    uint32_t end_tag;
+  } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE;
+  BCM2835_MBOX_INIT_BUF( &buffer );
+  BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_serial,
+    BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL );
+  bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
+
+  if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
+    return -1;
+
+  _entries->board_serial = buffer.get_board_serial.body.resp.board_serial;
+
+  if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
+    return -2;
+
+  return 0;
+}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
index 8d1067b..516f8f4 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
@@ -179,6 +179,17 @@ typedef struct {
 
 #define BCM2835_MAILBOX_TAG_GET_BOARD_MAC       0x00010003
 #define BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL    0x00010004
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+    } req;
+    struct {
+      uint64_t board_serial;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_get_board_serial;
+
 #define BCM2835_MAILBOX_TAG_GET_ARM_MEMORY      0x00010005
 typedef struct {
   bcm2835_mbox_tag_hdr tag_hdr;
-- 
1.9.1



More information about the devel mailing list