blob: a66b86dc2f13e4bd73cc25f157f80261638fc062 (
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
|
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel
#ifndef SWAPKIT_DISKSWAP_H
#define SWAPKIT_DISKSWAP_H
#include <CompilerKit/CompilerKit.h>
#include <NeKit/Config.h>
#include <hint/CompilerHint.h>
#define kSwapPageFilePath "/boot/pagefile.sys"
#define kSwapPageFilePathU8 u8"/boot/pagefile.sys"
/// @file SwapDisk.h
/// @brief Virtual memory swap disk.
namespace Kernel {
struct SwapDiskHdr;
class IDiskSwap;
/// @brief Virtual memory interface to swap memory chunks onto disk.
/// @note The class only supports the NeFS as of right now, as it is using forks to write data into
/// disk.
class IDiskSwap final {
public:
IDiskSwap() = default;
~IDiskSwap() = default;
NE_COPY_DEFAULT(IDiskSwap)
public:
/***********************************************************************************/
/// @brief Write memory chunk onto disk.
/// @param data the data packet.
/// @return Number of bytes written to swap.
/***********************************************************************************/
_Output Int64 Write(SwapDiskHdr* data);
/***********************************************************************************/
/// @brief Read memory chunk from disk.
/// @param data the data packet length.
/// @return Whether the swap was fetched to disk, or not.
/***********************************************************************************/
_Output SwapDiskHdr* Read(const UIntPtr offset, SizeT data_len);
};
/// @brief Swap disk header, containing information about the held virtual memory.
/// @param fMagic Ident number.
/// @param fHeaderSz This header size.
/// @param fTeamID Process Team ID.
/// @param fProcessID Process ID.
/// @param fVirtualAddress Virtual address pointed by data.
/// @param fBlobSz Blob's size.
/// @param fBlob Data blob.
typedef struct SwapDiskHdr {
UInt32 fMagic;
SizeT fHeaderSz;
UInt64 fTeamID;
UInt64 fProcessID;
UIntPtr fOffset;
UInt64 fVirtualAddress;
SizeT fBlobSz;
UInt8 fBlob[1];
} PACKED ALIGN(8) SwapDiskHdr;
} // namespace Kernel
#endif
|