mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Trying to make first few steps towards relocations
This commit is contained in:
parent
a8fecf77e1
commit
b39773b1d4
6
buildscripts/Makefile
Normal file
6
buildscripts/Makefile
Normal 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/
|
@ -63,6 +63,7 @@ SECTIONS
|
|||||||
*(.data.*)
|
*(.data.*)
|
||||||
*(.gnu.linkonce.d*)
|
*(.gnu.linkonce.d*)
|
||||||
CONSTRUCTORS
|
CONSTRUCTORS
|
||||||
|
*(.got)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
} : data
|
} : data
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ VERSION := $(LIBNX_MAJOR).$(LIBNX_MINOR).$(LIBNX_PATCH)
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
TARGET := nx
|
TARGET := nx
|
||||||
#BUILD := build
|
#BUILD := build
|
||||||
SOURCES := source
|
SOURCES := source source/srv
|
||||||
|
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := include
|
INCLUDES := include
|
||||||
@ -34,7 +34,7 @@ INCLUDES := include
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ARCH := -march=armv8-a
|
ARCH := -march=armv8-a
|
||||||
|
|
||||||
CFLAGS := -g -Wall -Werror -fPIE \
|
CFLAGS := -g -Wall -Werror -fPIC \
|
||||||
-ffunction-sections \
|
-ffunction-sections \
|
||||||
-fdata-sections \
|
-fdata-sections \
|
||||||
$(ARCH) \
|
$(ARCH) \
|
||||||
|
43
nx/include/switch/ipc.h
Normal file
43
nx/include/switch/ipc.h
Normal 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;
|
||||||
|
}
|
@ -16,5 +16,4 @@
|
|||||||
|
|
||||||
/// Builds a result code from its constituent components.
|
/// Builds a result code from its constituent components.
|
||||||
#define MAKERESULT(module,description) \
|
#define MAKERESULT(module,description) \
|
||||||
((((module)&0x1FF)) | ((description)&0x1FFF)<<9)
|
((((module)&0x1FF)) | ((description)&0x1FFF)<<9)
|
||||||
|
|
||||||
|
@ -12,27 +12,13 @@
|
|||||||
/// Pseudo handle for the current thread
|
/// Pseudo handle for the current thread
|
||||||
#define CUR_THREAD_HANDLE 0xFFFF8000
|
#define CUR_THREAD_HANDLE 0xFFFF8000
|
||||||
|
|
||||||
/**
|
static inline void* armGetTls(void) {
|
||||||
* @brief Gets the thread local storage buffer.
|
void* ret;
|
||||||
* @return The thread local storage buffer.
|
__asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret));
|
||||||
*/
|
return ret;
|
||||||
static inline void* getThreadLocalStorage(void)
|
|
||||||
{
|
|
||||||
void* ret;
|
|
||||||
__asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret));
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
Result svcConnectToNamedPort(Handle* session, const char* name);
|
||||||
* @brief Gets the thread command buffer.
|
|
||||||
* @return The thread command buffer.
|
|
||||||
*/
|
|
||||||
static inline u32* getThreadCommandBuffer(void)
|
|
||||||
{
|
|
||||||
return (u32*)getThreadLocalStorage();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result svcConnectToNamedPort();
|
|
||||||
Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
|
Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
|
||||||
Result svcManageNamedPort(Handle* portServer, const char* name, s32 maxSessions);
|
Result svcManageNamedPort(Handle* portServer, const char* name, s32 maxSessions);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user