⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csr1212.h

📁 ieee1394驱动,不多说了!直接可以在linux2.6内核中使用
💻 H
📖 第 1 页 / 共 2 页
字号:
	 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_SHIFT)#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) \	((CSR1212_BE32_TO_CPU((kv)->value.leaf.data[1]) >> \			     CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT) & \			    CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK)#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) \	(CSR1212_BE32_TO_CPU((kv)->value.leaf.data[1]) & \	 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK)#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA(kv) \	(&((kv)->value.leaf.data[2]))#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_SET_WIDTH(kv, width) \	((kv)->value.leaf.data[1] = \	 ((kv)->value.leaf.data[1] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_MASK << \				CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_SHIFT))) | \	 CSR1212_CPU_TO_BE32(((width) & \			      CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_MASK) << \			     CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_SHIFT))#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_SET_CHAR_SET(kv, char_set) \	((kv)->value.leaf.data[1] = \	 ((kv)->value.leaf.data[1] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK << \				CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT))) | \	 CSR1212_CPU_TO_BE32(((char_set) & \			      CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK) << \			     CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT))#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_SET_LANGUAGE(kv, language) \	((kv)->value.leaf.data[1] = \	 ((kv)->value.leaf.data[1] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK))) | \	 CSR1212_CPU_TO_BE32(((language) & \			      CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK)))/* Icon Descriptor Leaf manipulation macros */#define CSR1212_ICON_DESCRIPTOR_LEAF_VERSION_MASK 0xffffff#define CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_SHIFT 30#define CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_MASK 0x3 /* after shift */#define CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_SHIFT 16#define CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_MASK 0xf /* after shift */#define CSR1212_ICON_DESCRIPTOR_LEAF_LANGUAGE_MASK 0xffff#define CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN_SHIFT 16#define CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN_MASK 0xffff /* after shift */#define CSR1212_ICON_DESCRIPTOR_LEAF_VSCAN_MASK 0xffff#define CSR1212_ICON_DESCRIPTOR_LEAF_OVERHEAD (3 * sizeof(u_int32_t))#define CSR1212_ICON_DESCRIPTOR_LEAF_VERSION(kv) \	(CSR1212_BE32_TO_CPU((kv)->value.leaf.data[2]) & \	 CSR1212_ICON_DESCRIPTOR_LEAF_VERSION_MASK)#define CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH(kv) \	(CSR1212_BE32_TO_CPU((kv)->value.leaf.data[3]) >> \	 CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_SHIFT)#define CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE(kv) \	((CSR1212_BE32_TO_CPU((kv)->value.leaf.data[3]) >> \	  CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_SHIFT) & \	 CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_MASK)#define CSR1212_ICON_DESCRIPTOR_LEAF_LANGUAGE(kv) \	(CSR1212_BE32_TO_CPU((kv)->value.leaf.data[3]) & \	 CSR1212_ICON_DESCRIPTOR_LEAF_LANGUAGE_MASK)#define CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN(kv) \	((CSR1212_BE32_TO_CPU((kv)->value.leaf.data[4]) >> \	  CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_HSCAN_SHIFT) & \	 CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_HSCAN_MASK)#define CSR1212_ICON_DESCRIPTOR_LEAF_VSCAN(kv) \	(CSR1212_BE32_TO_CPU((kv)->value.leaf.data[4]) & \	 CSR1212_ICON_DESCRIPTOR_LEAF_VSCAN_MASK)#define CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE(kv) \	(&((kv)->value.leaf.data[5]))static inline u_int32_t *CSR1212_ICON_DESCRIPTOR_LEAF_PIXELS(struct csr1212_keyval *kv){	static const int pd[4] = { 0, 4, 16, 256 };	static const int cs[16] = { 4, 2 };	int ps = pd[CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH(kv)];	return &kv->value.leaf.data[5 +				    (ps * cs[CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE(kv)]) /			   sizeof(u_int32_t)];}#define CSR1212_ICON_DESCRIPTOR_LEAF_SET_VERSION(kv, version) \	((kv)->value.leaf.data[2] = \	 ((kv)->value.leaf.data[2] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_ICON_DESCRIPTOR_LEAF_VERSION_MASK))) | \	 CSR1212_CPU_TO_BE32(((version) & \			      CSR1212_ICON_DESCRIPTOR_LEAF_VERSION_MASK)))#define CSR1212_ICON_DESCRIPTOR_LEAF_SET_PALETTE_DEPTH(kv, palette_depth) \	((kv)->value.leaf.data[3] = \	 ((kv)->value.leaf.data[3] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_MASK << \				CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_SHIFT))) | \	 CSR1212_CPU_TO_BE32(((palette_depth) & \			      CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_MASK) << \			     CSR1212_ICON_DESCRIPTOR_LEAF_PALETTE_DEPTH_SHIFT))#define CSR1212_ICON_DESCRIPTOR_LEAF_SET_COLOR_SPACE(kv, color_space) \	((kv)->value.leaf.data[3] = \	 ((kv)->value.leaf.data[3] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_MASK << \				CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_SHIFT))) | \	 CSR1212_CPU_TO_BE32(((color_space) & \			      CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_MASK) << \			     CSR1212_ICON_DESCRIPTOR_LEAF_COLOR_SPACE_SHIFT))#define CSR1212_ICON_DESCRIPTOR_LEAF_SET_LANGUAGE(kv, language) \	((kv)->value.leaf.data[3] = \	 ((kv)->value.leaf.data[3] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_ICON_DESCRIPTOR_LEAF_LANGUAGE_MASK))) | \	 CSR1212_CPU_TO_BE32(((language) & \			      CSR1212_ICON_DESCRIPTOR_LEAF_LANGUAGE_MASK)))#define CSR1212_ICON_DESCRIPTOR_LEAF_SET_HSCAN(kv, hscan) \	((kv)->value.leaf.data[4] = \	 ((kv)->value.leaf.data[4] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN_MASK << \				CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN_SHIFT))) | \	 CSR1212_CPU_TO_BE32(((hscan) & \			      CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN_MASK) << \			     CSR1212_ICON_DESCRIPTOR_LEAF_HSCAN_SHIFT))#define CSR1212_ICON_DESCRIPTOR_LEAF_SET_VSCAN(kv, vscan) \	((kv)->value.leaf.data[4] = \	 (((kv)->value.leaf.data[4] & \	  CSR1212_CPU_TO_BE32(~CSR1212_ICON_DESCRIPTOR_LEAF_VSCAN_MASK))) | \	 CSR1212_CPU_TO_BE32(((vscan) & \			      CSR1212_ICON_DESCRIPTOR_LEAF_VSCAN_MASK)))/* Modifiable Descriptor Leaf manipulation macros */#define CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_MAX_SIZE_SHIFT 16#define CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_MAX_SIZE_MASK 0xffff#define CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_ADDR_HI_SHIFT 32#define CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_ADDR_HI_MASK 0xffff#define CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_ADDR_LO_MASK 0xffffffffULL#define CSR1212_MODIFIABLE_DESCRIPTOR_MAX_SIZE(kv) \	CSR1212_BE16_TO_CPU((kv)->value.leaf.data[0] >> CSR1212_MODIFIABLE_DESCRIPTOR_MAX_SIZE_SHIFT)#define CSR1212_MODIFIABLE_DESCRIPTOR_ADDRESS(kv) \	(CSR1212_BE16_TO_CPU(((u_int64_t)((kv)->value.leaf.data[0])) << \			     CSR1212_MODIFIABLE_DESCRIPTOR_ADDR_HI_SHIFT) | \	 CSR1212_BE32_TO_CPU((kv)->value.leaf.data[1]))#define CSR1212_MODIFIABLE_DESCRIPTOR_SET_MAX_SIZE(kv, size) \	((kv)->value.leaf.data[0] = \	 ((kv)->value.leaf.data[0] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_MAX_SIZE_MASK << \				CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_MAX_SIZE_SHIFT))) | \	 CSR1212_CPU_TO_BE32(((size) & \			      CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_MAX_SIZE_MASK) << \			     CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_MAX_SIZE_SHIFT))#define CSR1212_MODIFIABLE_DESCRIPTOR_SET_ADDRESS_HI(kv, addr) \	((kv)->value.leaf.data[0] = \	 ((kv)->value.leaf.data[0] & \	  CSR1212_CPU_TO_BE32(~(CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_ADDR_HI_MASK))) | \	  CSR1212_CPU_TO_BE32(((addr) & \			       CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_ADDR_HI_MASK)))#define CSR1212_MODIFIABLE_DESCRIPTOR_SET_ADDRESS_LO(kv, addr) \	((kv)->value.leaf.data[1] = \	 CSR1212_CPU_TO_BE32(addr & CSR1212_MODIFIABLE_DESCRIPTOR_LEAF_ADDR_LO_MASK))/* The following 2 function are for creating new Configuration ROM trees.  The * first function is used for both creating local trees and parsing remote * trees.  The second function adds pertinent information to local Configuration * ROM trees - namely data for the bus information block. */extern struct csr1212_csr *csr1212_create_csr(struct csr1212_bus_ops *ops,					      size_t bus_info_size,					      void *private);extern void csr1212_init_local_csr(struct csr1212_csr *csr,				   const u_int32_t *bus_info_data, int max_rom);/* The following function destroys a Configuration ROM tree and release all * memory taken by the tree. */extern void csr1212_destroy_csr(struct csr1212_csr *csr);/* The following set of functions are fore creating new keyvals for placement in * a Configuration ROM tree.  Code that creates new keyvals with these functions * must release those keyvals with csr1212_release_keyval() when they are no * longer needed. */extern struct csr1212_keyval *csr1212_new_immediate(u_int8_t key, u_int32_t value);extern struct csr1212_keyval *csr1212_new_leaf(u_int8_t key, const void *data,					       size_t data_len);extern struct csr1212_keyval *csr1212_new_csr_offset(u_int8_t key,						     u_int32_t csr_offset);extern struct csr1212_keyval *csr1212_new_directory(u_int8_t key);extern struct csr1212_keyval *csr1212_new_extended_immediate(u_int32_t spec,							     u_int32_t key,							     u_int32_t value);extern struct csr1212_keyval *csr1212_new_extended_leaf(u_int32_t spec,							u_int32_t key,							const void *data,							size_t data_len);extern struct csr1212_keyval *csr1212_new_descriptor_leaf(u_int8_t dtype,							  u_int32_t specifier_id,							  const void *data,							  size_t data_len);extern struct csr1212_keyval *csr1212_new_textual_descriptor_leaf(u_int8_t cwidth,								  u_int16_t cset,								  u_int16_t language,								  const void *data,								  size_t data_len);extern struct csr1212_keyval *csr1212_new_string_descriptor_leaf(const char *s);extern struct csr1212_keyval *csr1212_new_icon_descriptor_leaf(u_int32_t version,							       u_int8_t palette_depth,							       u_int8_t color_space,							       u_int16_t language,							       u_int16_t hscan,							       u_int16_t vscan,							       u_int32_t *palette,							       u_int32_t *pixels);extern struct csr1212_keyval *csr1212_new_modifiable_descriptor_leaf(u_int16_t max_size,								     u_int64_t address);extern struct csr1212_keyval *csr1212_new_keyword_leaf(int strc,						       const char *strv[]);/* The following functions manage association between keyvals.  Typically, * Descriptor Leaves and Directories will be associated with another keyval and * it is desirable for the Descriptor keyval to be place immediately after the * keyval that it is associated with.*/extern int csr1212_associate_keyval(struct csr1212_keyval *kv,				    struct csr1212_keyval *associate);extern void csr1212_disassociate_keyval(struct csr1212_keyval *kv);/* The following functions manage the association of a keyval and directories. * A keyval may be attached to more than one directory. */extern int csr1212_attach_keyval_to_directory(struct csr1212_keyval *dir,					      struct csr1212_keyval *kv);extern void csr1212_detach_keyval_from_directory(struct csr1212_keyval *dir,						 struct csr1212_keyval *kv);/* The following functions create a Configuration ROM image from the tree of * keyvals provided.  csr1212_generate_csr_image() creates a complete image in * the list of caches available via csr->cache_head.  The other functions are * provided should there be a need to create a flat image without restrictions * placed by IEEE 1212. */extern struct csr1212_keyval *csr1212_generate_positions(struct csr1212_csr_rom_cache *cache,							 struct csr1212_keyval *start_kv,							 int start_pos);extern size_t csr1212_generate_layout_order(struct csr1212_keyval *kv);extern void csr1212_fill_cache(struct csr1212_csr_rom_cache *cache);extern int csr1212_generate_csr_image(struct csr1212_csr *csr);/* This is a convience function for reading a block of data out of one of the * caches in the csr->cache_head list. */extern int csr1212_read(struct csr1212_csr *csr, u_int32_t offset, void *buffer,			u_int32_t len);/* The following functions are in place for parsing Configuration ROM images. * csr1212_parse_keyval() is used should there be a need to directly parse a * Configuration ROM directly. */extern int csr1212_parse_keyval(struct csr1212_keyval *kv,				struct csr1212_csr_rom_cache *cache);extern int csr1212_parse_csr(struct csr1212_csr *csr);/* These are internal functions referenced by inline functions below. */extern int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv);extern void _csr1212_destroy_keyval(struct csr1212_keyval *kv);/* This function allocates a new cache which may be used for either parsing or * generating sub-sets of Configuration ROM images. */static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t offset,								     size_t size){	struct csr1212_csr_rom_cache *cache;	cache = CSR1212_MALLOC(sizeof(*cache) + size);	if (!cache)		return NULL;	cache->next = NULL;	cache->prev = NULL;	cache->filled_head = NULL;	cache->filled_tail = NULL;	cache->layout_head = NULL;	cache->layout_tail = NULL;	cache->offset = offset;	cache->size = size;	cache->ext_rom = NULL;	return cache;}/* This function ensures that a keyval contains data when referencing a keyval * created by parsing a Configuration ROM. */static inline struct csr1212_keyval *csr1212_get_keyval(struct csr1212_csr *csr,							struct csr1212_keyval *kv){	if (!kv)		return NULL;	if (!kv->valid)		if (_csr1212_read_keyval(csr, kv) != CSR1212_SUCCESS)			return NULL;	return kv;}/* This function increments the reference count for a keyval should there be a * need for code to retain a keyval that has been parsed. */static inline void csr1212_keep_keyval(struct csr1212_keyval *kv){	kv->refcnt++;}/* This function decrements a keyval's reference count and will destroy the * keyval when there are no more users of the keyval.  This should be called by * any code that calls csr1212_keep_keyval() or any of the keyval creation * routines csr1212_new_*(). */static inline void csr1212_release_keyval(struct csr1212_keyval *kv){	if (kv->refcnt > 1)		kv->refcnt--;	else		_csr1212_destroy_keyval(kv);}/* * This macro allows for looping over the keyval entries in a directory and it * ensures that keyvals from remote ConfigROMs are parsed properly. * * _csr is a struct csr1212_csr * that points to CSR associated with dir. * _kv is a struct csr1212_keyval * that'll point to the current keyval (loop index). * _dir is a struct csr1212_keyval * that points to the directory to be looped. * _pos is a struct csr1212_dentry * that is used internally for indexing. * * kv will be NULL upon exit of the loop. */#define csr1212_for_each_dir_entry(_csr, _kv, _dir, _pos)			\	for (csr1212_get_keyval((_csr), (_dir)),				\	     _pos = (_dir)->value.directory.dentries_head,			\	     _kv = (_pos) ? csr1212_get_keyval((_csr), _pos->kv) : NULL;	\	     (_kv) && (_pos);							\	     (_kv->associate == NULL) ?						\		     ((_pos = _pos->next), 					\		      (_kv = (_pos) ? csr1212_get_keyval((_csr), _pos->kv) :	\                          NULL)) :						\		     (_kv = csr1212_get_keyval((_csr), _kv->associate)))#endif /* __CSR1212_H__ */

⌨️ 快捷键说明

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