[LinuxBIOS] GSoC -- Winflashrom Last Status

Darmawan Salihun darmawan.salihun at gmail.com
Mon Aug 20 11:59:12 CEST 2007


Hi all,
   The latest code from winflashrom is attached (overall code in tar.gz
format) and the diff. Anyway, sorry about the diff because it's
reversed, I can't get TortoiseCVS to make it not reversed. I don't know
why the diff is always reversed like that. I'll be moving to command
line SVN very soon to alleviate the problem.
   Anyway, I might be uploading an updated code in the next few hours.
This is only for GSoC "compliance". The current version has no DPC
support what so ever :(. I'll submit the one with DPC in the next few
hours. This is merely to make sure that there is a working code
submitted prior to GSoC "pencils down" time limit.
   Note that this version has an improved support for Winbond W39V040FA
flashchip. The original support in flashrom is *not* working because
it's not setting the Block Locking Register (BLR) prior to flashing.
I'll add the patch to the Linux version in the next few days (I need to
test it in my machine before hand even if winflashrom shows it's working
flawlessly). The excerpt as follows:
----------------------------------------------------
enum {
	BLOCKING_REGS_PHY_RANGE = 0x80000,
	BLOCKING_REGS_PHY_BASE = 0xFFB80000,
};


static volatile char * unprotect_39v040fa(void)
{
	unsigned char i, byte_val;
	volatile char * block_regs_base;

	block_regs_base = (volatile char*) map_physical_addr_range(
                                               BLOCKING_REGS_PHY_BASE,
                                             BLOCKING_REGS_PHY_RANGE);
	if (block_regs_base == NULL) {
		perror("Error: Unable to map Winbond w39v040fa"
                       "blocking registers!\n");
		return NULL;
	}

	//
	// Unprotect the BIOS chip address range
	//
	for( i = 0; i < 8 ; i++ )
	{
		byte_val =  *(block_regs_base + 2 + i*0x10000);
		myusec_delay(10);
		byte_val &= 0xF8; // Enable full access to the chip
		*(block_regs_base + 2 + i*0x10000) = byte_val;
		myusec_delay(10);
	}

	return block_regs_base;
}


static void protect_39v040fa(volatile char * reg_base)
{
	//
	// Protect the BIOS chip address range
	//
	unsigned char i, byte_val;
	volatile char * block_regs_base = reg_base;

	for( i = 0; i < 8 ; i++ )
	{
		byte_val = *(block_regs_base + 2 + i*0x10000);
		myusec_delay(10);
		byte_val |= 1; // Prohibited to write in the block
                               // where set
		*(block_regs_base + 2 + i*0x10000) = byte_val;
		myusec_delay(10);
	}

	unmap_physical_addr_range((void*) reg_base, BLOCKING_REGS_PHY_RANGE);
}


int write_39v040fa(struct flashchip *flash, uint8_t *buf)
{
	int i;
	int total_size = flash->total_size * 1024;
	int page_size = flash->page_size;
	volatile uint8_t *bios = flash->virtual_memory;
	volatile char * reg_base;
	
	reg_base = unprotect_39v040fa();
	erase_chip_jedec(flash);

	printf("Programming Page: ");
	for (i = 0; i < total_size / page_size; i++) {
		/* write to the sector */
		printf("%04d at address: 0x%08x", i, i * page_size);
		write_sector_jedec(bios, buf + i * page_size,
				   bios + i * page_size, page_size);
		
                printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
		fflush(stdout);
	}
	printf("\n");

	if(NULL != reg_base)
	{
	    protect_39v040fa(reg_base);
	}
	
	return (0);
}
---------------------------------------------------------------
   That's all for now.



Regards,

Darmawan Salihun
--------------------------------------------------------------------
-= Human knowledge belongs to the world =-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winflashrom.tar.gz
Type: application/x-gzip
Size: 121570 bytes
Desc: not available
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20070820/85bffcff/attachment.gz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winflashrom.diff
Type: application/octet-stream
Size: 48438 bytes
Desc: not available
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20070820/85bffcff/attachment.obj>


More information about the coreboot mailing list