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 |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 33 | * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set |
| 34 | * some bits in the same address |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 35 | * |
| 36 | * Revision History: |
| 37 | * 04-05-2004 Jerry Chen: Initial release |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 38 | * 11-24-2004 Warren Hsu: Add ControlvWriteByte, ControlvReadByte, |
| 39 | * ControlvMaskByte |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 40 | * |
| 41 | */ |
| 42 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #include "control.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 44 | #include "rndis.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 45 | |
| 46 | /*--------------------- Static Definitions -------------------------*/ |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 47 | /* static int msglevel =MSG_LEVEL_INFO; */ |
| 48 | /* static int msglevel =MSG_LEVEL_DEBUG; */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 49 | /*--------------------- Static Classes ----------------------------*/ |
| 50 | |
| 51 | /*--------------------- Static Variables --------------------------*/ |
| 52 | |
| 53 | /*--------------------- Static Functions --------------------------*/ |
| 54 | |
| 55 | /*--------------------- Export Variables --------------------------*/ |
| 56 | |
| 57 | /*--------------------- Export Functions --------------------------*/ |
| 58 | |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 59 | void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, |
| 60 | BYTE byData) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 61 | { |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 62 | BYTE byData1; |
| 63 | byData1 = byData; |
| 64 | CONTROLnsRequestOut(pDevice, |
| 65 | MESSAGE_TYPE_WRITE, |
| 66 | byRegOfs, |
| 67 | byRegType, |
| 68 | 1, |
| 69 | &byData1); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 70 | } |
| 71 | |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 72 | void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, |
| 73 | PBYTE pbyData) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 74 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 75 | int ntStatus; |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 76 | BYTE byData1; |
| 77 | ntStatus = CONTROLnsRequestIn(pDevice, |
| 78 | MESSAGE_TYPE_READ, |
| 79 | byRegOfs, |
| 80 | byRegType, |
| 81 | 1, |
| 82 | &byData1); |
| 83 | *pbyData = byData1; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 84 | } |
| 85 | |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 86 | void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, |
| 87 | BYTE byMask, BYTE byData) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 88 | { |
Daniel Kenji Toyama | f9ea02a | 2010-03-29 22:40:54 +1100 | [diff] [blame] | 89 | BYTE pbyData[2]; |
| 90 | pbyData[0] = byData; |
| 91 | pbyData[1] = byMask; |
| 92 | CONTROLnsRequestOut(pDevice, |
| 93 | MESSAGE_TYPE_WRITE_MASK, |
| 94 | byRegOfs, |
| 95 | byRegType, |
| 96 | 2, |
| 97 | pbyData); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 98 | } |