PCMCIA must be on to define ide_register and _unregister.
Then I used this module:
#define MODULE
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
int port=0x1f0;
int port1=0x3f6;
int irq=14;
int index=0;
int res;
init_module() {
printk("ide_unregister(%d)->%d\n",
res=index, ide_unregister(index));
printk("ide_register(%x, %x, %d)->%d\n",
port, port1, irq,
res=ide_register(port, port1, irq));
return res;
}
cleanup_module() {
}
Ok, look at this:
dmesg:
...
hda: WDC AC2700F, 696MB w/64kB Cache, LBA, CHS=708/32/63
hdb: , 40MB w/0kB Cache, CHS=745/4/28
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Partition check:
hda:Started kswapd v 1.4.2.2
hda1 < hda5 hda6 hda7 > hda2 hda3 hda4
hdb: hdb1
Adding Swap: 13068k swap-space (priority -1)
Swap is /dev/hda6.
Then, I did this:
insmod module.o port=0x1f0 port1=0x3f6 irq=14 index=0
Ok, I received:
ide_unregister(0)->1836132
hda: WDC AC2700F, 696MB w/64kB Cache, LBA, CHS=708/32/63
hdb: , 40MB w/0kB Cache, CHS=745/4/28
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hda: hda1 < hda5 hda6 > hda2 hda3 hda4
hdb: hdb1
ide_register(1f0, 3f6, 14)->0
Note the difference in partition table! cfdisk, BTW, read partition table
right after this.
Well, /dev/hda7 became mangled. Exactly - inodes was mangled, one
directory, and some files got dupe blocks. And swap became crazy -
ll_blk_rw: device 3:6: 1024 blocks ... not supported (4096).
3:6 is /dev/hda6, my swap.
I believe, this can be a lba problem ? Because on high-level directories,
it's readable, and if I go too deep in /dev/hda7 after such a action (insmod
module), I get:
EXT2-fs error (device 03:07): ext2_find_entry: bad entry in directory #39088: rec_len is smaller than minimal - offset=0, inode=1535, rec_len=0, name_len=17547
EXT2-fs error (device 03:07): ext2_find_entry: bad entry in directory #39255: directory entry across blocks - offset=0, inode=3458232727, rec_len=62728, name_len=15932
So, it's just mangled..
Well, so the question is:
- how do I make this work right?
- how do I implement some kind of a kernel lock: I mean, I need something to
lock kernel while this module is being run init_module, to prevent shit from
happening?
- what does it mean, this return code from ide_unregister? What does it
mean - port1 parameter to ide_register?
PS: Gadi Oxman: thanks! When I added hdb=slow to lilo boot, my old maxtor
40mb hdd started to work right! :-)
Egor Egorov, ComputerWorld/Kiev, egor@fastware.kiev.ua
Nothing in this message relates in any way with ComputerWorld/Kiev or IDG.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GMC/FA/CS dx s+:- a? C+++ UBLC*++++ P+ L+++ E--- W+++ N+++ o+ K? w--- O!
!M V? PS! PE! Y? PGP++@ t@ 5@ X@ R++@ tv++@ b+++ DI? D++() G !e h* r? z?
------END GEEK CODE BLOCK------