]> Chaos Git - console/XDS.git/commitdiff
added HLE
authorichfly <Meier.Hanz@gmx.net>
Sun, 6 Dec 2015 18:15:20 +0000 (19:15 +0100)
committerichfly <Meier.Hanz@gmx.net>
Sun, 6 Dec 2015 18:15:20 +0000 (19:15 +0100)
.gitattributes [new file with mode: 0644]
.gitignore [new file with mode: 0644]
.gitmodules [new file with mode: 0644]
HLE_replacements/DSP/Makefile [new file with mode: 0644]
HLE_replacements/DSP/README.md [new file with mode: 0644]
HLE_replacements/DSP/source/main.c [new file with mode: 0644]
HLE_replacements/DSP/source/svc.h [new file with mode: 0644]
HLE_replacements/DSP/source/svc.s [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.md [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..db38558
--- /dev/null
@@ -0,0 +1,18 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs     diff=csharp
+
+# Standard to msysgit
+*.doc   diff=astextplain
+*.DOC   diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot  diff=astextplain
+*.DOT  diff=astextplain
+*.pdf  diff=astextplain
+*.PDF   diff=astextplain
+*.rtf   diff=astextplain
+*.RTF   diff=astextplain
+
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..f94ef06
--- /dev/null
@@ -0,0 +1,228 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+
+[Dd]ebug/
+[Rr]elease/
+#x64/
+build/
+[Bb]in/
+[Oo]bj/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.log
+*.scc
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+*.ncrunch*
+.*crunch*.local.xml
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.Publish.xml
+*.pubxml
+*.publishproj
+
+# NuGet Packages Directory
+## TODO: If you have NuGet Package Restore enabled, uncomment the next line
+#packages/
+
+# Windows Azure Build Output
+csx
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+sql/
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.[Pp]ublish.xml
+*.pfx
+*.publishsettings
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+App_Data/*.mdf
+App_Data/*.ldf
+
+#############
+## Windows detritus
+#############
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Mac crap
+.DS_Store
+
+
+#############
+## Python
+#############
+
+*.py[cod]
+
+# Packages
+*.egg
+*.egg-info
+dist/
+build/
+eggs/
+parts/
+var/
+sdist/
+develop-eggs/
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+tests/jit/data.bin
+static_recompiler/jit/jit/data.bin
+static_recompiler/jit/data.bin
+xds/code.bin
+xds/*
+*.3dsx
+*.elf
+*.smdh
+windows/xds/*
+include/GL/glcorearb.h
+include/GL/gl3w.h
+*.autosave
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..883ae49
--- /dev/null
@@ -0,0 +1,6 @@
+[submodule "external/imgui"]
+       path = external/imgui
+       url = https://github.com/ocornut/imgui.git
+[submodule "external/gl3w"]
+       path = external/gl3w
+       url = https://github.com/skaslev/gl3w
diff --git a/HLE_replacements/DSP/Makefile b/HLE_replacements/DSP/Makefile
new file mode 100644 (file)
index 0000000..741dd33
--- /dev/null
@@ -0,0 +1,177 @@
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+
+NO_SMDH := "1"
+
+ifeq ($(strip $(DEVKITARM)),)
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
+endif
+
+TOPDIR ?= $(CURDIR)
+include $(DEVKITARM)/3ds_rules
+
+#---------------------------------------------------------------------------------
+# TARGET is the name of the output
+# BUILD is the directory where object files & intermediate files will be placed
+# SOURCES is a list of directories containing source code
+# DATA is a list of directories containing data files
+# INCLUDES is a list of directories containing header files
+#
+# NO_SMDH: if set to anything, no SMDH file is generated.
+# APP_TITLE is the name of the app stored in the SMDH file (Optional)
+# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
+# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
+# ICON is the filename of the icon (.png), relative to the project folder.
+#   If not set, it attempts to use one of the following (in this order):
+#     - <Project name>.png
+#     - icon.png
+#     - <libctru folder>/default_icon.png
+#---------------------------------------------------------------------------------
+TARGET         :=      $(notdir $(CURDIR))
+BUILD          :=      build
+SOURCES                :=      source
+DATA           :=      data
+INCLUDES       :=      include
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+ARCH   :=      -march=armv6k -mtune=mpcore -mfloat-abi=hard
+
+CFLAGS :=      -g -Wall -O2 -mword-relocations \
+                       -fomit-frame-pointer -ffast-math \
+                       $(ARCH)
+
+CFLAGS +=      $(INCLUDE) -DARM11 -D_3DS
+
+CXXFLAGS       := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
+
+ASFLAGS        :=      -g $(ARCH)
+LDFLAGS        =       -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+
+LIBS   := -lctru -lm
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS        := $(CTRULIB)
+
+
+#---------------------------------------------------------------------------------
+# 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 OUTPUT  :=      $(CURDIR)/$(TARGET)
+export TOPDIR  :=      $(CURDIR)
+
+export VPATH   :=      $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
+                       $(foreach dir,$(DATA),$(CURDIR)/$(dir))
+
+export DEPSDIR :=      $(CURDIR)/$(BUILD)
+
+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)/*.*)))
+
+#---------------------------------------------------------------------------------
+# use CXX for linking C++ projects, CC for standard C
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(CPPFILES)),)
+#---------------------------------------------------------------------------------
+       export LD       :=      $(CC)
+#---------------------------------------------------------------------------------
+else
+#---------------------------------------------------------------------------------
+       export LD       :=      $(CXX)
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
+
+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) \
+                       -I$(CURDIR)/$(BUILD)
+
+export LIBPATHS        :=      $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
+
+ifeq ($(strip $(ICON)),)
+       icons := $(wildcard *.png)
+       ifneq (,$(findstring $(TARGET).png,$(icons)))
+               export APP_ICON := $(TOPDIR)/$(TARGET).png
+       else
+               ifneq (,$(findstring icon.png,$(icons)))
+                       export APP_ICON := $(TOPDIR)/icon.png
+               endif
+       endif
+else
+       export APP_ICON := $(TOPDIR)/$(ICON)
+endif
+
+ifeq ($(strip $(NO_SMDH)),)
+       export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
+endif
+
+.PHONY: $(BUILD) clean all
+
+#---------------------------------------------------------------------------------
+all: $(BUILD)
+
+$(BUILD):
+       @[ -d $@ ] || mkdir -p $@
+       @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+clean:
+       @echo clean ...
+       @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
+
+
+#---------------------------------------------------------------------------------
+else
+
+DEPENDS        :=      $(OFILES:.o=.d)
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(NO_SMDH)),)
+$(OUTPUT).3dsx :       $(OUTPUT).elf $(OUTPUT).smdh
+else
+$(OUTPUT).3dsx :       $(OUTPUT).elf
+endif
+
+$(OUTPUT).elf  :       $(OFILES)
+
+#---------------------------------------------------------------------------------
+# you need a rule like this for each extension you use as binary data
+#---------------------------------------------------------------------------------
+%.bin.o        :       %.bin
+#---------------------------------------------------------------------------------
+       @echo $(notdir $<)
+       @$(bin2o)
+
+# WARNING: This is not the right way to do this! TODO: Do it right!
+#---------------------------------------------------------------------------------
+%.vsh.o        :       %.vsh
+#---------------------------------------------------------------------------------
+       @echo $(notdir $<)
+       @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
+       @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
+       @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
+       @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
+       @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
+       @rm ../$(notdir $<).shbin
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------------
diff --git a/HLE_replacements/DSP/README.md b/HLE_replacements/DSP/README.md
new file mode 100644 (file)
index 0000000..8a43ac1
--- /dev/null
@@ -0,0 +1,3 @@
+# template
+
+This is a template for starting new 3DS libctru projects.
diff --git a/HLE_replacements/DSP/source/main.c b/HLE_replacements/DSP/source/main.c
new file mode 100644 (file)
index 0000000..6a13539
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+            Version 2, December 2004
+
+Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+Everyone is permitted to copy and distribute verbatim or modified
+copies of this license document, and changing it is allowed as long
+as the name is changed.
+
+    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. You just DO WHAT THE FUCK YOU WANT TO.
+*/
+
+#include <string.h>
+
+#include <3ds.h>
+
+#include "stdio.h"
+
+#include "svc.h"
+Result srvRegisterService(Handle* out, const char* name, int maxSessions);
+
+extern char* fake_heap_start;
+extern char* fake_heap_end;
+extern u32 __linear_heap;
+extern u32 __heapBase;
+extern u32 __heap_size, __linear_heap_size;
+void __system_allocateHeaps();
+void stub(u32* cmdbuf);
+
+void __system_allocateHeaps() {
+        u32 tmp=0;
+
+        // Allocate the application heap
+        __heapBase = 0x08000000;
+        svcControlMemory(&tmp, __heapBase, 0x0, 0x10000, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
+
+        // Allocate the linear heap
+        svcControlMemory(&__linear_heap, 0x0, 0x0, 0x10000, MEMOP_ALLOC_LINEAR, MEMPERM_READ | MEMPERM_WRITE);
+        // Set up newlib heap
+        fake_heap_start = (char*)__heapBase;
+        fake_heap_end = fake_heap_start + 0x10000;
+
+}
+
+void __appInit() {
+        // Initialize services
+        srvInit();
+}
+void __libctru_init(void (*retAddr)(void))
+{
+    __system_allocateHeaps();
+}
+void  __attribute__((noreturn)) __libctru_exit(int rc)
+{
+        svcExitProcess();
+}
+void __appExit() {
+        // Exit services
+        srvExit();
+}
+typedef void (*cmdHandlerFunction)(u32* cmdbuf);
+
+
+#define NUM_CMD (0x21)
+void ConvertProcessAddressFromDspDram(u32* cmdbuf);
+void ReadPipeIfPossible(u32* cmdbuf);
+void LoadComponent(u32* cmdbuf);
+void GetVirtualAddress(u32* cmdbuf);
+void GetHeadphoneStatus(u32* cmdbuf);
+void RegisterInterruptEvents(u32* cmdbuf);
+void GetSemaphoreEventHandle(u32* cmdbuf);
+cmdHandlerFunction commandHandlers[NUM_CMD]={
+    stub,//RecvData,
+    stub,//RecvDataIsReady,
+    stub,//SendData ,
+    stub,//SendDataIsEmpty,
+    stub,//SendFifoEx,
+    stub,//RecvFifoEx,
+    stub,//WriteReg0x10,
+    stub,//GetSemaphore,
+    stub,//ClearSemaphore,
+    stub,//MaskSemaphore,
+    stub,//CheckSemaphoreRequest,
+    ConvertProcessAddressFromDspDram  ,
+    stub,//WriteProcessPipe  ,
+    stub,//ReadPipe,
+    stub,//GetPipeReadableSize,
+    ReadPipeIfPossible ,
+    LoadComponent,
+    stub,//UnloadComponent  ,
+    stub,//FlushDataCache  ,
+    stub,//InvalidateDCache  ,
+    RegisterInterruptEvents,
+    GetSemaphoreEventHandle  ,
+    stub,//SetSemaphoreMask  ,
+    stub,//GetPhysicalAddress,
+    GetVirtualAddress ,
+    stub,//SetIirFilterI2S1,
+    stub,//SetIirFilterI2S2,
+    stub,//SetIirFilterEQ,
+    stub,//ReadMultiEx_SPI2,
+    stub,//WriteMultiEx_SPI2,
+    GetHeadphoneStatus,
+    stub,//ForceHeadphoneOut,
+    stub//GetIsDspOccupied
+
+};
+
+
+u8 data = 0;
+u32 sessionHandles[7];
+u32 currentHandleIndex = 2;
+u32 numSessionHandles = 2;
+
+u32 event;
+u32 myeventhandel = 0;
+int main()
+{
+    consoleDebugInit(debugDevice_3DMOO);
+    fprintf(stderr,"DSP MODULE LIVE");
+    memset(sessionHandles,0,sizeof(sessionHandles));
+
+    srvRegisterService(&sessionHandles[0], "dsp::DSP", 4);
+
+    svcCreateTimer(&sessionHandles[1],0);
+    svc_SetTimer(sessionHandles[1],0,40000000);
+
+    svcCreateEvent(&event,1);
+
+    u32 ret = 0;
+    while(1)
+    {
+            ret=svc_replyAndReceive((s32*)&currentHandleIndex, sessionHandles, numSessionHandles, sessionHandles[currentHandleIndex]);
+            if(ret==0xc920181a)
+            {
+                    //close session handle
+                    svcCloseHandle(sessionHandles[currentHandleIndex]);
+                    sessionHandles[currentHandleIndex]=sessionHandles[numSessionHandles];
+                    sessionHandles[numSessionHandles]=0x0;
+                    currentHandleIndex=numSessionHandles--; //we want to have replyTarget=0x0
+            }else{
+                    switch(currentHandleIndex)
+                    {
+                            case 0:
+                                    {
+                                            // receiving new session
+                                            svc_acceptSession(&sessionHandles[numSessionHandles], sessionHandles[currentHandleIndex]);
+                                            numSessionHandles++;
+                                            currentHandleIndex = numSessionHandles;
+                                            sessionHandles[currentHandleIndex] = 0; //we want to have replyTarget=0x0
+                                    }
+                                    break;
+                            case 1:
+                            {
+                                    //send event at some points
+                                    if(myeventhandel)
+                                    {
+                                        svcSignalEvent(myeventhandel);
+                                    }
+                                    currentHandleIndex = numSessionHandles;
+                                    sessionHandles[currentHandleIndex] = 0; //we want to have replyTarget=0x0
+                            }
+                            break;
+                            default:
+                                    {
+                                            //receiving command from ongoing session
+                                            u32* cmdbuf=getThreadCommandBuffer();
+                                            u8 cmdIndex=cmdbuf[0]>>16;
+                                            if(cmdIndex<=NUM_CMD && cmdIndex>0)
+                                            {
+                                                    commandHandlers[cmdIndex-1](cmdbuf);
+                                            }
+                                            else
+                                            {
+                                                    cmdbuf[0] = (cmdbuf[0] & 0x00FF0000) | 0x40;
+                                                    cmdbuf[1] = 0xFFFFFFFF;
+                                            }
+                                    }
+                                    break;
+                    }
+            }
+    }
+
+    return 0;
+}
+
+
+static u32 ReadPipeIfPossibleCount = 0;
+u32 ReadPipeIfPossibleResp[] = {
+    0x000F, //Number of responses
+    0xBFFF,
+    0x9E8E,
+    0x8680,
+    0xA78E,
+    0x9430,
+    0x8400,
+    0x8540,
+    0x948E,
+    0x8710,
+    0x8410,
+    0xA90E,
+    0xAA0E,
+    0xAACE,
+    0xAC4E,
+    0xAC58
+};
+
+#define DSPramaddr 0x1FF00000
+
+
+
+
+//the real stuff
+
+void stub(u32* cmdbuf)
+{
+    fprintf(stderr,"NOT IMPLEMENTED, cid=%08x\n", cmdbuf[0]);
+    //just respond with SUCESS and nothing else
+    cmdbuf[0]=(cmdbuf[0] & 0x00FF0000) | 0x40;
+    cmdbuf[1]=0x00000000;
+}
+void LoadComponent(u32* cmdbuf)
+{
+    cmdbuf[0]= 0x00110080;
+    cmdbuf[1]= 0x00000000;
+    cmdbuf[2]= 0x00000001;
+}
+void RegisterInterruptEvents(u32* cmdbuf)
+{
+    if(cmdbuf[0] != 0x00150082)
+    {
+        cmdbuf[0]= 0x00150040;
+        cmdbuf[1]= 0xFFFFFFFF;
+        return;
+    }
+    myeventhandel = cmdbuf[4];
+    cmdbuf[0]= 0x00150040;
+    cmdbuf[1]= 0x00000000;
+}
+void GetSemaphoreEventHandle(u32* cmdbuf)
+{
+    cmdbuf[0]= 0x00160042;
+    cmdbuf[1]= 0x00000000; //Sucess
+    cmdbuf[2]= 0x00000000; //duplicate
+    cmdbuf[3]= event;
+}
+u16 buffer[0x100];
+void ReadPipeIfPossible(u32* cmdbuf)
+{
+    u32 i = 0;
+    u32 unk1 = cmdbuf[1];
+    u32 unk2 = cmdbuf[2];
+    u32 size = cmdbuf[3] & 0xFFFF;
+    u32 initialSize = ReadPipeIfPossibleCount;
+
+    for (i = 0; i < size; i += 2) {
+        if (ReadPipeIfPossibleCount < 16) {
+            *(buffer + i/2) = ReadPipeIfPossibleResp[ReadPipeIfPossibleCount];
+        }
+        ReadPipeIfPossibleCount++;
+    }
+    cmdbuf[0] = 0x00100082;
+    cmdbuf[1] = 0; //no error
+    cmdbuf[2] = (ReadPipeIfPossibleCount - initialSize) * 2; //no error
+    cmdbuf[3] = 0x00000002 | (cmdbuf[2] << 14);
+    cmdbuf[4] = buffer;
+
+}
+
+void ConvertProcessAddressFromDspDram(u32* cmdbuf)
+{
+    u32 addrin = cmdbuf[1];
+    cmdbuf[0]= 0x000c0080;
+    cmdbuf[1]= 0x00000000;
+    cmdbuf[2]= DSPramaddr + addrin*2 + 0x40000;
+}
+void GetVirtualAddress(u32* cmdbuf)
+{
+    u32 addr = cmdbuf[1];
+    u32 ret = 0;
+    if ((addr & 0xF8000000) == 0x20000000) ret = 0x14000000 + addr - 0x20000000;
+    if ((addr & 0xFFF80000) == 0x1FF00000) ret = addr;
+
+    cmdbuf[0]= 0x00190080;
+    cmdbuf[1]= 0x00000000;
+    cmdbuf[2]= ret;
+}
+void GetHeadphoneStatus(u32* cmdbuf)
+{
+    cmdbuf[0]= 0x001F0080;
+    cmdbuf[1]= 0x00000000;
+    cmdbuf[2]= 0x00000000;
+}
diff --git a/HLE_replacements/DSP/source/svc.h b/HLE_replacements/DSP/source/svc.h
new file mode 100644 (file)
index 0000000..ff7b655
--- /dev/null
@@ -0,0 +1,10 @@
+#pragma once
+
+Result svc_acceptSession(Handle* session, Handle port);
+Result svc_replyAndReceive(s32* index, Handle* handles, s32 handleCount, Handle replyTarget);
+
+Result svc_controlProcessMemory(Handle KProcess, unsigned int Addr0, unsigned int Addr1, unsigned int Size, unsigned int Type, unsigned int Permissions);
+Result svc_mapProcessMemory(Handle KProcess, unsigned int StartAddr, unsigned int EndAddr);
+Result svc_unmapProcessMemory(Handle KProcess, unsigned int StartAddr, unsigned int EndAddr);
+
+Result svc_SetTimer(Handle Hand, s64 init,s64 inter);
diff --git a/HLE_replacements/DSP/source/svc.s b/HLE_replacements/DSP/source/svc.s
new file mode 100644 (file)
index 0000000..db23507
--- /dev/null
@@ -0,0 +1,56 @@
+.arm
+
+.align 4
+
+.global svc_controlProcessMemory
+.type svc_controlProcessMemory, %function
+svc_controlProcessMemory:
+       stmfd sp!, {r4, r5}
+       ldr r4, [sp, #0x8]
+       ldr r5, [sp, #0xC]
+       svc 0x70
+       ldmfd sp!, {r4, r5}
+       bx lr
+
+.global svc_mapProcessMemory
+.type svc_mapProcessMemory, %function
+svc_mapProcessMemory:
+       svc 0x71
+       bx lr
+
+.global svc_unmapProcessMemory
+.type svc_unmapProcessMemory, %function
+svc_unmapProcessMemory:
+       svc 0x72
+       bx lr
+
+.global svc_replyAndReceive
+.type svc_replyAndReceive, %function
+svc_replyAndReceive:
+              STR   R0, [SP,#-4]!
+              SVC   0x4F
+              LDR   R2, [SP]
+              STR   R1, [R2]
+              ADD   SP, SP, #4
+              BX    LR
+
+
+.global svc_acceptSession
+.type svc_acceptSession, %function
+svc_acceptSession:
+              STR   R0, [SP,#-4]!
+              SVC   0x4A
+              LDR   R2, [SP]
+              STR   R1, [R2]
+              ADD   SP, SP, #4
+              BX    LR
+
+.global svc_SetTimer
+.type svc_SetTimer, %function
+svc_SetTimer:
+              stmfd sp!, {r4, r5}
+              LDR   R1, [SP,#0x8]
+              LDR   R4, [SP,#0xC]
+              SVC   0x1B
+              ldmfd sp!, {r4, r5}
+              BX    LR
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..e81aa1d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,34 @@
+TEST_DEFS   := -DXDS_TEST
+
+ARM_FILES := source/arm/dyncom/*.cpp source/arm/interpreter/*.cpp source/arm/skyeye_common/vfp/vfpdouble.cpp source/arm/skyeye_common/vfp/vfp.cpp source/arm/skyeye_common/vfp/vfpsingle.cpp source/arm/disassembler/*.cpp
+ARM_FLAGS := -Isource/
+KERNEL_FILES := source/kernel/*.cpp
+HARDWARE_FILES := source/hardware/*.cpp
+PROCESS9_FILES := source/process9/*.cpp source/process9/archive/*.cpp
+UTIL_FILES := source/util/*.cpp
+
+
+COMMON_FILES := source/Bootloader.cpp source/arm/*.cpp $(ARM_FILES) $(KERNEL_FILES) $(HARDWARE_FILES) $(PROCESS9_FILES) $(UTIL_FILES)
+
+
+BUILD_FLAGS := -Iinclude -g --std=c++11 $(ARM_FLAGS) -lpthread
+
+main:
+       g++ -o xds source/Main.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+
+test:
+       g++ -o xds_test_memorymap tests/kernel/MemoryMap.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+       g++ -o xds_test_handletable tests/kernel/HandleTable.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+       g++ -o xds_test_linkedlist tests/kernel/LinkedList.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+       g++ -o xds_test_resourcelimit tests/kernel/ResourceLimit.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+       g++ -o xds_test_mutex tests/util/Mutex.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+
+runtests:
+       ./xds_test_memorymap
+       ./xds_test_handletable
+       ./xds_test_linkedlist
+       ./xds_test_resourcelimit
+       ./xds_test_mutex
+
+clean:
+       rm ./xds ./xds_test_memorymap ./xds_test_handletable ./xds_test_linkedlist ./xds_test_resourcelimit ./xds_test_mutex
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..af9ea32
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+xds; Gör om, gör rätt.