Skip to content

add an IO Port to get the host clock value#792

Open
bigianb wants to merge 1 commit into
jpd002:masterfrom
bigianb:clock
Open

add an IO Port to get the host clock value#792
bigianb wants to merge 1 commit into
jpd002:masterfrom
bigianb:clock

Conversation

@bigianb

@bigianb bigianb commented Aug 30, 2019

Copy link
Copy Markdown
Contributor

Something like this would allow us to profile test scripts without needing to use the CD clock hack (that is a bit useless in any case from the EE as it goes via an RPC channel which takes an indeterminate amount of time)

Note ... just for discussion at the moment. Not even tested and would need something similar on the IOP side too.

@jpd002

jpd002 commented Sep 12, 2019

Copy link
Copy Markdown
Owner

Looking good! Did you test it with an executable generated from PS2SDK?

@bigianb

bigianb commented Sep 12, 2019

Copy link
Copy Markdown
Contributor Author

Looking good! Did you test it with an executable generated from PS2SDK?

yes ... but it's a very trivial test and so not in github yet. Just a POC really. It writes to stdout so the result is in the log file.

#include <tamtypes.h>
#include <stdio.h>

static void Kputc(u8 c) {
    while (*((u32*)0x1000f130) & 0x8000) { __asm__ ("nop\nnop\nnop\n"); }
    
	*((u8*)0x1000f180) = c;
}

static void Kputs(u8 *s) {
	while (*s != 0) {
		Kputc(*s++);
	}
}

int main()
{
	u32 startTime, endTime, clocksPerSec;
	u8 buf[256];
	int i;

	Kputs("Loop test\n");

	startTime = *((u32*)0x10001900);

	for (i=0; i<0x10000; ++i){
		__asm__ ("nop\nnop\nnop\n");
	}

	endTime = *((u32*)0x10001900);
	clocksPerSec = *((u32*)0x10001904);

	sprintf(buf, "start=%d, end=%d, clocksPerSec=%d\n", startTime, endTime, clocksPerSec);
	Kputs(buf);

    return 0;
}

@bigianb

bigianb commented Jan 14, 2021

Copy link
Copy Markdown
Contributor Author

I've pushed the test code up to a repo:

https://github.com/bigianb/ps2-speedtests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants