display works sortof
[rpikern] / src / rpi.h
1 #ifndef RPI_H_
2 #define RPI_H_
3
4 #include <stdint.h>
5
6
7 #define RPI_MEM_BUS_COHERENT(addr)      (((uint32_t)addr) | 0x40000000)
8 #define RPI_MEM_BUS_UNCACHED(addr)      (((uint32_t)addr) | 0xc0000000)
9
10
11 #define RPI_MBOX_FRAMEBUF       1
12 #define RPI_MBOX_PROP           8
13
14 #define RPI_TAG_GETMODEL        0x010001
15 #define RPI_TAG_GETREV          0x010002
16 #define RPI_TAG_GETRAM          0x010005
17 #define RPI_TAG_GETVRAM         0x010006
18 #define RPI_TAG_SETCLOCK        0x038002
19
20 #define RPI_TAG_ALLOCFB         0x040001
21 #define RPI_TAG_RELEASEFB       0x048001
22 #define RPI_TAG_BLANKSCR        0x040002
23 #define RPI_TAG_SETFBPHYS       0x048003
24 #define RPI_TAG_SETFBVIRT       0x048004
25 #define RPI_TAG_SETFBDEPTH      0x048005
26 #define RPI_TAG_GETFBPITCH      0x040008
27 #define RPI_TAG_SETFBOFFS       0x048009
28 #define RPI_TAG_GETFBOFFS       0x040009
29
30 struct rpi_prop_header {
31         uint32_t size;
32         uint32_t res;
33 };
34
35 struct rpi_prop {
36         uint32_t id, size, res;
37         uint32_t data[1];
38 };
39
40 #define RPI_PROP_NEXT(p) \
41         ((struct rpi_prop*)((char*)((p) + 1) + ((p)->size - sizeof (p)->data)))
42
43 extern int rpi_model;
44 extern uint32_t rpi_iobase;
45 extern uint32_t rpi_mem_base, rpi_mem_size, rpi_vmem_base, rpi_vmem_size;
46
47 void rpi_init(void);
48 void rpi_reboot(void) __attribute__((noreturn));
49
50 void rpi_mbox_send(int chan, uint32_t msg);
51 uint32_t rpi_mbox_recv(int chan);
52 int rpi_mbox_pending(int chan);
53
54 /* usage:
55  * rpi_prop(RPI_TAG_WHATEVER, foo, bar);
56  * rpi_prop(RPI_TAG_XYZZY, 42);
57  * if(rpi_prop_send() != -1) {
58  *     struct rpi_prop *prop;
59  *     while((prop = rpi_prop_next())) {
60  *         ... process response tags ...
61  *     }
62  * }
63  */
64 void rpi_prop(int id, ...);
65 int rpi_prop_send(void);
66 struct rpi_prop *rpi_prop_next(void);
67 /* find specific tag in response */
68 struct rpi_prop *rpi_prop_find(int id);
69
70 #endif  /* RPI_H_ */