2 Copyright © 2013-2019, The AROS Development Team. All rights reserved.
5 Desc: VideoCore mailbox support routines
9 #include <exec/types.h>
10 #include <aros/macros.h>
11 #include <hardware/bcm2708.h>
15 #include <hardware/videocore.h>
23 #define ARM_PERIIOBASE (__arm_periiobase)
24 extern uint32_t __arm_periiobase
;
26 volatile unsigned int *vcmb_read(uintptr_t mb
, unsigned int chan
)
28 unsigned int try = 0x20000000;
31 D(kprintf("[VCMB] vcmb_read(%p, %p)\n", mb
, chan
));
33 if (chan
<= VCMB_CHAN_MAX
)
37 while ((rd32le(mb
+ VCMB_STATUS
) & VCMB_STATUS_READREADY
) != 0)
39 /* Data synchronization barrier */
40 asm volatile ("mcr p15, 0, %[r], c7, c10, 4" : : [r
] "r" (0) );
48 asm volatile ("mcr p15, #0, %[r], c7, c10, #5" : : [r
] "r" (0) );
50 msg
= rd32le(mb
+ VCMB_READ
);
51 D(kprintf("[VCMB] -> %p\n", msg
));
53 asm volatile ("mcr p15, #0, %[r], c7, c10, #5" : : [r
] "r" (0) );
55 if ((msg
& VCMB_CHAN_MASK
) == chan
)
56 return (volatile unsigned int *)(msg
& ~VCMB_CHAN_MASK
);
59 return (volatile unsigned int *)-1;
62 void vcmb_write(uintptr_t mb
, unsigned int chan
, void *msg
)
64 D(kprintf("[VCMB] vcmb_write(%p, %p, %p)\n", mb
, chan
, msg
));
66 if ((((unsigned int)msg
& VCMB_CHAN_MASK
) == 0) && (chan
<= VCMB_CHAN_MAX
))
68 while ((rd32le(mb
+ VCMB_STATUS
) & VCMB_STATUS_WRITEREADY
) != 0)
70 /* Data synchronization barrier */
71 asm volatile ("mcr p15, 0, %[r], c7, c10, 4" : : [r
] "r" (0) );
74 asm volatile ("mcr p15, #0, %[r], c7, c10, #5" : : [r
] "r" (0) );
76 wr32le(mb
+ VCMB_WRITE
, (uintptr_t)msg
| chan
);