Media Engine?
Media Engine?
Some people might want to use the codecs in mebooter but I'd rather use the Media Engine as an extra CPU. To that end i've written a crappy sample that seems to work that runs a counter on the me. If anyone is interested i'll post it here.
I havn't investigated directly, but from looking at mebooter, it's local ram appears to be at 0x88300000 and visible from both CPU's. I'm not sure if it can see the main CPU's ram but I suspect it can and wouldn't be hard to check. Anyway, to the code.ector wrote:Yes indeed, would be interesting. Does it have access to main memory?
Code: Select all
#include <psptypes.h>
#include <string.h>
#include <pspkernel.h>
#include <pspdebug.h>
void *me_run();
void *me_end();
void (*sceSysregMeResetEnable)();
void (*sceSysregMeResetDisable)();
void (*sceSysreg_unk1)();
void (*sceSysregVmeResetDisable)();
PSP_MODULE_INFO("ME_test", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
int main(int param1, int param2)
{
SceModuleInfo *sysreg_driver;
pspDebugInstallErrorHandler(NULL);
pspDebugScreenInit();
pspDebugScreenPrintf("start\n");
memcpy((void *)0xbfc00040, me_run, (int)(me_end - me_run));
sysreg_driver = pspDebugFindModule("sceSYSREG_Driver");
sceSysregMeResetEnable = pspDebugFindExportedFunction(sysreg_driver, "sceSysreg_driver", 0xde59dacb);
sceSysregMeResetDisable = pspDebugFindExportedFunction(sysreg_driver, "sceSysreg_driver", 0x2db0eb28);
sceSysreg_unk1 = pspDebugFindExportedFunction(sysreg_driver, "sceSysreg_driver", 0x44f6cda7);
sceSysregVmeResetDisable = pspDebugFindExportedFunction(sysreg_driver, "sceSysreg_driver",0x7558064a);
sceKernelDcacheWritebackInvalidateAll();
(*sceSysregMeResetEnable)();
(*sceSysreg_unk1)();
(*sceSysregMeResetDisable)();
(*sceSysregVmeResetDisable)();
while(1)
{
sceKernelDcacheWritebackInvalidateAll();
pspDebugScreenPrintf("%08x", *(unsigned int *)0xbfc00060);
}
sceKernelExitGame();
return 0;
}
Code: Select all
#include <machine/regdef.h>
.globl me_run
.globl me_end
me_run:
li v0, 0xbfc00060
li v1, 0
a:
addiu v1, v1, 1
sw v1, 0(v0)
b a
me_end:
Nice work! I have a question about the Media Engine that I hope you'd answer for those of us who are still in the shallow waters of PSP programming :) How much, so far, has the Media Engine been implemented in the most popular homebrew programs? (Such as the many versions of Snes9x, NesterJ, etc).
Keep up the great work everyone, and now I will return to my mostly-lurker status, and continue to play catch-up from some of you guys about a half-mile back :)
Keep up the great work everyone, and now I will return to my mostly-lurker status, and continue to play catch-up from some of you guys about a half-mile back :)
Last edited by MDoggie on Fri Jul 15, 2005 9:08 am, edited 2 times in total.
This is awesome now will this work like a second CPU can the Main Core and Media Core work together to get faster speeds on snes9x and other Games?
EdwardFMA/IchigoKurosaki - PSP Expert
Athlon 64 - Socket 939 - 3000+
1GB 333 DDR-Ram
Geforce 6600 GT PCI-Express
Orbis PSP Development
Open-Source Development
Athlon 64 - Socket 939 - 3000+
1GB 333 DDR-Ram
Geforce 6600 GT PCI-Express
Orbis PSP Development
Open-Source Development
I just stuck this code at the beginning of snes9x to see if anything would break and as for as I can tell nothing did. So it seems we should be able to do just about anything with it.
Eventually. Some RPC system would have to be developed. Also, there may be a way to use the mebooter code to load homebrew code with the advantage of using the existing libraries. I looked, though, and it seems to me that the mebooter just contains a simple RPC system for just controlling the codecs and the VME.This is awesome now will this work like a second CPU can the Main Core and Media Core work together to get faster speeds on snes9x and other Games?
... *Crawls back into corner* ....
EdwardFMA/IchigoKurosaki - PSP Expert
Athlon 64 - Socket 939 - 3000+
1GB 333 DDR-Ram
Geforce 6600 GT PCI-Express
Orbis PSP Development
Open-Source Development
Athlon 64 - Socket 939 - 3000+
1GB 333 DDR-Ram
Geforce 6600 GT PCI-Express
Orbis PSP Development
Open-Source Development
I've written a bootstrap and loader that will load an elf binary into the me address space and jump to the entry. There is a sample program included and a shell script to build it.
http://home.wi.rr.com/crazyz/meloader.tgz
Edit: better
http://home.wi.rr.com/crazyz/meloader.tgz
Edit: better
am I the only one testing this ? ;-)
it seems it cannot compile with latest svn (update a few hours ago).
the debugfindmodule,... functions cannot be found.
same for kprintf sample ....
anyway, if we can get this to work it will be a major boost for lots of
homebrew here (codec, emulator core like snes'apu, ....)...
it seems it cannot compile with latest svn (update a few hours ago).
the debugfindmodule,... functions cannot be found.
same for kprintf sample ....
anyway, if we can get this to work it will be a major boost for lots of
homebrew here (codec, emulator core like snes'apu, ....)...
At least someone else is interested in it. :)yoyofr wrote:am I the only one testing this ? ;-)
That is in modmgr.c which was removed for some reason.yoyofr wrote: it seems it cannot compile with latest svn (update a few hours ago).
the debugfindmodule,... functions cannot be found.
same for kprintf sample ....
I've had problems with this. I'm working on cache flush to hopefully make it easier. Maybe it would be a good idea to make two new libraries in svn, maybe libmeinit for cpu side bootstrap and libme for a utility library and me specific libc functions.yoyofr wrote:ok, thx.
I'll play with it a bit now...
did you try to access main cpu memory from me ?
I'm very interested in the ME and other processors/accelerators in the PSP but I'm busy with work and getting Net stuff into PSPSDK. I will however work on getting ME stuff into PSPSDK after net stuff is in. I think it would be nice to have some more things done/figured out for ME before we put it in though, especially a good sample.
Thanks to TyRaNiD, a very basic test, which compiles with PSPSDK, is in svn now. I've fixed a bug, now the loop runs more than once :-) but more research is needed.yoyofr wrote:good.
right now I'm quite busy with psp gu... I'll have a look at me when
it will be in pspsdk then
You can't share the FPU, it's a coprocessor attached to each CPU individually.Saotome wrote:could it be possible that both cores share one FPU. or did you check already (write to FPU register from main core, read the same FPU register from ME)?crazyc wrote:...
Edit: and despite what sony's block diagram shows, the me has an fpu.
Please keep the memory map in the wiki up to date as you discover new things.crazyc wrote:I've gotten cache flush working and as expected, system ram is mapped at 0x88000000 and is all accessable. Local ram is mapped at 0x80000000. Video ram appears to be inaccessable, at least at the usual address.
Edit: and despite what sony's block diagram shows, the me has an fpu.
http://wiki.ps2dev.org/psp:memory_map
Here's a tarball with a sample to dump the chunks of address space. It also includes the start of libraries for me init and C code running on the me. No psp libraries can be used on the me, due to the lack of kernel functions, except psplibc (not right now though, becuase sbrk is incompatible; until that is resolved, use newlib).
http://home.wi.rr.com/crazyz/melib.tgz
http://home.wi.rr.com/crazyz/melib.tgz
It's well suited to things like background music because of the lack of cache coherency. I haven't been able to tell if the audio hardware is directly accessable from it though. Note the sbrk in tarball is broken, here is a correction.
Edit: it looks like the exception handler location is set by loading cop0 register 25 (usually perfcnt) with the address of your handler.
Code: Select all
#include <psptypes.h>
#include <sys/unistd.h>
#include <errno.h>
#define ME_HEAP_BOTTOM (void *)0x80000000
#define ME_HEAP_TOP (void *)0x80200000
extern int _me_stack_size;
static void *_me_heap_ptr = ME_HEAP_BOTTOM;
void *_sbrk(ptrdiff_t incr)
{
void *new_brk, *prev_brk = _me_heap_ptr;
if(incr)
{
new_brk = _me_heap_ptr + incr;
if((new_brk + _me_stack_size) > ME_HEAP_TOP)
{
errno = ENOMEM;
return (void *)-1;
}
if(new_brk < ME_HEAP_BOTTOM)
new_brk = ME_HEAP_BOTTOM;
_me_heap_ptr = new_brk;
}
return prev_brk;
}
Last edited by crazyc on Thu Jul 28, 2005 3:51 am, edited 1 time in total.