Re: 2.4.0-test1-ac4 link problem

From: Andrzej Krzysztofowicz (ankry@pg.gda.pl)
Date: Mon May 29 2000 - 17:34:30 EST


> When I try to build 2.5.0-test1-ac4 I get the following
> link error:-
>
> make[1]: Leaving directory `/home/roger/kernel/linux-2.4.0/arch/i386/lib'
> ld -m elf_i386 -T /home/roger/kernel/linux-2.4.0/arch/i386/vmlinux.lds -e stext arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/main.o init/version.o \
> --start-group \
> arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o \
> drivers/block/block.a drivers/char/char.o drivers/misc/misc.o drivers/net/net.o drivers/parport/parport.a drivers/net/appletalk/appletalk.a drivers/net/tokenring/tr.a drivers/ide/ide.a drivers/cdrom/cdrom.a drivers/pci/pci.a drivers/pcmcia/pcmcia.o drivers/video/video.o \
> net/network.a \
> /home/roger/kernel/linux-2.4.0/arch/i386/lib/lib.a /home/roger/kernel/linux-2.4.0/lib/lib.a /home/roger/kernel/linux-2.4.0/arch/i386/lib/lib.a \
> --end-group \
> -o vmlinux
> fs/fs.o: In function `msdos_partition':
> fs/fs.o(.text+0x1fce9): undefined reference to `ide_xlate_1024'
> fs/fs.o(.text+0x1fd1a): undefined reference to `ide_xlate_1024'
> fs/fs.o(.text+0x1fda3): undefined reference to `ide_xlate_1024'
> drivers/ide/ide.a: In function `probe_hwif':
> drivers/ide/ide.a(.text+0x6506): undefined reference to `probe_cmos_for_drives'
> make: *** [vmlinux] Error 1

The following patch fixes ide_xlate_1024() problems for hd/ide usage
and built-in/modular IDE. It introduces a pointer to the ide_xlate_1024()
function, which is set to null when ide_xlate_1024() is not available.

I have tested it with all possible combinations of
CONFIG_BLK_DEV_HD and CONFIG_BLK_DEV_IDE values and it seems to work...

Regards
    Andrzej

**********************************************************************
diff -u --recursive linux-2.4.0test1-ac4/drivers/ide/Makefile linux/drivers/ide/Makefile
--- linux-2.4.0test1-ac4/drivers/ide/Makefile Sat May 27 23:53:10 2000
+++ linux/drivers/ide/Makefile Mon May 29 20:30:18 2000
@@ -19,7 +19,7 @@
 ALL_SUB_DIRS := $(SUB_DIRS)
 
 O_TARGET := ide.a
-O_OBJS := ide-geometry.o
+O_OBJS :=
 M_OBJS :=
 MOD_LIST_NAME := IDE_MODULES
 OX_OBJS :=
@@ -179,11 +179,11 @@
 
 ifeq ($(CONFIG_BLK_DEV_IDE),y)
   OX_OBJS += ide.o ide-features.o
- O_OBJS += ide-probe.o $(IDE_OBJS)
+ O_OBJS += ide-probe.o ide-geometry.o $(IDE_OBJS)
 else
   ifeq ($(CONFIG_BLK_DEV_IDE),m)
   MIX_OBJS += ide.o ide-features.o $(IDE_OBJS)
- M_OBJS += ide-mod.o ide-probe-mod.o
+ M_OBJS += ide-mod.o ide-geometry.o ide-probe-mod.o
   endif
 endif
 
diff -u --recursive linux-2.4.0test1-ac4/drivers/ide/ide-geometry.c linux/drivers/ide/ide-geometry.c
--- linux-2.4.0test1-ac4/drivers/ide/ide-geometry.c Sat May 27 20:14:17 2000
+++ linux/drivers/ide/ide-geometry.c Mon May 29 20:30:18 2000
@@ -3,7 +3,8 @@
  */
 #include <linux/config.h>
 
-#if defined(CONFIG_IDE) && !defined(CONFIG_BLK_DEV_HD)
+#if defined(CONFIG_IDE) || defined(CONFIG_IDE_MODULE)
+#include <linux/module.h>
 #include <linux/ide.h>
 
 #include <asm/io.h>
@@ -152,10 +153,12 @@
         int transl = 1; /* try translation */
         int ret = 0;
 
+ MOD_INC_USE_COUNT;
         drive = get_info_ptr(i_rdev);
- if (!drive)
+ if (!drive) {
+ MOD_DEC_USE_COUNT;
                 return 0;
-
+ }
         /* remap? */
         if (drive->remap_0_to_1 != 2) {
                 if (xparm == 1) { /* DM */
@@ -209,6 +212,7 @@
         if (ret)
                 printk("%s%s [%d/%d/%d]", msg, msg1,
                        drive->bios_cyl, drive->bios_head, drive->bios_sect);
+ MOD_DEC_USE_COUNT;
         return ret;
 }
-#endif /* (CONFIG_IDE) && !(CONFIG_BLK_DEV_HD) */
+#endif /* CONFIG_IDE || CONFIG_IDE_MODULE */
diff -u --recursive linux-2.4.0test1-ac4/drivers/ide/ide-probe.c linux/drivers/ide/ide-probe.c
--- linux-2.4.0test1-ac4/drivers/ide/ide-probe.c Sat May 27 20:14:17 2000
+++ linux/drivers/ide/ide-probe.c Mon May 29 20:30:18 2000
@@ -865,6 +865,7 @@
         int probe[MAX_HWIFS];
         
         MOD_INC_USE_COUNT;
+ idexlateproc = ide_xlate_1024;
         memset(probe, 0, MAX_HWIFS * sizeof(int));
         for (index = 0; index < MAX_HWIFS; ++index)
                 probe[index] = !ide_hwifs[index].present;
@@ -898,6 +899,7 @@
 
 void cleanup_module (void)
 {
+ idexlateproc = NULL;
         ide_probe = NULL;
 }
 #endif /* MODULE */
diff -u --recursive linux-2.4.0test1-ac4/drivers/ide/ide.c linux/drivers/ide/ide.c
--- linux-2.4.0test1-ac4/drivers/ide/ide.c Sat May 27 20:14:17 2000
+++ linux/drivers/ide/ide.c Mon May 29 20:30:18 2000
@@ -2141,7 +2141,10 @@
         memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
         hwif->irq = hw->irq;
         hwif->noprobe = 0;
-
+#ifdef CONFIG_BLK_DEV_HD
+ if (hwif->io_ports[IDE_DATA_OFFSET] == HD_DATA)
+ hwif->noprobe = 1; /* may be overridden by ide_setup() */
+#endif /* CONFIG_BLK_DEV_HD */
         if (!initializing) {
                 ide_probe_module();
 #ifdef CONFIG_PROC_FS
diff -u --recursive linux-2.4.0test1-ac4/fs/partitions/msdos.c linux/fs/partitions/msdos.c
--- linux-2.4.0test1-ac4/fs/partitions/msdos.c Sat May 27 20:14:17 2000
+++ linux/fs/partitions/msdos.c Mon May 29 20:30:18 2000
@@ -27,9 +27,9 @@
 #include <linux/string.h>
 #include <linux/blk.h>
 
-#ifdef CONFIG_BLK_DEV_IDE
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
 #include <linux/ide.h> /* IDE xlate */
-#endif /* CONFIG_BLK_DEV_IDE */
+#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
 
 #include <asm/system.h>
 
@@ -38,6 +38,10 @@
 
 static int current_minor;
 
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
+idexlateproc_t *idexlateproc = NULL;
+#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
+
 /*
  * Many architectures don't like unaligned accesses, which is
  * frequently the case with the nr_sects and start_sect partition
@@ -350,19 +354,19 @@
         unsigned char *data;
         int mask = (1 << hd->minor_shift) - 1;
         int sector_size = get_hardsect_size(dev) / 512;
-#ifdef CONFIG_BLK_DEV_IDE
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
         int tested_for_xlate = 0;
 
 read_mbr:
-#endif /* CONFIG_BLK_DEV_IDE */
+#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
         if (!(bh = bread(dev,0,get_ptable_blocksize(dev)))) {
                 if (warn_no_part) printk(" unable to read partition table\n");
                 return -1;
         }
         data = bh->b_data;
-#ifdef CONFIG_BLK_DEV_IDE
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
 check_table:
-#endif /* CONFIG_BLK_DEV_IDE */
+#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
         /* Use bforget(), because we may have changed the disk geometry */
         if (*(unsigned short *) (0x1fe + data) != cpu_to_le16(MSDOS_LABEL_MAGIC)) {
                 bforget(bh);
@@ -370,8 +374,8 @@
         }
         p = (struct partition *) (0x1be + data);
 
-#ifdef CONFIG_BLK_DEV_IDE
- if (!tested_for_xlate++) { /* Do this only once per disk */
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
+ if (!tested_for_xlate++ && idexlateproc) { /* Do this only once per disk */
                 /*
                  * Look for various forms of IDE disk geometry translation
                  */
@@ -397,7 +401,7 @@
                         /*
                          * Accesses to sector 0 must go to sector 1 instead.
                          */
- if (ide_xlate_1024(dev, -1, heads, " [EZD]")) {
+ if (idexlateproc(dev, -1, heads, " [EZD]")) {
                                 data += 512;
                                 goto check_table;
                         }
@@ -407,7 +411,7 @@
                          * Everything on the disk is offset by 63 sectors,
                          * including a "new" MBR with its own partition table.
                          */
- if (ide_xlate_1024(dev, 1, heads, " [DM6:DDO]")) {
+ if (idexlateproc(dev, 1, heads, " [DM6:DDO]")) {
                                 bforget(bh);
                                 goto read_mbr; /* start over with new MBR */
                         }
@@ -415,18 +419,18 @@
                            data[sig] == 0xAA && data[sig+1] == 0x55 &&
                            (data[sig+2] & 1)) {
                         /* DM6 signature in MBR, courtesy of OnTrack */
- (void) ide_xlate_1024 (dev, 0, heads, " [DM6:MBR]");
+ (void) idexlateproc(dev, 0, heads, " [DM6:MBR]");
                 } else if (SYS_IND(p) == DM6_AUX1PARTITION ||
                            SYS_IND(p) == DM6_AUX3PARTITION) {
                         /*
                          * DM6 on other than the first (boot) drive
                          */
- (void) ide_xlate_1024(dev, 0, heads, " [DM6:AUX]");
+ (void) idexlateproc(dev, 0, heads, " [DM6:AUX]");
                 } else {
- (void) ide_xlate_1024(dev, 2, heads, " [PTBL]");
+ (void) idexlateproc(dev, 2, heads, " [PTBL]");
                 }
         }
-#endif /* CONFIG_BLK_DEV_IDE */
+#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
 
         /* Look for partitions in two passes:
            First find the primary partitions, and the DOS-type extended partitions.
diff -u --recursive linux-2.4.0test1-ac4/include/linux/ide.h linux/include/linux/ide.h
--- linux-2.4.0test1-ac4/include/linux/ide.h Sat May 27 21:50:15 2000
+++ linux/include/linux/ide.h Mon May 29 20:30:18 2000
@@ -667,6 +667,9 @@
 
 int ide_wait_noerr (ide_drive_t *drive, byte good, byte bad, unsigned long timeout);
 
+typedef int (idexlateproc_t)(kdev_t, int, int, const char *);
+extern idexlateproc_t *idexlateproc;
+
 /*
  * This routine is called from the partition-table code in genhd.c
  * to "convert" a drive to a logical geometry with fewer than 1024 cyls.
diff -u --recursive linux-2.4.0test1-ac4/kernel/ksyms.c linux/kernel/ksyms.c
--- linux-2.4.0test1-ac4/kernel/ksyms.c Sat May 27 23:53:11 2000
+++ linux/kernel/ksyms.c Mon May 29 20:34:16 2000
@@ -296,6 +296,11 @@
 EXPORT_SYMBOL(file_moveto);
 EXPORT_SYMBOL(drive_stat_acct);
 EXPORT_SYMBOL(set_bh_page);
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
+#include <linux/ide.h>
+/* for partitions/msdos.c <-> drivers/ide/ide-geometry.c interaction */
+EXPORT_SYMBOL(idexlateproc);
+#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
 
 /* tty routines */
 EXPORT_SYMBOL(tty_hangup);
**********************************************************************

--
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Technical University of Gdansk

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:22 EST