libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
lisa_tag.h File Reference

Structure definitions and conversion/serialization function declarations for Lisa family disk tags. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  sony_tag
struct  profile_tag
struct  priam_tag

Typedefs

typedef struct sony_tag sony_tag
typedef struct profile_tag profile_tag
typedef struct priam_tag priam_tag

Functions

sony_tag bytes_to_sony_tag (const uint8_t *bytes)
 Parse a 12-byte Sony tag record into a sony_tag structure.
profile_tag bytes_to_profile_tag (const uint8_t *bytes)
 Parse a 20-byte Profile tag record into a profile_tag structure.
priam_tag bytes_to_priam_tag (const uint8_t *bytes)
 Parse a 24-byte Priam tag record into a priam_tag structure.
uint8_t * sony_tag_to_bytes (sony_tag tag)
 Serialize a sony_tag into a newly allocated 12-byte big-endian on-disk representation.
uint8_t * profile_tag_to_bytes (profile_tag tag)
 Serialize a profile_tag into a newly allocated 20-byte big-endian on-disk representation.
uint8_t * priam_tag_to_bytes (priam_tag tag)
 Serialize a priam_tag into a newly allocated 24-byte big-endian on-disk representation.
profile_tag sony_tag_to_profile (sony_tag tag)
 Convert a sony_tag to a profile_tag representation.
profile_tag priam_tag_to_profile (priam_tag tag)
 Convert a priam_tag to a profile_tag.
priam_tag sony_tag_to_priam (sony_tag tag)
 Convert a sony_tag to a priam_tag representation.
priam_tag profile_tag_to_priam (profile_tag tag)
 Convert a profile_tag to a priam_tag.
sony_tag profile_tag_to_sony (profile_tag tag)
 Convert a profile_tag to a sony_tag.
sony_tag priam_tag_to_sony (priam_tag tag)
 Convert a priam_tag to a sony_tag.

Detailed Description

Structure definitions and conversion/serialization function declarations for Lisa family disk tags.

Provides compact C representations for on-disk tag metadata used by Sony, Profile and Priam storage devices in the Apple Lisa ecosystem. See lisa_tag.c for detailed description of field semantics and conversion rules.

Definition in file lisa_tag.h.

Typedef Documentation

◆ priam_tag

typedef struct priam_tag priam_tag

◆ profile_tag

typedef struct profile_tag profile_tag

◆ sony_tag

typedef struct sony_tag sony_tag

Function Documentation

◆ bytes_to_priam_tag()

priam_tag bytes_to_priam_tag ( const uint8_t * bytes)

Parse a 24-byte Priam tag record into a priam_tag structure.

Priam tags extend the Profile tag with an additional 4-byte disk_size field. This routine decodes all bit fields, separating the valid checksum flag (bit 7 of byte 6) from the 15-bit used_bytes value.

Parameters
bytesPointer to at least 24 consecutive bytes containing a raw Priam tag.
Returns
A populated priam_tag structure.
Warning
Undefined behavior if bytes is NULL or shorter than 24 bytes.
Note
The abs_page, next_block and prev_block 24-bit values are expanded into 32-bit integers in host memory.

Definition at line 112 of file lisa_tag.c.

References priam_tag::abs_page, priam_tag::checksum, priam_tag::disk_size, priam_tag::file_id, priam_tag::kind, priam_tag::next_block, priam_tag::prev_block, priam_tag::rel_page, priam_tag::reserved, priam_tag::used_bytes, priam_tag::valid_chk, priam_tag::version, and priam_tag::volume.

Referenced by aaruf_write_sector_long().

◆ bytes_to_profile_tag()

profile_tag bytes_to_profile_tag ( const uint8_t * bytes)

Parse a 20-byte Profile tag record into a profile_tag structure.

A Profile tag is similar to Priam but without the trailing disk_size field. Multi-byte numeric values are big-endian.

Parameters
bytesPointer to at least 20 consecutive bytes containing a raw Profile tag.
Returns
A populated profile_tag structure.
Warning
Undefined behavior if bytes is NULL or shorter than 20 bytes.

Definition at line 142 of file lisa_tag.c.

References profile_tag::abs_page, profile_tag::checksum, profile_tag::file_id, profile_tag::kind, profile_tag::next_block, profile_tag::prev_block, profile_tag::rel_page, profile_tag::reserved, profile_tag::used_bytes, profile_tag::valid_chk, profile_tag::version, and profile_tag::volume.

Referenced by aaruf_write_sector_long().

◆ bytes_to_sony_tag()

sony_tag bytes_to_sony_tag ( const uint8_t * bytes)

Parse a 12-byte Sony tag record into a sony_tag structure.

Field extraction follows the documented on-disk layout (big-endian). The next/prev block numbers are masked to 11 bits (0x7FF) since only those bits are defined in the Sony tag format. The reserved bits are preserved in the structure's reserved member for round-tripping if needed.

Parameters
bytesPointer to at least 12 consecutive bytes containing a raw Sony tag as read from disk.
Returns
A populated sony_tag structure with host-endian integer fields.
Warning
Behavior is undefined if bytes is NULL or does not point to at least 12 readable bytes.
Note
No validation of version, kind, or chain linkage consistency is performed.

Definition at line 82 of file lisa_tag.c.

References sony_tag::file_id, sony_tag::kind, sony_tag::next_block, sony_tag::prev_block, sony_tag::rel_page, sony_tag::reserved, SONY_BLOCK_ALLOWED_MASK, sony_tag::version, and sony_tag::volume.

Referenced by aaruf_write_sector_long().

◆ priam_tag_to_bytes()

uint8_t * priam_tag_to_bytes ( const priam_tag tag)

Serialize a priam_tag into a newly allocated 24-byte big-endian on-disk representation.

Layout matches bytes_to_priam_tag(). Includes the final 4-byte disk_size field. Packing rules for used_bytes and valid_chk mirror those used in profile_tag_to_bytes().

Parameters
tagPriam tag to serialize.
Returns
Pointer to a 24-byte buffer, or NULL on allocation failure.
Return values
NULLAllocation failure.
Note
Caller must free() the returned buffer.

Definition at line 409 of file lisa_tag.c.

References priam_tag::abs_page, priam_tag::checksum, priam_tag::disk_size, priam_tag::file_id, priam_tag::kind, priam_tag::next_block, priam_tag::prev_block, priam_tag::rel_page, priam_tag::reserved, priam_tag::used_bytes, priam_tag::valid_chk, priam_tag::version, and priam_tag::volume.

Referenced by aaruf_write_sector_long().

◆ priam_tag_to_profile()

profile_tag priam_tag_to_profile ( const priam_tag tag)

◆ priam_tag_to_sony()

sony_tag priam_tag_to_sony ( const priam_tag tag)

Convert a priam_tag to a sony_tag.

See profile_tag_to_sony(); Priam-only fields (abs_page, checksum, used_bytes, valid_chk, disk_size) are discarded. 0xFFFFFF chain terminators become 0x7FF; other values are truncated to 11 bits.

Parameters
tagSource Priam tag.
Returns
Sony tag with mapped values.

Definition at line 291 of file lisa_tag.c.

References priam_tag::file_id, sony_tag::file_id, priam_tag::kind, sony_tag::kind, priam_tag::next_block, sony_tag::next_block, priam_tag::prev_block, sony_tag::prev_block, priam_tag::rel_page, sony_tag::rel_page, priam_tag::reserved, sony_tag::reserved, SONY_BLOCK_NUMBER_MASK, priam_tag::version, sony_tag::version, priam_tag::volume, and sony_tag::volume.

Referenced by aaruf_write_sector_long().

◆ profile_tag_to_bytes()

uint8_t * profile_tag_to_bytes ( const profile_tag tag)

Serialize a profile_tag into a newly allocated 20-byte big-endian on-disk representation.

Bit/byte packing mirrors bytes_to_profile_tag(). The 24-bit next_block, prev_block and abs_page values are written most-significant byte first. The used_bytes high 7 bits and valid_chk flag are packed into the first byte of the 16-bit used_bytes field as per on-disk layout.

Parameters
tagProfile tag to serialize.
Returns
Pointer to a 20-byte buffer containing the serialized tag, or NULL on allocation failure.
Return values
NULLAllocation failure (caller should check before use).
Note
Caller must free() the returned buffer.

Definition at line 357 of file lisa_tag.c.

References profile_tag::abs_page, profile_tag::checksum, profile_tag::file_id, profile_tag::kind, profile_tag::next_block, profile_tag::prev_block, profile_tag::rel_page, profile_tag::reserved, profile_tag::used_bytes, profile_tag::valid_chk, profile_tag::version, and profile_tag::volume.

Referenced by aaruf_write_sector_long().

◆ profile_tag_to_priam()

◆ profile_tag_to_sony()

sony_tag profile_tag_to_sony ( const profile_tag tag)

Convert a profile_tag to a sony_tag.

Narrows 24-bit next/prev block numbers to 11 bits. A value of 0xFFFFFF (end-of-chain sentinel) is mapped back to 0x7FF. Any non-sentinel value is truncated to its lower 11 bits. Fields without Sony equivalents are dropped.

Parameters
tagSource Profile tag.
Returns
Sony tag with mapped/narrowed values.

Definition at line 257 of file lisa_tag.c.

References profile_tag::file_id, sony_tag::file_id, profile_tag::kind, sony_tag::kind, profile_tag::next_block, sony_tag::next_block, profile_tag::prev_block, sony_tag::prev_block, profile_tag::rel_page, sony_tag::rel_page, profile_tag::reserved, sony_tag::reserved, SONY_BLOCK_NUMBER_MASK, profile_tag::version, sony_tag::version, profile_tag::volume, and sony_tag::volume.

Referenced by aaruf_write_sector_long().

◆ sony_tag_to_bytes()

uint8_t * sony_tag_to_bytes ( sony_tag tag)

Serialize a sony_tag into a newly allocated 12-byte big-endian on-disk representation.

The next_block and prev_block fields are masked to 11 bits (0x7FF) during packing. Caller should ensure sentinel semantics are already encoded (i.e., use 0x7FF for end-of-chain) prior to calling.

Parameters
tagSony tag to serialize.
Returns
Pointer to a 12-byte buffer, or NULL on allocation failure.
Return values
NULLAllocation failure.
Note
Caller must free() the returned buffer.

Definition at line 466 of file lisa_tag.c.

References sony_tag::file_id, sony_tag::kind, sony_tag::next_block, sony_tag::prev_block, sony_tag::rel_page, sony_tag::reserved, SONY_BLOCK_ALLOWED_MASK, sony_tag::version, and sony_tag::volume.

Referenced by aaruf_write_sector_long().

◆ sony_tag_to_priam()

priam_tag sony_tag_to_priam ( const sony_tag tag)

Convert a sony_tag to a priam_tag representation.

Similar to sony_tag_to_profile() but returns a Priam tag. Priam-specific fields (abs_page, checksum, used_bytes, valid_chk, disk_size, reserved) are zero-initialized. 0x7FF next/prev sentinels expand to 0xFFFFFF.

Parameters
tagSource Sony tag.
Returns
Priam tag with mapped values.

Definition at line 201 of file lisa_tag.c.

References priam_tag::file_id, sony_tag::file_id, priam_tag::kind, sony_tag::kind, priam_tag::next_block, sony_tag::next_block, priam_tag::prev_block, sony_tag::prev_block, priam_tag::rel_page, sony_tag::rel_page, priam_tag::reserved, sony_tag::reserved, SONY_BLOCK_NUMBER_MASK, priam_tag::version, sony_tag::version, priam_tag::volume, and sony_tag::volume.

Referenced by aaruf_write_sector_long().

◆ sony_tag_to_profile()

profile_tag sony_tag_to_profile ( const sony_tag tag)

Convert a sony_tag to a profile_tag representation.

Sony tags contain a reduced-width (11-bit) next/prev block. To preserve chain termination semantics, values of 0x7FF are translated to 0xFFFFFF (24-bit "no next/prev" sentinel). Other values are copied verbatim into the wider fields. Only fields common to both formats are populated; Profile-specific fields (abs_page, checksum, used_bytes, valid_chk, reserved) remain zero-initialized.

Parameters
tagSource Sony tag.
Returns
Profile tag with mapped values.

Definition at line 173 of file lisa_tag.c.

References profile_tag::file_id, sony_tag::file_id, profile_tag::kind, sony_tag::kind, profile_tag::next_block, sony_tag::next_block, profile_tag::prev_block, sony_tag::prev_block, profile_tag::rel_page, sony_tag::rel_page, profile_tag::reserved, sony_tag::reserved, SONY_BLOCK_NUMBER_MASK, profile_tag::version, sony_tag::version, profile_tag::volume, and sony_tag::volume.

Referenced by aaruf_write_sector_long().