ppc64: Don't set Kp bit on SLB
[openbios/afaerber.git] / drivers / fw_cfg.c
blob402757070da007777fffe27b9ae5e2d643372b21
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"
8 #if !defined(CONFIG_SPARC64)
9 static volatile uint16_t *fw_cfg_cmd;
10 static volatile uint8_t *fw_cfg_data;
12 void
13 fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes)
15 unsigned int i;
17 *fw_cfg_cmd = cmd;
18 for (i = 0; i < nbytes; i++)
19 buf[i] = *fw_cfg_data;
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)
26 unsigned int i;
28 outw(cmd, CONFIG_FW_CFG_ADDR);
29 for (i = 0; i < nbytes; i++)
30 buf[i] = inb(CONFIG_FW_CFG_ADDR + 1);
32 #endif
34 uint64_t
35 fw_cfg_read_i64(uint16_t cmd)
37 uint64_t buf;
39 fw_cfg_read(cmd, (char *)&buf, sizeof(uint64_t));
41 return __le64_to_cpu(buf);
44 uint32_t
45 fw_cfg_read_i32(uint16_t cmd)
47 uint32_t buf;
49 fw_cfg_read(cmd, (char *)&buf, sizeof(uint32_t));
51 return __le32_to_cpu(buf);
54 uint16_t
55 fw_cfg_read_i16(uint16_t cmd)
57 uint16_t buf;
59 fw_cfg_read(cmd, (char *)&buf, sizeof(uint16_t));
61 return __le16_to_cpu(buf);
64 void
65 fw_cfg_init(void)
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