2 #include "libopenbios/bindings.h"
3 #include "libc/byteorder.h"
4 #include "libopenbios/ofmem.h"
6 #include "arch/common/fw_cfg.h"
8 #if !defined(CONFIG_SPARC64)
9 static volatile uint16_t *fw_cfg_cmd
;
10 static volatile uint8_t *fw_cfg_data
;
13 fw_cfg_read(uint16_t cmd
, char *buf
, unsigned int nbytes
)
18 for (i
= 0; i
< nbytes
; i
++)
19 buf
[i
] = *fw_cfg_data
;
22 // XXX depends on PCI bus location, should be removed
24 fw_cfg_read(uint16_t cmd
, char *buf
, unsigned int nbytes
)
28 outw(cmd
, CONFIG_FW_CFG_ADDR
);
29 for (i
= 0; i
< nbytes
; i
++)
30 buf
[i
] = inb(CONFIG_FW_CFG_ADDR
+ 1);
35 fw_cfg_read_i64(uint16_t cmd
)
39 fw_cfg_read(cmd
, (char *)&buf
, sizeof(uint64_t));
41 return __le64_to_cpu(buf
);
45 fw_cfg_read_i32(uint16_t cmd
)
49 fw_cfg_read(cmd
, (char *)&buf
, sizeof(uint32_t));
51 return __le32_to_cpu(buf
);
55 fw_cfg_read_i16(uint16_t cmd
)
59 fw_cfg_read(cmd
, (char *)&buf
, sizeof(uint16_t));
61 return __le16_to_cpu(buf
);
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);