version 1.1.2.2, 2010/10/23 01:50:49
|
version 1.1.2.3, 2010/10/25 12:56:27
|
Line 19 Usage()
|
Line 19 Usage()
|
{ |
{ |
printf( "athCtl is tool for Atheros WiFi cards managment \n" |
printf( "athCtl is tool for Atheros WiFi cards managment \n" |
"=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
" Syntax: athctl [options] [exec_file]\n\n" | " Syntax: athctl [options] [0xMemory_Address]\n" |
| " athctl [-v] -t [-i <iface_no>]\n" |
| " athctl [-v] -c <timeout> [-i <iface_no>]\n" |
| " athctl [-v] -d <distance> [-i <iface_no>]\n" |
| " athctl [-v] -r <0xoffset> <0xMemory_Address>\n" |
| " athctl [-v] -w <0xoffset> <0xMemory_Address>\n" |
| " athctl [-v] -s <file> <0xMemory_Address>\n" |
| " athctl [-v] -w <file> <0xMemory_Address>\n" |
| "\n" |
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\n" |
"\t-t\t\tGet current Atheros maximum range in meters\n" |
"\t-t\t\tGet current Atheros maximum range in meters\n" |
"\t-i <iface_no>\tApply to this Atheros interface number (like ath0 == 0)\n" |
"\t-i <iface_no>\tApply to this Atheros interface number (like ath0 == 0)\n" |
"\t-d <distance>\tMode distance, meters to target\n" |
"\t-d <distance>\tMode distance, meters to target\n" |
"\t-c <timeout>\tMode distance, mS timeouts correction\n" |
"\t-c <timeout>\tMode distance, mS timeouts correction\n" |
|
"\t-s <file>\tDump EEPROM to file\n" |
|
"\t-u <file>\tUpdate EEPROM from file\n" |
|
"\t-r <offset>\tRead EEPROM word from PCI mapped memory address\n" |
|
"\t-w <offset>\tWrite EEPROM word to PCI mapped memory address\n" |
"\n", compiled, compiledby, compilehost); |
"\n", compiled, compiledby, compilehost); |
} |
} |
|
|
Line 127 calcTimeout(int ifid, int cor)
|
Line 139 calcTimeout(int ifid, int cor)
|
|
|
return timeout[0]; |
return timeout[0]; |
} |
} |
|
|
|
|
|
static inline void * |
|
devOpen(u_long baseaddr) |
|
{ |
|
int fd; |
|
void *basemem; |
|
|
|
fd = open("/dev/mem", O_RDWR); |
|
if (fd == -1) { |
|
printf("Error:: open device #%d - %s\n", errno, strerror(errno)); |
|
return NULL; |
|
} |
|
basemem = mmap(NULL, ATH_PCI_MEM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, baseaddr); |
|
if (basemem == MAP_FAILED) { |
|
printf("Error:: map device #%d - %s\n", errno, strerror(errno)); |
|
close(fd); |
|
return NULL; |
|
} else |
|
close(fd); |
|
|
|
return basemem; |
|
} |
|
|
|
static inline void |
|
devClose(void *basemem) |
|
{ |
|
if (basemem) |
|
munmap(basemem, ATH_PCI_MEM_SIZE); |
|
} |
|
|
|
/* |
|
static int |
|
readEEPROM() |
|
{ |
|
register u_long i; |
|
|
|
printf("Reading EEPROM ...\n"); |
|
for (i = 0; i < ATH_EEPROM_SIZE / 2; i++) { |
|
} |
|
} |
|
*/ |
|
|
// ---------------------------------------------------- |
// ---------------------------------------------------- |
|
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char ch, mode = 0; | char ch, szName[MAXPATHLEN] = { 0 }, mode = 0; |
int ret = 0, dist = 0, cor = 0, ino = 0; |
int ret = 0, dist = 0, cor = 0, ino = 0; |
|
u_long offset, baseaddr = (u_long) -1; |
|
void *basemem = NULL; |
|
|
while ((ch = getopt(argc, argv, "hvti:d:c:")) != -1) | while ((ch = getopt(argc, argv, "hvtr:w:i:d:c:u:s:")) != -1) |
switch (ch) { |
switch (ch) { |
case 'v': |
case 'v': |
Verbose++; |
Verbose++; |
Line 162 main(int argc, char **argv)
|
Line 219 main(int argc, char **argv)
|
mode |= 1; |
mode |= 1; |
cor = strtol(optarg, NULL, 0); |
cor = strtol(optarg, NULL, 0); |
break; |
break; |
|
case 's': |
|
mode = 0x10; |
|
strlcpy(szName, optarg, MAXPATHLEN); |
|
break; |
|
case 'u': |
|
mode = 0x20; |
|
strlcpy(szName, optarg, MAXPATHLEN); |
|
break; |
|
case 'r': |
|
mode = 4; |
|
offset = strtoul(optarg, NULL, 0); |
|
break; |
|
case 'w': |
|
mode = 8; |
|
offset = strtoul(optarg, NULL, 0); |
|
break; |
case 'h': |
case 'h': |
default: |
default: |
Usage(); |
Usage(); |
Line 169 main(int argc, char **argv)
|
Line 242 main(int argc, char **argv)
|
} |
} |
argc -= optind; |
argc -= optind; |
argv += optind; |
argv += optind; |
|
if (argc && *argv) |
|
baseaddr = strtoul(*argv, NULL, 0); |
if (!mode) { |
if (!mode) { |
printf("Error:: not selected mode for operation ...\n"); |
printf("Error:: not selected mode for operation ...\n"); |
return 1; |
return 1; |
} |
} |
|
if (mode > 3 && baseaddr == (u_long) -1) { |
|
printf("Error:: in this mode for operation, must give memory mapped address ...\n"); |
|
return 1; |
|
} |
|
|
if (mode & 1) |
if (mode & 1) |
if ((ret = calcDistance(ino, dist, cor)) < 1) |
if ((ret = calcDistance(ino, dist, cor)) < 1) |
Line 186 main(int argc, char **argv)
|
Line 265 main(int argc, char **argv)
|
else |
else |
printf("~%d\n", ret); |
printf("~%d\n", ret); |
} |
} |
|
} |
|
|
|
if (mode & 4) { |
|
if (!(basemem = devOpen(baseaddr))) |
|
return 2; |
|
// if ((ret = readWord(basemem)) < 1) |
|
// return 3; |
|
devClose(basemem); |
} |
} |
|
|
return 0; |
return 0; |