[openbeos-midi] Re: module std_ops function

  • From: Philippe Houdoin <philippe.houdoin@xxxxxxx>
  • To: openbeos-midi@xxxxxxxxxxxxx
  • Date: Mon, 15 Sep 2003 23:52:07 +0200

Crain Greg asked:
> Hi,
> When you get_module the very first thing that seems to be called is the

Only when the module wasn't already loaded by another kernel driver or module, 
aka it's the first get_module() called on this module name.
But, put shortly, that's pretty much right, yes.

So, B_MODULE_INIT state is not the best place to setup stuff that should be 
by module *client*. Only global setup should be done here...
> my code:
> static status_t
> std_ops(int32 op, ...)
> {
>       dprintf("std_ops 0x%x\n", op);
>       switch(op) {
>       case B_MODULE_INIT:
>               mpu_readlock = create_sem(0, "mpu401 read");
>            //set_sem_owner(mpu_readlock, B_SYSTEM_TEAM);
>               if (mpu_readlock < B_OK)
>                       return mpu_readlock;
>               dprintf("mpu401: B_MODULE_INIT  sem_id:%d\n",mpu_readlock);
>               if (get_module(B_ISA_MODULE_NAME, (module_info **)&gISA) < B_OK)
>               {
>                       dprintf("could not get ISA module\n");
>                 return (B_ERROR);
>               }
>       return B_OK;
>       case B_MODULE_UNINIT:
> ..etc..
> }

Looks good enought to me.

> Is there a way to determine what is being passed to the 'std_ops( int32,
> ...)' function?   I'm not clear what the '...' could be or how it works.

There are no known usage of extra argument(s) to std_ops() hook that every 
every kernel module should export.
Today, there is only B_MODULE_INIT and B_MODULE_UNINIT op codes, without any 
extra arguments.

However, I'm not sure, but maybe BeOS release > R5.0.x (aka Dano) add some new 
std_ops() op code, for power saving support, like the extra drivers API 
introduced in Dano...
> I'm returning a B_OK, but it seems that for the AWE64, there is something
> more that the caller is expecting from the B_MODULE_INIT. 

The AWE64 driver just do a get_module("generic/mpu401/v1", &module_info).
However, if your mpu401 module replacement (that should be placed under 
/boot/beos/system/add-ons/kernel/generic/mpu401, BTW) don't return B_OK 
from his std_ops() module hook, module initialisation will be considered failed 
by BeOS kernel modules manager, and get_module() will fail too.

>  The R5 module
> works, but with my module code the AWE64 driver does not continue
> initializing after this point. 

Did your "mpu401: B_MODULE_INIT  sem_id:%d\n" message show up in 
kernel debug output?

BTW, under BeOS R5 and previous, the ISA module is builtin. I don't see how get 
ISA module could failed, even if it's a good behavior to check, as... 
well, "you never know!".

So, check the message show up, if not check you don't have original MPU401 
module already loaded (and hidding yours...).
Do you have implemented, even empty, the MPU401 hooks (create_device() and co)?
Did you see your create_device() called by the AWE64 driver?


> Greg


Other related posts: