mirror of
https://github.com/switchbrew/libnx.git
synced 2025-12-08 13:15:15 +01:00
- Simplify kernel/detect.h logic; introduce detectKernelVersion() - Use the detected kernel version during early startup as a first approximation of the current HOS version (which only goes up to 6.0.0) - Use set:sys (if available) during __appInit in order to refine it to the actual current HOS version
43 lines
1.8 KiB
C
43 lines
1.8 KiB
C
/**
|
|
* @file hosversion.h
|
|
* @brief Horizon OS (HOS) version detection utilities.
|
|
* @author fincs
|
|
* @copyright libnx Authors
|
|
*/
|
|
#pragma once
|
|
#include "../types.h"
|
|
|
|
/// Builds a HOS version value from its constituent components.
|
|
#define MAKEHOSVERSION(_major,_minor,_micro) (((u32)(_major) << 16) | ((u32)(_minor) << 8) | (u32)(_micro))
|
|
|
|
/// Extracts the major number from a HOS version value.
|
|
#define HOSVER_MAJOR(_version) (((_version) >> 16) & 0xFF)
|
|
|
|
/// Extracts the minor number from a HOS version value.
|
|
#define HOSVER_MINOR(_version) (((_version) >> 8) & 0xFF)
|
|
|
|
/// Extracts the micro number from a HOS version value.
|
|
#define HOSVER_MICRO(_version) ( (_version) & 0xFF)
|
|
|
|
/// Returns the current HOS version. Normally, this matches the version returned by \ref setsysGetFirmwareVersion or, if set:sys is not available, the version detected by \ref detectKernelVersion.
|
|
u32 hosversionGet(void);
|
|
|
|
/// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup.
|
|
void hosversionSet(u32 version);
|
|
|
|
/// Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
|
|
static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) {
|
|
return hosversionGet() >= MAKEHOSVERSION(major,minor,micro);
|
|
}
|
|
|
|
/// Returns true if the current HOS version is earlier than the specified major/minor/micro version.
|
|
static inline bool hosversionBefore(u8 major, u8 minor, u8 micro) {
|
|
return !hosversionAtLeast(major, minor, micro);
|
|
}
|
|
|
|
/// Returns true if the current HOS version is between the two specified major versions, i.e. [major1, major2).
|
|
static inline bool hosversionBetween(u8 major1, u8 major2) {
|
|
u32 ver = hosversionGet();
|
|
return ver >= MAKEHOSVERSION(major1,0,0) && ver < MAKEHOSVERSION(major2,0,0);
|
|
}
|