cbmimage
Loading...
Searching...
No Matches
block address functions

Classes

struct  cbmimage_track_sector_s
 Address on floppy: Track/Sector variant. More...
 
struct  cbmimage_blockaddress_s
 Address on drive. More...
 

Typedefs

typedef struct cbmimage_track_sector_s cbmimage_track_sector
 Address on floppy: Track/Sector variant.
 
typedef uint16_t cbmimage_lba
 Address on floppy: LBA variant.
 
typedef struct cbmimage_blockaddress_s cbmimage_blockaddress
 Address on drive.
 

Functions

static int cbmimage_i_generic_ts_to_blockaddress (cbmimage_fileimage *image, cbmimage_blockaddress *block)
 
int cbmimage_blockaddress_init_from_ts (cbmimage_fileimage *image, cbmimage_blockaddress *block)
 initialize a block address from its T/S specification
 
static int cbmimage_i_generic_lba_to_blockaddress (cbmimage_fileimage *image, cbmimage_blockaddress *block)
 
int cbmimage_blockaddress_init_from_lba (cbmimage_fileimage *image, cbmimage_blockaddress *block)
 initialize a block address from its T/S specification
 
int cbmimage_blockaddress_init_from_ts_value (cbmimage_fileimage *image, cbmimage_blockaddress *block, uint8_t track, uint8_t sector)
 initialize a block address when T/S are given
 
int cbmimage_blockaddress_init_from_lba_value (cbmimage_fileimage *image, cbmimage_blockaddress *block, uint16_t lba)
 initialize a block address when LBA is given
 
static int cbmimage_i_blockaddress_advance (cbmimage_fileimage *image, cbmimage_blockaddress *block, int do_not_advance_in_track)
 
int cbmimage_blockaddress_advance (cbmimage_fileimage *image, cbmimage_blockaddress *block)
 advance a block address, going to the next block
 
int cbmimage_blockaddress_advance_in_track (cbmimage_fileimage *image, cbmimage_blockaddress *block)
 advance a block address, going to the next block in the same track
 
int cbmimage_blockaddress_add (cbmimage_fileimage *image, cbmimage_blockaddress *blockresult, cbmimage_blockaddress block_adder)
 add two block address together
 

Detailed Description

Typedef Documentation

◆ cbmimage_blockaddress

Address on drive.

Remarks
Both variants (LBA and TS) must be valid at all times

◆ cbmimage_lba

typedef uint16_t cbmimage_lba

Address on floppy: LBA variant.

If the value is 0, this LBA is invalid

see also cbmimage_track_sector, struct cbmimage_track_sector_s

◆ cbmimage_track_sector

Address on floppy: Track/Sector variant.

see also cbmimage_lba

Function Documentation

◆ cbmimage_blockaddress_add()

int cbmimage_blockaddress_add ( cbmimage_fileimage * image,
cbmimage_blockaddress * blockresult,
cbmimage_blockaddress block_adder )

add two block address together

Parameters
[in]imagepointer to the image data
[in,out]blockresultpointer to a valid block address. On termination, it will contain the sum of the two block addresses.
[in]block_addera valid block address. It is the block to add to the one in *blockresult.
Returns
  • 0 if the add was successsfull.
  • 1 if an error occurred
Remarks
To understand the nature of this function, it is best to think about using a "base" for a block. The block in *blockresult will be modified as if the block in block_adder was block 1/0 (LBA 1) of this image. Thus, this function is mostly useful for calculating the addresses of blocks that are part of a partition on the image.

◆ cbmimage_blockaddress_advance()

int cbmimage_blockaddress_advance ( cbmimage_fileimage * image,
cbmimage_blockaddress * block )

advance a block address, going to the next block

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to a valid block address. On termination, it will contain the next block address.
Returns
  • 0 if the block address has been advanced, no error occurred
  • 1 if an error occurred, the block address was already the last one of the image
Remarks
  • the block address is updated in the T/S and in the LBA part
  • an error occurs if there is no next block; that is, the block is already the last block of the image
  • cf. cbmimage_blockaddress_advance_in_track()

◆ cbmimage_blockaddress_advance_in_track()

int cbmimage_blockaddress_advance_in_track ( cbmimage_fileimage * image,
cbmimage_blockaddress * block )

advance a block address, going to the next block in the same track

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to a valid block address. On termination, it will contain the next block address.
Returns
  • 0 if the block address has been advanced, no error occurred
  • 1 if an error occurred, the block address was already the last one of this track
Remarks

◆ cbmimage_blockaddress_init_from_lba()

int cbmimage_blockaddress_init_from_lba ( cbmimage_fileimage * image,
cbmimage_blockaddress * block )

initialize a block address from its T/S specification

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to the block address that has already the LBA set
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • the block address is updated in the track/sector part
  • an error occurs if the LBA does not exist as track/sector combination on this type of image

◆ cbmimage_blockaddress_init_from_lba_value()

int cbmimage_blockaddress_init_from_lba_value ( cbmimage_fileimage * image,
cbmimage_blockaddress * block,
uint16_t lba )

initialize a block address when LBA is given

Parameters
[in]imagepointer to the image data
[out]blockpointer to a block address. It does not need to be initialized in any way
[in]lbathe LBA to write into the block address
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • the block address is updated in the T/S and in the LBA part
  • an error occurs if the LBA does not exist on this type of image

◆ cbmimage_blockaddress_init_from_ts()

int cbmimage_blockaddress_init_from_ts ( cbmimage_fileimage * image,
cbmimage_blockaddress * block )

initialize a block address from its T/S specification

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to the block address that has already track and sector set
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • the block address is updated in the LBA part
  • an error occurs if the track/sector combination does not exist on this type of image

◆ cbmimage_blockaddress_init_from_ts_value()

int cbmimage_blockaddress_init_from_ts_value ( cbmimage_fileimage * image,
cbmimage_blockaddress * block,
uint8_t track,
uint8_t sector )

initialize a block address when T/S are given

Parameters
[in]imagepointer to the image data
[out]blockpointer to a block address. It does not need to be initialized in any way
[in]trackthe track to write into the block address
[in]sectorthe sector to write into the block address
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • the block address is updated in the T/S and in the LBA part
  • an error occurs if the track/sector combination does not exist on this type of image

◆ cbmimage_i_blockaddress_advance()

static int cbmimage_i_blockaddress_advance ( cbmimage_fileimage * image,
cbmimage_blockaddress * block,
int do_not_advance_in_track )
static

advance a block address, going to the next block of this image of in the same track

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to a valid block address. On termination, it will contain the next block address.
[in]do_not_advance_in_track
  • if 0, the next block of the image is determined. If needed, the block address advances to the next track
  • if not 0, the next block of this track is determined. That is, the block address does not advance to the next track
Returns
  • 0 if the block address has been advanced, no error occurred
  • 1 if an error occurred, the block address was already the last one of this image (if do_not_advance_in_track is 0) or of this track (if do_not_advance_in_track is not 0)
Remarks

◆ cbmimage_i_generic_lba_to_blockaddress()

static int cbmimage_i_generic_lba_to_blockaddress ( cbmimage_fileimage * image,
cbmimage_blockaddress * block )
static

convert the LBA to T/S block address, generic version

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to a block address that has an initialized LBA address
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • the block address is completely created from the lba parameter
  • an error occurs if the lba block does not exist on this type of image
  • this version is used if the image type does not specify its own variant. It assumes that the number of sectors is the same on all tracks.

◆ cbmimage_i_generic_ts_to_blockaddress()

static int cbmimage_i_generic_ts_to_blockaddress ( cbmimage_fileimage * image,
cbmimage_blockaddress * block )
static

convert the T/S to LBA block address, generic version

Parameters
[in]imagepointer to the image data
[in,out]blockpointer to a block address with an initialized T/S address
Returns
  • 0 if no error occurred
  • != 0 if an error occurred
Remarks
  • the block address is completely created from the ts parameter
  • an error occurs if the track/sector combination does not exist on this type of image
  • this version is used if the image type does not specify its own variant. It assumes that the number of sectors is the same on all tracks.