FreeBSD/sys/dev/firewire/sbp_targ.c
/*
 * Create page table in local memory
 * and transfer it from the initiator
 * in order to know where we are supposed
 * to put the data.
 */
Create page table in local memory
and transfer it from the initiator
in order to know where we are supposed
to put the data.
Create page table in local memory and transfer it from the initiator in order to know where we are supposed to put the data .
static void
sbp_targ_fetch_pt(struct orb_info *orbi)
{
	struct fw_xfer *xfer;
	if (orbi->page_table == NULL) {
		orbi->page_table = malloc(orbi->orb4.data_size*
					  sizeof(struct unrestricted_page_table_fmt),
					  M_SBP_TARG, M_NOWAIT|M_ZERO);
		if (orbi->page_table == NULL)
			goto error;
		orbi->cur_pte = orbi->page_table;
		orbi->last_pte = orbi->page_table + orbi->orb4.data_size;
		orbi->last_block_read = orbi->orb4.data_size;
		if (debug && orbi->page_table != NULL) 
			printf("%s: malloc'd orbi->page_table(%p), orb4.data_size(%u)\n",
 				__func__, orbi->page_table, orbi->orb4.data_size);
		xfer = fwmem_read_block(orbi->fwdev, (void *)orbi, FWSPD_S400,
					orbi->data_hi, orbi->data_lo, orbi->orb4.data_size*
					sizeof(struct unrestricted_page_table_fmt),
					(void *)orbi->page_table, sbp_targ_pt_done);
		if (xfer != NULL)
			return;
	} else {
		sbp_targ_xfer_pt(orbi);
		return;
	}
error:
	orbi->ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
	if (debug)      
		printf("%s: free orbi->page_table %p due to xfer == NULL\n", __func__, orbi->page_table);
	if (orbi->page_table != NULL) {
		free(orbi->page_table, M_SBP_TARG);
		orbi->page_table = NULL;
	}
	xpt_done(orbi->ccb);
	return;
}
static void sbp_targ_fetch_pt ( struct orb_info * orbi ) { struct fw_xfer * xfer ; if ( orbi -> page_table == NULL ) { orbi -> page_table = malloc ( orbi -> orb4 . data_size * sizeof ( struct unrestricted_page_table_fmt ) , M_SBP_TARG , M_NOWAIT | M_ZERO ) ; if ( orbi -> page_table == NULL ) goto error ; orbi -> cur_pte = orbi -> page_table ; orbi -> last_pte = orbi -> page_table + orbi -> orb4 . data_size ; orbi -> last_block_read = orbi -> orb4 . data_size ; if ( debug && orbi -> page_table != NULL ) printf ( " \n " , __func__ , orbi -> page_table , orbi -> orb4 . data_size ) ; xfer = fwmem_read_block ( orbi -> fwdev , ( void * ) orbi , FWSPD_S400 , orbi -> data_hi , orbi -> data_lo , orbi -> orb4 . data_size * sizeof ( struct unrestricted_page_table_fmt ) , ( void * ) orbi -> page_table , sbp_targ_pt_done ) ; if ( xfer != NULL ) return ; } else { sbp_targ_xfer_pt ( orbi ) ; return ; } error : orbi -> ccb -> ccb_h . status = CAM_RESRC_UNAVAIL ; if ( debug ) printf ( " \n " , __func__ , orbi -> page_table ) ; if ( orbi -> page_table != NULL ) { free ( orbi -> page_table , M_SBP_TARG ) ; orbi -> page_table = NULL ; } xpt_done ( orbi -> ccb ) ; return ; }
Create page table in local memory
 and transfer it from the initiator
 in order to know where we are supposed
 to put the data.
Create page table in local memory and transfer it from the initiator in order to know where we are supposed to put the data .
/*
	 * Pull in page table from initiator
	 * and setup for data from our
	 * backend device.
	 */ /*spd*/ /*
		 * This is a CTIO for a page table we have
		 * already malloc'd, so just directly invoke
		 * the xfer function on the orbi.
		 */