Problems using kmode functions/kmem in a kmode module

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Problems using kmode functions/kmem in a kmode module

Post by FreePlay »

Kernel mode and I are not friends. At least, not right now.

I'm running 3.10 OE-A, and I've loaded a user-mode module in VSH mode that loads and starts a kmode module. This all runs smoothly - loads and starts up OK. At this point, several things happen.

0. The VSH runs just fine, as I hope it would.

1. File I/O seems to die completely. I use sceIoOpen and sceIoWrite to write to a logfile, but the writing never actually happens.

2. I cannot access kernel-mode functions or read/write kmem.

As an example of how I'm attempting to read kmem:

Code: Select all

int res = sceIoWrite(fd,(void*)0x08000000,0x400000);
fd, of course, is the SceUID of an output file.

When I call a function that uses this code, the PSP freezes. I'm not sure if it's related to sceIo, or to kmem access. But it's bugging me.

Anyone have any idea why it's doing this?

umode module --> load/start kmode module --> start main thread --> dump kmem --> freeze.
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Post by FreePlay »

I've narrowed the problem down to the actual kmem access. sceIo* works just fine, as it should. Is there something I have to do to 'unlock' kmem and actually use it?
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Post by crazyc »

FreePlay wrote:I've narrowed the problem down to the actual kmem access. sceIo* works just fine, as it should. Is there something I have to do to 'unlock' kmem and actually use it?
I've never tested it, but your code seem to confirm, that even kernel mode code can't access protected regions in KUSEG (0x0 - 0x7fffffff). You can unlock it by writing to mmio registers at 0xbc000000 but it would probably be easier to OR your pointers with 0x80000000.
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Post by FreePlay »

So accessing it via 0x88000000 should work, even if 0x08000000 doesn't? I'll try that :/
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Post by FreePlay »

Problem solved. This:
moonlight wrote:Are you making your functions look like this?

Code: Select all

int k1 = pspSdkSetK1(0);

code...;

pspSdkSetK1(k1);

return something;
gives me read/write access to kmem. This thread can be closed.
Post Reply