Trying to make first few steps towards relocations

This commit is contained in:
plutoo 2017-09-09 02:48:15 +02:00
parent a8fecf77e1
commit b39773b1d4
6 changed files with 58 additions and 23 deletions

6
buildscripts/Makefile Normal file
View File

@ -0,0 +1,6 @@
install:
cp base_rules $(DEVKITA64)/
cp base_tools $(DEVKITA64)/
cp switch_rules $(DEVKITA64)/
cp lib/switch.ld $(DEVKITA64)/lib/
cp lib/switch.specs $(DEVKITA64)/lib/

View File

@ -63,6 +63,7 @@ SECTIONS
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
*(.got)
. = ALIGN(4);
} : data

View File

@ -24,7 +24,7 @@ VERSION := $(LIBNX_MAJOR).$(LIBNX_MINOR).$(LIBNX_PATCH)
#---------------------------------------------------------------------------------
TARGET := nx
#BUILD := build
SOURCES := source
SOURCES := source source/srv
DATA := data
INCLUDES := include
@ -34,7 +34,7 @@ INCLUDES := include
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a
CFLAGS := -g -Wall -Werror -fPIE \
CFLAGS := -g -Wall -Werror -fPIC \
-ffunction-sections \
-fdata-sections \
$(ARCH) \

43
nx/include/switch/ipc.h Normal file
View File

@ -0,0 +1,43 @@
typedef struct {
size_t NumSend; // A
size_t NumRecv; // B
size_t NumStaticSend; // X
size_t NumStaticRecv; // C
void* Buffers[8];
size_t Sizes[8];
u8 Flags[8];
bool SendPid;
size_t NumHandles;
Handle Handles[8];
} IpcCommand;
static inline void ipcInitialize(IpcCommand* cmd) {
cmd->NumSend = 0;
cmd->NumRecv = 0;
cmd->NumStaticSend = 0;
cmd->NumStaticRecv = 0;
cmd->SendPid = false;
cmd->NumHandles = 0;
}
static inline void ipcAddSendBuffer(IpcCommand* cmd, void* buffer, size_t size, u8 Flags) {
size_t off = cmd->NumSend;
cmd->Buffers[off] = buffer;
cmd->Sizes[off] = size;
cmd->Flags[off] = flags;
cmd->NumSend++;
}
static inline void ipcAddRecvBuffer(IpcCommand* cmd, void* buffer, size_t size, u8 Flags) {
size_t off = cmd->NumSend + cmd->NumRecv;
cmd->Buffers[off] = buffer;
cmd->Sizes[off] = size;
cmd->Flags[off] = flags;
cmd->NumRecv++;
}
static inline void ipcSendPid(IpcCommand* cmd) {
cmd->SendPid = true;
}

View File

@ -16,5 +16,4 @@
/// Builds a result code from its constituent components.
#define MAKERESULT(module,description) \
((((module)&0x1FF)) | ((description)&0x1FFF)<<9)
((((module)&0x1FF)) | ((description)&0x1FFF)<<9)

View File

@ -12,27 +12,13 @@
/// Pseudo handle for the current thread
#define CUR_THREAD_HANDLE 0xFFFF8000
/**
* @brief Gets the thread local storage buffer.
* @return The thread local storage buffer.
*/
static inline void* getThreadLocalStorage(void)
{
void* ret;
__asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret));
return ret;
static inline void* armGetTls(void) {
void* ret;
__asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret));
return ret;
}
/**
* @brief Gets the thread command buffer.
* @return The thread command buffer.
*/
static inline u32* getThreadCommandBuffer(void)
{
return (u32*)getThreadLocalStorage();
}
Result svcConnectToNamedPort();
Result svcConnectToNamedPort(Handle* session, const char* name);
Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
Result svcManageNamedPort(Handle* portServer, const char* name, s32 maxSessions);