| View previous topic :: View next topic |
| Author |
Message |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Fri Jul 15, 2005 7:13 am Post subject: 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. |
|
| Back to top |
|
 |
ector
Joined: 12 May 2005 Posts: 195
|
Posted: Fri Jul 15, 2005 7:31 am Post subject: |
|
|
| Yes indeed, would be interesting. Does it have access to main memory? |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Fri Jul 15, 2005 8:02 am Post subject: |
|
|
| ector wrote: | | Yes indeed, would be interesting. Does it have access to main memory? |
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.
| Code: | #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: | #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: |
|
|
| Back to top |
|
 |
MDoggie
Joined: 15 Jul 2005 Posts: 1
|
Posted: Fri Jul 15, 2005 8:45 am Post subject: |
|
|
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 :)
Last edited by MDoggie on Fri Jul 15, 2005 9:08 am; edited 2 times in total |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Fri Jul 15, 2005 8:49 am Post subject: |
|
|
Um this is the first publically available ME code anyone has seen.
Great work crazyc. |
|
| Back to top |
|
 |
EdwardFMA

Joined: 06 Jul 2005 Posts: 40
|
Posted: Fri Jul 15, 2005 10:50 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Fri Jul 15, 2005 11:22 am Post subject: |
|
|
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.
| Quote: | | 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? |
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. |
|
| Back to top |
|
 |
EdwardFMA

Joined: 06 Jul 2005 Posts: 40
|
Posted: Fri Jul 15, 2005 1:05 pm Post subject: |
|
|
... *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 |
|
| Back to top |
|
 |
lebron23
Joined: 16 Jul 2005 Posts: 1
|
Posted: Sat Jul 16, 2005 11:08 am Post subject: |
|
|
| [DELETED] |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Jul 16, 2005 12:09 pm Post subject: |
|
|
| lebron23 wrote: | | [DELETED] |
No software requests. |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Mon Jul 18, 2005 2:39 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
yoyofr
Joined: 25 Jun 2005 Posts: 23 Location: paris
|
Posted: Tue Jul 19, 2005 7:51 pm Post subject: |
|
|
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, ....)... |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Wed Jul 20, 2005 1:53 am Post subject: |
|
|
| yoyofr wrote: | | am I the only one testing this ? ;-) |
At least someone else is interested in it. :)
| 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 .... |
That is in modmgr.c which was removed for some reason. |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Wed Jul 20, 2005 2:13 am Post subject: |
|
|
| modmgr.c was removed because you can just create a stub which defines the kernel calls and call the functions directly, no more hackery required. I was going to quickly port acrosss crazyc's small example to pspsdk for people to play with, that would obviously bring the stubs in as well. |
|
| Back to top |
|
 |
yoyofr
Joined: 25 Jun 2005 Posts: 23 Location: paris
|
Posted: Wed Jul 20, 2005 2:14 am Post subject: |
|
|
ok, thx.
I'll play with it a bit now...
did you try to access main cpu memory from me ? |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Wed Jul 20, 2005 12:02 pm Post subject: |
|
|
| yoyofr wrote: | ok, thx.
I'll play with it a bit now...
did you try to access main cpu memory from me ? |
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. |
|
| Back to top |
|
 |
Warren
Joined: 24 Jan 2004 Posts: 173 Location: San Diego, CA
|
Posted: Wed Jul 20, 2005 1:31 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
yoyofr
Joined: 25 Jun 2005 Posts: 23 Location: paris
|
Posted: Thu Jul 21, 2005 2:35 am Post subject: |
|
|
good.
right now I'm quite busy with psp gu... I'll have a look at me when
it will be in pspsdk then |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Sat Jul 23, 2005 4:20 am Post subject: |
|
|
| 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 |
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. |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Sat Jul 23, 2005 10:30 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sat Jul 23, 2005 10:22 pm Post subject: |
|
|
| crazyc wrote: | ...
Edit: and despite what sony's block diagram shows, the me has an fpu. |
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)? _________________ infj |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Jul 23, 2005 11:51 pm Post subject: |
|
|
| Saotome wrote: | | crazyc wrote: | ...
Edit: and despite what sony's block diagram shows, the me has an fpu. |
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)? |
You can't share the FPU, it's a coprocessor attached to each CPU individually. |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sun Jul 24, 2005 3:01 am Post subject: |
|
|
Ok. I was just wondering, because of the block diagram. But maybe they just wanted to keep the diagram simple ;) _________________ infj |
|
| Back to top |
|
 |
Warren
Joined: 24 Jan 2004 Posts: 173 Location: San Diego, CA
|
Posted: Sun Jul 24, 2005 7:17 am Post subject: |
|
|
| 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. |
Please keep the memory map in the wiki up to date as you discover new things.
http://wiki.ps2dev.org/psp:memory_map |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Sun Jul 24, 2005 8:17 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Klimru
Joined: 09 Apr 2005 Posts: 34
|
Posted: Thu Jul 28, 2005 1:04 am Post subject: |
|
|
| is this processor fast enough to say, play an mp3? i'm not aware of the specs on it |
|
| Back to top |
|
 |
ector
Joined: 12 May 2005 Posts: 195
|
Posted: Thu Jul 28, 2005 1:04 am Post subject: |
|
|
| Easily. It runs the same speed as the main CPU, unless I have misunderstood something. |
|
| Back to top |
|
 |
Klimru
Joined: 09 Apr 2005 Posts: 34
|
Posted: Thu Jul 28, 2005 1:19 am Post subject: |
|
|
| maybe i'll try and get libmad to work on it |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Thu Jul 28, 2005 1:33 am Post subject: |
|
|
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.
| Code: | #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;
} |
Edit: it looks like the exception handler location is set by loading cop0 register 25 (usually perfcnt) with the address of your handler.
Last edited by crazyc on Thu Jul 28, 2005 3:51 am; edited 1 time in total |
|
| Back to top |
|
 |
Klimru
Joined: 09 Apr 2005 Posts: 34
|
Posted: Thu Jul 28, 2005 3:27 am Post subject: |
|
|
| thats pretty much all i want it for is background music... hopefully an mp3. The decoding of the mp3 just kills the processing in the game i'm working on, so, running it on a seperate processor all together would be perfect assuming its fast enough. |
|
| Back to top |
|
 |
|