Annotation of qemu/roms/openbios/drivers/fw_cfg.c, revision 1.1.1.1

1.1       root        1: #include "config.h"
                      2: #include "libopenbios/bindings.h"
                      3: #include "libc/byteorder.h"
                      4: #include "libopenbios/ofmem.h"
                      5: #define NO_QEMU_PROTOS
                      6: #include "arch/common/fw_cfg.h"
                      7: 
                      8: #if !defined(CONFIG_SPARC64)
                      9: static volatile uint16_t *fw_cfg_cmd;
                     10: static volatile uint8_t *fw_cfg_data;
                     11: 
                     12: void
                     13: fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes)
                     14: {
                     15:     unsigned int i;
                     16: 
                     17:     *fw_cfg_cmd = cmd;
                     18:     for (i = 0; i < nbytes; i++)
                     19:         buf[i] = *fw_cfg_data;
                     20: }
                     21: #else
                     22: // XXX depends on PCI bus location, should be removed
                     23: void
                     24: fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes)
                     25: {
                     26:     unsigned int i;
                     27: 
                     28:     outw(cmd, CONFIG_FW_CFG_ADDR);
                     29:     for (i = 0; i < nbytes; i++)
                     30:         buf[i] = inb(CONFIG_FW_CFG_ADDR + 1);
                     31: }
                     32: #endif
                     33: 
                     34: uint64_t
                     35: fw_cfg_read_i64(uint16_t cmd)
                     36: {
                     37:     uint64_t buf;
                     38: 
                     39:     fw_cfg_read(cmd, (char *)&buf, sizeof(uint64_t));
                     40: 
                     41:     return __le64_to_cpu(buf);
                     42: }
                     43: 
                     44: uint32_t
                     45: fw_cfg_read_i32(uint16_t cmd)
                     46: {
                     47:     uint32_t buf;
                     48: 
                     49:     fw_cfg_read(cmd, (char *)&buf, sizeof(uint32_t));
                     50: 
                     51:     return __le32_to_cpu(buf);
                     52: }
                     53: 
                     54: uint16_t
                     55: fw_cfg_read_i16(uint16_t cmd)
                     56: {
                     57:     uint16_t buf;
                     58: 
                     59:     fw_cfg_read(cmd, (char *)&buf, sizeof(uint16_t));
                     60: 
                     61:     return __le16_to_cpu(buf);
                     62: }
                     63: 
                     64: void
                     65: fw_cfg_init(void)
                     66: {
                     67: #if defined(CONFIG_SPARC32)
                     68:     fw_cfg_cmd = (void *)ofmem_map_io(CONFIG_FW_CFG_ADDR, 2);
                     69:     fw_cfg_data = (uint8_t *)fw_cfg_cmd + 2;
                     70: #elif defined(CONFIG_SPARC64)
                     71:     // Nothing for the port version
                     72: #elif defined(CONFIG_PPC)
                     73:     fw_cfg_cmd = (void *)CONFIG_FW_CFG_ADDR;
                     74:     fw_cfg_data = (void *)(CONFIG_FW_CFG_ADDR + 2);
                     75: #endif
                     76: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.