Skip to content
This repository was archived by the owner on Oct 13, 2019. It is now read-only.
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
2 changes: 1 addition & 1 deletion examples/camera/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
8 changes: 0 additions & 8 deletions examples/camera/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
} while(0)

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initNetwork();
initCamera();


// Connect to server and send message
char socketName[] = "debug";

Expand Down
2 changes: 1 addition & 1 deletion examples/canvas/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
6 changes: 0 additions & 6 deletions examples/canvas/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ void *canvasRenderer(void *arg) {
}

int _main(void) {
// Init and resolve libraries
initKernel();

initPthread();


// Create our canvas rendering thread
ScePthread thread;
scePthreadCreate(&thread, NULL, canvasRenderer, NULL, "canvasRenderer");
Expand Down
2 changes: 1 addition & 1 deletion examples/filesystem/directories/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
7 changes: 0 additions & 7 deletions examples/filesystem/directories/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ char *entryName(int entryType) {
}

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initNetwork();


// Connect to server
char socketName[] = "debug";

Expand Down
2 changes: 1 addition & 1 deletion examples/filesystem/files/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
7 changes: 0 additions & 7 deletions examples/filesystem/files/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
} while(0)

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initNetwork();


// Connect to server
char socketName[] = "debug";

Expand Down
2 changes: 1 addition & 1 deletion examples/hello/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
6 changes: 0 additions & 6 deletions examples/hello/source/main.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#include "ps4.h"

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();


// Use getpid system call
int pid = syscall(20);

Expand Down
2 changes: 1 addition & 1 deletion examples/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
7 changes: 0 additions & 7 deletions examples/modules/source/main.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#include "ps4.h"

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initNetwork();


// Connect to debug server
char socketName[] = "debug";

Expand Down
2 changes: 1 addition & 1 deletion examples/pad/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
17 changes: 1 addition & 16 deletions examples/pad/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,7 @@
unsigned char data[512];

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initNetwork();


// Get id of already loaded pad module
int padModule;
loadModule("libScePad.sprx", &padModule);

// Unload it
unloadModule(padModule);

// Start fresh
initPad();
scePadInit();


// Connect to debug server
Expand Down
2 changes: 1 addition & 1 deletion examples/sockets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
7 changes: 0 additions & 7 deletions examples/sockets/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
} while(0)

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initNetwork();


// Connect to server and send message
char socketName[] = "debug";

Expand Down
2 changes: 1 addition & 1 deletion examples/threads/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
6 changes: 0 additions & 6 deletions examples/threads/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ void *thread_func(void *arg) {
}

int _main(void) {
// Init and resolve libraries
initKernel();

initLibc();
initPthread();

int foo = 0;

ScePthread thread;
Expand Down
2 changes: 1 addition & 1 deletion examples/usb/list_devices/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
7 changes: 0 additions & 7 deletions examples/usb/list_devices/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ Device 0
} while(0)

int _main(void) {
// Load modules
initKernel();

initLibc();
initNetwork();
initUsb();

// Init netdebug
struct sockaddr_in server;
server.sin_len = sizeof(server);
Expand Down
2 changes: 1 addition & 1 deletion examples/usb/storage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LIBS := -lPS4
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
7 changes: 0 additions & 7 deletions examples/usb/storage/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,6 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
}

int _main(void) {
// Load modules
initKernel();

initLibc();
initNetwork();
initUsb();

// Init netdebug
struct sockaddr_in server;
server.sin_len = sizeof(server);
Expand Down
2 changes: 1 addition & 1 deletion examples/usb/usbfatfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LIBS := -lPS4 -lusbfatfs
TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(LIBPS4)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(CC) $(LIBPS4)/crt0.c $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

Expand Down
5 changes: 0 additions & 5 deletions examples/usb/usbfatfs/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ int _netdebug_sock;

int _main(void)
{
// Init and resolve libraries
initKernel();
initLibc();
initNetwork();

struct sockaddr_in server;

server.sin_len = sizeof(server);
Expand Down
13 changes: 11 additions & 2 deletions libPS4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ LDIR := lib
CFLAGS := -I$(IDIR) -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
SFLAGS := -nostartfiles -nostdlib -march=btver2 -mtune=btver2
CFILES := $(wildcard $(SDIR)/*.c)
CPPASFILES := $(wildcard $(SDIR)/*.S)
SFILES := $(wildcard $(SDIR)/*.s)
OBJS := $(patsubst $(SDIR)/%.c, build/%.o, $(CFILES)) $(patsubst $(SDIR)/%.s, build/%.o, $(SFILES))
OBJS := $(patsubst $(SDIR)/%.c, build/%.o, $(CFILES)) \
$(patsubst $(SDIR)/%.s, build/%.o, $(SFILES))

TARGET = $(shell basename $(CURDIR)).a

all: $(TARGET)

include import.mk

$(TARGET): $(ODIR) $(OBJS)
$(AR) rcs $@ $(OBJS)

$(ODIR)/%.o: $(SDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS)

$(ODIR)/%.o: $(SDIR)/%.S
$(CC) -c -o $@ $< $(CFLAGS)

$(ODIR)/%.o: $(SDIR)/%.s
$(AS) -c -o $@ $< $(SFLAGS)

Expand All @@ -29,4 +38,4 @@ $(ODIR):
.PHONY: clean

clean:
rm -f $(TARGET) $(ODIR)/*.o
rm -Rf $(TARGET) $(ODIR)/*
48 changes: 48 additions & 0 deletions libPS4/crt0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <module.h>

union module {
const char *s;
int id;
};

extern union module __moduleTop[];
extern union module __moduleBtm[];
extern void *__stubTop[];
extern void *__stubBtm[];

extern union module __libkernel;
int (* sceKernelLoadStartModule)(const char *name,
size_t argc, const void *argv, unsigned int flags, int, int);

int _main(int argc, char *argv[]);

static void loadModules()
{
union module *p;
int id;

loadModule(__libkernel.s, &__libkernel.id);
getFunctionAddressByName(__libkernel.id,
"sceKernelLoadStartModule", sceKernelLoadStartModule);

for (p = __moduleTop; p != __moduleBtm; p++) {
loadModule(p->s, &id);
unloadModule(id);
p->id = sceKernelLoadStartModule(p->s, 0, NULL, 0, 0, 0);
}
}

static void resolveStubs()
{
void **p;

for (p = __stubTop; p != __stubBtm; p += 2)
getFunctionAddressByName(*(int *)(p[0]), p[1], p);
}

int _start(int argc, char *argv[])
{
loadModules();
resolveStubs();
return _main(argc, argv);
}
6 changes: 0 additions & 6 deletions libPS4/crt0.s

This file was deleted.

Loading