Fixes to thread funcs, stack, etc.

This makes a number of changes:

 * Corrects `sceKernelReferThreadStatus()` and respects sdk version differences.
 * Stops reallocating the stack when terminating/restarting a thread (it's just allocated on create, which is what the PSP firmware seems to do.)
 * Fixes a timing issue with `sceKernelWakeupThread()`, which should reschedule to a resumed thread if better priority.
 * Returns some better errors / works around potential later errors in sceKernelCreateThread (particularly when stack couldn't be allocated.)
 * Returns better errors in sceKernelStartThread (for bad args.)
 * Fills the initial stack correctly, with the uid and stack ptr in the right place.
 * Correctly aligns args to 0x10 and doesn't corrupt the stack / k0 if there are more than 256 bytes of args.

Unfortunately, this doesn't seem to fix anything I have really, but it doesn't seem to break anything either.

-[Unknown]