hermes.h

来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 524 行 · 第 1/2 页

H
524
字号
	u8 rates[10];		/* Bit rate supported */	u16 proberesp_rate;	/* Data rate of the response frame */	u16 atim;		/* ATIM window time, Kus (hostscan only) */} __attribute__ ((packed));/* Same stuff for the Lucent/Agere card. * Thanks to h1kari <h1kari AT dachb0den.com> - Jean II */struct agere_scan_apinfo {	u16 channel;		/* Channel where the AP sits */	u16 noise;		/* Noise level */	u16 level;		/* Signal level */	u8 bssid[ETH_ALEN];	/* MAC address of the Access Point */	u16 beacon_interv;	/* Beacon interval */	u16 capabilities;	/* Capabilities */	/* bits: 0-ess, 1-ibss, 4-privacy [wep] */	u16 essid_len;		/* ESSID length */	u8 essid[32];		/* ESSID of the network */} __attribute__ ((packed));/* Moustafa: Scan structure for Symbol cards */struct symbol_scan_apinfo {	u8 channel;		/* Channel where the AP sits */	u8 unknown1;		/* 8 in 2.9x and 3.9x f/w, 0 otherwise */	u16 noise;		/* Noise level */	u16 level;		/* Signal level */	u8 bssid[ETH_ALEN];	/* MAC address of the Access Point */	u16 beacon_interv;	/* Beacon interval */	u16 capabilities;	/* Capabilities */	/* bits: 0-ess, 1-ibss, 4-privacy [wep] */	u16 essid_len;		/* ESSID length */	u8 essid[32];		/* ESSID of the network */    	u16 rates[5];		/* Bit rate supported */	u16 basic_rates;	/* Basic rates bitmask */	u8 unknown2[6];		/* Always FF:FF:FF:FF:00:00 */	u8 unknown3[8];		/* Always 0, appeared in f/w 3.91-68 */} __attribute__ ((packed));union hermes_scan_info {	struct agere_scan_apinfo	a;	struct prism2_scan_apinfo	p;	struct symbol_scan_apinfo	s;};#define HERMES_LINKSTATUS_NOT_CONNECTED   (0x0000)  #define HERMES_LINKSTATUS_CONNECTED       (0x0001)#define HERMES_LINKSTATUS_DISCONNECTED    (0x0002)#define HERMES_LINKSTATUS_AP_CHANGE       (0x0003)#define HERMES_LINKSTATUS_AP_OUT_OF_RANGE (0x0004)#define HERMES_LINKSTATUS_AP_IN_RANGE     (0x0005)#define HERMES_LINKSTATUS_ASSOC_FAILED    (0x0006)  struct hermes_linkstatus {	u16 linkstatus;         /* Link status */} __attribute__ ((packed));struct hermes_response {	u16 status, resp0, resp1, resp2;};/* "ID" structure - used for ESSID and station nickname */struct hermes_idstring {	u16 len;	u16 val[16];} __attribute__ ((packed));struct hermes_multicast {	u8 addr[HERMES_MAX_MULTICAST][ETH_ALEN];} __attribute__ ((packed));// #define HERMES_DEBUG_BUFFER 1#define HERMES_DEBUG_BUFSIZE 4096struct hermes_debug_entry {	int bap;	u16 id, offset;	int cycles;};#ifdef __KERNEL__/* Timeouts */#define HERMES_BAP_BUSY_TIMEOUT (500) /* In iterations of ~1us *//* Basic control structure */typedef struct hermes {	unsigned long iobase;	int io_space; /* 1 if we IO-mapped IO, 0 for memory-mapped IO? */#define HERMES_IO	1#define HERMES_MEM	0	int reg_spacing;#define HERMES_16BIT_REGSPACING	0#define HERMES_32BIT_REGSPACING	1	u16 inten; /* Which interrupts should be enabled? */#ifdef HERMES_DEBUG_BUFFER	struct hermes_debug_entry dbuf[HERMES_DEBUG_BUFSIZE];	unsigned long dbufp;	unsigned long profile[HERMES_BAP_BUSY_TIMEOUT+1];#endif} hermes_t;/* Register access convenience macros */#define hermes_read_reg(hw, off) ((hw)->io_space ? \	inw((hw)->iobase + ( (off) << (hw)->reg_spacing )) : \	readw((hw)->iobase + ( (off) << (hw)->reg_spacing )))#define hermes_write_reg(hw, off, val) do { \	if ((hw)->io_space) \		outw_p((val), (hw)->iobase + ((off) << (hw)->reg_spacing)); \	else \		writew((val), (hw)->iobase + ((off) << (hw)->reg_spacing)); \	} while (0)#define hermes_read_regn(hw, name) hermes_read_reg((hw), HERMES_##name)#define hermes_write_regn(hw, name, val) hermes_write_reg((hw), HERMES_##name, (val))/* Function prototypes */void hermes_struct_init(hermes_t *hw, ulong address, int io_space,			int reg_spacing);int hermes_init(hermes_t *hw);int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,		      struct hermes_response *resp);int hermes_allocate(hermes_t *hw, u16 size, u16 *fid);int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len,		       u16 id, u16 offset);int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len,			u16 id, u16 offset);int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen,		    u16 *length, void *buf);int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,		      u16 length, const void *value);/* Inline functions */static inline int hermes_present(hermes_t *hw){	return hermes_read_regn(hw, SWSUPPORT0) == HERMES_MAGIC;}static inline void hermes_set_irqmask(hermes_t *hw, u16 events){	hw->inten = events;	hermes_write_regn(hw, INTEN, events);}static inline int hermes_enable_port(hermes_t *hw, int port){	return hermes_docmd_wait(hw, HERMES_CMD_ENABLE | (port << 8),				 0, NULL);}static inline int hermes_disable_port(hermes_t *hw, int port){	return hermes_docmd_wait(hw, HERMES_CMD_DISABLE | (port << 8), 				 0, NULL);}/* Initiate an INQUIRE command (tallies or scan).  The result will come as an * information frame in __orinoco_ev_info() */static inline int hermes_inquire(hermes_t *hw, u16 rid){	return hermes_docmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL);}#define HERMES_BYTES_TO_RECLEN(n) ( (((n)+1)/2) + 1 )#define HERMES_RECLEN_TO_BYTES(n) ( ((n)-1) * 2 )/* Note that for the next two, the count is in 16-bit words, not bytes */static inline void hermes_read_words(struct hermes *hw, int off, void *buf, unsigned count){	off = off << hw->reg_spacing;	if (hw->io_space) {		insw(hw->iobase + off, buf, count);	} else {		unsigned i;		u16 *p;		/* This needs to *not* byteswap (like insw()) but		 * readw() does byteswap hence the conversion.  I hope		 * gcc is smart enough to fold away the two swaps on		 * big-endian platforms. */		for (i = 0, p = buf; i < count; i++) {			*p++ = cpu_to_le16(readw(hw->iobase + off));		}	}}static inline void hermes_write_words(struct hermes *hw, int off, const void *buf, unsigned count){	off = off << hw->reg_spacing;	if (hw->io_space) {		outsw(hw->iobase + off, buf, count);	} else {		unsigned i;		const u16 *p;		/* This needs to *not* byteswap (like outsw()) but		 * writew() does byteswap hence the conversion.  I		 * hope gcc is smart enough to fold away the two swaps		 * on big-endian platforms. */		for (i = 0, p = buf; i < count; i++) {			writew(le16_to_cpu(*p++), hw->iobase + off);		}	}}static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count){	unsigned i;	off = off << hw->reg_spacing;	if (hw->io_space) {		for (i = 0; i < count; i++)			outw(0, hw->iobase + off);	} else {		for (i = 0; i < count; i++)			writew(0, hw->iobase + off);	}}#define HERMES_READ_RECORD(hw, bap, rid, buf) \	(hermes_read_ltv((hw),(bap),(rid), sizeof(*buf), NULL, (buf)))#define HERMES_WRITE_RECORD(hw, bap, rid, buf) \	(hermes_write_ltv((hw),(bap),(rid),HERMES_BYTES_TO_RECLEN(sizeof(*buf)),(buf)))static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word){	u16 rec;	int err;	err = HERMES_READ_RECORD(hw, bap, rid, &rec);	*word = le16_to_cpu(rec);	return err;}static inline int hermes_write_wordrec(hermes_t *hw, int bap, u16 rid, u16 word){	u16 rec = cpu_to_le16(word);	return HERMES_WRITE_RECORD(hw, bap, rid, &rec);}#else /* ! __KERNEL__ *//* These are provided for the benefit of userspace drivers and testing programs   which use ioperm() or iopl() */#define hermes_read_reg(base, off) (inw((base) + (off)))#define hermes_write_reg(base, off, val) (outw((val), (base) + (off)))#define hermes_read_regn(base, name) (hermes_read_reg((base), HERMES_##name))#define hermes_write_regn(base, name, val) (hermes_write_reg((base), HERMES_##name, (val)))/* Note that for the next two, the count is in 16-bit words, not bytes */#define hermes_read_data(base, off, buf, count) (insw((base) + (off), (buf), (count)))#define hermes_write_data(base, off, buf, count) (outsw((base) + (off), (buf), (count)))#endif /* ! __KERNEL__ */#endif  /* _HERMES_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?