mdturbo

package
v0.0.0-...-20c68e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mdturbo provides the MicroDrive/Turbo partition map format, along with serializer and deserializer functions.

The format is AFAIK undocumented, but the CiderPress source at https://github.com/fadden/ciderpress/blob/master/diskimg/MicroDrive.cpp contains a partial description.

Package mdturbo provides the MicroDrive/Turbo partition map format, along with serializer and deserializer functions.

The format is AFAIK undocumented, but the CiderPress source at https://github.com/fadden/ciderpress/blob/master/diskimg/MicroDrive.cpp contains a partial description.

Package mdturbo provides the MicroDrive/Turbo partition map format, along with serializer and deserializer functions.

The format is AFAIK undocumented, but the CiderPress source at https://github.com/fadden/ciderpress/blob/master/diskimg/MicroDrive.cpp contains a partial description.

Package mdturbo provides the MicroDrive/Turbo partition map format, along with serializer and deserializer functions.

The format is AFAIK undocumented, but the CiderPress source at https://github.com/fadden/ciderpress/blob/master/diskimg/MicroDrive.cpp contains a partial description.

Package mdturbo provides the MicroDrive/Turbo partition map format, along with serializer and deserializer functions.

The format is AFAIK undocumented, but the CiderPress source at https://github.com/fadden/ciderpress/blob/master/diskimg/MicroDrive.cpp contains a partial description.

Index

Constants

View Source
const MaxPartitions = 8

MaxPartitions is the maximum number of partitions in an image

View Source
const PartChunkSize = 64

PartChunkSize is the number of bytes in either of the two partition blocks inside the table. Each of these chunks represents up to 8 partitions, with all of the start sector numbers (8 x 4 bytes apiece = 32) followed by all of the lengths (32 bits apiece each again), for 64 bytes total.

View Source
const PartitionBlkLen = 512

PartitionBlkLen is the number of bytes for a partition block

View Source
const SectorSize = 512

SectorSize is the number of bytes per sector

Variables

This section is empty.

Functions

func GoPrint

func GoPrint(partmap MDTurbo) string

GoPrint returns strings with a nice Go-style data structure representing the partition table

func PrettyPrint

func PrettyPrint(partmap MDTurbo) string

PrettyPrint formats a nice string representation of an MDTurbo struct. Returns a multi-line string.

This is a very manual structure and would be improved by automation, but getting good output is harder here than with serialize/deserialize.

func Serialize

func Serialize(partmap MDTurbo) ([PartitionBlkLen]uint8, error)

Serialize converts from a disk sector into an MDTurbo struct. Returns a 512-byte array, or an error if one occurs while parsing. It does not insist upon validity of the structure it encodes, so that we can successfully round-trip arbitrary sectors.

Types

type MDTurbo

type MDTurbo struct {
	Magic      uint16    `offset:"0x00"` // Drive type identifier
	Cylinders  uint16    `offset:"0x02"` // # of cylinders
	Unknown1   [2]uint8  `offset:"0x04"` // Unknown region 1
	Heads      uint16    `offset:"0x06"` // heads per cyl
	Sectors    uint16    `offset:"0x08"` // sectors per track
	Unknown2   [2]uint8  `offset:"0x0A"` // Unknown region 2
	PartCount1 uint8     `offset:"0x0C"` // # of partitions in first chunk
	PartCount2 uint8     `offset:"0x0D"` // # of partitions in second chunk
	Unknown3   [10]uint8 `offset:"0x0E"` // Unknown region 3
	RomVersion uint16    `offset:"0x18"` // IIgs Rom version (01 or 03)
	BootPart   uint16    `offset:"0x1A"` // Boot partition.
	Unknown4   [4]uint8  `offset:"0x1C"` // Unknown region 4

	// The partitions are actually represented as Start Sector
	// numbers followed by lengths - see PartChunkSize comment
	// above.
	Partitions1 [MaxPartitions]Partition `offset:"0x20"`

	Unknown5 [32]uint8 `offset:"0x60"` // Unknown region 5

	// Same as Partitions1 but starting at 0x80 and 0xA0
	Partitions2 [MaxPartitions]Partition `offset:"0x80"`
	// Probably padding, per CiderPress
	Unknown6 [320]uint8 `offset:"0xC0"`
}

MDTurbo is the data structure with what we know about a MicroDrive/Turbo partition map. The struct tag serialize is used to encode the offset of a field; length is calculated from the data type.

Because the Partitions data structure doesn't map exactly, we do keep the offset but the prcessing is a very very special case.

func Deserialize

func Deserialize(data [512]byte) (MDTurbo, error)

Deserialize converts from a disk sector into an MDTurbo struct. Returns a partition table data structure, or an error if the structure cannot be parsed. It does *NOT* check for overall structure validity; use MDTurbo.Validate() for that.

func (*MDTurbo) AddPartition

func (pt *MDTurbo) AddPartition(blocks uint32) (int, error)

AddPartition adds a new partition to a disk image, returns the new Partition number and an error if it can't.

func (MDTurbo) GetPartition

func (pt MDTurbo) GetPartition(partNum uint8) (Partition, error)

GetPartition returns the Partition data structure and an error

func (MDTurbo) PartCount

func (pt MDTurbo) PartCount() uint8

PartCount returns the total number of partitions in a partition table.

func (MDTurbo) Serialize

func (pt MDTurbo) Serialize() ([PartitionBlkLen]uint8, error)

Serialize is the struct-attached Serialize function, for convenience

func (MDTurbo) String

func (pt MDTurbo) String() string

String is the standard stringified partition printer

func (MDTurbo) Validate

func (pt MDTurbo) Validate() bool

Validate returns true if the partition tables appears to be valid, and False if it does not.

type Partition

type Partition struct {
	Start uint32 // Offset in bytes of partition in sectors

	// RawLength may not reflect the "actual" partition length, but
	// we need it for correct round-tripping of arbitrary partition
	// tables.
	RawLength uint32 `json:"Length"` // Length of partition in sectors
}

Partition is data for a single partition in a partition map

func (Partition) End

func (p Partition) End() uint32

End returns the last sector number of a partition

func (Partition) Length

func (p Partition) Length() uint32

Length returns the actual partition length, with the for-dual-CF bytes masked out, as per the CiderPress documentation.

func (Partition) String

func (p Partition) String() string

String returns a string representation of the partition details Format is start, end, size in kilobytes (tab-separated)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL