blob: 65efa4fe614a7cdaea70033d8f0baa4fae21a370 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/* -------------------------------------------
Copyright (C) 2024-2025, t& Corporation, all rights reserved.
------------------------------------------- */
#ifdef ZKA_USE_MBCI_FLASH
#include <NewKit/Defines.h>
#include <ArchKit/ArchKit.h>
#include <Mod/MFlash/MFlash.h>
#include <Mod/MBCI/MBCI.h>
/// @file MFlash.cc
/// @brief MBCI Flash support.
#define kMaxFlashSlots (8U)
namespace Kernel
{
/// /Mount/Flash/n
constexpr auto kFlashBridgeMagic = "FLSH";
constexpr auto kFlashBridgeRevision = 1;
STATIC BOOL kFlashEnabled = NO;
STATIC SizeT kFlashSize[kMaxFlashSlots] = {};
STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {};
STATIC IMBCIHost* kFlashMetaPackets[kMaxFlashSlots] = {};
STATIC IMBCIHost* kFlashDataPackets[kMaxFlashSlots] = {};
/// @brief Enable flash memory builtin.
STATIC Void drv_enable_flash(Int32 slot);
/// @brief Disable flash memory builtin.
STATIC Void drv_disable_flash(Int32 slot);
/// @brief get slot sector count.
/// @return slot sector count.
SizeT drv_get_sector_count(Int32 slot)
{
if (slot > kMaxFlashSlots)
return 0;
return kFlashSectorSz[slot];
}
/// @brief get slot full size (in bytes).
/// @return drive slot size
SizeT drv_get_size(Int32 slot)
{
if (slot > kMaxFlashSlots)
return 0;
return kFlashSize[slot];
}
/// @brief Enable flash memory at slot.
BOOL drv_enable_at(Int32 slot)
{
if (slot > kMaxFlashSlots)
return NO;
kFlashMetaPackets[slot]->InterruptEnable = YES;
kcout << "Enabled hardware slot at: " << number(slot) << endl;
return YES;
}
/// @brief Disable flash memory at slot.
BOOL drv_disable_at(Int32 slot)
{
if (slot > kMaxFlashSlots)
return NO;
kFlashMetaPackets[slot]->InterruptEnable = NO;
kcout << "Disabled hardware slot at: " << number(slot) << endl;
return YES;
}
} // namespace Kernel
#endif // if ZKA_USE_MBCI_FLASH
|