|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3:
1.1.1.3 ! root 4: Governed by the TrueCrypt License 2.5 the full text of which is contained
1.1 root 5: in the file License.txt included in TrueCrypt binary and source code
6: distribution packages.
7: */
8:
9: #ifndef TC_HEADER_Boot_BootDiskIo
10: #define TC_HEADER_Boot_BootDiskIo
11:
12: #include "Bios.h"
1.1.1.2 root 13: #include "BootDebug.h"
14: #include "BootDefs.h"
15:
16: enum
17: {
18: BiosResultEccCorrected = 0x11
19: };
1.1 root 20:
21: #pragma pack(1)
22:
23: struct PartitionEntryMBR
24: {
25: byte BootIndicator;
26:
27: byte StartHead;
28: byte StartCylSector;
29: byte StartCylinder;
30:
31: byte Type;
32:
33: byte EndHead;
34: byte EndSector;
35: byte EndCylinder;
36:
37: uint32 StartLBA;
38: uint32 SectorCountLBA;
39: };
40:
41: struct MBR
42: {
43: byte Code[446];
44: PartitionEntryMBR Partitions[4];
45: uint16 Signature;
46: };
47:
48: struct BiosLbaPacket
49: {
50: byte Size;
51: byte Reserved;
52: uint16 SectorCount;
53: uint32 Buffer;
54: uint64 Sector;
55: };
56:
57: #pragma pack()
58:
59:
60: struct ChsAddress
61: {
62: uint16 Cylinder;
63: byte Head;
64: byte Sector;
65: };
66:
67: struct Partition
68: {
69: byte Number;
70: byte Drive;
71: bool Active;
72: uint64 EndSector;
73: bool Primary;
74: uint64 SectorCount;
75: uint64 StartSector;
76: byte Type;
77: };
78:
79: struct DriveGeometry
80: {
81: uint16 Cylinders;
82: byte Heads;
83: byte Sectors;
84: };
85:
86:
1.1.1.2 root 87: #ifdef TC_BOOT_DEBUG_ENABLED
88: void AcquireSectorBuffer ();
89: void ReleaseSectorBuffer ();
90: #else
91: # define AcquireSectorBuffer()
92: # define ReleaseSectorBuffer()
93: #endif
94:
1.1 root 95: void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba);
1.1.1.3 ! root 96: bool GetActiveAndFollowingPartition (byte drive);
1.1 root 97: BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false);
1.1.1.3 ! root 98: BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false);
1.1 root 99: void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs);
100: void Print (const ChsAddress &chs);
101: void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr);
1.1.1.3 ! root 102: void PrintSectorCountInMB (const uint64 §orCount);
! 103: BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false);
1.1.1.2 root 104: BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
1.1 root 105: BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
106: BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false);
107: BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent);
108: BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
109: BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false);
110:
1.1.1.2 root 111: extern byte SectorBuffer[TC_LB_SIZE];
112:
1.1 root 113: #endif // TC_HEADER_Boot_BootDiskIo
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.