 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Thu Jul 21, 2005 5:43 pm Post subject: My bugs or maybe PSPSDK's bugs... sceIoDread and Callbacks |
|
|
Hello again...
Not sure that's not my bugs but as I did not find why... maybe somebody will tell me...
1. sceIoDread
I use it to retrieve FS informations (is it a DIR, a FILE,...) and each time the SceIoDirent.d_stat.st_mode access mode is wrong :
- 0x11FF for a dir instead of FIO_S_IFDIR (0x2000)
- 0x21FF for a file instead of FIO_S_IFREG;(0x1000)
So I have to patch them manually :(
Here is the piece of code :
| Code: |
SceIoDirent Lfiles[MAXDIRNUM];
...
while((ret>0) && (Lfiles_num<MAXDIRNUM)) {
ret = sceIoDread(fd, &Lfiles[Lfiles_num]);
//manual patch
//printf("before[%s] : %x\n", Lfiles[Lfiles_num].d_name, Lfiles[Lfiles_num].d_stat.st_mode);
if(Lfiles[Lfiles_num].d_stat.st_mode == 0x11FF) Lfiles[Lfiles_num].d_stat.st_mode = FIO_S_IFDIR;
if(Lfiles[Lfiles_num].d_stat.st_mode == 0x216D) Lfiles[Lfiles_num].d_stat.st_mode = FIO_S_IFREG;
if(Lfiles[Lfiles_num].d_stat.st_mode == 0x21FF) Lfiles[Lfiles_num].d_stat.st_mode = FIO_S_IFREG;
//printf("after[%s] : %x\n", Lfiles[Lfiles_num].d_name, Lfiles[Lfiles_num].d_stat.st_mode);
if (Lfiles[Lfiles_num].d_name[0] == '.') continue;
if (ret>0) Lfiles_num++;
}
|
I searched in the forums, I only found something about memseting the SceIoDirent, is it the issue ?
2. Exit callback
I use the standard pspsdk code to set the exit callback and blablabla... it works perfect when I run my code in user mode but in kernel mode the X button has no action on the Exit validation (the O works), exactly like in the PSP MediaCenter 0.87, X doesn't work too.
Any idea ?
I got this issue in 2 different apps... in the same context. _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Arwin
Joined: 12 Jul 2005 Posts: 426
|
Posted: Thu Jul 21, 2005 7:39 pm Post subject: |
|
|
I have a Japanese PSP and I can always only use the O for confirming Exit. It's the default 'confirm' button. This is different for the US version, where the X button is default. A bit confusing when I for instance play the US version of Wipeout on the Japanese PSP, as that game uses the X button for confirm as per the US standards.
Do you have a US PSP or a Jap PSP? |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Thu Jul 21, 2005 7:45 pm Post subject: |
|
|
US 1.5
X : validate Exit (no effect in kernel mode)
O : Cancel exit (always works) _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Arwin
Joined: 12 Jul 2005 Posts: 426
|
Posted: Thu Jul 21, 2005 11:25 pm Post subject: |
|
|
| Shazz wrote: | US 1.5
X : validate Exit (no effect in kernel mode)
O : Cancel exit (always works) |
Seems then that the regional settings for US are only active in user mode, which could make sense, somehow (not sure exactly how though ;). But lets assume that everything except possibly the dashboard itself is meant to run in user mode, and it makes sense. |
|
| Back to top |
|
 |
cwbowron

Joined: 06 May 2005 Posts: 76 Location: East Lansing, MI
|
Posted: Fri Jul 22, 2005 12:57 am Post subject: Re: My bugs or maybe PSPSDK's bugs... sceIoDread and Callbac |
|
|
| Shazz wrote: |
1. sceIoDread
I use it to retrieve FS informations (is it a DIR, a FILE,...) and each time the SceIoDirent.d_stat.st_mode access mode is wrong :
- 0x11FF for a dir instead of FIO_S_IFDIR (0x2000)
- 0x21FF for a file instead of FIO_S_IFREG;(0x1000)
So I have to patch them manually :(
|
I have the same issue with my file selection code, but I do not know why it is happening. |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Fri Jul 22, 2005 5:20 pm Post subject: |
|
|
Concerning sceIoDread, thnaks cwbowron for confirming the issue... so there is something....
as a work around, I saw that Adresd in his PSPMC used the d_attr to identify directories and files :
| Code: | (direntt->d_stat.st_attr & 0x10) == 0x10) { // directory
(direntt->d_stat.st_attr & 0x20) == 0x20) && (direntt->d_name[0] != 0)) { // File |
But....
Concerning the exit Callback, I don't know really what to think, it is obviously due to the fact I'm in kernel mode but.... even where to look at...
I'm going to disassemble the kernel call to see what's happening... _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
cage
Joined: 13 Jul 2005 Posts: 6
|
Posted: Fri Jul 22, 2005 7:19 pm Post subject: |
|
|
I got the same problems and I ran some tests on files and directories. It turns out, that there is a bug in the SDK.
To decide whether it is a file or a folder you got to check the st_mode variable.
BUT you have to use the IOAccessModes for that.
from pspiofilemgr_stat.h:
...
00029 FIO_S_IFMT = 0xF000,
00031 FIO_S_IFLNK = 0x4000,
00033 FIO_S_IFDIR = 0x2000, // wrong
00035 FIO_S_IFREG = 0x1000, // wrong
...
Furthermore the entries for folders and regular files are switched =(
So to check for a folder you do something like
SceIoDirent file;
// check for folder
if (FIO_S_IFREG & (file.d_stat.st_mode & FIO_S_IFMT)) {
...
}
or you redifne the stuff if it is too anoying for ya.
I noticed that I only cant exit a program if something turned wrong (some errors occured), in any other case it works ok. (jap PSP, v1.5)
Any information on that would be great... |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Fri Jul 22, 2005 8:22 pm Post subject: |
|
|
The FIO values come from the PS2, and they were meant more as placeholders. Sorry for the confusion. A patch would to fix them would be appreciated :).
As far as the exit callback goes, the thread that registers the callback must be a usermode thread. So just pass PSP_THREAD_ATTR_USER to sceKernelCreateThread() and you should be fine. |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Sat Jul 23, 2005 2:45 am Post subject: |
|
|
| mrbrown wrote: |
As far as the exit callback goes, the thread that registers the callback must be a usermode thread. So just pass PSP_THREAD_ATTR_USER to sceKernelCreateThread() and you should be fine. |
Huummm.. So I changed to
| Code: |
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread,
0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
|
And when I pushed the X button to validate the exit, I've got the Please Wait message.... freezes 10s then power off...
So I tried in user mode using :
| Code: | PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
__attribute__ ((constructor))
void loaderInit()
{
pspKernelSetKernelPC();
pspSdkInstallNoDeviceCheckPatch();
//pspDebugInstallKprintfHandler(NULL);
} |
And then it 'works'....(with a funny message: "prfile.mod.c:...oem... not exit, reboot start in debug) and exit
But as I have to be in kernel mode to use sceKernelLoadExec, not really a solution for the moment :D _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Sat Jul 23, 2005 4:11 am Post subject: |
|
|
OK, found,
While in kernel mode :
1. Set the callback thread in user mode while creating it
2. Detect that the exit_callback is called (global var)
3. In your main loop (in kernel mode), call sceGameExit() if the callback is detected to kill the kernel thread
ouch :D _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Mon Jul 25, 2005 11:36 pm Post subject: |
|
|
About the SceIoDirent usage, before doing a patch, I tested some examples and I saw :
- the usage of SceIoDirent ->d_stat.st_attr & FIO_SO_IFREG/FIO_SO_IFDIR is not possible with an UMD (always 0)
- SceIoDirent ->d_stat.st_mode should be used, as said Cage like that :
| Code: | // check for a file
if (FIO_S_IFREG & (SceIoDirent .d_stat.st_mode & FIO_S_IFMT))
// check for a folder
if (FIO_S_IFDIR & (SceIoDirent .d_stat.st_mode & FIO_S_IFMT))
|
Maybe everybody already knew it, not my case.... that's the macros I never saw before :
// File mode checking macros
#define FIO_S_ISLNK(m) (((m) & FIO_S_IFMT) == FIO_S_IFLNK)
#define FIO_S_ISREG(m) (((m) & FIO_S_IFMT) == FIO_S_IFREG)
#define FIO_S_ISDIR(m) (((m) & FIO_S_IFMT) == FIO_S_IFDIR)
Shame on me :D
so here is the patch I propose (simply invert #define)
Note :
I have some doubts about those one too... need to check
| Code: | /** User access rights mask */
FIO_S_IRWXU = 0x01C0,
/** Read user permission */
FIO_S_IRUSR = 0x0100,
/** Write user permission */
FIO_S_IWUSR = 0x0080,
/** Execute user permission */
FIO_S_IXUSR = 0x0040,
/** Group access rights mask */
FIO_S_IRWXG = 0x0038,
/** Group read permission */
FIO_S_IRGRP = 0x0020,
/** Group write permission */
FIO_S_IWGRP = 0x0010,
/** Group execute permission */
FIO_S_IXGRP = 0x0008, |
patch:
| Code: | --- pspiofilemgr_stat.h 2005-07-20 09:37:12.287260600 +0200
+++ pspiofilemgr_stat2.h 2005-07-25 15:35:39.661769400 +0200
@@ -30,9 +30,9 @@
/** Symbolic link */
FIO_S_IFLNK = 0x4000,
/** Directory */
- FIO_S_IFDIR = 0x2000,
+ FIO_S_IFDIR = 0x1000,
/** Regular file */
- FIO_S_IFREG = 0x1000,
+ FIO_S_IFREG = 0x2000,
/** Set UID */
FIO_S_ISUID = 0x0800, |
_________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| 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
|