First commit of the static lib version.

This commit is contained in:
Maschell 2017-10-29 08:28:11 +01:00
parent 94ba38b005
commit a0e296c0a3
43 changed files with 251 additions and 80 deletions

53
.gitignore vendored
View File

@ -1,50 +1,3 @@
# Windows image file caches libdynamiclibs.cbp
Thumbs.db libdynamiclibs.depend
ehthumbs.db release/*
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Build artifacts
*.o

123
Makefile Normal file
View File

@ -0,0 +1,123 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
endif
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
endif
include $(DEVKITPPC)/wii_rules
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
#---------------------------------------------------------------------------------
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files
# LIBDIR is where the built library will be placed
# all directories are relative to this makefile
#---------------------------------------------------------------------------------
BUILD ?= release
SOURCES := source
INCLUDES := include
DATA :=
LIB := lib
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -Os -Wall -D__wiiu__ $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
ASFLAGS := -g
export WIIUBIN := $(LIB)/libdynamiclibs.a
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS :=
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export TOPDIR ?= $(CURDIR)/..
export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include -I$(PORTLIBS)/include
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(PORTLIBS)/lib
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr debug release $(LIB) include
all: $(WIIUBIN)
install:
@cp $(BUILD)/lib/libdynamiclibs.a $(PORTLIBS)/lib
@mkdir -p $(PORTLIBS)/include/dynamic_libs
@cp source/*.h $(PORTLIBS)/include/dynamic_libs
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(WIIUBIN) : $(OFILES) $(LIB)
@rm -f "$(WIIUBIN)"
@$(AR) rcs "$(WIIUBIN)" $(OFILES)
@echo built ... $(notdir $@)
$(LIB):
mkdir $(LIB)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,2 +1,31 @@
# dynamic_libs # Dynamic libs for WiiU homebrew.
Dynamic libs for WiiU homebrew
## Compiling
Install this static library into your portlibs folder via:
```
make && make install
```
## Usage
To be able to use this library, you need to include the header initialize the OS functions.
```
InitOSFunctionPointers();
```
After that, you can initialize any lib and use their functions. Example:
```
InitVPadFunctionPointers();
InitProcUIFunctionPointers();
```
Check out the header for more information.
# Credits
- Based on the dynamic_libs from dimok.
- Various other

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 acp_handle; extern u32 acp_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 aoc_handle; extern u32 aoc_handle;

View File

@ -21,7 +21,6 @@
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
***************************************************************************/ ***************************************************************************/
#include "common/common.h"
#include "os_functions.h" #include "os_functions.h"
#include "ax_functions.h" #include "ax_functions.h"

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 sound_handle; extern u32 sound_handle;
extern u32 sound_handle_old; extern u32 sound_handle_old;

View File

@ -28,7 +28,8 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
#include "socket_functions.h" #include "socket_functions.h"
typedef int socklen_t; typedef int socklen_t;
#include <curl/curl.h> #include <curl/curl.h>

View File

@ -1,8 +1,6 @@
#ifndef FS_DEFS_H #ifndef FS_DEFS_H
#define FS_DEFS_H #define FS_DEFS_H
#include <gctypes.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
#include "fs_defs.h" #include "fs_defs.h"
void InitFSFunctionPointers(void); void InitFSFunctionPointers(void);

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
#include "gx2_types.h" #include "gx2_types.h"
extern u32 gx2_handle; extern u32 gx2_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
//!----------------------------------------------------------------------------------------------------------------------- //!-----------------------------------------------------------------------------------------------------------------------
//! Constants //! Constants

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 nfp_handle; extern u32 nfp_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 nn_act_handle; extern u32 nn_act_handle;

View File

@ -5,7 +5,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
/* Handle for coreinit */ /* Handle for coreinit */
extern u32 nn_nim_handle; extern u32 nn_nim_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 nn_save_handle; extern u32 nn_save_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 ntag_handle; extern u32 ntag_handle;

25
source/os_defs.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef __OS_DEFS_H_
#define __OS_DEFS_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _OsSpecifics
{
unsigned int addr_OSDynLoad_Acquire;
unsigned int addr_OSDynLoad_FindExport;
unsigned int addr_OSTitle_main_entry;
unsigned int addr_KernSyscallTbl1;
unsigned int addr_KernSyscallTbl2;
unsigned int addr_KernSyscallTbl3;
unsigned int addr_KernSyscallTbl4;
unsigned int addr_KernSyscallTbl5;
} OsSpecifics;
#ifdef __cplusplus
}
#endif
#endif // __OS_DEFS_H_

View File

@ -21,7 +21,6 @@
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
***************************************************************************/ ***************************************************************************/
#include "common/common.h"
#include "os_functions.h" #include "os_functions.h"
u32 coreinit_handle __attribute__((section(".data"))) = 0; u32 coreinit_handle __attribute__((section(".data"))) = 0;

View File

@ -24,14 +24,22 @@
#ifndef __OS_FUNCTIONS_H_ #ifndef __OS_FUNCTIONS_H_
#define __OS_FUNCTIONS_H_ #define __OS_FUNCTIONS_H_
#include <gctypes.h>
#include "common/os_defs.h"
#include "os_types.h" #include "os_types.h"
#include "os_defs.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef MEM_BASE
#define MEM_BASE (0x00800000)
#endif
#define OS_FIRMWARE (*(volatile u32*)(MEM_BASE + 0x1400 + 0x04))
#define OS_SPECIFICS ((OsSpecifics*)(MEM_BASE + 0x1500))
/* Disassembler */ /* Disassembler */
typedef void (*DisasmReport)(char *outputBuffer, ...); typedef void (*DisasmReport)(char *outputBuffer, ...);

View File

@ -5,8 +5,44 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
/*+----------------------------------------------------------------------------------------------+*/
typedef uint8_t u8; ///< 8bit unsigned integer
typedef uint16_t u16; ///< 16bit unsigned integer
typedef uint32_t u32; ///< 32bit unsigned integer
typedef uint64_t u64; ///< 64bit unsigned integer
/*+----------------------------------------------------------------------------------------------+*/
typedef int8_t s8; ///< 8bit signed integer
typedef int16_t s16; ///< 16bit signed integer
typedef int32_t s32; ///< 32bit signed integer
typedef int64_t s64; ///< 64bit signed integer
/*+----------------------------------------------------------------------------------------------+*/
typedef volatile u8 vu8; ///< 8bit unsigned volatile integer
typedef volatile u16 vu16; ///< 16bit unsigned volatile integer
typedef volatile u32 vu32; ///< 32bit unsigned volatile integer
typedef volatile u64 vu64; ///< 64bit unsigned volatile integer
/*+----------------------------------------------------------------------------------------------+*/
typedef volatile s8 vs8; ///< 8bit signed volatile integer
typedef volatile s16 vs16; ///< 16bit signed volatile integer
typedef volatile s32 vs32; ///< 32bit signed volatile integer
typedef volatile s64 vs64; ///< 64bit signed volatile integer
/*+----------------------------------------------------------------------------------------------+*/
// fixed point math typedefs
typedef s16 sfp16; ///< signed 8:8 fixed point
typedef s32 sfp32; ///< signed 20:8 fixed point
typedef u16 ufp16; ///< unsigned 8:8 fixed point
typedef u32 ufp32; ///< unsigned 24:8 fixed point
/*+----------------------------------------------------------------------------------------------+*/
typedef float f32;
typedef double f64;
/*+----------------------------------------------------------------------------------------------+*/
typedef volatile float vf32;
typedef volatile double vf64;
/*+----------------------------------------------------------------------------------------------+*/
#define OS_MESSAGE_NOBLOCK 0 #define OS_MESSAGE_NOBLOCK 0
#define OS_MESSAGE_BLOCK 1 #define OS_MESSAGE_BLOCK 1

View File

@ -28,12 +28,12 @@
extern "C" { extern "C" {
#endif #endif
#include "dynamic_libs/vpad_functions.h" #include "os_types.h"
#include "vpad_functions.h"
extern u32 padscore_handle; extern u32 padscore_handle;
#include <gctypes.h>
#define WPAD_EXT_CORE 0 #define WPAD_EXT_CORE 0
#define WPAD_EXT_NUNCHUK 1 #define WPAD_EXT_NUNCHUK 1
#define WPAD_EXT_CLASSIC 2 #define WPAD_EXT_CLASSIC 2

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 proc_ui_handle; extern u32 proc_ui_handle;

View File

@ -28,9 +28,9 @@
extern "C" { extern "C" {
#endif #endif
extern u32 nsysnet_handle; #include "os_types.h"
#include <gctypes.h> extern u32 nsysnet_handle;
extern u32 hostIpAddress; extern u32 hostIpAddress;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 sysapp_handle; extern u32 sysapp_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 syshid_handle; extern u32 syshid_handle;

View File

@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "os_types.h"
extern u32 vpad_handle; extern u32 vpad_handle;
extern u32 vpadbase_handle; extern u32 vpadbase_handle;