FreeBSD/sys/dev/mfi/mfi_tbolt.c
/*
 * Description:
 *      This function will prepare message pools for the Thunderbolt controller
 * Arguments:
 *      DevExt - HBA miniport driver's adapter data storage structure
 *      pMemLocation - start of the memory allocated for Thunderbolt.
 * Return Value:
 *      TRUE if successful
 *      FALSE if failed
 */
This function will prepare message pools for the Thunderbolt controller
Arguments:
DevExt - HBA miniport driver's adapter data storage structure
pMemLocation - start of the memory allocated for Thunderbolt.
Return Value:
TRUE if successful
FALSE if failed
This function will prepare message pools for the Thunderbolt controller Arguments : DevExt - HBA miniport driver ' s adapter data storage structure pMemLocation - start of the memory allocated for Thunderbolt . Return Value : TRUE if successful FALSE if failed
int
mfi_tbolt_init_desc_pool(struct mfi_softc *sc, uint8_t* mem_location,
    uint32_t tbolt_contg_length)
{
	uint32_t     offset = 0;
	uint8_t      *addr = mem_location;
	if (((uintptr_t)addr) & (0xFF)) {
		addr = &addr[sc->raid_io_msg_size];
		addr = (uint8_t *)((uintptr_t)addr & (~0xFF));
		sc->request_message_pool_align = addr;
	} else
		sc->request_message_pool_align = addr;
	offset = sc->request_message_pool_align - sc->request_message_pool;
	sc->request_msg_busaddr = sc->mfi_tb_busaddr + offset;
	addr = &addr[sc->raid_io_msg_size * (sc->mfi_max_fw_cmds + 1)];
	sc->reply_frame_pool = (struct mfi_mpi2_reply_header *) addr;
	if (((uintptr_t)addr) & (0xFF)) {
		addr = &addr[sc->reply_size];
		addr = (uint8_t *)((uintptr_t)addr & (~0xFF));
	}
	sc->reply_frame_pool_align
		    = (struct mfi_mpi2_reply_header *)addr;
	offset = (uintptr_t)sc->reply_frame_pool_align
	    - (uintptr_t)sc->request_message_pool;
	sc->reply_frame_busaddr = sc->mfi_tb_busaddr + offset;
	addr += sc->reply_size * sc->mfi_max_fw_cmds;
	sc->reply_pool_limit = addr;
	memset((uint8_t *)sc->reply_frame_pool, 0xFF,
	       (sc->reply_size * sc->mfi_max_fw_cmds));
	offset = sc->reply_size * sc->mfi_max_fw_cmds;
	sc->sg_frame_busaddr = sc->reply_frame_busaddr + offset;
	sc->last_reply_idx = 0;
	MFI_WRITE4(sc, MFI_RFPI, sc->mfi_max_fw_cmds - 1);
	MFI_WRITE4(sc, MFI_RPI, sc->last_reply_idx);
	offset = (sc->sg_frame_busaddr + (MEGASAS_MAX_SZ_CHAIN_FRAME *
	    sc->mfi_max_fw_cmds)) - sc->mfi_tb_busaddr;
	if (offset > tbolt_contg_length)
		device_printf(sc->mfi_dev, "Error:Initialized more than "
		    "allocated\n");
	return 0;
}
int mfi_tbolt_init_desc_pool ( struct mfi_softc * sc , uint8_t * mem_location , uint32_t tbolt_contg_length ) { uint32_t offset = 0 ; uint8_t * addr = mem_location ; if ( ( ( uintptr_t ) addr ) & ( 0xFF ) ) { addr = & addr [ sc -> raid_io_msg_size ] ; addr = ( uint8_t * ) ( ( uintptr_t ) addr & ( ~ 0xFF ) ) ; sc -> request_message_pool_align = addr ; } else sc -> request_message_pool_align = addr ; offset = sc -> request_message_pool_align - sc -> request_message_pool ; sc -> request_msg_busaddr = sc -> mfi_tb_busaddr + offset ; addr = & addr [ sc -> raid_io_msg_size * ( sc -> mfi_max_fw_cmds + 1 ) ] ; sc -> reply_frame_pool = ( struct mfi_mpi2_reply_header * ) addr ; if ( ( ( uintptr_t ) addr ) & ( 0xFF ) ) { addr = & addr [ sc -> reply_size ] ; addr = ( uint8_t * ) ( ( uintptr_t ) addr & ( ~ 0xFF ) ) ; } sc -> reply_frame_pool_align = ( struct mfi_mpi2_reply_header * ) addr ; offset = ( uintptr_t ) sc -> reply_frame_pool_align - ( uintptr_t ) sc -> request_message_pool ; sc -> reply_frame_busaddr = sc -> mfi_tb_busaddr + offset ; addr += sc -> reply_size * sc -> mfi_max_fw_cmds ; sc -> reply_pool_limit = addr ; memset ( ( uint8_t * ) sc -> reply_frame_pool , 0xFF , ( sc -> reply_size * sc -> mfi_max_fw_cmds ) ) ; offset = sc -> reply_size * sc -> mfi_max_fw_cmds ; sc -> sg_frame_busaddr = sc -> reply_frame_busaddr + offset ; sc -> last_reply_idx = 0 ; MFI_WRITE4 ( sc , MFI_RFPI , sc -> mfi_max_fw_cmds - 1 ) ; MFI_WRITE4 ( sc , MFI_RPI , sc -> last_reply_idx ) ; offset = ( sc -> sg_frame_busaddr + ( MEGASAS_MAX_SZ_CHAIN_FRAME * sc -> mfi_max_fw_cmds ) ) - sc -> mfi_tb_busaddr ; if ( offset > tbolt_contg_length ) device_printf ( sc -> mfi_dev , " " " \n " ) ; return 0 ; }
Description:
      This function will prepare message pools for the Thunderbolt controller
 Arguments:
      DevExt - HBA miniport driver's adapter data storage structure
      pMemLocation - start of the memory allocated for Thunderbolt.
Description : This function will prepare message pools for the Thunderbolt controller Arguments : DevExt - HBA miniport driver ' s adapter data storage structure pMemLocation - start of the memory allocated for Thunderbolt .
/* Request Descriptor Base physical Address */ /* For Request Decriptors Virtual Memory */ /* Initialise the aligned IO Frames Virtual Memory Pointer */ /* DJA XXX should this be bus dma ??? */ /* Skip request message pool */ /* Reply Frame Pool is initialized */ /* Skip Reply Frame Pool */ /* initializing reply address to 0xFFFFFFFF */ /* initialize the last_reply_idx to 0 */