Ejemplo n.º 1
0
/*
 * Free Buffer Supply Queue Data Structures
 *
 * Arguments:
 *	fup		pointer to device unit structure
 *
 * Returns:
 *	none
 */
void
fore_buf_free(Fore_unit *fup)
{
	Buf_handle	*bhp;
	KBuffer		*m;

	/*
	 * Free any previously supplied and not returned buffers
	 */
	if (fup->fu_flags & CUF_INITED) {

		/*
		 * Run through Strategy 1 Small queue
		 */
		while ((bhp = Q_HEAD(fup->fu_buf1s_bq, Buf_handle)) != NULL) {
			caddr_t		cp;

			/*
			 * Back off to buffer
			 */
			m = (KBuffer *)((caddr_t)bhp - BUF1_SM_HOFF);

			/*
			 * Dequeue handle and free buffer
			 */
			DEQUEUE(bhp, Buf_handle, bh_qelem, fup->fu_buf1s_bq);

			KB_DATASTART(m, cp, caddr_t);
			DMA_FREE_ADDR(cp, bhp->bh_dma, BUF1_SM_SIZE, 0);

			KB_FREEALL(m);
		}

		/*
		 * Run through Strategy 1 Large queue
		 */
		while ((bhp = Q_HEAD(fup->fu_buf1l_bq, Buf_handle)) != NULL) {
			caddr_t		cp;

			/*
			 * Back off to buffer
			 */
			m = (KBuffer *)((caddr_t)bhp - BUF1_LG_HOFF);

			/*
			 * Dequeue handle and free buffer
			 */
			DEQUEUE(bhp, Buf_handle, bh_qelem, fup->fu_buf1l_bq);

			KB_DATASTART(m, cp, caddr_t);
			DMA_FREE_ADDR(cp, bhp->bh_dma, BUF1_LG_SIZE, 0);

			KB_FREEALL(m);
		}
	}

	/*
	 * Free the status words
	 */
	if (fup->fu_buf1s_stat) {
		if (fup->fu_buf1s_statd) {
			DMA_FREE_ADDR(fup->fu_buf1s_stat, fup->fu_buf1s_statd,
				sizeof(Q_status) *
					(BUF1_SM_QUELEN + BUF1_LG_QUELEN),
				ATM_DEV_NONCACHE);
		}
		atm_dev_free((volatile void *)fup->fu_buf1s_stat);
		fup->fu_buf1s_stat = NULL;
		fup->fu_buf1s_statd = NULL;
		fup->fu_buf1l_stat = NULL;
		fup->fu_buf1l_statd = NULL;
	}

	/*
	 * Free the transmit descriptors
	 */
	if (fup->fu_buf1s_desc) {
		if (fup->fu_buf1s_descd) {
			DMA_FREE_ADDR(fup->fu_buf1s_desc, fup->fu_buf1s_descd,
				sizeof(Buf_descr) *
					((BUF1_SM_QUELEN * BUF1_SM_ENTSIZE) +
					 (BUF1_LG_QUELEN * BUF1_LG_ENTSIZE)),
				0);
		}
		atm_dev_free(fup->fu_buf1s_desc);
		fup->fu_buf1s_desc = NULL;
		fup->fu_buf1s_descd = NULL;
		fup->fu_buf1l_desc = NULL;
		fup->fu_buf1l_descd = NULL;
	}

	return;
}
Ejemplo n.º 2
0
/*
 * Halt driver processing 
 * 
 * This will be called just prior to unloading the module from memory.
 * Everything we've setup since we've been loaded must be undone here.
 *
 * Arguments:
 *	none
 *
 * Returns:
 *	0 	shutdown was successful 
 *	errno	shutdown failed - reason indicated
 *
 */
static int
fore_stop()
{
	int	err = 0;
	int	s = splimp();
	int	i;

	/*
	 * Stop the watchdog timer
	 */
	(void) atm_untimeout(&fore_timer);

	/*
	 * Clean up each device (if any)
	 */
	for ( i = 0; i < fore_nunits; i++ ) {
		Fore_unit	*fup = fore_units[i];

		if (fup == NULL)
			continue;

		/*
		 * Deregister device from kernel services
		 */
		if (err = atm_physif_deregister((Cmn_unit *)fup)) {
			(void) splx(s);
			return (err);
		}

		/*
		 * Unattach the device from the system
		 */
		fore_unattach(fup);

		/*
		 * Free any Fore-specific device resources
		 */
		fore_interface_free(fup);

		/*
		 * Free the unit structure
		 */
		atm_dev_free(fup);
		fore_units[i] = NULL;
	}

	fore_nunits = 0;

	/*
	 * Now free our global resources
	 */

	/*
	 * Release our storage pools
	 */
	atm_release_pool(&fore_vcc_pool);
	atm_release_pool(&fore_nif_pool);

	/*
	 * Release all DMA mappings
	 */
	DMA_RELEASE();

	fore_inited = 0;

	(void) splx(s);

	return (0);
}