-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfb.h
More file actions
59 lines (44 loc) · 1.6 KB
/
fb.h
File metadata and controls
59 lines (44 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef FRAMEBUFFER_H
#define FRAMEBUFFER_H
#include "types.h"
/*
* Explication des adresses, offsets, channels, etc: http://elinux.org/RPi_Framebuffer
* Intro au framebuffer: http://magicsmoke.co.za/?p=284
*/
/*
* Mailbox functions
*/
enum {
MAILBOX_BASE = 0x2000B880,
MAILBOX_POLL = 0x2000B890, // Receive without retrieving. R
MAILBOX_SENDER = 0x2000B894, // Sender information. R
MAILBOX_STATUS = 0x2000B898, // Information. R
MAILBOX_CONFIGURATION = 0x2000B89C, // Settings. RW
MAILBOX_WRITE = 0x2000B8A0 // Sending mail. W
};
void MailboxWrite(uint32 message, uint32 mailbox);
uint32 MailboxRead(uint32 mailbox);
#define data_mem_barrier() __asm__ __volatile__ ("mcr p15, 0, %[reg], c7, c10, 5"::[reg] "r" (0))
#define data_sync_barrier() __asm__ __volatile__ ("mcr p15, 0, %[reg], c7, c10, 4"::[reg] "r" (0))
// fonction pour écrire un message data dans une mailbox suivant un des mode de l'enum si dessus
static inline void mmio_write(uint32 reg, uint32 data) {
uint32 *ptr = (uint32*)reg;
__asm__ volatile("str %[data], [%[reg]]"
: : [reg]"r"(ptr), [data]"r"(data));
}
// fonction pour lire un message data dans une mailbox suivant un des mode de l'enum si dessus
static inline uint32 mmio_read(uint32 reg) {
uint32 *ptr = (uint32*)reg;
uint32 data;
__asm__ volatile("ldr %[data], [%[reg]]"
: [data]"=r"(data) : [reg]"r"(ptr));
return data;
}
/*
* Framebuffer functions
*/
int FramebufferInitialize();
void draw();
void drawRed();
void drawBlue();
#endif