This repository has been archived by the owner on Sep 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from misson20000/support-100
add env_get_kernel_version() and 1.0.0 support
- Loading branch information
Showing
7 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @file libtransistor/environment.h | ||
* @brief Functions to query the current environment | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include<libtransistor/types.h> | ||
|
||
typedef enum { | ||
KERNEL_VERSION_INVALID, | ||
KERNEL_VERSION_100, | ||
KERNEL_VERSION_200, | ||
KERNEL_VERSION_300, | ||
KERNEL_VERSION_400, | ||
KERNEL_VERSION_500, | ||
} kernel_version_t; | ||
|
||
/** | ||
* @brief Returns the current kernel version, for feature-detection purposes | ||
*/ | ||
kernel_version_t env_get_kernel_version(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include<libtransistor/environment.h> | ||
#include<libtransistor/svc.h> | ||
|
||
kernel_version_t env_get_kernel_version() { | ||
static kernel_version_t version = KERNEL_VERSION_INVALID; | ||
if(version == KERNEL_VERSION_INVALID) { | ||
version = KERNEL_VERSION_500; | ||
uint64_t info; | ||
if(svcGetInfo(&info, 20, 0xffff8001, 0) == 0xf001) { version = KERNEL_VERSION_500 - 1; } | ||
if(svcGetInfo(&info, 19, 0xffff8001, 0) == 0xf001) { version = KERNEL_VERSION_400 - 1; } | ||
if(svcGetInfo(&info, 16, 0xffff8001, 0) == 0xf001) { version = KERNEL_VERSION_300 - 1; } | ||
if(svcGetInfo(&info, 12, 0xffff8001, 0) == 0xf001) { version = KERNEL_VERSION_200 - 1; } | ||
} | ||
return version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters