cbmimage
Loading...
Searching...
No Matches
blockaddress.c File Reference

cbmimage: specificy "addresses" into images More...

#include "cbmimage/internal.h"
#include "cbmimage/alloc.h"
#include <assert.h>
Include dependency graph for blockaddress.c:

Functions

int cbmimage_blockaddress_ts_exists (cbmimage_fileimage *image, uint8_t track, uint8_t sector)
 check if T/S is valid
 
int cbmimage_blockaddress_lba_exists (cbmimage_fileimage *image, uint16_t lba)
 check if LBA is valid
 
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
 

Variables

const cbmimage_blockaddress cbmimage_block_unused = CBMIMAGE_BLOCK_INIT(0, 0, 0)
 Definition of an empty cbmimage_blockaddress.
 

Detailed Description

cbmimage: specificy "addresses" into images


Author
Spiro Trikaliotis

For CBM disks, the addresses are given by track and sector specifications. On the other side, a so-called LBA (logical block address) is much easier to handle.

These functions specify how on address type is converted into the other

Function Documentation

◆ cbmimage_blockaddress_lba_exists()

int cbmimage_blockaddress_lba_exists ( cbmimage_fileimage * image,
uint16_t lba )

check if LBA is valid

Parameters
[in]imagepointer to the image data
[in]lbathe LBA of the block to be tested for existance
Returns
  • 0 if the block T/S is not valid
  • != 0 if the block T/S is valid
Remarks

◆ cbmimage_blockaddress_ts_exists()

int cbmimage_blockaddress_ts_exists ( cbmimage_fileimage * image,
uint8_t track,
uint8_t sector )

check if T/S is valid

Parameters
[in]imagepointer to the image data
[in]trackthe track of the block to be tested for existance
[in]sectorthe sector of the block to be tested for existance
Returns
  • 0 if the block T/S is not valid
  • != 0 if the block T/S is valid
Remarks

Variable Documentation

◆ cbmimage_block_unused

const cbmimage_blockaddress cbmimage_block_unused = CBMIMAGE_BLOCK_INIT(0, 0, 0)

Definition of an empty cbmimage_blockaddress.

Whenever you need to use an empty or unused block address, you can use this one instead of defining it on your own.