mid-kid / CakeHax

Open source ARM9 payload loader for Nintendo 3DS
Mozilla Public License 2.0
17 stars 10 forks source link

Refactoring #11

Closed 173210 closed 8 years ago

mid-kid commented 8 years ago

Summary: Reimplementations of functions found in the apps we launch from, written in C (2 of which could better be done directly from assembly, instead of C, in which it looks ugly), and cleaning out the data and instruction cache in the chainloader payload.

I won't merge the reimplementations because they look and read ugly in C. (I might consider reimplementing them myself, and I actually considered it when making CakeHax, but I've never really found it necessary.) Is clearing the cache in the payload really necessary?

173210 commented 8 years ago

@mid-kid Actually __asm__ looks ugly, but it's necessary to exclude unnecessary code in the output and to allow the compiler to assign registers more efficiently. It's code for GCC, so this should be OK. And you know, such system calls are often implemented in inline assembly (refer free OSes (Linux or BSDs) code). That's why GCC doesn't implement __svc, implemented in armcc.

Yes, cleaning is necessary.

mid-kid commented 8 years ago

Holy shit, that's a lot of changes. It actually freaks me out a bit.
Please tell me when you're done changing things and I'll look them through, okay? Please also note that I won't accept any style changes like in https://github.com/173210/CakeHax/commit/7fbe2655ad542608460cf7b11ac82edfde830316.

173210 commented 8 years ago

@mid-kid Now it's ready to merge. b048ea35313a24a46b83ae7830fbead3631fcb9e breaks compatibility, so ignore it if you don't want. 7fbe2655ad542608460cf7b11ac82edfde830316 removed __ prefix, which is reserved for the compiler and libraries by the ANSI-C standard.

mid-kid commented 8 years ago

7fbe265 removed __ prefix, which is reserved for the compiler and libraries by the ANSI-C standard.

I somehow taught myself that practice (I think it came from the early versions of "Learn C The Hard Way". It seems the guy fixed it now). Thanks for telling me it's a bad one.
Still, I'll look at it seriously, and I'll only accept the commits that I think actually make things easier to read/understand/maintain, and fit with the way I prefer to do things (especially this last part). Sorry for being so spergy about this, but bear with me. This is all part of the warning on the CakesFW OP (should I put this in a CONTRIBUTING.md?): Just don't be scared if I end up rewriting/restructuring your code as I see fit.
I'm having a busy week, but I'll take a look at it as soon as I have time.

173210 commented 8 years ago

@mid-kid It's completely OK for me to rewriting my patches. It's your project. I added 98c3a5766048cdd9eb8d8a44095fe935f5694418, according to Exhibit A in the MPL and Mozilla's code.

mid-kid commented 8 years ago

Compiling and testing your changes, CakesFW fails to boot for me on both MSET and SPIDER. I've been going through your changes, and this one seems very dodgy: https://github.com/173210/CakeHax/commit/65503432e4989bf7abd166840a0896fb4df5de61 Okay, hammering svc 8 seems like a meh idea, if it actually worked. Did you test this? Does this work on an n3ds or something?

173210 commented 8 years ago

@mid-kid Yes, it works on my 3DS and new 3DS. So it's also a bug I can't reproduce? Hmm.... Anyway, if it doesn't work, please ignore the commit.

mid-kid commented 8 years ago

Merged. If there's anything I've missed (the point of) or I've done incorrectly, please say so.