78 lines
1.5 KiB
C
Raw Normal View History

#include <cpu.h>
#include <pxi.h>
2017-08-21 21:01:18 -03:00
#include <gic.h>
#include <gpulcd.h>
#include <vram.h>
2017-08-21 21:01:18 -03:00
#include <types.h>
2017-08-21 21:01:18 -03:00
vu32 *entrypoint = (vu32*)0x1FFFFFFC;
2017-07-26 21:39:30 +02:00
2017-08-21 21:01:18 -03:00
void PXI_IRQHandler(void)
2017-07-26 21:39:30 +02:00
{
2017-08-21 21:01:18 -03:00
char pxi_buf[PXI_MAXBUFLEN] = {0};
u32 pxi_args[PXI_FIFO_LEN] = {0};
u8 pxi_cmd;
2017-07-26 21:39:30 +02:00
2017-08-21 21:01:18 -03:00
pxi_cmd = PXI_GetRemote();
switch (pxi_cmd) {
default:
break;
2017-07-26 21:39:30 +02:00
2017-08-21 21:01:18 -03:00
case PXI_BRIGHTNESS:
{
PXI_RecvArray(pxi_args, 1);
PXI_SetRemote(PXI_BUSY);
LCD_SetBrightness(0, pxi_args[0]);
LCD_SetBrightness(1, pxi_args[0]);
break;
}
2017-07-26 21:39:30 +02:00
2017-08-21 21:01:18 -03:00
/* New CMD template:
case CMD_ID:
{
<var declarations/assignments>
<receive args from PXI FIFO>
<if necessary, copy stuff to pxi_buf>
PXI_SetRemote(PXI_BUSY);
<execute the command>
break;
}
2017-08-21 21:01:18 -03:00
*/
}
PXI_SetRemote(PXI_READY);
return;
}
void main(void)
{
2017-08-21 21:01:18 -03:00
u32 entry=0;
PXI_Reset();
2017-07-26 21:39:30 +02:00
2017-08-21 21:01:18 -03:00
GPU_Init();
GPU_PSCFill(VRAM_START, VRAM_END, 0);
GPU_SetFramebuffers((u32[]){VRAM_TOP_LA, VRAM_TOP_LB,
VRAM_TOP_RA, VRAM_TOP_RB,
VRAM_BOT_A, VRAM_BOT_B});
GPU_SetFramebufferMode(0, PDC_RGB24);
GPU_SetFramebufferMode(1, PDC_RGB24);
GIC_Reset();
GIC_SetIRQ(IRQ_PXI_SYNC, PXI_IRQHandler);
PXI_EnableIRQ();
CPU_EnableIRQ();
2017-08-21 21:01:18 -03:00
PXI_SetRemote(PXI_READY);
2017-08-21 21:01:18 -03:00
*entrypoint = 0;
while((entry=*entrypoint) == 0);
CPU_DisableIRQ();
PXI_DisableIRQ();
PXI_Reset();
GIC_Reset();
2017-08-21 21:01:18 -03:00
((void (*)())(entry))();
2017-07-26 21:39:30 +02:00
}