FreeBSD/sys/dev/ntb/ntb_hw/ntb_hw.c
/*
 * ntb_mw_get_range() - get the range of a memory window
 * @ntb:        NTB device context
 * @idx:        Memory window number
 * @base:       OUT - the base address for mapping the memory window
 * @size:       OUT - the size for mapping the memory window
 * @align:      OUT - the base alignment for translating the memory window
 * @align_size: OUT - the size alignment for translating the memory window
 *
 * Get the range of a memory window.  NULL may be given for any output
 * parameter if the value is not needed.  The base and size may be used for
 * mapping the memory window, to access the peer memory.  The alignment and
 * size may be used for translating the memory window, for the peer to access
 * memory on the local system.
 *
 * Return: Zero on success, otherwise an error number.
 */


Get the range of a memory window.  NULL may be given for any output
parameter if the value is not needed.  The base and size may be used for
mapping the memory window, to access the peer memory.  The alignment and
size may be used for translating the memory window, for the peer to access
memory on the local system.

Zero on success, otherwise an error number.
Get the range of a memory window . NULL may be given for any output parameter if the value is not needed . The base and size may be used for mapping the memory window to access the peer memory . The alignment and size may be used for translating the memory window for the peer to access memory on the local system . Zero on success otherwise an error number .
int
ntb_mw_get_range(struct ntb_softc *ntb, unsigned mw_idx, vm_paddr_t *base,
    caddr_t *vbase, size_t *size, size_t *align, size_t *align_size,
    bus_addr_t *plimit)
{
	struct ntb_pci_bar_info *bar;
	bus_addr_t limit;
	size_t bar_b2b_off;
	enum ntb_bar bar_num;
	if (mw_idx >= ntb_mw_count(ntb))
		return (EINVAL);
	mw_idx = ntb_user_mw_to_idx(ntb, mw_idx);
	bar_num = ntb_mw_to_bar(ntb, mw_idx);
	bar = &ntb->bar_info[bar_num];
	bar_b2b_off = 0;
	if (mw_idx == ntb->b2b_mw_idx) {
		KASSERT(ntb->b2b_off != 0,
		    ("user shouldn't get non-shared b2b mw"));
		bar_b2b_off = ntb->b2b_off;
	}
	if (bar_is_64bit(ntb, bar_num))
		limit = BUS_SPACE_MAXADDR;
	else
		limit = BUS_SPACE_MAXADDR_32BIT;
	if (base != NULL)
		*base = bar->pbase + bar_b2b_off;
	if (vbase != NULL)
		*vbase = bar->vbase + bar_b2b_off;
	if (size != NULL)
		*size = bar->size - bar_b2b_off;
	if (align != NULL)
		*align = bar->size;
	if (align_size != NULL)
		*align_size = 1;
	if (plimit != NULL)
		*plimit = limit;
	return (0);
}
int ntb_mw_get_range ( struct ntb_softc * ntb , unsigned mw_idx , vm_paddr_t * base , caddr_t * vbase , size_t * size , size_t * align , size_t * align_size , bus_addr_t * plimit ) { struct ntb_pci_bar_info * bar ; bus_addr_t limit ; size_t bar_b2b_off ; enum ntb_bar bar_num ; if ( mw_idx >= ntb_mw_count ( ntb ) ) return ( EINVAL ) ; mw_idx = ntb_user_mw_to_idx ( ntb , mw_idx ) ; bar_num = ntb_mw_to_bar ( ntb , mw_idx ) ; bar = & ntb -> bar_info [ bar_num ] ; bar_b2b_off = 0 ; if ( mw_idx == ntb -> b2b_mw_idx ) { KASSERT ( ntb -> b2b_off != 0 , ( " " ) ) ; bar_b2b_off = ntb -> b2b_off ; } if ( bar_is_64bit ( ntb , bar_num ) ) limit = BUS_SPACE_MAXADDR ; else limit = BUS_SPACE_MAXADDR_32BIT ; if ( base != NULL ) * base = bar -> pbase + bar_b2b_off ; if ( vbase != NULL ) * vbase = bar -> vbase + bar_b2b_off ; if ( size != NULL ) * size = bar -> size - bar_b2b_off ; if ( align != NULL ) * align = bar -> size ; if ( align_size != NULL ) * align_size = 1 ; if ( plimit != NULL ) * plimit = limit ; return ( 0 ) ; }
ntb_mw_get_range() - get the range of a memory window
 @ntb:        NTB device context
 @idx:        Memory window number
 @base:       OUT - the base address for mapping the memory window
 @size:       OUT - the size for mapping the memory window
 @align:      OUT - the base alignment for translating the memory window
 @align_size: OUT - the size alignment for translating the memory window
ntb_mw_get_range () - get the range of a memory window @ntb : NTB device context @idx : Memory window number @base : OUT - the base address for mapping the memory window @size : OUT - the size for mapping the memory window @align : OUT - the base alignment for translating the memory window @align_size : OUT - the size alignment for translating the memory window