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/)
2019-09-24 22:54:27 +02:00
# pragma once
# include <map>
# include <unordered_map>
2020-09-05 01:06:07 +02:00
# include <span>
2019-09-24 22:54:27 +02:00
# include <vector>
# include <fstream>
2020-01-09 02:37:54 +01:00
# include <mutex>
2020-09-25 16:35:10 +02:00
# include <functional>
2020-02-01 16:51:32 +01:00
# include <thread>
2019-09-24 22:54:27 +02:00
# include <string>
# include <cstdint>
# include <stdexcept>
# include <string>
2020-09-17 22:38:23 +02:00
# include <sstream>
# include <memory>
# include <syslog.h>
# include <sys/mman.h>
# include <fmt/format.h>
# include <frozen/unordered_map.h>
# include <frozen/string.h>
2019-12-02 18:40:53 +01:00
# include <jni.h>
2020-01-07 03:36:08 +01:00
# include "nce/guest_common.h"
2019-09-24 22:54:27 +02:00
namespace skyline {
2020-09-17 22:38:23 +02:00
namespace frz = frozen ;
2020-03-25 18:59:37 +01:00
using KHandle = u32 ; //!< The type of a kernel handle
2019-09-24 22:54:27 +02:00
2020-09-03 20:43:52 +02:00
/**
* @ brief The result of an operation in HOS
* @ url https : //switchbrew.org/wiki/Error_codes
*/
union Result {
u32 raw { } ;
2020-09-07 18:39:05 +02:00
struct __attribute__ ( ( packed ) ) {
2020-09-03 20:43:52 +02:00
u16 module : 9 ;
u16 id : 12 ;
} ;
/**
* @ note Success is 0 , 0 - it is the only error that ' s not specific to a module
*/
2020-09-07 18:39:05 +02:00
Result ( ) = default ;
2020-09-03 20:43:52 +02:00
constexpr Result ( u16 module , u16 id ) {
this - > module = module ;
this - > id = id ;
}
constexpr operator u32 ( ) const {
return raw ;
}
} ;
2019-09-24 22:54:27 +02:00
namespace constant {
// Memory
2020-09-26 07:17:57 +02:00
constexpr u64 BaseAddress { 0x8000000 } ; //!< The address space base
constexpr u64 DefStackSize { 0x1E8480 } ; //!< The default amount of stack: 2 MB
2020-03-25 18:59:37 +01:00
// Display
2020-09-26 07:17:57 +02:00
constexpr u16 HandheldResolutionW { 1280 } ; //!< The width component of the handheld resolution
constexpr u16 HandheldResolutionH { 720 } ; //!< The height component of the handheld resolution
constexpr u16 DockedResolutionW { 1920 } ; //!< The width component of the docked resolution
constexpr u16 DockedResolutionH { 1080 } ; //!< The height component of the docked resolution
2020-04-22 19:02:27 +02:00
// Time
2020-09-28 12:05:17 +02:00
constexpr u64 NsInSecond { 1000000000 } ; //!< The amount of nanoseconds in a second
2020-09-14 15:53:40 +02:00
}
/**
2020-09-28 12:05:17 +02:00
* @ brief A wrapper over std : : runtime_error with libfmt formatting
2020-09-14 15:53:40 +02:00
*/
class exception : public std : : runtime_error {
public :
/**
* @ param formatStr The exception string to be written , with libfmt formatting
* @ param args The arguments based on format_str
*/
template < typename S , typename . . . Args >
inline exception ( const S & formatStr , Args & & . . . args ) : runtime_error ( fmt : : format ( formatStr , args . . . ) ) { }
2019-09-24 22:54:27 +02:00
} ;
2020-04-17 23:19:19 +02:00
namespace util {
2020-01-21 08:16:57 +01:00
/**
* @ brief Returns the current time in nanoseconds
* @ return The current time in nanoseconds
*/
2020-02-05 19:37:45 +01:00
inline u64 GetTimeNs ( ) {
2020-02-11 07:34:22 +01:00
static u64 frequency { } ;
if ( ! frequency )
asm ( " MRS %0, CNTFRQ_EL0 " : " =r " ( frequency ) ) ;
2020-02-05 19:37:45 +01:00
u64 ticks ;
asm ( " MRS %0, CNTVCT_EL0 " : " =r " ( ticks ) ) ;
2020-04-22 19:02:27 +02:00
return ( ( ticks / frequency ) * constant : : NsInSecond ) + ( ( ( ticks % frequency ) * constant : : NsInSecond + ( frequency / 2 ) ) / frequency ) ;
2020-01-21 08:16:57 +01:00
}
2020-04-30 23:53:45 +02:00
/**
* @ brief Returns the current time in arbitrary ticks
* @ return The current time in ticks
*/
inline u64 GetTimeTicks ( ) {
u64 ticks ;
asm ( " MRS %0, CNTVCT_EL0 " : " =r " ( ticks ) ) ;
return ticks ;
}
2020-01-21 08:16:57 +01:00
/**
2020-09-25 02:05:12 +02:00
* @ return The value aligned up to the next multiple
2020-09-25 16:35:10 +02:00
* @ note The multiple needs to be a power of 2
2020-01-21 08:16:57 +01:00
*/
2020-02-05 19:37:45 +01:00
template < typename TypeVal , typename TypeMul >
2020-09-28 12:05:17 +02:00
constexpr TypeVal AlignUp ( TypeVal value , TypeMul multiple ) {
2020-03-24 21:17:31 +01:00
multiple - - ;
return ( value + multiple ) & ~ ( multiple ) ;
2020-01-21 08:16:57 +01:00
}
/**
2020-09-25 02:05:12 +02:00
* @ return The value aligned down to the previous multiple
2020-09-25 16:35:10 +02:00
* @ note The multiple needs to be a power of 2
2020-01-21 08:16:57 +01:00
*/
2020-02-05 19:37:45 +01:00
template < typename TypeVal , typename TypeMul >
2020-09-28 12:05:17 +02:00
constexpr TypeVal AlignDown ( TypeVal value , TypeMul multiple ) {
2020-02-15 10:38:17 +01:00
return value & ~ ( multiple - 1 ) ;
2020-01-21 08:16:57 +01:00
}
2020-02-01 16:51:32 +01:00
/**
2020-04-22 19:02:27 +02:00
* @ return If the address is aligned with the multiple
2020-02-01 16:51:32 +01:00
*/
2020-09-20 21:46:26 +02:00
template < typename TypeVal , typename TypeMul >
2020-09-28 12:05:17 +02:00
constexpr bool IsAligned ( TypeVal value , TypeMul multiple ) {
2020-09-20 21:46:26 +02:00
if ( ( multiple & ( multiple - 1 ) ) = = 0 )
return ! ( value & ( multiple - 1U ) ) ;
else
return ( value % multiple ) = = 0 ;
2020-01-21 08:16:57 +01:00
}
2020-02-01 16:51:32 +01:00
/**
2020-04-22 19:02:27 +02:00
* @ return If the value is page aligned
2020-02-01 16:51:32 +01:00
*/
2020-09-28 12:05:17 +02:00
constexpr bool PageAligned ( u64 value ) {
2020-04-22 19:02:27 +02:00
return IsAligned ( value , PAGE_SIZE ) ;
}
/**
* @ return If the value is word aligned
*/
2020-09-28 12:05:17 +02:00
constexpr bool WordAligned ( u64 value ) {
2020-04-22 19:02:27 +02:00
return IsAligned ( value , WORD_BIT / 8 ) ;
2020-02-01 16:51:32 +01:00
}
2020-04-17 23:19:19 +02:00
/**
* @ param string The string to create a magic from
* @ return The magic of the supplied string
*/
template < typename Type >
constexpr Type MakeMagic ( std : : string_view string ) {
Type object { } ;
2020-09-26 07:17:57 +02:00
size_t offset { } ;
2020-04-17 23:19:19 +02:00
2020-04-18 23:40:18 +02:00
for ( auto & character : string ) {
2020-04-17 23:19:19 +02:00
object | = static_cast < Type > ( character ) < < offset ;
offset + = sizeof ( character ) * 8 ;
}
return object ;
}
2020-09-14 15:53:40 +02:00
constexpr u8 HexDigitToByte ( char digit ) {
if ( digit > = ' 0 ' & & digit < = ' 9 ' )
return digit - ' 0 ' ;
else if ( digit > = ' a ' & & digit < = ' f ' )
return digit - ' a ' + 10 ;
else if ( digit > = ' A ' & & digit < = ' F ' )
return digit - ' A ' + 10 ;
throw exception ( fmt : : format ( " Invalid hex char {} " , digit ) ) ;
}
template < size_t Size >
2020-09-19 16:45:17 +02:00
constexpr std : : array < u8 , Size > HexStringToArray ( std : : string_view hexString ) {
2020-09-14 15:53:40 +02:00
if ( hexString . size ( ) ! = Size * 2 )
throw exception ( " Invalid size " ) ;
std : : array < u8 , Size > result ;
2020-09-25 16:35:10 +02:00
for ( size_t i { } ; i < Size ; i + + ) {
2020-09-14 15:53:40 +02:00
size_t hexStrIndex { i * 2 } ;
result [ i ] = ( HexDigitToByte ( hexString [ hexStrIndex ] ) < < 4 ) | HexDigitToByte ( hexString [ hexStrIndex + 1 ] ) ;
}
return result ;
}
2020-09-17 22:38:23 +02:00
2020-09-25 02:05:12 +02:00
/**
* @ brief A compile - time hash function as std : : hash isn ' t constexpr
*/
2020-09-19 16:45:17 +02:00
constexpr std : : size_t Hash ( std : : string_view view ) {
2020-09-17 22:38:23 +02:00
return frz : : elsa < frz : : string > { } ( frz : : string ( view . data ( ) , view . size ( ) ) , 0 ) ;
}
2020-09-25 02:05:12 +02:00
}
/**
* @ brief A custom wrapper over span that adds several useful methods to it
* @ note This class is completely transparent , it implicitly converts from and to span
*/
template < typename T , size_t Extent = std : : dynamic_extent >
class span : public std : : span < T , Extent > {
public :
using std : : span < T , Extent > : : span ;
using std : : span < T , Extent > : : operator = ;
typedef typename std : : span < T , Extent > : : element_type elementType ;
typedef typename std : : span < T , Extent > : : index_type indexType ;
constexpr span ( const std : : span < T , Extent > & spn ) : std : : span < T , Extent > ( spn ) { }
/**
* @ brief We want to support implicitly casting from std : : string_view - > span as it is just a specialization of a data view which span is a generic form of , the opposite doesn ' t hold true as not all data held by a span is string data therefore the conversion isn ' t implicit there
*/
template < class Traits >
constexpr span ( const std : : basic_string_view < T , Traits > & string ) : std : : span < T , Extent > ( const_cast < T * > ( string . data ( ) ) , string . size ( ) ) { }
template < typename Out >
constexpr Out & as ( ) {
if ( span : : size_bytes ( ) > = sizeof ( Out ) )
return * reinterpret_cast < Out * > ( span : : data ( ) ) ;
throw exception ( " Span size is less than Out type size (0x{:X}/0x{:X}) " , span::size_bytes(), sizeof(Out)) ;
}
2020-09-19 16:45:17 +02:00
2020-09-25 02:05:12 +02:00
constexpr std : : string_view as_string ( indexType length = 0 ) {
return std : : string_view ( reinterpret_cast < char * > ( span : : data ( ) ) , length ? length : span : : size_bytes ( ) ) ;
2020-09-19 16:45:17 +02:00
}
2020-09-25 02:05:12 +02:00
template < typename Out , size_t OutExtent = std : : dynamic_extent >
constexpr span < Out > cast ( ) {
if ( util : : IsAligned ( span : : size_bytes ( ) , sizeof ( Out ) ) )
return span < Out , OutExtent > ( reinterpret_cast < Out * > ( span : : data ( ) ) , span : : size_bytes ( ) / sizeof ( Out ) ) ;
throw exception ( " Span size not aligned with Out type size (0x{:X}/0x{:X}) " , span::size_bytes(), sizeof(Out)) ;
2020-09-19 16:45:17 +02:00
}
2020-09-25 02:05:12 +02:00
/**
* @ brief Copies data from the supplied span into this one
* @ param amount The amount of elements that need to be copied ( in terms of the supplied span ) , 0 will try to copy the entirety of the other span
*/
template < typename In , size_t InExtent >
constexpr void copy_from ( const span < In , InExtent > spn , indexType amount = 0 ) {
auto size { amount ? amount * sizeof ( In ) : spn . size_bytes ( ) } ;
if ( span : : size_bytes ( ) < size )
throw exception ( " Data being copied is larger than this span " ) ;
std : : memmove ( span : : data ( ) , spn . data ( ) , size ) ;
}
/**
* @ brief Implicit type conversion for copy_from , this allows passing in std : : vector / std : : array in directly is automatically passed by reference which is important for any containers
*/
template < typename In >
constexpr void copy_from ( const In & in , indexType amount = 0 ) {
copy_from ( span < typename std : : add_const < typename In : : value_type > : : type > ( in ) , amount ) ;
}
/** Base Class Functions that return an instance of it, we upcast them **/
template < size_t Count >
constexpr span < T , Count > first ( ) const noexcept {
return std : : span < T , Extent > : : template first < Count > ( ) ;
}
template < size_t Count >
constexpr span < T , Count > last ( ) const noexcept {
return std : : span < T , Extent > : : template last < Count > ( ) ;
}
constexpr span < elementType , std : : dynamic_extent > first ( indexType count ) const noexcept {
return std : : span < T , Extent > : : first ( count ) ;
}
constexpr span < elementType , std : : dynamic_extent > last ( indexType count ) const noexcept {
return std : : span < T , Extent > : : last ( count ) ;
}
template < size_t Offset , size_t Count = std : : dynamic_extent >
constexpr auto subspan ( ) const noexcept - > span < T , Count ! = std : : dynamic_extent ? Count : Extent - Offset > {
return std : : span < T , Extent > : : template subspan < Offset , Count > ( ) ;
}
constexpr span < T , std : : dynamic_extent > subspan ( indexType offset , indexType count = std : : dynamic_extent ) const noexcept {
return std : : span < T , Extent > : : subspan ( offset , count ) ;
}
} ;
/**
* @ brief Deduction guides required for arguments to span , CTAD will fail for iterators , arrays and containers without this
*/
template < class It , class End , size_t Extent = std : : dynamic_extent >
span ( It , End ) - > span < typename std : : iterator_traits < It > : : value_type , Extent > ;
template < class T , size_t Size >
span ( T ( & ) [ Size ] ) - > span < T , Size > ;
template < class T , size_t Size >
span ( std : : array < T , Size > & ) - > span < T , Size > ;
template < class T , size_t Size >
span ( const std : : array < T , Size > & ) - > span < const T , Size > ;
template < class Container >
span ( Container & ) - > span < typename Container : : value_type > ;
template < class Container >
span ( const Container & ) - > span < const typename Container : : value_type > ;
2020-01-21 08:16:57 +01:00
2019-09-24 22:54:27 +02:00
/**
2020-09-28 12:05:17 +02:00
* @ brief The Mutex class is a wrapper around an atomic bool used for low - contention synchronization
2019-12-26 19:10:29 +01:00
*/
class Mutex {
2020-01-07 03:36:08 +01:00
std : : atomic_flag flag = ATOMIC_FLAG_INIT ; //!< An atomic flag to hold the state of the mutex
2019-12-26 19:10:29 +01:00
public :
/**
* @ brief Wait on and lock the mutex
*/
void lock ( ) ;
/**
2020-01-11 05:52:25 +01:00
* @ brief Try to lock the mutex if it is unlocked else return
2019-12-26 19:10:29 +01:00
* @ return If the mutex was successfully locked or not
*/
2020-02-01 16:51:32 +01:00
inline bool try_lock ( ) {
return ! flag . test_and_set ( std : : memory_order_acquire ) ;
}
2019-12-26 19:10:29 +01:00
/**
* @ brief Unlock the mutex if it is held by this thread
*/
2020-02-01 16:51:32 +01:00
inline void unlock ( ) {
flag . clear ( std : : memory_order_release ) ;
}
2019-12-26 19:10:29 +01:00
} ;
2020-01-11 05:52:25 +01:00
/**
* @ brief The GroupMutex class is a special type of mutex that allows two groups of users and only allows one group to run in parallel
*/
class GroupMutex {
public :
/**
2020-09-28 12:05:17 +02:00
* @ brief All the possible owners of the mutex
2020-01-11 05:52:25 +01:00
*/
enum class Group : u8 {
2020-09-28 12:05:17 +02:00
None = 0 , //!< No group owns this mutex
2020-01-11 05:52:25 +01:00
Group1 = 1 , //!< Group 1 owns this mutex
2020-09-28 12:05:17 +02:00
Group2 = 2 , //!< Group 2 owns this mutex
2020-01-11 05:52:25 +01:00
} ;
/**
* @ brief Wait on and lock the mutex
*/
void lock ( Group group = Group : : Group1 ) ;
/**
* @ brief Unlock the mutex
* @ note Undefined behavior in case unlocked by thread in non - owner group
*/
void unlock ( ) ;
private :
2020-02-15 10:38:17 +01:00
std : : atomic < Group > flag { Group : : None } ; //!< An atomic flag to hold which group holds the mutex
std : : atomic < Group > next { Group : : None } ; //!< An atomic flag to hold which group will hold the mutex next
2020-09-26 07:17:57 +02:00
std : : atomic < u8 > num { } ; //!< An atomic u8 keeping track of how many users are holding the mutex
2020-02-11 07:34:22 +01:00
Mutex mtx ; //!< A mutex to lock before changing of num and flag
2020-01-11 05:52:25 +01:00
} ;
2019-12-26 19:10:29 +01:00
/**
* @ brief The Logger class is to write log output to file and logcat
2019-09-24 22:54:27 +02:00
*/
class Logger {
private :
std : : ofstream logFile ; //!< An output stream to the log file
2020-09-28 12:05:17 +02:00
std : : array < char , 4 > levelCharacter { ' 0 ' , ' 1 ' , ' 2 ' , ' 3 ' } ; //!< The LogLevel as written out to a file
static constexpr std : : array < int , 4 > levelSyslog { LOG_ERR , LOG_WARNING , LOG_INFO , LOG_DEBUG } ; //!< This corresponds to LogLevel and provides it's equivalent for syslog
2020-04-17 23:19:19 +02:00
Mutex mtx ; //!< A mutex to lock before logging anything
2019-09-24 22:54:27 +02:00
public :
2020-09-28 12:05:17 +02:00
enum class LogLevel {
Error ,
Warn ,
Info ,
Debug ,
} ;
LogLevel configLevel ; //!< The minimum level of logs to write
2019-09-24 22:54:27 +02:00
/**
2020-08-08 21:38:51 +02:00
* @ param path The path of the log file
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
* @ param configLevel The minimum level of logs to write
2019-09-24 22:54:27 +02:00
*/
2020-08-08 21:38:51 +02:00
Logger ( const std : : string & path , LogLevel configLevel ) ;
2019-09-24 22:54:27 +02:00
/**
2019-12-02 18:40:53 +01:00
* @ brief Writes the termination message to the log file
2019-09-24 22:54:27 +02:00
*/
~ Logger ( ) ;
/**
* @ brief Writes a header , should only be used for emulation starting and ending
* @ param str The value to be written
*/
void WriteHeader ( const std : : string & str ) ;
/**
* @ brief Write a log to the log file
* @ param level The level of the log
* @ param str The value to be written
*/
2020-04-22 19:02:27 +02:00
void Write ( LogLevel level , std : : string str ) ;
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
* @ brief Write an error log with libfmt formatting
* @ param formatStr The value to be written , with libfmt formatting
* @ param args The arguments based on format_str
*/
template < typename S , typename . . . Args >
inline void Error ( const S & formatStr , Args & & . . . args ) {
if ( LogLevel : : Error < = configLevel ) {
Write ( LogLevel : : Error , fmt : : format ( formatStr , args . . . ) ) ;
}
}
/**
* @ brief Write a debug log with libfmt formatting
* @ param formatStr The value to be written , with libfmt formatting
* @ param args The arguments based on format_str
*/
template < typename S , typename . . . Args >
inline void Warn ( const S & formatStr , Args & & . . . args ) {
if ( LogLevel : : Warn < = configLevel ) {
Write ( LogLevel : : Warn , fmt : : format ( formatStr , args . . . ) ) ;
}
}
/**
* @ brief Write a debug log with libfmt formatting
* @ param formatStr The value to be written , with libfmt formatting
* @ param args The arguments based on format_str
*/
template < typename S , typename . . . Args >
inline void Info ( const S & formatStr , Args & & . . . args ) {
if ( LogLevel : : Info < = configLevel ) {
Write ( LogLevel : : Info , fmt : : format ( formatStr , args . . . ) ) ;
}
}
/**
* @ brief Write a debug log with libfmt formatting
2019-09-24 22:54:27 +02:00
* @ param formatStr The value to be written , with libfmt formatting
* @ param args The arguments based on format_str
*/
template < typename S , typename . . . Args >
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
inline void Debug ( const S & formatStr , Args & & . . . args ) {
if ( LogLevel : : Debug < = configLevel ) {
Write ( LogLevel : : Debug , fmt : : format ( formatStr , args . . . ) ) ;
}
2019-09-24 22:54:27 +02:00
}
} ;
/**
* @ brief The Settings class is used to access the parameters set in the Java component of the application
*/
class Settings {
private :
std : : map < std : : string , std : : string > stringMap ; //!< A mapping from all keys to their corresponding string value
std : : map < std : : string , bool > boolMap ; //!< A mapping from all keys to their corresponding boolean value
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
std : : map < std : : string , int > intMap ; //!< A mapping from all keys to their corresponding integer value
2019-09-24 22:54:27 +02:00
public :
/**
2020-04-22 19:02:27 +02:00
* @ param fd An FD to the preference XML file
2019-09-24 22:54:27 +02:00
*/
2020-04-22 19:02:27 +02:00
Settings ( int fd ) ;
2019-09-24 22:54:27 +02:00
/**
* @ brief Retrieves a particular setting as a string
* @ param key The key of the setting
* @ return The string value of the setting
*/
std : : string GetString ( const std : : string & key ) ;
/**
* @ brief Retrieves a particular setting as a boolean
* @ param key The key of the setting
* @ return The boolean value of the setting
*/
bool GetBool ( const std : : string & key ) ;
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
/**
* @ brief Retrieves a particular setting as a integer
* @ param key The key of the setting
* @ return The integer value of the setting
*/
int GetInt ( const std : : string & key ) ;
2019-09-24 22:54:27 +02:00
/**
2020-09-28 12:05:17 +02:00
* @ brief Writes all settings keys and values to syslog , this function is for development purposes
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
void List ( const std : : shared_ptr < Logger > & logger ) ;
} ;
2019-09-24 22:54:27 +02:00
class NCE ;
2019-12-05 16:35:34 +01:00
class JvmManager ;
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
namespace gpu {
class GPU ;
}
2019-09-24 22:54:27 +02:00
namespace kernel {
namespace type {
class KProcess ;
class KThread ;
}
class OS ;
}
2020-01-02 21:19:34 +01:00
namespace audio {
class Audio ;
}
2020-04-26 01:34:35 +02:00
namespace input {
class Input ;
}
2020-06-22 13:13:35 +02:00
namespace loader {
class Loader ;
}
2019-09-24 22:54:27 +02:00
/**
2020-09-28 12:05:17 +02:00
* @ brief The state of the entire emulator is contained within this class , all objects related to emulation are tied into it
2019-09-24 22:54:27 +02:00
*/
struct DeviceState {
2020-01-07 03:36:08 +01:00
DeviceState ( kernel : : OS * os , std : : shared_ptr < kernel : : type : : KProcess > & process , std : : shared_ptr < JvmManager > jvmManager , std : : shared_ptr < Settings > settings , std : : shared_ptr < Logger > logger ) ;
2019-09-24 22:54:27 +02:00
2020-09-28 12:05:17 +02:00
kernel : : OS * os ;
std : : shared_ptr < kernel : : type : : KProcess > & process ;
thread_local static std : : shared_ptr < kernel : : type : : KThread > thread ; //!< The KThread of the thread which accesses this object
thread_local static ThreadContext * ctx ; //!< The context of the guest thread for the corresponding host thread
std : : shared_ptr < NCE > nce ;
std : : shared_ptr < gpu : : GPU > gpu ;
std : : shared_ptr < audio : : Audio > audio ;
std : : shared_ptr < input : : Input > input ;
std : : shared_ptr < loader : : Loader > loader ;
std : : shared_ptr < JvmManager > jvm ;
std : : shared_ptr < Settings > settings ;
std : : shared_ptr < Logger > logger ;
2019-09-24 22:54:27 +02:00
} ;
}