Exemple #1
0
/*
    Programming timer callback
*/
void at29x_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch (m_pgm)
	{
	case PGM_1:
		// Programming cycle timeout
		logerror("%s: Programming cycle timeout\n", tag());
		m_pgm = PGM_0;
		break;

	case PGM_2:
		// Programming cycle start
		if (TRACE_PRG) logerror("%s: Sector write start\n", tag());
		m_pgm = PGM_3;
		// We assume a typical delay of 70% of the max value
		m_programming_timer->adjust(attotime::from_msec(m_cycle_time*7/10));
		break;

	case PGM_3:
		// Programming cycle end; now burn the buffer into the flash EEPROM
		memcpy(m_eememory.get() + 2 + get_sector_number(m_programming_last_offset) * m_sector_size, m_programming_buffer.get(), m_sector_size);

		if (TRACE_PRG) logerror("%s: Sector write completed at location %04x\n", tag(), m_programming_last_offset);

		// Data protect state will be activated at the end of the program cycle [1]
		if (m_enabling_sdb)  m_sdp = true;

		// Data protect state will be deactivated at the end of the program period [1]
		if (m_disabling_sdb) m_sdp = false;

		if (TRACE_PRG) logerror("%s: Software data protection = %d\n", tag(), m_sdp);

		m_pgm = PGM_0;
		m_enabling_sdb = false;
		m_disabling_sdb = false;
		sync_flags();
		break;

	default:
		logerror("%s: Invalid state %d during programming\n", tag(), m_pgm);
		m_pgm = PGM_0;
		break;
	}
}
Exemple #2
0
/**
	Find the first entry of a cluster
	@param fs FS_Instance to find all the information from
	@param current_cluster Cluster to find the first entry for
	@return Location of the first entry
**/
uint32_t find_first_entry(FS_Instance *fs, uint32_t current_cluster) {
	uint32_t sector_number = get_sector_number(fs, current_cluster);
	uint32_t offset = get_offset(fs, current_cluster);
	uint32_t bytes_per_sector = fs->BPB_BytsPerSec;
	uint32_t entry = 0xFFFFFFFF;
	uint8_t *sector;
	
	if((fs->fat_type == 12) && (offset == (fs->BPB_BytsPerSec - 1)) && !((sector_number - fs->BPB_RsvdSecCnt) == (fs->BPB_FATSz16 - 1))) {
		bytes_per_sector *= 2;
	}
	
	sector = malloc(bytes_per_sector);
	if(NULL == sector) {
		return 0;
	}
	
	fseek(fs->image, (sector_number * fs->BPB_BytsPerSec), SEEK_SET);
	fread(sector, bytes_per_sector, 1, fs->image);
	
	switch(fs->fat_type) {
		case 12:
			if(current_cluster % 2) {
				entry = ((*((uint16_t *)&sector[offset])) >> 4);
			} else {