libnx  v4.8.0
hosversion.h
Go to the documentation of this file.
1 /**
2  * @file hosversion.h
3  * @brief Horizon OS (HOS) version detection utilities.
4  * @author fincs
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 
10 /// Builds a HOS version value from its constituent components.
11 #define MAKEHOSVERSION(_major,_minor,_micro) (((u32)(_major) << 16) | ((u32)(_minor) << 8) | (u32)(_micro))
12 
13 /// Extracts the major number from a HOS version value.
14 #define HOSVER_MAJOR(_version) (((_version) >> 16) & 0xFF)
15 
16 /// Extracts the minor number from a HOS version value.
17 #define HOSVER_MINOR(_version) (((_version) >> 8) & 0xFF)
18 
19 /// Extracts the micro number from a HOS version value.
20 #define HOSVER_MICRO(_version) ( (_version) & 0xFF)
21 
22 /// Returns the current HOS version that was previously set with \ref hosversionSet. If version initialization fails during startup (such as in the case set:sys is not available), this function returns zero.
24 
25 /// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup with the version info obtained with \ref setsysGetFirmwareVersion.
26 void hosversionSet(u32 version);
27 
28 /// Returns whether the current HOS version is augmented by running the Atmosphère custom firmware.
30 
31 /// Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
32 static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) {
33  return hosversionGet() >= MAKEHOSVERSION(major,minor,micro);
34 }
35 
36 /// Returns true if the current HOS version is earlier than the specified major/minor/micro version.
37 static inline bool hosversionBefore(u8 major, u8 minor, u8 micro) {
38  return !hosversionAtLeast(major, minor, micro);
39 }
40 
41 /// Returns true if the current HOS version is between the two specified major versions, i.e. [major1, major2).
42 static inline bool hosversionBetween(u8 major1, u8 major2) {
43  u32 ver = hosversionGet();
44  return ver >= MAKEHOSVERSION(major1,0,0) && ver < MAKEHOSVERSION(major2,0,0);
45 }
static bool hosversionAtLeast(u8 major, u8 minor, u8 micro)
Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
Definition: hosversion.h:32
static bool hosversionBetween(u8 major1, u8 major2)
Returns true if the current HOS version is between the two specified major versions,...
Definition: hosversion.h:42
bool hosversionIsAtmosphere(void)
Returns whether the current HOS version is augmented by running the Atmosphère custom firmware.
u32 hosversionGet(void)
Returns the current HOS version that was previously set with hosversionSet. If version initialization...
static bool hosversionBefore(u8 major, u8 minor, u8 micro)
Returns true if the current HOS version is earlier than the specified major/minor/micro version.
Definition: hosversion.h:37
#define MAKEHOSVERSION(_major, _minor, _micro)
Builds a HOS version value from its constituent components.
Definition: hosversion.h:11
void hosversionSet(u32 version)
Sets or overrides the current HOS version. This function is normally called automatically by libnx on...
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21