2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-07-28 18:13:49 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Atari.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Partitioning scheme plugins.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Manages Atari ST GEMDOS partitions.
|
|
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
// ****************************************************************************/
|
2015-04-20 16:38:13 +01:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2017-12-21 14:30:38 +00:00
|
|
|
using DiscImageChef.Checksums;
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2015-10-18 22:04:03 +01:00
|
|
|
using DiscImageChef.Console;
|
2017-12-21 14:30:38 +00:00
|
|
|
using DiscImageChef.DiscImages;
|
2015-10-18 22:04:03 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
namespace DiscImageChef.Partitions
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
public class AtariPartitions : PartitionPlugin
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
const uint TypeGEMDOS = 0x0047454D;
|
|
|
|
|
const uint TypeBigGEMDOS = 0x0042474D;
|
|
|
|
|
const uint TypeExtended = 0x0058474D;
|
|
|
|
|
const uint TypeLinux = 0x004C4E58;
|
|
|
|
|
const uint TypeSwap = 0x00535750;
|
|
|
|
|
const uint TypeRAW = 0x00524157;
|
|
|
|
|
const uint TypeNetBSD = 0x004E4244;
|
|
|
|
|
const uint TypeNetBSDSwap = 0x004E4253;
|
|
|
|
|
const uint TypeSysV = 0x00554E58;
|
|
|
|
|
const uint TypeMac = 0x004D4143;
|
|
|
|
|
const uint TypeMinix = 0x004D4958;
|
|
|
|
|
const uint TypeMinix2 = 0x004D4E58;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2015-10-05 19:58:42 +01:00
|
|
|
public AtariPartitions()
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
|
|
|
|
Name = "Atari partitions";
|
2017-12-20 17:15:26 +00:00
|
|
|
PluginUuid = new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
|
2015-04-20 16:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-24 03:11:33 +00:00
|
|
|
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
2017-12-21 14:30:38 +00:00
|
|
|
partitions = new List<Partition>();
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(imagePlugin.GetSectorSize() < 512) return false;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
|
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
2017-07-24 23:35:33 +01:00
|
|
|
byte[] sector = imagePlugin.ReadSector(sectorOffset);
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-22 16:53:11 +00:00
|
|
|
AtariTable table = new AtariTable
|
|
|
|
|
{
|
|
|
|
|
boot = new byte[342],
|
|
|
|
|
icdEntries = new AtariEntry[8],
|
|
|
|
|
unused = new byte[12],
|
|
|
|
|
entries = new AtariEntry[4]
|
|
|
|
|
};
|
2015-04-20 16:38:13 +01:00
|
|
|
|
|
|
|
|
Array.Copy(sector, 0, table.boot, 0, 342);
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < 8; i++)
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
|
|
|
|
table.icdEntries[i].type = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 0);
|
|
|
|
|
table.icdEntries[i].start = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 4);
|
|
|
|
|
table.icdEntries[i].length = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Array.Copy(sector, 438, table.unused, 0, 12);
|
|
|
|
|
|
|
|
|
|
table.size = BigEndianBitConverter.ToUInt32(sector, 450);
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < 4; i++)
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
|
|
|
|
table.entries[i].type = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 0);
|
|
|
|
|
table.entries[i].start = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 4);
|
|
|
|
|
table.entries[i].length = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.badStart = BigEndianBitConverter.ToUInt32(sector, 502);
|
|
|
|
|
table.badLength = BigEndianBitConverter.ToUInt32(sector, 506);
|
|
|
|
|
table.checksum = BigEndianBitConverter.ToUInt16(sector, 510);
|
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
Sha1Context sha1Ctx = new Sha1Context();
|
2015-10-18 22:04:03 +01:00
|
|
|
sha1Ctx.Init();
|
|
|
|
|
sha1Ctx.Update(table.boot);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "Boot code SHA1: {0}", sha1Ctx.End());
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < 8; i++)
|
2015-10-18 22:04:03 +01:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].flag = 0x{1:X2}", i,
|
|
|
|
|
(table.icdEntries[i].type & 0xFF000000) >> 24);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].type = 0x{1:X6}", i,
|
2017-12-20 17:26:28 +00:00
|
|
|
table.icdEntries[i].type & 0x00FFFFFF);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].start = {1}", i,
|
|
|
|
|
table.icdEntries[i].start);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].length = {1}", i,
|
|
|
|
|
table.icdEntries[i].length);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.size = {0}", table.size);
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < 4; i++)
|
2015-10-18 22:04:03 +01:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].flag = 0x{1:X2}", i,
|
|
|
|
|
(table.entries[i].type & 0xFF000000) >> 24);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].type = 0x{1:X6}", i,
|
2017-12-20 17:26:28 +00:00
|
|
|
table.entries[i].type & 0x00FFFFFF);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].start = {1}", i,
|
|
|
|
|
table.entries[i].start);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].length = {1}", i,
|
|
|
|
|
table.entries[i].length);
|
2015-04-20 16:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.badStart = {0}", table.badStart);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.badLength = {0}", table.badLength);
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin", "table.checksum = 0x{0:X4}", table.checksum);
|
|
|
|
|
|
2015-04-20 16:38:13 +01:00
|
|
|
bool validTable = false;
|
|
|
|
|
ulong partitionSequence = 0;
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < 4; i++)
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
uint type = table.entries[i].type & 0x00FFFFFF;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
switch(type)
|
|
|
|
|
{
|
2017-12-21 04:43:29 +00:00
|
|
|
case TypeGEMDOS:
|
|
|
|
|
case TypeBigGEMDOS:
|
|
|
|
|
case TypeLinux:
|
|
|
|
|
case TypeSwap:
|
|
|
|
|
case TypeRAW:
|
|
|
|
|
case TypeNetBSD:
|
|
|
|
|
case TypeNetBSDSwap:
|
|
|
|
|
case TypeSysV:
|
|
|
|
|
case TypeMac:
|
|
|
|
|
case TypeMinix:
|
|
|
|
|
case TypeMinix2:
|
|
|
|
|
validTable = true;
|
|
|
|
|
|
|
|
|
|
if(table.entries[i].start <= imagePlugin.GetSectors())
|
|
|
|
|
{
|
|
|
|
|
if(table.entries[i].start + table.entries[i].length > imagePlugin.GetSectors())
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin",
|
|
|
|
|
"WARNING: End of partition goes beyond device size");
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
ulong sectorSize = imagePlugin.GetSectorSize();
|
|
|
|
|
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
byte[] partType = new byte[3];
|
|
|
|
|
partType[0] = (byte)((type & 0xFF0000) >> 16);
|
|
|
|
|
partType[1] = (byte)((type & 0x00FF00) >> 8);
|
|
|
|
|
partType[2] = (byte)(type & 0x0000FF);
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
Partition part = new Partition
|
2017-12-21 04:43:29 +00:00
|
|
|
{
|
|
|
|
|
Size = table.entries[i].length * sectorSize,
|
|
|
|
|
Length = table.entries[i].length,
|
|
|
|
|
Sequence = partitionSequence,
|
|
|
|
|
Name = "",
|
|
|
|
|
Offset = table.entries[i].start * sectorSize,
|
|
|
|
|
Start = table.entries[i].start,
|
|
|
|
|
Type = Encoding.ASCII.GetString(partType),
|
|
|
|
|
Scheme = Name
|
|
|
|
|
};
|
|
|
|
|
switch(type)
|
|
|
|
|
{
|
|
|
|
|
case TypeGEMDOS:
|
|
|
|
|
part.Description = "Atari GEMDOS partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeBigGEMDOS:
|
|
|
|
|
part.Description = "Atari GEMDOS partition bigger than 32 MiB";
|
|
|
|
|
break;
|
|
|
|
|
case TypeLinux:
|
|
|
|
|
part.Description = "Linux partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeSwap:
|
|
|
|
|
part.Description = "Swap partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeRAW:
|
|
|
|
|
part.Description = "RAW partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeNetBSD:
|
|
|
|
|
part.Description = "NetBSD partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeNetBSDSwap:
|
|
|
|
|
part.Description = "NetBSD swap partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeSysV:
|
|
|
|
|
part.Description = "Atari UNIX partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeMac:
|
|
|
|
|
part.Description = "Macintosh partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeMinix:
|
|
|
|
|
case TypeMinix2:
|
|
|
|
|
part.Description = "MINIX partition";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
part.Description = "Unknown partition type";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
partitions.Add(part);
|
|
|
|
|
partitionSequence++;
|
2015-04-20 16:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
break;
|
|
|
|
|
case TypeExtended:
|
|
|
|
|
byte[] extendedSector = imagePlugin.ReadSector(table.entries[i].start);
|
|
|
|
|
AtariTable extendedTable = new AtariTable();
|
|
|
|
|
extendedTable.entries = new AtariEntry[4];
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
for(int j = 0; j < 4; j++)
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
2017-12-21 04:43:29 +00:00
|
|
|
extendedTable.entries[j].type =
|
|
|
|
|
BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 0);
|
|
|
|
|
extendedTable.entries[j].start =
|
|
|
|
|
BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 4);
|
|
|
|
|
extendedTable.entries[j].length =
|
|
|
|
|
BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 8);
|
|
|
|
|
}
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
for(int j = 0; j < 4; j++)
|
|
|
|
|
{
|
|
|
|
|
uint extendedType = extendedTable.entries[j].type & 0x00FFFFFF;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
if(extendedType != TypeGEMDOS && extendedType != TypeBigGEMDOS &&
|
|
|
|
|
extendedType != TypeLinux && extendedType != TypeSwap && extendedType != TypeRAW &&
|
|
|
|
|
extendedType != TypeNetBSD && extendedType != TypeNetBSDSwap &&
|
|
|
|
|
extendedType != TypeSysV && extendedType != TypeMac && extendedType != TypeMinix &&
|
|
|
|
|
extendedType != TypeMinix2) continue;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
validTable = true;
|
|
|
|
|
if(extendedTable.entries[j].start > imagePlugin.GetSectors()) continue;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
if(extendedTable.entries[j].start + extendedTable.entries[j].length >
|
|
|
|
|
imagePlugin.GetSectors())
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin",
|
|
|
|
|
"WARNING: End of partition goes beyond device size");
|
2015-04-20 16:38:13 +01:00
|
|
|
|
|
|
|
|
ulong sectorSize = imagePlugin.GetSectorSize();
|
2017-12-19 20:33:03 +00:00
|
|
|
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
|
2015-04-20 16:38:13 +01:00
|
|
|
|
|
|
|
|
byte[] partType = new byte[3];
|
2017-12-21 06:06:19 +00:00
|
|
|
partType[0] = (byte)((extendedType & 0xFF0000) >> 16);
|
|
|
|
|
partType[1] = (byte)((extendedType & 0x00FF00) >> 8);
|
|
|
|
|
partType[2] = (byte)(extendedType & 0x0000FF);
|
2015-04-20 16:38:13 +01:00
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
Partition part = new Partition
|
2017-07-23 22:54:36 +01:00
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
Size = extendedTable.entries[j].length * sectorSize,
|
|
|
|
|
Length = extendedTable.entries[j].length,
|
2017-07-23 22:54:36 +01:00
|
|
|
Sequence = partitionSequence,
|
|
|
|
|
Name = "",
|
2017-12-21 06:06:19 +00:00
|
|
|
Offset = extendedTable.entries[j].start * sectorSize,
|
|
|
|
|
Start = extendedTable.entries[j].start,
|
2017-07-23 22:54:36 +01:00
|
|
|
Type = Encoding.ASCII.GetString(partType),
|
|
|
|
|
Scheme = Name
|
|
|
|
|
};
|
2017-12-21 06:06:19 +00:00
|
|
|
switch(extendedType)
|
2015-04-20 16:38:13 +01:00
|
|
|
{
|
|
|
|
|
case TypeGEMDOS:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Atari GEMDOS partition";
|
2015-04-20 16:38:13 +01:00
|
|
|
break;
|
|
|
|
|
case TypeBigGEMDOS:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Atari GEMDOS partition bigger than 32 MiB";
|
2015-04-20 16:38:13 +01:00
|
|
|
break;
|
|
|
|
|
case TypeLinux:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Linux partition";
|
2015-04-20 16:38:13 +01:00
|
|
|
break;
|
2015-04-20 17:51:21 +01:00
|
|
|
case TypeSwap:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Swap partition";
|
2015-04-20 16:38:13 +01:00
|
|
|
break;
|
|
|
|
|
case TypeRAW:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "RAW partition";
|
2015-04-20 16:38:13 +01:00
|
|
|
break;
|
2015-04-20 17:51:21 +01:00
|
|
|
case TypeNetBSD:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "NetBSD partition";
|
2015-04-20 17:51:21 +01:00
|
|
|
break;
|
|
|
|
|
case TypeNetBSDSwap:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "NetBSD swap partition";
|
2015-04-20 17:51:21 +01:00
|
|
|
break;
|
2016-02-10 05:14:49 +00:00
|
|
|
case TypeSysV:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Atari UNIX partition";
|
2016-04-19 02:11:47 +01:00
|
|
|
break;
|
2016-02-10 05:14:49 +00:00
|
|
|
case TypeMac:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Macintosh partition";
|
2016-04-19 02:11:47 +01:00
|
|
|
break;
|
2016-02-10 05:14:49 +00:00
|
|
|
case TypeMinix:
|
|
|
|
|
case TypeMinix2:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "MINIX partition";
|
2016-04-19 02:11:47 +01:00
|
|
|
break;
|
2015-04-20 16:38:13 +01:00
|
|
|
default:
|
2017-07-19 16:37:11 +01:00
|
|
|
part.Description = "Unknown partition type";
|
2015-04-20 16:38:13 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partitions.Add(part);
|
|
|
|
|
partitionSequence++;
|
|
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!validTable) return partitions.Count > 0;
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
uint type = table.icdEntries[i].type & 0x00FFFFFF;
|
|
|
|
|
|
|
|
|
|
if(type != TypeGEMDOS && type != TypeBigGEMDOS && type != TypeLinux && type != TypeSwap &&
|
|
|
|
|
type != TypeRAW && type != TypeNetBSD && type != TypeNetBSDSwap && type != TypeSysV &&
|
|
|
|
|
type != TypeMac && type != TypeMinix && type != TypeMinix2) continue;
|
|
|
|
|
|
|
|
|
|
if(table.icdEntries[i].start > imagePlugin.GetSectors()) continue;
|
|
|
|
|
|
|
|
|
|
if(table.icdEntries[i].start + table.icdEntries[i].length > imagePlugin.GetSectors())
|
|
|
|
|
DicConsole.DebugWriteLine("Atari partition plugin",
|
|
|
|
|
"WARNING: End of partition goes beyond device size");
|
|
|
|
|
|
|
|
|
|
ulong sectorSize = imagePlugin.GetSectorSize();
|
|
|
|
|
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
|
|
|
|
|
|
|
|
|
|
byte[] partType = new byte[3];
|
|
|
|
|
partType[0] = (byte)((type & 0xFF0000) >> 16);
|
|
|
|
|
partType[1] = (byte)((type & 0x00FF00) >> 8);
|
|
|
|
|
partType[2] = (byte)(type & 0x0000FF);
|
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
Partition part = new Partition
|
2017-12-21 06:06:19 +00:00
|
|
|
{
|
|
|
|
|
Size = table.icdEntries[i].length * sectorSize,
|
|
|
|
|
Length = table.icdEntries[i].length,
|
|
|
|
|
Sequence = partitionSequence,
|
|
|
|
|
Name = "",
|
|
|
|
|
Offset = table.icdEntries[i].start * sectorSize,
|
|
|
|
|
Start = table.icdEntries[i].start,
|
|
|
|
|
Type = Encoding.ASCII.GetString(partType),
|
|
|
|
|
Scheme = Name
|
|
|
|
|
};
|
|
|
|
|
switch(type)
|
|
|
|
|
{
|
|
|
|
|
case TypeGEMDOS:
|
|
|
|
|
part.Description = "Atari GEMDOS partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeBigGEMDOS:
|
|
|
|
|
part.Description = "Atari GEMDOS partition bigger than 32 MiB";
|
|
|
|
|
break;
|
|
|
|
|
case TypeLinux:
|
|
|
|
|
part.Description = "Linux partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeSwap:
|
|
|
|
|
part.Description = "Swap partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeRAW:
|
|
|
|
|
part.Description = "RAW partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeNetBSD:
|
|
|
|
|
part.Description = "NetBSD partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeNetBSDSwap:
|
|
|
|
|
part.Description = "NetBSD swap partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeSysV:
|
|
|
|
|
part.Description = "Atari UNIX partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeMac:
|
|
|
|
|
part.Description = "Macintosh partition";
|
|
|
|
|
break;
|
|
|
|
|
case TypeMinix:
|
|
|
|
|
case TypeMinix2:
|
|
|
|
|
part.Description = "MINIX partition";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
part.Description = "Unknown partition type";
|
|
|
|
|
break;
|
2015-04-20 16:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
partitions.Add(part);
|
|
|
|
|
partitionSequence++;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-20 16:38:13 +01:00
|
|
|
return partitions.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Atari partition entry
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
|
|
|
|
struct AtariEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// First byte flag, three bytes type in ASCII.
|
|
|
|
|
/// Flag bit 0 = active
|
|
|
|
|
/// Flag bit 7 = bootable
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint type;
|
2015-04-20 16:38:13 +01:00
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Starting sector
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint start;
|
2015-04-20 16:38:13 +01:00
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Length in sectors
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint length;
|
2015-04-20 16:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct AtariTable
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Boot code for 342 bytes
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public byte[] boot;
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// 8 extra entries for ICDPro driver
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public AtariEntry[] icdEntries;
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Unused, 12 bytes
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public byte[] unused;
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Disk size in sectors
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint size;
|
2015-04-20 16:38:13 +01:00
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// 4 partition entries
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public AtariEntry[] entries;
|
|
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Starting sector of bad block list
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint badStart;
|
2015-04-20 16:38:13 +01:00
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Length in sectors of bad block list
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public uint badLength;
|
2015-04-20 16:38:13 +01:00
|
|
|
/// <summary>
|
2017-12-24 03:11:33 +00:00
|
|
|
/// Checksum for bootable disks
|
2015-04-20 16:38:13 +01:00
|
|
|
/// </summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort checksum;
|
2015-04-20 16:38:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|