[OpenBIOS] r292 - in openbios-devel: arch/amd64 arch/ppc/briq arch/ppc/pearpc arch/ppc/qemu arch/sparc64 arch/x86 config/examples config/xml drivers include/openbios

svn at openbios.org svn at openbios.org
Sat Dec 20 15:48:40 CET 2008


Author: blueswirl
Date: 2008-12-20 15:48:40 +0100 (Sat, 20 Dec 2008)
New Revision: 292

Modified:
   openbios-devel/arch/amd64/openbios.c
   openbios-devel/arch/ppc/briq/init.c
   openbios-devel/arch/ppc/briq/tree.fs
   openbios-devel/arch/ppc/pearpc/init.c
   openbios-devel/arch/ppc/pearpc/tree.fs
   openbios-devel/arch/ppc/qemu/init.c
   openbios-devel/arch/ppc/qemu/tree.fs
   openbios-devel/arch/sparc64/openbios.c
   openbios-devel/arch/sparc64/tree.fs
   openbios-devel/arch/x86/init.fs
   openbios-devel/arch/x86/openbios.c
   openbios-devel/config/examples/cross-ppc_config.xml
   openbios-devel/config/xml/config-c.xsl
   openbios-devel/config/xml/config-forth.xsl
   openbios-devel/drivers/build.xml
   openbios-devel/drivers/ide.c
   openbios-devel/drivers/pci.c
   openbios-devel/include/openbios/drivers.h
Log:
IDE fixes for PPC (Laurent Vivier)

Modified: openbios-devel/arch/amd64/openbios.c
===================================================================
--- openbios-devel/arch/amd64/openbios.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/amd64/openbios.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -17,7 +17,6 @@
 #include "relocate.h"
 
 void boot(void);
-void ob_ide_init(void);
 
 static char intdict[256 * 1024];
 
@@ -42,7 +41,7 @@
 	modules_init();
 #ifdef CONFIG_DRIVER_IDE
 	setup_timers();
-	ob_ide_init();
+	ob_ide_init("/pci/pci-ata", 0x1f0, 0x3f4, 0x170, 0x374);
 #endif
 	device_end();
 	bind_func("platform-boot", boot );

Modified: openbios-devel/arch/ppc/briq/init.c
===================================================================
--- openbios-devel/arch/ppc/briq/init.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/ppc/briq/init.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -27,7 +27,6 @@
 #include "openbios-version.h"
 
 extern void unexpected_excep( int vector );
-extern void ob_ide_init( void );
 extern void setup_timers( void );
 
 #if 0
@@ -91,15 +90,11 @@
 
 	devtree_init();
 	node_methods_init();
-	nvram_init("/pci/mac-io/nvram");
 	modules_init();
+        setup_timers();
 #ifdef CONFIG_DRIVER_PCI
 	ob_pci_init();
 #endif
-#ifdef CONFIG_DRIVER_IDE
-        setup_timers();
-        ob_ide_init();
-#endif
 
 #if USE_RTAS
 	if( !(ph=find_dev("/rtas")) )

Modified: openbios-devel/arch/ppc/briq/tree.fs
===================================================================
--- openbios-devel/arch/ppc/briq/tree.fs	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/ppc/briq/tree.fs	2008-12-20 14:48:40 UTC (rev 292)
@@ -82,6 +82,65 @@
 	0 encode-int 0 encode-int encode+ " bus-range" property
 
 new-device
+  " isa" device-name
+  " isa" device-type
+	2 encode-int " #address-cells" property
+	1 encode-int " #size-cells" property
+
+  external
+  : open true ;
+  : close ;
+
+finish-device
+
+: ?devalias ( alias-str alias-len device-str device-len --
+  \		alias-str alias-len false | true )
+  active-package >r
+  " /aliases" find-device
+  \ 2dup ." Checking " type
+  2dup find-dev if     \ check if device exists
+    drop
+    2over find-dev if  \ do we already have an alias?
+      \ ." alias exists" cr
+      drop 2drop false
+    else
+      \ ." device exists" cr
+      encode-string
+      2swap property
+      true
+    then
+  else
+    \ ." device doesn't exist" cr
+    2drop false
+  then
+  r> active-package!
+  ;
+
+:noname
+  " hd"
+  " /pci/pci-ata/ata-1/disk at 0" ?devalias not if
+    " /pci/pci-ata/ata-1/disk at 1" ?devalias not if
+      " /pci/pci-ata/ata-2/disk at 0" ?devalias not if
+        " /pci/pci-ata/ata-2/disk at 1" ?devalias not if
+	  2drop ." No disk found." cr
+	then
+      then
+    then
+  then
+
+  " cdrom"
+  " /pci/pci-ata/ata-1/cdrom at 0" ?devalias not if
+    " /pci/pci-ata/ata-1/cdrom at 1" ?devalias not if
+      " /pci/pci-ata/ata-2/cdrom at 0" ?devalias not if
+        " /pci/pci-ata/ata-2/cdrom at 1" ?devalias not if
+	  2drop ." No cdrom found" cr
+	then
+      then
+    then
+  then
+; SYSTEM-initializer
+
+new-device
 	" ide" device-name
 	" ide" device-type
 	" WINBOND,82C553" model

Modified: openbios-devel/arch/ppc/pearpc/init.c
===================================================================
--- openbios-devel/arch/ppc/pearpc/init.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/ppc/pearpc/init.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -28,7 +28,6 @@
 #include "openbios-version.h"
 
 extern void unexpected_excep( int vector );
-extern void ob_ide_init( void );
 extern void ob_pci_init( void );
 extern void ob_adb_init( void );
 extern void setup_timers( void );
@@ -95,17 +94,10 @@
 	devtree_init();
 	nvram_init("/pci/mac-io/nvram");
 	modules_init();
+        setup_timers();
 #ifdef CONFIG_DRIVER_PCI
 	ob_pci_init();
 #endif
-#ifdef CONFIG_DRIVER_IDE
-        setup_timers();
-        ob_ide_init();
-#endif
-#ifdef CONFIG_DRIVER_ADB
-	ob_adb_init();
-#endif
-
 	node_methods_init();
 	init_video();
 

Modified: openbios-devel/arch/ppc/pearpc/tree.fs
===================================================================
--- openbios-devel/arch/ppc/pearpc/tree.fs	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/ppc/pearpc/tree.fs	2008-12-20 14:48:40 UTC (rev 292)
@@ -82,6 +82,65 @@
 	0 encode-int 0 encode-int encode+ " bus-range" property
 
 new-device
+  " isa" device-name
+  " isa" device-type
+	2 encode-int " #address-cells" property
+	1 encode-int " #size-cells" property
+
+  external
+  : open true ;
+  : close ;
+
+finish-device
+
+: ?devalias ( alias-str alias-len device-str device-len --
+  \		alias-str alias-len false | true )
+  active-package >r
+  " /aliases" find-device
+  \ 2dup ." Checking " type
+  2dup find-dev if     \ check if device exists
+    drop
+    2over find-dev if  \ do we already have an alias?
+      \ ." alias exists" cr
+      drop 2drop false
+    else
+      \ ." device exists" cr
+      encode-string
+      2swap property
+      true
+    then
+  else
+    \ ." device doesn't exist" cr
+    2drop false
+  then
+  r> active-package!
+  ;
+
+:noname
+  " hd"
+  " /pci/pci-ata/ata-1/disk at 0" ?devalias not if
+    " /pci/pci-ata/ata-1/disk at 1" ?devalias not if
+      " /pci/pci-ata/ata-2/disk at 0" ?devalias not if
+        " /pci/pci-ata/ata-2/disk at 1" ?devalias not if
+	  2drop ." No disk found." cr
+	then
+      then
+    then
+  then
+
+  " cdrom"
+  " /pci/pci-ata/ata-1/cdrom at 0" ?devalias not if
+    " /pci/pci-ata/ata-1/cdrom at 1" ?devalias not if
+      " /pci/pci-ata/ata-2/cdrom at 0" ?devalias not if
+        " /pci/pci-ata/ata-2/cdrom at 1" ?devalias not if
+	  2drop ." No cdrom found" cr
+	then
+      then
+    then
+  then
+; SYSTEM-initializer
+
+new-device
 	" ide" device-name
 	" ide" device-type
 	" WINBOND,82C553" model

Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/ppc/qemu/init.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -29,7 +29,6 @@
 #include "openbios-version.h"
 
 extern void unexpected_excep( int vector );
-extern void ob_ide_init( void );
 extern void ob_pci_init( void );
 extern void setup_timers( void );
 
@@ -108,10 +107,6 @@
 #ifdef CONFIG_DRIVER_PCI
 	ob_pci_init();
 #endif
-#ifdef CONFIG_DRIVER_IDE
-        ob_ide_init();
-#endif
-
 	node_methods_init();
 
 #ifdef USE_RTAS

Modified: openbios-devel/arch/ppc/qemu/tree.fs
===================================================================
--- openbios-devel/arch/ppc/qemu/tree.fs	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/ppc/qemu/tree.fs	2008-12-20 14:48:40 UTC (rev 292)
@@ -82,6 +82,65 @@
 	0 encode-int 0 encode-int encode+ " bus-range" property
 
 new-device
+  " isa" device-name
+  " isa" device-type
+	2 encode-int " #address-cells" property
+	1 encode-int " #size-cells" property
+
+  external
+  : open true ;
+  : close ;
+
+finish-device
+
+: ?devalias ( alias-str alias-len device-str device-len --
+  \		alias-str alias-len false | true )
+  active-package >r
+  " /aliases" find-device
+  \ 2dup ." Checking " type
+  2dup find-dev if     \ check if device exists
+    drop
+    2over find-dev if  \ do we already have an alias?
+      \ ." alias exists" cr
+      drop 2drop false
+    else
+      \ ." device exists" cr
+      encode-string
+      2swap property
+      true
+    then
+  else
+    \ ." device doesn't exist" cr
+    2drop false
+  then
+  r> active-package!
+  ;
+
+:noname
+  " hd"
+  " /pci/pci-ata/ata-1/disk at 0" ?devalias not if
+    " /pci/pci-ata/ata-1/disk at 1" ?devalias not if
+      " /pci/pci-ata/ata-2/disk at 0" ?devalias not if
+        " /pci/pci-ata/ata-2/disk at 1" ?devalias not if
+	  2drop ." No disk found." cr
+	then
+      then
+    then
+  then
+
+  " cdrom"
+  " /pci/pci-ata/ata-1/cdrom at 0" ?devalias not if
+    " /pci/pci-ata/ata-1/cdrom at 1" ?devalias not if
+      " /pci/pci-ata/ata-2/cdrom at 0" ?devalias not if
+        " /pci/pci-ata/ata-2/cdrom at 1" ?devalias not if
+	  2drop ." No cdrom found" cr
+	then
+      then
+    then
+  then
+; SYSTEM-initializer
+
+new-device
 	" ide" device-name
 	" ide" device-type
 	" WINBOND,82C553" model

Modified: openbios-devel/arch/sparc64/openbios.c
===================================================================
--- openbios-devel/arch/sparc64/openbios.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/sparc64/openbios.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -865,7 +865,7 @@
 #endif
 #ifdef CONFIG_DRIVER_IDE
 	setup_timers();
-	ob_ide_init();
+	ob_ide_init("/pci/isa", 0x1f0, 0x3f4, 0x170, 0x374);
 #endif
 #ifdef CONFIG_DRIVER_FLOPPY
 	ob_floppy_init();

Modified: openbios-devel/arch/sparc64/tree.fs
===================================================================
--- openbios-devel/arch/sparc64/tree.fs	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/sparc64/tree.fs	2008-12-20 14:48:40 UTC (rev 292)
@@ -32,3 +32,65 @@
 
 " /openprom" find-device
   " OBP 3.10.24 1999/01/01 01:01" encode-string " version" property
+
+dev /pci
+
+\ simple isa bus node
+new-device
+  " isa" device-name
+  " isa" device-type
+	2 encode-int " #address-cells" property
+	1 encode-int " #size-cells" property
+
+  external
+  : open true ;
+  : close ;
+
+finish-device
+
+: ?devalias ( alias-str alias-len device-str device-len --
+  \		alias-str alias-len false | true )
+  active-package >r
+  " /aliases" find-device
+  \ 2dup ." Checking " type
+  2dup find-dev if     \ check if device exists
+    drop
+    2over find-dev if  \ do we already have an alias?
+      \ ." alias exists" cr
+      drop 2drop false
+    else
+      \ ." device exists" cr
+      encode-string
+      2swap property
+      true
+    then
+  else
+    \ ." device doesn't exist" cr
+    2drop false
+  then
+  r> active-package!
+  ;
+
+:noname
+  " hd"
+  " /pci/isa/ide0/disk at 0" ?devalias not if
+    " /pci/isa/ide0/disk at 1" ?devalias not if
+      " /pci/isa/ide1/disk at 0" ?devalias not if
+        " /pci/isa/ide1/disk at 1" ?devalias not if
+	  2drop ." No disk found." cr
+	then
+      then
+    then
+  then
+
+  " cdrom"
+  " /pci/isa/ide0/cdrom at 0" ?devalias not if
+    " /pci/isa/ide0/cdrom at 1" ?devalias not if
+      " /pci/isa/ide1/cdrom at 0" ?devalias not if
+        " /pci/isa/ide1/cdrom at 1" ?devalias not if
+	  2drop ." No cdrom found" cr
+	then
+      then
+    then
+  then
+; SYSTEM-initializer

Modified: openbios-devel/arch/x86/init.fs
===================================================================
--- openbios-devel/arch/x86/init.fs	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/x86/init.fs	2008-12-20 14:48:40 UTC (rev 292)
@@ -75,3 +75,65 @@
   " keyboard" input
 ; CONSOLE-IN-initializer
  
+
+dev /pci
+
+\ simple isa bus node
+new-device
+  " isa" device-name
+  " isa" device-type
+	2 encode-int " #address-cells" property
+	1 encode-int " #size-cells" property
+
+  external
+  : open true ;
+  : close ;
+
+finish-device
+
+: ?devalias ( alias-str alias-len device-str device-len --
+  \		alias-str alias-len false | true )
+  active-package >r
+  " /aliases" find-device
+  \ 2dup ." Checking " type
+  2dup find-dev if     \ check if device exists
+    drop
+    2over find-dev if  \ do we already have an alias?
+      \ ." alias exists" cr
+      drop 2drop false
+    else
+      \ ." device exists" cr
+      encode-string
+      2swap property
+      true
+    then
+  else
+    \ ." device doesn't exist" cr
+    2drop false
+  then
+  r> active-package!
+  ;
+
+:noname
+  " hd"
+  " /pci/isa/ide0/disk at 0" ?devalias not if
+    " /pci/isa/ide0/disk at 1" ?devalias not if
+      " /pci/isa/ide1/disk at 0" ?devalias not if
+        " /pci/isa/ide1/disk at 1" ?devalias not if
+	  2drop ." No disk found." cr
+	then
+      then
+    then
+  then
+
+  " cdrom"
+  " /pci/isa/ide0/cdrom at 0" ?devalias not if
+    " /pci/isa/ide0/cdrom at 1" ?devalias not if
+      " /pci/isa/ide1/cdrom at 0" ?devalias not if
+        " /pci/isa/ide1/cdrom at 1" ?devalias not if
+	  2drop ." No cdrom found" cr
+	then
+      then
+    then
+  then
+; SYSTEM-initializer

Modified: openbios-devel/arch/x86/openbios.c
===================================================================
--- openbios-devel/arch/x86/openbios.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/arch/x86/openbios.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -45,7 +45,7 @@
 #endif
 #ifdef CONFIG_DRIVER_IDE
 	setup_timers();
-	ob_ide_init();
+	ob_ide_init("/pci/isa", 0x1f0, 0x3f4, 0x170, 0x374);
 #endif
 #ifdef CONFIG_DRIVER_FLOPPY
 	ob_floppy_init();

Modified: openbios-devel/config/examples/cross-ppc_config.xml
===================================================================
--- openbios-devel/config/examples/cross-ppc_config.xml	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/config/examples/cross-ppc_config.xml	2008-12-20 14:48:40 UTC (rev 292)
@@ -66,7 +66,10 @@
   <option name="CONFIG_DRIVER_PCI" type="boolean" value="true"/>
   <option name="CONFIG_DEBUG_PCI" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_IDE" type="boolean" value="true"/>
-  <option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="4"/>
+  <option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="2"/>
+  <option name="CONFIG_IDE_FIRST_UNIT" type="integer" value="1"/>
+  <option name="CONFIG_IDE_DEV_NAME" type="string" value="ata-%d"/>
+  <option name="CONFIG_IDE_DEV_TYPE" type="string" value="ata"/>
   <option name="CONFIG_DEBUG_IDE" type="boolean" value="false"/>
   <option name="CONFIG_DRIVER_ADB" type="boolean" value="true"/>
   <option name="CONFIG_DRIVER_VGA" type="boolean" value="true"/>

Modified: openbios-devel/config/xml/config-c.xsl
===================================================================
--- openbios-devel/config/xml/config-c.xsl	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/config/xml/config-c.xsl	2008-12-20 14:48:40 UTC (rev 292)
@@ -34,6 +34,11 @@
       <xsl:value-of select="@name"/><xsl:text> </xsl:text>
       <xsl:value-of select="@value"/>
      </xsl:when>
+
+     <!-- config option "string" -->
+     <xsl:when test="@type='string'">
+      <xsl:text>#define </xsl:text>
+      <xsl:value-of select="@name"/><xsl:text> </xsl:text> "<xsl:value-of select="@value"/>" </xsl:when>
     
      <!-- unsupported config option: bail out -->
      <xsl:otherwise>

Modified: openbios-devel/config/xml/config-forth.xsl
===================================================================
--- openbios-devel/config/xml/config-forth.xsl	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/config/xml/config-forth.xsl	2008-12-20 14:48:40 UTC (rev 292)
@@ -26,6 +26,9 @@
        <xsl:value-of select="@name"/>
        <xsl:text>&#10;</xsl:text>
      </xsl:when>
+     <!-- config option "string" -->
+     <xsl:when test="@type='string'">
+     </xsl:when>
      <xsl:otherwise>
       <xsl:message terminate="yes">&#10;ERROR: configuration option '<xsl:value-of select="@name"/>' has unsupported type '<xsl:value-of select="@type"/>'.</xsl:message> 
      </xsl:otherwise>

Modified: openbios-devel/drivers/build.xml
===================================================================
--- openbios-devel/drivers/build.xml	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/drivers/build.xml	2008-12-20 14:48:40 UTC (rev 292)
@@ -19,7 +19,6 @@
 
  <dictionary name="openbios" target="forth">
   <object source="pci.fs" condition="DRIVER_PCI"/>
-  <object source="ide.fs" condition="DRIVER_IDE"/>
   <object source="sbus.fs" condition="DRIVER_SBUS"/>
   <object source="esp.fs" condition="DRIVER_ESP"/>
  </dictionary>

Modified: openbios-devel/drivers/ide.c
===================================================================
--- openbios-devel/drivers/ide.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/drivers/ide.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -13,11 +13,6 @@
  *
  */
 
-/*
- * TODO:
- *  - Really probe for interfaces, don't just rely on legacy
- */
-
 #include "openbios/config.h"
 #include "openbios/bindings.h"
 #include "openbios/kernel.h"
@@ -43,13 +38,30 @@
 #endif
 #define IDE_MAX_CHANNELS 4
 
+#ifndef CONFIG_IDE_FIRST_UNIT
+#define FIRST_UNIT 0
+#else
+#define FIRST_UNIT CONFIG_IDE_FIRST_UNIT
+#endif
+
+#ifndef CONFIG_IDE_DEV_TYPE
+#define DEV_TYPE "ide"
+#else
+#define DEV_TYPE CONFIG_IDE_DEV_TYPE
+#endif
+
+#ifndef CONFIG_IDE_DEV_NAME
+#define DEV_NAME "ide%d"
+#else
+#define DEV_NAME CONFIG_IDE_DEV_NAME
+#endif
+
+static int current_channel = FIRST_UNIT;
+
 static struct ide_channel ob_ide_channels[IDE_MAX_CHANNELS];
 
-/*
- * FIXME: probe, we just hardwire legacy ports for now
- */
-static const int io_ports[IDE_MAX_CHANNELS] = { 0x1f0, 0x170, 0x1e8, 0x168 };
-static const int ctl_ports[IDE_MAX_CHANNELS] = { 0x3f6, 0x376, 0x3ee, 0x36e };
+static int io_ports[IDE_MAX_CHANNELS];
+static int ctl_ports[IDE_MAX_CHANNELS];
 
 /*
  * don't be pedantic
@@ -634,6 +646,9 @@
 	struct atapi_command *cmd = &drive->channel->atapi_cmd;
 	struct atapi_capacity cap;
 
+#ifdef CONFIG_DEBUG_IDE
+	printk("ob_ide_atapi_drive_ready\n");
+#endif
 	/*
 	 * Test Unit Ready is like a ping
 	 */
@@ -835,7 +850,8 @@
 		return 1;
 
 #ifdef CONFIG_DEBUG_IDE
-		printk("ob_ide_read_sectors: block=%Ld sectors=%u\n", (unsigned long) block, sectors);
+	printk("ob_ide_read_sectors: block=%lu sectors=%u\n",
+	       (unsigned long) block, sectors);
 #endif
 
 	if (drive->type == ide_type_ata)
@@ -1133,6 +1149,9 @@
 ob_ide_max_transfer(int *idx)
 {
 	struct ide_drive *drive=&ob_ide_channels[idx[1]].drives[idx[0]];
+#ifdef CONFIG_DEBUG_IDE
+	printk("max_transfer %x\n", drive->max_sectors * drive->bs);
+#endif
 
 	PUSH(drive->max_sectors * drive->bs);
 }
@@ -1171,6 +1190,9 @@
 ob_ide_block_size(int *idx)
 {
 	struct ide_drive *drive=&ob_ide_channels[idx[1]].drives[idx[0]];
+#ifdef CONFIG_DEBUG_IDE
+	printk("ob_ide_block_size: block size %x\n", drive->bs);
+#endif
 	PUSH(drive->bs);
 }
 
@@ -1184,6 +1206,10 @@
 	fword("device-type");
 
 	// Set dummy reg properties
+
+	set_int_property(ph, "#address-cells", 1);
+	set_int_property(ph, "#size-cells", 0);
+
 	props[0] = __cpu_to_be32(0); props[1] = __cpu_to_be32(0); props[2] = __cpu_to_be32(0);
 	set_property(ph, "reg", (char *)&props, 3*sizeof(int));
 
@@ -1205,7 +1231,7 @@
 	fword("ihandle>phandle");
 	ph=(phandle_t)POP();
 	idename=get_property(ph, "name", &len);
-	idx[1]=idename[3]-0x30;
+	idx[1]=(idename[strlen(idename) - 1] - '0' - FIRST_UNIT) % 2;
 
 #ifdef CONFIG_DEBUG_IDE
 	printk("opening channel %d unit %d\n", idx[1], idx[0]);
@@ -1249,20 +1275,21 @@
 	phandle_t ph=get_cur_dev();
 	char *idename;
 
-	set_int_property(ph, "#address-cells", 1);
-	set_int_property(ph, "#size-cells", 0);
-
 	/* set device type */
-	push_str("ide");
+	push_str(DEV_TYPE);
 	fword("device-type");
 
 	idename=get_property(ph, "name", &len);
-	devnum=idename[3]-0x30;
+	devnum=idename[strlen(idename) - 1] - '0' - FIRST_UNIT;
 
 	/* Create interrupt properties. */
 	props[0]=14; props[1]=0;
 	set_property(ph, "interrupts", (char *)&props, 2*sizeof(int));
 
+	set_property(ph, "compatible", "pci1095,646\0pci1095,646\0pciclass,01018f", 40);
+	set_int_property(ph, "#address-cells", 1);
+	set_int_property(ph, "#size-cells", 0);
+
 	props[0] = __cpu_to_be32(io_ports[devnum]);
 	props[1] = __cpu_to_be32(1); props[2] = __cpu_to_be32(8);
 	props[3] = __cpu_to_be32(ctl_ports[devnum]);
@@ -1281,16 +1308,21 @@
 	{ "decode-unit",	ob_ide_ctrl_decodeunit  },
 };
 
-int ob_ide_init(void)
+int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
+		uint32_t io_port1, uint32_t ctl_port1)
 {
 	int i, j;
-
-        const char *nodetemp_chan = "/pci/isa/ide%d";
-        const char *nodetemp = "/pci/isa/ide%d/%s";
+	const char * nodetemp_chan = "%s/"DEV_NAME;
+	const char * nodetemp = "%s/"DEV_NAME"/%s";
 	char nodebuff[32];
 	phandle_t dnode;
 
-	for (i = 0; i < IDE_NUM_CHANNELS; i++) {
+	io_ports[0] = io_port0;
+	ctl_ports[0] = ctl_port0 + 2;
+	io_ports[1] = io_port1;
+	ctl_ports[1] = ctl_port1 + 2;
+
+	for (i = 0; i < IDE_NUM_CHANNELS; i++, current_channel++) {
 		struct ide_channel *chan = &ob_ide_channels[i];
 
 		chan->mmio = 0;
@@ -1330,10 +1362,13 @@
 
 		ob_ide_identify_drives(chan);
 
-                snprintf(nodebuff, sizeof(nodebuff), nodetemp_chan, i);
+		snprintf(nodebuff, sizeof(nodebuff), nodetemp_chan, path,
+                         current_channel);
 		REGISTER_NAMED_NODE(ob_ide_ctrl, nodebuff);
+		printk(DEV_NAME": [io ports 0x%x-0x%x,0x%x]\n",
+		       current_channel, chan->io_regs[0],
+		       chan->io_regs[0] + 7, chan->io_regs[8]);
 
-		printk("ide%d: [io ports 0x%x-0x%x,0x%x]\n", i, chan->io_regs[0], chan->io_regs[0] + 7, chan->io_regs[8]);
 		for (j = 0; j < 2; j++) {
 			struct ide_drive *drive = &chan->drives[j];
                         const char *media = "UNKNOWN";
@@ -1357,8 +1392,8 @@
 					break;
 			}
 			printk("%s]: %s\n", media, drive->model);
-                        snprintf(nodebuff, sizeof(nodebuff), nodetemp, i,
-                                 media);
+			snprintf(nodebuff, sizeof(nodebuff), nodetemp, path,
+                                 current_channel, media);
 			REGISTER_NAMED_NODE(ob_ide, nodebuff);
 			dnode=find_dev(nodebuff);
 			set_int_property(dnode, "reg", j);

Modified: openbios-devel/drivers/pci.c
===================================================================
--- openbios-devel/drivers/pci.c	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/drivers/pci.c	2008-12-20 14:48:40 UTC (rev 292)
@@ -147,13 +147,11 @@
 
 static int ide_config_cb2 (const pci_config_t *config)
 {
-#if 0
-	ide_init(config->path,
-		 config->regions[0] & ~0x0000000F,
-		 config->regions[1] & ~0x0000000F,
-		 config->regions[2] & ~0x0000000F,
-		 config->regions[3] & ~0x0000000F);
-#endif
+	ob_ide_init(config->path,
+		    config->regions[0] & ~0x0000000F,
+		    config->regions[1] & ~0x0000000F,
+		    config->regions[2] & ~0x0000000F,
+		    config->regions[3] & ~0x0000000F);
 	return 0;
 }
 
@@ -1092,6 +1090,7 @@
 phandle_t pic_handle;
 static int macio_config_cb (const pci_config_t *config)
 {
+#ifdef CONFIG_PPC
 	char buf[64];
 	phandle_t ph;
         cell props[2];
@@ -1108,21 +1107,10 @@
 	set_property(ph, "reg", &props, sizeof(props));
 	pic_handle = ph;
 
-#if 0
 	cuda_init(config->path, config->regions[0]);
 	macio_nvram_init(config->path, config->regions[0]);
-    ide_init(config->path,
-    	     config->regions[0] + 0x1f000,
-    	     config->regions[0] + 0x1f000 + 0x1000,
-    	     config->regions[0] + 0x1f000 + 0x2000,
-    	     config->regions[0] + 0x1f000 + 0x3000);
 #endif
-#if 0
-    OF_finalize_pci_macio(device->common.OF_private,
-                          device->regions[0] & ~0x0000000F, device->sizes[0],
-                          private_data);
-#endif
-    return 0;
+	return 0;
 }
 
 static const pci_dev_t misc_pci[] = {

Modified: openbios-devel/include/openbios/drivers.h
===================================================================
--- openbios-devel/include/openbios/drivers.h	2008-12-18 20:44:20 UTC (rev 291)
+++ openbios-devel/include/openbios/drivers.h	2008-12-20 14:48:40 UTC (rev 292)
@@ -26,7 +26,8 @@
 #endif
 #endif
 #ifdef CONFIG_DRIVER_IDE
-int ob_ide_init(void);
+int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
+                uint32_t io_port1, uint32_t ctl_port1);
 #endif
 #ifdef CONFIG_DRIVER_ESP
 int ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset,




More information about the OpenBIOS mailing list