>
> in mdBindDev, it calls mdControlChan, as follows,
...
> but why in mdControlChan, we can typecast the (pointer to PortObj) to
> (pointer to _VPORT_ChanObj)?
...
Notice that in mdBindDev, the call to mdControlChan has
VPORT_CMD_CONFIG_PORT as the second parameter. Looking at mdControlChan,
the switch statement contains:
...
case VPORT_CMD_CONFIG_PORT:
retVal = _configPort(chanp, args);
break;
...
Now, looking at _configPort, we see that:
static Int _configPort(Ptr portp, Ptr args)
{
PortObj* port = (PortObj *)portp;
....
So, calling mdControlChan with VPORT_CMD_CONFIG_PORT is a special case.
In this case, chanp is a pointer to a port (PortObj *), in all other
cases it's a pointer to a channel (_VFVPORT_ChanObj*).
Cheers
mark-r
--
"Let's meet the panel. You couldn't ask for four finer comedians -
so that answers your next question..."
-- Humphrey Lyttleton
Reply by hmq●June 19, 20062006-06-19
I am now working on TI Dm642 evm and studying DDK. I have some problems
with the video port driver.
in mdBindDev, it calls mdControlChan, as follows,
===================
static Int mdBindDev(Ptr *devp, Int devid, Ptr devParams)
{
Int portNum = devid;
volatile Int i;
volatile Int* base = (volatile Int *)portObjs[portNum].base;
assert(portNum < _VP_PORT_CNT);
base[_VP_VPCTL_OFFSET] = VP_VPCTL_VPRST_RESET <<
_VP_VPCTL_VPRST_SHIFT;
for(i = 0; i < 100000; i ++);
*devp = &portObjs[portNum];
return mdControlChan(&portObjs[portNum], VPORT_CMD_CONFIG_PORT,
devParams);
}
=======================
but why in mdControlChan, we can typecast the (pointer to PortObj) to
(pointer to _VPORT_ChanObj)?
static Int mdControlChan(Ptr chanp, Uns cmd, Ptr args)
{
Int retVal = IOM_EBADMODE;
_VPORT_ChanObj* chan = (_VPORT_ChanObj* )chanp;
PortObj* port = &portObjs[chan->portNum];
....
==========================
Can anyone help me? I am really appreciate your help.