Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * |
| 20 | * File: control.c |
| 21 | * |
| 22 | * Purpose: Handle USB control endpoint |
| 23 | * |
| 24 | * Author: Jerry Chen |
| 25 | * |
| 26 | * Date: Apr. 5, 2004 |
| 27 | * |
| 28 | * Functions: |
| 29 | * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM |
| 30 | * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM |
| 31 | * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM |
| 32 | * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM |
| 33 | * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set some bits in the same address |
| 34 | * |
| 35 | * Revision History: |
| 36 | * 04-05-2004 Jerry Chen: Initial release |
| 37 | * 11-24-2004 Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte |
| 38 | * |
| 39 | */ |
| 40 | |
| 41 | #if !defined(__CONTROL_H__) |
| 42 | #include "control.h" |
| 43 | #endif |
| 44 | #if !defined(__UMEM_H__) |
| 45 | #include "umem.h" |
| 46 | #endif |
| 47 | #if !defined(__RNDIS_H__) |
| 48 | #include "rndis.h" |
| 49 | #endif |
| 50 | |
| 51 | /*--------------------- Static Definitions -------------------------*/ |
| 52 | //static int msglevel =MSG_LEVEL_INFO; |
| 53 | //static int msglevel =MSG_LEVEL_DEBUG; |
| 54 | /*--------------------- Static Classes ----------------------------*/ |
| 55 | |
| 56 | /*--------------------- Static Variables --------------------------*/ |
| 57 | |
| 58 | /*--------------------- Static Functions --------------------------*/ |
| 59 | |
| 60 | /*--------------------- Export Variables --------------------------*/ |
| 61 | |
| 62 | /*--------------------- Export Functions --------------------------*/ |
| 63 | |
| 64 | |
| 65 | void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byData) |
| 66 | { |
| 67 | BYTE byData1; |
| 68 | |
| 69 | byData1 = byData; |
| 70 | |
| 71 | CONTROLnsRequestOut(pDevice, |
| 72 | MESSAGE_TYPE_WRITE, |
| 73 | byRegOfs, |
| 74 | byRegType, |
| 75 | 1, |
| 76 | &byData1 |
| 77 | ); |
| 78 | |
| 79 | } |
| 80 | |
| 81 | |
| 82 | void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, PBYTE pbyData) |
| 83 | { |
| 84 | NTSTATUS ntStatus; |
| 85 | BYTE byData1; |
| 86 | |
| 87 | |
| 88 | ntStatus = CONTROLnsRequestIn(pDevice, |
| 89 | MESSAGE_TYPE_READ, |
| 90 | byRegOfs, |
| 91 | byRegType, |
| 92 | 1, |
| 93 | &byData1); |
| 94 | |
| 95 | *pbyData = byData1; |
| 96 | |
| 97 | } |
| 98 | |
| 99 | |
| 100 | |
| 101 | void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byMask, BYTE byData) |
| 102 | { |
| 103 | BYTE pbyData[2]; |
| 104 | |
| 105 | pbyData[0] = byData; |
| 106 | pbyData[1] = byMask; |
| 107 | |
| 108 | CONTROLnsRequestOut(pDevice, |
| 109 | MESSAGE_TYPE_WRITE_MASK, |
| 110 | byRegOfs, |
| 111 | byRegType, |
| 112 | 2, |
| 113 | pbyData |
| 114 | ); |
| 115 | |
| 116 | } |