summaryrefslogtreecommitdiff
path: root/satasii.c
diff options
context:
space:
mode:
authordhendrix <dhendrix@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2011-06-14 01:35:36 +0000
committerdhendrix <dhendrix@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2011-06-14 01:35:36 +0000
commitd505c148eaab4d51e88b1bfcb53f234596b28002 (patch)
treea77cc4239b59731e98cf6c9681b5a7c665613038 /satasii.c
parente5d41cb416a9bba9650269e02732eab3ff7b6252 (diff)
downloadflashrom-d505c148eaab4d51e88b1bfcb53f234596b28002.tar.gz
Use shutdown callback mechanism to shutdown programmers
This patch attempts to resolve some programmer shutdown ordering issues by having the programmer init functions register shutdown callbacks explicitly wherever it makes most sense. Before, assumptions were made that could lead to the internal programmer's state changing before the external programmer could be shut down properly. Now, each programmer cleans up after itself and (hopefully) performs each operation in the correct order. As a side-effect, this patch gives us a better usage model for reverse operations such as rpci_* and rmmio_*. In the long-run, this should make reversing the initialization process easier to understand, less tedious, and less error-prone. In short, this patch does the following: - Registers a shutdown callback during initialization for each programmer. - Kills the .shutdown function pointer from programmer_entry struct. Also, make most shutdown functions static. - Adds a few minor clean-ups and corrections (e.g. missing physunmap() calls). TODO: Remove forward declaration of serprog_shutdown() (added to simplify diff) Signed-off-by: David Hendricks <dhendrix@google.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1338 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'satasii.c')
-rw-r--r--satasii.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/satasii.c b/satasii.c
index 9d05b2d..dbc4f4f 100644
--- a/satasii.c
+++ b/satasii.c
@@ -26,6 +26,8 @@
#define PCI_VENDOR_ID_SII 0x1095
+#define SATASII_MEMMAP_SIZE 0x100
+
uint8_t *sii_bar;
static uint16_t id;
@@ -40,6 +42,14 @@ const struct pcidev_status satas_sii[] = {
{},
};
+static int satasii_shutdown(void *data)
+{
+ physunmap(sii_bar, SATASII_MEMMAP_SIZE);
+ pci_cleanup(pacc);
+ release_io_perms();
+ return 0;
+}
+
int satasii_init(void)
{
uint32_t addr;
@@ -59,7 +69,8 @@ int satasii_init(void)
reg_offset = 0x50;
}
- sii_bar = physmap("SATA SIL registers", addr, 0x100) + reg_offset;
+ sii_bar = physmap("SATA SIL registers", addr, SATASII_MEMMAP_SIZE) +
+ reg_offset;
/* Check if ROM cycle are OK. */
if ((id != 0x0680) && (!(pci_mmio_readl(sii_bar) & (1 << 26))))
@@ -67,13 +78,8 @@ int satasii_init(void)
buses_supported = CHIP_BUSTYPE_PARALLEL;
- return 0;
-}
-
-int satasii_shutdown(void)
-{
- pci_cleanup(pacc);
- release_io_perms();
+ if (register_shutdown(satasii_shutdown, NULL))
+ return 1;
return 0;
}