someone can helpme with request_region() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



CFLAGS= -O2 -fno-strict-aliasing -Wall

KERNELDIR= /usr/src/linux

mydrv.o: mydrv.c
	$(MAKE) -C $(KERNELDIR) M=$(PWD) 

obj-m := mydrv.o

back:
	cp mydrv* drv
	cp Makefile.mydrv drv

.PHONY: clean back
 
clean: 
	rm mydrv.o mydrv.ko


--------------------------------------------------
/*
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ioport.h>

MODULE_LICENSE("GPL");

MODULE_DESCRIPTION("my driver");

/* Standard ISAPnP ports */

#define ADDRESS 0x279
#define WRITE_DATA 0xa79
#define READ_DATA 0x203		/* assigned range port 0x200 to
0x3ff masked by 0x3 */

#define DRV_NAME "mydrv"

/* remove ethernet card */
static void my_remove(void)
{

	printk(KERN_INFO "Remove started\n");
/*
	release_region(ADDRESS, 1);
	release_region(WRITE_DATA, 1);
	release_region(READ_DATA, 1);
*/
	printk(KERN_INFO "Remove exit!\n");

}

/* probe the card */
static int __init my_probe(void)
{
	// request_region(start, n, name)
	// for data port, addr port & read port

	/*
	if (!request_region(ADDRESS, 1, DRV_NAME)) {
		printk(KERN_INFO "pnp_addr port not available.\n");
	} else {
		printk(KERN_INFO "pnp_addr port available.\n");
		release_region(ADDRESS, 1);
	}
	
	if (!request_region(WRITE_DATA, 1, DRV_NAME)) {
		printk(KERN_INFO "pnp_write_data port not
available.\n"); } else {
		printk(KERN_INFO "pnp_write_data port available.\n");
		release_region(WRITE_DATA, 1);
	}
	*/
	if (!request_region(READ_DATA, 1, DRV_NAME)) {
		printk(KERN_INFO "pnp_read_data: %#x port not
available.\n", READ_DATA); } else {
		printk(KERN_INFO "pnp_read_data: %#x port
available.\n", READ_DATA); release_region(READ_DATA, 1);
	}
	
	//	set_wait(0x04);		// wait for key

	//	set_wait(0x02);

//      set_wait(0x04); // CSN = 0

//	write_csn(0);		// all cards to isolation

//	wake_csn(0);

//	write_csn(1);		// wake first card

//	read_conf();		// read config and write to dmesg

	return 0;

}

static int __init my_init(void)
{

	printk(KERN_INFO "Initializing...\n");

	if(my_probe())
		return -1;

	printk(KERN_INFO "Init finished.\n");


	return 0;
}

static void __exit my_clean(void)
{

	my_remove();

}

module_init(my_init);
module_exit(my_clean);


--------------------------------------------
#dmesg

Initializing...
BUG: rwlock cpu recursion on CPU#0, insmod/5143, c028c998
 [<c0103c89>] dump_stack+0x15/0x17
 [<c01b16f9>] rwlock_bug+0x3d/0x45
 [<c01b1848>] _raw_write_lock+0x45/0x55
 [<c0249181>] _write_lock+0x17/0x1a
 [<c011aef1>] __request_region+0x46/0x7a
 [<c8a3402d>] my_probe+0x2d/0x90 [mydrv]
 [<c8a340a7>] my_init+0x17/0x34 [mydrv]
 [<c012c9a4>] sys_init_module+0xd6/0x228
 [<c01027d9>] syscall_call+0x7/0xb
Unable to handle kernel NULL pointer dereference at virtual address
00000207 printing eip:
c011ab4d
*pde = 00000000
Oops: 0000 [#2]
PREEMPT DEBUG_PAGEALLOC
Modules linked in: mydrv tsdev parport_pc parport floppy
8250_pnp 8250 s erial_core pcspkr snd_cmipci snd_opl3_lib snd_hwdep
snd_mpu401_uart snd_rawmidi snd_seq_device i2c_viapro i2c_core via_agp
uhci_hcd usbcore sg sr_mod aic7xxx sc si_transport_spi scsi_mod sis900
mii agpgart snd_pcm_oss snd_pcm snd_timer snd_p age_alloc snd_mixer_oss
snd soundcore ide_cd cdrom unix CPU:    0 EIP:    0060:[<c011ab4d>]
Not tainted VLI EFLAGS: 00010286   (2.6.15) EIP is at
__request_resource+0x14/0x45 eax: 00000203   ebx: c54aad4c   ecx:
00000203   edx: c54aad4c esi: d330eaaf   edi: 10000000   ebp:
c53f7f58   esp: c53f7f4c ds: 007b   es: 007b   ss: 0068 Process insmod
(pid: 5143, threadinfo=c53f6000 task=c5d7bab0) Stack: c54aad4c 00000203
10000000 c53f7f70 c011aefa c330eab0 c8a32700 c53f6000 b7f0de70 c53f7f90
c8a3402d c028c960 00000203 00000001 c8a32093 c8a32099 c53f7f9c c53f7fa0
c8a340a7 c8a32099 b7f0de70 c53f7fb4 c012c9a4 0804b018 Call Trace:
[<c0103c6c>] show_stack+0x7e/0x86 [<c0103d77>] show_registers+0xec/0x154
 [<c0103f2e>] die+0xdb/0x14c
 [<c0111a10>] do_page_fault+0x38a/0x4c5
 [<c010392f>] error_code+0x4f/0x60
 [<c011aefa>] __request_region+0x4f/0x7a
 [<c8a3402d>] my_probe+0x2d/0x90 [mydrv]
 [<c8a340a7>] my_init+0x17/0x34 [mydrv]
 [<c012c9a4>] sys_init_module+0xd6/0x228
 [<c01027d9>] syscall_call+0x7/0xb
Code: c0 89 c2 75 0d 8b 83 80 00 00 00 c7 40 44 7c c9 28 c0 5b 89 d0 c9
c3 55 89 c1 89 e5  57 56 53 89 d3 8b 7a 04 8b 72 08 39 fe 72 2c <3b> 78
04 72 27 3b 70 08 77 22 8d 50 18 8b  02 85 c0 74 05 39 70 <6>note:
insmod[5143] exited with preempt_count 1 Debug: sleeping function
called from invalid context at include/linux/rwsem.h:43 in_atomic():1,
irqs_disabled():0 [<c0103c89>] dump_stack+0x15/0x17 [<c0113df9>]
__might_sleep+0x8f/0x99 [<c0117a90>] exit_mm+0x2f/0x10b
 [<c01183d8>] do_exit+0x17a/0x395
 [<c0103f9f>] do_trap+0x0/0x96
 [<c0111a10>] do_page_fault+0x38a/0x4c5
 [<c010392f>] error_code+0x4f/0x60
 [<c011aefa>] __request_region+0x4f/0x7a
 [<c8a3402d>] my_probe+0x2d/0x90 [mydrv]
 [<c8a340a7>] my_init+0x17/0x34 [mydrv]
 [<c012c9a4>] sys_init_module+0xd6/0x228
 [<c01027d9>] syscall_call+0x7/0xb


# cat /proc/ioports
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-006f : keyboard
0070-0077 : rtc
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : ide1
01f0-01f7 : ide0
02f8-02ff : serial
0376-0376 : ide1
0378-037a : parport0
037b-037f : parport0
03c0-03df : vga+
03f0-03f1 : W83877F WDT
03f6-03f6 : ide0
03f8-03ff : serial
0443-0443 : W8387FF WDT
0778-077a : parport0
0cf8-0cff : PCI conf1
5000-5007 : vt596_smbus
c000-cfff : PCI Bus #01
  c000-c07f : 0000:01:00.0
d000-d00f : 0000:00:07.1
  d000-d007 : ide0
  d008-d00f : ide1
d400-d41f : 0000:00:07.2
  d400-d41f : uhci_hcd
d800-d8ff : 0000:00:09.0
  d800-d8ff : CMI8738
dc00-dcff : 0000:00:0a.0
e000-e0ff : 0000:00:0b.0
  e000-e0ff : sis900


TIA

--ArYiX

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux