 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
matkeupon
Joined: 02 Jul 2005 Posts: 26
|
Posted: Wed Oct 12, 2005 6:43 am Post subject: wifi and user mode |
|
|
Hi all,
I'm trying to add some multiplayer to my game, so I need the wlan modules in my game. My problem is, my game runs in user mode only. When I set the kernel flag,
| Code: | PSP_MAIN_THREAD_ATTR(0);
Instead of
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); |
then the game freezes at the splash screen (but it loads hte characters fine, starts the music).
I tried to:
- load the modules in the main thread, create and start a user thread to run the game, but every time I tried it froze.
- create a kernel thread in the constructor, and load the libs from it. The libs won't load (Exception: bus error...)
Can someone give me a solution ? Maybe some tricks and things to avoid to have the game run in kernel mode ?
Or maybe what I tried to do is possible but I messed up, I really don't know how to load those libs and having my game run at the same time :(
Thanks in advance for any help. |
|
| Back to top |
|
 |
PspPet
Joined: 30 Mar 2005 Posts: 210
|
Posted: Wed Oct 12, 2005 7:40 am Post subject: |
|
|
> I tried to:
> - load the modules in the main thread, create and start a user thread to run the game, but every time I tried it froze.
That should work (change back to "PSP_MAIN_THREAD_ATTR(0);")
If the game is freezing, I would look into that in more detail (including stack size etc -- something weird going - if it *needs* user mode, usually it is the other way around)
---
BTW: the WiFi APIs do work in user mode (I did this earlier with my WiFi .02 sample)
Leave the startup the same, including "nlhLoadDrivers"
Then create a new USER mode thread, and do all the other stuff ("DoInetNetTest" in my sample) |
|
| Back to top |
|
 |
benji
Joined: 14 Oct 2005 Posts: 17
|
Posted: Fri Oct 14, 2005 2:53 pm Post subject: |
|
|
This indeed works well. However... having your module load in kernel mode and declaring a pre-main constructor that loads the drivers so that your main thread can run in user mode does not seem to work. Any clue as to why that would be the case?
In summary, for wifi to work in user mode, you need to load the module in kernel mode, have your main thread start in kernel mode, load the wifi drivers from the main thread then create a user mode thread.
benji |
|
| Back to top |
|
 |
matkeupon
Joined: 02 Jul 2005 Posts: 26
|
Posted: Fri Oct 14, 2005 7:32 pm Post subject: |
|
|
Well now that I've set up the exception handler, I can see that my main thread works fine, in user mode.
Now I have problems loading the libs, I've got to figure out why nhlloaddrivers fails (exception - bus error).
Thanks for your help, I won't try to load the libs from the constructor any more.
But if someone has a working source for an app that loads the wifi modules while the main thread runs in user mode, that would be great. |
|
| Back to top |
|
 |
PspPet
Joined: 30 Mar 2005 Posts: 210
|
Posted: Sat Oct 15, 2005 2:54 am Post subject: |
|
|
> having your module load in kernel mode and declaring a pre-main constructor that loads the drivers
The "pre-main" state is limited -- it won't allow you to load modules. Do everything significant in a created thread.
BTW: From ancient tips&tricks: http://forums.ps2dev.org/viewtopic.php?t=2211
> Loading a library in the startup code ('kmain' in {old structured app} kdumper) will fail (error 0x80020143). Instead create a separate thread and try to load the library from there.
----
If your app has a PSPSDK startup KERNEL thread, and creates a USER thread (with appropriate attributes and stack sizes) -- it *should* work the same as a app starting with a USER mode thread.
If not, change the "crt0.c" startup to do what you want (ie. the default start order and logic is PSPSDK specific - not the only way of doing it) |
|
| Back to top |
|
 |
|
|
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
|