Moved OS module back out. Renamed functions.

This commit is contained in:
plutoo 2014-07-28 22:31:20 +02:00
parent 314d53a922
commit ec9734bdeb
5 changed files with 24 additions and 24 deletions

View File

@ -1,7 +0,0 @@
#ifndef OS_H
#define OS_H
u32 OS_ConvertVaddr2Physaddr(u32 vaddr);
#endif

7
libctru/include/3ds/os.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef OS_H
#define OS_H
u32 osConvertVirtToPhys(u32 vaddr);
#endif

14
libctru/source/os.c Normal file
View File

@ -0,0 +1,14 @@
#include <3ds/types.h>
#include <3ds/svc.h>
#include <3ds/os.h>
u32 osConvertVirtToPhys(u32 vaddr)
{
if(vaddr >= 0x14000000 && vaddr < 0x1c000000)
return vaddr + 0x0c000000; // LINEAR heap
if(vaddr >= 0x30000000 && vaddr < 0x40000000)
return vaddr - 0x10000000; // Only available under FIRM v8+ for certain processes.
if(vaddr >= 0x1F000000 && vaddr < 0x1F600000)
return vaddr - 0x07000000; // VRAM
return 0;
}

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <3ds/types.h>
#include <3ds/OS.h>
#include <3ds/os.h>
#include <3ds/svc.h>
#include <3ds/srv.h>
#include <3ds/CSND.h>
@ -283,8 +283,8 @@ Result CSND_playsound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u3
u32 physaddr0 = 0;
u32 physaddr1 = 0;
physaddr0 = OS_ConvertVaddr2Physaddr((u32)vaddr0);
physaddr1 = OS_ConvertVaddr2Physaddr((u32)vaddr1);
physaddr0 = osConvertVirtToPhys((u32)vaddr0);
physaddr1 = osConvertVirtToPhys((u32)vaddr1);
CSND_sharedmemtype0_cmde(channel, looping, encoding, samplerate, unk0, unk1, physaddr0, physaddr1, totalbytesize);
CSND_sharedmemtype0_cmd8(channel, samplerate);

View File

@ -1,14 +0,0 @@
#include <3ds/types.h>
#include <3ds/svc.h>
#include <3ds/OS.h>
u32 OS_ConvertVaddr2Physaddr(u32 vaddr)
{
if(vaddr >= 0x14000000 && vaddr<0x1c000000)return vaddr + 0x0c000000;//LINEAR memory
if(vaddr >= 0x30000000 && vaddr<0x40000000)return vaddr - 0x10000000;//Only available under system-version v8.0 for certain processes, see here: http://3dbrew.org/wiki/SVC#enum_MemoryOperation
if(vaddr >= 0x1F000000 && vaddr<0x1F600000)return vaddr - 0x07000000;//VRAM
return 0;
}