2010-03-14 17:19:58 +00:00
|
|
|
#include "config.h"
|
2010-03-14 15:05:53 +00:00
|
|
|
#include "libopenbios/bindings.h"
|
2009-01-31 08:49:16 +00:00
|
|
|
#include "libc/byteorder.h"
|
2010-03-14 15:05:53 +00:00
|
|
|
#include "libopenbios/ofmem.h"
|
2009-01-31 08:49:16 +00:00
|
|
|
#define NO_QEMU_PROTOS
|
2010-03-14 16:09:44 +00:00
|
|
|
#include "arch/common/fw_cfg.h"
|
2009-01-31 08:49:16 +00:00
|
|
|
|
|
|
|
|
#if !defined(CONFIG_SPARC64)
|
|
|
|
|
static volatile uint16_t *fw_cfg_cmd;
|
|
|
|
|
static volatile uint8_t *fw_cfg_data;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
*fw_cfg_cmd = cmd;
|
|
|
|
|
for (i = 0; i < nbytes; i++)
|
|
|
|
|
buf[i] = *fw_cfg_data;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
// XXX depends on PCI bus location, should be removed
|
|
|
|
|
void
|
|
|
|
|
fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
outw(cmd, CONFIG_FW_CFG_ADDR);
|
|
|
|
|
for (i = 0; i < nbytes; i++)
|
|
|
|
|
buf[i] = inb(CONFIG_FW_CFG_ADDR + 1);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
|
fw_cfg_read_i64(uint16_t cmd)
|
|
|
|
|
{
|
2009-08-23 12:40:22 +00:00
|
|
|
uint64_t buf;
|
2009-01-31 08:49:16 +00:00
|
|
|
|
2009-08-23 12:40:22 +00:00
|
|
|
fw_cfg_read(cmd, (char *)&buf, sizeof(uint64_t));
|
2009-01-31 08:49:16 +00:00
|
|
|
|
2009-08-23 12:40:22 +00:00
|
|
|
return __le64_to_cpu(buf);
|
2009-01-31 08:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
|
fw_cfg_read_i32(uint16_t cmd)
|
|
|
|
|
{
|
2009-08-23 12:40:22 +00:00
|
|
|
uint32_t buf;
|
2009-01-31 08:49:16 +00:00
|
|
|
|
2009-08-23 12:40:22 +00:00
|
|
|
fw_cfg_read(cmd, (char *)&buf, sizeof(uint32_t));
|
2009-01-31 08:49:16 +00:00
|
|
|
|
2009-08-23 12:40:22 +00:00
|
|
|
return __le32_to_cpu(buf);
|
2009-01-31 08:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
|
fw_cfg_read_i16(uint16_t cmd)
|
|
|
|
|
{
|
2009-08-23 12:40:22 +00:00
|
|
|
uint16_t buf;
|
2009-01-31 08:49:16 +00:00
|
|
|
|
2009-08-23 12:40:22 +00:00
|
|
|
fw_cfg_read(cmd, (char *)&buf, sizeof(uint16_t));
|
2009-01-31 08:49:16 +00:00
|
|
|
|
2009-08-23 12:40:22 +00:00
|
|
|
return __le16_to_cpu(buf);
|
2009-01-31 08:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fw_cfg_init(void)
|
|
|
|
|
{
|
|
|
|
|
#if defined(CONFIG_SPARC32)
|
|
|
|
|
fw_cfg_cmd = (void *)map_io(CONFIG_FW_CFG_ADDR, 2);
|
|
|
|
|
fw_cfg_data = (uint8_t *)fw_cfg_cmd + 2;
|
|
|
|
|
#elif defined(CONFIG_SPARC64)
|
|
|
|
|
// Nothing for the port version
|
|
|
|
|
#elif defined(CONFIG_PPC)
|
|
|
|
|
fw_cfg_cmd = (void *)CONFIG_FW_CFG_ADDR;
|
|
|
|
|
fw_cfg_data = (void *)(CONFIG_FW_CFG_ADDR + 2);
|
|
|
|
|
#endif
|
|
|
|
|
}
|