forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems using kmode functions/kmem in a kmode module

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Thu Feb 22, 2007 8:52 am    Post subject: Problems using kmode functions/kmem in a kmode module Reply with quote

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:
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.
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Thu Feb 22, 2007 11:21 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
crazyc



Joined: 17 Jun 2005
Posts: 410

PostPosted: Thu Feb 22, 2007 11:50 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Thu Feb 22, 2007 12:02 pm    Post subject: Reply with quote

So accessing it via 0x88000000 should work, even if 0x08000000 doesn't? I'll try that :/
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Thu Feb 22, 2007 1:06 pm    Post subject: Reply with quote

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

Code:

int k1 = pspSdkSetK1(0);

code...;

pspSdkSetK1(k1);

return something;

gives me read/write access to kmem. This thread can be closed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group