{"action":"created","issue":{"url":"https://api.github.com/repos/ps2dev/ps2sdk/issues/52","repository_url":"https://api.github.com/repos/ps2dev/ps2sdk","labels_url":"https://api.github.com/repos/ps2dev/ps2sdk/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/ps2dev/ps2sdk/issues/52/comments","events_url":"https://api.github.com/repos/ps2dev/ps2sdk/issues/52/events","html_url":"https://github.com/ps2dev/ps2sdk/issues/52","id":249571191,"number":52,"title":"Built-in compatibility with loader-like/resident projects - do we want it?","user":{"login":"sp193","id":3446348,"avatar_url":"https://avatars1.githubusercontent.com/u/3446348?v=4","gravatar_id":"","url":"https://api.github.com/users/sp193","html_url":"https://github.com/sp193","followers_url":"https://api.github.com/users/sp193/followers","following_url":"https://api.github.com/users/sp193/following{/other_user}","gists_url":"https://api.github.com/users/sp193/gists{/gist_id}","starred_url":"https://api.github.com/users/sp193/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sp193/subscriptions","organizations_url":"https://api.github.com/users/sp193/orgs","repos_url":"https://api.github.com/users/sp193/repos","events_url":"https://api.github.com/users/sp193/events{/privacy}","received_events_url":"https://api.github.com/users/sp193/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-11T08:39:02Z","updated_at":"2017-08-26T14:55:40Z","closed_at":null,"body":"Sometime ago, I copied and implemented a version of the SCE alarm functions patch, as well as completed the patch for the TLB functions.\r\nThis brings us to having the following EE kernel patches:\r\n\r\n- alarm (SetAlarm, ReleaseAlarm, iSetAlarm, iReleaseAlarm)\r\n\r\n- thread (iWakeupThread, iSuspendThread, iRotateThreadReadyQueue)\r\n\r\n- TLB (All TLB functions + ExecPS2, LoadExecPS2, Exit, ExecOSD)\r\n\r\n- libosd (ExecPS2 and OSD config functions), for the SCPH-10000 and SCPH-15000.\r\n\r\nHowever, I realize that the TLB patches and thread function patches in particular do make the building and maintenance of loader-like/resident projects difficult (other than some problems with linking, the thread patch is always linked to because of SIFRPC). Right now, my solution for OPL and FMCB is:\r\n1. Use a custom crt0 module that does not apply any of the patches and calls _Exit instead of Exit (to avoid linking to the dysfunctional patch).\r\n2. Do not call any of the patched functions, but use their originals (i.e. instead of ExecPS2, call _ExecPS2).\r\n3. Provide a iWakeupThread object that defines the original iWakeupThread syscall as an object, to override the one that is supplied by thread.o.\r\n4. For (3), provide a part of kernel.S.\r\n\r\nSo it feels rather hackish and I am not sure whether things are getting too confusing for other developers who don't dive as deep as I do into the bowels of the EE kernel...\r\n\r\nI believe that SCEI kept things working by using specific SDKs for their patches. For example, the SDK for our browsers has always maintained the old module design, so it should technically be SDK v1.x.\r\n\r\nMost EELOAD programs (includes the ones from the system driver update) do not have signs of being compiled with a late SDK version.\r\nOnly the HDD MBR programs seem to be compiled with a later version, which already has a version of the TLB function patches.\r\n\r\nSo what I am proposing to do (which is also already in the works) is:\r\n\r\n- Modify kernel.S to allow a syscall to be optionally defined to have a different symbol name from its definition (so I can define ExecPS2.o to use __NR__ExecPS2, for example).\r\n- Create a compile-time Makefile option (KERNEL_NO_PATCHES) that will define KERNEL_NO_PATCHES = 1, which defines that all patches will not be linked to, and the _InitSys (called by crt0 before main is invoked) and TerminateLibrary (called by crt0 when main returns) functions do not link to the patch either.\r\n\r\nIf anyone has any objections or a better suggestion, please feel free to write about it here!\r\n\r\nThis will still mean that the syscall number definitions will not be backward-compatible, but at least the objects will be backward-compatible if libkernel-nopatch is used. As the unpatched EE syscalls will be used, the developer will also have to be mindful of their problems.\r\n\r\n***\r\nThe TLB function patch may not be only for the sake of allowing the developer to manipulate the TLB. I believe that it's also for supporting the PSX, if/when the kernel's memory mode is switched. Otherwise, the kernel will fault within ExecPS2 when it tries to copy arguments."},"comment":{"url":"https://api.github.com/repos/ps2dev/ps2sdk/issues/comments/325135254","html_url":"https://github.com/ps2dev/ps2sdk/issues/52#issuecomment-325135254","issue_url":"https://api.github.com/repos/ps2dev/ps2sdk/issues/52","id":325135254,"user":{"login":"sp193","id":3446348,"avatar_url":"https://avatars1.githubusercontent.com/u/3446348?v=4","gravatar_id":"","url":"https://api.github.com/users/sp193","html_url":"https://github.com/sp193","followers_url":"https://api.github.com/users/sp193/followers","following_url":"https://api.github.com/users/sp193/following{/other_user}","gists_url":"https://api.github.com/users/sp193/gists{/gist_id}","starred_url":"https://api.github.com/users/sp193/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sp193/subscriptions","organizations_url":"https://api.github.com/users/sp193/orgs","repos_url":"https://api.github.com/users/sp193/repos","events_url":"https://api.github.com/users/sp193/events{/privacy}","received_events_url":"https://api.github.com/users/sp193/received_events","type":"User","site_admin":false},"created_at":"2017-08-26T14:55:40Z","updated_at":"2017-08-26T14:55:40Z","body":"I have updated my branch. If libkernel-nopatch is linked to, then glue.o will also include a (previously missing!) workaround that SCEI employed. Our SDK was always missing the enabling/disabling of interrupts around these syscalls.\r\n\r\nI believe this workaround addresses the documented risk of a stray di instruction getting executed during the syscall's handling, which can permanently disable thread-switching on the EE."}}
{"actor":{"display_login":"sp193"}}