⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hllcputils.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*      @(#)hllcputils.c 1.1 92/07/30 SMI      *//* * Copyright (c) 1988 by Sun Microsystems, Inc. *//* * hllcputils.c - contains routines which should be invarient from application   *		to application. The routines contained in this file are: * *		LLCP_SEND_CMD - macro to send a command to the controller *		llcp_get_pkt - polls for a data packet *		llcp_send_pkt - sends a data packet *		strt_init - initiates llcp initialization  *		send_info - sends host info to controller *		get_info -  sends controller info to host *		llcp_error - gets error string and displays to console *		llcp_reset - decides to call reset_cmd or power_on_rst  *		reset_cmd - attempts to s/w reset the cntrlr board *		pre_err_chk - checks llcp prior to issueing command *		post_err_chk - checks llcp after issueing command *		add_llc_hdr - adds llc snap hdr for ISO compatibility *		strip_llc_hdr - strips llcp snap hdr from packet *		llcp_get_status - gets a copy of the current register status *					 *		initial - PAS - 3/16/88 */#ifdef PROMCODE#include "../h/types.h" #include "../dev/llcp.h"#include "../h/sunromvec.h"#include "../h/globram.h"#include "../h/socket.h"#include <net/if.h>#include <netinet/in.h>#include <netinet/if_ether.h>#include "../dev/if_llc.h"#else PROMCODE#include <sys/types.h>#include <sunif/llcp.h>#include <sys/mbuf.h>#include <sys/uio.h>#include <sys/map.h>#include <sys/socket.h>#include <net/if.h>#include <netinet/in.h>#include <netinet/if_ether.h>#include "../sunif/if_llc.h" #if  defined(STANDALONE)#include <mon/sunromvec.h>#endif#endif PROMCODE#ifdef KERNEL#define UNIXDVR 1#endifextern char *llcp_msgs[];/* * LLCP_SEND_CMD - the order of the operations is critical for the *		handshake.  The command register being written *		to a non-zero value initiates controller action. *		The was changed to a macro to save space for *		cpu host prom. */#define LLCP_SEND_CMD(regp,a,b,c)\regp->len = a;\regp->addr = b;\regp->cmd = c;			/* issue command *//* * llcp_get_pkt - polls for a packet of data for a maximum time as specified *	in the controller info structure. Returns 0 for no packet *	or an error, otherwise returns the length of the packet *	Upon command completion if an error occurs, prints a message *	to the console. */intllcp_get_pkt(llcptr, buf)llcp_info_t *llcptr;char *buf;{	int length = 0;	llcp_reg_t treg;	register llcp_reg_t *regptr = llcptr->regp;	void cmd_wait(), strip_llc_hdr();	/*	 * check for error conditions prior to issueing command	 */#ifndef PROMCODE	if ( pre_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL ) 		return(0);		/* return packet of length 0 */#endif	/* issue llcp command - (length, address, command) */	LLCP_SEND_CMD(regptr, 0L, (u_char *)0, LLCP_GET_PKT);	#ifndef UNIXDVR	cmd_wait(llcptr, LLCP_RDY);	/* wait up to timeout */	/*	 * check for errors on command completion 	 */	if ( post_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL )		return(0);		/* return packet of length 0 */	/*	 * command completed successfully 	 * so transfer data to buffer	 */	llcp_get_status(llcptr, &treg);	/* get register values */	if ( ((length = (int) treg.len) > 0) && (length <= LLCP_BUF_SIZ) ) {  		strip_llc_hdr((char *)llcptr->cinfop->buf, (char*)buf, &length);		return(length);	}#endif	return(0);			/* return packet of length 0 */} /* llcp_get_pkt *//* * llcp_send_pkt - transmits a packet of data. Waits for a maximum time as  *		specified in the controller info structure. Returns LLCP_FAIL  *		for error and LLCP_SUCC otherwise. If an error occurs, prints a  *		msg to the console.  */intllcp_send_pkt(llcptr, buf, length)llcp_info_t *llcptr;char *buf;int length;{	register llcp_reg_t *regptr = llcptr->regp;	void cmd_wait(), add_llc_hdr();	/*	 * check for error conditions prior to issueing command	 */#ifndef PROMCODE	if ( pre_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL ) 		return(LLCP_FAIL);	#endif	/* add iso llc header and adjust len */	add_llc_hdr(buf, (char *)llcptr->cinfop->buf, &length); 		/* issue llcp command - (length, address, command) */	LLCP_SEND_CMD(regptr, length, (u_char *)0, LLCP_SEND_PKT);	#ifndef UNIXDVR	cmd_wait(llcptr, LLCP_RDY);	/* wait up to timeout */	/*	 * check for errors on command completion 	 */	if ( post_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL )		return(LLCP_FAIL);#endif	return(LLCP_SUCC);		/* command completed successfully */} /* llcp_send_pkt *//* * strt_init -  Initiates llcp initialization *		Returns either LLCP_SUCC or LLCP_FAIL. */strt_init(llcptr)llcp_info_t *llcptr;{	llcp_reg_t treg;	register llcp_reg_t *regptr = llcptr->regp;	llcp_cntrlr_info_t *cinfoptr = llcptr->cinfop;	void cmd_wait();#ifndef PROMCODE	if ( pre_err_chk(llcptr, LLCP_INIT1) == LLCP_FAIL ) 		return(LLCP_FAIL);#endif	/* issue llcp command - (length, address, command) */	LLCP_SEND_CMD(regptr, 0L, 		((cinfoptr->memtyp == DMA_MEM)? cinfoptr->buf: (u_char *)0),								LLCP_STRT_INIT);#ifndef UNIXDVR	cmd_wait(llcptr, LLCP_INIT2);						/* wait up to timeout */	if ( post_err_chk(llcptr, LLCP_INIT2) == LLCP_FAIL ) 		return(LLCP_FAIL);	/*	 * save address of shared memory buffer and check if host	 * has dma interface and controller expects shared mem or 	 * vice versa.	 */	llcp_get_status(llcptr, &treg);		/* get register values*/	if ( cinfoptr->memtyp == SHARED_MEM ) {	/* host has shared mem int*/		if ( treg.addr == (u_char *)0 ) { 			printf(llcp_msgs[E_LLCP_DMA]);			return(LLCP_FAIL);		}		else 				/* save address of shared mem */			cinfoptr->phys_addr = treg.addr;	} else {										/* host has dma interface */		if ( treg.addr != (u_char *)0 ) {			printf(llcp_msgs[E_LLCP_DMA]);			return(LLCP_FAIL);		}	}#endif	return(LLCP_SUCC);} /* strt_init *//* * get_info -  sends controller info to host *		Returns either LLCP_SUCC or LLCP_FAIL. */get_info(llcptr)llcp_info_t *llcptr;{	llcp_reg_t treg;	register llcp_reg_t *regptr = llcptr->regp;	void cmd_wait();#ifndef PROMCODE	if ( pre_err_chk(llcptr, LLCP_INIT2) == LLCP_FAIL ) 		return(LLCP_FAIL);#endif	/* issue llcp command - (length, address, command) */	LLCP_SEND_CMD(regptr, 0L, (u_char *)0, LLCP_GET_INFO);	#ifndef UNIXDVR	cmd_wait(llcptr, LLCP_INIT3);		/* wait up to timeout */	if ( post_err_chk(llcptr, LLCP_INIT3) == LLCP_FAIL ) 		return(LLCP_FAIL);	llcp_get_status(llcptr, &treg);		/* get register values */	/* transfer controller information structure */	if ( stuff_cinfo(llcptr, (int)treg.len) == LLCP_FAIL )		return(LLCP_FAIL);#ifdef DEBUG	/*	 * print out entire Cinfo struct	 */	printf("---------------- CINFO STRUCTURE -------------------------\n");	printf("len = %d",llcptr->cinfop->len);	printf("				llcp_ver = %d\n",llcptr->cinfop->llcp_ver);	printf("addrtyp = %x",llcptr->cinfop->addrtyp);	printf("				net_laddr = %s\n",llcptr->cinfop->net_laddr);	printf("buf = 0x%x",llcptr->cinfop->buf);	printf("				memtyp = %x\n",llcptr->cinfop->memtyp);	printf("max_pkt = %d",llcptr->cinfop->max_pkt);	printf("				timeout = %d\n",llcptr->cinfop->timeout);	printf("----------------------------------------------------------\n");#endif DEBUG#endif	return(LLCP_SUCC);} /* get_info *//* * send_info -  sends host info to controller *		Returns either LLCP_SUCC or LLCP_FAIL. */send_info(llcptr)llcp_info_t *llcptr;{	register llcp_reg_t *regptr = llcptr->regp;	void cmd_wait();#ifndef PROMCODE	if ( pre_err_chk(llcptr, LLCP_INIT3) == LLCP_FAIL ) 		return(LLCP_FAIL);#endif	/*	 * set length of structure and send second half of init command	 */	bcopy((char *)llcptr->hinfop, (char *)llcptr->cinfop->buf, 						sizeof(llcp_host_info_t));	/* issue llcp command - (length, address, command) */	LLCP_SEND_CMD(regptr, (long) sizeof(llcp_host_info_t), (u_char *)0, 							LLCP_SEND_INFO);#ifndef UNIXDVR	cmd_wait(llcptr, LLCP_RDY);		/* wait up to timeout */	if ( post_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL )		return(LLCP_FAIL);		#endif	return(LLCP_SUCC);} /* send_info *//* * ena_net -  sends the enable network command *		This command is always sent after the init sequence, and *		is not optional. *		Returns either LLCP_SUCC or LLCP_FAIL. */ena_net(llcptr)llcp_info_t *llcptr;{	register llcp_reg_t *regptr = llcptr->regp;	void cmd_wait();#ifndef PROMCODE	if ( pre_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL ) 			return(LLCP_FAIL);#endif	/* issue llcp command - (length, address, command) */	LLCP_SEND_CMD(regptr, 0L, (u_char *)0, LLCP_ENA_NET);	#ifndef UNIXDVR	cmd_wait(llcptr, LLCP_RDY);		/* wait up to timeout */	if ( post_err_chk(llcptr, LLCP_RDY) == LLCP_FAIL ) 		return(LLCP_FAIL);#endif	return(LLCP_SUCC);} /* ena_net */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -