Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern unsigned int GET32(unsigned int);
- extern void PUT32(unsigned int, unsigned int);
- #include "gpio.h"
- #include "timer.h"
- #define MAILBOX_FULL 0x80000000
- #define MAILBOX_EMPTY 0x40000000
- #define MAILBOX0READ 0x2000b880
- #define MAILBOX0STATUS 0x2000b898
- #define MAILBOX0WRITE 0x2000b8a0
- int cmain(void)
- {
- LedInit();
- // 1. Fill out the FB request
- volatile unsigned int fbInfo[256] __attribute__ ((aligned (16)));
- fbInfo[0] = 1024; // Physical Width
- fbInfo[1] = 768; // Physical Height
- fbInfo[2] = 1024; // Virtual Width
- fbInfo[3] = 768; // Virtual Height
- fbInfo[4] = 0; // Pitch (will be filled in my GPU)
- fbInfo[5] = 16; // Depth
- fbInfo[6] = 0; // X offset
- fbInfo[7] = 0; // Y offset
- fbInfo[8] = 0; // FB pointer (will be filled in my GPU)
- fbInfo[9] = 0; // FB Size (will be filled in my GPU)
- // 2. Send struct to GPU
- while(GET32(MAILBOX0STATUS) & MAILBOX_FULL){ } // Wait for mailbox to become available
- PUT32(MAILBOX0WRITE, (((unsigned int)&fbInfo + 0x40000000) << 4) | 1); // Offset struct addr to prevent caching
- // 3. Read Response
- unsigned int data = 0;
- while(1)
- {
- while(GET32(MAILBOX0STATUS) & MAILBOX_EMPTY){} // Wait for mail
- data = GET32(MAILBOX0READ);
- if((data &0xF) == 1) // Data on channel 1
- {
- data = data >> 4;
- break;
- }
- }
- // 4. Check if we got a valid FB response
- if(fbInfo[8] == 0)
- {
- LedOn(); // We did not get a pointer :-(
- while(1);
- }
- else
- {
- while(1)
- {
- LedOff(); // All is well
- Wait(1);
- LedOn();
- Wait(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement