 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Krevnik
Joined: 09 Mar 2005 Posts: 71
|
Posted: Wed Mar 09, 2005 12:28 pm Post subject: Development on Big-Endian Platforms |
|
|
I discovered a minor issue with bin2o, bin2c, and bin2s. While a great tool, they are written solely for little-endian use. So, when you use these tools on a big-endian system, such as PPC, it creates a byte swapped version of the IRX, which is wrong. Because of this, no IRX merged into an ELF on a PPC system will load on the PS2. I have made a couple of changes to bin2s which makes it platform neutral (but the resulting .s file is much larger, since it simply defines a series of bytes, rather than words). I am doing a couple of things to get the size back down a little, but retain the platform neutrality. Also, I am working on similar patches for bin2o and bin2c.
Also, there are a few module calls in the IOP section of PS2SDK which aren't entirely wired up yet (import stub missing declaration in a header, or vice versa). I have wired up a few of these, and would also like to submit the patch for these as well.
Who should I send the patch to for submission into CVS if it is useful? ;) |
|
| Back to top |
|
 |
ooPo Site Admin
Joined: 17 Jan 2004 Posts: 2032 Location: Canada
|
Posted: Wed Mar 09, 2005 2:51 pm Post subject: |
|
|
Generally you can post a patch here, or if its large you can pop by the irc channel (#ps2dev on efnet) and either ask for cvs write access or for someone to test/merge for you.
Its always good to see someone who tests AND fixes. Welcome to ps2dev! :) |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 09, 2005 3:12 pm Post subject: |
|
|
As a fellow PPC'er (and there are quite a few of us around) I feel for ya, I run into the same thing alot too. ;)
The main thing is, the x86 architecture is the more common development platform, and it fortunately it is already little-endian. So when people write little utilities that are intended to execute *on* the dev platform, endianness isn't always realized as an important consideration while coding.
Us PPC'ers need to stand tall and beat up the little guys. :) |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 09, 2005 3:35 pm Post subject: |
|
|
| ooPo wrote: | ... you can pop by the irc channel (#ps2dev on efnet) and either ask for cvs write access or for someone to test/merge for you.
|
Oh, Oopo didn't mention that thick skin is required on the irc channel. The people on #ps2dev are actually very nice folx, in a playfully trolling sort of way. ;) |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Wed Mar 09, 2005 10:59 pm Post subject: |
|
|
| gorim wrote: | | Oh, Oopo didn't mention that thick skin is required on the irc channel. The people on #ps2dev are actually very nice folx, in a playfully trolling sort of way. ;) | GRrouummpff?
Okay, seriously, post your patch here, or give it to some random cvs-writer guy in IRC, that'll be commited asap.
But, that doesn't affect bin2c, does it ? Only bin2s should be affected. _________________ pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department. |
|
| Back to top |
|
 |
Krevnik
Joined: 09 Mar 2005 Posts: 71
|
Posted: Thu Mar 10, 2005 12:48 am Post subject: |
|
|
I haven't checked bin2c, although bin2s and bin2o are definitely broken on PPC. (bin2o produces a completely unreadable object file on PPC)
I will take a look tonight when I have some time, and make the needed diffs. |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Thu Mar 10, 2005 4:24 am Post subject: |
|
|
Funny: bin2o is only a script to ee-ld. _________________ pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department. |
|
| Back to top |
|
 |
Krevnik
Joined: 09 Mar 2005 Posts: 71
|
Posted: Thu Mar 10, 2005 8:29 am Post subject: |
|
|
Heh, whadda know, it is. Hmm, seems like there was something else interfering, or I was using the wrong nm (dear god, I realized I have over 8 gcc toolchains on this machine, with only ONE per platform, *shudder*). bin2o seems to be working again... odd. Ignore my bin2o complaints. :)
bin2s is still borked, but not for long. It was a pretty simple patch. ;)
Anyways, the patches of work I have done so far... isn't much:
bin2s diff
iop sources diff |
|
| Back to top |
|
 |
rinco
Joined: 21 Jan 2005 Posts: 255 Location: Canberra, Australia
|
Posted: Wed Apr 13, 2005 11:45 am Post subject: |
|
|
| Code: | fprintf(dest, "\n\t.byte 0x%02x,0x%02x,0x%02x,0x%02x",
buffer[i], buffer[i+1], buffer[i+2], buffer[i+3]);
|
i see where you're going with the bin2s patch... but I still seem to get the
wrong order.
however this works for me:
| Code: | fprintf(dest, "\n\t.byte 0x%02x,0x%02x,0x%02x,0x%02x",
buffer[i+3], buffer[i+2], buffer[i+1], buffer[i]);
|
but i'm guessing it won't work for the x86 crowd.
perhaps it would be best to use one of the functions from arpa/inet.h? |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Apr 13, 2005 12:01 pm Post subject: |
|
|
| Or you can look at code I included in my PARAM.SFO parsing code on the psp forums that will convert a number into the proper endian version needed. |
|
| Back to top |
|
 |
rinco
Joined: 21 Jan 2005 Posts: 255 Location: Canberra, Australia
|
Posted: Wed Apr 13, 2005 12:38 pm Post subject: |
|
|
ok this works great, thanks gorim
| Code: | diff -u bin2s.c le32_bin2s.c
--- bin2s.c Wed Apr 13 12:40:10 2005
+++ le32_bin2s.c Wed Apr 13 12:40:49 2005
@@ -19,6 +19,15 @@
unsigned char *buffer;
+/* For endian neutrality */
+u_int32_t le32(u_int32_t bits)
+{
+ u_int8_t *bytes;
+ bytes = (u_int8_t*)&bits;
+ return(bytes[0] | (bytes[1]<<8) | (bytes[2]<<16) | (bytes[3]<<24));
+}
+
+
int main(int argc, char *argv[])
{
int fd_size;
@@ -65,8 +74,8 @@
fprintf(dest, "%s:\n\n",argv[3]);
for(i=0;i<fd_size;i+=4) {
- if((i % 16) == 0) fprintf(dest, "\n\t.word 0x%08x", *(int*)&buffer[i]);
- else fprintf(dest, ", 0x%08x", *(int*)&buffer[i]);
+ if((i % 16) == 0) fprintf(dest, "\n\t.word 0x%08x", le32(*(int*)&buffer[i]));
+ else fprintf(dest, ", 0x%08x", le32(*(int*)&buffer[i]));
}
fprintf(dest, "\n");
|
|
|
| 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
|