[SDBUG] Re: FreeBSD KLD Module Problem

Kiran Patil - NPD, Chennai. kiranp at hcltech.com
Tue May 17 11:43:42 PDT 2005


Hi Andrew,

>>	No panic message?  nothing?  I will have to more closely inspect the
5.3 
Release code (looking at 6.0-CURRENT).

	Yes I am getting panic message. It looks like this,

	Fatal Trap 12 : page fault while in kernel mode
	Fatal Virtual Address 	= 	0x0
	Fatal Code		=	Supervisor Read, Page not present
	...

>>	I guess I was looking for the answer "my cdev was initialized OK."

	I made use of sample character driver available from freebsd.org
site. So here is the small code snippet,
	
	static struct cdev *echo_dev;	<---- Do you mean to initialize the
"echo_dev"?
	
	static int
	echo_loader(struct module *m, int what, void *arg)
	{
    	  int err = 0;
   	  
  	  switch (what) {
    	  case MOD_LOAD:                /* kldload */
    	    echo_dev = make_dev(&echo_cdevsw,
      	     0,
      	     UID_ROOT,
       	     GID_WHEEL,
       	     0600,
       	     "echo");
     	     /* kmalloc memory for use by this driver */
     	     MALLOC(echomsg, t_echo *, sizeof(t_echo), M_ECHOBUF, M_WAITOK);
     	     printf("Echo device loaded.\n");
     	   break;
	 ...
	 }

>	I did some changes and obtained the following results,
	static int
	echo_loader(struct module *m, int what, void *arg)
	{
    	  int err = 0;
   	  return(10);	--------> if I put return(-1) or return(10) module
will not encounter panic instead  module will registers, the out put of
dmesg is at the end of this function.
  	  switch (what) {					
							
    	  case MOD_LOAD:                /* kldload */	
    	    echo_dev = make_dev(&echo_cdevsw,		      
	     0,
      	     UID_ROOT,
       	     GID_WHEEL,
       	     0600,
       	     "echo");
     	     /* kmalloc memory for use by this driver */
     	     MALLOC(echomsg, t_echo *, sizeof(t_echo), M_ECHOBUF, M_WAITOK);
     	     printf("Echo device loaded.\n");
     	   break;
	 ...
	 }

The out put of dmesg:
Freebsd# dmesg
module_register_init: MOD_LOAD (echo, 0xc16895cc, 0) error 10
module_register_init: MOD_LOAD (echo, 0xc16a45cc, 0) error -1

The out put of kldstat:
Freebsd# kldstat
Id Refs Address    Size     Name
 1    4 0xc0400000 5cdad0   kernel
 2   14 0xc09ce000 537f0    acpi.ko
 3    1 0xc16b6000 2000     char.ko

So even though I returned before case MOD_LOAD: in the module with nonzero
values, the module will registers to the kernel,
I need to do kldunload to remove it from the kernel.

But my need is, I have to return from the module before registering it as
CHARACTER DRIVER to the kernel and the module should not be present in
kernel so as to avoid doing KLDUNLOAD.

Thanks,
Kiran





Disclaimer:

This message and any attachment(s) contained here are information that is confidential, proprietary to HCL Technologies and its customers, privileged or otherwise protected by law. The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.


More information about the SDBUG mailing list
More information about M5 Hosting