[OpenBIOS] r432 - in openbios-devel: arch/ppc/qemu arch/sparc32 arch/sparc64 config/examples drivers include/openbios

svn at openbios.org svn at openbios.org
Sat Jan 31 09:49:16 CET 2009


Author: blueswirl
Date: 2009-01-31 09:49:16 +0100 (Sat, 31 Jan 2009)
New Revision: 432

Added:
   openbios-devel/drivers/fw_cfg.c
Modified:
   openbios-devel/arch/ppc/qemu/init.c
   openbios-devel/arch/sparc32/entry.S
   openbios-devel/arch/sparc64/entry.S
   openbios-devel/arch/sparc64/openbios.c
   openbios-devel/config/examples/cross-ppc_config.xml
   openbios-devel/config/examples/cross-sparc32_config.xml
   openbios-devel/config/examples/cross-sparc64_config.xml
   openbios-devel/config/examples/ppc_config.xml
   openbios-devel/config/examples/sparc32_config.xml
   openbios-devel/config/examples/sparc64_config.xml
   openbios-devel/drivers/build.xml
   openbios-devel/drivers/obio.c
   openbios-devel/include/openbios/fw_cfg.h
Log:
Refactor QEMU firmware confguration device handling (based on patch by
Aurelien Jarno)


Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/arch/ppc/qemu/init.c	2009-01-31 08:49:16 UTC (rev 432)
@@ -33,8 +33,6 @@
 #define NO_QEMU_PROTOS
 #include "openbios/fw_cfg.h"
 
-#define CFG_ADDR 0xf0000510
-
 #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
 
 struct cpudef {
@@ -95,39 +93,6 @@
 };
 uint32_t isa_io_base;
 
-static volatile uint16_t *fw_cfg_cmd = (void *)CFG_ADDR;
-static volatile uint8_t *fw_cfg_data = (void *)(CFG_ADDR + 2);
-
-static 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;
-}
-
-static uint32_t
-fw_cfg_read_i32(uint16_t cmd)
-{
-    char buf[sizeof(uint32_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint32_t));
-
-    return __le32_to_cpu(*(uint32_t *)buf);
-}
-
-static uint16_t
-fw_cfg_read_i16(uint16_t cmd)
-{
-    char buf[sizeof(uint16_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint16_t));
-
-    return __le16_to_cpu(*(uint16_t *)buf);
-}
-
 void
 entry( void )
 {
@@ -136,6 +101,8 @@
 
         arch = &known_arch[ARCH_HEATHROW];
 
+        fw_cfg_init();
+
         fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
         buf[4] = '\0';
         if (strncmp(buf, "QEMU", 4) == 0) {

Modified: openbios-devel/arch/sparc32/entry.S
===================================================================
--- openbios-devel/arch/sparc32/entry.S	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/arch/sparc32/entry.S	2009-01-31 08:49:16 UTC (rev 432)
@@ -11,6 +11,7 @@
 #include "asm/asi.h"
 #include "asm/crs.h"
 #define NO_QEMU_PROTOS
+#define NO_OPENBIOS_PROTOS
 #include "openbios/fw_cfg.h"
 
 #define CFG_ADDR 0x00000510

Modified: openbios-devel/arch/sparc64/entry.S
===================================================================
--- openbios-devel/arch/sparc64/entry.S	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/arch/sparc64/entry.S	2009-01-31 08:49:16 UTC (rev 432)
@@ -12,6 +12,7 @@
 #include "pstate.h"
 #include "lsu.h"
 #define NO_QEMU_PROTOS
+#define NO_OPENBIOS_PROTOS
 #include "openbios/fw_cfg.h"
 
 #define PROM_ADDR 0x1fff0000000

Modified: openbios-devel/arch/sparc64/openbios.c
===================================================================
--- openbios-devel/arch/sparc64/openbios.c	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/arch/sparc64/openbios.c	2009-01-31 08:49:16 UTC (rev 432)
@@ -24,9 +24,6 @@
 #include "openbios/fw_cfg.h"
 #include "video_subr.h"
 
-#define BIOS_CFG_CMD  0x510
-#define BIOS_CFG_DATA 0x511
-
 #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
 
 #define NVRAM_ADDR_LO 0x74
@@ -244,46 +241,6 @@
     for (;;);
 }
 
-static void
-fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes)
-{
-    unsigned int i;
-
-    outw(cmd, BIOS_CFG_CMD);
-    for (i = 0; i < nbytes; i++)
-        buf[i] = inb(BIOS_CFG_DATA);
-}
-
-static uint64_t
-fw_cfg_read_i64(uint16_t cmd)
-{
-    char buf[sizeof(uint64_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint64_t));
-
-    return __le64_to_cpu(*(uint64_t *)buf);
-}
-
-static uint32_t
-fw_cfg_read_i32(uint16_t cmd)
-{
-    char buf[sizeof(uint32_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint32_t));
-
-    return __le32_to_cpu(*(uint32_t *)buf);
-}
-
-static uint16_t
-fw_cfg_read_i16(uint16_t cmd)
-{
-    char buf[sizeof(uint16_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint16_t));
-
-    return __le16_to_cpu(*(uint16_t *)buf);
-}
-
 static uint8_t nvram_read_byte(uint16_t offset)
 {
     outb(offset & 0xff, NVRAM_ADDR_LO);
@@ -330,6 +287,8 @@
 
     nvram_read(0, (char *)&nv_info, sizeof(ohwcfg_v3_t));
 
+    fw_cfg_init();
+
     fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
     buf[4] = '\0';
 

Modified: openbios-devel/config/examples/cross-ppc_config.xml
===================================================================
--- openbios-devel/config/examples/cross-ppc_config.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/config/examples/cross-ppc_config.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -75,5 +75,6 @@
   <option name="CONFIG_DRIVER_VGA" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_MACIO" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_ESCC" type="boolean" value="true"/>
-
+  <option name="CONFIG_DRIVER_FW_CFG" type="boolean" value="true"/>
+  <option name="CONFIG_FW_CFG_ADDR" type="integer" value="0xf0000510"/>
 </config>

Modified: openbios-devel/config/examples/cross-sparc32_config.xml
===================================================================
--- openbios-devel/config/examples/cross-sparc32_config.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/config/examples/cross-sparc32_config.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -76,5 +76,6 @@
   <option name="CONFIG_DEBUG_FLOPPY" type="boolean" value="false"/>
   <option name="CONFIG_DRIVER_ESCC" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_ESCC_SUN" type="boolean" value="true"/>
-
+  <option name="CONFIG_DRIVER_FW_CFG" type="boolean" value="true"/>
+  <option name="CONFIG_FW_CFG_ADDR" type="integer" value="0xd00000510ULL"/>
 </config>

Modified: openbios-devel/config/examples/cross-sparc64_config.xml
===================================================================
--- openbios-devel/config/examples/cross-sparc64_config.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/config/examples/cross-sparc64_config.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -77,5 +77,6 @@
   <option name="CONFIG_DRIVER_EBUS" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_PC_KBD" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_PC_SERIAL" type="boolean" value="true"/>
-
+  <option name="CONFIG_DRIVER_FW_CFG" type="boolean" value="true"/>
+  <option name="CONFIG_FW_CFG_ADDR" type="integer" value="0x510"/>
 </config>

Modified: openbios-devel/config/examples/ppc_config.xml
===================================================================
--- openbios-devel/config/examples/ppc_config.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/config/examples/ppc_config.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -75,5 +75,6 @@
   <option name="CONFIG_DRIVER_VGA" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_MACIO" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_ESCC" type="boolean" value="true"/>
-
+  <option name="CONFIG_DRIVER_FW_CFG" type="boolean" value="true"/>
+  <option name="CONFIG_FW_CFG_ADDR" type="integer" value="0xf0000510"/>
 </config>

Modified: openbios-devel/config/examples/sparc32_config.xml
===================================================================
--- openbios-devel/config/examples/sparc32_config.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/config/examples/sparc32_config.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -76,5 +76,6 @@
   <option name="CONFIG_DEBUG_FLOPPY" type="boolean" value="false"/>
   <option name="CONFIG_DRIVER_ESCC" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_ESCC_SUN" type="boolean" value="true"/>
-
+  <option name="CONFIG_DRIVER_FW_CFG" type="boolean" value="true"/>
+  <option name="CONFIG_FW_CFG_ADDR" type="integer" value="0xd00000510ULL"/>
 </config>

Modified: openbios-devel/config/examples/sparc64_config.xml
===================================================================
--- openbios-devel/config/examples/sparc64_config.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/config/examples/sparc64_config.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -77,5 +77,6 @@
   <option name="CONFIG_DRIVER_EBUS" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_PC_KBD" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_PC_SERIAL" type="boolean" value="true"/>
-
+  <option name="CONFIG_DRIVER_FW_CFG" type="boolean" value="true"/>
+  <option name="CONFIG_FW_CFG_ADDR" type="integer" value="0x510"/>
 </config>

Modified: openbios-devel/drivers/build.xml
===================================================================
--- openbios-devel/drivers/build.xml	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/drivers/build.xml	2009-01-31 08:49:16 UTC (rev 432)
@@ -22,6 +22,7 @@
   <object source="pc_kbd.c" condition="DRIVER_PC_KBD"/>
   <object source="pc_serial.c" condition="DRIVER_PC_SERIAL"/>
   <object source="escc.c" condition="DRIVER_ESCC"/>
+  <object source="fw_cfg.c" condition="DRIVER_FW_CFG"/>
  </library>
 
  <dictionary name="openbios" target="forth">

Added: openbios-devel/drivers/fw_cfg.c
===================================================================
--- openbios-devel/drivers/fw_cfg.c	                        (rev 0)
+++ openbios-devel/drivers/fw_cfg.c	2009-01-31 08:49:16 UTC (rev 432)
@@ -0,0 +1,76 @@
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "libc/byteorder.h"
+#include "ofmem.h"
+#define NO_QEMU_PROTOS
+#include "openbios/fw_cfg.h"
+
+#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)
+{
+    char buf[sizeof(uint64_t)];
+
+    fw_cfg_read(cmd, buf, sizeof(uint64_t));
+
+    return __le64_to_cpu(*(uint64_t *)buf);
+}
+
+uint32_t
+fw_cfg_read_i32(uint16_t cmd)
+{
+    char buf[sizeof(uint32_t)];
+
+    fw_cfg_read(cmd, buf, sizeof(uint32_t));
+
+    return __le32_to_cpu(*(uint32_t *)buf);
+}
+
+uint16_t
+fw_cfg_read_i16(uint16_t cmd)
+{
+    char buf[sizeof(uint16_t)];
+
+    fw_cfg_read(cmd, buf, sizeof(uint16_t));
+
+    return __le16_to_cpu(*(uint16_t *)buf);
+}
+
+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
+}

Modified: openbios-devel/drivers/obio.c
===================================================================
--- openbios-devel/drivers/obio.c	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/drivers/obio.c	2009-01-31 08:49:16 UTC (rev 432)
@@ -646,39 +646,6 @@
     for (;;);
 }
 
-static volatile uint16_t *fw_cfg_cmd;
-static volatile uint8_t *fw_cfg_data;
-
-static 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;
-}
-
-static uint32_t
-fw_cfg_read_i32(uint16_t cmd)
-{
-    char buf[sizeof(uint32_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint32_t));
-
-    return __le32_to_cpu(*(uint32_t *)buf);
-}
-
-static uint16_t
-fw_cfg_read_i16(uint16_t cmd)
-{
-    char buf[sizeof(uint16_t)];
-
-    fw_cfg_read(cmd, buf, sizeof(uint16_t));
-
-    return __le16_to_cpu(*(uint16_t *)buf);
-}
-
 static uint8_t qemu_uuid[16];
 
 static void
@@ -710,8 +677,7 @@
 
     fword("finish-device");
 
-    fw_cfg_cmd = map_io(CFG_ADDR, CFG_SIZE);
-    fw_cfg_data = (uint8_t *)fw_cfg_cmd + 2;
+    fw_cfg_init();
 
     fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
     buf[4] = '\0';

Modified: openbios-devel/include/openbios/fw_cfg.h
===================================================================
--- openbios-devel/include/openbios/fw_cfg.h	2009-01-30 07:44:48 UTC (rev 431)
+++ openbios-devel/include/openbios/fw_cfg.h	2009-01-31 08:49:16 UTC (rev 432)
@@ -30,4 +30,12 @@
 
 #endif /* NO_QEMU_PROTOS */
 
+#ifndef NO_OPENBIOS_PROTOS
+void fw_cfg_read(uint16_t cmd, char *buf, unsigned int nbytes);
+uint64_t fw_cfg_read_i64(uint16_t cmd);
+uint32_t fw_cfg_read_i32(uint16_t cmd);
+uint16_t fw_cfg_read_i16(uint16_t cmd);
+void fw_cfg_init(void);
+#endif /* NO_OPENBIOS_PROTOS */
+
 #endif




More information about the OpenBIOS mailing list