Changeset View
Changeset View
Standalone View
Standalone View
head/tools/tools/ath/athrd/athrd.c
Show All 26 Lines | |||||
* THE POSSIBILITY OF SUCH DAMAGES. | * THE POSSIBILITY OF SUCH DAMAGES. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include "opt_ah.h" | #include "opt_ah.h" | ||||
#include "ah.h" | #include "ah.h" | ||||
#include <sys/param.h> | |||||
#include <net80211/_ieee80211.h> | #include <net80211/_ieee80211.h> | ||||
#include <net80211/ieee80211_regdomain.h> | #include <net80211/ieee80211_regdomain.h> | ||||
#include "ah_internal.h" | #include "ah_internal.h" | ||||
#include "ah_eeprom_v3.h" /* XXX */ | #include "ah_eeprom_v3.h" /* XXX */ | ||||
#include <ctype.h> | |||||
#include <stdarg.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <stdarg.h> | |||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <ctype.h> | |||||
int ath_hal_debug = 0; | int ath_hal_debug = 0; | ||||
HAL_CTRY_CODE cc = CTRY_DEFAULT; | HAL_CTRY_CODE cc = CTRY_DEFAULT; | ||||
HAL_REG_DOMAIN rd = 169; /* FCC */ | HAL_REG_DOMAIN rd = 169; /* FCC */ | ||||
HAL_BOOL Amode = 1; | HAL_BOOL Amode = 1; | ||||
HAL_BOOL Bmode = 1; | HAL_BOOL Bmode = 1; | ||||
HAL_BOOL Gmode = 1; | HAL_BOOL Gmode = 1; | ||||
HAL_BOOL HT20mode = 1; | HAL_BOOL HT20mode = 1; | ||||
▲ Show 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | #define D(_x) { #_x, _x } | ||||
D(WORLD), | D(WORLD), | ||||
D(DEBUG_REG_DMN), | D(DEBUG_REG_DMN), | ||||
#undef D | #undef D | ||||
}; | }; | ||||
static HAL_BOOL | static HAL_BOOL | ||||
rdlookup(const char *name, HAL_REG_DOMAIN *rd) | rdlookup(const char *name, HAL_REG_DOMAIN *rd) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(domains); i++) | for (i = 0; i < nitems(domains); i++) | ||||
if (strcasecmp(domains[i].name, name) == 0) { | if (strcasecmp(domains[i].name, name) == 0) { | ||||
*rd = domains[i].rd; | *rd = domains[i].rd; | ||||
return AH_TRUE; | return AH_TRUE; | ||||
} | } | ||||
return AH_FALSE; | return AH_FALSE; | ||||
#undef N | |||||
} | } | ||||
static const char * | static const char * | ||||
getrdname(HAL_REG_DOMAIN rd) | getrdname(HAL_REG_DOMAIN rd) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(domains); i++) | for (i = 0; i < nitems(domains); i++) | ||||
if (domains[i].rd == rd) | if (domains[i].rd == rd) | ||||
return domains[i].name; | return domains[i].name; | ||||
return NULL; | return NULL; | ||||
#undef N | |||||
} | } | ||||
static void | static void | ||||
rdlist() | rdlist() | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
printf("\nRegulatory domains:\n\n"); | printf("\nRegulatory domains:\n\n"); | ||||
for (i = 0; i < N(domains); i++) | for (i = 0; i < nitems(domains); i++) | ||||
printf("%-15s%s", domains[i].name, | printf("%-15s%s", domains[i].name, | ||||
((i+1)%5) == 0 ? "\n" : ""); | ((i+1)%5) == 0 ? "\n" : ""); | ||||
printf("\n"); | printf("\n"); | ||||
#undef N | |||||
} | } | ||||
typedef struct { | typedef struct { | ||||
HAL_CTRY_CODE countryCode; | HAL_CTRY_CODE countryCode; | ||||
HAL_REG_DOMAIN regDmnEnum; | HAL_REG_DOMAIN regDmnEnum; | ||||
const char* isoName; | const char* isoName; | ||||
const char* name; | const char* name; | ||||
} COUNTRY_CODE_TO_ENUM_RD; | } COUNTRY_CODE_TO_ENUM_RD; | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | static COUNTRY_CODE_TO_ENUM_RD allCountries[] = { | ||||
{CTRY_VIET_NAM, NULL1_WORLD, "VN", "VIET NAM" }, | {CTRY_VIET_NAM, NULL1_WORLD, "VN", "VIET NAM" }, | ||||
{CTRY_YEMEN, NULL1_WORLD, "YE", "YEMEN" }, | {CTRY_YEMEN, NULL1_WORLD, "YE", "YEMEN" }, | ||||
{CTRY_ZIMBABWE, NULL1_WORLD, "ZW", "ZIMBABWE" } | {CTRY_ZIMBABWE, NULL1_WORLD, "ZW", "ZIMBABWE" } | ||||
}; | }; | ||||
static HAL_BOOL | static HAL_BOOL | ||||
cclookup(const char *name, HAL_REG_DOMAIN *rd, HAL_CTRY_CODE *cc) | cclookup(const char *name, HAL_REG_DOMAIN *rd, HAL_CTRY_CODE *cc) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(allCountries); i++) | for (i = 0; i < nitems(allCountries); i++) | ||||
if (strcasecmp(allCountries[i].isoName, name) == 0 || | if (strcasecmp(allCountries[i].isoName, name) == 0 || | ||||
strcasecmp(allCountries[i].name, name) == 0) { | strcasecmp(allCountries[i].name, name) == 0) { | ||||
*rd = allCountries[i].regDmnEnum; | *rd = allCountries[i].regDmnEnum; | ||||
*cc = allCountries[i].countryCode; | *cc = allCountries[i].countryCode; | ||||
return AH_TRUE; | return AH_TRUE; | ||||
} | } | ||||
return AH_FALSE; | return AH_FALSE; | ||||
#undef N | |||||
} | } | ||||
static const char * | static const char * | ||||
getccname(HAL_CTRY_CODE cc) | getccname(HAL_CTRY_CODE cc) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(allCountries); i++) | for (i = 0; i < nitems(allCountries); i++) | ||||
if (allCountries[i].countryCode == cc) | if (allCountries[i].countryCode == cc) | ||||
return allCountries[i].name; | return allCountries[i].name; | ||||
return NULL; | return NULL; | ||||
#undef N | |||||
} | } | ||||
static const char * | static const char * | ||||
getccisoname(HAL_CTRY_CODE cc) | getccisoname(HAL_CTRY_CODE cc) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(allCountries); i++) | for (i = 0; i < nitems(allCountries); i++) | ||||
if (allCountries[i].countryCode == cc) | if (allCountries[i].countryCode == cc) | ||||
return allCountries[i].isoName; | return allCountries[i].isoName; | ||||
return NULL; | return NULL; | ||||
#undef N | |||||
} | } | ||||
static void | static void | ||||
cclist() | cclist() | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
printf("\nCountry codes:\n"); | printf("\nCountry codes:\n"); | ||||
for (i = 0; i < N(allCountries); i++) | for (i = 0; i < nitems(allCountries); i++) | ||||
printf("%2s %-15.15s%s", | printf("%2s %-15.15s%s", | ||||
allCountries[i].isoName, | allCountries[i].isoName, | ||||
allCountries[i].name, | allCountries[i].name, | ||||
((i+1)%4) == 0 ? "\n" : " "); | ((i+1)%4) == 0 ? "\n" : " "); | ||||
printf("\n"); | printf("\n"); | ||||
#undef N | |||||
} | } | ||||
static HAL_BOOL | static HAL_BOOL | ||||
setRateTable(struct ath_hal *ah, const struct ieee80211_channel *chan, | setRateTable(struct ath_hal *ah, const struct ieee80211_channel *chan, | ||||
int16_t tpcScaleReduction, int16_t powerLimit, | int16_t tpcScaleReduction, int16_t powerLimit, | ||||
int16_t *pMinPower, int16_t *pMaxPower); | int16_t *pMinPower, int16_t *pMaxPower); | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 881 Lines • Show Last 20 Lines |