Logo Search packages:      
Sourcecode: cbmlink version File versions  Download package

static int m_w ( const struct comm comm,
const void *  buf,
unsigned  len,
unsigned  addr 
) [static]

write a block of data to disk memory

Parameters:
comm the communication primitives
buf the data
len length of the data in bytes
addr the start address in drive memory

buffer pointer

pointer to end of buffer

Definition at line 149 of file qdisk.c.

References rdfile_raw(), and workbuf.

Referenced by qdisk_format(), and qdisk_install().

{
  /** buffer pointer */
  register const char* b = buf;
  /** pointer to end of buffer */
  register const char* bend = b + len;

  for (; b < bend; b += 32, addr += 32) {
    int status;
    unsigned l = bend - b > 32 ? 32 : bend - b;
    workbuf[0] = l + 6;
    memcpy (workbuf + 1, "M-W", 3);
    workbuf[4] = addr, workbuf[5] = addr >> 8, workbuf[6] = l;
    memcpy (workbuf + 7, b, l);
    if ((status = rdfile_raw (comm, 0, workbuf)))
      return status;
    if (workbuf[0] != '0' || workbuf[1] != '0') {
      fputs ("qdisk: M-W failed\n", stderr);
      return -1;
    }
  }

  return 0;
}


Generated by  Doxygen 1.6.0   Back to index