pspdev / pspsdk

An open-source SDK for PSP homebrew development.
Other
856 stars 143 forks source link

Move `sceGeEdramSetSize` function to sceGe_driver #223

Closed diamant3 closed 3 weeks ago

diamant3 commented 2 months ago

PR is based on https://spenon-dev.github.io/PSPLibDoc/modules/ge.prx_sceGe_driver.html and https://github.com/uofw/uofw/blob/master/include/ge_kernel.h#L294

Also adjust the flags version of sceGe_driver and sceGe_user based on https://raw.githubusercontent.com/Spenon-dev/PSPLibDoc/main/PSPLibDoc/6.60/PSPLibDoc_6.60.xml

Hopefully could fix the issue #139

sharkwouter commented 2 months ago

I am not able to test this, since I this seems to move the function to a place that requires kernel mode and I don't know how to trigger that.

I have the following code from the issue which compiles:

CMakeLists.txt

cmake_minimum_required(VERSION 3.0)

project(edramsize)

add_executable(${PROJECT_NAME}
  main.c
)

target_link_libraries(${PROJECT_NAME}
  pspdebug
  pspdisplay
  pspge
  pspge_driver
)

create_pbp_file(
    TARGET ${PROJECT_NAME}
    ICON_PATH NULL
    BACKGROUND_PATH NULL
    PREVIEW_PATH NULL
    TITLE ${PROJECT_NAME}
)

main.c:

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspge.h>

PSP_MODULE_INFO("PSP VRAM ISSUE", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

int main(int argc, char *argv[])
{
    pspDebugScreenInit(); // Initialize the debug screen

    struct KernelCallArg args = {0x400000};
    if (sceGeEdramSetSize(0x400000) == 0)
    {
        pspDebugScreenPrintf("sceGeEdramSetSize 4MB ok\n"); // Never called
    }
    else
    {
        pspDebugScreenPrintf("sceGeEdramSetSize 4MB ERROR\n"); // Called
    }

    pspDebugScreenPrintf("%i", sceGeEdramGetSize()); // Prints "2097152" instead of the double

    while (1)
    {
        sceDisplayWaitVblankStart();
    }
}

I get a 0x8002013C error when trying to start it.

One thing of note, with this change you need to link to pspge_driver.

joel16 commented 2 months ago

I am not able to test this, since I this seems to move the function to a place that requires kernel mode and I don't know how to trigger that.

I have the following code from the issue which compiles:

CMakeLists.txt

cmake_minimum_required(VERSION 3.0)

project(edramsize)

add_executable(${PROJECT_NAME}
  main.c
)

target_link_libraries(${PROJECT_NAME}
  pspdebug
  pspdisplay
  pspge
  pspge_driver
)

create_pbp_file(
    TARGET ${PROJECT_NAME}
    ICON_PATH NULL
    BACKGROUND_PATH NULL
    PREVIEW_PATH NULL
    TITLE ${PROJECT_NAME}
)

main.c:

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspge.h>

PSP_MODULE_INFO("PSP VRAM ISSUE", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

int main(int argc, char *argv[])
{
    pspDebugScreenInit(); // Initialize the debug screen

    struct KernelCallArg args = {0x400000};
    if (sceGeEdramSetSize(0x400000) == 0)
    {
        pspDebugScreenPrintf("sceGeEdramSetSize 4MB ok\n"); // Never called
    }
    else
    {
        pspDebugScreenPrintf("sceGeEdramSetSize 4MB ERROR\n"); // Called
    }

    pspDebugScreenPrintf("%i", sceGeEdramGetSize()); // Prints "2097152" instead of the double

    while (1)
    {
        sceDisplayWaitVblankStart();
    }
}

I get a 0x8002013C error when trying to start it.

One thing of note, with this change you need to link to pspge_driver.

This PR is moving sceGeEdramSetSize to a kernel library. You're attempting to use it in a usermode application, which won't work. You'll need to use kubridge or write your own kernel -> user plugin to use this. Also, don't you have to initialize this with sceGeEdramInit before attempting to call sceGeEdramSetSize?

diamant3 commented 2 months ago

I get a 0x8002013C error when trying to start it.

One thing of note, with this change you need to link to pspge_driver.

Thanks for testing! too bad we're same result.

I'm trying to learn how to work on this one here: https://uofw.github.io/upspd/docs/software/ModuleTutorialv1.pdf but not sure if this is the correct one to get this thing work. also practicing some samples from https://github.com/pspdev/pspsdk/tree/master/src/samples/prx. Right now, I'm really confused how this thing works and I don't want to go down to the rabbit hole for this(hopefully not😅). Should I draft this, close it or just open?

You'll need to use kubridge or write your own kernel -> user plugin to use this. Also, don't you have to initialize this with sceGeEdramInit before attempting to call sceGeEdramSetSize?

I applied this one too, I tried the kubridge and calling the sceGeEdramInit first, both PPSSPP(like 0x8002013C or 0x8002013A errors I always got and sometimes it's just a violet screen with the same error :( ) and PSP(just exiting with a 0x8002013C error) but it's not working to me, also something like sceKernelLoadModule functions I tried but no luck. last but not the least, I tried to use the setK1 or something to trick my eboot.pbp to call the kernel functions but it's not working to me too.

joel16 commented 2 months ago

I get a 0x8002013C error when trying to start it. One thing of note, with this change you need to link to pspge_driver.

Thanks for testing! too bad we're same result.

I'm trying to learn how to work on this one here: https://uofw.github.io/upspd/docs/software/ModuleTutorialv1.pdf but not sure if this is the correct one to get this thing work. also practicing some samples from https://github.com/pspdev/pspsdk/tree/master/src/samples/prx. Right now, I'm really confused how this thing works and I don't want to go down to the rabbit hole for this(hopefully not😅). Should I draft this, close it or just open?

You'll need to use kubridge or write your own kernel -> user plugin to use this. Also, don't you have to initialize this with sceGeEdramInit before attempting to call sceGeEdramSetSize?

I applied this one too, I tried the kubridge and calling the sceGeEdramInit first, both PPSSPP(like 0x8002013C or 0x8002013A errors I always got and sometimes it's just a violet screen with the same error :( ) and PSP(just exiting with a 0x8002013C error) but it's not working to me, also something like sceKernelLoadModule functions I tried but no luck. last but not the least, I tried to use the setK1 or something to trick my eboot.pbp to call the kernel functions but it's not working to me too.

I wouldn't use PPSSPP for testing kernel->user functionality. However, I know you should be able to use kuKernelCall like this: https://github.com/joel16/CMFileManager-PSP/blob/30b0be604e4ea9cf770bd4c56e7db1af8355fbbb/app/source/kernel_functions.cpp#L10

diamant3 commented 2 months ago

I wouldn't use PPSSPP for testing kernel->user functionality. However, I know you should be able to use kuKernelCall like this: https://github.com/joel16/CMFileManager-PSP/blob/30b0be604e4ea9cf770bd4c56e7db1af8355fbbb/app/source/kernel_functions.cpp#L10

I'll take note of that, and thanks for the code! I'll try that one.

For now, I'll draft this because it's currently not working.

diamant3 commented 3 weeks ago

I will close this PR because I can't get it to work, and this PR will probably get stuck in here.

Hopefully someone can work on this and solve the issue. Thanks.