#!/usr/bin/perl

@DEFAULT_target_config = (
                           "true",                       # use cusstom settings?
			   "Generic",                    # target processor
			   "PowerTAP PRO CCS",           # connection (probe name)
			   "false",                      # use target initialization file?
			   "target_configuration_file",  # target configuration filename
			   0x00000000,                   # target memory buffer base address
			   0x00020000,                   # target memory buffer size
			   "true",                       # enable logging
			   "false",                      # verify memory writes
                         );

@DEFAULT_flash_config = (
                          0xFF800000,                    # flash memory base address			 
			  "LH28F016SC",                  # flash device name
			  "2048Kx8x4",                   # flash memory organization
			  0xFF800000,                    # flash memory start address
			  0xFFFFFFFF,                    # flash memory end address
                        );
			
@DEFAULT_program_verify_config = (
                          "false",                       # use selected file for program/verify operation?
			  "nofile",                      # selected filename
			  "Auto Detect",                 # File IO type
			  "true",                        # restrict address range?
			  0xFF800000,                    # restrict address range: start address (usually == flash memory start address)
			  0xFFFFFFFF,                    # restrict address range: end address (usually == flash memory end address)
			  "false",                       # apply offset to current file?
			  0x00000000,                    # offset value
                        );			

@DEFAULT_erase_blankcheck_config = (
                          "false",                       # erase all sectors (has chip erase feature)?
			  (""),                          # selected sectors (string, list or reference? not yet decided)
			  "true",                        # process sectors individually?
                        );

@DEFAULT_checksum_config = (
                          "FileOnTarg",                  # compute checsum method
			  0xFF800000,                    # start address (for Memory Range on Target option)
			  0x007FFFFF,                    # end address (for Memory Range on Target option)
                        );
			
sub metrowerks_flash_config_style
{
  my $FILE_REF;
  my $target_config_ref, $flash_config_ref, $program_verify_config_ref, $referase_blankcheck_config_ref, $checksum_config_ref;
  my @target_config, @flash_config, @program_verify_config, @erase_blankcheck_config, @checksum_config;
  
  ($FILE_REF, $target_config_ref, $flash_config_ref, $program_verify_config_ref, $referase_blankcheck_config_ref, $checksum_config_ref) = @_;

  @target_config    = @{$target_config_ref};
  @flash_config     = @{$flash_config_ref};
  
  @program_verify_config   = @{$program_verify_config_ref};
  @erase_blankcheck_config = @{$referase_blankcheck_config_ref};
  @checksum_config         = @{$checksum_config_ref};
  
  printf $FILE_REF ("<\?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"no\" \?>\r\n");
  printf $FILE_REF ("<fpconfig>\r\n\r\n");

  printf $FILE_REF ("  <targetconfwindow>\r\n");
  printf $FILE_REF ("    <usecustomsettings>".$target_config[0]."</usecustomsettings>\r\n");
  printf $FILE_REF ("    <targetprocessor>".$target_config[1]."</targetprocessor>\r\n");
  printf $FILE_REF ("    <connection>".$target_config[2]."</connection>\r\n");
  printf $FILE_REF ("    <usetargetinit>".$target_config[3]."</usetargetinit>\r\n");
  printf $FILE_REF ("    <targetinitfile>".$target_config[4]."</targetinitfile>\r\n");
  printf $FILE_REF ("    <targetmembuffaddr>0x%08X</targetmembuffaddr>\r\n", $target_config[5]);
  printf $FILE_REF ("    <targetmembuffsize>0x%08X</targetmembuffsize>\r\n", $target_config[6]);
  printf $FILE_REF ("    <enablelogging>".$target_config[7]."</enablelogging>\r\n");
  printf $FILE_REF ("    <verifywrites>".$target_config[8]."</verifywrites>\r\n");
  printf $FILE_REF ("  </targetconfwindow>\r\n\r\n");

  printf $FILE_REF ("  <flashconfwindow>\r\n");
  printf $FILE_REF ("    <membaseaddr>0x%08X</membaseaddr>\r\n", $flash_config[0]);
  printf $FILE_REF ("    <device>".$flash_config[1]."</device>\r\n");
  printf $FILE_REF ("    <organization>".$flash_config[2]."</organization>\r\n");
  printf $FILE_REF ("    <flashstart>0x%08X</flashstart>\r\n", $flash_config[3]);
  printf $FILE_REF ("    <flashend>0x%08X</flashend>\r\n", $flash_config[4]);
  printf $FILE_REF ("  </flashconfwindow>\r\n\r\n");

  printf $FILE_REF ("  <programverifywindow>\r\n");
  printf $FILE_REF ("    <useselectedfile>".$program_verify_config[0]."</useselectedfile>\r\n");
  printf $FILE_REF ("    <projbuildtargetfile>".$program_verify_config[1]."</projbuildtargetfile>\r\n");
  printf $FILE_REF ("    <fileiotype>".$program_verify_config[2]."</fileiotype>\r\n");
  printf $FILE_REF ("    <restrictaddrrange>".$program_verify_config[3]."</restrictaddrrange>\r\n", );
  printf $FILE_REF ("    <restrictaddrrangestart>0x%08X</restrictaddrrangestart>\r\n", $program_verify_config[4]);
  printf $FILE_REF ("    <restrictaddrrangeend>0x%08X</restrictaddrrangeend>\r\n", $program_verify_config[5]);
  printf $FILE_REF ("    <applyaddroffset>".$program_verify_config[6]."</applyaddroffset>\r\n");
  printf $FILE_REF ("    <addroffset>0x%08X</addroffset>\r\n", $program_verify_config[7]);
  printf $FILE_REF ("  </programverifywindow>\r\n\r\n");

  printf $FILE_REF ("  <eraseblankcheckwindow>\r\n");
  printf $FILE_REF ("    <eraseallsectors>".$erase_blankcheck_config[0]."</eraseallsectors>\r\n");
  printf $FILE_REF ("    <sector>".$erase_blankcheck_config[1]."</sector>\r\n"); # TO DO !!!
  printf $FILE_REF ("    <processsectorsindividually>".$erase_blankcheck_config[2]."</processsectorsindividually>\r\n");
  printf $FILE_REF ("  </eraseblankcheckwindow>\r\n\r\n");

  printf $FILE_REF ("  <checksumwindow>\r\n");
  printf $FILE_REF ("    <computechecksumover>".$checksum_config[0]."</computechecksumover>\r\n");
  printf $FILE_REF ("    <addrstart>0x%08X</addrstart>\r\n", $checksum_config[1]);
  printf $FILE_REF ("    <addrsize>0x%08X</addrsize>\r\n", $checksum_config[2]);
  printf $FILE_REF ("  </checksumwindow>\r\n\r\n");

  printf $FILE_REF ("</fpconfig>\r\n");
}


sub generate_config_file
{
  my $config_filename;
  my $proc_type, $connection_type, $target_init_filename, $mem_buffer_start_address, $mem_buffer_size;
  my $flash_base_address, $flash_dev_name, $flash_dev_org;
  my $chip_size, $chip_buslen, $chip_no, $flash_end_address, $flash_size;

  my @target_config, @flash_config, @program_verify_config, @erase_blankcheck_config, @checksum_config;
  my $i1, $i2;

  ($config_filename, $proc_type, $connection_type,
   $target_init_filename, $mem_buffer_start_address, $mem_buffer_size,
   $flash_base_address, $flash_dev_name, $flash_dev_org) = @_;
   
  @target_config    = @DEFAULT_target_config;
  @flash_config     = @DEFAULT_flash_config;
  
  @program_verify_config   = @DEFAULT_program_verify_config;
  @erase_blankcheck_config = @DEFAULT_erase_blankcheck_config;
  @checksum_config         = @DEFAULT_checksum_config;

  $target_config[1] = $proc_type       if ( $proc_type );       # set processor type
  $target_config[2] = $connection_type if ( $connection_type ); #set connection type
  if ( $target_init_filename )
  {
    $target_config[3] = "true";
    $target_config[4] = $target_init_filename; #set initialization file
  }
  $target_config[5] = $mem_buffer_start_address if ( $mem_buffer_start_address ); # mem buffer start address
  $target_config[6] = $mem_buffer_size          if ( $mem_buffer_size );          # mem buffer size
  
  
  if ( $flash_base_address == "" || $flash_base_address < 0 )
  {
    $flash_base_address = 0;
  }
  $flash_config[0] = $flash_config[3] = $program_verify_config[4] = $checksum_config[1] = $flash_base_address; # flash base address for restrict addr. range, checksum, etc
  
  $flash_config[1] = $flash_dev_name     if ( $flash_dev_name ); # set flash device name
  $flash_config[2] = $flash_dev_org      if ( $flash_dev_org );  # det flash device organization
  
  # compute the flash memory size starting from the flash device organization
  @_ = ();
  
  split(/x/, $flash_config[2]);
  split(/X/, $flash_config[2])  if ( @_ == 1 );
  
  if ( @_ == 1 )
  {
    printf "ERROR: Invalid flash device organization !!!\r\n";
    exit(1);
  }
  
  ($chip_size, $chip_buslen, $chip_no) = @_;

  $chip_buslen = $chip_buslen / 8;
  $chip_buslen = 1 unless ( $chip_buslen );
  $chip_no = 1     unless ( $chip_no );

  $i1 = index($chip_size, "M");
  $i2 = index($chip_size, "m");
  if ( $i1 != -1 || $i2 != -1 )
  {
    chop($chip_size);
    $chip_size *= 1024 * 1024;
  }
  else
  {
    $i1 = index($chip_size, "K");
    $i2 = index($chip_size, "k");
    if ( $i1 != -1 || $i2 != -1 )
    {
      chop($chip_size);
      $chip_size *= 1024;
    }
  }

  $flash_size = $chip_size * $chip_buslen * $chip_no;
  # end of compute the flash memory size starting from the flash device organization

  $flash_end_address = $flash_base_address + $flash_size - 1;
  
  $flash_config[4] = $program_verify_config[5] = $flash_end_address; # flash_end_address, restrict adress range end address
  $checksum_config[2] = $flash_size; # compute checksum over a range: range size
  
  open(FILE, "> ".$config_filename);

  metrowerks_flash_config_style(\*FILE, \@target_config,
                                \@flash_config, \@program_verify_config,
			        \@erase_blankcheck_config, \@checksum_config);
  close(FILE);
  
}

# open(FILE, ">-");
# metrowerks_flash_config_style(\*FILE, \@DEFAULT_target_config,
#                               \@DEFAULT_flash_config, \@DEFAULT_program_verify_config,
#			      \@DEFAULT_erase_blankcheck_config, \@DEFAULT_checksum_config);
# close(FILE);

my %target_list_hash;
	 
@{$target_list_hash{"555_AXIOM"}} = (
	   "555_AXIOM.xml",
	   "555",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\555_AXIOM_flash_init.cfg',
	   0x003F9800,
	   0x00006000,
	   0x00000000,
	   "MPC555",
	   "448Kx8x1",
         );
	 

@{$target_list_hash{"555_AXIOM_SHADOW"}} = (
	   "555_AXIOM_SHADOW.xml",
	   "555",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\555_AXIOM_vfSH_flash_init.cfg',
	   0x003F9800,
	   0x00006000,
	   0x00000000,
	   "MPC555 SHADOW",
	   "512x8x1",
         );
	 

@{$target_list_hash{"555_AXIOM_EXTERNAL_FLASH"}} = (
	   "555_AXIOM_external_flash.xml",
	   "555",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\555_AXIOM_flash_init.cfg',
	   0x003F9800,
	   0x00006000,
	   0x00800000,
	   "AM29LV400BB",
	   "256Kx16x2",
         );
	 

 @{$target_list_hash{"555_ETAS"}} = (
	   "555_ETAS.xml",
	   "555",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\555_ETAS_flash_init.cfg',
	   0x003F9800,
	   0x00006000,
	   0x00000000,
	   "MPC555",
	   "448Kx8x1",
         );
	 

@{$target_list_hash{"555_ETAS_SHADOW"}} = (
	   "555_ETAS_SHADOW.xml",
	   "555",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\555_ETAS_vfSH_flash_init.cfg',
	   0x003F9800,
	   0x00006000,
	   0x00000000,
	   "MPC555 SHADOW",
	   "512x8x1",
         );
	 

@{$target_list_hash{"565_AXIOM"}} = (
	   "565_AXIOM.xml",
	   "565",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\565_AXIOM_flash_init.cfg',
	   0x003F8000,
	   0x00006000,
	   0x00000000,
	   "MPC565",
	   "1Mx8x1",
         );
	 

@{$target_list_hash{"565_AXIOM_SHADOW"}} = (
	   "565_AXIOM_SHADOW.xml",
	   "565",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\565_AXIOM_vfSH_flash_init.cfg',
	   0x003F8000,
	   0x00006000,
	   0x00000000,
	   "MPC565 SHADOW",
	   "512x8x1",
         );
	 

@{$target_list_hash{"565_AXIOM_EXTERNAL_FLASH"}} = (
	   "565_AXIOM_external_flash.xml",
	   "565",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\565_AXIOM_flash_init.cfg',
	   0x003F8000,
	   0x00006000,
	   0x00800000,
	   "AM29BL162C",
	   "1Mx16x2",
         );
	 

@{$target_list_hash{"56x_CHIP"}} = (
	   "56x_CHIP.xml",
	   "565",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\5xx\56X_CHIP_init.cfg',
	   0x003F8000,
	   0x00006000,
	   0x00000000,
	   "MPC565",
	   "1Mx8x1",
         );
	 

@{$target_list_hash{"5100-IceCube"}} = (
	   "5100-IceCube.xml",
	   "5100",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\52xx\5100_Icecube_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV065D",
	   "8Mx8x1",
         );
	 

@{$target_list_hash{"Lite5200_8M"}} = (
	   "Lite5200_8MB_flash.xml",
	   "5200",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\52xx\Lite5200_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV065D",
	   "8Mx8x1",
         );


@{$target_list_hash{"Lite5200_16M"}} = (
	   "Lite5200_16MB_flash.xml",
	   "5200",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\52xx\Lite5200_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF000000,
	   "AM29LV652D",
	   "16Mx8x1",
         );


@{$target_list_hash{"862_ADS"}} = (
	   "862_ADS.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\862_ADS_NewMode_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFE00000,
	   "AM29F040B",
	   "512Kx8x4",
         );
	 

@{$target_list_hash{"866_ADS"}} = (
	   "866_ADS.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\866_ADS_NewMode_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFE00000,
	   "AM29F040B",
	   "512Kx8x4",
         );


@{$target_list_hash{"8xx_FADS"}} = (
	   "8xx_FADS.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\8xx_FADS_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFE00000,
	   "AM29F040B",
	   "512Kx8x4",
         );


@{$target_list_hash{"8xx_DUET_ADS_Motorola"}} = (
#	   "8xx_DUET_ADS_Motorola_SIMM.xml",
	   "8xx_DUET_ADS.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\885ads_init.cfg',
	   0x00000000,
	   0x00020000,
	   0x02800000,
	   "AM29F040B",
	   "512Kx8x4",
         );


#@{$target_list_hash{"8xx_DUET_ADS_Smart"}} = (
#	   "8xx_DUET_ADS_Smart_SIMM.xml",
#	   "8xx",
#	   "PowerTAP PRO DPI",
#	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\885ads_init.cfg',
#	   0x00000000,
#	   0x00020000,
#	   0x02800000,
#	   "LH28F016SC",
#	   "2048Kx8x4",
#         );


@{$target_list_hash{"857_IAD"}} = (
	   "857_IAD.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\857DSL_IAD_init.cfg',
	   0x00000000,
	   0x00020000,
	   0x02800000,
	   "AM29LV320DT",
	   "2Mx16x2",
         );
	 

@{$target_list_hash{"RPX Lite BW"}} = (
	   "8xxEP_RPX_Lite_BW.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\8xx_RPX_BW_50M_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV160BB",
	   "2Mx8x4",
         );
	 

@{$target_list_hash{"RPX Lite DW"}} = (
	   "8xxEP_RPX_Lite_DW.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\8xx_RPX_DW_50M_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV160BB",
	   "2Mx8x4",
         );
	 

@{$target_list_hash{"862_EP_first_bank"}} = (
	   "862EP_first_bank.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\862_EP_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV160BB",
	   "1Mx16x2",
         );
	 

@{$target_list_hash{"862_EP_second_bank"}} = (
	   "862EP_second_bank.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\862_EP_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFC00000,
	   "AM29LV160BB",
	   "1Mx16x2",
         );


@{$target_list_hash{"852_EP"}} = (
	   "852EP.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\852_EP_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV320MB",
	   "2Mx16x2",
         );



@{$target_list_hash{"8xx_RPX_CLLF"}} = (
	   "8xx_RPX_CLLF.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\8xx_RPX_BW_50M_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV160BB",
	   "2Mx8x4",
         );

@{$target_list_hash{"8260_EP_8M"}} = (
	   "8260EP_8M_FLASH.xml",
	   "8260",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8260_EP_init_1.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV160BB",
	   "1Mx16x4",
         );


@{$target_list_hash{"8260_EP_16M"}} = (
	   "8260EP_16M_FLASH.xml",
	   "8260",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8260_EP_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF000000,
	   "AM29DL323CB",
	   "2Mx16x4",
         );
	 

@{$target_list_hash{"603ei_AMC_Eval"}} = (
	   "603ei_AMC_Eval.xml",
	   "603ei",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\603ei_AMCEval_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFC00000,
	   "AM29LV800BB",
	   "512Kx16x4",
         );
	 
@{$target_list_hash{"603e_Excimer"}} = (
	   "603e_Excimer.xml",
	   "603e",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\603_Excimer_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFC00000,
	   "AM29LV800BB",
	   "512Kx16x4",
         );
	 

@{$target_list_hash{"7400_Maximer"}} = (
	   "7400_Maximer.xml",
	   "7400",
	   "Abatron Serial",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\Host\7400_Maximer_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFC00000,
	   "AM29LV800BB",
	   "512Kx16x4",
         );
	 

@{$target_list_hash{"8260_ADS"}} = (
	   "8260_ADS.xml",
	   "8260",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8260_ADS_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );


@{$target_list_hash{"8250_ADS_PCI"}} = (
	   "8250_ADS_PCI.xml",
	   "8250",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8250_ADS_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );
	 

@{$target_list_hash{"8264_ADS_PCI"}} = (
	   "8264_ADS_PCI.xml",
	   "8264",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8264_ADS_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );
	 

@{$target_list_hash{"8265_ADS_PCI"}} = (
	   "8265_ADS_PCI.xml",
	   "8265",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8265_ADS_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );


@{$target_list_hash{"8266_ADS_PCI"}} = (
	   "8266_ADS_PCI.xml",
	   "8266",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8266_ADS_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );


@{$target_list_hash{"8266_ADS_PCI_AI"}} = (
	   "8266_ADS_PCI_AI_EEPROM_boot.xml",
	   "8266",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8266AI_ADS_init_EPROM.cfg',
	   0x00000000,
	   0x00020000,
	   0xFFC00000,
	   "AM29F160DB",
	   "1Mx16x2",
         );


@{$target_list_hash{"82xx_PQ2_FADS_ZU"}} = (
	   "82xx_PQ2_FADS_ZU.xml",
	   "8270",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\PQ2_FADS_ZU_Local_init_100MHz.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );
	 

@{$target_list_hash{"PQ27e"}} = (
	   "PQ27e.xml",
	   "8270",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\PQ27e_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "LH28F016SC",
	   "2048Kx8x4",
         );
	 


@{$target_list_hash{"8560_ADS_Pilot_FLASH"}} = (
	   "8560_ADS_Pilot_FLASH_boot.xml",
	   "8560",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ3\8560ADS_init.cfg',
	   0x00002000,
	   0x00020000,
	   0xFF000000,
	   "IN28F640J3",
	   "4Mx16x2",
         );

@{$target_list_hash{"8560_ADS_Pilot_EEPROM"}} = (
	   "8560_ADS_Pilot_EEPROM_boot.xml",
	   "8560",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ3\8560ADS_boot_seq_init.cfg',
	   0x00002000,
	   0x00020000,
	   0xFF000000,
	   "IN28F640J3",
	   "4Mx16x2",
         );
	 

@{$target_list_hash{"8560_ADS_Prototype"}} = (
	   "8560_ADS_Prototype.xml",
	   "8560",
	   "PowerTAP PRO CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ3\8560ADS_prototype_init.cfg',
	   0x00002000,
	   0x00020000,
	   0xFF800000,
	   "IN28F640J3",
	   "4Mx16x1",
         );
	 

@{$target_list_hash{"824x_Sandpoint"}} = (
	   "824x_Sandpoint.xml",
	   "8240",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\Host\Sandpoint_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "M29W800AB",
	   "1Mx8x2",
         );
	 

@{$target_list_hash{"7xx_Sandpoint"}} = (
	   "7xx_Sandpoint.xml",
	   "740",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\Host\Sandpoint_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "M29W800AB",
	   "1Mx8x2",
         );
	 

@{$target_list_hash{"74x0_Sandpoint"}} = (
	   "74x0_Sandpoint.xml",
	   "7400",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\Host\74xx_Sandpoint_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "M29W800AB",
	   "1Mx8x2",
         );
	 

@{$target_list_hash{"745x_Sandpoint"}} = (
	   "745x_Sandpoint.xml",
	   "7450",
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\Host\7450_Sandpoint_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "M29W800AB",
	   "1Mx8x2",
         );
	 

@{$target_list_hash{"7457_Sandpoint"}} = (
	   "7457_Sandpoint.xml",
	   '744x/745x',
	   "PowerTAP PRO JTAG",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\Host\7457_Sandpoint_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "M29W800AB",
	   "1Mx8x2",
         );

@{$target_list_hash{"862_EP_MPC866"}} = (
	   "862EP_MPC866.xml",
	   "8xx",
	   "PowerTAP PRO DPI",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\862_EP_MPC866_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF000000,
	   "AM29LV640M",
	   "4Mx16x2",
         );

@{$target_list_hash{"875_AM_Adder"}} = (
	   "875AM_Adder.xml",
	   "875",
	   "WireTAP 8xx",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ1\875_AM_Adder_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV641DU",
	   "4Mx16x1",
         );

@{$target_list_hash{"8250_AM_PCI"}} = (
	   "8250_AM_PCI.xml",
	   "8250",
	   "WireTAP CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8250_AM_Rattler_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV641DU",
	   "4Mx16x1",
         );

@{$target_list_hash{"8280_AM_PCI"}} = (
	   "8280_AM_PCI.xml",
	   "8280",
	   "WireTAP CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ2\8280_AM_Rattler_init.cfg',
	   0x00000000,
	   0x00020000,
	   0xFF800000,
	   "AM29LV641DU",
	   "4Mx16x1",
         );

@{$target_list_hash{"8540_EVAL_FLASH"}} = (
	   "8540_EVAL_FLASH.xml",
	   "8540",
	   "WireTAP CCS",
	   '{CodeWarrior}\PowerPC_EABI_Support\Initialization_Files\PQ3\8540EVAL_init.cfg',
	   0x00002000,
	   0x00020000,
	   0xFF800000,
	   "IN28F640J3",
	   "4Mx16x1",
         );

foreach (keys(%target_list_hash))
{
  printf "Generating config file for: ".$_."\r\n";
  generate_config_file(@{$target_list_hash{$_}});
}

