Example #1
0
/* Loader proper */
t_stat sim_load (FILE *fi, char *cptr, char *fnam, int flag)
{
  int rombase;
  int c1, c2, i;
  if (flag == 1) /* don't dump */
    return SCPE_ARG;
  /* this assumes a HDT style ROM, where the first 2 bytes refer to the 
   * actual word start of the ROM, e.g. with PDQ-3 the HDT ROM has 0xf401
   * as the first word, so it will load at word address 0xf400, and 0xfc68
   * will be preset to 0xf401
   */
  c1 = fgetc(fi);
  c2 = fgetc(fi);
  rombase = c1 + c2 * 256;
  rom_write(rombase & 0xfffe, rombase);
  reg_fc68 = rombase;
  i = 0;
  while (!feof(fi) && i<0x1ff) {
    c1 = fgetc(fi);
    c2 = fgetc(fi);
    rom_write(rombase+i, (uint16)(c1 + c2*256));
    i++;
  }
  reg_romsize = i;
  /* preset the cpu_serial number from ROM, may be overwritten manually for special purposes */
  rom_read(rombase+i-1, &reg_cpuserial);
  return SCPE_OK;
}
void
putchar(int x)
{
	char c = x;

	rom_write(1, &c, 1);
}
Example #3
0
static int _write_rom_byte(volatile uint8_t *addr, uint8_t data, void *arg) {
	HexStat *stat = arg;
	uint32_t rom_addr = ((uint32_t) addr) & (ROM_SIZE - 1);
	rom_write(rom_addr, &data, 1);
	stat->size++;
	if(rom_addr < stat->offset)
		stat->offset = rom_addr;
	return 0;
}
void
putchar(int x)
{
	char c = x;

	if (apbus)
		apcall_write(1, &c, 1);
	else
		rom_write(1, &c, 1);
}
Example #5
0
void load_hex_to_rom(const char *path) {
		void *entry;
		HexStat stat = {0, 0xFFFFFFFF};
		RomHeader header;
		int x, y;
		int fd;
		
		printf("Erasing ROM... ");
		
		rom_erase();
		while(rom_status() & 0x1);
		
		terminal_set_fg(TERMINAL_COLOR_LIGHT_GREEN);
		printf("done.\n");
		terminal_set_fg(TERMINAL_COLOR_LIGHT_GRAY);
		
		printf("Writing to ROM... ");
		terminal_get_pos(&x, &y);
		
		fd = fat_open(path, O_RDONLY);
		
		if(hexload(get_byte, fd, _write_rom_byte, &stat, &entry) < 0) {
			terminal_set_fg(TERMINAL_COLOR_RED);
			printf("Invalid hex file");
			terminal_set_fg(TERMINAL_COLOR_LIGHT_GRAY);
			
			fat_close(fd);
			return;
		}
		fat_close(fd);
		
		header.magic = 0xDEADBEEF;
		header.entry = (uint32_t) entry;
		header.size = stat.size;
		header.dest_addr = LLRAM_BASE | stat.offset;
		header.flash_offset = stat.offset;
		
		rom_write(ROM_SIZE - 512, (void *) &header, sizeof(header));
		
		terminal_set_pos(x, y);
		terminal_set_fg(TERMINAL_COLOR_LIGHT_GREEN);
		printf("done.\n");
		terminal_set_fg(TERMINAL_COLOR_LIGHT_GRAY);
		printf("Press any key...");
}