mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-04 07:00:39 +01:00 
			
		
		
		
	cli_classic.c: Convert do_erase() to libflashrom call
Inline emergency_help_message() to cli_classic call site. This leaves do_erase() a redudant wrapper and moves us a step closer to cli_classic as a pure libflashrom user by using flashrom_flash_erase(). BUG=b:208132085 TEST=`flashrom -E` Change-Id: I8566164e7dbad69cf478b24208014f10fb99e4d0 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/60068 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
		
				
					committed by
					
						
						Edward O'Callaghan
					
				
			
			
				
	
			
			
			
						parent
						
							f136a2a69c
						
					
				
				
					commit
					7a2d7efd83
				
			@@ -840,8 +840,18 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
		ret = do_read(fill_flash, filename);
 | 
							ret = do_read(fill_flash, filename);
 | 
				
			||||||
	else if (extract_it)
 | 
						else if (extract_it)
 | 
				
			||||||
		ret = do_extract(fill_flash);
 | 
							ret = do_extract(fill_flash);
 | 
				
			||||||
	else if (erase_it)
 | 
						else if (erase_it) {
 | 
				
			||||||
		ret = do_erase(fill_flash);
 | 
							ret = flashrom_flash_erase(fill_flash);
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							 * FIXME: Do we really want the scary warning if erase failed?
 | 
				
			||||||
 | 
							 * After all, after erase the chip is either blank or partially
 | 
				
			||||||
 | 
							 * blank or it has the old contents. A blank chip won't boot,
 | 
				
			||||||
 | 
							 * so if the user wanted erase and reboots afterwards, the user
 | 
				
			||||||
 | 
							 * knows very well that booting won't work.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							if (ret)
 | 
				
			||||||
 | 
								emergency_help_message();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	else if (write_it)
 | 
						else if (write_it)
 | 
				
			||||||
		ret = do_write(fill_flash, filename, referencefile);
 | 
							ret = do_write(fill_flash, filename, referencefile);
 | 
				
			||||||
	else if (verify_it)
 | 
						else if (verify_it)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								flash.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								flash.h
									
									
									
									
									
								
							@@ -344,6 +344,7 @@ int probe_flash(struct registered_master *mst, int startchip, struct flashctx *f
 | 
				
			|||||||
int read_flash_to_file(struct flashctx *flash, const char *filename);
 | 
					int read_flash_to_file(struct flashctx *flash, const char *filename);
 | 
				
			||||||
int verify_range(struct flashctx *flash, const uint8_t *cmpbuf, unsigned int start, unsigned int len);
 | 
					int verify_range(struct flashctx *flash, const uint8_t *cmpbuf, unsigned int start, unsigned int len);
 | 
				
			||||||
int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran, const uint8_t erased_value);
 | 
					int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran, const uint8_t erased_value);
 | 
				
			||||||
 | 
					void emergency_help_message(void);
 | 
				
			||||||
void print_version(void);
 | 
					void print_version(void);
 | 
				
			||||||
void print_buildinfo(void);
 | 
					void print_buildinfo(void);
 | 
				
			||||||
void print_banner(void);
 | 
					void print_banner(void);
 | 
				
			||||||
@@ -355,7 +356,6 @@ int prepare_flash_access(struct flashctx *, bool read_it, bool write_it, bool er
 | 
				
			|||||||
void finalize_flash_access(struct flashctx *);
 | 
					void finalize_flash_access(struct flashctx *);
 | 
				
			||||||
int do_read(struct flashctx *, const char *filename);
 | 
					int do_read(struct flashctx *, const char *filename);
 | 
				
			||||||
int do_extract(struct flashctx *);
 | 
					int do_extract(struct flashctx *);
 | 
				
			||||||
int do_erase(struct flashctx *);
 | 
					 | 
				
			||||||
int do_write(struct flashctx *, const char *const filename, const char *const referencefile);
 | 
					int do_write(struct flashctx *, const char *const filename, const char *const referencefile);
 | 
				
			||||||
int do_verify(struct flashctx *, const char *const filename);
 | 
					int do_verify(struct flashctx *, const char *const filename);
 | 
				
			||||||
int register_chip_restore(chip_restore_fn_cb_t func, struct flashctx *flash, uint8_t status);
 | 
					int register_chip_restore(chip_restore_fn_cb_t func, struct flashctx *flash, uint8_t status);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								flashrom.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								flashrom.c
									
									
									
									
									
								
							@@ -1553,7 +1553,7 @@ static void nonfatal_help_message(void)
 | 
				
			|||||||
			 "https://www.flashrom.org/Contact for details), thanks!\n");
 | 
								 "https://www.flashrom.org/Contact for details), thanks!\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void emergency_help_message(void)
 | 
					void emergency_help_message(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	msg_gerr("Your flash chip is in an unknown state.\n");
 | 
						msg_gerr("Your flash chip is in an unknown state.\n");
 | 
				
			||||||
#if CONFIG_INTERNAL == 1
 | 
					#if CONFIG_INTERNAL == 1
 | 
				
			||||||
@@ -2208,23 +2208,6 @@ int do_extract(struct flashctx *const flash)
 | 
				
			|||||||
	return do_read(flash, NULL);
 | 
						return do_read(flash, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int do_erase(struct flashctx *const flash)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	const int ret = flashrom_flash_erase(flash);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * FIXME: Do we really want the scary warning if erase failed?
 | 
					 | 
				
			||||||
	 * After all, after erase the chip is either blank or partially
 | 
					 | 
				
			||||||
	 * blank or it has the old contents. A blank chip won't boot,
 | 
					 | 
				
			||||||
	 * so if the user wanted erase and reboots afterwards, the user
 | 
					 | 
				
			||||||
	 * knows very well that booting won't work.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	if (ret)
 | 
					 | 
				
			||||||
		emergency_help_message();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int do_write(struct flashctx *const flash, const char *const filename, const char *const referencefile)
 | 
					int do_write(struct flashctx *const flash, const char *const filename, const char *const referencefile)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const size_t flash_size = flash->chip->total_size * 1024;
 | 
						const size_t flash_size = flash->chip->total_size * 1024;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user