3.2.6 dp_get_page_data Function Implementation

dp_get_page_data is the only function that must interface with the communication peripheral of the image data file. As the requested data blocks may not be contiguous, it must have random access to the data blocks. Its purpose is to fill the page buffer with valid data.

In addition, this function must maintain start_page_address, end_page_address, and return_bytes. These global variables contain the range of data currently in the page as well as the number of valid bytes.

dp_get_page_data takes one argument:

  • address_offset— Contains the relative address of the needed element within the data block of the image file.

dp_get_page_data Function Implementation

void dp_get_page_data(DPULONG image_requested_address)
{
DPULONG image_address_index;
start_page_address=0;
image_address_index=image_requested_address;
return_bytes = PAGE_BUFFER_SIZE;
if (image_requested_address + return_bytes > image_size)
return_bytes = image_size - image_requested_address;
while (image_address_index < image_requested_address + return_bytes)
{
page_global_buffer[start_page_address]=image_buffer[image_address_index];
start_page_address++;
image_address_index++;
}
start_page_address = image_requested_address;
end_page_address = image_requested_address + return_bytes - 1;
return;
}