Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added stubs for homebrew #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/libcinternals.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ __signbit \
__signbitf \
__signbitl \
__srget \
__stderrp \
__stdinp \
__stdoutp \
__swbuf \
_Exit \
abort \
Expand Down
2 changes: 2 additions & 0 deletions core/libkernels.mk
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ sceKernelAddUserEvent \
sceKernelAllocateDirectMemory \
sceKernelCreateEqueue \
sceKernelDeleteEqueue \
sceKernelWaitEqueue \
sceKernelDlsym \
sceKernelGetDirectMemorySize \
sceKernelGetCurrentCpu \
sceKernelGetModuleInfo \
sceKernelGetModuleList \
Expand Down
8 changes: 8 additions & 0 deletions core/stub.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ $(eval $(call generateModule, libSceNet, sceNetAccept sceNetBind sceNetConnect s
$(eval $(call generateModule, libScePad, scePadClose scePadInit scePadOpen scePadRead scePadReadState))
$(eval $(call generateModule, libSceSysmodule, sceSysmoduleIsLoaded sceSysmoduleLoadModule sceSysmoduleUnloadModule))
$(eval $(call generateModule, libSceUsbd, sceUsbdBulkTransfer sceUsbdCheckConnected sceUsbdClearHalt sceUsbdClose sceUsbdControlTransfer sceUsbdExit sceUsbdFreeConfigDescriptor sceUsbdFreeDeviceList sceUsbdGetActiveConfigDescriptor sceUsbdGetConfigDescriptor sceUsbdGetConfigDescriptorByValue sceUsbdGetDeviceDescriptor sceUsbdGetDeviceList sceUsbdInit sceUsbdInterruptTransfer sceUsbdOpen sceUsbdOpenDeviceWithVidPid sceUsbdResetDevice sceUsbdSetInterfaceAltSetting))
$(eval $(call generateModule, libSceUserService, sceUserServiceInitialize sceUserServiceTerminate sceUserServiceGetLoginUserIdList sceUserServiceGetEvent sceUserServiceGetInitialUser sceUserServiceGetUserName sceUserServiceGetUserColor))
$(eval $(call generateModule, libSceVideoOut, sceVideoOutOpen sceVideoOutClose sceVideoOutRegisterBuffers sceVideoOutUnregisterBuffers sceVideoOutSubmitFlip sceVideoOutSetBufferAttribute sceVideoOutSetFlipRate sceVideoOutAddFlipEvent sceVideoOutGetFlipStatus))
$(eval $(call generateModule, libSceGnmDriver, sceGnmFlushGarlic))
$(eval $(call generateModule, libSceSystemService, sceSystemServiceHideSplashScreen))
$(eval $(call generateModule, libSceAudioOut, sceAudioOutInit sceAudioOutOpen sceAudioOutClose sceAudioOutOutput sceAudioOutSetVolume))
$(eval $(call generateModule, libSceIme, sceImeKeyboardOpen sceImeKeyboardClose sceImeKeyboardUpdate sceImeKeyboardGetInfo sceImeKeyboardSetMode sceImeKeyboardGetResourceId sceImeUpdate sceImeOpen sceImeClose sceImeParamInit sceImeSetText))



# no need to touch, generates non-module libs
$(eval $(call generateLibraryLarge, kern_function, libps4Kernel, none, $(kerns)))
Expand Down
13 changes: 13 additions & 0 deletions include/sce/audioout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <stdint.h>
#include <types/kernel.h>
#include <types/userservice.h>



int sceAudioOutInit();
int sceAudioOutOpen(SceUserServiceUserId userId,unsigned int channel,int unknown ,unsigned int samples, unsigned int frequency, unsigned int format);
int sceAudioOutClose(int handle);
int sceAudioOutOutput(int handle, void *buf);
int sceAudioOutSetVolume(int handle, int filter, int *value);
6 changes: 6 additions & 0 deletions include/sce/gnmdriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include <stdint.h>


int sceGnmFlushGarlic();

3 changes: 3 additions & 0 deletions include/sce/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ int sceKernelCreateEqueue(SceKernelEqueue *eq, const char *name);
int sceKernelDeleteEqueue(SceKernelEqueue eq);
int sceKernelAddUserEvent(SceKernelEqueue eq, int id);
int sceKernelAddReadEvent(SceKernelEqueue eq, int fd, size_t size, void *data);
int sceKernelWaitEqueue(SceKernelEqueue eq, SceKernelEvent *ev, int num, int *out, SceKernelUseconds *timo);

size_t sceKernelGetDirectMemorySize();

/* more interresting wrappers */
int sceKernelAllocateDirectMemory(off_t searchStart, off_t searchEnd, size_t length, size_t alignment, int type, off_t *physicalAddressDestination);
Expand Down
16 changes: 5 additions & 11 deletions include/sce/pad.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
#pragma once

#include <stdint.h>
#include <inttypes.h>
#include <sce/types/pad.h>
#include <sce/types/userservice.h>

int scePadInit(void);
int scePadOpen(int userID, int, int, void *);
int scePadOpen(SceUserServiceUserId userId,int type,int index,uint8_t *param);
int scePadClose(int handle);
int scePadRead(int handle, void *data, int count);
int scePadReadState(int handle, void *data);
int scePadRead(int handle, ScePadData *data, int count);
int scePadReadState(int handle, ScePadData *data);

/* unreversed */
int64_t scePadResetOrientation();
int64_t scePadSetAngularVelocityDeadbandState();
int64_t scePadSetLightBar();
int64_t scePadSetMotionSensorState();
int64_t scePadSetTiltCorrectionState();
int64_t scePadSetVibration();
4 changes: 4 additions & 0 deletions include/sce/systemservice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#include <stdint.h>
int sceSystemServiceHideSplashScreen();
4 changes: 4 additions & 0 deletions include/sce/types/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

#include <stdint.h>
#include <sys/time.h>
#include <sys/event.h>
Copy link

@masterzorag masterzorag Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I just declare struct knote in my sample, this header give me error due forwarding declaration of struct knote;
Also, ps4sdk-examples/posix/stdio-redirect need 1 line change to compile fine now;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @masterzorag! Thanks for the feedback and help! The example can be fixed by adding #define __BSD_VISIBLE 1 before the includes.

But I would like to avoid including this header into the user-space as well. Instead of adding the include, can we use a void pointer to define SceKernelEvent? I see getter symbols for the fields of the structs, which suggests that this is the intended way of using the type. E.g. sceKernelGetEventData: SceKernelEvent -> intptr_t.

So, I would remove the sys/event.h include and use typedef void * SceKernelEvent instead. Then add the additional getters like sceKernelGetEventData

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psxdev if you can fix the above issue I will merge the PR. Alternatively we can close it and you could add it to the libs directly (but there it should not be in /include/sce but in /include) so you will have to refactor your code. If that is ok we can close the PR - otherwise lets add the headers (after the fix above) so that for now you do not need to port your code to the new header locations.


#ifndef MAP_TYPE
#define MAP_TYPE 0x0f
#endif



typedef struct SceKernelModuleSegmentInfo
{
void *address;
Expand Down Expand Up @@ -34,3 +37,4 @@ typedef void *ScePthreadMutexattr;
typedef uint32_t SceKernelModule;

typedef uint64_t SceKernelEqueue;
typedef struct kevent SceKernelEvent;
40 changes: 40 additions & 0 deletions include/sce/types/pad.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <stdint.h>

typedef struct vec_float3
{
float x;
float y;
float z;
}vec_float3;

typedef struct vec_float4
{
float x;
float y;
float z;
float w;
}vec_float4;

typedef struct ScePadData {
unsigned int buttons;
uint8_t lx;
uint8_t ly;
uint8_t rx;
uint8_t ry;
uint8_t l2;
uint8_t r2;
uint16_t padding;
vec_float4 quat;
vec_float3 vel;
vec_float3 acell;
uint8_t touch[24];
uint8_t connected;
uint64_t timestamp;
uint8_t ext[16];
uint8_t count;
uint8_t unknown[15];
}ScePadData;


6 changes: 6 additions & 0 deletions include/sce/types/userservice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <stdint.h>


typedef int SceUserServiceUserId;
27 changes: 27 additions & 0 deletions include/sce/types/videoout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <stdint.h>


typedef struct SceVideoOutBufferAttribute {
int32_t format;
int32_t tmode;
int32_t aspect;
uint32_t width;
uint32_t height;
uint32_t pixelPitch;
uint64_t reserved[2];
} SceVideoOutBufferAttribute;

typedef struct SceVideoOutFlipStatus {
uint64_t num;
uint64_t ptime;
uint64_t stime;
int64_t flipArg;
uint64_t reserved[2];
int32_t numGpuFlipPending;
int32_t numFlipPending;
int32_t currentBuffer;
uint32_t reserved1;
} SceVideoOutFlipStatus;

7 changes: 7 additions & 0 deletions include/sce/userservice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <stdint.h>
#include <sce/types/userservice.h>
int sceUserServiceInitialize(int *params);
int sceUserServiceTerminate();
int sceUserServiceGetInitialUser(SceUserServiceUserId *userId);
18 changes: 18 additions & 0 deletions include/sce/videoout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <stdint.h>
#include <types/kernel.h>
#include <types/userservice.h>
#include <types/videoout.h>



int sceVideoOutOpen(SceUserServiceUserId userId, int type, int index, const void *param);
int sceVideoOutClose(int handle);
int sceVideoOutRegisterBuffers(int handle, int initialIndex, void * const *addr, int numBuf, const SceVideoOutBufferAttribute *attr);
int sceVideoOutUnregisterBuffers(int handle, int indexAttr);
int sceVideoOutSubmitFlip(int handle, int indexBuf, unsigned int flipMode, int64_t flipArg);
void sceVideoOutSetBufferAttribute(SceVideoOutBufferAttribute *attr, unsigned int format, unsigned int tmode,unsigned int aspect, unsigned int width, unsigned int height, unsigned int pixelPitch);
int sceVideoOutSetFlipRate(int handle, int flipRate);
int sceVideoOutAddFlipEvent(SceKernelEqueue eq, int handle, void *data);
int sceVideoOutGetFlipStatus(int handle, SceVideoOutFlipStatus *status);