-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ac8a68
commit 57f7871
Showing
8 changed files
with
139 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
TOPTARGETS = build clean | ||
|
||
IMAGES = common \ | ||
cpu/code-in-scratchpad \ | ||
gpu/bandwidth \ | ||
gpu/benchmark \ | ||
gpu/quad \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
TARGET = code-in-scratchpad.elf | ||
|
||
include ../../common-test.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
|
||
void FlushCache(); | ||
uint32_t codeRam(); | ||
uint32_t codeScratchpad(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <asm.h> | ||
#include <inline_s.h> | ||
|
||
.extern FlushCache | ||
FlushCache: | ||
li $t1, 0x44 | ||
li $t2, 0xa0 | ||
jr $t2 | ||
nop | ||
|
||
getPc: | ||
move $v0, $ra | ||
jr $ra | ||
nop | ||
|
||
.globl codeRam | ||
codeRam: | ||
addiu $sp, -4 | ||
sw $ra, 0($sp) | ||
|
||
la $t0, getPc | ||
jalr $ra, $t0 # Get PC | ||
nop | ||
|
||
lw $ra, 0($sp) | ||
addiu $sp, 4 | ||
jr $ra | ||
nop | ||
|
||
.globl codeScratchpad | ||
codeScratchpad: | ||
addiu $sp, -4 | ||
sw $ra, 0($sp) | ||
|
||
la $t0, getPc | ||
jalr $ra, $t0 # Get PC | ||
nop | ||
|
||
lw $ra, 0($sp) | ||
addiu $sp, 4 | ||
jr $ra | ||
nop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <common.h> | ||
#include <psxapi.h> | ||
#include <string.h> | ||
#include "code.h" | ||
|
||
uint32_t RAM_FUN_ADDR = 0x00040000; | ||
uint32_t SCRATCHPAD_FUN_ADDR = 0x1F800000; | ||
|
||
typedef uint32_t (*func)(); | ||
|
||
// TODO: This test is not fully finished | ||
// It is only for testing whether PS1 can execute code from Scratchpad | ||
|
||
int main() { | ||
initVideo(320, 240); | ||
printf("\ncpu/code-in-scratchpad\n"); | ||
|
||
clearScreen(); | ||
|
||
EnterCriticalSection(); | ||
|
||
memcpy((void*)RAM_FUN_ADDR, codeRam, 64); | ||
memcpy((void*)SCRATCHPAD_FUN_ADDR, codeScratchpad, 64); | ||
|
||
FlushCache(); | ||
|
||
func codeInRam = (func)RAM_FUN_ADDR; | ||
func codeInScratchpad = (func)SCRATCHPAD_FUN_ADDR; | ||
|
||
printf("Code in ram returned PC: 0x%08x\n", codeInRam()); | ||
printf("Code in scratchpad returned PC: 0x%08x\n", codeInScratchpad()); | ||
// ^^^ This line crashes on real HW | ||
|
||
printf("Done\n"); | ||
|
||
ExitCriticalSection(); | ||
for (;;) { | ||
VSync(0); | ||
} | ||
return 0; | ||
} |