Draft: lab 5 failed
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include <mbox.h>
|
||||
|
||||
/* mailbox message buffer */
|
||||
volatile unsigned int __attribute__((aligned(16))) mbox[36];
|
||||
// volatile unsigned int __attribute__((aligned(16))) mbox[36];
|
||||
|
||||
#define VIDEOCORE_MBOX (MMIO_BASE+0x0000B880)
|
||||
#define MBOX_READ ((volatile unsigned int*)(VIDEOCORE_MBOX+0x0))
|
||||
@@ -49,7 +49,7 @@ volatile unsigned int __attribute__((aligned(16))) mbox[36];
|
||||
/**
|
||||
* Make a mailbox call. Returns 0 on failure, non-zero on success
|
||||
*/
|
||||
int mbox_call(unsigned char ch)
|
||||
int mbox_call(unsigned char ch, unsigned int *mbox)
|
||||
{
|
||||
unsigned int r = (((unsigned int)((unsigned long)&mbox)&~0xF) | (ch&0xF));
|
||||
/* wait until we can write to the mailbox */
|
||||
@@ -57,7 +57,7 @@ int mbox_call(unsigned char ch)
|
||||
/* write the address of our message to the mailbox with channel identifier */
|
||||
*MBOX_WRITE = r;
|
||||
/* now wait for the response */
|
||||
while(1) {
|
||||
for (;;) {
|
||||
/* is there a response? */
|
||||
do{asm volatile("nop");}while(*MBOX_STATUS & MBOX_EMPTY);
|
||||
/* is it a response to our message? */
|
||||
@@ -70,6 +70,7 @@ int mbox_call(unsigned char ch)
|
||||
|
||||
unsigned int get_board_revision(void)
|
||||
{
|
||||
unsigned int __attribute__((aligned(16))) mbox[36];
|
||||
mbox[0] = 36 * 4;
|
||||
mbox[1] = MBOX_REQUEST;
|
||||
|
||||
@@ -81,13 +82,14 @@ unsigned int get_board_revision(void)
|
||||
|
||||
mbox[6] = MBOX_TAG_LAST;
|
||||
|
||||
mbox_call(MBOX_CH_PROP);
|
||||
mbox_call(MBOX_CH_PROP, mbox);
|
||||
|
||||
return mbox[5];
|
||||
}
|
||||
|
||||
unsigned int get_memory_base_addr(void)
|
||||
{
|
||||
unsigned int __attribute__((aligned(16))) mbox[36];
|
||||
mbox[0] = 36 * 4;
|
||||
mbox[1] = MBOX_REQUEST;
|
||||
|
||||
@@ -100,13 +102,14 @@ unsigned int get_memory_base_addr(void)
|
||||
|
||||
mbox[7] = MBOX_TAG_LAST;
|
||||
|
||||
mbox_call(MBOX_CH_PROP);
|
||||
mbox_call(MBOX_CH_PROP, mbox);
|
||||
|
||||
return mbox[5];
|
||||
}
|
||||
|
||||
unsigned int get_memory_size(void)
|
||||
{
|
||||
unsigned int __attribute__((aligned(16))) mbox[36];
|
||||
mbox[0] = 36 * 4;
|
||||
mbox[1] = MBOX_REQUEST;
|
||||
|
||||
@@ -119,7 +122,7 @@ unsigned int get_memory_size(void)
|
||||
|
||||
mbox[7] = MBOX_TAG_LAST;
|
||||
|
||||
mbox_call(MBOX_CH_PROP);
|
||||
mbox_call(MBOX_CH_PROP, mbox);
|
||||
|
||||
return mbox[6];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user