Ejemplo n.º 1
0
int
md_read_rom (const char *filename, unsigned short parport, int size)
{
  FILE *file;
  unsigned short int id;
  unsigned char buffer[0x100];
  int blocksleft, address = 0;
  time_t starttime;
  void (*read_block) (int, unsigned char *) = ttt_read_rom_w; // ttt_read_rom_b

  if ((file = fopen (filename, "wb")) == NULL)
    {
      fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename);
      exit (1);
    }
  ttt_init_io (parport);

  id = check_card ();
  if (id == 0)
    {
      fclose (file);
      remove (filename);
      exit (1);
    }

  if ((id == 0xb0d0 || id == 0x8916) && size > 32 * MBIT)
    size = 32 * MBIT;                           // Sharp or Intel 32 Mbit flash card
#if 0
  // size is set to 64 * MBIT "by default" (in ucon64_opts.c)
  else if (id == 0x8917 && size > 64 * MBIT)
    size = 64 * MBIT;                           // Intel 64 Mbit flash card
#endif

  printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT);

  blocksleft = size >> 8;
  eep_reset ();
  ttt_rom_enable ();
  if (read_block == ttt_read_rom_w)
    ttt_set_ai_data (6, 0x94);          // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS
  starttime = time (NULL);
  while (blocksleft-- > 0)
    {
      read_block (address, buffer);             // 0x100 bytes read
      if (read_block == ttt_read_rom_b)
        ucon64_bswap16_n (buffer, 0x100);
      fwrite (buffer, 1, 0x100, file);
      address += 0x100;
      if ((address & 0x3fff) == 0)
        ucon64_gauge (starttime, address, size);
    }
  // original code doesn't call ttt_rom_disable() when byte-size function is
  //  used (ttt_read_rom_b() calls it)
  if (read_block == ttt_read_rom_w)
    ttt_rom_disable ();

  fclose (file);

  return 0;
}
Ejemplo n.º 2
0
void
ttt_write_page_rom (int addr, unsigned char *buf) // original name: writeEEPDataPAGE
{
  int i;

  // send command 0xe8
  ttt_rom_enable ();
  ttt_write_mem (addr, 0xe8);

  // read status
  set_ai (3);
  set_data_read ();
  while (inportb (port_c) < 0x80)
    ;

  set_ai (3);
  outportb (port_c, 0x1f);
  ttt_set_ai_data (6, 0x94);
  set_addr_write (addr);
  for (i = 0; i <= 0x1f; i++)
    outportb (port_c, buf[(addr + i) & 0x3fff]);
  ttt_set_ai_data (6, 0x84);
  set_ai (3);
  outportb (port_c, 0xd0);

  // read status
  set_ai (3);
  set_data_read ();
  while (inportb (port_c) < 0x80)
    ;
  ttt_rom_disable ();
}
Ejemplo n.º 3
0
static void
eep_reset (void)
{
  ttt_rom_enable ();
  ttt_write_mem (0x000000, 0xff);               // reset EEP
  ttt_write_mem (0x200000, 0xff);               // reset EEP
  ttt_rom_disable ();
}
Ejemplo n.º 4
0
void
ttt_write_byte_sharp (int addr, unsigned char b) // original name: writeEEPDataB
{
  ttt_rom_enable ();
  ttt_write_mem (addr, 0x40);
  outportb (port_c, b);
  ttt_rom_disable ();
}
Ejemplo n.º 5
0
void
eep_reset (void)
{
  ttt_rom_enable ();
  ttt_write_mem (0x400000, 0xff);               // reset EEP chip 2
  ttt_write_mem (0, 0xff);                      // reset EEP chip 1
  ttt_write_mem (0x600000, 0xff);               // reset EEP chip 2
  ttt_write_mem (0x200000, 0xff);               // reset EEP chip 1
  ttt_rom_disable ();
}
Ejemplo n.º 6
0
// Sharp function
void
ttt_erase_block (int addr)                      // original name: EraseBLOCK
{
  ttt_rom_enable ();
  ttt_write_mem (addr, 0x50);
  ttt_rom_disable ();

  ttt_rom_enable ();
  ttt_write_mem (addr, 0x20);
  outportb (port_c, 0xd0);
  ttt_rom_disable ();

  ttt_rom_enable ();
  set_ai (3);
  set_data_read ();                             // set read mode
  while (inportb (port_c) < 0x80)
    ;
  ttt_rom_disable ();
}
Ejemplo n.º 7
0
void
readstatus (void)
{                                               // MD-PRO function
  // send command 0xe8
  ttt_rom_enable ();
  set_ai (3);
  set_data_read ();
  while (inportb (port_c) < 0x80)
    ;
  ttt_rom_disable ();
}
Ejemplo n.º 8
0
void
ttt_write_byte_intel (int addr, unsigned char b) // original name: writeIntelEEPDataB
{                                               // MD-PRO function
  ttt_rom_enable ();
  ttt_write_mem (addr, 0x40);
  outportb (port_c, b);

  set_data_read ();
  while (inportb (port_c) < 0x80)
    ;
  ttt_rom_disable ();
}
Ejemplo n.º 9
0
void
ttt_read_rom_b (int addr, unsigned char *buf)   // original name: read_buffb
{
  int count;

  ttt_rom_enable ();
  for (count = 0; count < 0x100; count++)
    {
      set_addr_read (addr + count);
      buf[count] = inportb (port_c);            // read_data ()
    }
  ttt_rom_disable ();
}
Ejemplo n.º 10
0
int
pce_read_rom (const char *filename, unsigned short parport, int size)
{
  FILE *file;
  unsigned char buffer[0x100];
  int blocksleft, address = 0;
  time_t starttime;
  void (*read_block) (int, unsigned char *) = ttt_read_rom_w; // ttt_read_rom_b

  if ((file = fopen (filename, "wb")) == NULL)
    {
      fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename);
      exit (1);
    }
  ttt_init_io (parport);

  printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT);

  if (check_card () == 0)
    {
      fclose (file);
      remove (filename);
      exit (1);
    }

  blocksleft = size >> 8;
  eep_reset ();
  ttt_rom_enable ();
  if (read_block == ttt_read_rom_w)
    ttt_set_ai_data (6, 0x94);          // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS
  starttime = time (NULL);
  while (blocksleft-- > 0)
    {
      read_block (address, buffer);             // 0x100 bytes read
      fwrite (buffer, 1, 0x100, file);
      address += 0x100;
      if ((address & 0x3fff) == 0)
        ucon64_gauge (starttime, address, size);
    }
  // original code doesn't call ttt_rom_disable() when byte-size function is
  //  used (ttt_read_rom_b() calls it)
  if (read_block == ttt_read_rom_w)
    ttt_rom_disable ();

  fclose (file);

  return 0;
}
Ejemplo n.º 11
0
unsigned char
get_id_byte (unsigned char addr)                // original name: GETID
{
  unsigned char byte;

  ttt_rom_enable ();
  ttt_set_ai_data (0, addr);                    // a[7..0] = 0
  set_ai (3);
  outportb (port_c, 0x90);                      // write_data ()

  set_ai (3);
  set_data_read ();                             // ninit=0, nwrite=1
  byte = inportb (port_c);                      // read_data ()
  ttt_rom_disable ();

  return byte;
}