-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework some of the code to allow modularity
- Loading branch information
Showing
8 changed files
with
367 additions
and
207 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
FirmwareGen/GPT/Constants.cs → FirmwareGen/DeviceProfiles/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using FirmwareGen.GPT; | ||
using FirmwareGen.VirtualDisks; | ||
using System.IO; | ||
|
||
namespace FirmwareGen.DeviceProfiles | ||
{ | ||
public class EpsilonHalfSplit128GB : IDeviceProfile | ||
{ | ||
public byte[] GetPrimaryGPT() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
//ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
ulong DiskSize = 111_723_675_648; // 128GB; | ||
ulong SectorSize = 4096; | ||
|
||
byte[] PrimaryMBR = new byte[SectorSize]; | ||
PrimaryMBR[0x1C0] = 0x01; | ||
PrimaryMBR[0x1C2] = 0xEE; | ||
PrimaryMBR[0x1C3] = 0xFF; | ||
PrimaryMBR[0x1C4] = 0xFF; | ||
PrimaryMBR[0x1C5] = 0xFF; | ||
PrimaryMBR[0x1C6] = 0x01; | ||
PrimaryMBR[0x1CA] = 0xFF; | ||
PrimaryMBR[0x1CB] = 0xFF; | ||
PrimaryMBR[0x1CC] = 0xFF; | ||
PrimaryMBR[0x1CD] = 0xFF; | ||
PrimaryMBR[0x1FE] = 0x55; | ||
PrimaryMBR[0x1FF] = 0xAA; | ||
|
||
return [ | ||
.. PrimaryMBR, | ||
.. GPTUtils.MakeGPT(DiskSize, SectorSize, Constants.OEMEP_UFS_LUN_0_PARTITIONS, IsBackupGPT: false) | ||
]; | ||
} | ||
|
||
public byte[] GetBackupGPT() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
//ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
ulong DiskSize = 111_723_675_648; // 128GB; | ||
ulong SectorSize = 4096; | ||
|
||
return GPTUtils.MakeGPT(DiskSize, SectorSize, Constants.OEMEP_UFS_LUN_0_PARTITIONS, IsBackupGPT: true); | ||
} | ||
|
||
public string GetBlankVHD() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
//ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
ulong DiskSize = 111_723_675_648; // 128GB; | ||
uint SectorSize = 4096; | ||
|
||
const string tmp = "tmp"; | ||
const string TmpVHD = $@"{tmp}\temp.vhdx"; | ||
|
||
if (!Directory.Exists(tmp)) | ||
{ | ||
_ = Directory.CreateDirectory(tmp); | ||
} | ||
|
||
if (File.Exists(TmpVHD)) | ||
{ | ||
File.Delete(TmpVHD); | ||
} | ||
|
||
Logging.Log("Generating Primary GPT"); | ||
byte[] PrimaryGPT = GetPrimaryGPT(); | ||
|
||
Logging.Log("Generating Backup GPT"); | ||
byte[] BackupGPT = GetBackupGPT(); | ||
|
||
Logging.Log("Generating Main VHD"); | ||
VHDUtils.CreateVHDX(TmpVHD, SectorSize, DiskSize); | ||
|
||
BlankVHDUtils.PrepareVHD(TmpVHD, PrimaryGPT, BackupGPT); | ||
|
||
return TmpVHD; | ||
} | ||
|
||
public string[] SupplementaryBCDCommands() | ||
{ | ||
return []; | ||
} | ||
|
||
public string PlatformID() | ||
{ | ||
return "Microsoft Corporation.Surface.Surface Duo.1930"; | ||
} | ||
|
||
public string FFUFileName(string OSVersion, string Language, string Sku) | ||
{ | ||
return $"OEMEP_128GB_HalfSplit_{OSVersion}_CLIENT{Sku}_a64fre_{Language}_unsigned.ffu"; | ||
} | ||
|
||
public string DriverCommand(string DriverFolder) | ||
{ | ||
return $@"{DriverFolder}\definitions\Desktop\ARM64\Internal\epsilon.xml"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using FirmwareGen.GPT; | ||
using FirmwareGen.VirtualDisks; | ||
using System.IO; | ||
|
||
namespace FirmwareGen.DeviceProfiles | ||
{ | ||
internal class EpsilonHalfSplit256GB : IDeviceProfile | ||
{ | ||
public byte[] GetPrimaryGPT() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
//ulong DiskSize = 111_723_675_648; // 128GB; | ||
ulong SectorSize = 4096; | ||
|
||
byte[] PrimaryMBR = new byte[SectorSize]; | ||
PrimaryMBR[0x1C0] = 0x01; | ||
PrimaryMBR[0x1C2] = 0xEE; | ||
PrimaryMBR[0x1C3] = 0xFF; | ||
PrimaryMBR[0x1C4] = 0xFF; | ||
PrimaryMBR[0x1C5] = 0xFF; | ||
PrimaryMBR[0x1C6] = 0x01; | ||
PrimaryMBR[0x1CA] = 0xFF; | ||
PrimaryMBR[0x1CB] = 0xFF; | ||
PrimaryMBR[0x1CC] = 0xFF; | ||
PrimaryMBR[0x1CD] = 0xFF; | ||
PrimaryMBR[0x1FE] = 0x55; | ||
PrimaryMBR[0x1FF] = 0xAA; | ||
|
||
return [ | ||
.. PrimaryMBR, | ||
.. GPTUtils.MakeGPT(DiskSize, SectorSize, Constants.OEMEP_UFS_LUN_0_PARTITIONS, IsBackupGPT: false) | ||
]; | ||
} | ||
|
||
public byte[] GetBackupGPT() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
//ulong DiskSize = 111_723_675_648; // 128GB; | ||
ulong SectorSize = 4096; | ||
|
||
return GPTUtils.MakeGPT(DiskSize, SectorSize, Constants.OEMEP_UFS_LUN_0_PARTITIONS, IsBackupGPT: true); | ||
} | ||
|
||
public string GetBlankVHD() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
//ulong DiskSize = 111_723_675_648; // 128GB; | ||
uint SectorSize = 4096; | ||
|
||
const string tmp = "tmp"; | ||
const string TmpVHD = $@"{tmp}\temp.vhdx"; | ||
|
||
if (!Directory.Exists(tmp)) | ||
{ | ||
_ = Directory.CreateDirectory(tmp); | ||
} | ||
|
||
if (File.Exists(TmpVHD)) | ||
{ | ||
File.Delete(TmpVHD); | ||
} | ||
|
||
Logging.Log("Generating Primary GPT"); | ||
byte[] PrimaryGPT = GetPrimaryGPT(); | ||
|
||
Logging.Log("Generating Backup GPT"); | ||
byte[] BackupGPT = GetBackupGPT(); | ||
|
||
Logging.Log("Generating Main VHD"); | ||
VHDUtils.CreateVHDX(TmpVHD, SectorSize, DiskSize); | ||
|
||
BlankVHDUtils.PrepareVHD(TmpVHD, PrimaryGPT, BackupGPT); | ||
|
||
return TmpVHD; | ||
} | ||
|
||
public string[] SupplementaryBCDCommands() | ||
{ | ||
return []; | ||
} | ||
|
||
public string PlatformID() | ||
{ | ||
return "Microsoft Corporation.Surface.Surface Duo.1930"; | ||
} | ||
|
||
public string FFUFileName(string OSVersion, string Language, string Sku) | ||
{ | ||
return $"OEMEP_256GB_HalfSplit_{OSVersion}_CLIENT{Sku}_a64fre_{Language}_unsigned.ffu"; | ||
} | ||
|
||
public string DriverCommand(string DriverFolder) | ||
{ | ||
return $@"{DriverFolder}\definitions\Desktop\ARM64\Internal\epsilon.xml"; | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
FirmwareGen/DeviceProfiles/EpsilonMaximizedForWindows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using FirmwareGen.GPT; | ||
using FirmwareGen.VirtualDisks; | ||
using System.IO; | ||
|
||
namespace FirmwareGen.DeviceProfiles | ||
{ | ||
internal class EpsilonMaximizedForWindows : IDeviceProfile | ||
{ | ||
public byte[] GetPrimaryGPT() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
//ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
ulong DiskSize = 111_723_675_648; // 128GB; | ||
ulong SectorSize = 4096; | ||
|
||
byte[] PrimaryMBR = new byte[SectorSize]; | ||
PrimaryMBR[0x1C0] = 0x01; | ||
PrimaryMBR[0x1C2] = 0xEE; | ||
PrimaryMBR[0x1C3] = 0xFF; | ||
PrimaryMBR[0x1C4] = 0xFF; | ||
PrimaryMBR[0x1C5] = 0xFF; | ||
PrimaryMBR[0x1C6] = 0x01; | ||
PrimaryMBR[0x1CA] = 0xFF; | ||
PrimaryMBR[0x1CB] = 0xFF; | ||
PrimaryMBR[0x1CC] = 0xFF; | ||
PrimaryMBR[0x1CD] = 0xFF; | ||
PrimaryMBR[0x1FE] = 0x55; | ||
PrimaryMBR[0x1FF] = 0xAA; | ||
|
||
return [ | ||
.. PrimaryMBR, | ||
.. GPTUtils.MakeGPT(DiskSize, SectorSize, Constants.OEMEP_UFS_LUN_0_PARTITIONS, IsBackupGPT: false, SplitInHalf: false) | ||
]; | ||
} | ||
|
||
public byte[] GetBackupGPT() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
//ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
ulong DiskSize = 111_723_675_648; // 128GB; | ||
ulong SectorSize = 4096; | ||
|
||
return GPTUtils.MakeGPT(DiskSize, SectorSize, Constants.OEMEP_UFS_LUN_0_PARTITIONS, IsBackupGPT: true, SplitInHalf: false); | ||
} | ||
|
||
public string GetBlankVHD() | ||
{ | ||
//ulong DiskSize = 239_683_502_080; // 256GB (Bigger variant); | ||
//ulong DiskSize = 239_651_758_080; // 256GB (Smaller variant); | ||
ulong DiskSize = 111_723_675_648; // 128GB; | ||
uint SectorSize = 4096; | ||
|
||
const string tmp = "tmp"; | ||
const string TmpVHD = $@"{tmp}\temp.vhdx"; | ||
|
||
if (!Directory.Exists(tmp)) | ||
{ | ||
_ = Directory.CreateDirectory(tmp); | ||
} | ||
|
||
if (File.Exists(TmpVHD)) | ||
{ | ||
File.Delete(TmpVHD); | ||
} | ||
|
||
Logging.Log("Generating Primary GPT"); | ||
byte[] PrimaryGPT = GetPrimaryGPT(); | ||
|
||
Logging.Log("Generating Backup GPT"); | ||
byte[] BackupGPT = GetBackupGPT(); | ||
|
||
Logging.Log("Generating Main VHD"); | ||
VHDUtils.CreateVHDX(TmpVHD, SectorSize, DiskSize); | ||
|
||
BlankVHDUtils.PrepareVHD(TmpVHD, PrimaryGPT, BackupGPT); | ||
|
||
return TmpVHD; | ||
} | ||
|
||
public string[] SupplementaryBCDCommands() | ||
{ | ||
return []; | ||
} | ||
|
||
public string PlatformID() | ||
{ | ||
return "Microsoft Corporation.Surface.Surface Duo.1930"; | ||
} | ||
|
||
public string FFUFileName(string OSVersion, string Language, string Sku) | ||
{ | ||
return $"OEMEP_MaximizedForWindows_{OSVersion}_CLIENT{Sku}_a64fre_{Language}_unsigned.ffu"; | ||
} | ||
|
||
public string DriverCommand(string DriverFolder) | ||
{ | ||
return $@"{DriverFolder}\definitions\Desktop\ARM64\Internal\epsilon.xml"; | ||
} | ||
} | ||
} |
Oops, something went wrong.