summaryrefslogtreecommitdiffstats
path: root/flash.h
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-02-14 01:20:28 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-02-14 01:20:28 +0000
commitcc389fc6b105572a0ed214e0e0795fb63b92f784 (patch)
treecec0b7507929eb51b11d3359be45eb3aad5179e3 /flash.h
parent879b351bfe1ffe7a7fe8b7c98986a208be706598 (diff)
downloadast2050-flashrom-cc389fc6b105572a0ed214e0e0795fb63b92f784.zip
ast2050-flashrom-cc389fc6b105572a0ed214e0e0795fb63b92f784.tar.gz
Allow the registration of functions to be called at programmer shutdown
Some programmers want to run certain functions during programmer shutdown, but the function choice depends on the code path taken during programmer init. Rather than rebuilding the whole init logic in the shutdown function, it is now possible to register functions for execution on programmer shutdown. The behaviour is similar to atexit(), but the registered functions will be run on programmer shutdown instead of on exit and the functions will be called with a void * argument that is specified on registration. Registered functions must have the prototype void function(void *); and will be executed in reverse registration order directly before calling the programmer-specific shutdown() function. It is recommended to have shutdown() only disable programmer/hardware access and leave all code path sensitive shutdown to functions registered with register_shutdown(). The most prominent use case is resetting the EC after flashing on laptops. Note: There are quite a few code paths in flashrom which proceed to terminate flashrom without any programmer shutdown. Those code paths will not get the benefit of register_shutdown() and they should be changed wherever possible. Corresponding to flashrom svn r904. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'flash.h')
-rw-r--r--flash.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/flash.h b/flash.h
index 9238c2a..1474a38 100644
--- a/flash.h
+++ b/flash.h
@@ -99,6 +99,8 @@ struct programmer_entry {
extern const struct programmer_entry programmer_table[];
+int register_shutdown(void (*function) (void *data), void *data);
+
int programmer_init(void);
int programmer_shutdown(void);
void *programmer_map_flash_region(const char *descr, unsigned long phys_addr,
OpenPOWER on IntegriCloud