2020-04-19 23:04:05 +02:00
// SPDX-License-Identifier: MPL-2.0
2020-03-27 20:36:02 +01:00
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
2020-09-29 14:46:17 +02:00
# include <android/log.h>
2019-09-24 22:54:27 +02:00
# include "common.h"
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
# include "nce.h"
# include "gpu.h"
2020-01-02 21:19:34 +01:00
# include "audio.h"
2020-04-26 01:34:35 +02:00
# include "input.h"
# include "kernel/types/KThread.h"
2019-09-24 22:54:27 +02:00
namespace skyline {
2020-08-08 21:38:51 +02:00
Logger : : Logger ( const std : : string & path , LogLevel configLevel ) : configLevel ( configLevel ) {
2020-09-29 14:46:17 +02:00
logFile . open ( path , std : : ios : : trunc ) ;
2020-10-28 17:00:39 +01:00
UpdateTag ( ) ;
2019-09-24 22:54:27 +02:00
WriteHeader ( " Logging started " ) ;
}
Logger : : ~ Logger ( ) {
WriteHeader ( " Logging ended " ) ;
2020-04-17 23:19:19 +02:00
logFile . flush ( ) ;
2019-09-24 22:54:27 +02:00
}
2020-10-28 17:00:39 +01:00
thread_local static std : : string logTag , threadName ;
void Logger : : UpdateTag ( ) {
std : : array < char , 16 > name ;
if ( ! pthread_getname_np ( pthread_self ( ) , name . data ( ) , name . size ( ) ) )
2020-11-08 20:54:15 +01:00
threadName = name . data ( ) ;
2020-10-28 17:00:39 +01:00
else
threadName = " unk " ;
logTag = std : : string ( " emu-cpp- " ) + threadName ;
}
2019-09-24 22:54:27 +02:00
void Logger : : WriteHeader ( const std : : string & str ) {
2020-09-29 14:46:17 +02:00
__android_log_write ( ANDROID_LOG_INFO , " emu-cpp " , str . c_str ( ) ) ;
2020-03-25 18:59:37 +01:00
2020-04-17 23:19:19 +02:00
std : : lock_guard guard ( mtx ) ;
2021-02-18 12:46:26 +01:00
logFile < < " \036 0 \035 " < < str < < ' \n ' ;
2019-09-24 22:54:27 +02:00
}
2021-02-18 12:46:26 +01:00
void Logger : : Write ( LogLevel level , const std : : string & str ) {
constexpr std : : array < char , 5 > levelCharacter { ' E ' , ' W ' , ' I ' , ' D ' , ' V ' } ; // The LogLevel as written out to a file
2021-03-04 14:30:14 +01:00
constexpr std : : array < int , 5 > levelAlog { ANDROID_LOG_ERROR , ANDROID_LOG_WARN , ANDROID_LOG_INFO , ANDROID_LOG_DEBUG , ANDROID_LOG_VERBOSE } ; // This corresponds to LogLevel and provides its equivalent for NDK Logging
2020-09-29 14:46:17 +02:00
2020-10-28 17:00:39 +01:00
if ( logTag . empty ( ) )
UpdateTag ( ) ;
__android_log_write ( levelAlog [ static_cast < u8 > ( level ) ] , logTag . c_str ( ) , str . c_str ( ) ) ;
2020-03-25 18:59:37 +01:00
2020-04-17 23:19:19 +02:00
std : : lock_guard guard ( mtx ) ;
2021-02-18 12:46:26 +01:00
logFile < < " \036 1 \035 " < < levelCharacter [ static_cast < u8 > ( level ) ] < < ' \035 ' < < threadName < < ' \035 ' < < str < < ' \n ' ; // We use RS (\036) and GS (\035) as our delimiters
2019-09-24 22:54:27 +02:00
}
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
2020-11-03 10:44:09 +01:00
DeviceState : : DeviceState ( kernel : : OS * os , std : : shared_ptr < JvmManager > jvmManager , std : : shared_ptr < Settings > settings , std : : shared_ptr < Logger > logger )
: os ( os ) , jvm ( std : : move ( jvmManager ) ) , settings ( std : : move ( settings ) ) , logger ( std : : move ( logger ) ) {
2019-12-02 18:40:53 +01:00
// We assign these later as they use the state in their constructor and we don't want null pointers
2020-06-15 17:38:49 +02:00
gpu = std : : make_shared < gpu : : GPU > ( * this ) ;
audio = std : : make_shared < audio : : Audio > ( * this ) ;
2020-11-17 01:48:41 +01:00
nce = std : : make_shared < nce : : NCE > ( * this ) ;
2020-12-05 18:41:52 +01:00
scheduler = std : : make_shared < kernel : : Scheduler > ( * this ) ;
2020-04-26 01:34:35 +02:00
input = std : : make_shared < input : : Input > ( * this ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
}
2019-09-24 22:54:27 +02:00
}