FreeBSD/sys/dev/firewire/firewire.c
/*
 * Find the root node, if it is not
 * Cycle Master Capable, then we should
 * override this and become the Cycle
 * Master
 */
Find the root node, if it is not
Cycle Master Capable, then we should
override this and become the Cycle
Master
Find the root node if it is not Cycle Master Capable then we should override this and become the Cycle Master
static int
fw_bmr(struct firewire_comm *fc)
{
	struct fw_device fwdev;
	union fw_self_id *self_id;
	int cmstr;
	uint32_t quad;
	self_id = fw_find_self_id(fc, fc->max_node);
	if (fc->max_node > 0) {
		if (self_id->p0.link_active && self_id->p0.contender)
			cmstr = fc->max_node;
		else {
			device_printf(fc->bdev,
			    "root node is not cycle master capable\n");
			cmstr = fc->nodeid;
		}
	} else
		cmstr = -1;
	device_printf(fc->bdev, "bus manager %d %s\n",
		CSRARC(fc, BUS_MGR_ID),
		(CSRARC(fc, BUS_MGR_ID) != fc->nodeid) ? "(me)" : "");
	if (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) {
		return (0);
	}
	if (fc->max_hop <= MAX_GAPHOP)
		fw_phy_config(fc, cmstr, gap_cnt[fc->max_hop]);
	if (cmstr == fc->nodeid || cmstr == -1)
		return 0;
	bzero(&fwdev, sizeof(fwdev));
	fwdev.fc = fc;
	fwdev.dst = cmstr;
	fwdev.speed = 0;
	fwdev.maxrec = 8; 
	fwdev.status = FWDEVINIT;
	quad = htonl(1 << 8);
	fwmem_write_quad(&fwdev, NULL, 0,
	    0xffff, 0xf0000000 | STATE_SET, &quad, fw_asy_callback_free);
	return 0;
}
static int fw_bmr ( struct firewire_comm * fc ) { struct fw_device fwdev ; union fw_self_id * self_id ; int cmstr ; uint32_t quad ; self_id = fw_find_self_id ( fc , fc -> max_node ) ; if ( fc -> max_node > 0 ) { if ( self_id -> p0 . link_active && self_id -> p0 . contender ) cmstr = fc -> max_node ; else { device_printf ( fc -> bdev , " \n " ) ; cmstr = fc -> nodeid ; } } else cmstr = -1 ; device_printf ( fc -> bdev , " \n " , CSRARC ( fc , BUS_MGR_ID ) , ( CSRARC ( fc , BUS_MGR_ID ) != fc -> nodeid ) ? " " : " " ) ; if ( CSRARC ( fc , BUS_MGR_ID ) != fc -> nodeid ) { return ( 0 ) ; } if ( fc -> max_hop <= MAX_GAPHOP ) fw_phy_config ( fc , cmstr , gap_cnt [ fc -> max_hop ] ) ; if ( cmstr == fc -> nodeid || cmstr == -1 ) return 0 ; bzero ( & fwdev , sizeof ( fwdev ) ) ; fwdev . fc = fc ; fwdev . dst = cmstr ; fwdev . speed = 0 ; fwdev . maxrec = 8 ; fwdev . status = FWDEVINIT ; quad = htonl ( 1 << 8 ) ; fwmem_write_quad ( & fwdev , NULL , 0 , 0xffff , 0xf0000000 | STATE_SET , & quad , fw_asy_callback_free ) ; return 0 ; }
Find the root node, if it is not
 Cycle Master Capable, then we should
 override this and become the Cycle
 Master
Find the root node if it is not Cycle Master Capable then we should override this and become the Cycle Master
/* Check to see if the current root node is cycle master capable */ /* XXX check cmc bit of businfo block rather than contender */ /* XXX shall we be the cycle master? */ /* XXX need bus reset */ /* We are not the bus manager */ /* Optimize gapcount */ /* If we are the cycle master, nothing to do */ /* Bus probe has not finished, make dummy fwdev for cmstr */ /* 512 */ /* Set cmstr bit on the cycle master */ /*spd*/