|
Nugget
Bare-metal libraries and examples for the original PlayStation
|
#include <stdint.h>#include "common/hardware/dma.h"#include "common/hardware/hwregs.h"#include "common/syscalls/syscalls.h"#include "exotic/cester.h"
Macros | |
| #define | PCSX_TESTS 0 |
| #define | CESTER_MAYBE_TEST CESTER_TEST |
| #define | CESTER_NO_SIGNAL |
| #define | CESTER_NO_TIME |
| #define | EXIT_SUCCESS 0 |
| #define | EXIT_FAILURE 1 |
| #define | R32(a) (*(volatile uint32_t *)(a)) |
| #define | D2_MADR R32(0xbf8010a0) |
| #define | D2_BCR R32(0xbf8010a4) |
| #define | D2_CHCR R32(0xbf8010a8) |
| #define | D2_DPCR R32(0xbf8010f0) |
| #define | D2_DICR R32(0xbf8010f4) |
| #define | VBLANKS 5 |
Functions | |
| CESTER_BODY (#define R32(a) #define D2_MADR #define D2_BCR #define D2_CHCR #define D2_DPCR #define D2_DICR #define VBLANKS static uint32_t s_nodeA[2] __attribute__((aligned(16)));static uint32_t s_nodeB[2] __attribute__((aligned(16)));struct Run { uint32_t chcr[VBLANKS+1];uint32_t madr[VBLANKS+1];uint32_t dicr[VBLANKS+1];uint32_t chcrAfterStop;unsigned madrChanges;};static struct Run s_term, s_loop0, s_loop1;static int s_interruptsWereEnabled;static void run(struct Run *r, unsigned words, int terminated) { GPU_STATUS=0x00000000;GPU_STATUS=0x04000002;uint32_t a=(uint32_t) s_nodeA &0xffffff, b=(uint32_t) s_nodeB &0xffffff;s_nodeA[0]=(words<< 24)|b;s_nodeA[1]=0;s_nodeB[0]=(words<< 24)|(terminated ? 0xffffff :a);s_nodeB[1]=0;D2_DPCR|=0x00000800;D2_MADR=a;D2_BCR=0;D2_CHCR=0x01000401;r->chcr[0]=D2_CHCR;r->madr[0]=D2_MADR;r->dicr[0]=D2_DICR;r->madrChanges=0;uint32_t last=r->madr[0];for(int v=1;v<=VBLANKS;v++) { IREG=~1u;while(!(IREG &1)) { uint32_t m=D2_MADR;if(m !=last) { r->madrChanges++;last=m;} } r->chcr[v]=D2_CHCR;r->madr[v]=D2_MADR;r->dicr[v]=D2_DICR;} D2_CHCR=0x00000401;r->chcrAfterStop=D2_CHCR;ramsyscall_printf("words=%d terminated=%d chcr0=%08x chcr5=%08x madr0=%08x madr5=%08x dicr5=%08x changes=%d stop=%08x\n", words, terminated, r->chcr[0], r->chcr[VBLANKS], r->madr[0], r->madr[VBLANKS], r->dicr[VBLANKS], r->madrChanges, r->chcrAfterStop);}) CESTER_BEFORE_ALL(gpudmaloop | |
| CESTER_AFTER_ALL (CESTER_TEST(gpudmaloop, GPU_STATUS=0x00000000;if(s_interruptsWereEnabled) leaveCriticalSection();) | |
Variables | |
| s_interruptsWereEnabled = enterCriticalSection() | |
| IMASK = 0 | |
| run & | s_term |
| run & | s_loop0 |
| run & | s_loop1 |
| #define CESTER_MAYBE_TEST CESTER_TEST |
| #define CESTER_NO_SIGNAL |
| #define CESTER_NO_TIME |
| #define D2_BCR R32(0xbf8010a4) |
| #define D2_CHCR R32(0xbf8010a8) |
| #define D2_DICR R32(0xbf8010f4) |
| #define D2_DPCR R32(0xbf8010f0) |
| #define D2_MADR R32(0xbf8010a0) |
| #define EXIT_FAILURE 1 |
| #define EXIT_SUCCESS 0 |
| #define PCSX_TESTS 0 |
| #define R32 | ( | a | ) | (*(volatile uint32_t *)(a)) |
| #define VBLANKS 5 |
| CESTER_AFTER_ALL | ( | CESTER_TEST( | gpudmaloop, |
| GPU_STATUS | = 0x00000000; if (s_interruptsWereEnabled) leaveCriticalSection(); |
||
| ) |
| CESTER_BODY | ( | #define R32(a) #define D2_MADR #define D2_BCR #define D2_CHCR #define D2_DPCR #define D2_DICR #define VBLANKS static uint32_t s_nodeA __attribute__((aligned(16)));static uint32_t s_nodeB __attribute__((aligned(16)));struct Run { uint32_t chcr[VBLANKS+1];uint32_t madr[VBLANKS+1];uint32_t dicr[VBLANKS+1];uint32_t chcrAfterStop;unsigned madrChanges;};static struct Run | s_term[2][2], |
| s_loop0 | , | ||
| s_loop1;static int s_interruptsWereEnabled;static void run(struct Run *r, unsigned words, int terminated) { GPU_STATUS=0x00000000;GPU_STATUS=0x04000002;uint32_t a=(uint32_t) s_nodeA &0xffffff, b=(uint32_t) s_nodeB &0xffffff;s_nodeA[0]=(words<< 24)|b;s_nodeA[1]=0;s_nodeB[0]=(words<< 24)|(terminated ? 0xffffff :a);s_nodeB[1]=0;D2_DPCR|=0x00000800;D2_MADR=a;D2_BCR=0;D2_CHCR=0x01000401;r->chcr[0]=D2_CHCR;r->madr[0]=D2_MADR;r->dicr[0]=D2_DICR;r->madrChanges=0;uint32_t last=r->madr[0];for(int v=1;v<=VBLANKS;v++) { IREG=~1u;while(!(IREG &1)) { uint32_t m=D2_MADR;if(m !=last) { r->madrChanges++;last=m;} } r->chcr[v]=D2_CHCR;r->madr[v]=D2_MADR;r->dicr[v]=D2_DICR;} D2_CHCR=0x00000401;r->chcrAfterStop=D2_CHCR;ramsyscall_printf("words=%d terminated=%d chcr0=%08x chcr5=%08x madr0=%08x madr5=%08x dicr5=%08x changes=%d stop=%08x\n", words, terminated, r->chcr[0], r->chcr[VBLANKS], r->madr[0], r->madr[VBLANKS], r->dicr[VBLANKS], r->madrChanges, r->chcrAfterStop);} | |||
| ) |
| IMASK = 0 |
| s_interruptsWereEnabled = enterCriticalSection() |
| run& s_loop0 |
| run& s_loop1 |
| run& s_term |