summaryrefslogtreecommitdiffhomepage
path: root/dev/modules
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-11 13:04:22 +0200
committerGitHub <noreply@github.com>2025-05-11 13:04:22 +0200
commit57d040e3e6b6d0257c0ba5a914396520b18d9d87 (patch)
tree78be4974d8a24e983034b0962ac5435f1b1d0b53 /dev/modules
parent7690c1976b3127e17370708aef47ba3f18f3b8c2 (diff)
parentf775566da3cf4f8e3ffd4ca6dfe0a3c7776c3b35 (diff)
Merge pull request #30 from nekernel-org/dev0.0.2e2
0.0.2e2
Diffstat (limited to 'dev/modules')
-rw-r--r--dev/modules/MBCI/MBCI.h33
1 files changed, 18 insertions, 15 deletions
diff --git a/dev/modules/MBCI/MBCI.h b/dev/modules/MBCI/MBCI.h
index 1038f17c..99ecf802 100644
--- a/dev/modules/MBCI/MBCI.h
+++ b/dev/modules/MBCI/MBCI.h
@@ -39,7 +39,7 @@ enum {
};
/// @brief MBCI Host header.
-struct PACKED IMBCIHost final {
+volatile struct PACKED IMBCIHost final {
UInt32 Magic;
UInt32 HostId;
UInt16 VendorId;
@@ -96,27 +96,30 @@ enum MBCIHostState {
/// @brief An AuthKey is a context used to tokenize data for an MBCI packet.
typedef UInt32 MBCIAuthKeyType;
-/// @brief Read Auth key for MBCI host.
-/// @param host the mbci host to get the key on.
-/// @return the 24-bit key.
-inline MBCIAuthKeyType mbci_read_auth_key(_Input volatile struct IMBCIHost* host) {
- constexpr auto const kChallengeMBCI = 0xdeadbeef;
+/// @internal
+inline BOOL busi_test_mmio(_Input struct IMBCIHost* host, _Input const UInt32 test) {
+ host->MMIOTest = test;
+ UInt16 timeout = 0UL;
- host->MMIOTest = kChallengeMBCI;
+ while (host->MMIOTest == test) {
+ ++timeout;
- if (host->MMIOTest == kChallengeMBCI) {
- return (host->Esb[kMBCIESBSz - 1] << 16) | (host->Esb[kMBCIESBSz - 2] << 8) |
- (host->Esb[kMBCIESBSz - 3] & 0xFF);
+ if (timeout > 0x1000) return NO;
}
- return kChallengeMBCI;
+ return host->MMIOTest == 0;
}
-inline BOOL mbci_test_mmio(_Input volatile struct IMBCIHost* host) {
- constexpr auto const kChallengeMBCI = 0xdeadbeef;
+/// @brief Read Auth key for MBCI host.
+/// @param host the mbci host to get the key on.
+/// @return the 24-bit key.
+inline MBCIAuthKeyType mbci_read_auth_key(_Input struct IMBCIHost* host) {
+ auto const kChallengeMBCI = 0x1; // MBCI Challenge test
+
+ if (!busi_test_mmio(host, kChallengeMBCI)) return ~0;
- host->MMIOTest = kChallengeMBCI;
- return host->MMIOTest == kChallengeMBCI;
+ return (host->Esb[kMBCIESBSz - 1] << 16) | (host->Esb[kMBCIESBSz - 2] << 8) |
+ (host->Esb[kMBCIESBSz - 3] & 0xFF);
}
} // namespace Kernel