📄 devctl.c
字号:
/* * $QNXLicenseC: * Copyright 2007, QNX Software Systems. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not reproduce, modify or distribute this software except in * compliance with the License. You may obtain a copy of the License * at: http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OF ANY KIND, either express or implied. * * This file may contain contributions from others, either as * contributors under the License or as licensors under other terms. * Please review this entire file for other proprietary rights or license * notices, as well as the QNX Development Suite License Guide at * http://licensing.qnx.com/license-guide/ for other information. * $ */#include <crys8900.h>int cs8900_devctl( void *hdl, int dcmd, void *data, size_t size, union _io_net_dcmd_ret_cred *ret ){ cs8900_dev_t *cs8900 = (cs8900_dev_t *)hdl; int status; int linectl, rxctl; uint32_t iobase; status = EOK; iobase = cs8900->iobase; switch( dcmd ) { case DCMD_IO_NET_TX_FLUSH: pthread_mutex_lock( &cs8900->mutex ); cs8900_transmit_complete ( cs8900 ); pthread_mutex_unlock( &cs8900->mutex ); break; case DCMD_IO_NET_GET_STATS: memcpy(data, &cs8900->stats, sizeof (cs8900->stats)); break; case DCMD_IO_NET_GET_CONFIG: memcpy(data, &cs8900->cfg, sizeof (cs8900->cfg)); status = EOK; break; case DCMD_IO_NET_PROMISCUOUS: pthread_mutex_lock( &cs8900->mutex ); /* Disable the receiver */ linectl = cs8900_rpktpage( iobase, CS8900_LINECTL ); linectl &= ~LINECTL_RXON; cs8900_wpktpage( iobase, CS8900_LINECTL, linectl ); /* Get the current RX Control Values */ rxctl = cs8900_rpktpage( iobase, CS8900_RXCTL ); if( *(int *)data ) { cs8900->cfg.flags |= NIC_FLAG_PROMISCUOUS; rxctl |= RXCTL_PROM_OK; } else { cs8900->cfg.flags &= ~NIC_FLAG_PROMISCUOUS; rxctl &= ~RXCTL_PROM_OK; } /* Set the new RX Control Values */ cs8900_wpktpage( iobase, CS8900_RXCTL, rxctl ); /* Re-enable the receiver */ linectl |= LINECTL_RXON; cs8900_wpktpage( iobase, CS8900_LINECTL, linectl ); pthread_mutex_unlock( &cs8900->mutex ); break; case DCMD_IO_NET_CHANGE_MCAST: if (cs8900->cfg.flags & NIC_FLAG_MULTICAST) { status = cs8900_do_multicast (cs8900, (io_net_msg_join_mcast_t *) data, NULL); } else { if ( cs8900->cfg.verbose > 3 ) nic_slogf (_SLOGC_NETWORK, _SLOG_ERROR, "devn-cs8900: devctl() MCAST ENOTSUP"); status = ENOTSUP; } break; default: status = ENOTSUP; break; } return( status );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -