From owner-freebsd-current@FreeBSD.ORG Fri Dec 30 08:43:17 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE8B516A41F for ; Fri, 30 Dec 2005 08:43:17 +0000 (GMT) (envelope-from akbeech@gmail.com) Received: from msgmmp-1.gci.net (msgmmp-1.gci.net [209.165.130.11]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6309B43D5D for ; Fri, 30 Dec 2005 08:43:17 +0000 (GMT) (envelope-from akbeech@gmail.com) Received: from stargate.akparadise.com ([209.124.141.64]) by msgmmp-1.gci.net (Sun Java System Messaging Server 6.2-3.03 (built Jun 27 2005)) with ESMTPA id <0ISA00GHVYW1Y2E0@msgmmp-1.gci.net> for freebsd-current@freebsd.org; Thu, 29 Dec 2005 23:43:15 -0900 (AKST) Received: by stargate.akparadise.com (Postfix, from userid 0) id 74F993F98; Thu, 29 Dec 2005 23:43:13 -0900 (AKST) Date: Thu, 29 Dec 2005 23:43:10 -0900 From: Beech Rintoul To: freebsd-current@freebsd.org Message-id: <200512292343.11523.akbeech@gmail.com> Organization: NorthWind Communications MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_DLu7yAyuIwGROlqmeVS24Q)" User-Agent: KMail/1.8.3 Subject: Help compiling a C utility X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2005 08:43:18 -0000 --Boundary_(ID_DLu7yAyuIwGROlqmeVS24Q) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline I'm trying to compile a utility to fix one of my wireless cards. I got this off a freebsd list and it's supposed to work with 6.0, but I can't get it to compile. I get the following error: stargate# gcc ar5k.c -o ar5k ar5k.c: In function `main': ar5k.c:236: error: syntax error before "t" ar5k.c:236:47: invalid suffix "x" on integer constant ar5k.c:236:50: invalid suffix "X" on integer constant ar5k.c:236:57: invalid suffix "x" on integer constant ar5k.c:236:60: invalid suffix "X" on integer constant ar5k.c:236: error: stray '\' in program ar5k.c:236: error: missing terminating " character I copied this off the message to a text editor (kate). Would someone take a look and see if it's something simple. Beech -- --------------------------------------------------------------------------------------- Beech Rintoul - System Administrator - akbeech@gmail.com /"\ ASCII Ribbon Campaign | NorthWind Communications \ / - NO HTML/RTF in e-mail | 201 East 9th Avenue Ste.310 X - NO Word docs in e-mail | Anchorage, AK 99501 / \ - Please visit Alaska Paradise - http://akparadise.byethost33.com --------------------------------------------------------------------------------------- --Boundary_(ID_DLu7yAyuIwGROlqmeVS24Q) Content-type: text/plain; charset=us-ascii; name=ar5k.c.txt Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=ar5k.c.txt /* * This program is derived from code bearing the following Copyright(s) */ /* -*- linux-c -*- * _ _ ____ __ _ ___ ____ ____ __ _ _ _ _ | * . \/ |--| | \| | |--< [__] | \| | _X_ | s e c u r e s y s t e m s * * .vt|ar5k - PCI/CardBus 802.11a WirelessLAN driver for Atheros AR5k chipsets * * Copyright (c) 2002, .vantronix | secure systems * and Reyk Floeter * * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation ; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY ; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #define AR5K_PCICFG 0x4010 #define AR5K_PCICFG_EEAE 0x00000001 #define AR5K_PCICFG_CLKRUNEN 0x00000004 #define AR5K_PCICFG_LED_PEND 0x00000020 #define AR5K_PCICFG_LED_ACT 0x00000040 #define AR5K_PCICFG_SL_INTEN 0x00000800 #define AR5K_PCICFG_BCTL 0x00001000 #define AR5K_PCICFG_SPWR_DN 0x00010000 /* EEPROM Registers in the MAC */ #define AR5211_EEPROM_ADDR 0x6000 #define AR5211_EEPROM_DATA 0x6004 #define AR5211_EEPROM_COMD 0x6008 #define AR5211_EEPROM_COMD_READ 0x0001 #define AR5211_EEPROM_COMD_WRITE 0x0002 #define AR5211_EEPROM_COMD_RESET 0x0003 #define AR5211_EEPROM_STATUS 0x600C #define AR5211_EEPROM_STAT_RDERR 0x0001 #define AR5211_EEPROM_STAT_RDDONE 0x0002 #define AR5211_EEPROM_STAT_WRERR 0x0003 #define AR5211_EEPROM_STAT_WRDONE 0x0004 #define AR5211_EEPROM_CONF 0x6010 #define VT_WLAN_IN32(a) (*((volatile unsigned long int *)(mem + (a)))) #define VT_WLAN_OUT32(v,a) (*((volatile unsigned long int *)(mem + (a))) = (v)) int vt_ar5211_eeprom_read( unsigned char *mem, unsigned long int offset, unsigned short int *data ) { int timeout = 10000 ; unsigned long int status ; VT_WLAN_OUT32( 0, AR5211_EEPROM_CONF ), usleep( 5 ) ; /** enable eeprom read access */ VT_WLAN_OUT32( VT_WLAN_IN32(AR5211_EEPROM_COMD) | AR5211_EEPROM_COMD_RESET, AR5211_EEPROM_COMD) ; usleep( 5 ) ; /** set address */ VT_WLAN_OUT32( (unsigned char) offset, AR5211_EEPROM_ADDR) ; usleep( 5 ) ; VT_WLAN_OUT32( VT_WLAN_IN32(AR5211_EEPROM_COMD) | AR5211_EEPROM_COMD_READ, AR5211_EEPROM_COMD) ; while (timeout > 0) { usleep(1) ; status = VT_WLAN_IN32(AR5211_EEPROM_STATUS) ; if (status & AR5211_EEPROM_STAT_RDDONE) { if (status & AR5211_EEPROM_STAT_RDERR) { (void) fputs( "eeprom read access failed!\n", stderr ) ; return 1 ; } status = VT_WLAN_IN32(AR5211_EEPROM_DATA) ; *data = status & 0x0000ffff ; return 0 ; } timeout-- ; } (void) fputs( "eeprom read timeout!\n", stderr ) ; return 1 ; } int vt_ar5211_eeprom_write( unsigned char *mem, unsigned int offset, unsigned short int new_data ) { int timeout = 10000 ; unsigned long int status ; unsigned long int pcicfg ; int i ; unsigned short int sdata ; /** enable eeprom access */ pcicfg = VT_WLAN_IN32( AR5K_PCICFG ) ; VT_WLAN_OUT32( ( pcicfg & ~AR5K_PCICFG_SPWR_DN ), AR5K_PCICFG ) ; usleep( 500 ) ; VT_WLAN_OUT32( pcicfg | AR5K_PCICFG_EEAE /* | 0x2 */, AR5K_PCICFG) ; usleep( 50 ) ; VT_WLAN_OUT32( 0, AR5211_EEPROM_STATUS ); usleep( 50 ) ; /* VT_WLAN_OUT32( 0x1, AR5211_EEPROM_CONF ) ; */ VT_WLAN_OUT32( 0x0, AR5211_EEPROM_CONF ) ; usleep( 50 ) ; i = 100 ; retry: /** enable eeprom write access */ VT_WLAN_OUT32( AR5211_EEPROM_COMD_RESET, AR5211_EEPROM_COMD); usleep( 500 ) ; /* Write data */ VT_WLAN_OUT32( new_data, AR5211_EEPROM_DATA ); usleep( 5 ) ; /** set address */ VT_WLAN_OUT32( offset, AR5211_EEPROM_ADDR); usleep( 5 ) ; VT_WLAN_OUT32( AR5211_EEPROM_COMD_WRITE, AR5211_EEPROM_COMD); usleep( 5 ) ; for ( timeout = 10000 ; timeout > 0 ; --timeout ) { status = VT_WLAN_IN32( AR5211_EEPROM_STATUS ); if ( status & 0xC ) { if ( status & AR5211_EEPROM_STAT_WRERR ) { fprintf( stderr, "eeprom write access failed!\n"); return 1 ; } VT_WLAN_OUT32( 0, AR5211_EEPROM_STATUS ); usleep( 10 ) ; break ; } usleep( 10 ) ; timeout--; } (void) vt_ar5211_eeprom_read( mem, offset, &sdata ) ; if ( ( sdata != new_data ) && i ) { --i ; fprintf( stderr, "Retrying eeprom write!\n"); goto retry ; } return !i ; } static void Usage( char *progname ) { (void) fprintf( stderr, "Usage: %s physical_address_base new_country_code\n", progname ) ; return ; } int main( int argc, char **argv ) { unsigned long int base_addr ; int fd ; void *membase ; unsigned short int sdata ; unsigned short int new_cc ; if ( argc < 3 ) { Usage( argv[0] ) ; return -1 ; } base_addr = strtoul( argv[2], NULL, 0 ) ; if ( base_addr > 0xFFFF ) { (void) fputs( "Error: New domain code must be 16 bits or less\n", stderr ) ; Usage( argv[0] ) ; return -2 ; } new_cc = (unsigned short int) base_addr ; base_addr = strtoul( argv[1], NULL, 0 ) ; #define ATHEROS_PCI_MEM_SIZE 0x10000 fd = open( "/dev/mem", O_RDWR ) ; if ( fd < 0 ) { fprintf( stderr, "Open of /dev/mem failed!\n" ) ; return -2 ; } membase = mmap( 0, ATHEROS_PCI_MEM_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FILE, fd, base_addr ) ; if ( membase == (void *) -1 ) { fprintf( stderr, "Mmap of device at 0x%08X for 0x%X bytes failed!\n", base_addr, ATHEROS_PCI_MEM_SIZE ) ; return -3 ; } #if 0 (void) vt_ar5211_eeprom_write( (unsigned char *) membase, AR5K_EEPROM_PROTECT_OFFSET, 0 ) ; #endif /* #if 0 */ if ( vt_ar5211_eeprom_read( (unsigned char *) membase, 0xBF, &sdata ) ) fprintf( stderr, "EEPROM read failed\n" ) ; printf( "Current value 0x%04X will change to 0x%04X\n", sdata, new_cc ) ; if ( vt_ar5211_eeprom_write( (unsigned char *) membase, 0xBF, new_cc ) ) fprintf( stderr, "EEPROM write failed\n" ) ; if ( vt_ar5211_eeprom_read( (unsigned char *) membase, 0xBF, &sdata ) ) fprintf( stderr, "EEPROM read failed\n" ) ; if ( sdata != new_cc ) fprintf( stderr, "Write & read don"t match 0x%04X != 0x%04X\n", new_cc, sdata ) ; return 0 ; } --Boundary_(ID_DLu7yAyuIwGROlqmeVS24Q)--