wifi and user mode

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

Moderators: cheriff, TyRaNiD

Post Reply
matkeupon
Posts: 26
Joined: Sat Jul 02, 2005 10:58 pm

wifi and user mode

Post by matkeupon »

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: Select all

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.
PspPet
Posts: 210
Joined: Wed Mar 30, 2005 2:13 am
Contact:

Post by PspPet »

> 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)
benji
Posts: 17
Joined: Fri Oct 14, 2005 2:41 pm

Post by benji »

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
matkeupon
Posts: 26
Joined: Sat Jul 02, 2005 10:58 pm

Post by matkeupon »

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.
PspPet
Posts: 210
Joined: Wed Mar 30, 2005 2:13 am
Contact:

Post by PspPet »

> 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)
Post Reply