mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-29 07:53:44 +02:00
atahpt: Refactor singleton states into reentrant pattern
Move global singleton states into a struct and store within the par_master data field for the life-time of the driver. This is one of the steps on the way to move par_master data memory management behind the initialisation API, for more context see other patches under the same topic "register_master_api". Implements: https://ticket.coreboot.org/issues/391 BUG=b:185191942 TEST=builds Change-Id: I82e4c82916dc835e9462b80750b06f9d78701edf Signed-off-by: Alexander Goncharov <chat@joursoir.net> Reviewed-on: https://review.coreboot.org/c/flashrom/+/64963 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
parent
40997e30ac
commit
41337be92b
33
atahpt.c
33
atahpt.c
@ -28,7 +28,9 @@
|
|||||||
|
|
||||||
#define PCI_VENDOR_ID_HPT 0x1103
|
#define PCI_VENDOR_ID_HPT 0x1103
|
||||||
|
|
||||||
static uint32_t io_base_addr = 0;
|
struct atahpt_data {
|
||||||
|
uint32_t io_base_addr;
|
||||||
|
};
|
||||||
|
|
||||||
static const struct dev_entry ata_hpt[] = {
|
static const struct dev_entry ata_hpt[] = {
|
||||||
{0x1103, 0x0004, NT, "Highpoint", "HPT366/368/370/370A/372/372N"},
|
{0x1103, 0x0004, NT, "Highpoint", "HPT366/368/370/370A/372/372N"},
|
||||||
@ -41,15 +43,25 @@ static const struct dev_entry ata_hpt[] = {
|
|||||||
static void atahpt_chip_writeb(const struct flashctx *flash, uint8_t val,
|
static void atahpt_chip_writeb(const struct flashctx *flash, uint8_t val,
|
||||||
chipaddr addr)
|
chipaddr addr)
|
||||||
{
|
{
|
||||||
OUTL((uint32_t)addr, io_base_addr + BIOS_ROM_ADDR);
|
struct atahpt_data *data = flash->mst->par.data;
|
||||||
OUTB(val, io_base_addr + BIOS_ROM_DATA);
|
|
||||||
|
OUTL((uint32_t)addr, data->io_base_addr + BIOS_ROM_ADDR);
|
||||||
|
OUTB(val, data->io_base_addr + BIOS_ROM_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t atahpt_chip_readb(const struct flashctx *flash,
|
static uint8_t atahpt_chip_readb(const struct flashctx *flash,
|
||||||
const chipaddr addr)
|
const chipaddr addr)
|
||||||
{
|
{
|
||||||
OUTL((uint32_t)addr, io_base_addr + BIOS_ROM_ADDR);
|
struct atahpt_data *data = flash->mst->par.data;
|
||||||
return INB(io_base_addr + BIOS_ROM_DATA);
|
|
||||||
|
OUTL((uint32_t)addr, data->io_base_addr + BIOS_ROM_ADDR);
|
||||||
|
return INB(data->io_base_addr + BIOS_ROM_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int atahpt_shutdown(void *par_data)
|
||||||
|
{
|
||||||
|
free(par_data);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct par_master par_master_atahpt = {
|
static const struct par_master par_master_atahpt = {
|
||||||
@ -61,11 +73,13 @@ static const struct par_master par_master_atahpt = {
|
|||||||
.chip_writew = fallback_chip_writew,
|
.chip_writew = fallback_chip_writew,
|
||||||
.chip_writel = fallback_chip_writel,
|
.chip_writel = fallback_chip_writel,
|
||||||
.chip_writen = fallback_chip_writen,
|
.chip_writen = fallback_chip_writen,
|
||||||
|
.shutdown = atahpt_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int atahpt_init(void)
|
static int atahpt_init(void)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = NULL;
|
struct pci_dev *dev = NULL;
|
||||||
|
uint32_t io_base_addr;
|
||||||
uint32_t reg32;
|
uint32_t reg32;
|
||||||
|
|
||||||
if (rget_io_perms())
|
if (rget_io_perms())
|
||||||
@ -84,7 +98,14 @@ static int atahpt_init(void)
|
|||||||
reg32 |= (1 << 24);
|
reg32 |= (1 << 24);
|
||||||
rpci_write_long(dev, REG_FLASH_ACCESS, reg32);
|
rpci_write_long(dev, REG_FLASH_ACCESS, reg32);
|
||||||
|
|
||||||
return register_par_master(&par_master_atahpt, BUS_PARALLEL, NULL);
|
struct atahpt_data *data = calloc(1, sizeof(*data));
|
||||||
|
if (!data) {
|
||||||
|
msg_perr("Unable to allocate space for PAR master data\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
data->io_base_addr = io_base_addr;
|
||||||
|
|
||||||
|
return register_par_master(&par_master_atahpt, BUS_PARALLEL, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct programmer_entry programmer_atahpt = {
|
const struct programmer_entry programmer_atahpt = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user