code_text
stringlengths
604
999k
repo_name
stringlengths
4
100
file_path
stringlengths
4
873
language
stringclasses
23 values
license
stringclasses
15 values
size
int32
1.02k
999k
/* -*- mode: c; c-basic-offset: 8; -*- * vim: noexpandtab sw=8 ts=8 sts=0: * * move_extents.c * * Copyright (C) 2011 Oracle. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License version 2 as published by the Free Software Foundation. * * 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. */ #include <linux/fs.h> #include <linux/types.h> #include <linux/mount.h> #include <linux/swap.h> #include <cluster/masklog.h> #include "ocfs2.h" #include "ocfs2_ioctl.h" #include "alloc.h" #include "aops.h" #include "dlmglue.h" #include "extent_map.h" #include "inode.h" #include "journal.h" #include "suballoc.h" #include "uptodate.h" #include "super.h" #include "dir.h" #include "buffer_head_io.h" #include "sysfile.h" #include "suballoc.h" #include "refcounttree.h" #include "move_extents.h" struct ocfs2_move_extents_context { struct inode *inode; struct file *file; int auto_defrag; int partial; int credits; u32 new_phys_cpos; u32 clusters_moved; u64 refcount_loc; struct ocfs2_move_extents *range; struct ocfs2_extent_tree et; struct ocfs2_alloc_context *meta_ac; struct ocfs2_alloc_context *data_ac; struct ocfs2_cached_dealloc_ctxt dealloc; }; static int __ocfs2_move_extent(handle_t *handle, struct ocfs2_move_extents_context *context, u32 cpos, u32 len, u32 p_cpos, u32 new_p_cpos, int ext_flags) { int ret = 0, index; struct inode *inode = context->inode; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_extent_rec *rec, replace_rec; struct ocfs2_path *path = NULL; struct ocfs2_extent_list *el; u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci); u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos); ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos, p_cpos, new_p_cpos, len); if (ret) { mlog_errno(ret); goto out; } memset(&replace_rec, 0, sizeof(replace_rec)); replace_rec.e_cpos = cpu_to_le32(cpos); replace_rec.e_leaf_clusters = cpu_to_le16(len); replace_rec.e_blkno = cpu_to_le64(ocfs2_clusters_to_blocks(inode->i_sb, new_p_cpos)); path = ocfs2_new_path_from_et(&context->et); if (!path) { ret = -ENOMEM; mlog_errno(ret); goto out; } ret = ocfs2_find_path(INODE_CACHE(inode), path, cpos); if (ret) { mlog_errno(ret); goto out; } el = path_leaf_el(path); index = ocfs2_search_extent_list(el, cpos); if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) { ocfs2_error(inode->i_sb, "Inode %llu has an extent at cpos %u which can no " "longer be found.\n", (unsigned long long)ino, cpos); ret = -EROFS; goto out; } rec = &el->l_recs[index]; BUG_ON(ext_flags != rec->e_flags); /* * after moving/defraging to new location, the extent is not going * to be refcounted anymore. */ replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED; ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), context->et.et_root_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (ret) { mlog_errno(ret); goto out; } ret = ocfs2_split_extent(handle, &context->et, path, index, &replace_rec, context->meta_ac, &context->dealloc); if (ret) { mlog_errno(ret); goto out; } ocfs2_journal_dirty(handle, context->et.et_root_bh); context->new_phys_cpos = new_p_cpos; /* * need I to append truncate log for old clusters? */ if (old_blkno) { if (ext_flags & OCFS2_EXT_REFCOUNTED) ret = ocfs2_decrease_refcount(inode, handle, ocfs2_blocks_to_clusters(osb->sb, old_blkno), len, context->meta_ac, &context->dealloc, 1); else ret = ocfs2_truncate_log_append(osb, handle, old_blkno, len); } out: return ret; } /* * lock allocators, and reserving appropriate number of bits for * meta blocks and data clusters. * * in some cases, we don't need to reserve clusters, just let data_ac * be NULL. */ static int ocfs2_lock_allocators_move_extents(struct inode *inode, struct ocfs2_extent_tree *et, u32 clusters_to_move, u32 extents_to_split, struct ocfs2_alloc_context **meta_ac, struct ocfs2_alloc_context **data_ac, int extra_blocks, int *credits) { int ret, num_free_extents; unsigned int max_recs_needed = 2 * extents_to_split + clusters_to_move; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); num_free_extents = ocfs2_num_free_extents(osb, et); if (num_free_extents < 0) { ret = num_free_extents; mlog_errno(ret); goto out; } if (!num_free_extents || (ocfs2_sparse_alloc(osb) && num_free_extents < max_recs_needed)) extra_blocks += ocfs2_extend_meta_needed(et->et_root_el); ret = ocfs2_reserve_new_metadata_blocks(osb, extra_blocks, meta_ac); if (ret) { mlog_errno(ret); goto out; } if (data_ac) { ret = ocfs2_reserve_clusters(osb, clusters_to_move, data_ac); if (ret) { mlog_errno(ret); goto out; } } *credits += ocfs2_calc_extend_credits(osb->sb, et->et_root_el, clusters_to_move + 2); mlog(0, "reserve metadata_blocks: %d, data_clusters: %u, credits: %d\n", extra_blocks, clusters_to_move, *credits); out: if (ret) { if (*meta_ac) { ocfs2_free_alloc_context(*meta_ac); *meta_ac = NULL; } } return ret; } /* * Using one journal handle to guarantee the data consistency in case * crash happens anywhere. * * XXX: defrag can end up with finishing partial extent as requested, * due to not enough contiguous clusters can be found in allocator. */ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, u32 cpos, u32 phys_cpos, u32 *len, int ext_flags) { int ret, credits = 0, extra_blocks = 0, partial = context->partial; handle_t *handle; struct inode *inode = context->inode; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct inode *tl_inode = osb->osb_tl_inode; struct ocfs2_refcount_tree *ref_tree = NULL; u32 new_phys_cpos, new_len; u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) { BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); BUG_ON(!context->refcount_loc); ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, &ref_tree, NULL); if (ret) { mlog_errno(ret); return ret; } ret = ocfs2_prepare_refcount_change_for_del(inode, context->refcount_loc, phys_blkno, *len, &credits, &extra_blocks); if (ret) { mlog_errno(ret); goto out; } } ret = ocfs2_lock_allocators_move_extents(inode, &context->et, *len, 1, &context->meta_ac, &context->data_ac, extra_blocks, &credits); if (ret) { mlog_errno(ret); goto out; } /* * should be using allocation reservation strategy there? * * if (context->data_ac) * context->data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv; */ mutex_lock(&tl_inode->i_mutex); if (ocfs2_truncate_log_needs_flush(osb)) { ret = __ocfs2_flush_truncate_log(osb); if (ret < 0) { mlog_errno(ret); goto out_unlock_mutex; } } handle = ocfs2_start_trans(osb, credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); mlog_errno(ret); goto out_unlock_mutex; } ret = __ocfs2_claim_clusters(handle, context->data_ac, 1, *len, &new_phys_cpos, &new_len); if (ret) { mlog_errno(ret); goto out_commit; } /* * allowing partial extent moving is kind of 'pros and cons', it makes * whole defragmentation less likely to fail, on the contrary, the bad * thing is it may make the fs even more fragmented after moving, let * userspace make a good decision here. */ if (new_len != *len) { mlog(0, "len_claimed: %u, len: %u\n", new_len, *len); if (!partial) { context->range->me_flags &= ~OCFS2_MOVE_EXT_FL_COMPLETE; ret = -ENOSPC; goto out_commit; } } mlog(0, "cpos: %u, phys_cpos: %u, new_phys_cpos: %u\n", cpos, phys_cpos, new_phys_cpos); ret = __ocfs2_move_extent(handle, context, cpos, new_len, phys_cpos, new_phys_cpos, ext_flags); if (ret) mlog_errno(ret); if (partial && (new_len != *len)) *len = new_len; /* * Here we should write the new page out first if we are * in write-back mode. */ ret = ocfs2_cow_sync_writeback(inode->i_sb, context->inode, cpos, *len); if (ret) mlog_errno(ret); out_commit: ocfs2_commit_trans(osb, handle); out_unlock_mutex: mutex_unlock(&tl_inode->i_mutex); if (context->data_ac) { ocfs2_free_alloc_context(context->data_ac); context->data_ac = NULL; } if (context->meta_ac) { ocfs2_free_alloc_context(context->meta_ac); context->meta_ac = NULL; } out: if (ref_tree) ocfs2_unlock_refcount_tree(osb, ref_tree, 1); return ret; } /* * find the victim alloc group, where #blkno fits. */ static int ocfs2_find_victim_alloc_group(struct inode *inode, u64 vict_blkno, int type, int slot, int *vict_bit, struct buffer_head **ret_bh) { int ret, i, bits_per_unit = 0; u64 blkno; char namebuf[40]; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct buffer_head *ac_bh = NULL, *gd_bh = NULL; struct ocfs2_chain_list *cl; struct ocfs2_chain_rec *rec; struct ocfs2_dinode *ac_dinode; struct ocfs2_group_desc *bg; ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type, slot); ret = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf, strlen(namebuf), &blkno); if (ret) { ret = -ENOENT; goto out; } ret = ocfs2_read_blocks_sync(osb, blkno, 1, &ac_bh); if (ret) { mlog_errno(ret); goto out; } ac_dinode = (struct ocfs2_dinode *)ac_bh->b_data; cl = &(ac_dinode->id2.i_chain); rec = &(cl->cl_recs[0]); if (type == GLOBAL_BITMAP_SYSTEM_INODE) bits_per_unit = osb->s_clustersize_bits - inode->i_sb->s_blocksize_bits; /* * 'vict_blkno' was out of the valid range. */ if ((vict_blkno < le64_to_cpu(rec->c_blkno)) || (vict_blkno >= (le32_to_cpu(ac_dinode->id1.bitmap1.i_total) << bits_per_unit))) { ret = -EINVAL; goto out; } for (i = 0; i < le16_to_cpu(cl->cl_next_free_rec); i++) { rec = &(cl->cl_recs[i]); if (!rec) continue; bg = NULL; do { if (!bg) blkno = le64_to_cpu(rec->c_blkno); else blkno = le64_to_cpu(bg->bg_next_group); if (gd_bh) { brelse(gd_bh); gd_bh = NULL; } ret = ocfs2_read_blocks_sync(osb, blkno, 1, &gd_bh); if (ret) { mlog_errno(ret); goto out; } bg = (struct ocfs2_group_desc *)gd_bh->b_data; if (vict_blkno < (le64_to_cpu(bg->bg_blkno) + le16_to_cpu(bg->bg_bits))) { *ret_bh = gd_bh; *vict_bit = (vict_blkno - blkno) >> bits_per_unit; mlog(0, "find the victim group: #%llu, " "total_bits: %u, vict_bit: %u\n", blkno, le16_to_cpu(bg->bg_bits), *vict_bit); goto out; } } while (le64_to_cpu(bg->bg_next_group)); } ret = -EINVAL; out: brelse(ac_bh); /* * caller has to release the gd_bh properly. */ return ret; } /* * XXX: helper to validate and adjust moving goal. */ static int ocfs2_validate_and_adjust_move_goal(struct inode *inode, struct ocfs2_move_extents *range) { int ret, goal_bit = 0; struct buffer_head *gd_bh = NULL; struct ocfs2_group_desc *bg = NULL; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); int c_to_b = 1 << (osb->s_clustersize_bits - inode->i_sb->s_blocksize_bits); /* * make goal become cluster aligned. */ range->me_goal = ocfs2_block_to_cluster_start(inode->i_sb, range->me_goal); /* * moving goal is not allowd to start with a group desc blok(#0 blk) * let's compromise to the latter cluster. */ if (range->me_goal == le64_to_cpu(bg->bg_blkno)) range->me_goal += c_to_b; /* * validate goal sits within global_bitmap, and return the victim * group desc */ ret = ocfs2_find_victim_alloc_group(inode, range->me_goal, GLOBAL_BITMAP_SYSTEM_INODE, OCFS2_INVALID_SLOT, &goal_bit, &gd_bh); if (ret) goto out; bg = (struct ocfs2_group_desc *)gd_bh->b_data; /* * movement is not gonna cross two groups. */ if ((le16_to_cpu(bg->bg_bits) - goal_bit) * osb->s_clustersize < range->me_len) { ret = -EINVAL; goto out; } /* * more exact validations/adjustments will be performed later during * moving operation for each extent range. */ mlog(0, "extents get ready to be moved to #%llu block\n", range->me_goal); out: brelse(gd_bh); return ret; } static void ocfs2_probe_alloc_group(struct inode *inode, struct buffer_head *bh, int *goal_bit, u32 move_len, u32 max_hop, u32 *phys_cpos) { int i, used, last_free_bits = 0, base_bit = *goal_bit; struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; u32 base_cpos = ocfs2_blocks_to_clusters(inode->i_sb, le64_to_cpu(gd->bg_blkno)); for (i = base_bit; i < le16_to_cpu(gd->bg_bits); i++) { used = ocfs2_test_bit(i, (unsigned long *)gd->bg_bitmap); if (used) { /* * we even tried searching the free chunk by jumping * a 'max_hop' distance, but still failed. */ if ((i - base_bit) > max_hop) { *phys_cpos = 0; break; } if (last_free_bits) last_free_bits = 0; continue; } else last_free_bits++; if (last_free_bits == move_len) { *goal_bit = i; *phys_cpos = base_cpos + i; break; } } mlog(0, "found phys_cpos: %u to fit the wanted moving.\n", *phys_cpos); } static int ocfs2_alloc_dinode_update_counts(struct inode *inode, handle_t *handle, struct buffer_head *di_bh, u32 num_bits, u16 chain) { int ret; u32 tmp_used; struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain; ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (ret < 0) { mlog_errno(ret); goto out; } tmp_used = le32_to_cpu(di->id1.bitmap1.i_used); di->id1.bitmap1.i_used = cpu_to_le32(num_bits + tmp_used); le32_add_cpu(&cl->cl_recs[chain].c_free, -num_bits); ocfs2_journal_dirty(handle, di_bh); out: return ret; } static inline int ocfs2_block_group_set_bits(handle_t *handle, struct inode *alloc_inode, struct ocfs2_group_desc *bg, struct buffer_head *group_bh, unsigned int bit_off, unsigned int num_bits) { int status; void *bitmap = bg->bg_bitmap; int journal_type = OCFS2_JOURNAL_ACCESS_WRITE; /* All callers get the descriptor via * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, num_bits); if (ocfs2_is_cluster_bitmap(alloc_inode)) journal_type = OCFS2_JOURNAL_ACCESS_UNDO; status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), group_bh, journal_type); if (status < 0) { mlog_errno(status); goto bail; } le16_add_cpu(&bg->bg_free_bits_count, -num_bits); if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) { ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit" " count %u but claims %u are freed. num_bits %d", (unsigned long long)le64_to_cpu(bg->bg_blkno), le16_to_cpu(bg->bg_bits), le16_to_cpu(bg->bg_free_bits_count), num_bits); return -EROFS; } while (num_bits--) ocfs2_set_bit(bit_off++, bitmap); ocfs2_journal_dirty(handle, group_bh); bail: return status; } static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, u32 cpos, u32 phys_cpos, u32 *new_phys_cpos, u32 len, int ext_flags) { int ret, credits = 0, extra_blocks = 0, goal_bit = 0; handle_t *handle; struct inode *inode = context->inode; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct inode *tl_inode = osb->osb_tl_inode; struct inode *gb_inode = NULL; struct buffer_head *gb_bh = NULL; struct buffer_head *gd_bh = NULL; struct ocfs2_group_desc *gd; struct ocfs2_refcount_tree *ref_tree = NULL; u32 move_max_hop = ocfs2_blocks_to_clusters(inode->i_sb, context->range->me_threshold); u64 phys_blkno, new_phys_blkno; phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); if ((ext_flags & OCFS2_EXT_REFCOUNTED) && len) { BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); BUG_ON(!context->refcount_loc); ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, &ref_tree, NULL); if (ret) { mlog_errno(ret); return ret; } ret = ocfs2_prepare_refcount_change_for_del(inode, context->refcount_loc, phys_blkno, len, &credits, &extra_blocks); if (ret) { mlog_errno(ret); goto out; } } ret = ocfs2_lock_allocators_move_extents(inode, &context->et, len, 1, &context->meta_ac, NULL, extra_blocks, &credits); if (ret) { mlog_errno(ret); goto out; } /* * need to count 2 extra credits for global_bitmap inode and * group descriptor. */ credits += OCFS2_INODE_UPDATE_CREDITS + 1; /* * ocfs2_move_extent() didn't reserve any clusters in lock_allocators() * logic, while we still need to lock the global_bitmap. */ gb_inode = ocfs2_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, OCFS2_INVALID_SLOT); if (!gb_inode) { mlog(ML_ERROR, "unable to get global_bitmap inode\n"); ret = -EIO; goto out; } mutex_lock(&gb_inode->i_mutex); ret = ocfs2_inode_lock(gb_inode, &gb_bh, 1); if (ret) { mlog_errno(ret); goto out_unlock_gb_mutex; } mutex_lock(&tl_inode->i_mutex); handle = ocfs2_start_trans(osb, credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); mlog_errno(ret); goto out_unlock_tl_inode; } new_phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, *new_phys_cpos); ret = ocfs2_find_victim_alloc_group(inode, new_phys_blkno, GLOBAL_BITMAP_SYSTEM_INODE, OCFS2_INVALID_SLOT, &goal_bit, &gd_bh); if (ret) { mlog_errno(ret); goto out_commit; } /* * probe the victim cluster group to find a proper * region to fit wanted movement, it even will perfrom * a best-effort attempt by compromising to a threshold * around the goal. */ ocfs2_probe_alloc_group(inode, gd_bh, &goal_bit, len, move_max_hop, new_phys_cpos); if (!new_phys_cpos) { ret = -ENOSPC; goto out_commit; } ret = __ocfs2_move_extent(handle, context, cpos, len, phys_cpos, *new_phys_cpos, ext_flags); if (ret) { mlog_errno(ret); goto out_commit; } gd = (struct ocfs2_group_desc *)gd_bh->b_data; ret = ocfs2_alloc_dinode_update_counts(gb_inode, handle, gb_bh, len, le16_to_cpu(gd->bg_chain)); if (ret) { mlog_errno(ret); goto out_commit; } ret = ocfs2_block_group_set_bits(handle, gb_inode, gd, gd_bh, goal_bit, len); if (ret) mlog_errno(ret); /* * Here we should write the new page out first if we are * in write-back mode. */ ret = ocfs2_cow_sync_writeback(inode->i_sb, context->inode, cpos, len); if (ret) mlog_errno(ret); out_commit: ocfs2_commit_trans(osb, handle); brelse(gd_bh); out_unlock_tl_inode: mutex_unlock(&tl_inode->i_mutex); ocfs2_inode_unlock(gb_inode, 1); out_unlock_gb_mutex: mutex_unlock(&gb_inode->i_mutex); brelse(gb_bh); iput(gb_inode); out: if (context->meta_ac) { ocfs2_free_alloc_context(context->meta_ac); context->meta_ac = NULL; } if (ref_tree) ocfs2_unlock_refcount_tree(osb, ref_tree, 1); return ret; } /* * Helper to calculate the defraging length in one run according to threshold. */ static void ocfs2_calc_extent_defrag_len(u32 *alloc_size, u32 *len_defraged, u32 threshold, int *skip) { if ((*alloc_size + *len_defraged) < threshold) { /* * proceed defragmentation until we meet the thresh */ *len_defraged += *alloc_size; } else if (*len_defraged == 0) { /* * XXX: skip a large extent. */ *skip = 1; } else { /* * split this extent to coalesce with former pieces as * to reach the threshold. * * we're done here with one cycle of defragmentation * in a size of 'thresh', resetting 'len_defraged' * forces a new defragmentation. */ *alloc_size = threshold - *len_defraged; *len_defraged = 0; } } static int __ocfs2_move_extents_range(struct buffer_head *di_bh, struct ocfs2_move_extents_context *context) { int ret = 0, flags, do_defrag, skip = 0; u32 cpos, phys_cpos, move_start, len_to_move, alloc_size; u32 len_defraged = 0, defrag_thresh = 0, new_phys_cpos = 0; struct inode *inode = context->inode; struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; struct ocfs2_move_extents *range = context->range; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); if ((inode->i_size == 0) || (range->me_len == 0)) return 0; if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) return 0; context->refcount_loc = le64_to_cpu(di->i_refcount_loc); ocfs2_init_dinode_extent_tree(&context->et, INODE_CACHE(inode), di_bh); ocfs2_init_dealloc_ctxt(&context->dealloc); /* * TO-DO XXX: * * - xattr extents. */ do_defrag = context->auto_defrag; /* * extents moving happens in unit of clusters, for the sake * of simplicity, we may ignore two clusters where 'byte_start' * and 'byte_start + len' were within. */ move_start = ocfs2_clusters_for_bytes(osb->sb, range->me_start); len_to_move = (range->me_start + range->me_len) >> osb->s_clustersize_bits; if (len_to_move >= move_start) len_to_move -= move_start; else len_to_move = 0; if (do_defrag) { defrag_thresh = range->me_threshold >> osb->s_clustersize_bits; if (defrag_thresh <= 1) goto done; } else new_phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, range->me_goal); mlog(0, "Inode: %llu, start: %llu, len: %llu, cstart: %u, clen: %u, " "thresh: %u\n", (unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)range->me_start, (unsigned long long)range->me_len, move_start, len_to_move, defrag_thresh); cpos = move_start; while (len_to_move) { ret = ocfs2_get_clusters(inode, cpos, &phys_cpos, &alloc_size, &flags); if (ret) { mlog_errno(ret); goto out; } if (alloc_size > len_to_move) alloc_size = len_to_move; /* * XXX: how to deal with a hole: * * - skip the hole of course * - force a new defragmentation */ if (!phys_cpos) { if (do_defrag) len_defraged = 0; goto next; } if (do_defrag) { ocfs2_calc_extent_defrag_len(&alloc_size, &len_defraged, defrag_thresh, &skip); /* * skip large extents */ if (skip) { skip = 0; goto next; } mlog(0, "#Defrag: cpos: %u, phys_cpos: %u, " "alloc_size: %u, len_defraged: %u\n", cpos, phys_cpos, alloc_size, len_defraged); ret = ocfs2_defrag_extent(context, cpos, phys_cpos, &alloc_size, flags); } else { ret = ocfs2_move_extent(context, cpos, phys_cpos, &new_phys_cpos, alloc_size, flags); new_phys_cpos += alloc_size; } if (ret < 0) { mlog_errno(ret); goto out; } context->clusters_moved += alloc_size; next: cpos += alloc_size; len_to_move -= alloc_size; } done: range->me_flags |= OCFS2_MOVE_EXT_FL_COMPLETE; out: range->me_moved_len = ocfs2_clusters_to_bytes(osb->sb, context->clusters_moved); range->me_new_offset = ocfs2_clusters_to_bytes(osb->sb, context->new_phys_cpos); ocfs2_schedule_truncate_log_flush(osb, 1); ocfs2_run_deallocs(osb, &context->dealloc); return ret; } static int ocfs2_move_extents(struct ocfs2_move_extents_context *context) { int status; handle_t *handle; struct inode *inode = context->inode; struct ocfs2_dinode *di; struct buffer_head *di_bh = NULL; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); if (!inode) return -ENOENT; if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) return -EROFS; mutex_lock(&inode->i_mutex); /* * This prevents concurrent writes from other nodes */ status = ocfs2_rw_lock(inode, 1); if (status) { mlog_errno(status); goto out; } status = ocfs2_inode_lock(inode, &di_bh, 1); if (status) { mlog_errno(status); goto out_rw_unlock; } /* * rememer ip_xattr_sem also needs to be held if necessary */ down_write(&OCFS2_I(inode)->ip_alloc_sem); status = __ocfs2_move_extents_range(di_bh, context); up_write(&OCFS2_I(inode)->ip_alloc_sem); if (status) { mlog_errno(status); goto out_inode_unlock; } /* * We update ctime for these changes */ handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); if (IS_ERR(handle)) { status = PTR_ERR(handle); mlog_errno(status); goto out_inode_unlock; } status = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (status) { mlog_errno(status); goto out_commit; } di = (struct ocfs2_dinode *)di_bh->b_data; inode->i_ctime = CURRENT_TIME; di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); ocfs2_journal_dirty(handle, di_bh); out_commit: ocfs2_commit_trans(osb, handle); out_inode_unlock: brelse(di_bh); ocfs2_inode_unlock(inode, 1); out_rw_unlock: ocfs2_rw_unlock(inode, 1); out: mutex_unlock(&inode->i_mutex); return status; } int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp) { int status; struct inode *inode = filp->f_path.dentry->d_inode; struct ocfs2_move_extents range; struct ocfs2_move_extents_context *context = NULL; status = mnt_want_write(filp->f_path.mnt); if (status) return status; if ((!S_ISREG(inode->i_mode)) || !(filp->f_mode & FMODE_WRITE)) goto out; if (inode->i_flags & (S_IMMUTABLE|S_APPEND)) { status = -EPERM; goto out; } context = kzalloc(sizeof(struct ocfs2_move_extents_context), GFP_NOFS); if (!context) { status = -ENOMEM; mlog_errno(status); goto out; } context->inode = inode; context->file = filp; if (argp) { if (copy_from_user(&range, (struct ocfs2_move_extents *)argp, sizeof(range))) { status = -EFAULT; goto out; } } else { status = -EINVAL; goto out; } if (range.me_start > i_size_read(inode)) goto out; if (range.me_start + range.me_len > i_size_read(inode)) range.me_len = i_size_read(inode) - range.me_start; context->range = &range; if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) { context->auto_defrag = 1; /* * ok, the default theshold for the defragmentation * is 1M, since our maximum clustersize was 1M also. * any thought? */ if (!range.me_threshold) range.me_threshold = 1024 * 1024; if (range.me_threshold > i_size_read(inode)) range.me_threshold = i_size_read(inode); if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG) context->partial = 1; } else { /* * first best-effort attempt to validate and adjust the goal * (physical address in block), while it can't guarantee later * operation can succeed all the time since global_bitmap may * change a bit over time. */ status = ocfs2_validate_and_adjust_move_goal(inode, &range); if (status) goto out; } status = ocfs2_move_extents(context); if (status) mlog_errno(status); out: /* * movement/defragmentation may end up being partially completed, * that's the reason why we need to return userspace the finished * length and new_offset even if failure happens somewhere. */ if (argp) { if (copy_to_user((struct ocfs2_move_extents *)argp, &range, sizeof(range))) status = -EFAULT; } kfree(context); mnt_drop_write(filp->f_path.mnt); return status; }
EPDCenter/android_kernel_odys_genio
fs/ocfs2/move_extents.c
C
gpl-2.0
27,910
/* * Copyright (C) 2001,2002,2003 Broadcom Corporation * * 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 <linux/sched.h> #include <asm/mipsregs.h> #include <asm/sibyte/sb1250.h> #include <asm/sibyte/sb1250_regs.h> #if !defined(CONFIG_SIBYTE_BUS_WATCHER) || defined(CONFIG_SIBYTE_BW_TRACE) #include <asm/io.h> #include <asm/sibyte/sb1250_scd.h> #endif /* * We'd like to dump the L2_ECC_TAG register on errors, but errata make * that unsafe... So for now we don't. (BCM1250/BCM112x erratum SOC-48.) */ #undef DUMP_L2_ECC_TAG_ON_ERROR /* SB1 definitions */ /* XXX should come from config1 XXX */ #define SB1_CACHE_INDEX_MASK 0x1fe0 #define CP0_ERRCTL_RECOVERABLE (1 << 31) #define CP0_ERRCTL_DCACHE (1 << 30) #define CP0_ERRCTL_ICACHE (1 << 29) #define CP0_ERRCTL_MULTIBUS (1 << 23) #define CP0_ERRCTL_MC_TLB (1 << 15) #define CP0_ERRCTL_MC_TIMEOUT (1 << 14) #define CP0_CERRI_TAG_PARITY (1 << 29) #define CP0_CERRI_DATA_PARITY (1 << 28) #define CP0_CERRI_EXTERNAL (1 << 26) #define CP0_CERRI_IDX_VALID(c) (!((c) & CP0_CERRI_EXTERNAL)) #define CP0_CERRI_DATA (CP0_CERRI_DATA_PARITY) #define CP0_CERRD_MULTIPLE (1 << 31) #define CP0_CERRD_TAG_STATE (1 << 30) #define CP0_CERRD_TAG_ADDRESS (1 << 29) #define CP0_CERRD_DATA_SBE (1 << 28) #define CP0_CERRD_DATA_DBE (1 << 27) #define CP0_CERRD_EXTERNAL (1 << 26) #define CP0_CERRD_LOAD (1 << 25) #define CP0_CERRD_STORE (1 << 24) #define CP0_CERRD_FILLWB (1 << 23) #define CP0_CERRD_COHERENCY (1 << 22) #define CP0_CERRD_DUPTAG (1 << 21) #define CP0_CERRD_DPA_VALID(c) (!((c) & CP0_CERRD_EXTERNAL)) #define CP0_CERRD_IDX_VALID(c) \ (((c) & (CP0_CERRD_LOAD | CP0_CERRD_STORE)) ? (!((c) & CP0_CERRD_EXTERNAL)) : 0) #define CP0_CERRD_CAUSES \ (CP0_CERRD_LOAD | CP0_CERRD_STORE | CP0_CERRD_FILLWB | CP0_CERRD_COHERENCY | CP0_CERRD_DUPTAG) #define CP0_CERRD_TYPES \ (CP0_CERRD_TAG_STATE | CP0_CERRD_TAG_ADDRESS | CP0_CERRD_DATA_SBE | CP0_CERRD_DATA_DBE | CP0_CERRD_EXTERNAL) #define CP0_CERRD_DATA (CP0_CERRD_DATA_SBE | CP0_CERRD_DATA_DBE) static uint32_t extract_ic(unsigned short addr, int data); static uint32_t extract_dc(unsigned short addr, int data); static inline void breakout_errctl(unsigned int val) { if (val & CP0_ERRCTL_RECOVERABLE) printk(" recoverable"); if (val & CP0_ERRCTL_DCACHE) printk(" dcache"); if (val & CP0_ERRCTL_ICACHE) printk(" icache"); if (val & CP0_ERRCTL_MULTIBUS) printk(" multiple-buserr"); printk("\n"); } static inline void breakout_cerri(unsigned int val) { if (val & CP0_CERRI_TAG_PARITY) printk(" tag-parity"); if (val & CP0_CERRI_DATA_PARITY) printk(" data-parity"); if (val & CP0_CERRI_EXTERNAL) printk(" external"); printk("\n"); } static inline void breakout_cerrd(unsigned int val) { switch (val & CP0_CERRD_CAUSES) { case CP0_CERRD_LOAD: printk(" load,"); break; case CP0_CERRD_STORE: printk(" store,"); break; case CP0_CERRD_FILLWB: printk(" fill/wb,"); break; case CP0_CERRD_COHERENCY: printk(" coherency,"); break; case CP0_CERRD_DUPTAG: printk(" duptags,"); break; default: printk(" NO CAUSE,"); break; } if (!(val & CP0_CERRD_TYPES)) printk(" NO TYPE"); else { if (val & CP0_CERRD_MULTIPLE) printk(" multi-err"); if (val & CP0_CERRD_TAG_STATE) printk(" tag-state"); if (val & CP0_CERRD_TAG_ADDRESS) printk(" tag-address"); if (val & CP0_CERRD_DATA_SBE) printk(" data-SBE"); if (val & CP0_CERRD_DATA_DBE) printk(" data-DBE"); if (val & CP0_CERRD_EXTERNAL) printk(" external"); } printk("\n"); } #ifndef CONFIG_SIBYTE_BUS_WATCHER static void check_bus_watcher(void) { uint32_t status, l2_err, memio_err; #ifdef DUMP_L2_ECC_TAG_ON_ERROR uint64_t l2_tag; #endif /* Destructive read, clears register and interrupt */ status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS)); /* Bit 31 is always on, but there's no #define for that */ if (status & ~(1UL << 31)) { l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS)); #ifdef DUMP_L2_ECC_TAG_ON_ERROR l2_tag = in64(IOADDR(A_L2_ECC_TAG)); #endif memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS)); printk("Bus watcher error counters: %08x %08x\n", l2_err, memio_err); printk("\nLast recorded signature:\n"); printk("Request %02x from %d, answered by %d with Dcode %d\n", (unsigned int)(G_SCD_BERR_TID(status) & 0x3f), (int)(G_SCD_BERR_TID(status) >> 6), (int)G_SCD_BERR_RID(status), (int)G_SCD_BERR_DCODE(status)); #ifdef DUMP_L2_ECC_TAG_ON_ERROR printk("Last L2 tag w/ bad ECC: %016llx\n", l2_tag); #endif } else { printk("Bus watcher indicates no error\n"); } } #else extern void check_bus_watcher(void); #endif asmlinkage void sb1_cache_error(void) { uint32_t errctl, cerr_i, cerr_d, dpalo, dpahi, eepc, res; unsigned long long cerr_dpa; #ifdef CONFIG_SIBYTE_BW_TRACE /* Freeze the trace buffer now */ csr_out32(M_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG)); printk("Trace buffer frozen\n"); #endif printk("Cache error exception on CPU %x:\n", (read_c0_prid() >> 25) & 0x7); __asm__ __volatile__ ( " .set push\n\t" " .set mips64\n\t" " .set noat\n\t" " mfc0 %0, $26\n\t" " mfc0 %1, $27\n\t" " mfc0 %2, $27, 1\n\t" " dmfc0 $1, $27, 3\n\t" " dsrl32 %3, $1, 0 \n\t" " sll %4, $1, 0 \n\t" " mfc0 %5, $30\n\t" " .set pop" : "=r" (errctl), "=r" (cerr_i), "=r" (cerr_d), "=r" (dpahi), "=r" (dpalo), "=r" (eepc)); cerr_dpa = (((uint64_t)dpahi) << 32) | dpalo; printk(" c0_errorepc == %08x\n", eepc); printk(" c0_errctl == %08x", errctl); breakout_errctl(errctl); if (errctl & CP0_ERRCTL_ICACHE) { printk(" c0_cerr_i == %08x", cerr_i); breakout_cerri(cerr_i); if (CP0_CERRI_IDX_VALID(cerr_i)) { /* Check index of EPC, allowing for delay slot */ if (((eepc & SB1_CACHE_INDEX_MASK) != (cerr_i & SB1_CACHE_INDEX_MASK)) && ((eepc & SB1_CACHE_INDEX_MASK) != ((cerr_i & SB1_CACHE_INDEX_MASK) - 4))) printk(" cerr_i idx doesn't match eepc\n"); else { res = extract_ic(cerr_i & SB1_CACHE_INDEX_MASK, (cerr_i & CP0_CERRI_DATA) != 0); if (!(res & cerr_i)) printk("...didn't see indicated icache problem\n"); } } } if (errctl & CP0_ERRCTL_DCACHE) { printk(" c0_cerr_d == %08x", cerr_d); breakout_cerrd(cerr_d); if (CP0_CERRD_DPA_VALID(cerr_d)) { printk(" c0_cerr_dpa == %010llx\n", cerr_dpa); if (!CP0_CERRD_IDX_VALID(cerr_d)) { res = extract_dc(cerr_dpa & SB1_CACHE_INDEX_MASK, (cerr_d & CP0_CERRD_DATA) != 0); if (!(res & cerr_d)) printk("...didn't see indicated dcache problem\n"); } else { if ((cerr_dpa & SB1_CACHE_INDEX_MASK) != (cerr_d & SB1_CACHE_INDEX_MASK)) printk(" cerr_d idx doesn't match cerr_dpa\n"); else { res = extract_dc(cerr_d & SB1_CACHE_INDEX_MASK, (cerr_d & CP0_CERRD_DATA) != 0); if (!(res & cerr_d)) printk("...didn't see indicated problem\n"); } } } } check_bus_watcher(); /* * Calling panic() when a fatal cache error occurs scrambles the * state of the system (and the cache), making it difficult to * investigate after the fact. However, if you just stall the CPU, * the other CPU may keep on running, which is typically very * undesirable. */ #ifdef CONFIG_SB1_CERR_STALL while (1) ; #else panic("unhandled cache error"); #endif } /* Parity lookup table. */ static const uint8_t parity[256] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; /* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */ static const uint64_t mask_72_64[8] = { 0x0738C808099264FFULL, 0x38C808099264FF07ULL, 0xC808099264FF0738ULL, 0x08099264FF0738C8ULL, 0x099264FF0738C808ULL, 0x9264FF0738C80809ULL, 0x64FF0738C8080992ULL, 0xFF0738C808099264ULL }; /* Calculate the parity on a range of bits */ static char range_parity(uint64_t dword, int max, int min) { char parity = 0; int i; dword >>= min; for (i=max-min; i>=0; i--) { if (dword & 0x1) parity = !parity; dword >>= 1; } return parity; } /* Calculate the 4-bit even byte-parity for an instruction */ static unsigned char inst_parity(uint32_t word) { int i, j; char parity = 0; for (j=0; j<4; j++) { char byte_parity = 0; for (i=0; i<8; i++) { if (word & 0x80000000) byte_parity = !byte_parity; word <<= 1; } parity <<= 1; parity |= byte_parity; } return parity; } static uint32_t extract_ic(unsigned short addr, int data) { unsigned short way; int valid; uint32_t taghi, taglolo, taglohi; unsigned long long taglo, va; uint64_t tlo_tmp; uint8_t lru; int res = 0; printk("Icache index 0x%04x ", addr); for (way = 0; way < 4; way++) { /* Index-load-tag-I */ __asm__ __volatile__ ( " .set push \n\t" " .set noreorder \n\t" " .set mips64 \n\t" " .set noat \n\t" " cache 4, 0(%3) \n\t" " mfc0 %0, $29 \n\t" " dmfc0 $1, $28 \n\t" " dsrl32 %1, $1, 0 \n\t" " sll %2, $1, 0 \n\t" " .set pop" : "=r" (taghi), "=r" (taglohi), "=r" (taglolo) : "r" ((way << 13) | addr)); taglo = ((unsigned long long)taglohi << 32) | taglolo; if (way == 0) { lru = (taghi >> 14) & 0xff; printk("[Bank %d Set 0x%02x] LRU > %d %d %d %d > MRU\n", ((addr >> 5) & 0x3), /* bank */ ((addr >> 7) & 0x3f), /* index */ (lru & 0x3), ((lru >> 2) & 0x3), ((lru >> 4) & 0x3), ((lru >> 6) & 0x3)); } va = (taglo & 0xC0000FFFFFFFE000ULL) | addr; if ((taglo & (1 << 31)) && (((taglo >> 62) & 0x3) == 3)) va |= 0x3FFFF00000000000ULL; valid = ((taghi >> 29) & 1); if (valid) { tlo_tmp = taglo & 0xfff3ff; if (((taglo >> 10) & 1) ^ range_parity(tlo_tmp, 23, 0)) { printk(" ** bad parity in VTag0/G/ASID\n"); res |= CP0_CERRI_TAG_PARITY; } if (((taglo >> 11) & 1) ^ range_parity(taglo, 63, 24)) { printk(" ** bad parity in R/VTag1\n"); res |= CP0_CERRI_TAG_PARITY; } } if (valid ^ ((taghi >> 27) & 1)) { printk(" ** bad parity for valid bit\n"); res |= CP0_CERRI_TAG_PARITY; } printk(" %d [VA %016llx] [Vld? %d] raw tags: %08X-%016llX\n", way, va, valid, taghi, taglo); if (data) { uint32_t datahi, insta, instb; uint8_t predecode; int offset; /* (hit all banks and ways) */ for (offset = 0; offset < 4; offset++) { /* Index-load-data-I */ __asm__ __volatile__ ( " .set push\n\t" " .set noreorder\n\t" " .set mips64\n\t" " .set noat\n\t" " cache 6, 0(%3) \n\t" " mfc0 %0, $29, 1\n\t" " dmfc0 $1, $28, 1\n\t" " dsrl32 %1, $1, 0 \n\t" " sll %2, $1, 0 \n\t" " .set pop \n" : "=r" (datahi), "=r" (insta), "=r" (instb) : "r" ((way << 13) | addr | (offset << 3))); predecode = (datahi >> 8) & 0xff; if (((datahi >> 16) & 1) != (uint32_t)range_parity(predecode, 7, 0)) { printk(" ** bad parity in predecode\n"); res |= CP0_CERRI_DATA_PARITY; } /* XXXKW should/could check predecode bits themselves */ if (((datahi >> 4) & 0xf) ^ inst_parity(insta)) { printk(" ** bad parity in instruction a\n"); res |= CP0_CERRI_DATA_PARITY; } if ((datahi & 0xf) ^ inst_parity(instb)) { printk(" ** bad parity in instruction b\n"); res |= CP0_CERRI_DATA_PARITY; } printk(" %05X-%08X%08X", datahi, insta, instb); } printk("\n"); } } return res; } /* Compute the ECC for a data doubleword */ static uint8_t dc_ecc(uint64_t dword) { uint64_t t; uint32_t w; uint8_t p; int i; p = 0; for (i = 7; i >= 0; i--) { p <<= 1; t = dword & mask_72_64[i]; w = (uint32_t)(t >> 32); p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF] ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]); w = (uint32_t)(t & 0xFFFFFFFF); p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF] ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]); } return p; } struct dc_state { unsigned char val; char *name; }; static struct dc_state dc_states[] = { { 0x00, "INVALID" }, { 0x0f, "COH-SHD" }, { 0x13, "NCO-E-C" }, { 0x19, "NCO-E-D" }, { 0x16, "COH-E-C" }, { 0x1c, "COH-E-D" }, { 0xff, "*ERROR*" } }; #define DC_TAG_VALID(state) \ (((state) == 0x0) || ((state) == 0xf) || ((state) == 0x13) || \ ((state) == 0x19) || ((state) == 0x16) || ((state) == 0x1c)) static char *dc_state_str(unsigned char state) { struct dc_state *dsc = dc_states; while (dsc->val != 0xff) { if (dsc->val == state) break; dsc++; } return dsc->name; } static uint32_t extract_dc(unsigned short addr, int data) { int valid, way; unsigned char state; uint32_t taghi, taglolo, taglohi; unsigned long long taglo, pa; uint8_t ecc, lru; int res = 0; printk("Dcache index 0x%04x ", addr); for (way = 0; way < 4; way++) { __asm__ __volatile__ ( " .set push\n\t" " .set noreorder\n\t" " .set mips64\n\t" " .set noat\n\t" " cache 5, 0(%3)\n\t" /* Index-load-tag-D */ " mfc0 %0, $29, 2\n\t" " dmfc0 $1, $28, 2\n\t" " dsrl32 %1, $1, 0\n\t" " sll %2, $1, 0\n\t" " .set pop" : "=r" (taghi), "=r" (taglohi), "=r" (taglolo) : "r" ((way << 13) | addr)); taglo = ((unsigned long long)taglohi << 32) | taglolo; pa = (taglo & 0xFFFFFFE000ULL) | addr; if (way == 0) { lru = (taghi >> 14) & 0xff; printk("[Bank %d Set 0x%02x] LRU > %d %d %d %d > MRU\n", ((addr >> 11) & 0x2) | ((addr >> 5) & 1), /* bank */ ((addr >> 6) & 0x3f), /* index */ (lru & 0x3), ((lru >> 2) & 0x3), ((lru >> 4) & 0x3), ((lru >> 6) & 0x3)); } state = (taghi >> 25) & 0x1f; valid = DC_TAG_VALID(state); printk(" %d [PA %010llx] [state %s (%02x)] raw tags: %08X-%016llX\n", way, pa, dc_state_str(state), state, taghi, taglo); if (valid) { if (((taglo >> 11) & 1) ^ range_parity(taglo, 39, 26)) { printk(" ** bad parity in PTag1\n"); res |= CP0_CERRD_TAG_ADDRESS; } if (((taglo >> 10) & 1) ^ range_parity(taglo, 25, 13)) { printk(" ** bad parity in PTag0\n"); res |= CP0_CERRD_TAG_ADDRESS; } } else { res |= CP0_CERRD_TAG_STATE; } if (data) { uint32_t datalohi, datalolo, datahi; unsigned long long datalo; int offset; char bad_ecc = 0; for (offset = 0; offset < 4; offset++) { /* Index-load-data-D */ __asm__ __volatile__ ( " .set push\n\t" " .set noreorder\n\t" " .set mips64\n\t" " .set noat\n\t" " cache 7, 0(%3)\n\t" /* Index-load-data-D */ " mfc0 %0, $29, 3\n\t" " dmfc0 $1, $28, 3\n\t" " dsrl32 %1, $1, 0 \n\t" " sll %2, $1, 0 \n\t" " .set pop" : "=r" (datahi), "=r" (datalohi), "=r" (datalolo) : "r" ((way << 13) | addr | (offset << 3))); datalo = ((unsigned long long)datalohi << 32) | datalolo; ecc = dc_ecc(datalo); if (ecc != datahi) { int bits; bad_ecc |= 1 << (3-offset); ecc ^= datahi; bits = hweight8(ecc); res |= (bits == 1) ? CP0_CERRD_DATA_SBE : CP0_CERRD_DATA_DBE; } printk(" %02X-%016llX", datahi, datalo); } printk("\n"); if (bad_ecc) printk(" dwords w/ bad ECC: %d %d %d %d\n", !!(bad_ecc & 8), !!(bad_ecc & 4), !!(bad_ecc & 2), !!(bad_ecc & 1)); } } return res; }
dchadic/linux-cmps107
arch/mips/mm/cerr-sb1.c
C
gpl-2.0
16,531
/* * Support for 'media5200-platform' compatible boards. * * Copyright (C) 2008 Secret Lab Technologies Ltd. * * 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. * * Description: * This code implements support for the Freescape Media5200 platform * (built around the MPC5200 SoC). * * Notable characteristic of the Media5200 is the presence of an FPGA * that has all external IRQ lines routed through it. This file implements * a cascaded interrupt controller driver which attaches itself to the * Virtual IRQ subsystem after the primary mpc5200 interrupt controller * is initialized. * */ #undef DEBUG #include <linux/irq.h> #include <linux/interrupt.h> #include <linux/io.h> #include <asm/time.h> #include <asm/prom.h> #include <asm/machdep.h> #include <asm/mpc52xx.h> static struct of_device_id mpc5200_gpio_ids[] __initdata = { { .compatible = "fsl,mpc5200-gpio", }, { .compatible = "mpc5200-gpio", }, {} }; /* FPGA register set */ #define MEDIA5200_IRQ_ENABLE (0x40c) #define MEDIA5200_IRQ_STATUS (0x410) #define MEDIA5200_NUM_IRQS (6) #define MEDIA5200_IRQ_SHIFT (32 - MEDIA5200_NUM_IRQS) struct media5200_irq { void __iomem *regs; spinlock_t lock; struct irq_domain *irqhost; }; struct media5200_irq media5200_irq; static void media5200_irq_unmask(struct irq_data *d) { unsigned long flags; u32 val; spin_lock_irqsave(&media5200_irq.lock, flags); val = in_be32(media5200_irq.regs + MEDIA5200_IRQ_ENABLE); val |= 1 << (MEDIA5200_IRQ_SHIFT + irqd_to_hwirq(d)); out_be32(media5200_irq.regs + MEDIA5200_IRQ_ENABLE, val); spin_unlock_irqrestore(&media5200_irq.lock, flags); } static void media5200_irq_mask(struct irq_data *d) { unsigned long flags; u32 val; spin_lock_irqsave(&media5200_irq.lock, flags); val = in_be32(media5200_irq.regs + MEDIA5200_IRQ_ENABLE); val &= ~(1 << (MEDIA5200_IRQ_SHIFT + irqd_to_hwirq(d))); out_be32(media5200_irq.regs + MEDIA5200_IRQ_ENABLE, val); spin_unlock_irqrestore(&media5200_irq.lock, flags); } static struct irq_chip media5200_irq_chip = { .name = "Media5200 FPGA", .irq_unmask = media5200_irq_unmask, .irq_mask = media5200_irq_mask, .irq_mask_ack = media5200_irq_mask, }; void media5200_irq_cascade(unsigned int virq, struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); int sub_virq, val; u32 status, enable; /* Mask off the cascaded IRQ */ raw_spin_lock(&desc->lock); chip->irq_mask(&desc->irq_data); raw_spin_unlock(&desc->lock); /* Ask the FPGA for IRQ status. If 'val' is 0, then no irqs * are pending. 'ffs()' is 1 based */ status = in_be32(media5200_irq.regs + MEDIA5200_IRQ_ENABLE); enable = in_be32(media5200_irq.regs + MEDIA5200_IRQ_STATUS); val = ffs((status & enable) >> MEDIA5200_IRQ_SHIFT); if (val) { sub_virq = irq_linear_revmap(media5200_irq.irqhost, val - 1); /* pr_debug("%s: virq=%i s=%.8x e=%.8x hwirq=%i subvirq=%i\n", * __func__, virq, status, enable, val - 1, sub_virq); */ generic_handle_irq(sub_virq); } /* Processing done; can reenable the cascade now */ raw_spin_lock(&desc->lock); chip->irq_ack(&desc->irq_data); if (!irqd_irq_disabled(&desc->irq_data)) chip->irq_unmask(&desc->irq_data); raw_spin_unlock(&desc->lock); } static int media5200_irq_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw) { pr_debug("%s: h=%p, virq=%i, hwirq=%i\n", __func__, h, virq, (int)hw); irq_set_chip_data(virq, &media5200_irq); irq_set_chip_and_handler(virq, &media5200_irq_chip, handle_level_irq); irq_set_status_flags(virq, IRQ_LEVEL); return 0; } static int media5200_irq_xlate(struct irq_domain *h, struct device_node *ct, const u32 *intspec, unsigned int intsize, irq_hw_number_t *out_hwirq, unsigned int *out_flags) { if (intsize != 2) return -1; pr_debug("%s: bank=%i, number=%i\n", __func__, intspec[0], intspec[1]); *out_hwirq = intspec[1]; *out_flags = IRQ_TYPE_NONE; return 0; } static const struct irq_domain_ops media5200_irq_ops = { .map = media5200_irq_map, .xlate = media5200_irq_xlate, }; /* * Setup Media5200 IRQ mapping */ static void __init media5200_init_irq(void) { struct device_node *fpga_np; int cascade_virq; /* First setup the regular MPC5200 interrupt controller */ mpc52xx_init_irq(); /* Now find the FPGA IRQ */ fpga_np = of_find_compatible_node(NULL, NULL, "fsl,media5200-fpga"); if (!fpga_np) goto out; pr_debug("%s: found fpga node: %s\n", __func__, fpga_np->full_name); media5200_irq.regs = of_iomap(fpga_np, 0); if (!media5200_irq.regs) goto out; pr_debug("%s: mapped to %p\n", __func__, media5200_irq.regs); cascade_virq = irq_of_parse_and_map(fpga_np, 0); if (!cascade_virq) goto out; pr_debug("%s: cascaded on virq=%i\n", __func__, cascade_virq); /* Disable all FPGA IRQs */ out_be32(media5200_irq.regs + MEDIA5200_IRQ_ENABLE, 0); spin_lock_init(&media5200_irq.lock); media5200_irq.irqhost = irq_domain_add_linear(fpga_np, MEDIA5200_NUM_IRQS, &media5200_irq_ops, &media5200_irq); if (!media5200_irq.irqhost) goto out; pr_debug("%s: allocated irqhost\n", __func__); irq_set_handler_data(cascade_virq, &media5200_irq); irq_set_chained_handler(cascade_virq, media5200_irq_cascade); return; out: pr_err("Could not find Media5200 FPGA; PCI interrupts will not work\n"); } /* * Setup the architecture */ static void __init media5200_setup_arch(void) { struct device_node *np; struct mpc52xx_gpio __iomem *gpio; u32 port_config; if (ppc_md.progress) ppc_md.progress("media5200_setup_arch()", 0); /* Map important registers from the internal memory map */ mpc52xx_map_common_devices(); /* Some mpc5200 & mpc5200b related configuration */ mpc5200_setup_xlb_arbiter(); mpc52xx_setup_pci(); np = of_find_matching_node(NULL, mpc5200_gpio_ids); gpio = of_iomap(np, 0); of_node_put(np); if (!gpio) { printk(KERN_ERR "%s() failed. expect abnormal behavior\n", __func__); return; } /* Set port config */ port_config = in_be32(&gpio->port_config); port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */ port_config |= 0x01000000; out_be32(&gpio->port_config, port_config); /* Unmap zone */ iounmap(gpio); } /* list of the supported boards */ static const char * const board[] __initconst = { "fsl,media5200", NULL }; /* * Called very early, MMU is off, device-tree isn't unflattened */ static int __init media5200_probe(void) { return of_flat_dt_match(of_get_flat_dt_root(), board); } define_machine(media5200_platform) { .name = "media5200-platform", .probe = media5200_probe, .setup_arch = media5200_setup_arch, .init = mpc52xx_declare_of_platform_devices, .init_IRQ = media5200_init_irq, .get_irq = mpc52xx_get_irq, .restart = mpc52xx_restart, .calibrate_decr = generic_calibrate_decr, };
mukulsoni/android_kernel_samsung_j700f
arch/powerpc/platforms/52xx/media5200.c
C
gpl-2.0
6,973
/* * security/tomoyo/common.c * * Securityfs interface for TOMOYO. * * Copyright (C) 2005-2010 NTT DATA CORPORATION */ #include <linux/security.h> #include "common.h" /** * tomoyo_open - open() for /sys/kernel/security/tomoyo/ interface. * * @inode: Pointer to "struct inode". * @file: Pointer to "struct file". * * Returns 0 on success, negative value otherwise. */ static int tomoyo_open(struct inode *inode, struct file *file) { const int key = ((u8 *) file->f_path.dentry->d_inode->i_private) - ((u8 *) NULL); return tomoyo_open_control(key, file); } /** * tomoyo_release - close() for /sys/kernel/security/tomoyo/ interface. * * @inode: Pointer to "struct inode". * @file: Pointer to "struct file". * * Returns 0 on success, negative value otherwise. */ static int tomoyo_release(struct inode *inode, struct file *file) { return tomoyo_close_control(file); } /** * tomoyo_poll - poll() for /proc/ccs/ interface. * * @file: Pointer to "struct file". * @wait: Pointer to "poll_table". * * Returns 0 on success, negative value otherwise. */ static unsigned int tomoyo_poll(struct file *file, poll_table *wait) { return tomoyo_poll_control(file, wait); } /** * tomoyo_read - read() for /sys/kernel/security/tomoyo/ interface. * * @file: Pointer to "struct file". * @buf: Pointer to buffer. * @count: Size of @buf. * @ppos: Unused. * * Returns bytes read on success, negative value otherwise. */ static ssize_t tomoyo_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { return tomoyo_read_control(file, buf, count); } /** * tomoyo_write - write() for /sys/kernel/security/tomoyo/ interface. * * @file: Pointer to "struct file". * @buf: Pointer to buffer. * @count: Size of @buf. * @ppos: Unused. * * Returns @count on success, negative value otherwise. */ static ssize_t tomoyo_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { return tomoyo_write_control(file, buf, count); } /* * tomoyo_operations is a "struct file_operations" which is used for handling * /sys/kernel/security/tomoyo/ interface. * * Some files under /sys/kernel/security/tomoyo/ directory accept open(O_RDWR). * See tomoyo_io_buffer for internals. */ static const struct file_operations tomoyo_operations = { .open = tomoyo_open, .release = tomoyo_release, .poll = tomoyo_poll, .read = tomoyo_read, .write = tomoyo_write, .llseek = noop_llseek, }; /** * tomoyo_create_entry - Create interface files under /sys/kernel/security/tomoyo/ directory. * * @name: The name of the interface file. * @mode: The permission of the interface file. * @parent: The parent directory. * @key: Type of interface. * * Returns nothing. */ static void __init tomoyo_create_entry(const char *name, const mode_t mode, struct dentry *parent, const u8 key) { securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key, &tomoyo_operations); } /** * tomoyo_initerface_init - Initialize /sys/kernel/security/tomoyo/ interface. * * Returns 0. */ static int __init tomoyo_initerface_init(void) { struct dentry *tomoyo_dir; /* Don't create securityfs entries unless registered. */ if (current_cred()->security != &tomoyo_kernel_domain) return 0; tomoyo_dir = securityfs_create_dir("tomoyo", NULL); tomoyo_create_entry("query", 0600, tomoyo_dir, TOMOYO_QUERY); tomoyo_create_entry("domain_policy", 0600, tomoyo_dir, TOMOYO_DOMAINPOLICY); tomoyo_create_entry("exception_policy", 0600, tomoyo_dir, TOMOYO_EXCEPTIONPOLICY); tomoyo_create_entry("self_domain", 0400, tomoyo_dir, TOMOYO_SELFDOMAIN); tomoyo_create_entry(".domain_status", 0600, tomoyo_dir, TOMOYO_DOMAIN_STATUS); tomoyo_create_entry(".process_status", 0600, tomoyo_dir, TOMOYO_PROCESS_STATUS); tomoyo_create_entry("meminfo", 0600, tomoyo_dir, TOMOYO_MEMINFO); tomoyo_create_entry("profile", 0600, tomoyo_dir, TOMOYO_PROFILE); tomoyo_create_entry("manager", 0600, tomoyo_dir, TOMOYO_MANAGER); tomoyo_create_entry("version", 0400, tomoyo_dir, TOMOYO_VERSION); return 0; } fs_initcall(tomoyo_initerface_init);
civato/A500ICS_StormFlex
security/tomoyo/securityfs_if.c
C
gpl-2.0
4,258
define( [ "./core", "./var/rnotwhite" ], function( jQuery, rnotwhite ) { // Convert String-formatted options into Object-formatted ones function createOptions( options ) { var object = {}; jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { object[ flag ] = true; } ); return object; } /* * Create a callback list using the following parameters: * * options: an optional list of space-separated options that will change how * the callback list behaves or a more traditional option object * * By default a callback list will act like an event callback list and can be * "fired" multiple times. * * Possible options: * * once: will ensure the callback list can only be fired once (like a Deferred) * * memory: will keep track of previous values and will call any callback added * after the list has been fired right away with the latest "memorized" * values (like a Deferred) * * unique: will ensure a callback can only be added once (no duplicate in the list) * * stopOnFalse: interrupt callings when a callback returns false * */ jQuery.Callbacks = function( options ) { // Convert options from String-formatted to Object-formatted if needed // (we check in cache first) options = typeof options === "string" ? createOptions( options ) : jQuery.extend( {}, options ); var // Flag to know if list is currently firing firing, // Last fire value for non-forgettable lists memory, // Flag to know if list was already fired fired, // Flag to prevent firing locked, // Actual callback list list = [], // Queue of execution data for repeatable lists queue = [], // Index of currently firing callback (modified by add/remove as needed) firingIndex = -1, // Fire callbacks fire = function() { // Enforce single-firing locked = options.once; // Execute callbacks for all pending executions, // respecting firingIndex overrides and runtime changes fired = firing = true; for ( ; queue.length; firingIndex = -1 ) { memory = queue.shift(); while ( ++firingIndex < list.length ) { // Run callback and check for early termination if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && options.stopOnFalse ) { // Jump to end and forget the data so .add doesn't re-fire firingIndex = list.length; memory = false; } } } // Forget the data if we're done with it if ( !options.memory ) { memory = false; } firing = false; // Clean up if we're done firing for good if ( locked ) { // Keep an empty list if we have data for future add calls if ( memory ) { list = []; // Otherwise, this object is spent } else { list = ""; } } }, // Actual Callbacks object self = { // Add a callback or a collection of callbacks to the list add: function() { if ( list ) { // If we have memory from a past run, we should fire after adding if ( memory && !firing ) { firingIndex = list.length - 1; queue.push( memory ); } ( function add( args ) { jQuery.each( args, function( _, arg ) { if ( jQuery.isFunction( arg ) ) { if ( !options.unique || !self.has( arg ) ) { list.push( arg ); } } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { // Inspect recursively add( arg ); } } ); } )( arguments ); if ( memory && !firing ) { fire(); } } return this; }, // Remove a callback from the list remove: function() { jQuery.each( arguments, function( _, arg ) { var index; while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { list.splice( index, 1 ); // Handle firing indexes if ( index <= firingIndex ) { firingIndex--; } } } ); return this; }, // Check if a given callback is in the list. // If no argument is given, return whether or not list has callbacks attached. has: function( fn ) { return fn ? jQuery.inArray( fn, list ) > -1 : list.length > 0; }, // Remove all callbacks from the list empty: function() { if ( list ) { list = []; } return this; }, // Disable .fire and .add // Abort any current/pending executions // Clear all callbacks and values disable: function() { locked = queue = []; list = memory = ""; return this; }, disabled: function() { return !list; }, // Disable .fire // Also disable .add unless we have memory (since it would have no effect) // Abort any pending executions lock: function() { locked = queue = []; if ( !memory ) { list = memory = ""; } return this; }, locked: function() { return !!locked; }, // Call all callbacks with the given context and arguments fireWith: function( context, args ) { if ( !locked ) { args = args || []; args = [ context, args.slice ? args.slice() : args ]; queue.push( args ); if ( !firing ) { fire(); } } return this; }, // Call all the callbacks with the given arguments fire: function() { self.fireWith( this, arguments ); return this; }, // To know if the callbacks have already been called at least once fired: function() { return !!fired; } }; return self; }; return jQuery; } );
aspirin1988/zan_zakon_site
wp-content/plugins/pp-gallery/bower_components/jquery/src/callbacks.js
JavaScript
gpl-2.0
5,457
/* * AD5446 SPI DAC driver * * Copyright 2010 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ #include <linux/interrupt.h> #include <linux/workqueue.h> #include <linux/device.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/sysfs.h> #include <linux/list.h> #include <linux/spi/spi.h> #include <linux/regulator/consumer.h> #include <linux/err.h> #include <linux/module.h> #include "../iio.h" #include "../sysfs.h" #include "dac.h" #include "ad5446.h" static void ad5446_store_sample(struct ad5446_state *st, unsigned val) { st->data.d16 = cpu_to_be16(AD5446_LOAD | val); } static void ad5542_store_sample(struct ad5446_state *st, unsigned val) { st->data.d16 = cpu_to_be16(val); } static void ad5620_store_sample(struct ad5446_state *st, unsigned val) { st->data.d16 = cpu_to_be16(AD5620_LOAD | val); } static void ad5660_store_sample(struct ad5446_state *st, unsigned val) { val |= AD5660_LOAD; st->data.d24[0] = (val >> 16) & 0xFF; st->data.d24[1] = (val >> 8) & 0xFF; st->data.d24[2] = val & 0xFF; } static void ad5620_store_pwr_down(struct ad5446_state *st, unsigned mode) { st->data.d16 = cpu_to_be16(mode << 14); } static void ad5660_store_pwr_down(struct ad5446_state *st, unsigned mode) { unsigned val = mode << 16; st->data.d24[0] = (val >> 16) & 0xFF; st->data.d24[1] = (val >> 8) & 0xFF; st->data.d24[2] = val & 0xFF; } static ssize_t ad5446_write_powerdown_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad5446_state *st = iio_priv(indio_dev); if (sysfs_streq(buf, "1kohm_to_gnd")) st->pwr_down_mode = MODE_PWRDWN_1k; else if (sysfs_streq(buf, "100kohm_to_gnd")) st->pwr_down_mode = MODE_PWRDWN_100k; else if (sysfs_streq(buf, "three_state")) st->pwr_down_mode = MODE_PWRDWN_TRISTATE; else return -EINVAL; return len; } static ssize_t ad5446_read_powerdown_mode(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad5446_state *st = iio_priv(indio_dev); char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"}; return sprintf(buf, "%s\n", mode[st->pwr_down_mode]); } static ssize_t ad5446_read_dac_powerdown(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad5446_state *st = iio_priv(indio_dev); return sprintf(buf, "%d\n", st->pwr_down); } static ssize_t ad5446_write_dac_powerdown(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad5446_state *st = iio_priv(indio_dev); unsigned long readin; int ret; ret = strict_strtol(buf, 10, &readin); if (ret) return ret; if (readin > 1) ret = -EINVAL; mutex_lock(&indio_dev->mlock); st->pwr_down = readin; if (st->pwr_down) st->chip_info->store_pwr_down(st, st->pwr_down_mode); else st->chip_info->store_sample(st, st->cached_val); ret = spi_sync(st->spi, &st->msg); mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR, ad5446_read_powerdown_mode, ad5446_write_powerdown_mode, 0); static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, "1kohm_to_gnd 100kohm_to_gnd three_state"); static IIO_DEVICE_ATTR(out_voltage0_powerdown, S_IRUGO | S_IWUSR, ad5446_read_dac_powerdown, ad5446_write_dac_powerdown, 0); static struct attribute *ad5446_attributes[] = { &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, NULL, }; static const struct attribute_group ad5446_attribute_group = { .attrs = ad5446_attributes, }; #define AD5446_CHANNEL(bits, storage, shift) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .output = 1, \ .channel = 0, \ .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \ .scan_type = IIO_ST('u', (bits), (storage), (shift)) \ } static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { [ID_AD5444] = { .channel = AD5446_CHANNEL(12, 16, 2), .store_sample = ad5446_store_sample, }, [ID_AD5446] = { .channel = AD5446_CHANNEL(14, 16, 0), .store_sample = ad5446_store_sample, }, [ID_AD5541A] = { .channel = AD5446_CHANNEL(16, 16, 0), .store_sample = ad5542_store_sample, }, [ID_AD5542A] = { .channel = AD5446_CHANNEL(16, 16, 0), .store_sample = ad5542_store_sample, }, [ID_AD5543] = { .channel = AD5446_CHANNEL(16, 16, 0), .store_sample = ad5542_store_sample, }, [ID_AD5512A] = { .channel = AD5446_CHANNEL(12, 16, 4), .store_sample = ad5542_store_sample, }, [ID_AD5553] = { .channel = AD5446_CHANNEL(14, 16, 0), .store_sample = ad5542_store_sample, }, [ID_AD5601] = { .channel = AD5446_CHANNEL(8, 16, 6), .store_sample = ad5542_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5611] = { .channel = AD5446_CHANNEL(10, 16, 4), .store_sample = ad5542_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5621] = { .channel = AD5446_CHANNEL(12, 16, 2), .store_sample = ad5542_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5620_2500] = { .channel = AD5446_CHANNEL(12, 16, 2), .int_vref_mv = 2500, .store_sample = ad5620_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5620_1250] = { .channel = AD5446_CHANNEL(12, 16, 2), .int_vref_mv = 1250, .store_sample = ad5620_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5640_2500] = { .channel = AD5446_CHANNEL(14, 16, 0), .int_vref_mv = 2500, .store_sample = ad5620_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5640_1250] = { .channel = AD5446_CHANNEL(14, 16, 0), .int_vref_mv = 1250, .store_sample = ad5620_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5660_2500] = { .channel = AD5446_CHANNEL(16, 16, 0), .int_vref_mv = 2500, .store_sample = ad5660_store_sample, .store_pwr_down = ad5660_store_pwr_down, }, [ID_AD5660_1250] = { .channel = AD5446_CHANNEL(16, 16, 0), .int_vref_mv = 1250, .store_sample = ad5660_store_sample, .store_pwr_down = ad5660_store_pwr_down, }, }; static int ad5446_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { struct ad5446_state *st = iio_priv(indio_dev); unsigned long scale_uv; switch (m) { case IIO_CHAN_INFO_SCALE: scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits; *val = scale_uv / 1000; *val2 = (scale_uv % 1000) * 1000; return IIO_VAL_INT_PLUS_MICRO; } return -EINVAL; } static int ad5446_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { struct ad5446_state *st = iio_priv(indio_dev); int ret; switch (mask) { case 0: if (val >= (1 << chan->scan_type.realbits) || val < 0) return -EINVAL; val <<= chan->scan_type.shift; mutex_lock(&indio_dev->mlock); st->cached_val = val; st->chip_info->store_sample(st, val); ret = spi_sync(st->spi, &st->msg); mutex_unlock(&indio_dev->mlock); break; default: ret = -EINVAL; } return ret; } static const struct iio_info ad5446_info = { .read_raw = ad5446_read_raw, .write_raw = ad5446_write_raw, .attrs = &ad5446_attribute_group, .driver_module = THIS_MODULE, }; static const struct iio_info ad5446_info_no_pwr_down = { .read_raw = ad5446_read_raw, .write_raw = ad5446_write_raw, .driver_module = THIS_MODULE, }; static int __devinit ad5446_probe(struct spi_device *spi) { struct ad5446_state *st; struct iio_dev *indio_dev; struct regulator *reg; int ret, voltage_uv = 0; reg = regulator_get(&spi->dev, "vcc"); if (!IS_ERR(reg)) { ret = regulator_enable(reg); if (ret) goto error_put_reg; voltage_uv = regulator_get_voltage(reg); } indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { ret = -ENOMEM; goto error_disable_reg; } st = iio_priv(indio_dev); st->chip_info = &ad5446_chip_info_tbl[spi_get_device_id(spi)->driver_data]; spi_set_drvdata(spi, indio_dev); st->reg = reg; st->spi = spi; /* Establish that the iio_dev is a child of the spi device */ indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; if (st->chip_info->store_pwr_down) indio_dev->info = &ad5446_info; else indio_dev->info = &ad5446_info_no_pwr_down; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels = 1; /* Setup default message */ st->xfer.tx_buf = &st->data; st->xfer.len = st->chip_info->channel.scan_type.storagebits / 8; spi_message_init(&st->msg); spi_message_add_tail(&st->xfer, &st->msg); switch (spi_get_device_id(spi)->driver_data) { case ID_AD5620_2500: case ID_AD5620_1250: case ID_AD5640_2500: case ID_AD5640_1250: case ID_AD5660_2500: case ID_AD5660_1250: st->vref_mv = st->chip_info->int_vref_mv; break; default: if (voltage_uv) st->vref_mv = voltage_uv / 1000; else dev_warn(&spi->dev, "reference voltage unspecified\n"); } ret = iio_device_register(indio_dev); if (ret) goto error_free_device; return 0; error_free_device: iio_free_device(indio_dev); error_disable_reg: if (!IS_ERR(reg)) regulator_disable(reg); error_put_reg: if (!IS_ERR(reg)) regulator_put(reg); return ret; } static int ad5446_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad5446_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } iio_free_device(indio_dev); return 0; } static const struct spi_device_id ad5446_id[] = { {"ad5444", ID_AD5444}, {"ad5446", ID_AD5446}, {"ad5512a", ID_AD5512A}, {"ad5541a", ID_AD5541A}, {"ad5542a", ID_AD5542A}, {"ad5543", ID_AD5543}, {"ad5553", ID_AD5553}, {"ad5601", ID_AD5601}, {"ad5611", ID_AD5611}, {"ad5621", ID_AD5621}, {"ad5620-2500", ID_AD5620_2500}, /* AD5620/40/60: */ {"ad5620-1250", ID_AD5620_1250}, /* part numbers may look differently */ {"ad5640-2500", ID_AD5640_2500}, {"ad5640-1250", ID_AD5640_1250}, {"ad5660-2500", ID_AD5660_2500}, {"ad5660-1250", ID_AD5660_1250}, {} }; MODULE_DEVICE_TABLE(spi, ad5446_id); static struct spi_driver ad5446_driver = { .driver = { .name = "ad5446", .owner = THIS_MODULE, }, .probe = ad5446_probe, .remove = __devexit_p(ad5446_remove), .id_table = ad5446_id, }; module_spi_driver(ad5446_driver); MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); MODULE_DESCRIPTION("Analog Devices AD5444/AD5446 DAC"); MODULE_LICENSE("GPL v2");
xXminiWHOOPERxX/xXminiWHOOPERxX-Kernel-for-M4-MLG-
drivers/staging/iio/dac/ad5446.c
C
gpl-2.0
10,900
/* * Copyright (C) ST-Ericsson SA 2010 * Author: Stefan Nilsson <stefan.xk.nilsson@stericsson.com> for ST-Ericsson. * Author: Martin Persson <martin.persson@stericsson.com> for ST-Ericsson. * License terms: GNU General Public License (GPL), version 2. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/irq.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/slab.h> #include <mach/id.h> #define MODEM_INTCON_BASE_ADDR 0xBFFD3000 #define MODEM_INTCON_SIZE 0xFFF #define DEST_IRQ41_OFFSET 0x2A4 #define DEST_IRQ43_OFFSET 0x2AC #define DEST_IRQ45_OFFSET 0x2B4 #define PRIO_IRQ41_OFFSET 0x6A4 #define PRIO_IRQ43_OFFSET 0x6AC #define PRIO_IRQ45_OFFSET 0x6B4 #define ALLOW_IRQ_OFFSET 0x104 #define MODEM_INTCON_CPU_NBR 0x1 #define MODEM_INTCON_PRIO_HIGH 0x0 #define MODEM_INTCON_ALLOW_IRQ41 0x0200 #define MODEM_INTCON_ALLOW_IRQ43 0x0800 #define MODEM_INTCON_ALLOW_IRQ45 0x2000 #define MODEM_IRQ_REG_OFFSET 0x4 struct modem_irq { void __iomem *modem_intcon_base; }; static void setup_modem_intcon(void __iomem *modem_intcon_base) { /* IC_DESTINATION_BASE_ARRAY - Which CPU to receive the IRQ */ writel(MODEM_INTCON_CPU_NBR, modem_intcon_base + DEST_IRQ41_OFFSET); writel(MODEM_INTCON_CPU_NBR, modem_intcon_base + DEST_IRQ43_OFFSET); writel(MODEM_INTCON_CPU_NBR, modem_intcon_base + DEST_IRQ45_OFFSET); /* IC_PRIORITY_BASE_ARRAY - IRQ priority in modem IRQ controller */ writel(MODEM_INTCON_PRIO_HIGH, modem_intcon_base + PRIO_IRQ41_OFFSET); writel(MODEM_INTCON_PRIO_HIGH, modem_intcon_base + PRIO_IRQ43_OFFSET); writel(MODEM_INTCON_PRIO_HIGH, modem_intcon_base + PRIO_IRQ45_OFFSET); /* IC_ALLOW_ARRAY - IRQ enable */ writel(MODEM_INTCON_ALLOW_IRQ41 | MODEM_INTCON_ALLOW_IRQ43 | MODEM_INTCON_ALLOW_IRQ45, modem_intcon_base + ALLOW_IRQ_OFFSET); } static irqreturn_t modem_cpu_irq_handler(int irq, void *data) { int real_irq; int virt_irq; struct modem_irq *mi = (struct modem_irq *)data; /* Read modem side IRQ number from modem IRQ controller */ real_irq = readl(mi->modem_intcon_base + MODEM_IRQ_REG_OFFSET) & 0xFF; virt_irq = IRQ_MODEM_EVENTS_BASE + real_irq; pr_debug("modem_irq: Worker read addr 0x%X and got value 0x%X " "which will be 0x%X (%d) which translates to " "virtual IRQ 0x%X (%d)!\n", (u32)mi->modem_intcon_base + MODEM_IRQ_REG_OFFSET, real_irq, real_irq & 0xFF, real_irq & 0xFF, virt_irq, virt_irq); if (virt_irq != 0) generic_handle_irq(virt_irq); pr_debug("modem_irq: Done handling virtual IRQ %d!\n", virt_irq); return IRQ_HANDLED; } static void create_virtual_irq(int irq, struct irq_chip *modem_irq_chip) { irq_set_chip_and_handler(irq, modem_irq_chip, handle_simple_irq); set_irq_flags(irq, IRQF_VALID); pr_debug("modem_irq: Created virtual IRQ %d\n", irq); } static int modem_irq_init(void) { int err; static struct irq_chip modem_irq_chip; struct modem_irq *mi; if (!cpu_is_u5500()) return -ENODEV; pr_info("modem_irq: Set up IRQ handler for incoming modem IRQ %d\n", IRQ_DB5500_MODEM); mi = kmalloc(sizeof(struct modem_irq), GFP_KERNEL); if (!mi) { pr_err("modem_irq: Could not allocate device\n"); return -ENOMEM; } mi->modem_intcon_base = ioremap(MODEM_INTCON_BASE_ADDR, MODEM_INTCON_SIZE); pr_debug("modem_irq: ioremapped modem_intcon_base from " "phy 0x%x to virt 0x%x\n", MODEM_INTCON_BASE_ADDR, (u32)mi->modem_intcon_base); setup_modem_intcon(mi->modem_intcon_base); modem_irq_chip = dummy_irq_chip; modem_irq_chip.name = "modem_irq"; /* Create the virtual IRQ:s needed */ create_virtual_irq(MBOX_PAIR0_VIRT_IRQ, &modem_irq_chip); create_virtual_irq(MBOX_PAIR1_VIRT_IRQ, &modem_irq_chip); create_virtual_irq(MBOX_PAIR2_VIRT_IRQ, &modem_irq_chip); err = request_threaded_irq(IRQ_DB5500_MODEM, NULL, modem_cpu_irq_handler, IRQF_ONESHOT, "modem_irq", mi); if (err) pr_err("modem_irq: Could not register IRQ %d\n", IRQ_DB5500_MODEM); return 0; } arch_initcall(modem_irq_init);
mlongob/Linux-Kernel-Hack
arch/arm/mach-ux500/modem-irq-db5500.c
C
gpl-2.0
4,017
/** * @file * Stylesheet for the Dashboard module. */ #dashboard div.dashboard-region { float: left; min-height: 1px; } #dashboard div#dashboard_main { width: 65%; margin-right: 1%; /* LTR */ } #dashboard div#dashboard_sidebar { width: 33%; } #dashboard div.block { margin-bottom: 20px; } #dashboard .dashboard-region .block { clear: both; } #dashboard div.block h2 { float: none; } #dashboard #disabled-blocks .block, #dashboard .block-placeholder { background: #e2e1dc; padding: 6px 4px 6px 8px; /* LTR */ margin: 3px 3px 3px 0; /* LTR */ float: left; /* LTR */ -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } #dashboard .dashboard-add-other-blocks { margin: 10px 0 0 0; } #dashboard .ui-sortable { border: 2px dashed #ccc; padding: 10px; } #dashboard .canvas-content { padding: 10px; } #dashboard #disabled-blocks .ui-sortable { padding: 0; background-color: #777; border: 0; } #dashboard .canvas-content a.button { margin: 0 0 0 10px; /* LTR */ color: #5a5a5a; text-decoration: none; } #dashboard .region { margin: 5px; } #dashboard #disabled-blocks .region { background-color: #E0E0D8; border: #ccc 1px solid; padding: 10px; } #dashboard #disabled-blocks { padding: 5px 0; } #dashboard #disabled-blocks h2 { display: inline; font-weight: normal; white-space: nowrap; } #dashboard #disabled-blocks .block { background: #444; color: #fff; } #dashboard.customize-inactive #disabled-blocks .block:hover { background: #0074BD; } #dashboard #disabled-blocks .block .content, #dashboard .ui-sortable-helper .content { display: none; } #dashboard .ui-sortable .block { cursor: move; min-height: 1px; } #dashboard .ui-sortable .block h2 { background: transparent url(../../misc/draggable.png) no-repeat 0px -39px; padding: 0 17px; } #dashboard.customize-inactive #disabled-blocks .block:hover h2 { background: #0074BD url(../../misc/draggable.png) no-repeat 0px -39px; color: #fff; } #dashboard.customize-inactive .dashboard-region .ui-sortable .block:hover h2 { background: #0074BD url(../../misc/draggable.png) no-repeat; background-position: 3px -36px; color: #fff; } #dashboard .dashboard-region .block-placeholder { margin: 0 0 20px 0; padding: 0; display: block; height: 1.6em; width: 100%; } #dashboard #disabled-blocks .block-placeholder { width: 30px; height: 1.6em; }
broekhuisgavin/voorwaarts10-nl
modules/dashboard/dashboard.css
CSS
gpl-2.0
2,435
/* via_irq.c * * Copyright 2004 BEAM Ltd. * Copyright 2002 Tungsten Graphics, Inc. * Copyright 2005 Thomas Hellstrom. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BEAM LTD, TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Terry Barnaby <terry1@beam.ltd.uk> * Keith Whitwell <keith@tungstengraphics.com> * Thomas Hellstrom <unichrome@shipmail.org> * * This code provides standard DRM access to the Via Unichrome / Pro Vertical blank * interrupt, as well as an infrastructure to handle other interrupts of the chip. * The refresh rate is also calculated for video playback sync purposes. */ #include "drmP.h" #include "drm.h" #include "via_drm.h" #include "via_drv.h" #define VIA_REG_INTERRUPT 0x200 /* VIA_REG_INTERRUPT */ #define VIA_IRQ_GLOBAL (1 << 31) #define VIA_IRQ_VBLANK_ENABLE (1 << 19) #define VIA_IRQ_VBLANK_PENDING (1 << 3) #define VIA_IRQ_HQV0_ENABLE (1 << 11) #define VIA_IRQ_HQV1_ENABLE (1 << 25) #define VIA_IRQ_HQV0_PENDING (1 << 9) #define VIA_IRQ_HQV1_PENDING (1 << 10) #define VIA_IRQ_DMA0_DD_ENABLE (1 << 20) #define VIA_IRQ_DMA0_TD_ENABLE (1 << 21) #define VIA_IRQ_DMA1_DD_ENABLE (1 << 22) #define VIA_IRQ_DMA1_TD_ENABLE (1 << 23) #define VIA_IRQ_DMA0_DD_PENDING (1 << 4) #define VIA_IRQ_DMA0_TD_PENDING (1 << 5) #define VIA_IRQ_DMA1_DD_PENDING (1 << 6) #define VIA_IRQ_DMA1_TD_PENDING (1 << 7) /* * Device-specific IRQs go here. This type might need to be extended with * the register if there are multiple IRQ control registers. * Currently we activate the HQV interrupts of Unichrome Pro group A. */ static maskarray_t via_pro_group_a_irqs[] = { {VIA_IRQ_HQV0_ENABLE, VIA_IRQ_HQV0_PENDING, 0x000003D0, 0x00008010, 0x00000000 }, {VIA_IRQ_HQV1_ENABLE, VIA_IRQ_HQV1_PENDING, 0x000013D0, 0x00008010, 0x00000000 }, {VIA_IRQ_DMA0_TD_ENABLE, VIA_IRQ_DMA0_TD_PENDING, VIA_PCI_DMA_CSR0, VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}, {VIA_IRQ_DMA1_TD_ENABLE, VIA_IRQ_DMA1_TD_PENDING, VIA_PCI_DMA_CSR1, VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}, }; static int via_num_pro_group_a = ARRAY_SIZE(via_pro_group_a_irqs); static int via_irqmap_pro_group_a[] = {0, 1, -1, 2, -1, 3}; static maskarray_t via_unichrome_irqs[] = { {VIA_IRQ_DMA0_TD_ENABLE, VIA_IRQ_DMA0_TD_PENDING, VIA_PCI_DMA_CSR0, VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}, {VIA_IRQ_DMA1_TD_ENABLE, VIA_IRQ_DMA1_TD_PENDING, VIA_PCI_DMA_CSR1, VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008} }; static int via_num_unichrome = ARRAY_SIZE(via_unichrome_irqs); static int via_irqmap_unichrome[] = {-1, -1, -1, 0, -1, 1}; static unsigned time_diff(struct timeval *now, struct timeval *then) { return (now->tv_usec >= then->tv_usec) ? now->tv_usec - then->tv_usec : 1000000 - (then->tv_usec - now->tv_usec); } u32 via_get_vblank_counter(struct drm_device *dev, int crtc) { drm_via_private_t *dev_priv = dev->dev_private; if (crtc != 0) return 0; return atomic_read(&dev_priv->vbl_received); } irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; u32 status; int handled = 0; struct timeval cur_vblank; drm_via_irq_t *cur_irq = dev_priv->via_irqs; int i; status = VIA_READ(VIA_REG_INTERRUPT); if (status & VIA_IRQ_VBLANK_PENDING) { atomic_inc(&dev_priv->vbl_received); if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) { do_gettimeofday(&cur_vblank); if (dev_priv->last_vblank_valid) { dev_priv->usec_per_vblank = time_diff(&cur_vblank, &dev_priv->last_vblank) >> 4; } dev_priv->last_vblank = cur_vblank; dev_priv->last_vblank_valid = 1; } if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) { DRM_DEBUG("US per vblank is: %u\n", dev_priv->usec_per_vblank); } drm_handle_vblank(dev, 0); handled = 1; } for (i = 0; i < dev_priv->num_irqs; ++i) { if (status & cur_irq->pending_mask) { atomic_inc(&cur_irq->irq_received); DRM_WAKEUP(&cur_irq->irq_queue); handled = 1; if (dev_priv->irq_map[drm_via_irq_dma0_td] == i) via_dmablit_handler(dev, 0, 1); else if (dev_priv->irq_map[drm_via_irq_dma1_td] == i) via_dmablit_handler(dev, 1, 1); } cur_irq++; } /* Acknowledge interrupts */ VIA_WRITE(VIA_REG_INTERRUPT, status); if (handled) return IRQ_HANDLED; else return IRQ_NONE; } static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t *dev_priv) { u32 status; if (dev_priv) { /* Acknowledge interrupts */ status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status | dev_priv->irq_pending_mask); } } int via_enable_vblank(struct drm_device *dev, int crtc) { drm_via_private_t *dev_priv = dev->dev_private; u32 status; if (crtc != 0) { DRM_ERROR("%s: bad crtc %d\n", __func__, crtc); return -EINVAL; } status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_VBLANK_ENABLE); VIA_WRITE8(0x83d4, 0x11); VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) | 0x30); return 0; } void via_disable_vblank(struct drm_device *dev, int crtc) { drm_via_private_t *dev_priv = dev->dev_private; u32 status; status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status & ~VIA_IRQ_VBLANK_ENABLE); VIA_WRITE8(0x83d4, 0x11); VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30); if (crtc != 0) DRM_ERROR("%s: bad crtc %d\n", __func__, crtc); } static int via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence, unsigned int *sequence) { drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; unsigned int cur_irq_sequence; drm_via_irq_t *cur_irq; int ret = 0; maskarray_t *masks; int real_irq; DRM_DEBUG("\n"); if (!dev_priv) { DRM_ERROR("called with no initialization\n"); return -EINVAL; } if (irq >= drm_via_irq_num) { DRM_ERROR("Trying to wait on unknown irq %d\n", irq); return -EINVAL; } real_irq = dev_priv->irq_map[irq]; if (real_irq < 0) { DRM_ERROR("Video IRQ %d not available on this hardware.\n", irq); return -EINVAL; } masks = dev_priv->irq_masks; cur_irq = dev_priv->via_irqs + real_irq; if (masks[real_irq][2] && !force_sequence) { DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, ((VIA_READ(masks[irq][2]) & masks[irq][3]) == masks[irq][4])); cur_irq_sequence = atomic_read(&cur_irq->irq_received); } else { DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, (((cur_irq_sequence = atomic_read(&cur_irq->irq_received)) - *sequence) <= (1 << 23))); } *sequence = cur_irq_sequence; return ret; } /* * drm_dma.h hooks */ void via_driver_irq_preinstall(struct drm_device *dev) { drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; u32 status; drm_via_irq_t *cur_irq; int i; DRM_DEBUG("dev_priv: %p\n", dev_priv); if (dev_priv) { cur_irq = dev_priv->via_irqs; dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE; dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING; if (dev_priv->chipset == VIA_PRO_GROUP_A || dev_priv->chipset == VIA_DX9_0) { dev_priv->irq_masks = via_pro_group_a_irqs; dev_priv->num_irqs = via_num_pro_group_a; dev_priv->irq_map = via_irqmap_pro_group_a; } else { dev_priv->irq_masks = via_unichrome_irqs; dev_priv->num_irqs = via_num_unichrome; dev_priv->irq_map = via_irqmap_unichrome; } for (i = 0; i < dev_priv->num_irqs; ++i) { atomic_set(&cur_irq->irq_received, 0); cur_irq->enable_mask = dev_priv->irq_masks[i][0]; cur_irq->pending_mask = dev_priv->irq_masks[i][1]; DRM_INIT_WAITQUEUE(&cur_irq->irq_queue); dev_priv->irq_enable_mask |= cur_irq->enable_mask; dev_priv->irq_pending_mask |= cur_irq->pending_mask; cur_irq++; DRM_DEBUG("Initializing IRQ %d\n", i); } dev_priv->last_vblank_valid = 0; /* Clear VSync interrupt regs */ status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status & ~(dev_priv->irq_enable_mask)); /* Clear bits if they're already high */ viadrv_acknowledge_irqs(dev_priv); } } int via_driver_irq_postinstall(struct drm_device *dev) { drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; u32 status; DRM_DEBUG("via_driver_irq_postinstall\n"); if (!dev_priv) return -EINVAL; status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL | dev_priv->irq_enable_mask); /* Some magic, oh for some data sheets ! */ VIA_WRITE8(0x83d4, 0x11); VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) | 0x30); return 0; } void via_driver_irq_uninstall(struct drm_device *dev) { drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; u32 status; DRM_DEBUG("\n"); if (dev_priv) { /* Some more magic, oh for some data sheets ! */ VIA_WRITE8(0x83d4, 0x11); VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30); status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status & ~(VIA_IRQ_VBLANK_ENABLE | dev_priv->irq_enable_mask)); } } int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_via_irqwait_t *irqwait = data; struct timeval now; int ret = 0; drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; drm_via_irq_t *cur_irq = dev_priv->via_irqs; int force_sequence; if (irqwait->request.irq >= dev_priv->num_irqs) { DRM_ERROR("Trying to wait on unknown irq %d\n", irqwait->request.irq); return -EINVAL; } cur_irq += irqwait->request.irq; switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) { case VIA_IRQ_RELATIVE: irqwait->request.sequence += atomic_read(&cur_irq->irq_received); irqwait->request.type &= ~_DRM_VBLANK_RELATIVE; case VIA_IRQ_ABSOLUTE: break; default: return -EINVAL; } if (irqwait->request.type & VIA_IRQ_SIGNAL) { DRM_ERROR("Signals on Via IRQs not implemented yet.\n"); return -EINVAL; } force_sequence = (irqwait->request.type & VIA_IRQ_FORCE_SEQUENCE); ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence, &irqwait->request.sequence); do_gettimeofday(&now); irqwait->reply.tval_sec = now.tv_sec; irqwait->reply.tval_usec = now.tv_usec; return ret; }
AK-Kernel/AK-Mako
drivers/gpu/drm/via/via_irq.c
C
gpl-2.0
11,234
/* * linux/arch/sh/boards/lbox/setup.c * * Copyright (C) 2007 Nobuhiro Iwamatsu * * NTT COMWARE L-BOX RE2 Support * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * */ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/ata_platform.h> #include <asm/machvec.h> #include <asm/addrspace.h> #include <mach/lboxre2.h> #include <asm/io.h> static struct resource cf_ide_resources[] = { [0] = { .start = 0x1f0, .end = 0x1f0 + 8 , .flags = IORESOURCE_IO, }, [1] = { .start = 0x1f0 + 0x206, .end = 0x1f0 +8 + 0x206 + 8, .flags = IORESOURCE_IO, }, [2] = { .start = IRQ_CF0, .flags = IORESOURCE_IRQ, }, }; static struct platform_device cf_ide_device = { .name = "pata_platform", .id = -1, .num_resources = ARRAY_SIZE(cf_ide_resources), .resource = cf_ide_resources, }; static struct platform_device *lboxre2_devices[] __initdata = { &cf_ide_device, }; static int __init lboxre2_devices_setup(void) { u32 cf0_io_base; /* Boot CF base address */ pgprot_t prot; unsigned long paddrbase, psize; /* open I/O area window */ paddrbase = virt_to_phys((void*)PA_AREA5_IO); psize = PAGE_SIZE; prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16); cf0_io_base = (u32)ioremap_prot(paddrbase, psize, pgprot_val(prot)); if (!cf0_io_base) { printk(KERN_ERR "%s : can't open CF I/O window!\n" , __func__ ); return -ENOMEM; } cf_ide_resources[0].start += cf0_io_base ; cf_ide_resources[0].end += cf0_io_base ; cf_ide_resources[1].start += cf0_io_base ; cf_ide_resources[1].end += cf0_io_base ; return platform_add_devices(lboxre2_devices, ARRAY_SIZE(lboxre2_devices)); } device_initcall(lboxre2_devices_setup); /* * The Machine Vector */ static struct sh_machine_vector mv_lboxre2 __initmv = { .mv_name = "L-BOX RE2", .mv_nr_irqs = 72, .mv_init_irq = init_lboxre2_IRQ, };
Kra1o5/android_kernel_huawei_u8815-gb
arch/sh/boards/mach-lboxre2/setup.c
C
gpl-2.0
2,009
<?php namespace Aws\Tests\Route53Domains\Integration; use Aws\Common\Exception\ServiceResponseException; use Aws\Route53Domains\Route53DomainsClient; /** * @group integration */ class IntegrationTest extends \Aws\Tests\IntegrationTestCase { /** * @var Route53DomainsClient */ protected $client; public function setUp() { $this->client = $this->getServiceBuilder()->get('route53domains'); } public function testSimpleOperation() { $result = $this->client->checkDomainAvailability(array( 'DomainName' => 'amazon.com', 'IdnLangCode' => 'eng', )); $this->assertEquals('UNAVAILABLE', $result['Availability']); } public function testErrorHandling() { try { $this->client->checkDomainAvailability(array( 'DomainName' => 'amazon.com', 'IdnLangCode' => 'zzz', )); $this->fail('An exception should have been thrown.'); } catch (ServiceResponseException $e) { $this->assertInstanceOf('Aws\Route53Domains\Exception\Route53DomainsException', $e); $this->assertEquals('InvalidInput', $e->getExceptionCode()); } } }
dwaybright/BigDataFinalProject
Website/vendor/aws/aws-sdk-php/tests/Aws/Tests/Route53Domains/Integration/IntegrationTest.php
PHP
gpl-2.0
1,238
/* * WysiwygPro 3.0.3.20080303 (c) Copyright Chris Bolt and ViziMetrics Inc. All Rights Reserved. * Unlicensed distribution, copying, reverse engineering, re-purposing or otherwise stealing of this code is a violation of copyright law. * Get yourself a license at www.wysiwygpro.com */ function wproPreventDefault(evt) { evt.stopPropagation(); evt.preventDefault(); } function wproMozAddAttrs(obj, tag, str) { elem = obj.editDocument.getElementsByTagName(tag)[0]; if (elem) { WPro.stripAttributes(elem); var regex = new RegExp("<"+tag+"[^>]*?>", "gi"); var strAttrs = str.match(regex); if (strAttrs) { if (strAttrs[0]) { attrs = strAttrs[0].match(/ [^=]+="[^"]*"/gi); if (attrs) { var n = attrs.length; for (var i=0; i<n; i++) { var attribute = attrs[i].split("="); var elm = attribute[0].trim().replace(/"/gi,''); var val = attribute[1].trim().replace(/"/gi,''); elem.setAttribute( elm, val, 0 ); } } } } } } function wproWriteDocument(str) { this.editDocument = this.editWindow.document; doc = this.editDocument; if (!this._initiated) { doc.open('text/html', 'replace'); doc.write(this.doctype+'<html><head>'+(this.baseURL?'<base href="'+this.baseURL+'">':'')+'<title></title></head><body></body></html>') doc.close(); this.editWindow.stop(); } else { var headContent = str.match(/<head[^>]*?>([\s\S]*?)<\/head>/gi); if (headContent) { if (headContent[0]) { headContent = headContent[0].replace(/<head[^>]*?>([\s\S]*?)<\/head>/gi, "$1"); var headtag = doc.getElementsByTagName('HEAD') WPro.setInnerHTML(headtag[0], headContent); } } var bodyContent = str.match(/<body[^>]*?>([\s\S]*?)<\/body>/gi); if (!bodyContent) { bodyContent = str.match(/<body[^>]*?>([\s\S]*)/gi); } if (bodyContent) { if (bodyContent[0]) { bodyContent = bodyContent[0].replace(/<body[^>]*?>/gi, "").replace(/<\/body>/gi, ""); WPro.setInnerHTML(doc.body, bodyContent); } } wproMozAddAttrs(this, 'HTML', str); wproMozAddAttrs(this, 'HEAD', str); wproMozAddAttrs(this, 'BODY', str); this.redraw(); } this.editDocument = this.editWindow.document; } function wp_remove_first_br (obj, evt) { var sel = obj.editWindow.getSelection() var range = sel.getRangeAt(0) var startContainer = range.startContainer var container = startContainer.parentNode var node = WPro.getBlockParent(container) if (node.firstChild) { if (node.firstChild.nodeType == 3) { if (node.firstChild.nextSibling) { node = node.firstChild.nextSibling } } while (node.firstChild && node.firstChild.nodeType == 1) { node = node.firstChild; } var previousTag = '' if (node.nextSibling) { nextTag = node.nextSibling.nodeName if (node.nodeName == 'BR' && nextTag != 'BR') { node.parentNode.removeChild(node) } } } } function wproLineReturn(evt) { var wproRange = this.selAPI.getRange(); if (wproRange.getContainerByTagName('LI')) { return; } var sel = this.editWindow.getSelection() var range = wproRange.range; var startContainer = range.startContainer var container = startContainer.parentNode var parentTag = WPro.getBlockParent(container) var endContainer = range.endContainer var endNode1 = endContainer.parentNode if (this.lineReturns == 'br') { var br = this.editDocument.createElement('BR'); wproRange.insertNode(br); var t = this.editDocument.createTextNode(' '); wproRange.insertNode(t); wproRange.select(); } else { var beforeTag; var afterTag; var addAttributes = false; var attributes; var className; var cssText; if (parentTag.tagName) { if (WPro.supported_blocks.test(parentTag.tagName)) { addAttributes = true attributes = parentTag.attributes } if (parentTag.tagName != 'P' && WPro.supported_blocks.test(parentTag.tagName)) { beforeTag = parentTag.tagName } else if (this.lineReturns == 'p') { beforeTag = 'P' } else if (!WPro.supported_blocks.test(parentTag.tagName)) { beforeTag = 'P' } else { beforeTag = 'DIV' this.callFormatting("FormatBlock", "div") } } else if (this.lineReturns == 'p') { beforeTag = 'P' } else { beforeTag = 'DIV' } var afterTag = beforeTag if (container != endNode1) { this.callFormatting('Delete') } else if (container.tagName=='A') { var inA = true; } var rngbefore = this.editDocument.createRange() var rngafter = this.editDocument.createRange() rngbefore.setStart(sel.anchorNode, sel.anchorOffset); rngafter.setStart(sel.focusNode, sel.focusOffset); rngbefore.collapse(true); rngafter.collapse(true); var direct = rngbefore.compareBoundaryPoints(rngbefore.START_TO_END, rngafter) < 0; var startNode = direct ? sel.anchorNode : sel.focusNode; var startOffset = direct ? sel.anchorOffset : sel.focusOffset; var endNode = direct ? sel.focusNode : sel.anchorNode; var endOffset = direct ? sel.focusOffset : sel.anchorOffset; var startBlock = WPro.getBlockParent(startNode); var endBlock = WPro.getBlockParent(endNode); var startCut = startNode; var endCut = endNode; while ((startCut.previousSibling && startCut.previousSibling.nodeName != beforeTag) || (startCut.parentNode && startCut.parentNode != startBlock && startCut.parentNode.nodeType != 9)) { startCut = startCut.previousSibling ? startCut.previousSibling : startCut.parentNode; } while ((endCut.nextSibling && endCut.nextSibling.nodeName != afterTag) || (endCut.parentNode && endCut.parentNode != endBlock && endCut.parentNode.nodeType != 9)) { endCut = endCut.nextSibling ? endCut.nextSibling : endCut.parentNode; } rngbefore.setStartBefore(startCut); rngbefore.setEnd(startNode,startOffset); var beforeContents = rngbefore.cloneContents() rngafter.setEndAfter(endCut); rngafter.setStart(endNode,endOffset); var afterContents = rngafter.cloneContents() if (!WPro.hasContent(afterContents )) { if (this.lineReturns == 'p') { afterTag = 'p' } else { afterTag = 'div' } } var newbefore = this.editDocument.createElement(beforeTag); var newafter = this.editDocument.createElement(afterTag); newbefore.appendChild(beforeContents) newafter.appendChild(afterContents) this.fillContent(newbefore) this.fillContent(newafter) if (addAttributes) { WPro.addAttributes(newbefore, attributes) WPro.addAttributes(newafter, attributes, false, true) } var rngSurround = this.editDocument.createRange(); if (!startCut.previousSibling && startCut.parentNode.nodeName == beforeTag) { rngSurround.setStartBefore(startCut.parentNode); } else { rngSurround.setStart(rngbefore.startContainer, rngbefore.startOffset) } if (!endCut.nextSibling && endCut.parentNode.nodeName == beforeTag) { rngSurround.setEndAfter(endCut.parentNode); } else { rngSurround.setEnd(rngafter.endContainer, rngafter.endOffset) } rngSurround.deleteContents(); rngSurround.insertNode(newafter) rngSurround.insertNode(newbefore) var scrollTop = this.editDocument.body.scrollTop + this.editDocument.documentElement.scrollTop var scrollLeft = this.editDocument.body.scrollLeft + this.editDocument.documentElement.scrollLeft var scrollBottom = this.editFrame.style.height scrollBottom = scrollBottom.replace(/px/i, '') var frameHeight = scrollBottom scrollBottom = scrollTop + parseInt(scrollBottom) var afterposition = WPro.getElementPosition(newafter) if (afterposition['top'] > scrollBottom - 25) { this.editWindow.scrollTo(afterposition['left'], afterposition['top'] - parseInt(frameHeight) + 25) } else { this.editWindow.scrollBy(afterposition['left'] - scrollLeft, 0) } while (newafter.firstChild && WPro.inline_tags.test(newafter.firstChild.nodeName)) { newafter = newafter.firstChild; if (newafter.tagName=='A') { var pnode = newafter.parentNode; var cn = newafter.childNodes; for (var i=0; i<cn.length; i++) { pnode.insertBefore(cn[i].cloneNode(true), newafter ); } pnode.removeChild(newafter); newafter = pnode; } } if (newafter.firstChild && newafter.firstChild.nodeType == 3) { newafter = newafter.firstChild } var rngCaret = this.editDocument.createRange() rngCaret.setStart(newafter, 0); rngCaret.collapse(true) sel = this.editWindow.getSelection() sel.removeAllRanges() sel.addRange(rngCaret) } WPro.preventDefault(evt); } function wproKeyDownHandler (obj, evt) { var keyCode = (evt.which || evt.charCode || evt.keyCode); var doRD = true; if (evt.ctrlKey || evt.metaKey) { if (keyCode == 122) { obj.callFormatting("Undo", false, null); WPro.preventDefault(evt); } if (keyCode == 121) { obj.callFormatting("Redo", false, null); WPro.preventDefault(evt); } if (keyCode == 98) { obj.callFormatting("Bold", false, null); WPro.preventDefault(evt); } if (keyCode == 105) { obj.callFormatting("Italic", false, null); WPro.preventDefault(evt); } if (keyCode == 117) { obj.callFormatting("Underline", false, null); WPro.preventDefault(evt); } } else if (!evt.shiftKey && !obj._inSource) { if (keyCode == 13) { obj.lineReturn(evt) } else if (keyCode == 8) { wp_remove_first_br(obj, evt) } } if (doRD) obj.history.addKey(keyCode); } function wproKeyUpHandler (obj, evt) { var keyCode = (evt.which || evt.charCode || evt.keyCode); if (keyCode == 39 || keyCode == 37 || keyCode == 38 || keyCode == 40) { obj.setButtonStates(); } } function wproMouseDownHandler (obj, evt) { wp_current_obj = obj; WPro.currentEditor = obj; WPro.updateAll('closePMenu'); } function wproMouseUpHandler(obj, evt) { obj.setButtonStates(); wp_current_obj = obj; WPro.currentEditor = obj; obj.selectFix(obj, evt); obj.history.keyPresses=0; } function wproFillContent(node) { if (!WPro.hasContent(node) ) { while (node.firstChild && node.firstChild.nodeType == 1) { node = node.firstChild; } node.innerHTML = '&nbsp;' } } function wproSelectFix(evt) { var sel = this.editWindow.getSelection() var range = sel.getRangeAt(0) var startContainer = range.startContainer var endContainer = range.endContainer var startNode = startContainer.parentNode var endNode = endContainer.parentNode if (startNode != endNode) { return } else { while (startNode.firstChild && WPro.inline_tags.test(startNode.firstChild.nodeName)) { startNode = startNode.firstChild; } if (startNode.innerHTML == '&nbsp;' && startNode.firstChild && startNode.firstChild.nodeType == 3) { startNode = startNode.firstChild var rngCaret = this.editDocument.createRange(); rngCaret.setStart(startNode, 0); rngCaret.collapse(true); sel = this.editWindow.getSelection(); sel.removeAllRanges(); sel.addRange(rngCaret); } } } function wproCutCopyBSH (EDITOR,srcElement,cmd,inTable,inA,range){ return range.getHTMLText()?'wproReady':'wproDisabled'; } function wproPasteBSH (EDITOR,srcElement,cmd,inTable,inA,range){ return WPro.clipBoard?'wproReady':'wproDisabled'; } function wproGetCommonAncestorContainer () { if (this.type == 'control' && this.nodes) { return this.getContainer(); } else { var n = this.range.commonAncestorContainer; while (n.nodeType!=1 && n.parentNode) { n = n.parentNode; } return n; } } function wproGetEndContainer () { if (this.type == 'control' && this.nodes) { return this.getContainer(); } else { return this.range.endContainer; } } function wproGetStartContainer () { if (this.type == 'control' && this.nodes) { return this.getContainer(); } else { return this.range.startContainer; } } function wproGetHTMLText () { if (this.type == 'control' && this.nodes[0]) { var div = WPro.editors[this.editor].editDocument.createElement('div'); div.appendChild(this.nodes[0].cloneNode(true)); return div.innerHTML; } else { var clonedSelection = this.range.cloneContents(); var div = WPro.editors[this.editor].editDocument.createElement('div'); div.appendChild(clonedSelection); return div.innerHTML; } } function wproSelect () { var sel = WPro.editors[this.editor].editWindow.getSelection() sel.removeAllRanges() sel.addRange(this.range) WPro.editors[this.editor].focus(); } function wproSelectNodeContents (referenceNode) { if (this.type == 'control') return false; this.range.selectNodeContents(referenceNode); } function wproCloneContents () { return this.range.cloneContents(); } function wproDeleteContents () { var editor = WPro.editors[this.editor]; editor.history.add(); this.range.deleteContents(); editor.history.add(); } function wproExtractContents () { var editor = WPro.editors[this.editor]; editor.history.add(); var df = this.range.extractContents(); editor.history.add(); return df; } function wproPasteHTML (html) { var editor = WPro.editors[this.editor]; html = editor.triggerHTMLFilter('design', html); var div = editor.editDocument.createElement("DIV") WPro.setInnerHTML(div, html); var cn = div.childNodes; var num = cn.length; editor.history.add(); var bd = editor.history.disabled; editor.history.disabled = true; for (var i=0; i < num; i++) { this.insertNode(cn[0]); } editor.history.disabled = bd; editor.history.add(); } function wproInsertNode (insertNode, selectNode) { var editor = WPro.editors[this.editor]; editor.history.add(); if (selectNode) editor.selAPI.removeAllRanges(); this.range.deleteContents(); var container = this.range.startContainer var pos = this.range.startOffset if (container.nodeType==3 && insertNode.nodeType==3) { container.insertData(pos, insertNode.nodeValue) this.range.setEnd(container, pos+insertNode.length) this.range.setStart(container, pos+insertNode.length) } else { var afterNode if (container.nodeType==3) { var textNode = container container = textNode.parentNode var text = textNode.nodeValue var textBefore = text.substr(0,pos) var textAfter = text.substr(pos) var beforeNode = editor.editDocument.createTextNode(textBefore) afterNode = editor.editDocument.createTextNode(textAfter) container.insertBefore(afterNode, textNode) container.insertBefore(insertNode, afterNode) container.insertBefore(beforeNode, insertNode) container.removeChild(textNode) } else { afterNode = container.childNodes[pos] container.insertBefore(insertNode, afterNode) } this.range.selectNode(insertNode); if (!selectNode) { this.range.collapse(false); } } editor.history.add(); } function wproCloneRange () { var r; if (this.range.cloneRange) { r = this.range.cloneRange(); } var nr = new wproRange(r, this.editor); nr.type = this.type; nr.nodes = this.nodes; return nr; } function wproToString () { return this.range.toString(); } function wproGetSelectedNodes () { this.range = null; var nodes = []; var sel = WPro.editors[this.editor].editWindow.getSelection(); var range var num = sel.rangeCount var j = 0; for (var i=0; i < num; i++) { range = sel.getRangeAt(i); if (i == 0) this.range = range var container = range.startContainer var endContainer = range.endContainer var pos = range.startOffset; if (container == endContainer) { if (range.endOffset == (pos+1)) { if (container.tagName) { var cn = container.childNodes if (cn[pos]) { if (cn[pos].tagName) { nodes[j] = cn[pos]; j++; } else { } } } } } } if (j > 0) { return nodes; } if (!this.range) { this.range = WPro.editors[this.editor].editDocument.createRange(); } return false; } function wproCreateRange () { var range = WPro.editors[this.editor].editDocument.createRange(); var r = new wproRange(range, this.editor); return r; }
healthcommcore/hcc_website
plugins/editors/wysiwygPro3/wysiwygPro/core/js/operaSpecific.js
JavaScript
gpl-2.0
14,681
<html> <head> <title>VNC server for eCos</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <h1>VNC server for eCos</h1> <h2>Introduction</h2> <p>VNC stands for Virtual Network Computing. It is in essence, a remote display system which allows you to view a computing 'desktop' environment not only on the machine where it is running, but from anywhere on the Internet and from a wide variety of machine architectures. For full details of VNC, and to get the vncviewer program see: <a href="http://www.uk.research.att.com/vnc/" target="VNC_PAGE">http://www.uk.research.att.com/vnc/</a>. </p> <p>The VNC server for eCos runs on the target platform and waits for a client (vncviewer program running on a PC) to connect via an ethernet connection (port 5900). Once a client has connected, the target platform has a virtual screen, keyboard and mouse.</p> <p>&nbsp;</p> <h2>Limitations</h2> <p>The eCos port of the VNC server has been designed with some limitations in order to keep memory and processor power requirements to a minimum.</p> <ol> <li>The VNC client must accept the settings that the VNC server suggests (bits-per-pixel, number-of-colours and so on as specified at build time with the eCos configuration tool) or the VNC server will just disconnect.</li> <li>The VNC server only supports CoRRE encoding and RAW encoding for sending display data to the client.</li> <li>The VNC server does not support password authentication, the client is able to connect without the user typing in a password.</li> <li>Only one VNC client may connect to the VNC server at a time.</li> </ol> <p>In reality these limitations are not a problem.</p> <p>&nbsp;</p> <h2>VNC server API</h2> <p>If the VNC server is to be used with the eCos port of MicroWindows, then VNC server API may be ignored and the application should just use one of the API supplied by MicroWindows.</p> <h3>VNC server display API</h3> <p>To use the VNC server display API the application should include the VNC server header file by adding the following line to their C application:</p> <p><font face="Courier New, Courier, mono"><font size="-1">#include &lt;vnc-server.h&gt; &nbsp;&nbsp;/* VNC server header file *</font></font></p> <p>This file specifies several function to manipulate the display.</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><b>vnc_frame_forma</b></font><b><font face="Courier New, Courier, mono">t_t* VncGetInfo(void)</font></b></font></p> <p>The VNC get info function returns a pointer to a 'vnc_frame_format_t' type structure and is used to get information about the VNC display. 'vnc_frame_format_t' is defined in the vnc-server.h file as:</p> <p><font face="Courier New, Courier, mono" size="-1">typedef struct<br> {<br> &nbsp;&nbsp;&nbsp;&nbsp;cyg_uint16 frame_width;<br> &nbsp;&nbsp;&nbsp;&nbsp;cyg_uint16 frame_height;<br> &nbsp;&nbsp;&nbsp;&nbsp;void * frame_buffer;<br> &nbsp;&nbsp;&nbsp;&nbsp;bool rgb332;<br> &nbsp;&nbsp;&nbsp;&nbsp;</font><font face="Courier New, Courier, mono" size="-1">bool rgb555;<br> &nbsp;&nbsp;&nbsp;&nbsp;bool rgb565;<br> &nbsp;&nbsp;&nbsp;&nbsp;</font><font face="Courier New, Courier, mono" size="-1">bool bgr233;<br> } vnc_frame_format_t;</font></p> <p>The frame_width and frame height fields contain the VNC server display size in pixels.</p> <p>The * frame_buffer pointer contains the address of the actual frame buffer the VNC server uses, though the application should never write to this buffer directly.</p> <p>The final 4 (bool) fields specifiy the pixel format - only one of them will be set to true.</p> </td> </tr> </table> <p>&nbsp;</p><table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b><font face="Courier New, Courier, mono">void VncInit(vnc_colour_t colour)</font></b></font></p> <p>The VNC initialise function, initialises the VNC server and paints the display with the specified colour. This funcftion must be called before any of the other VNC server display functions are used, except for VncGetInfo() - which may be called at any time.</p> <p>The type 'vnc_colour_t' is defined in the vnc-server.h file - and is used to represent a colour. If the VNC server is built to support 8-bit pixel data then 'vnc_colour_t' will be type cyg_uint8, but if 16-bit pixel data is being used then 'vnc_colour_t' will be type cyg_uint16.</p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><b><font face="Courier New, Courier, mono">void VncDrawPixel(cyg_uint16 x,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cyg_uint16 y, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vnc_colour_t colour)</font></b><font face="Courier New, Courier, mono"></font></font></p> <p>The VNC draw pixel function simply draws a pixel of colour, 'colour', at position ('x', 'y') on the VNC server display. Note that pixel (0, 0) is the top-left pixel in the display.</p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><b><font face="Courier New, Courier, mono">vnc_colour_t VncReadPixel(cyg_uint16 x<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y)</font></b></font></p> <p>The VNC read pixel function simply returns the colour of the pixel at position ('x', 'y') on the VNC server display. Note that pixel (0, 0) is the top-left pixel in the display.</p> </td> </tr> </table> <p>&nbsp;</p><table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b>void VncDrawHorzLine(cyg_uint16 x1,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x2, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vnc_colour_t colour)</b></font></p> <p>The VNC draw horizontal line function simply draws a line of pixels of colour, 'colour', from position ('x1', 'y') to position ('x2', 'y') (inclusive) on the VNC server display. Note that pixel (0, 0) is the top-left pixel in the display.</p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b><font face="Courier New, Courier, mono">void VncDrawVertLine(cyg_uint16 x,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y1,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y2, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vnc_colour_t colour)</font></b></font></p> <p>The VNC draw vertical line function simply draws a line of pixels of colour, 'colour', from position ('x', 'y1') to position ('x', 'y2') (inclusive) on the VNC server display. Note that pixel (0, 0) is the top-left pixel in the display.</p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b><font face="Courier New, Courier, mono">void VncFillRect(cyg_uint16 x1,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y1,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x2, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y2, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vnc_colour_t colour)</font></b></font></p> <p>The VNC fill rectangle function draws a solid rectangle of colour, 'colour', with top-left corner at ('x1', 'y1') and bottom right corner at ('x2', 'y2') (inclusive) on the VNC server display. Note that pixel (0, 0) is the top-left pixel in the display.</p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b>void VncCopyRect(cyg_uint16 x1,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y1, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 width, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 height,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x2,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y2)</b></font></p> <p>The VNC copy rectangle function copies a rectangle from one part of the VNC display to another. The source rectangle is of width 'width', and height 'height', with its top-left corner at ('x1', 'y1'). The destination rectangle is the same size with its top-left corner at ('x2', 'y2'). Note that pixel (0, 0) is the top-left pixel in the display.</p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b>void VncCopyRect2Buffer(cyg_uint16 x,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 width,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 height,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void *buffer,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 buff_w,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 buff_h,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x_off,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y_off)</b></font></p> <p>The VNC copy rectangle to buffer function copies a rectangle of the VNC server display to a buffer supplied by the application. This function is useful for saving areas of the display which will need to be restored later, such as the area under a mouse cursor.</p> <p>The rectangle of the display to be copied is of width 'width' and height 'height' with its top-left corner at position ('x', 'y'). The address of the buffer supplied to copy the image data is specified by '*buffer'. This buffer is of width 'buff_w' and height 'buff_height'. If the buffer width and height is larger than the rectangle being copied from the display, an x and y offset may be supplied ('x_off' and 'y_off' respectively) to offset where the rectangle of display data in the buffer.</p> <p>For example a buffer of width = 50 and height = 40 could be defined with:</p> <p><font face="Courier New, Courier, mono"><font size="-1">vnc_colour_t my_buffer[40][50];</font></font></p> <p>Then VncCopyRect2Buffer() could be called with:</p> <p><font face="Courier New, Courier, mono"><font size="-1">VncCopyRect2Buffer(10, &nbsp;/* x-pos on display */<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10, &nbsp;/* y-pos on display */</font></font><br> <font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;30, &nbsp;/* rectangle width on display */</font></font> <br> <font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20, &nbsp;/* rectangle heigth on display */</font></font> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Courier New, Courier, mono"><font size="-1">(void *)my_buffer, /* Address of buffer */<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;50, &nbsp;/* buffer width */</font></font> <font size="-1"> <br> </font><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;40, &nbsp;/* buffer height */</font></font> <br> </font></font><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5, &nbsp;&nbsp;/* buffer x-offset */</font></font> <font size="-1"> <br> </font><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6); &nbsp;/* buffer y-offset */</font></font> <font size="-1"> </font></font><font size="-1"> <br> </font></font></font></p> <p>This would copy a 30 pixel wide, 20 pixel high rectangle from (10, 10) of the VNC server display to the buffer 'my_buffer'. Inside the buffer there would by an x-offset of 5 and a y offset of 6. Thus pixel (10, 10) from the VNC server display would now be copied to my_buffer[6][5] - and so on for the rest of the rectangle.</p> </td> </tr> </table> <p>&nbsp; </p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b>void VncCopyBuffer2Rect(void *buffer,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 buff_w,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 buff_h, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x_off,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y_off,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 width,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 height)</b></font></p> <p>The VNC copy buffer to rectangle function copies a rectangle from a buffer supplied by the application to the VNC server display. This function is usefull for restoring previously saved areas of the display.</p> <p>For example, to restore the rectangle saved in the previous example use of the VncCopyRect2Buffer() function above, the VncCopyBuff2Rect() would be called with:</p> <p><font face="Courier New, Courier, mono"><font size="-1">VncCopyBuffer2Rect(</font><font face="Courier New, Courier, mono"><font size="-1">(void *)my_buffer, /* Address of buffer */</font></font><font size="-1"><br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;50, &nbsp;/* buffer width */</font></font> <font size="-1"> <br> </font><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;40, &nbsp;/* buffer height */</font></font> <br> </font></font><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5, &nbsp;&nbsp;/* buffer x-offset */</font></font> <font size="-1"> <br> </font><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6, &nbsp;&nbsp;/* buffer y-offset */</font></font> <font size="-1"> </font></font><br> </font></font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10, &nbsp;/* x-pos on display */<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10, &nbsp;/* y-pos on display */</font></font><br> <font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;30, &nbsp;/* rectangle width on display */</font></font> <br> <font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20); /* rectangle heigth on display */</font></font> </p> <p>Note that in most uses of the VncCopyBuff2Rect() and VncCopyRect2Buffer() functions would be called with:<br> &nbsp;&nbsp;&nbsp;&nbsp;width = buff_w<br> &nbsp;&nbsp;&nbsp;&nbsp;heigth = buff_h<br> &nbsp;&nbsp;&nbsp;&nbsp;x_off = 0<br> &nbsp;&nbsp;&nbsp;&nbsp;y_off = 0.</p> <p>In this case there is no offset into the buffer and the buffer is used 100% to store the rectangle from the display. <font face="Courier New, Courier, mono"><font size="-1"> </font></font></p> </td> </tr> </table> <p>&nbsp;</p><table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b>void VncCopyBuffer2RectMask(void *buffer,<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 buff_w,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 buff_h, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x_off,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y_off,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 x, <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 y,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 width,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cyg_uint16 height,<br> <font face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vnc_colour_t mask_colour</font> )</b></font></p> <p>The VNC copy buffer to rectangle with mask function works exactly like VncCopyRect2Buffer(), except that a mask colour is also specified. Any pixels in the buffer that have the value mask_colour, will not be copied to the frame buffer - leaving the original pixels untouched.<font face="Courier New, Courier, mono"><font size="-1"> </font></font></p> </td> </tr> </table> <p>&nbsp;</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><font face="Courier New, Courier, mono"></font><b>vnc_printf_return_t VncPrintf(MWCFONT* font,<br> </b></font><font face="Courier New, Courier, mono"><b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int do_print,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vnc_colour_t colour,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int x,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int y,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const char *fmt, ... );)</b></font></p> <p>The VNC printf function writes test to a specified position in the VNC frame buffer, using the specified font and colour.</p> <p>The '* font' argument is a pointer to a MWCFONT font structure. This is the same font structure as used by MicroWindows, though the VNC server has its own copy of the font description files. The available fonts are:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;font_rom8x16<br> &nbsp;&nbsp;&nbsp;&nbsp;font_rom8x8<br> &nbsp;&nbsp;&nbsp;&nbsp;font_winFreeSansSerif11x13<br> &nbsp;&nbsp;&nbsp;&nbsp;font_winFreeSystem14x16<br> &nbsp;&nbsp;&nbsp;&nbsp;font_helvB10<br> &nbsp;&nbsp;&nbsp;&nbsp;font_helvB12<br> &nbsp;&nbsp;&nbsp;&nbsp;font_helvR10<br> &nbsp;&nbsp;&nbsp;&nbsp;font_X5x7<br> &nbsp;&nbsp;&nbsp;&nbsp;font_X6x13</p> <p>If the font argument is set to '0', then the default font (winFreeSystem14x16) is used.</p> <p>The 'do_print' argument is used to specify whether the function should actually write the text to the frame buffer. If do_print is non-zero, then the text will be written to the frame buffer. If do_print is zero, then no text will be written, but the return value from the function will sill be valid.</p> <p>The 'colour' argument specifies the colour to use to write the text.</p> <p>The 'x' and 'y' arguments specify the pixel position (x, y) in the frame buffer of the top left pixel of the first character to be printed.</p> <p>The 'const char *fmt, ...' argumets are used as in a normal printf statement.</p> <p>The function returns a data structure of type vnc_printf_return_t, this is defined as:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;typedef struct<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int chars;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cyg_uint16 width;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cyg_uint16 height;<br> &nbsp;&nbsp;&nbsp;&nbsp;} vnc_printf_return_t;</p> <p>The 'chars' values is exactly as would have been returned by the printf() function.</p> <p>The width and height attributes specify the width and height of a rectangle surrounding the text written to the screen. This data can be used to know how much of the frame buffer needs to be painted to delete the text, or (used together with the 'do_print' argument set to 0) to calculate how much of the screen should be saved before printing to it so that it may be restored later.</p> <p>An example of writing some text to position (250, 200) of the frame buffer, using the colout cyan and the font, winFreeSansSerif11x13:</p> <p><font face="Courier New, Courier, mono"></font><font face="Courier New, Courier, mono"><font size="-1">vnc_printf_return_t print_area;</font></font></p> <p><font face="Courier New, Courier, mono"><font size="-1">print_area = VncPrintf(&font_winFreeSansSerif11x13,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1"> VNC_CYAN, <br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1"> 250,<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1"> 200,<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1"> </font></font><font face="Courier New, Courier, mono"><font size="-1">"Hello World!\nUsing winFreeSansSerif11x13 font");</font></font></p> <p>Note: 'print_area.width' and 'print_area.height' will be set to indicate how much of the frame buffer was used to print this text.</p> <p>Another example, using the default font this time:</p> <p><font face="Courier New, Courier, mono"><font size="-1">print_area = VncPrintf(0,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1">VNC_BLACK, <br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1">250,<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font><font size="-1">200,<br> </font><font face="Courier New, Courier, mono"><font size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font></font><font face="Courier New, Courier, mono"><font size="-1">"50 * 34 = %d", 50*34);</font></font></p> <p></p> </td> </tr> </table> <p>Also included in the vnc-server.h header file are 16 predefined colours:</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td><font face="Courier New, Courier, mono"><b>VNC_BLACK<br> VNC_BLUE<br> VNC_GREEN<br> VNC_CYAN<br> VNC_RED<br> VNC_MAGENTA<br> VNC_BROWN<br> VNC_LTGRAY<br> VNC_LTGREY&nbsp; /* Same as VNC_LTGRAY */<br> VNC_GRAY<br> VNC_GREY&nbsp; /* Same as VNC_GRAY */<br> VNC_LTBLUE<br> VNC_LTGREEN<br> VNC_LTCYAN<br> VNC_LTRED<br> VNC_LTMAGENTA<br> VNC_YELLOW<br> VNC_WHITE</b></font> <p>These colours are all of type vnc_colour_t and are always correct for the selected pixel type.</p> </td> </tr> </table> <p>Also contained in the vnc-server.h header file is a macro to convert from a full RGB colour value to the nearest colour that the type vnc_colour_t can represent. This macro is:</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><b>VNC_RGB2COL(red, green, blue)</b></font></p> <p>The arguments red, green and blue each have a value from 0 to 255.</p> <p>For example, to initialise the VNC server display with a colour as close to a very specific shade of green [red=156, green=229, blue=91] - the VncInit() function could be called as follows:</p> <p><font face="Courier New, Courier, mono" size="-1">VncInit( VNC_RGB2COL(156, 229, 91) );</font></p> <p>Obviously the colour match will be better if the VNC server had been built with 16 bits per pixel rather than with 8 bits per pixel, but in each case the best available colour will be used.</p> </td> </tr> </table> <p>Though not strictly a display function, a function to sound a bell on the client is available.</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono"><b><font face="Courier New, Courier, mono">void VncSoundBell(void)</font></b></font></p> <p>The VNC Sound Bell function simply sounds a bell on the client - if the client supports this.</p> </td> </tr> </table> <p>&nbsp; </p> <h3>VNC server mouse API</h3> <p>The VNC server mouse device driver is a standard eCos IO device driver. The device name is &quot;/dev/vnc_mouse&quot; by default, but this may be modified with the configuration tool. The first step in using the mouse device driver is to use the cyg_io_lookup() function:</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p> <font face="Courier New, Courier, mono" size="-1">Cyg_ErrNo mouse_err;<br> cyg_io_handle_t mouse_handle;<br> cyg_uint8 mouse_data[8];<br> cyg_uint32 mouse_len;</font><br> <br> <font face="Courier New, Courier, mono" size="-1">mouse_err = cyg_io_lookup("/dev/vnc_mouse", &mouse_handle); /* Open mouse device */ if (mouse_err == -ENOENT)<br> { <br> &nbsp;&nbsp;&nbsp;&nbsp;diag_printf("Could not open mouse device\n"); <br> } </font></p> </td> </tr> </table> <p>Once the cyg_io_lookup() function has found the mouse device driver, the driver is active and should be read regularly to prevent the receive buffer from overflowing with data. Data is read using the cyg_io_read() function:</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono" size="-1">mouse_len = 8;&nbsp;&nbsp;/* Try to read 8 bytes from mouse */ <br> cyg_io_read(mouse_handle, mouse_data, &mouse_len ); <br> if (mouse_len == 0)<br> {<br> &nbsp;&nbsp;&nbsp;&nbsp;diag_printf(&quot;Mouse has no new data\n&quot;);<br> }<br> else<br> { <br> &nbsp;&nbsp;&nbsp;&nbsp;diag_printf(&quot;Have New mouse data:\n&quot;);</font><br> <font face="Courier New, Courier, mono" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;<font face="Courier New, Courier, mono" size="-1">diag_printf(&quot;&nbsp;&nbsp;Mouse button data: 0x%x\n&quot;, mouse_data[1]);</font> </font> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Courier New, Courier, mono" size="-1">diag_printf(&quot;&nbsp;&nbsp;Mouse x-coord: %d\n&quot;, mouse_data[2]*256 + mouse_data[3]);</font><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Courier New, Courier, mono" size="-1">diag_printf(&quot;&nbsp;&nbsp;Mouse y-coord: %d\n&quot;, mouse_data[4]*256 + mouse_data[5]);<br> }</font> </p> </td> </tr> </table> <p>The cyg_io_read() function is a non-blocking function and each mouse event generates 8 bytes of data:</p> <p>Byte 0: Padding - always zero<br> Byte 1: Button data (bit 0 = 1 if the left button is pressed, bit 2 = 1 if the right button is pressed)<br> Byte 2: Mose position x-coord MSB<br> Byte 3: Mose position x-coord LSB<br> Byte 4: Mose position y-coord MSB<br> Byte 5: Mose position y-coord LSB<br> Byte 6: Padding - always zero<br> Byte 7: Padding - always zero </p> <p>&nbsp;</p> <h3>VNC server keyboard API</h3> <p>The VNC server keyboard device driver is a standard eCos IO device driver. The device name is &quot;/dev/vnc_kbd&quot; by default, but this may be modified with the configuration tool. The first step in using the keyboard device driver is to use the cyg_io_lookup() function:</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p> <font face="Courier New, Courier, mono" size="-1">Cyg_ErrNo kdb_err;<br> cyg_io_handle_t kbd_handle;<br> cyg_uint8 kbd_data[8];<br> cyg_uint32 kbd_len;</font><br> <br> <font face="Courier New, Courier, mono" size="-1">kbd_err = cyg_io_lookup("/dev/vnc_kbd", &kbd_handle); /* Open kbd device */ <br> if (kbd_err == -ENOENT)<br> { <br> &nbsp;&nbsp;&nbsp;&nbsp;diag_printf("Could not open kbd device\n"); <br> } </font></p> </td> </tr> </table> <p>Once the cyg_io_lookup() function has found the keyboard device driver, the driver is active and should be read regularly to prevent the receive buffer from overflowing with data. Data is read using the cyg_io_read() function:</p> <table width="91%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"> <tr> <td> <p><font face="Courier New, Courier, mono" size="-1">kbd_len = 4;&nbsp;&nbsp;/* Try to read 4 bytes from keyboard */ <br> cyg_io_read(kbd_handle, kbd_data, &kbd_len ); <br> if (kbd_len == 0)<br> {<br> &nbsp;&nbsp;&nbsp;&nbsp;diag_printf(&quot;Keyboard has no new data\n&quot;);<br> }<br> else<br> { <br> &nbsp;&nbsp;&nbsp;&nbsp;diag_printf(&quot;Have New keyboard data:\n&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;if (kbd_data[1])<br> &nbsp;&nbsp;&nbsp;&nbsp;{ </font><br> <font face="Courier New, Courier, mono" size="-1"><font face="Courier New, Courier, mono" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;diag_printf(&quot;&nbsp;&nbsp;Keysym value 0x%x pressed\n&quot;,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kbd_data[2]*256 + kbd_data[3]</font></font><font face="Courier New, Courier, mono" size="-1"><font face="Courier New, Courier, mono" size="-1">);<br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;else<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> <font face="Courier New, Courier, mono" size="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;diag_printf(&quot;&nbsp;&nbsp;Keysym value 0x%x released\n&quot;,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kbd_data[2]*256 + kbd_data[3]</font></font><font face="Courier New, Courier, mono" size="-1"><font face="Courier New, Courier, mono" size="-1">);</font></font><font face="Courier New, Courier, mono" size="-1"> <br> &nbsp;&nbsp;&nbsp;&nbsp;} </font></font><br> <font face="Courier New, Courier, mono" size="-1">}</font> </p> </td> </tr> </table> <p>The cyg_io_read() function is a non-blocking function and each keystroke event generates 4 bytes of data:</p> <p>Byte 0: Padding - always zero<br> Byte 1: Key pressed/released (1 when key pressed)<br> Byte 2: Keysym value for key MSB<br> Byte 3: Keysym value for key LSB<br> </p> <p>The actual key values are specified using the &quot;keysym&quot; values defined by the X Window System. For most ordinary keys the keysym value is the same as the corresponding ASCII value. For full details see either the Xlib Reference Manual, published by O'Reilly &amp; Associates or see the header file &lt;X11/keysymdef.h&gt; from any X Window System installation (a google search for 'keysymdef.h' should find it).</p> <p>&nbsp;</p> <h3>&nbsp;</h3> </body> </html>
micro2440/ecos_s3c2440
packages/net/vnc_server/current/doc/vnc-server.html
HTML
gpl-2.0
41,366
#include <iostream> #include <sstream> #include <algorithm> #include <tblog.h> #include <gtest/gtest.h> #include "common/ob_malloc.h" #include "common/ob_scanner.h" #include "common/ob_get_param.h" #include "ob_ms_scanner_encoder.h" #include "../common/test_rowkey_helper.h" using namespace std; using namespace oceanbase::common; using namespace oceanbase::mergeserver; static CharArena allocator_; int main(int argc, char **argv) { ob_init_memory_pool(); ::testing::InitGoogleTest(&argc,argv); return RUN_ALL_TESTS(); } class TestScannerEncoder: public ::testing::Test { public: virtual void SetUp() { } virtual void TearDown() { } }; TEST_F(TestScannerEncoder, encode) { // set get_param cell ObGetParam get_param; ObGetParam err_param; const int64_t count = 50; ObCellInfo cell; ObString table_name; ObRowkey row_key; ObString column_name; char * table = (char*)"table"; char * rowkey = (char*)"rowkey"; char * column = (char*)"column"; table_name.assign(table, static_cast<int32_t>(strlen(table))); row_key = make_rowkey(rowkey, &allocator_); column_name.assign(column, static_cast<int32_t>(strlen(column))); for (int64_t i = 0; i < count; ++i) { cell.reset(); cell.table_name_ = table_name; cell.row_key_ = row_key; cell.column_name_ = column_name; EXPECT_TRUE(OB_SUCCESS == get_param.add_cell(cell)); if (0 == i) { continue; } EXPECT_TRUE(OB_SUCCESS == err_param.add_cell(cell)); } // ups return scanner ObScanner temp_result; ObScanner err_result; uint64_t table_id = 1234; uint64_t column_id = 1234; ObObj obj; for (int64_t i = 0; i < count; ++i) { cell.reset(); cell.table_id_= table_id; cell.row_key_ = row_key; cell.column_id_ = column_id; obj.set_int(i); cell.value_ = obj; EXPECT_TRUE(OB_SUCCESS == temp_result.add_cell(cell)); if (0 == i) { continue; } EXPECT_TRUE(OB_SUCCESS == err_result.add_cell(cell)); } ObScanner result; // encode EXPECT_TRUE(OB_SUCCESS == ObMergerScannerEncoder::encode(get_param, temp_result, result)); result.clear(); EXPECT_TRUE(OB_SUCCESS != ObMergerScannerEncoder::encode(err_param, temp_result, result)); result.clear(); EXPECT_TRUE(OB_SUCCESS != ObMergerScannerEncoder::encode(get_param, err_result, result)); result.clear(); EXPECT_TRUE(OB_SUCCESS == ObMergerScannerEncoder::encode(err_param, err_result, result)); result.clear(); EXPECT_TRUE(OB_SUCCESS == err_result.add_cell(cell)); EXPECT_TRUE(OB_SUCCESS == ObMergerScannerEncoder::encode(get_param, err_result, result)); result.clear(); EXPECT_TRUE(OB_SUCCESS != ObMergerScannerEncoder::encode(err_param, err_result, result)); }
lzpfmh/oceanbase
oceanbase_0.4/tests/mergeserver/test_merger_scanner_encoder.cpp
C++
gpl-2.0
2,742
<?php /** * @version $Id: theme.php 300 2014-07-04 11:09:09Z michal $ * @package DJ-Catalog2 * @copyright Copyright (C) 2012 DJ-Extensions.com LTD, All rights reserved. * @license http://www.gnu.org/licenses GNU/GPL * @author url: http://dj-extensions.com * @author email contact@dj-extensions.com * @developer Michal Olczyk - michal.olczyk@design-joomla.eu * * DJ-Catalog2 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 3 of the License, or * (at your option) any later version. * * DJ-Catalog2 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 DJ-Catalog2. If not, see <http://www.gnu.org/licenses/>. * */ defined('_JEXEC') or die('Restricted access'); require_once(JPATH_BASE.DS.'components'.DS.'com_djcatalog2'.DS.'defines.djcatalog2.php'); require_once(JPATH_BASE.DS.'components'.DS.'com_djcatalog2'.DS.'helpers'.DS.'djcatalog2.php'); class DJCatalog2ThemeHelper { static $themeSet = null; static $themeName = null; public static function setThemeAssets() { if (!isset(self::$themeSet)) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $params = Djcatalog2Helper::getParams(); //$app->getParams('com_djcatalog2'); $theme = self::getThemeName(); //TODO jquery scripts $jquery = false; JHTML::_('behavior.framework', true); JHTML::_('behavior.modal'); $lightboxes = array('slimbox', 'picbox'); $slimboxJs = JURI::base().'components/com_djcatalog2/assets/slimbox-1.8/js/slimbox.js'; $slimboxCss = JURI::base().'components/com_djcatalog2/assets/slimbox-1.8/css/slimbox.css'; $lightboxes['slimbox']['css'] = $slimboxCss; $lightboxes['slimbox']['js'] = $slimboxJs; $picboxJs = JURI::base().'components/com_djcatalog2/assets/picbox/js/picbox.js'; $picboxCss = JURI::base().'components/com_djcatalog2/assets/picbox/css/picbox.css'; $lightboxes['picbox']['css'] = $picboxCss; $lightboxes['picbox']['js'] = $picboxJs; $document->addStyleSheet($lightboxes[$params->get('lightbox_type', 'slimbox')]['css']); $document->addScript($lightboxes[$params->get('lightbox_type', 'slimbox')]['js']); $theme_css_url = JURI::base().'components/com_djcatalog2/themes/default/css/theme.css'; $theme_responsive_url = JURI::base().'components/com_djcatalog2/themes/default/css/responsive.css'; $theme_js_file = $jquery ? 'theme.jquery.js' : 'theme.js'; $theme_js_url = JURI::base().'components/com_djcatalog2/themes/default/js/'.$theme_js_file; $theme_class_file = DJCATCOMPONENTPATH.DS.'themes'.DS.'default'.DS.'theme.php'; $theme_class = 'Djcatalog2Theme'; if (JFile::exists( DJCATCOMPONENTPATH.DS.'themes'.DS.$theme.DS.'css'.DS.'theme.css' )) { $theme_css_url = JURI::base().'components/com_djcatalog2/themes/'.$theme.'/css/theme.css'; } if (JFile::exists( DJCATCOMPONENTPATH.DS.'themes'.DS.$theme.DS.'css'.DS.'responsive.css' )) { $theme_responsive_url = JURI::base().'components/com_djcatalog2/themes/'.$theme.'/css/responsive.css'; } if (JFile::exists( DJCATCOMPONENTPATH.DS.'themes'.DS.$theme.DS.'js'.DS.$theme_js_file )) { $theme_js_url = JURI::base().'components/com_djcatalog2/themes/'.$theme.'/js/'.$theme_js_file; } if (JFile::exists( DJCATCOMPONENTPATH.DS.'themes'.DS.$theme.DS.'theme.php' )) { $theme_class_file = DJCATCOMPONENTPATH.DS.'themes'.DS.$theme.DS.'theme.php'; } $document->addStyleSheet($theme_css_url); if ($params->get('theme_responsive', '1') == '1') { $document->addStyleSheet($theme_responsive_url); } $document->addScript($theme_js_url); if (!class_exists($theme_class)) { if (file_exists($theme_class_file)) { require_once $theme_class_file; } } if (class_exists($theme_class)) { $themeClass = new $theme_class(); if (method_exists($themeClass, 'setStyles')) { $themeClass->setStyles($params); } } self::$themeSet = true; } } public static function getThemeImage($filename) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); //$params = $app->getParams('com_djcatalog2'); $params = Djcatalog2Helper::getParams(); $theme = $params->get('theme','default'); if (JFile::exists(DJCATCOMPONENTPATH.DS.'themes'.DS.$theme.DS.'images'.DS.$filename)) { return JURI::base().'components/com_djcatalog2/themes/'.$theme.'/images/'.$filename; } else if (JFile::exists(DJCATCOMPONENTPATH.DS.'themes'.DS.'default'.DS.'images'.DS.$filename)) { return JURI::base().'components/com_djcatalog2/themes/default/images/'.$filename; } else { return ''; } } public static function getThemeName() { if (!self::$themeName) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); //$params = $app->getParams('com_djcatalog2'); $params = Djcatalog2Helper::getParams(); self::$themeName = $params->get('theme','default'); } return self::$themeName; } }
ForAEdesWeb/AEW4
components/com_djcatalog2/helpers/theme.php
PHP
gpl-2.0
5,323
<?php /** * @file * This file contains no working PHP code; it exists to provide additional * documentation for doxygen as well as to document hooks in the standard * Drupal manner. */ /** * @addtogroup hooks * @{ */ /** * Alter the term tree callback that is used for content taxonomy options lists. * * By default taxonomy_get_tree is used to retrieve the list of terms. It is * important that any provided tree callback must have the same function * signature as hook_content_taxonomy_tree_callback_alter(). * For example this hook can be used to exchange the callback with a language * specific tree function. * * @param $tree_callback * The current callback that can be overridden. * @param $field * The term reference field info array. * @param $vocabulary * The vocabulary object for which the term list should be retrieved. One * field can have multiple vocabularies attached, which leads to multiple * invocations of this function. */ function hook_content_taxonomy_tree_callback_alter(&$tree_callback, $field, $vocabulary) { if ($vocabulary->machine_name == 'my_voc') { $tree_callback = 'my_tree_callback'; } } /** * @} End of "addtogroup hooks". */
govhackaustralia/hackerspace
docroot/sites/all/modules/content_taxonomy/content_taxonomy.api.php
PHP
gpl-2.0
1,210
<?php /** * This file is part of the eZ Publish Kernel package. * * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. * * @version //autogentag// */ namespace eZ\Publish\Core\Search\Common\Slot; use eZ\Publish\Core\SignalSlot\Signal; use eZ\Publish\Core\Search\Common\Slot; /** * A Search Engine slot handling SetContentStateSignal. */ class SetContentState extends Slot { /** * Receive the given $signal and react on it. * * @param \eZ\Publish\Core\SignalSlot\Signal $signal */ public function receive(Signal $signal) { if (!$signal instanceof Signal\ObjectStateService\SetContentStateSignal) { return; } $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($signal->contentId); $this->searchHandler->indexContent( $this->persistenceHandler->contentHandler()->load( $contentInfo->id, $contentInfo->currentVersionNo ) ); $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($contentInfo->id); foreach ($locations as $location) { $this->searchHandler->indexLocation($location); } } }
htollefsen/ezpublish-kernel
eZ/Publish/Core/Search/Common/Slot/SetContentState.php
PHP
gpl-2.0
1,348
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Qt 4.4: diagramitem.h Example File (graphicsview/diagramscene/diagramitem.h)</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="namespaces.html"><font color="#004faf">All&nbsp;Namespaces</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"></td></tr></table><h1 class="title">diagramitem.h Example File<br /><span class="small-subtitle">graphicsview/diagramscene/diagramitem.h</span> </h1> <pre><span class="comment"> /**************************************************************************** ** ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the example classes of the Qt Toolkit. ** ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License versions 2.0 or 3.0 as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in ** the packaging of this file. Please review the following information ** to ensure GNU General Public Licensing requirements will be met: ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special ** exception, Nokia gives you certain additional rights. These rights ** are described in the Nokia Qt GPL Exception version 1.3, included in ** the file GPL_EXCEPTION.txt in this package. ** ** Qt for Windows(R) Licensees ** As a special exception, Nokia, as the sole copyright holder for Qt ** Designer, grants users of the Qt/Eclipse Integration plug-in the ** right for the Qt/Eclipse Integration to link to functionality ** provided by Qt Designer and its related libraries. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** ****************************************************************************/</span> #ifndef DIAGRAMITEM_H #define DIAGRAMITEM_H #include &lt;QGraphicsPixmapItem&gt; #include &lt;QList&gt; class QPixmap; class QGraphicsItem; class QGraphicsScene; class QTextEdit; class QGraphicsSceneMouseEvent; class QMenu; class QGraphicsSceneContextMenuEvent; class QPainter; class QStyleOptionGraphicsItem; class QWidget; class QPolygonF; class Arrow; class DiagramItem : public QGraphicsPolygonItem { public: enum { Type = UserType + 15 }; enum DiagramType { Step, Conditional, StartEnd, Io }; DiagramItem(DiagramType diagramType, QMenu *contextMenu, QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); void removeArrow(Arrow *arrow); void removeArrows(); DiagramType diagramType() const { return myDiagramType; } QPolygonF polygon() const { return myPolygon; } void addArrow(Arrow *arrow); QPixmap image() const; int type() const { return Type;} protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); QVariant itemChange(GraphicsItemChange change, const QVariant &amp;value); private: DiagramType myDiagramType; QPolygonF myPolygon; QMenu *myContextMenu; QList&lt;Arrow *&gt; arrows; }; #endif</pre> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%" align="left">Copyright &copy; 2008 Nokia</td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.4.3</div></td> </tr></table></div></address></body> </html>
liuyanghejerry/qtextended
doc/html/graphicsview-diagramscene-diagramitem-h.html
HTML
gpl-2.0
4,926
/* Copyright (c) 2008-2011, Hisilicon Tech. Co., Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Code Aurora Forum, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "mipi_dsi.h" #include "mipi_reg.h" /* * mipi dsi short write with 0, 1 2 parameters * Write to GEN_HDR 24 bit register the value: * 1. 00h, MCS_command[15:8] ,VC[7:6],13h * 2. Data1[23:16], MCS_command[15:8] ,VC[7:6],23h */ int mipi_dsi_swrite(struct dsi_cmd_desc *cm, u32 edc_base) { u32 hdr = 0; int len = 0; if (cm->dlen && cm->payload == 0) { k3fb_loge("NO payload error!\n"); return 0; } len = (cm->dlen > 2) ? 2 : cm->dlen; hdr |= DSI_HDR_DTYPE(cm->dtype); hdr |= DSI_HDR_VC(cm->vc); if (len == 1) { hdr |= DSI_HDR_DATA1(cm->payload[0]); hdr |= DSI_HDR_DATA2(0); } else if (len == 2) { hdr |= DSI_HDR_DATA1(cm->payload[0]); hdr |= DSI_HDR_DATA2(cm->payload[1]); } else { hdr |= DSI_HDR_DATA1(0); hdr |= DSI_HDR_DATA2(0); } set_MIPIDSI_GEN_HDR(edc_base, hdr); return len; /* 4 bytes */ } /* * mipi dsi long write * Write to GEN_PLD_DATA 32 bit register the value: * Data3[31:24], Data2[23:16], Data1[15:8], MCS_command[7:0] * If need write again to GEN_PLD_DATA 32 bit register the value: * Data7[31:24], Data6[23:16], Data5[15:8], Data4[7:0] * * Write to GEN_HDR 24 bit register the value: WC[23:8] ,VC[7:6],29h */ int mipi_dsi_lwrite(struct dsi_cmd_desc *cm, u32 edc_base) { u32 hdr = 0; int i = 0; if (cm->dlen && cm->payload == 0) { k3fb_loge("NO payload error!\n"); return 0; } /* fill up payload */ for (i = 0; i < cm->dlen; i += 4) { set_MIPIDSI_GEN_PLD_DATA(edc_base, *((u32 *)(cm->payload + i))); } /* fill up header */ hdr |= DSI_HDR_DTYPE(cm->dtype); hdr |= DSI_HDR_VC(cm->vc); hdr |= DSI_HDR_WC(cm->dlen); set_MIPIDSI_GEN_HDR(edc_base, hdr); return cm->dlen; } void mipi_dsi_max_return_packet_size(struct dsi_cmd_desc *cm, u32 edc_base) { u32 hdr = 0; /* fill up header */ hdr |= DSI_HDR_DTYPE(cm->dtype); hdr |= DSI_HDR_VC(cm->vc); hdr |= DSI_HDR_WC(cm->dlen); set_MIPIDSI_GEN_HDR(edc_base, hdr); } void mipi_dsi_sread(u32 *out, u32 edc_base) { unsigned long dw_jiffies = 0; u32 tmp = 0; dw_jiffies = jiffies + HZ / 2; do { tmp = inp32(edc_base + MIPIDSI_CMD_PKT_STATUS_OFFSET); if ((tmp & 0x00000040) == 0x00000040) { break; } } while (time_after(dw_jiffies, jiffies)); dw_jiffies = jiffies + HZ / 2; do { tmp = inp32(edc_base + MIPIDSI_CMD_PKT_STATUS_OFFSET); if ((tmp & 0x00000040) != 0x00000040) { break; } } while (time_after(dw_jiffies, jiffies)); *out = inp32(edc_base + MIPIDSI_GEN_PLD_DATA_OFFSET); } void mipi_dsi_lread(u32 *out, u32 edc_base) { /* do something here*/ } /* * prepare cmd buffer to be txed */ int mipi_dsi_cmd_add(struct dsi_cmd_desc *cm, u32 edc_base) { int len = 0; switch (cm->dtype) { case DTYPE_GEN_WRITE: case DTYPE_GEN_WRITE1: case DTYPE_GEN_WRITE2: case DTYPE_DCS_WRITE: case DTYPE_DCS_WRITE1: len = mipi_dsi_swrite(cm, edc_base); break; case DTYPE_GEN_LWRITE: case DTYPE_DCS_LWRITE: len = mipi_dsi_lwrite(cm, edc_base); break; default: k3fb_loge("dtype=%x NOT supported!\n", cm->dtype); break; } return len; } int mipi_dsi_cmds_tx(struct dsi_cmd_desc *cmds, int cnt, u32 edc_base) { struct dsi_cmd_desc *cm = NULL; int i = 0; BUG_ON(cmds == NULL); cm = cmds; for (i = 0; i < cnt; i++) { mipi_dsi_cmd_add(cm, edc_base); if (cm->wait) { if (cm->waittype == WAIT_TYPE_US) udelay(cm->wait); else if (cm->waittype == WAIT_TYPE_MS) mdelay(cm->wait); else mdelay(cm->wait * 1000); } cm++; } return cnt; }
hwmt1-u06/android_kernel_huawei_hwmt1-u06
drivers/video/k3/mipi_dsi_host.c
C
gpl-2.0
5,027
/* * File: test_correct.c * Author: Vasileios Trigonakis <vasileios.trigonakis@epfl.ch> * Description: * test_correct.c is part of ASCYLIB * * Copyright (c) 2014 Vasileios Trigonakis <vasileios.trigonakis@epfl.ch>, * Tudor David <tudor.david@epfl.ch> * Distributed Programming Lab (LPD), EPFL * * ASCYLIB 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, version 2 * of the License. * * 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. * */ #include <assert.h> #include <getopt.h> #include <limits.h> #include <pthread.h> #include <signal.h> #include <stdlib.h> #include <stdio.h> #include <sys/time.h> #include <time.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <sched.h> #include <inttypes.h> #include <sys/time.h> #include <unistd.h> #include <malloc.h> #include "utils.h" #include "atomic_ops.h" #ifdef __sparc__ # include <sys/types.h> # include <sys/processor.h> # include <sys/procset.h> #endif #include "intset.h" /* ################################################################### * * Definition of macros: per data structure * ################################################################### */ #define DS_CONTAINS(s,k) set_contains(s, k) #define DS_ADD(s,k,v) set_add(s, k, (sval_t) v) #define DS_REMOVE(s,k) set_remove(s, k) #define DS_SIZE(s) set_size(s) #define DS_NEW() set_new() #define DS_TYPE intset_t #define DS_NODE node_t /* ################################################################### * * GLOBALS * ################################################################### */ size_t initial = DEFAULT_INITIAL; size_t range = DEFAULT_RANGE; size_t load_factor; size_t update = DEFAULT_UPDATE; size_t num_threads = DEFAULT_NB_THREADS; size_t duration = DEFAULT_DURATION; size_t print_vals_num = 100; size_t pf_vals_num = 1023; size_t put, put_explicit = false; double update_rate, put_rate, get_rate; size_t size_after = 0; int seed = 0; __thread unsigned long * seeds; uint32_t rand_max; #define rand_min 1 static volatile int stop; __thread uint32_t phys_id; volatile ticks *putting_succ; volatile ticks *putting_fail; volatile ticks *getting_succ; volatile ticks *getting_fail; volatile ticks *removing_succ; volatile ticks *removing_fail; volatile ticks *putting_count; volatile ticks *putting_count_succ; volatile ticks *getting_count; volatile ticks *getting_count_succ; volatile ticks *removing_count; volatile ticks *removing_count_succ; volatile ticks *total; /* ################################################################### * * LOCALS * ################################################################### */ #ifdef DEBUG extern __thread uint32_t put_num_restarts; extern __thread uint32_t put_num_failed_expand; extern __thread uint32_t put_num_failed_on_new; #endif barrier_t barrier, barrier_global; typedef struct thread_data { uint8_t id; DS_TYPE* set; } thread_data_t; void* test(void* thread) { thread_data_t* td = (thread_data_t*) thread; uint8_t ID = td->id; phys_id = the_cores[ID]; set_cpu(phys_id); ssalloc_init(); DS_TYPE* set = td->set; PF_INIT(3, SSPFD_NUM_ENTRIES, ID); #if defined(COMPUTE_LATENCY) volatile ticks my_putting_succ = 0; volatile ticks my_putting_fail = 0; volatile ticks my_getting_succ = 0; volatile ticks my_getting_fail = 0; volatile ticks my_removing_succ = 0; volatile ticks my_removing_fail = 0; #endif uint64_t my_putting_count = 0; uint64_t my_getting_count = 0; uint64_t my_removing_count = 0; uint64_t my_putting_count_succ = 0; uint64_t my_getting_count_succ = 0; uint64_t my_removing_count_succ = 0; #if defined(COMPUTE_LATENCY) && PFD_TYPE == 0 volatile ticks start_acq, end_acq; volatile ticks correction = getticks_correction_calc(); #endif seeds = seed_rand(); #if GC == 1 alloc = (ssmem_allocator_t*) malloc(sizeof(ssmem_allocator_t)); assert(alloc != NULL); ssmem_alloc_init(alloc, SSMEM_DEFAULT_MEM_SIZE, ID); ssmem_allocator_t* alloc_data = (ssmem_allocator_t*) malloc(sizeof(ssmem_allocator_t)); assert(alloc_data != NULL); ssmem_alloc_init(alloc_data, SSMEM_DEFAULT_MEM_SIZE, ID); #endif uint64_t key; size_t* val = NULL; int c = 0; uint32_t scale_rem = (uint32_t) (update_rate * UINT_MAX); uint32_t scale_put = (uint32_t) (put_rate * UINT_MAX); int i; uint32_t num_elems_thread = (uint32_t) (initial / num_threads); int32_t missing = (uint32_t) initial - (num_elems_thread * num_threads); if (ID < missing) { num_elems_thread++; } #if INITIALIZE_FROM_ONE == 1 num_elems_thread = (ID == 0) * initial; #endif for(i = 0; i < num_elems_thread; i++) { key = (my_random(&(seeds[0]), &(seeds[1]), &(seeds[2])) % (rand_max + 1)) + rand_min; if (val == NULL) { val = (size_t*) ssmem_alloc(alloc_data, sizeof(size_t)); } val[0] = key; if(DS_ADD(set, key, val) == false) { i--; } else { val = NULL; } } MEM_BARRIER; barrier_cross(&barrier); if (!ID) { printf("#BEFORE size is: %zu\n", (size_t) DS_SIZE(set)); } barrier_cross(&barrier_global); while (stop == 0) { c = (uint32_t)(my_random(&(seeds[0]),&(seeds[1]),&(seeds[2]))); key = (c & rand_max) + rand_min; if (unlikely(c <= scale_put)) { if (val == NULL) { val = (size_t*) ssmem_alloc(alloc_data, sizeof(size_t)); } val[0] = key; int res; START_TS(1); res = DS_ADD(set, key, val); END_TS(1, my_putting_count); if(res) { ADD_DUR(my_putting_succ); my_putting_count_succ++; val = NULL; } ADD_DUR_FAIL(my_putting_fail); my_putting_count++; } else if(unlikely(c <= scale_rem)) { size_t* removed; START_TS(2); removed = (size_t*) DS_REMOVE(set, key); END_TS(2, my_removing_count); if(removed != NULL) { ADD_DUR(my_removing_succ); my_removing_count_succ++; if (removed[0] != key) { printf(" *[REM]* WRONG for key: %-10lu : %-10lu @ %p\n", key, removed[0], removed); } ssmem_free(alloc_data, removed); } ADD_DUR_FAIL(my_removing_fail); my_removing_count++; } else { size_t* res; START_TS(0); res = (size_t*) DS_CONTAINS(set, key); END_TS(0, my_getting_count); if(res != NULL) { ADD_DUR(my_getting_succ); my_getting_count_succ++; if (res[0] != key) { printf(" *[GET]* WRONG for key: %-10lu : %-10lu @ %p\n", key, res[0], res); } } ADD_DUR_FAIL(my_getting_fail); my_getting_count++; } } barrier_cross(&barrier); if (!ID) { size_after = DS_SIZE(set); printf("#AFTER size is: %zu\n", size_after); } barrier_cross(&barrier); #if defined(COMPUTE_LATENCY) putting_succ[ID] += my_putting_succ; putting_fail[ID] += my_putting_fail; getting_succ[ID] += my_getting_succ; getting_fail[ID] += my_getting_fail; removing_succ[ID] += my_removing_succ; removing_fail[ID] += my_removing_fail; #endif putting_count[ID] += my_putting_count; getting_count[ID] += my_getting_count; removing_count[ID]+= my_removing_count; putting_count_succ[ID] += my_putting_count_succ; getting_count_succ[ID] += my_getting_count_succ; removing_count_succ[ID]+= my_removing_count_succ; EXEC_IN_DEC_ID_ORDER(ID, num_threads) { print_latency_stats(ID, SSPFD_NUM_ENTRIES, print_vals_num); } EXEC_IN_DEC_ID_ORDER_END(&barrier); SSPFDTERM(); #if GC == 1 ssmem_term(); free(alloc); free(alloc_data); #endif pthread_exit(NULL); } int main(int argc, char **argv) { set_cpu(the_cores[0]); ssalloc_init(); seeds = seed_rand(); struct option long_options[] = { // These options don't set a flag {"help", no_argument, NULL, 'h'}, {"duration", required_argument, NULL, 'd'}, {"initial-size", required_argument, NULL, 'i'}, {"num-threads", required_argument, NULL, 'n'}, {"range", required_argument, NULL, 'r'}, {"update-rate", required_argument, NULL, 'u'}, {"num-buckets", required_argument, NULL, 'b'}, {"print-vals", required_argument, NULL, 'v'}, {"vals-pf", required_argument, NULL, 'f'}, {NULL, 0, NULL, 0} }; int i, c; while(1) { i = 0; c = getopt_long(argc, argv, "hAf:d:i:n:r:s:u:m:a:l:p:b:v:f:", long_options, &i); if(c == -1) break; if(c == 0 && long_options[i].flag == 0) c = long_options[i].val; switch(c) { case 0: /* Flag is automatically set */ break; case 'h': printf("ASCYLIB -- stress test " "\n" "\n" "Usage:\n" " %s [options...]\n" "\n" "Options:\n" " -h, --help\n" " Print this message\n" " -d, --duration <int>\n" " Test duration in milliseconds\n" " -i, --initial-size <int>\n" " Number of elements to insert before test\n" " -n, --num-threads <int>\n" " Number of threads\n" " -r, --range <int>\n" " Range of integer values inserted in set\n" " -u, --update-rate <int>\n" " Percentage of update transactions\n" " -p, --put-rate <int>\n" " Percentage of put update transactions (should be less than percentage of updates)\n" " -b, --num-buckets <int>\n" " Number of initial buckets (stronger than -l)\n" " -v, --print-vals <int>\n" " When using detailed profiling, how many values to print.\n" " -f, --val-pf <int>\n" " When using detailed profiling, how many values to keep track of.\n" , argv[0]); exit(0); case 'd': duration = atoi(optarg); break; case 'i': initial = atoi(optarg); break; case 'n': num_threads = atoi(optarg); break; case 'r': range = atol(optarg); break; case 'u': update = atoi(optarg); break; case 'p': put_explicit = 1; put = atoi(optarg); break; case 'l': load_factor = atoi(optarg); break; case 'v': print_vals_num = atoi(optarg); break; case 'f': pf_vals_num = pow2roundup(atoi(optarg)) - 1; break; case '?': default: printf("Use -h or --help for help\n"); exit(1); } } if (!is_power_of_two(initial)) { size_t initial_pow2 = pow2roundup(initial); printf("** rounding up initial (to make it power of 2): old: %zu / new: %zu\n", initial, initial_pow2); initial = initial_pow2; } if (range < initial) { range = 2 * initial; } printf("## Test correctness \n"); printf("## Initial: %zu / Range: %zu\n", initial, range); double kb = initial * sizeof(DS_NODE) / 1024.0; double mb = kb / 1024.0; printf("Sizeof initial: %.2f KB = %.2f MB\n", kb, mb); if (!is_power_of_two(range)) { size_t range_pow2 = pow2roundup(range); printf("** rounding up range (to make it power of 2): old: %zu / new: %zu\n", range, range_pow2); range = range_pow2; } if (put > update) { put = update; } update_rate = update / 100.0; if (put_explicit) { put_rate = put / 100.0; } else { put_rate = update_rate / 2; } get_rate = 1 - update_rate; /* printf("num_threads = %u\n", num_threads); */ /* printf("cap: = %u\n", num_buckets); */ /* printf("num elem = %u\n", num_elements); */ /* printf("filing rate= %f\n", filling_rate); */ /* printf("update = %f (putting = %f)\n", update_rate, put_rate); */ rand_max = range - 1; struct timeval start, end; struct timespec timeout; timeout.tv_sec = duration / 1000; timeout.tv_nsec = (duration % 1000) * 1000000; stop = 0; DS_TYPE* set = DS_NEW(); assert(set != NULL); /* Initializes the local data */ putting_succ = (ticks *) calloc(num_threads , sizeof(ticks)); putting_fail = (ticks *) calloc(num_threads , sizeof(ticks)); getting_succ = (ticks *) calloc(num_threads , sizeof(ticks)); getting_fail = (ticks *) calloc(num_threads , sizeof(ticks)); removing_succ = (ticks *) calloc(num_threads , sizeof(ticks)); removing_fail = (ticks *) calloc(num_threads , sizeof(ticks)); putting_count = (ticks *) calloc(num_threads , sizeof(ticks)); putting_count_succ = (ticks *) calloc(num_threads , sizeof(ticks)); getting_count = (ticks *) calloc(num_threads , sizeof(ticks)); getting_count_succ = (ticks *) calloc(num_threads , sizeof(ticks)); removing_count = (ticks *) calloc(num_threads , sizeof(ticks)); removing_count_succ = (ticks *) calloc(num_threads , sizeof(ticks)); pthread_t threads[num_threads]; pthread_attr_t attr; int rc; void *status; barrier_init(&barrier_global, num_threads + 1); barrier_init(&barrier, num_threads); /* Initialize and set thread detached attribute */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); thread_data_t* tds = (thread_data_t*) malloc(num_threads * sizeof(thread_data_t)); long t; for(t = 0; t < num_threads; t++) { tds[t].id = t; tds[t].set = set; rc = pthread_create(&threads[t], &attr, test, tds + t); if (rc) { printf("ERROR; return code from pthread_create() is %d\n", rc); exit(-1); } } /* Free attribute and wait for the other threads */ pthread_attr_destroy(&attr); barrier_cross(&barrier_global); gettimeofday(&start, NULL); nanosleep(&timeout, NULL); stop = 1; gettimeofday(&end, NULL); duration = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000); for(t = 0; t < num_threads; t++) { rc = pthread_join(threads[t], &status); if (rc) { printf("ERROR; return code from pthread_join() is %d\n", rc); exit(-1); } } free(tds); volatile ticks putting_suc_total = 0; volatile ticks putting_fal_total = 0; volatile ticks getting_suc_total = 0; volatile ticks getting_fal_total = 0; volatile ticks removing_suc_total = 0; volatile ticks removing_fal_total = 0; volatile uint64_t putting_count_total = 0; volatile uint64_t putting_count_total_succ = 0; volatile uint64_t getting_count_total = 0; volatile uint64_t getting_count_total_succ = 0; volatile uint64_t removing_count_total = 0; volatile uint64_t removing_count_total_succ = 0; for(t=0; t < num_threads; t++) { putting_suc_total += putting_succ[t]; putting_fal_total += putting_fail[t]; getting_suc_total += getting_succ[t]; getting_fal_total += getting_fail[t]; removing_suc_total += removing_succ[t]; removing_fal_total += removing_fail[t]; putting_count_total += putting_count[t]; putting_count_total_succ += putting_count_succ[t]; getting_count_total += getting_count[t]; getting_count_total_succ += getting_count_succ[t]; removing_count_total += removing_count[t]; removing_count_total_succ += removing_count_succ[t]; } #if defined(COMPUTE_LATENCY) printf("#thread srch_suc srch_fal insr_suc insr_fal remv_suc remv_fal ## latency (in cycles) \n"); fflush(stdout); long unsigned get_suc = (getting_count_total_succ) ? getting_suc_total / getting_count_total_succ : 0; long unsigned get_fal = (getting_count_total - getting_count_total_succ) ? getting_fal_total / (getting_count_total - getting_count_total_succ) : 0; long unsigned put_suc = putting_count_total_succ ? putting_suc_total / putting_count_total_succ : 0; long unsigned put_fal = (putting_count_total - putting_count_total_succ) ? putting_fal_total / (putting_count_total - putting_count_total_succ) : 0; long unsigned rem_suc = removing_count_total_succ ? removing_suc_total / removing_count_total_succ : 0; long unsigned rem_fal = (removing_count_total - removing_count_total_succ) ? removing_fal_total / (removing_count_total - removing_count_total_succ) : 0; printf("%-7zu %-8lu %-8lu %-8lu %-8lu %-8lu %-8lu\n", num_threads, get_suc, get_fal, put_suc, put_fal, rem_suc, rem_fal); #endif #define LLU long long unsigned int int UNUSED pr = (int) (putting_count_total_succ - removing_count_total_succ); if (size_after != (initial + pr)) { printf("// WRONG size. %zu + %d != %zu\n", initial, pr, size_after); assert(size_after == (initial + pr)); } printf(" : %-10s | %-10s | %-11s | %-11s | %s\n", "total", "success", "succ %", "total %", "effective %"); uint64_t total = putting_count_total + getting_count_total + removing_count_total; double putting_perc = 100.0 * (1 - ((double)(total - putting_count_total) / total)); double putting_perc_succ = (1 - (double) (putting_count_total - putting_count_total_succ) / putting_count_total) * 100; double getting_perc = 100.0 * (1 - ((double)(total - getting_count_total) / total)); double getting_perc_succ = (1 - (double) (getting_count_total - getting_count_total_succ) / getting_count_total) * 100; double removing_perc = 100.0 * (1 - ((double)(total - removing_count_total) / total)); double removing_perc_succ = (1 - (double) (removing_count_total - removing_count_total_succ) / removing_count_total) * 100; printf("srch: %-10llu | %-10llu | %10.1f%% | %10.1f%% | \n", (LLU) getting_count_total, (LLU) getting_count_total_succ, getting_perc_succ, getting_perc); printf("insr: %-10llu | %-10llu | %10.1f%% | %10.1f%% | %10.1f%%\n", (LLU) putting_count_total, (LLU) putting_count_total_succ, putting_perc_succ, putting_perc, (putting_perc * putting_perc_succ) / 100); printf("rems: %-10llu | %-10llu | %10.1f%% | %10.1f%% | %10.1f%%\n", (LLU) removing_count_total, (LLU) removing_count_total_succ, removing_perc_succ, removing_perc, (removing_perc * removing_perc_succ) / 100); double throughput = (putting_count_total + getting_count_total + removing_count_total) * 1000.0 / duration; printf("#txs %zu\t(%-10.0f\n", num_threads, throughput); printf("#Mops %.3f\n", throughput / 1e6); pthread_exit(NULL); return 0; }
Gwinel/ASCYLIB
src/tests/test_correct.c
C
gpl-2.0
18,395
/* * arch/arm/mach-kirkwood/openrd-setup.c * * Marvell OpenRD (Base|Client|Ultimate) Board Setup * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/ata_platform.h> #include <linux/mv643xx_eth.h> #include <linux/i2c.h> #include <linux/gpio.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/kirkwood.h> #include <linux/platform_data/mmc-mvsdio.h> #include "common.h" #include "mpp.h" static struct mtd_partition openrd_nand_parts[] = { { .name = "u-boot", .offset = 0, .size = SZ_1M, .mask_flags = MTD_WRITEABLE }, { .name = "uImage", .offset = MTDPART_OFS_NXTBLK, .size = SZ_4M }, { .name = "root", .offset = MTDPART_OFS_NXTBLK, .size = MTDPART_SIZ_FULL }, }; static struct mv643xx_eth_platform_data openrd_ge00_data = { .phy_addr = MV643XX_ETH_PHY_ADDR(8), }; static struct mv643xx_eth_platform_data openrd_ge01_data = { .phy_addr = MV643XX_ETH_PHY_ADDR(24), }; static struct mv_sata_platform_data openrd_sata_data = { .n_ports = 2, }; static struct mvsdio_platform_data openrd_mvsdio_data = { .gpio_card_detect = 29, /* MPP29 used as SD card detect */ .gpio_write_protect = -1, }; static unsigned int openrd_mpp_config[] __initdata = { MPP12_SD_CLK, MPP13_SD_CMD, MPP14_SD_D0, MPP15_SD_D1, MPP16_SD_D2, MPP17_SD_D3, MPP28_GPIO, MPP29_GPIO, MPP34_GPIO, 0 }; /* Configure MPP for UART1 */ static unsigned int openrd_uart1_mpp_config[] __initdata = { MPP13_UART1_TXD, MPP14_UART1_RXD, 0 }; static struct i2c_board_info i2c_board_info[] __initdata = { { I2C_BOARD_INFO("cs42l51", 0x4a), }, }; static struct platform_device openrd_client_audio_device = { .name = "openrd-client-audio", .id = -1, }; static int __initdata uart1; static int __init sd_uart_selection(char *str) { uart1 = -EINVAL; /* Default is SD. Change if required, for UART */ if (!str) return 0; if (!strncmp(str, "232", 3)) { uart1 = 232; } else if (!strncmp(str, "485", 3)) { /* OpenRD-Base doesn't have RS485. Treat is as an * unknown argument & just have default setting - * which is SD */ if (machine_is_openrd_base()) { uart1 = -ENODEV; return 1; } uart1 = 485; } return 1; } /* Parse boot_command_line string kw_openrd_init_uart1=232/485 */ __setup("kw_openrd_init_uart1=", sd_uart_selection); static int __init uart1_mpp_config(void) { kirkwood_mpp_conf(openrd_uart1_mpp_config); if (gpio_request(34, "SD_UART1_SEL")) { pr_err("GPIO request 34 failed for SD/UART1 selection\n"); return -EIO; } if (gpio_request(28, "RS232_RS485_SEL")) { pr_err("GPIO request 28 failed for RS232/RS485 selection\n"); gpio_free(34); return -EIO; } /* Select UART1 * Pin # 34: 0 => UART1, 1 => SD */ gpio_direction_output(34, 0); /* Select RS232 OR RS485 * Pin # 28: 0 => RS232, 1 => RS485 */ if (uart1 == 232) gpio_direction_output(28, 0); else gpio_direction_output(28, 1); gpio_free(34); gpio_free(28); return 0; } static void __init openrd_init(void) { /* * Basic setup. Needs to be called early. */ kirkwood_init(); kirkwood_mpp_conf(openrd_mpp_config); kirkwood_uart0_init(); kirkwood_nand_init(openrd_nand_parts, ARRAY_SIZE(openrd_nand_parts), 25); kirkwood_ehci_init(); if (machine_is_openrd_ultimate()) { openrd_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0); openrd_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1); } kirkwood_ge00_init(&openrd_ge00_data); if (!machine_is_openrd_base()) kirkwood_ge01_init(&openrd_ge01_data); kirkwood_sata_init(&openrd_sata_data); kirkwood_i2c_init(); if (machine_is_openrd_client() || machine_is_openrd_ultimate()) { platform_device_register(&openrd_client_audio_device); i2c_register_board_info(0, i2c_board_info, ARRAY_SIZE(i2c_board_info)); kirkwood_audio_init(); } if (uart1 <= 0) { if (uart1 < 0) pr_err("Invalid kernel parameter to select UART1. Defaulting to SD. ERROR CODE: %d\n", uart1); /* Select SD * Pin # 34: 0 => UART1, 1 => SD */ if (gpio_request(34, "SD_UART1_SEL")) { pr_err("GPIO request 34 failed for SD/UART1 selection\n"); } else { gpio_direction_output(34, 1); gpio_free(34); kirkwood_sdio_init(&openrd_mvsdio_data); } } else { if (!uart1_mpp_config()) kirkwood_uart1_init(); } } static int __init openrd_pci_init(void) { if (machine_is_openrd_base() || machine_is_openrd_client() || machine_is_openrd_ultimate()) kirkwood_pcie_init(KW_PCIE0); return 0; } subsys_initcall(openrd_pci_init); #ifdef CONFIG_MACH_OPENRD_BASE MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board") /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ .atag_offset = 0x100, .init_machine = openrd_init, .map_io = kirkwood_map_io, .init_early = kirkwood_init_early, .init_irq = kirkwood_init_irq, .init_time = kirkwood_timer_init, .restart = kirkwood_restart, MACHINE_END #endif #ifdef CONFIG_MACH_OPENRD_CLIENT MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board") /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ .atag_offset = 0x100, .init_machine = openrd_init, .map_io = kirkwood_map_io, .init_early = kirkwood_init_early, .init_irq = kirkwood_init_irq, .init_time = kirkwood_timer_init, .restart = kirkwood_restart, MACHINE_END #endif #ifdef CONFIG_MACH_OPENRD_ULTIMATE MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board") /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ .atag_offset = 0x100, .init_machine = openrd_init, .map_io = kirkwood_map_io, .init_early = kirkwood_init_early, .init_irq = kirkwood_init_irq, .init_time = kirkwood_timer_init, .restart = kirkwood_restart, MACHINE_END #endif
woodbunny/JIT-ASLR-kernel
arch/arm/mach-kirkwood/openrd-setup.c
C
gpl-2.0
5,956
/* * drivers/usb/misc/lvstest.c * * Test pattern generation for Link Layer Validation System Tests * * Copyright (C) 2014 ST Microelectronics * Pratyush Anand <pratyush.anand@st.com> * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/usb.h> #include <linux/usb/ch11.h> #include <linux/usb/hcd.h> #include <linux/usb/phy.h> struct lvs_rh { /* root hub interface */ struct usb_interface *intf; /* if lvs device connected */ bool present; /* port no at which lvs device is present */ int portnum; /* urb buffer */ u8 buffer[8]; /* class descriptor */ struct usb_hub_descriptor descriptor; /* urb for polling interrupt pipe */ struct urb *urb; /* LVS RH work queue */ struct workqueue_struct *rh_queue; /* LVH RH work */ struct work_struct rh_work; /* RH port status */ struct usb_port_status port_status; }; static struct usb_device *create_lvs_device(struct usb_interface *intf) { struct usb_device *udev, *hdev; struct usb_hcd *hcd; struct lvs_rh *lvs = usb_get_intfdata(intf); if (!lvs->present) { dev_err(&intf->dev, "No LVS device is present\n"); return NULL; } hdev = interface_to_usbdev(intf); hcd = bus_to_hcd(hdev->bus); udev = usb_alloc_dev(hdev, hdev->bus, lvs->portnum); if (!udev) { dev_err(&intf->dev, "Could not allocate lvs udev\n"); return NULL; } udev->speed = USB_SPEED_SUPER; udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512); usb_set_device_state(udev, USB_STATE_DEFAULT); if (hcd->driver->enable_device) { if (hcd->driver->enable_device(hcd, udev) < 0) { dev_err(&intf->dev, "Failed to enable\n"); usb_put_dev(udev); return NULL; } } return udev; } static void destroy_lvs_device(struct usb_device *udev) { struct usb_device *hdev = udev->parent; struct usb_hcd *hcd = bus_to_hcd(hdev->bus); if (hcd->driver->free_dev) hcd->driver->free_dev(hcd, udev); usb_put_dev(udev); } static int lvs_rh_clear_port_feature(struct usb_device *hdev, int port1, int feature) { return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1, NULL, 0, 1000); } static int lvs_rh_set_port_feature(struct usb_device *hdev, int port1, int feature) { return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, NULL, 0, 1000); } static ssize_t u3_entry_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *hdev = interface_to_usbdev(intf); struct lvs_rh *lvs = usb_get_intfdata(intf); struct usb_device *udev; int ret; udev = create_lvs_device(intf); if (!udev) { dev_err(dev, "failed to create lvs device\n"); return -ENOMEM; } ret = lvs_rh_set_port_feature(hdev, lvs->portnum, USB_PORT_FEAT_SUSPEND); if (ret < 0) dev_err(dev, "can't issue U3 entry %d\n", ret); destroy_lvs_device(udev); if (ret < 0) return ret; return count; } static DEVICE_ATTR_WO(u3_entry); static ssize_t u3_exit_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *hdev = interface_to_usbdev(intf); struct lvs_rh *lvs = usb_get_intfdata(intf); struct usb_device *udev; int ret; udev = create_lvs_device(intf); if (!udev) { dev_err(dev, "failed to create lvs device\n"); return -ENOMEM; } ret = lvs_rh_clear_port_feature(hdev, lvs->portnum, USB_PORT_FEAT_SUSPEND); if (ret < 0) dev_err(dev, "can't issue U3 exit %d\n", ret); destroy_lvs_device(udev); if (ret < 0) return ret; return count; } static DEVICE_ATTR_WO(u3_exit); static ssize_t hot_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *hdev = interface_to_usbdev(intf); struct lvs_rh *lvs = usb_get_intfdata(intf); int ret; ret = lvs_rh_set_port_feature(hdev, lvs->portnum, USB_PORT_FEAT_RESET); if (ret < 0) { dev_err(dev, "can't issue hot reset %d\n", ret); return ret; } return count; } static DEVICE_ATTR_WO(hot_reset); static ssize_t u2_timeout_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *hdev = interface_to_usbdev(intf); struct lvs_rh *lvs = usb_get_intfdata(intf); unsigned long val; int ret; ret = kstrtoul(buf, 10, &val); if (ret < 0) { dev_err(dev, "couldn't parse string %d\n", ret); return ret; } if (val < 0 || val > 127) return -EINVAL; ret = lvs_rh_set_port_feature(hdev, lvs->portnum | (val << 8), USB_PORT_FEAT_U2_TIMEOUT); if (ret < 0) { dev_err(dev, "Error %d while setting U2 timeout %ld\n", ret, val); return ret; } return count; } static DEVICE_ATTR_WO(u2_timeout); static ssize_t u1_timeout_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *hdev = interface_to_usbdev(intf); struct lvs_rh *lvs = usb_get_intfdata(intf); unsigned long val; int ret; ret = kstrtoul(buf, 10, &val); if (ret < 0) { dev_err(dev, "couldn't parse string %d\n", ret); return ret; } if (val < 0 || val > 127) return -EINVAL; ret = lvs_rh_set_port_feature(hdev, lvs->portnum | (val << 8), USB_PORT_FEAT_U1_TIMEOUT); if (ret < 0) { dev_err(dev, "Error %d while setting U1 timeout %ld\n", ret, val); return ret; } return count; } static DEVICE_ATTR_WO(u1_timeout); static ssize_t get_dev_desc_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *udev; struct usb_device_descriptor *descriptor; int ret; descriptor = kmalloc(sizeof(*descriptor), GFP_KERNEL); if (!descriptor) { dev_err(dev, "failed to allocate descriptor memory\n"); return -ENOMEM; } udev = create_lvs_device(intf); if (!udev) { dev_err(dev, "failed to create lvs device\n"); ret = -ENOMEM; goto free_desc; } ret = usb_control_msg(udev, (PIPE_CONTROL << 30) | USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, USB_DT_DEVICE << 8, 0, descriptor, sizeof(*descriptor), USB_CTRL_GET_TIMEOUT); if (ret < 0) dev_err(dev, "can't read device descriptor %d\n", ret); destroy_lvs_device(udev); free_desc: kfree(descriptor); if (ret < 0) return ret; return count; } static DEVICE_ATTR_WO(get_dev_desc); static struct attribute *lvs_attributes[] = { &dev_attr_get_dev_desc.attr, &dev_attr_u1_timeout.attr, &dev_attr_u2_timeout.attr, &dev_attr_hot_reset.attr, &dev_attr_u3_entry.attr, &dev_attr_u3_exit.attr, NULL }; static const struct attribute_group lvs_attr_group = { .attrs = lvs_attributes, }; static void lvs_rh_work(struct work_struct *work) { struct lvs_rh *lvs = container_of(work, struct lvs_rh, rh_work); struct usb_interface *intf = lvs->intf; struct usb_device *hdev = interface_to_usbdev(intf); struct usb_hcd *hcd = bus_to_hcd(hdev->bus); struct usb_hub_descriptor *descriptor = &lvs->descriptor; struct usb_port_status *port_status = &lvs->port_status; int i, ret = 0; u16 portchange; /* Examine each root port */ for (i = 1; i <= descriptor->bNbrPorts; i++) { ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, i, port_status, sizeof(*port_status), 1000); if (ret < 4) continue; portchange = le16_to_cpu(port_status->wPortChange); if (portchange & USB_PORT_STAT_C_LINK_STATE) lvs_rh_clear_port_feature(hdev, i, USB_PORT_FEAT_C_PORT_LINK_STATE); if (portchange & USB_PORT_STAT_C_ENABLE) lvs_rh_clear_port_feature(hdev, i, USB_PORT_FEAT_C_ENABLE); if (portchange & USB_PORT_STAT_C_RESET) lvs_rh_clear_port_feature(hdev, i, USB_PORT_FEAT_C_RESET); if (portchange & USB_PORT_STAT_C_BH_RESET) lvs_rh_clear_port_feature(hdev, i, USB_PORT_FEAT_C_BH_PORT_RESET); if (portchange & USB_PORT_STAT_C_CONNECTION) { lvs_rh_clear_port_feature(hdev, i, USB_PORT_FEAT_C_CONNECTION); if (le16_to_cpu(port_status->wPortStatus) & USB_PORT_STAT_CONNECTION) { lvs->present = true; lvs->portnum = i; if (hcd->usb_phy) usb_phy_notify_connect(hcd->usb_phy, USB_SPEED_SUPER); } else { lvs->present = false; if (hcd->usb_phy) usb_phy_notify_disconnect(hcd->usb_phy, USB_SPEED_SUPER); } break; } } ret = usb_submit_urb(lvs->urb, GFP_KERNEL); if (ret != 0 && ret != -ENODEV && ret != -EPERM) dev_err(&intf->dev, "urb resubmit error %d\n", ret); } static void lvs_rh_irq(struct urb *urb) { struct lvs_rh *lvs = urb->context; queue_work(lvs->rh_queue, &lvs->rh_work); } static int lvs_rh_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *hdev; struct usb_host_interface *desc; struct usb_endpoint_descriptor *endpoint; struct lvs_rh *lvs; unsigned int pipe; int ret, maxp; hdev = interface_to_usbdev(intf); desc = intf->cur_altsetting; endpoint = &desc->endpoint[0].desc; /* valid only for SS root hub */ if (hdev->descriptor.bDeviceProtocol != USB_HUB_PR_SS || hdev->parent) { dev_err(&intf->dev, "Bind LVS driver with SS root Hub only\n"); return -EINVAL; } lvs = devm_kzalloc(&intf->dev, sizeof(*lvs), GFP_KERNEL); if (!lvs) return -ENOMEM; lvs->intf = intf; usb_set_intfdata(intf, lvs); /* how many number of ports this root hub has */ ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB, USB_DT_SS_HUB << 8, 0, &lvs->descriptor, USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT); if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) { dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret); return ret; } /* submit urb to poll interrupt endpoint */ lvs->urb = usb_alloc_urb(0, GFP_KERNEL); if (!lvs->urb) { dev_err(&intf->dev, "couldn't allocate lvs urb\n"); return -ENOMEM; } lvs->rh_queue = create_singlethread_workqueue("lvs_rh_queue"); if (!lvs->rh_queue) { dev_err(&intf->dev, "couldn't create workqueue\n"); ret = -ENOMEM; goto free_urb; } INIT_WORK(&lvs->rh_work, lvs_rh_work); ret = sysfs_create_group(&intf->dev.kobj, &lvs_attr_group); if (ret < 0) { dev_err(&intf->dev, "Failed to create sysfs node %d\n", ret); goto destroy_queue; } pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp, lvs_rh_irq, lvs, endpoint->bInterval); ret = usb_submit_urb(lvs->urb, GFP_KERNEL); if (ret < 0) { dev_err(&intf->dev, "couldn't submit lvs urb %d\n", ret); goto sysfs_remove; } return ret; sysfs_remove: sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group); destroy_queue: destroy_workqueue(lvs->rh_queue); free_urb: usb_free_urb(lvs->urb); return ret; } static void lvs_rh_disconnect(struct usb_interface *intf) { struct lvs_rh *lvs = usb_get_intfdata(intf); sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group); destroy_workqueue(lvs->rh_queue); usb_free_urb(lvs->urb); } static struct usb_driver lvs_driver = { .name = "lvs", .probe = lvs_rh_probe, .disconnect = lvs_rh_disconnect, }; module_usb_driver(lvs_driver); MODULE_DESCRIPTION("Link Layer Validation System Driver"); MODULE_LICENSE("GPL");
tom--pollard/linux-raspberrypi_4.1
drivers/usb/misc/lvstest.c
C
gpl-2.0
11,728
a .glyphicon-spin,fieldset .panel-heading a.panel-title:hover{text-decoration:none}.tabs-left>.nav-tabs>li:focus,.tabs-left>.nav-tabs>li>a:focus,.tabs-right>.nav-tabs>li:focus,.tabs-right>.nav-tabs>li>a:focus{outline:0}html.overlay-open .navbar-fixed-top{z-index:400}html.js fieldset.collapsed{border-left-width:1px;border-right-width:1px;height:auto}html.js input.form-autocomplete{background-image:none}html.js .autocomplete-throbber{background-position:100% 2px;background-repeat:no-repeat;display:inline-block;height:15px;margin:2px 0 0 2px;width:15px}html.js .autocomplete-throbber.throbbing{background-position:100% -18px}body{position:relative}body.admin-expanded.admin-vertical.admin-nw .navbar,body.admin-expanded.admin-vertical.admin-sw .navbar{margin-left:260px}body.navbar-is-fixed-top{padding-top:64px!important}body.navbar-is-fixed-bottom{padding-bottom:64px!important}body.toolbar{padding-top:30px!important}body.toolbar .navbar-fixed-top{top:30px}body.toolbar.navbar-is-fixed-top{padding-top:94px!important}body.toolbar-drawer{padding-top:64px!important}body.toolbar-drawer .navbar-fixed-top{top:64px}body.toolbar-drawer.navbar-is-fixed-top{padding-top:128px!important}body.admin-menu .navbar-fixed-top{top:29px}body.admin-menu.navbar-is-fixed-top{padding-top:93px!important}body div#admin-toolbar{z-index:1600}body #admin-menu,body #admin-toolbar,body #toolbar{-webkit-box-shadow:none;box-shadow:none}body #admin-menu{margin:0;padding:0;position:fixed;z-index:1600}body #admin-menu .dropdown li{line-height:normal}@media screen and (min-width:768px){.navbar.container{max-width:720px}}@media screen and (min-width:992px){.navbar.container{max-width:940px}}@media screen and (min-width:1200px){.navbar.container{max-width:1140px}}.navbar.container,.navbar.container-fluid{margin-top:20px}.navbar.container-fluid>.container-fluid,.navbar.container>.container{margin:0;padding:0;width:auto}#overlay-container,.overlay-element,.overlay-modal-background{z-index:1500}#toolbar{z-index:1600}.modal{z-index:1620}.modal-dialog{z-index:1630}.ctools-modal-dialog .modal-body{width:100%!important;overflow:auto}.book-toc>.dropdown-menu,.region-help .block,div.image-widget-data{overflow:hidden}.modal-backdrop{z-index:1610}.footer{margin-top:45px;padding-top:35px;padding-bottom:36px;border-top:1px solid #E5E5E5}.element-invisible{margin:0;padding:0;width:1px}.navbar .logo{margin-right:-15px;padding-left:15px;padding-right:15px}ul.secondary{float:left}@media screen and (min-width:768px){.navbar .logo{margin-right:0;padding-left:0}ul.secondary{float:right}}.block:first-child h2.block-title,.page-header{margin-top:0}p:last-child{margin-bottom:0}.region-help>.glyphicon{font-size:18px;float:left;margin:-.05em .5em 0 0}form#search-block-form{margin:0}.navbar #block-search-form{float:none;margin:5px 0 5px 5px}@media screen and (min-width:992px){.navbar #block-search-form{float:right}}.navbar #block-search-form .input-group-btn{width:auto}.navbar-search .control-group{margin-bottom:0}ul.action-links{margin:12px 0;padding:0}ul.action-links li{display:inline;margin:0;padding:0 6px 0 0}ul.action-links .glyphicon{padding-right:.5em}.uneditable-input,input,select,textarea{max-width:100%;width:auto}.filter-wrapper .form-type-select .filter-list,.managed-files.table td:first-child{width:100%}input.error{color:#a94442;border-color:#ebccd1}fieldset legend.panel-heading{float:left;line-height:1em;margin:0}fieldset .panel-body{clear:both;display:inherit}.form-type-password-confirm label,.panel-heading{display:block}fieldset .panel-heading a.panel-title{color:inherit;display:block;margin:-10px -15px;padding:10px 15px}.form-group:last-child,.panel:last-child{margin-bottom:0}.form-horizontal .form-group{margin-left:0;margin-right:0}.form-actions{clear:both}div.image-widget-data{float:none}table.sticky-header{z-index:1}.resizable-textarea textarea{border-radius:4px 4px 0 0}.ajax-progress-bar,.filter-wrapper{border-radius:0 0 4px 4px}.text-format-wrapper{margin-bottom:15px}.text-format-wrapper .filter-wrapper,.text-format-wrapper>.form-type-textarea{margin-bottom:0}.filter-wrapper .panel-body{padding:7px}.filter-wrapper .form-type-select{min-width:30%}.filter-help{margin-top:5px;text-align:center}@media screen and (min-width:768px){.filter-help{float:right}}.filter-help .glyphicon{margin:0 5px 0 0;vertical-align:text-top}.checkbox:first-child,.radio:first-child{margin-top:0}.checkbox:last-child,.radio:last-child{margin-bottom:0}.control-group .help-inline,.help-block{color:#777;font-size:12px;margin:5px 0 10px;padding:0}a.tabledrag-handle .handle{height:auto;width:auto}.error{color:#a94442}div.error,table tr.error{background-color:#f2dede;color:#a94442}.form-group.error,.form-group.has-error{background:0 0}.form-group.error .control-label,.form-group.error label,.form-group.has-error .control-label,.form-group.has-error label{color:#a94442;font-weight:600}.form-group.error .uneditable-input,.form-group.error input,.form-group.error select,.form-group.error textarea,.form-group.has-error .uneditable-input,.form-group.has-error input,.form-group.has-error select,.form-group.has-error textarea{color:#555}.form-group.error .help-block,.form-group.error .help-inline,.form-group.has-error .help-block,.form-group.has-error .help-inline,.submitted{color:#777}.nav-tabs{margin-bottom:10px}ul li.collapsed,ul li.expanded,ul li.leaf{list-style:none}.tabs--secondary{margin:0 0 10px}.submitted{margin-bottom:1em;font-style:italic;font-weight:400}.alert a,.book-toc>.dropdown-menu>li:nth-child(1)>a{font-weight:700}.form-type-password-confirm{position:relative}.form-type-password-confirm label .label{float:right}.form-type-password-confirm .password-help{padding-left:2em}@media (min-width:768px){.form-type-password-confirm .password-help{border-left:1px solid #ddd;left:50%;margin-left:15px;position:absolute}}@media (min-width:992px){.form-type-password-confirm .password-help{left:33.33333333%}}.form-type-password-confirm .progress{background:0 0;border-radius:0 0 5px 5px;-webkit-box-shadow:none;box-shadow:none;height:4px;margin:-5px 0 0}.form-type-password-confirm .form-type-password{clear:left}.form-type-password-confirm .form-control-feedback{right:15px}.form-type-password-confirm .help-block{clear:both}ul.pagination li>a.progress-disabled{float:left}.form-autocomplete .glyphicon{color:#777;font-size:120%}.form-autocomplete .glyphicon.glyphicon-spin{color:#428bca}.form-autocomplete .input-group-addon{background-color:#fff}.ajax-progress-bar{border:1px solid #ccc;margin:-1px 0 0;padding:6px 12px;width:100%}.ajax-progress-bar .progress{height:8px;margin:0}.ajax-progress-bar .message,.ajax-progress-bar .percentage{color:#777;font-size:12px;line-height:1em;margin:5px 0 0;padding:0}.glyphicon-spin{display:inline-block;-o-animation:spin 1s infinite linear;-webkit-animation:spin 1s infinite linear;animation:spin 1s infinite linear}a .glyphicon-spin{display:inline-block}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(359deg)}}@-o-keyframes spin{0%{-o-transform:rotate(0)}100%{-o-transform:rotate(359deg)}}@keyframes spin{0%{-webkit-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);-o-transform:rotate(359deg);transform:rotate(359deg)}}.tabbable{margin-bottom:20px}.tabs-below>.nav-tabs,.tabs-left>.nav-tabs,.tabs-right>.nav-tabs{border-bottom:0}.tabs-below>.nav-tabs .summary,.tabs-left>.nav-tabs .summary,.tabs-right>.nav-tabs .summary{color:#777;font-size:12px}.tab-pane>.panel-heading{display:none}.tab-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:focus,.tabs-below>.nav-tabs>li>a:hover{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:focus,.tabs-below>.nav-tabs>.active>a:hover{border-color:transparent #ddd #ddd}.tabs-left>.nav-tabs,.tabs-right>.nav-tabs{padding-bottom:20px;width:220px}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{margin-right:0;margin-bottom:3px}.tabs-left>.tab-content,.tabs-right>.tab-content{border-radius:0 4px 4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05);border:1px solid #ddd;overflow:hidden;padding:10px 15px}.tabs-left>.nav-tabs{float:left;margin-right:-1px}.tabs-left>.nav-tabs>li>a{border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:focus,.tabs-left>.nav-tabs>li>a:hover{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs>.active>a,.tabs-left>.nav-tabs>.active>a:focus,.tabs-left>.nav-tabs>.active>a:hover{border-color:#ddd transparent #ddd #ddd;-webkit-box-shadow:-1px 1px 1px rgba(0,0,0,.05);box-shadow:-1px 1px 1px rgba(0,0,0,.05)}.tabs-right>.nav-tabs{float:right;margin-left:-1px}.tabs-right>.nav-tabs>li>a{border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:focus,.tabs-right>.nav-tabs>li>a:hover{border-color:#eee #eee #eee #ddd;-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.05);box-shadow:1px 1px 1px rgba(0,0,0,.05)}.tabs-right>.nav-tabs>.active>a,.tabs-right>.nav-tabs>.active>a:focus,.tabs-right>.nav-tabs>.active>a:hover{border-color:#ddd #ddd #ddd transparent}td.checkbox,td.radio,th.checkbox,th.radio{display:table-cell}.views-display-settings .label{font-size:100%;color:#666}.views-display-settings .footer{padding:0;margin:4px 0 0}.views-exposed-form .views-exposed-widget .btn{margin-top:1.8em}table .checkbox input[type=checkbox],table .radio input[type=radio]{max-width:inherit}.form-horizontal .form-group label{position:relative;min-height:1px;margin-top:0;margin-bottom:0;padding-top:7px;padding-left:15px;padding-right:15px;text-align:right}@media (min-width:768px){.form-horizontal .form-group label{float:left;width:16.66666667%}body.navbar-is-fixed-top.navbar-administration.navbar-vertical.navbar-tray-open .navbar-fixed-top{left:240px;left:24rem}}.alert-success a{color:#2b542c}.alert-info a{color:#245269}.alert-warning a{color:#66512c}.alert-danger a{color:#843534}div.image-style-new,div.image-style-new div{display:block}div.image-style-new div.input-group{display:table}.table-striped>tbody>tr:nth-child(odd)>td.module,.table>tbody>tr>td.module,td.module{background:#ddd;font-weight:700}.book-toc>.dropdown-menu>.dropdown-header{white-space:nowrap}.book-toc>.dropdown-menu .dropdown-menu{-webkit-box-shadow:none;box-shadow:none;border:0;display:block;font-size:12px;margin:0;padding:0;position:static;width:100%}.book-toc>.dropdown-menu .dropdown-menu>li{padding-left:20px}.book-toc>.dropdown-menu .dropdown-menu>li>a{margin-left:-40px;padding-left:60px}#features-filter .form-item.form-type-checkbox{padding-left:20px}fieldset.features-export-component{font-size:12px}fieldset.features-export-component,html.js #features-export-form fieldset.features-export-component{margin:0 0 10px}fieldset.features-export-component .panel-heading{padding:5px 10px}fieldset.features-export-component .panel-heading a.panel-title{font-size:12px;font-weight:500;margin:-5px -10px;padding:5px 10px}fieldset.features-export-component .panel-body{padding:0 10px}div.features-export-list{margin:-11px 0 10px;padding:0 10px}div.features-export-list .form-type-checkbox,fieldset.features-export-component .component-select .form-type-checkbox{line-height:1em;margin:5px 5px 5px 0!important;min-height:0;padding:3px 3px 3px 25px!important}div.features-export-list .form-type-checkbox input[type=checkbox],fieldset.features-export-component .component-select .form-type-checkbox input[type=checkbox]{margin-top:0}body.navbar-is-fixed-top.navbar-administration.navbar-horizontal.navbar-tray-open .navbar-fixed-top{top:79px}body.navbar-is-fixed-top.navbar-administration .navbar-fixed-top{top:39px}.navbar-administration #navbar-administration.navbar-oriented .navbar-bar{z-index:1032}.navbar-administration #navbar-administration .navbar-tray{z-index:1031}body.navbar-is-fixed-top.navbar-administration{padding-top:103px!important}body.navbar-is-fixed-top.navbar-administration.navbar-horizontal.navbar-tray-open{padding-top:143px!important}body.navbar-tray-open.navbar-vertical.navbar-fixed{margin-left:24rem}#navbar-administration.navbar-oriented .navbar-tray-vertical{width:24rem}
P2Pvalue/cbpp-directory-code
sites/all/themes/bootstrap/css/3.2.0/overrides-sandstone.min.css
CSS
gpl-2.0
12,317
/* * linux/arch/cris/kernel/signal.c * * Based on arch/i386/kernel/signal.c by * Copyright (C) 1991, 1992 Linus Torvalds * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson * * * Ideas also taken from arch/arm. * * Copyright (C) 2000-2007 Axis Communications AB * * Authors: Bjorn Wesen (bjornw@axis.com) * */ #include <linux/sched.h> #include <linux/mm.h> #include <linux/smp.h> #include <linux/kernel.h> #include <linux/signal.h> #include <linux/errno.h> #include <linux/wait.h> #include <linux/ptrace.h> #include <linux/unistd.h> #include <linux/stddef.h> #include <asm/processor.h> #include <asm/ucontext.h> #include <asm/uaccess.h> #include <arch/system.h> #define DEBUG_SIG 0 /* a syscall in Linux/CRIS is a break 13 instruction which is 2 bytes */ /* manipulate regs so that upon return, it will be re-executed */ /* We rely on that pc points to the instruction after "break 13", so the * library must never do strange things like putting it in a delay slot. */ #define RESTART_CRIS_SYS(regs) regs->r10 = regs->orig_r10; regs->irp -= 2; void do_signal(int canrestart, struct pt_regs *regs); /* * Do a signal return; undo the signal stack. */ struct sigframe { struct sigcontext sc; unsigned long extramask[_NSIG_WORDS-1]; unsigned char retcode[8]; /* trampoline code */ }; struct rt_sigframe { struct siginfo *pinfo; void *puc; struct siginfo info; struct ucontext uc; unsigned char retcode[8]; /* trampoline code */ }; static int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) { unsigned int err = 0; unsigned long old_usp; /* Always make any pending restarted system calls return -EINTR */ current->restart_block.fn = do_no_restart_syscall; /* restore the regs from &sc->regs (same as sc, since regs is first) * (sc is already checked for VERIFY_READ since the sigframe was * checked in sys_sigreturn previously) */ if (__copy_from_user(regs, sc, sizeof(struct pt_regs))) goto badframe; /* make sure the U-flag is set so user-mode cannot fool us */ regs->dccr |= 1 << 8; /* restore the old USP as it was before we stacked the sc etc. * (we cannot just pop the sigcontext since we aligned the sp and * stuff after pushing it) */ err |= __get_user(old_usp, &sc->usp); wrusp(old_usp); /* TODO: the other ports use regs->orig_XX to disable syscall checks * after this completes, but we don't use that mechanism. maybe we can * use it now ? */ return err; badframe: return 1; } asmlinkage int sys_sigreturn(void) { struct pt_regs *regs = current_pt_regs(); struct sigframe __user *frame = (struct sigframe *)rdusp(); sigset_t set; /* * Since we stacked the signal on a dword boundary, * then frame should be dword aligned here. If it's * not, then the user is trying to mess with us. */ if (((long)frame) & 3) goto badframe; if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) goto badframe; if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1 && __copy_from_user(&set.sig[1], frame->extramask, sizeof(frame->extramask)))) goto badframe; set_current_blocked(&set); if (restore_sigcontext(regs, &frame->sc)) goto badframe; /* TODO: SIGTRAP when single-stepping as in arm ? */ return regs->r10; badframe: force_sig(SIGSEGV, current); return 0; } asmlinkage int sys_rt_sigreturn(void) { struct pt_regs *regs = current_pt_regs(); struct rt_sigframe __user *frame = (struct rt_sigframe *)rdusp(); sigset_t set; /* * Since we stacked the signal on a dword boundary, * then frame should be dword aligned here. If it's * not, then the user is trying to mess with us. */ if (((long)frame) & 3) goto badframe; if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) goto badframe; if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) goto badframe; set_current_blocked(&set); if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) goto badframe; if (restore_altstack(&frame->uc.uc_stack)) goto badframe; return regs->r10; badframe: force_sig(SIGSEGV, current); return 0; } /* * Set up a signal frame. */ static int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned long mask) { int err = 0; unsigned long usp = rdusp(); /* copy the regs. they are first in sc so we can use sc directly */ err |= __copy_to_user(sc, regs, sizeof(struct pt_regs)); /* Set the frametype to CRIS_FRAME_NORMAL for the execution of the signal handler. The frametype will be restored to its previous value in restore_sigcontext. */ regs->frametype = CRIS_FRAME_NORMAL; /* then some other stuff */ err |= __put_user(mask, &sc->oldmask); err |= __put_user(usp, &sc->usp); return err; } /* Figure out where we want to put the new signal frame * - usually on the stack. */ static inline void __user * get_sigframe(struct ksignal *ksig, size_t frame_size) { unsigned long sp = sigsp(rdusp(), ksig); /* make sure the frame is dword-aligned */ sp &= ~3; return (void __user*)(sp - frame_size); } /* grab and setup a signal frame. * * basically we stack a lot of state info, and arrange for the * user-mode program to return to the kernel using either a * trampoline which performs the syscall sigreturn, or a provided * user-mode trampoline. */ static int setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { struct sigframe __user *frame; unsigned long return_ip; int err = 0; frame = get_sigframe(ksig, sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) return -EFAULT; err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); if (err) return -EFAULT; if (_NSIG_WORDS > 1) { err |= __copy_to_user(frame->extramask, &set->sig[1], sizeof(frame->extramask)); } if (err) return -EFAULT; /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ksig->ka.sa.sa_flags & SA_RESTORER) { return_ip = (unsigned long)ksig->ka.sa.sa_restorer; } else { /* trampoline - the desired return ip is the retcode itself */ return_ip = (unsigned long)&frame->retcode; /* This is movu.w __NR_sigreturn, r9; break 13; */ err |= __put_user(0x9c5f, (short __user*)(frame->retcode+0)); err |= __put_user(__NR_sigreturn, (short __user*)(frame->retcode+2)); err |= __put_user(0xe93d, (short __user*)(frame->retcode+4)); } if (err) return -EFAULT; /* Set up registers for signal handler */ regs->irp = (unsigned long) ksig->ka.sa.sa_handler; /* what we enter NOW */ regs->srp = return_ip; /* what we enter LATER */ regs->r10 = ksig->sig; /* first argument is signo */ /* actually move the usp to reflect the stacked frame */ wrusp((unsigned long)frame); return 0; } static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { struct rt_sigframe __user *frame; unsigned long return_ip; int err = 0; frame = get_sigframe(ksig, sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) return -EFAULT; err |= __put_user(&frame->info, &frame->pinfo); err |= __put_user(&frame->uc, &frame->puc); err |= copy_siginfo_to_user(&frame->info, &ksig->info); if (err) return -EFAULT; /* Clear all the bits of the ucontext we don't use. */ err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]); err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); err |= __save_altstack(&frame->uc.uc_stack, rdusp()); if (err) return -EFAULT; /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ksig->ka.sa.sa_flags & SA_RESTORER) { return_ip = (unsigned long)ksig->ka.sa.sa_restorer; } else { /* trampoline - the desired return ip is the retcode itself */ return_ip = (unsigned long)&frame->retcode; /* This is movu.w __NR_rt_sigreturn, r9; break 13; */ err |= __put_user(0x9c5f, (short __user *)(frame->retcode+0)); err |= __put_user(__NR_rt_sigreturn, (short __user *)(frame->retcode+2)); err |= __put_user(0xe93d, (short __user *)(frame->retcode+4)); } if (err) return -EFAULT; /* Set up registers for signal handler */ /* What we enter NOW */ regs->irp = (unsigned long) ksig->ka.sa.sa_handler; /* What we enter LATER */ regs->srp = return_ip; /* First argument is signo */ regs->r10 = ksig->sig; /* Second argument is (siginfo_t *) */ regs->r11 = (unsigned long)&frame->info; /* Third argument is unused */ regs->r12 = 0; /* Actually move the usp to reflect the stacked frame */ wrusp((unsigned long)frame); return 0; } /* * OK, we're invoking a handler */ static inline void handle_signal(int canrestart, struct ksignal *ksig, struct pt_regs *regs) { sigset_t *oldset = sigmask_to_save(); int ret; /* Are we from a system call? */ if (canrestart) { /* If so, check system call restarting.. */ switch (regs->r10) { case -ERESTART_RESTARTBLOCK: case -ERESTARTNOHAND: /* ERESTARTNOHAND means that the syscall should * only be restarted if there was no handler for * the signal, and since we only get here if there * is a handler, we don't restart */ regs->r10 = -EINTR; break; case -ERESTARTSYS: /* ERESTARTSYS means to restart the syscall if * there is no handler or the handler was * registered with SA_RESTART */ if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { regs->r10 = -EINTR; break; } /* fallthrough */ case -ERESTARTNOINTR: /* ERESTARTNOINTR means that the syscall should * be called again after the signal handler returns. */ RESTART_CRIS_SYS(regs); } } /* Set up the stack frame */ if (ksig->ka.sa.sa_flags & SA_SIGINFO) ret = setup_rt_frame(ksig, oldset, regs); else ret = setup_frame(ksig, oldset, regs); signal_setup_done(ret, ksig, 0); } /* * Note that 'init' is a special process: it doesn't get signals it doesn't * want to handle. Thus you cannot kill init even with a SIGKILL even by * mistake. * * Also note that the regs structure given here as an argument, is the latest * pushed pt_regs. It may or may not be the same as the first pushed registers * when the initial usermode->kernelmode transition took place. Therefore * we can use user_mode(regs) to see if we came directly from kernel or user * mode below. */ void do_signal(int canrestart, struct pt_regs *regs) { struct ksignal ksig; /* * We want the common case to go fast, which * is why we may in certain cases get here from * kernel mode. Just return without doing anything * if so. */ if (!user_mode(regs)) return; if (get_signal(&ksig)) { /* Whee! Actually deliver the signal. */ handle_signal(canrestart, &ksig, regs); return; } /* Did we come from a system call? */ if (canrestart) { /* Restart the system call - no handlers present */ if (regs->r10 == -ERESTARTNOHAND || regs->r10 == -ERESTARTSYS || regs->r10 == -ERESTARTNOINTR) { RESTART_CRIS_SYS(regs); } if (regs->r10 == -ERESTART_RESTARTBLOCK) { regs->r9 = __NR_restart_syscall; regs->irp -= 2; } } /* if there's no signal to deliver, we just put the saved sigmask * back */ restore_saved_sigmask(); }
gilelad/linux
arch/cris/arch-v10/kernel/signal.c
C
gpl-2.0
11,510
#define _GNU_SOURCE #include <stdio.h> #include <signal.h> #include <unistd.h> #include <errno.h> #include <linux/types.h> #include <sys/wait.h> #include <sys/syscall.h> #include <sys/user.h> #include <sys/mman.h> #include "linux/ptrace.h" static int sys_rt_sigqueueinfo(pid_t tgid, int sig, siginfo_t *uinfo) { return syscall(SYS_rt_sigqueueinfo, tgid, sig, uinfo); } static int sys_rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *uinfo) { return syscall(SYS_rt_tgsigqueueinfo, tgid, tid, sig, uinfo); } static int sys_ptrace(int request, pid_t pid, void *addr, void *data) { return syscall(SYS_ptrace, request, pid, addr, data); } #define SIGNR 10 #define TEST_SICODE_PRIV -1 #define TEST_SICODE_SHARE -2 #ifndef PAGE_SIZE #define PAGE_SIZE sysconf(_SC_PAGESIZE) #endif #define err(fmt, ...) \ fprintf(stderr, \ "Error (%s:%d): " fmt, \ __FILE__, __LINE__, ##__VA_ARGS__) static int check_error_paths(pid_t child) { struct ptrace_peeksiginfo_args arg; int ret, exit_code = -1; void *addr_rw, *addr_ro; /* * Allocate two contiguous pages. The first one is for read-write, * another is for read-only. */ addr_rw = mmap(NULL, 2 * PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (addr_rw == MAP_FAILED) { err("mmap() failed: %m\n"); return 1; } addr_ro = mmap(addr_rw + PAGE_SIZE, PAGE_SIZE, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (addr_ro == MAP_FAILED) { err("mmap() failed: %m\n"); goto out; } arg.nr = SIGNR; arg.off = 0; /* Unsupported flags */ arg.flags = ~0; ret = sys_ptrace(PTRACE_PEEKSIGINFO, child, &arg, addr_rw); if (ret != -1 || errno != EINVAL) { err("sys_ptrace() returns %d (expected -1)," " errno %d (expected %d): %m\n", ret, errno, EINVAL); goto out; } arg.flags = 0; /* A part of the buffer is read-only */ ret = sys_ptrace(PTRACE_PEEKSIGINFO, child, &arg, addr_ro - sizeof(siginfo_t) * 2); if (ret != 2) { err("sys_ptrace() returns %d (expected 2): %m\n", ret); goto out; } /* Read-only buffer */ ret = sys_ptrace(PTRACE_PEEKSIGINFO, child, &arg, addr_ro); if (ret != -1 && errno != EFAULT) { err("sys_ptrace() returns %d (expected -1)," " errno %d (expected %d): %m\n", ret, errno, EFAULT); goto out; } exit_code = 0; out: munmap(addr_rw, 2 * PAGE_SIZE); return exit_code; } int check_direct_path(pid_t child, int shared, int nr) { struct ptrace_peeksiginfo_args arg = {.flags = 0, .nr = nr, .off = 0}; int i, j, ret, exit_code = -1; siginfo_t siginfo[SIGNR]; int si_code; if (shared == 1) { arg.flags = PTRACE_PEEKSIGINFO_SHARED; si_code = TEST_SICODE_SHARE; } else { arg.flags = 0; si_code = TEST_SICODE_PRIV; } for (i = 0; i < SIGNR; ) { arg.off = i; ret = sys_ptrace(PTRACE_PEEKSIGINFO, child, &arg, siginfo); if (ret == -1) { err("ptrace() failed: %m\n"); goto out; } if (ret == 0) break; for (j = 0; j < ret; j++, i++) { if (siginfo[j].si_code == si_code && siginfo[j].si_int == i) continue; err("%d: Wrong siginfo i=%d si_code=%d si_int=%d\n", shared, i, siginfo[j].si_code, siginfo[j].si_int); goto out; } } if (i != SIGNR) { err("Only %d signals were read\n", i); goto out; } exit_code = 0; out: return exit_code; } int main(int argc, char *argv[]) { siginfo_t siginfo[SIGNR]; int i, exit_code = 1; sigset_t blockmask; pid_t child; sigemptyset(&blockmask); sigaddset(&blockmask, SIGRTMIN); sigprocmask(SIG_BLOCK, &blockmask, NULL); child = fork(); if (child == -1) { err("fork() failed: %m"); return 1; } else if (child == 0) { pid_t ppid = getppid(); while (1) { if (ppid != getppid()) break; sleep(1); } return 1; } /* Send signals in process-wide and per-thread queues */ for (i = 0; i < SIGNR; i++) { siginfo->si_code = TEST_SICODE_SHARE; siginfo->si_int = i; sys_rt_sigqueueinfo(child, SIGRTMIN, siginfo); siginfo->si_code = TEST_SICODE_PRIV; siginfo->si_int = i; sys_rt_tgsigqueueinfo(child, child, SIGRTMIN, siginfo); } if (sys_ptrace(PTRACE_ATTACH, child, NULL, NULL) == -1) return 1; waitpid(child, NULL, 0); /* Dump signals one by one*/ if (check_direct_path(child, 0, 1)) goto out; /* Dump all signals for one call */ if (check_direct_path(child, 0, SIGNR)) goto out; /* * Dump signal from the process-wide queue. * The number of signals is not multible to the buffer size */ if (check_direct_path(child, 1, 3)) goto out; if (check_error_paths(child)) goto out; printf("PASS\n"); exit_code = 0; out: if (sys_ptrace(PTRACE_KILL, child, NULL, NULL) == -1) return 1; waitpid(child, NULL, 0); return exit_code; }
kaneawk/android_kernel_motorola_msm8996
tools/testing/selftests/ptrace/peeksiginfo.c
C
gpl-2.0
4,716
/* * Copyright (c) 2005 Voltaire Inc. All rights reserved. * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved. * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved. * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/completion.h> #include <linux/in.h> #include <linux/in6.h> #include <linux/mutex.h> #include <linux/random.h> #include <linux/idr.h> #include <linux/inetdevice.h> #include <linux/slab.h> #include <linux/module.h> #include <net/route.h> #include <net/tcp.h> #include <net/ipv6.h> #include <rdma/rdma_cm.h> #include <rdma/rdma_cm_ib.h> #include <rdma/rdma_netlink.h> #include <rdma/ib_cache.h> #include <rdma/ib_cm.h> #include <rdma/ib_sa.h> #include <rdma/iw_cm.h> MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("Generic RDMA CM Agent"); MODULE_LICENSE("Dual BSD/GPL"); #define CMA_CM_RESPONSE_TIMEOUT 20 #define CMA_MAX_CM_RETRIES 15 #define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24) #define CMA_IBOE_PACKET_LIFETIME 18 static void cma_add_one(struct ib_device *device); static void cma_remove_one(struct ib_device *device); static struct ib_client cma_client = { .name = "cma", .add = cma_add_one, .remove = cma_remove_one }; static struct ib_sa_client sa_client; static struct rdma_addr_client addr_client; static LIST_HEAD(dev_list); static LIST_HEAD(listen_any_list); static DEFINE_MUTEX(lock); static struct workqueue_struct *cma_wq; static DEFINE_IDR(sdp_ps); static DEFINE_IDR(tcp_ps); static DEFINE_IDR(udp_ps); static DEFINE_IDR(ipoib_ps); static DEFINE_IDR(ib_ps); struct cma_device { struct list_head list; struct ib_device *device; struct completion comp; atomic_t refcount; struct list_head id_list; }; struct rdma_bind_list { struct idr *ps; struct hlist_head owners; unsigned short port; }; enum { CMA_OPTION_AFONLY, }; /* * Device removal can occur at anytime, so we need extra handling to * serialize notifying the user of device removal with other callbacks. * We do this by disabling removal notification while a callback is in process, * and reporting it after the callback completes. */ struct rdma_id_private { struct rdma_cm_id id; struct rdma_bind_list *bind_list; struct hlist_node node; struct list_head list; /* listen_any_list or cma_device.list */ struct list_head listen_list; /* per device listens */ struct cma_device *cma_dev; struct list_head mc_list; int internal_id; enum rdma_cm_state state; spinlock_t lock; struct mutex qp_mutex; struct completion comp; atomic_t refcount; struct mutex handler_mutex; int backlog; int timeout_ms; struct ib_sa_query *query; int query_id; union { struct ib_cm_id *ib; struct iw_cm_id *iw; } cm_id; u32 seq_num; u32 qkey; u32 qp_num; pid_t owner; u32 options; u8 srq; u8 tos; u8 reuseaddr; u8 afonly; }; struct cma_multicast { struct rdma_id_private *id_priv; union { struct ib_sa_multicast *ib; } multicast; struct list_head list; void *context; struct sockaddr_storage addr; struct kref mcref; }; struct cma_work { struct work_struct work; struct rdma_id_private *id; enum rdma_cm_state old_state; enum rdma_cm_state new_state; struct rdma_cm_event event; }; struct cma_ndev_work { struct work_struct work; struct rdma_id_private *id; struct rdma_cm_event event; }; struct iboe_mcast_work { struct work_struct work; struct rdma_id_private *id; struct cma_multicast *mc; }; union cma_ip_addr { struct in6_addr ip6; struct { __be32 pad[3]; __be32 addr; } ip4; }; struct cma_hdr { u8 cma_version; u8 ip_version; /* IP version: 7:4 */ __be16 port; union cma_ip_addr src_addr; union cma_ip_addr dst_addr; }; struct sdp_hh { u8 bsdh[16]; u8 sdp_version; /* Major version: 7:4 */ u8 ip_version; /* IP version: 7:4 */ u8 sdp_specific1[10]; __be16 port; __be16 sdp_specific2; union cma_ip_addr src_addr; union cma_ip_addr dst_addr; }; struct sdp_hah { u8 bsdh[16]; u8 sdp_version; }; #define CMA_VERSION 0x00 #define SDP_MAJ_VERSION 0x2 static int cma_comp(struct rdma_id_private *id_priv, enum rdma_cm_state comp) { unsigned long flags; int ret; spin_lock_irqsave(&id_priv->lock, flags); ret = (id_priv->state == comp); spin_unlock_irqrestore(&id_priv->lock, flags); return ret; } static int cma_comp_exch(struct rdma_id_private *id_priv, enum rdma_cm_state comp, enum rdma_cm_state exch) { unsigned long flags; int ret; spin_lock_irqsave(&id_priv->lock, flags); if ((ret = (id_priv->state == comp))) id_priv->state = exch; spin_unlock_irqrestore(&id_priv->lock, flags); return ret; } static enum rdma_cm_state cma_exch(struct rdma_id_private *id_priv, enum rdma_cm_state exch) { unsigned long flags; enum rdma_cm_state old; spin_lock_irqsave(&id_priv->lock, flags); old = id_priv->state; id_priv->state = exch; spin_unlock_irqrestore(&id_priv->lock, flags); return old; } static inline u8 cma_get_ip_ver(struct cma_hdr *hdr) { return hdr->ip_version >> 4; } static inline void cma_set_ip_ver(struct cma_hdr *hdr, u8 ip_ver) { hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF); } static inline u8 sdp_get_majv(u8 sdp_version) { return sdp_version >> 4; } static inline u8 sdp_get_ip_ver(struct sdp_hh *hh) { return hh->ip_version >> 4; } static inline void sdp_set_ip_ver(struct sdp_hh *hh, u8 ip_ver) { hh->ip_version = (ip_ver << 4) | (hh->ip_version & 0xF); } static void cma_attach_to_dev(struct rdma_id_private *id_priv, struct cma_device *cma_dev) { atomic_inc(&cma_dev->refcount); id_priv->cma_dev = cma_dev; id_priv->id.device = cma_dev->device; id_priv->id.route.addr.dev_addr.transport = rdma_node_get_transport(cma_dev->device->node_type); list_add_tail(&id_priv->list, &cma_dev->id_list); } static inline void cma_deref_dev(struct cma_device *cma_dev) { if (atomic_dec_and_test(&cma_dev->refcount)) complete(&cma_dev->comp); } static inline void release_mc(struct kref *kref) { struct cma_multicast *mc = container_of(kref, struct cma_multicast, mcref); kfree(mc->multicast.ib); kfree(mc); } static void cma_release_dev(struct rdma_id_private *id_priv) { mutex_lock(&lock); list_del(&id_priv->list); cma_deref_dev(id_priv->cma_dev); id_priv->cma_dev = NULL; mutex_unlock(&lock); } static int cma_set_qkey(struct rdma_id_private *id_priv) { struct ib_sa_mcmember_rec rec; int ret = 0; if (id_priv->qkey) return 0; switch (id_priv->id.ps) { case RDMA_PS_UDP: id_priv->qkey = RDMA_UDP_QKEY; break; case RDMA_PS_IPOIB: ib_addr_get_mgid(&id_priv->id.route.addr.dev_addr, &rec.mgid); ret = ib_sa_get_mcmember_rec(id_priv->id.device, id_priv->id.port_num, &rec.mgid, &rec); if (!ret) id_priv->qkey = be32_to_cpu(rec.qkey); break; default: break; } return ret; } static int find_gid_port(struct ib_device *device, union ib_gid *gid, u8 port_num) { int i; int err; struct ib_port_attr props; union ib_gid tmp; err = ib_query_port(device, port_num, &props); if (err) return err; for (i = 0; i < props.gid_tbl_len; ++i) { err = ib_query_gid(device, port_num, i, &tmp); if (err) return err; if (!memcmp(&tmp, gid, sizeof tmp)) return 0; } return -EADDRNOTAVAIL; } static int cma_acquire_dev(struct rdma_id_private *id_priv) { struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; struct cma_device *cma_dev; union ib_gid gid, iboe_gid; int ret = -ENODEV; u8 port; enum rdma_link_layer dev_ll = dev_addr->dev_type == ARPHRD_INFINIBAND ? IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET; if (dev_ll != IB_LINK_LAYER_INFINIBAND && id_priv->id.ps == RDMA_PS_IPOIB) return -EINVAL; mutex_lock(&lock); iboe_addr_get_sgid(dev_addr, &iboe_gid); memcpy(&gid, dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof gid); list_for_each_entry(cma_dev, &dev_list, list) { for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) { if (rdma_port_get_link_layer(cma_dev->device, port) == dev_ll) { if (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB && rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET) ret = find_gid_port(cma_dev->device, &iboe_gid, port); else ret = find_gid_port(cma_dev->device, &gid, port); if (!ret) { id_priv->id.port_num = port; goto out; } } } } out: if (!ret) cma_attach_to_dev(id_priv, cma_dev); mutex_unlock(&lock); return ret; } static void cma_deref_id(struct rdma_id_private *id_priv) { if (atomic_dec_and_test(&id_priv->refcount)) complete(&id_priv->comp); } static int cma_disable_callback(struct rdma_id_private *id_priv, enum rdma_cm_state state) { mutex_lock(&id_priv->handler_mutex); if (id_priv->state != state) { mutex_unlock(&id_priv->handler_mutex); return -EINVAL; } return 0; } struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler, void *context, enum rdma_port_space ps, enum ib_qp_type qp_type) { struct rdma_id_private *id_priv; id_priv = kzalloc(sizeof *id_priv, GFP_KERNEL); if (!id_priv) return ERR_PTR(-ENOMEM); id_priv->owner = task_pid_nr(current); id_priv->state = RDMA_CM_IDLE; id_priv->id.context = context; id_priv->id.event_handler = event_handler; id_priv->id.ps = ps; id_priv->id.qp_type = qp_type; spin_lock_init(&id_priv->lock); mutex_init(&id_priv->qp_mutex); init_completion(&id_priv->comp); atomic_set(&id_priv->refcount, 1); mutex_init(&id_priv->handler_mutex); INIT_LIST_HEAD(&id_priv->listen_list); INIT_LIST_HEAD(&id_priv->mc_list); get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num); return &id_priv->id; } EXPORT_SYMBOL(rdma_create_id); static int cma_init_ud_qp(struct rdma_id_private *id_priv, struct ib_qp *qp) { struct ib_qp_attr qp_attr; int qp_attr_mask, ret; qp_attr.qp_state = IB_QPS_INIT; ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); if (ret) return ret; ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask); if (ret) return ret; qp_attr.qp_state = IB_QPS_RTR; ret = ib_modify_qp(qp, &qp_attr, IB_QP_STATE); if (ret) return ret; qp_attr.qp_state = IB_QPS_RTS; qp_attr.sq_psn = 0; ret = ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_SQ_PSN); return ret; } static int cma_init_conn_qp(struct rdma_id_private *id_priv, struct ib_qp *qp) { struct ib_qp_attr qp_attr; int qp_attr_mask, ret; qp_attr.qp_state = IB_QPS_INIT; ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); if (ret) return ret; return ib_modify_qp(qp, &qp_attr, qp_attr_mask); } int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd, struct ib_qp_init_attr *qp_init_attr) { struct rdma_id_private *id_priv; struct ib_qp *qp; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (id->device != pd->device) return -EINVAL; qp = ib_create_qp(pd, qp_init_attr); if (IS_ERR(qp)) return PTR_ERR(qp); if (id->qp_type == IB_QPT_UD) ret = cma_init_ud_qp(id_priv, qp); else ret = cma_init_conn_qp(id_priv, qp); if (ret) goto err; id->qp = qp; id_priv->qp_num = qp->qp_num; id_priv->srq = (qp->srq != NULL); return 0; err: ib_destroy_qp(qp); return ret; } EXPORT_SYMBOL(rdma_create_qp); void rdma_destroy_qp(struct rdma_cm_id *id) { struct rdma_id_private *id_priv; id_priv = container_of(id, struct rdma_id_private, id); mutex_lock(&id_priv->qp_mutex); ib_destroy_qp(id_priv->id.qp); id_priv->id.qp = NULL; mutex_unlock(&id_priv->qp_mutex); } EXPORT_SYMBOL(rdma_destroy_qp); static int cma_modify_qp_rtr(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct ib_qp_attr qp_attr; int qp_attr_mask, ret; mutex_lock(&id_priv->qp_mutex); if (!id_priv->id.qp) { ret = 0; goto out; } /* Need to update QP attributes from default values. */ qp_attr.qp_state = IB_QPS_INIT; ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); if (ret) goto out; ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask); if (ret) goto out; qp_attr.qp_state = IB_QPS_RTR; ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); if (ret) goto out; if (conn_param) qp_attr.max_dest_rd_atomic = conn_param->responder_resources; ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask); out: mutex_unlock(&id_priv->qp_mutex); return ret; } static int cma_modify_qp_rts(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct ib_qp_attr qp_attr; int qp_attr_mask, ret; mutex_lock(&id_priv->qp_mutex); if (!id_priv->id.qp) { ret = 0; goto out; } qp_attr.qp_state = IB_QPS_RTS; ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask); if (ret) goto out; if (conn_param) qp_attr.max_rd_atomic = conn_param->initiator_depth; ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask); out: mutex_unlock(&id_priv->qp_mutex); return ret; } static int cma_modify_qp_err(struct rdma_id_private *id_priv) { struct ib_qp_attr qp_attr; int ret; mutex_lock(&id_priv->qp_mutex); if (!id_priv->id.qp) { ret = 0; goto out; } qp_attr.qp_state = IB_QPS_ERR; ret = ib_modify_qp(id_priv->id.qp, &qp_attr, IB_QP_STATE); out: mutex_unlock(&id_priv->qp_mutex); return ret; } static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv, struct ib_qp_attr *qp_attr, int *qp_attr_mask) { struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; int ret; u16 pkey; if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) == IB_LINK_LAYER_INFINIBAND) pkey = ib_addr_get_pkey(dev_addr); else pkey = 0xffff; ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num, pkey, &qp_attr->pkey_index); if (ret) return ret; qp_attr->port_num = id_priv->id.port_num; *qp_attr_mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT; if (id_priv->id.qp_type == IB_QPT_UD) { ret = cma_set_qkey(id_priv); if (ret) return ret; qp_attr->qkey = id_priv->qkey; *qp_attr_mask |= IB_QP_QKEY; } else { qp_attr->qp_access_flags = 0; *qp_attr_mask |= IB_QP_ACCESS_FLAGS; } return 0; } int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr, int *qp_attr_mask) { struct rdma_id_private *id_priv; int ret = 0; id_priv = container_of(id, struct rdma_id_private, id); switch (rdma_node_get_transport(id_priv->id.device->node_type)) { case RDMA_TRANSPORT_IB: if (!id_priv->cm_id.ib || (id_priv->id.qp_type == IB_QPT_UD)) ret = cma_ib_init_qp_attr(id_priv, qp_attr, qp_attr_mask); else ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, qp_attr, qp_attr_mask); if (qp_attr->qp_state == IB_QPS_RTR) qp_attr->rq_psn = id_priv->seq_num; break; case RDMA_TRANSPORT_IWARP: if (!id_priv->cm_id.iw) { qp_attr->qp_access_flags = 0; *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS; } else ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr, qp_attr_mask); break; default: ret = -ENOSYS; break; } return ret; } EXPORT_SYMBOL(rdma_init_qp_attr); static inline int cma_zero_addr(struct sockaddr *addr) { struct in6_addr *ip6; if (addr->sa_family == AF_INET) return ipv4_is_zeronet( ((struct sockaddr_in *)addr)->sin_addr.s_addr); else { ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr; return (ip6->s6_addr32[0] | ip6->s6_addr32[1] | ip6->s6_addr32[2] | ip6->s6_addr32[3]) == 0; } } static inline int cma_loopback_addr(struct sockaddr *addr) { if (addr->sa_family == AF_INET) return ipv4_is_loopback( ((struct sockaddr_in *) addr)->sin_addr.s_addr); else return ipv6_addr_loopback( &((struct sockaddr_in6 *) addr)->sin6_addr); } static inline int cma_any_addr(struct sockaddr *addr) { return cma_zero_addr(addr) || cma_loopback_addr(addr); } static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst) { if (src->sa_family != dst->sa_family) return -1; switch (src->sa_family) { case AF_INET: return ((struct sockaddr_in *) src)->sin_addr.s_addr != ((struct sockaddr_in *) dst)->sin_addr.s_addr; default: return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr, &((struct sockaddr_in6 *) dst)->sin6_addr); } } static inline __be16 cma_port(struct sockaddr *addr) { if (addr->sa_family == AF_INET) return ((struct sockaddr_in *) addr)->sin_port; else return ((struct sockaddr_in6 *) addr)->sin6_port; } static inline int cma_any_port(struct sockaddr *addr) { return !cma_port(addr); } static int cma_get_net_info(void *hdr, enum rdma_port_space ps, u8 *ip_ver, __be16 *port, union cma_ip_addr **src, union cma_ip_addr **dst) { switch (ps) { case RDMA_PS_SDP: if (sdp_get_majv(((struct sdp_hh *) hdr)->sdp_version) != SDP_MAJ_VERSION) return -EINVAL; *ip_ver = sdp_get_ip_ver(hdr); *port = ((struct sdp_hh *) hdr)->port; *src = &((struct sdp_hh *) hdr)->src_addr; *dst = &((struct sdp_hh *) hdr)->dst_addr; break; default: if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION) return -EINVAL; *ip_ver = cma_get_ip_ver(hdr); *port = ((struct cma_hdr *) hdr)->port; *src = &((struct cma_hdr *) hdr)->src_addr; *dst = &((struct cma_hdr *) hdr)->dst_addr; break; } if (*ip_ver != 4 && *ip_ver != 6) return -EINVAL; return 0; } static void cma_save_net_info(struct rdma_addr *addr, struct rdma_addr *listen_addr, u8 ip_ver, __be16 port, union cma_ip_addr *src, union cma_ip_addr *dst) { struct sockaddr_in *listen4, *ip4; struct sockaddr_in6 *listen6, *ip6; switch (ip_ver) { case 4: listen4 = (struct sockaddr_in *) &listen_addr->src_addr; ip4 = (struct sockaddr_in *) &addr->src_addr; ip4->sin_family = listen4->sin_family; ip4->sin_addr.s_addr = dst->ip4.addr; ip4->sin_port = listen4->sin_port; ip4 = (struct sockaddr_in *) &addr->dst_addr; ip4->sin_family = listen4->sin_family; ip4->sin_addr.s_addr = src->ip4.addr; ip4->sin_port = port; break; case 6: listen6 = (struct sockaddr_in6 *) &listen_addr->src_addr; ip6 = (struct sockaddr_in6 *) &addr->src_addr; ip6->sin6_family = listen6->sin6_family; ip6->sin6_addr = dst->ip6; ip6->sin6_port = listen6->sin6_port; ip6 = (struct sockaddr_in6 *) &addr->dst_addr; ip6->sin6_family = listen6->sin6_family; ip6->sin6_addr = src->ip6; ip6->sin6_port = port; break; default: break; } } static inline int cma_user_data_offset(enum rdma_port_space ps) { switch (ps) { case RDMA_PS_SDP: return 0; default: return sizeof(struct cma_hdr); } } static void cma_cancel_route(struct rdma_id_private *id_priv) { switch (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)) { case IB_LINK_LAYER_INFINIBAND: if (id_priv->query) ib_sa_cancel_query(id_priv->query_id, id_priv->query); break; default: break; } } static void cma_cancel_listens(struct rdma_id_private *id_priv) { struct rdma_id_private *dev_id_priv; /* * Remove from listen_any_list to prevent added devices from spawning * additional listen requests. */ mutex_lock(&lock); list_del(&id_priv->list); while (!list_empty(&id_priv->listen_list)) { dev_id_priv = list_entry(id_priv->listen_list.next, struct rdma_id_private, listen_list); /* sync with device removal to avoid duplicate destruction */ list_del_init(&dev_id_priv->list); list_del(&dev_id_priv->listen_list); mutex_unlock(&lock); rdma_destroy_id(&dev_id_priv->id); mutex_lock(&lock); } mutex_unlock(&lock); } static void cma_cancel_operation(struct rdma_id_private *id_priv, enum rdma_cm_state state) { switch (state) { case RDMA_CM_ADDR_QUERY: rdma_addr_cancel(&id_priv->id.route.addr.dev_addr); break; case RDMA_CM_ROUTE_QUERY: cma_cancel_route(id_priv); break; case RDMA_CM_LISTEN: if (cma_any_addr((struct sockaddr *) &id_priv->id.route.addr.src_addr) && !id_priv->cma_dev) cma_cancel_listens(id_priv); break; default: break; } } static void cma_release_port(struct rdma_id_private *id_priv) { struct rdma_bind_list *bind_list = id_priv->bind_list; if (!bind_list) return; mutex_lock(&lock); hlist_del(&id_priv->node); if (hlist_empty(&bind_list->owners)) { idr_remove(bind_list->ps, bind_list->port); kfree(bind_list); } mutex_unlock(&lock); } static void cma_leave_mc_groups(struct rdma_id_private *id_priv) { struct cma_multicast *mc; while (!list_empty(&id_priv->mc_list)) { mc = container_of(id_priv->mc_list.next, struct cma_multicast, list); list_del(&mc->list); switch (rdma_port_get_link_layer(id_priv->cma_dev->device, id_priv->id.port_num)) { case IB_LINK_LAYER_INFINIBAND: ib_sa_free_multicast(mc->multicast.ib); kfree(mc); break; case IB_LINK_LAYER_ETHERNET: kref_put(&mc->mcref, release_mc); break; default: break; } } } void rdma_destroy_id(struct rdma_cm_id *id) { struct rdma_id_private *id_priv; enum rdma_cm_state state; id_priv = container_of(id, struct rdma_id_private, id); state = cma_exch(id_priv, RDMA_CM_DESTROYING); cma_cancel_operation(id_priv, state); /* * Wait for any active callback to finish. New callbacks will find * the id_priv state set to destroying and abort. */ mutex_lock(&id_priv->handler_mutex); mutex_unlock(&id_priv->handler_mutex); if (id_priv->cma_dev) { switch (rdma_node_get_transport(id_priv->id.device->node_type)) { case RDMA_TRANSPORT_IB: if (id_priv->cm_id.ib) ib_destroy_cm_id(id_priv->cm_id.ib); break; case RDMA_TRANSPORT_IWARP: if (id_priv->cm_id.iw) iw_destroy_cm_id(id_priv->cm_id.iw); break; default: break; } cma_leave_mc_groups(id_priv); cma_release_dev(id_priv); } cma_release_port(id_priv); cma_deref_id(id_priv); wait_for_completion(&id_priv->comp); if (id_priv->internal_id) cma_deref_id(id_priv->id.context); kfree(id_priv->id.route.path_rec); kfree(id_priv); } EXPORT_SYMBOL(rdma_destroy_id); static int cma_rep_recv(struct rdma_id_private *id_priv) { int ret; ret = cma_modify_qp_rtr(id_priv, NULL); if (ret) goto reject; ret = cma_modify_qp_rts(id_priv, NULL); if (ret) goto reject; ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0); if (ret) goto reject; return 0; reject: cma_modify_qp_err(id_priv); ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED, NULL, 0, NULL, 0); return ret; } static int cma_verify_rep(struct rdma_id_private *id_priv, void *data) { if (id_priv->id.ps == RDMA_PS_SDP && sdp_get_majv(((struct sdp_hah *) data)->sdp_version) != SDP_MAJ_VERSION) return -EINVAL; return 0; } static void cma_set_rep_event_data(struct rdma_cm_event *event, struct ib_cm_rep_event_param *rep_data, void *private_data) { event->param.conn.private_data = private_data; event->param.conn.private_data_len = IB_CM_REP_PRIVATE_DATA_SIZE; event->param.conn.responder_resources = rep_data->responder_resources; event->param.conn.initiator_depth = rep_data->initiator_depth; event->param.conn.flow_control = rep_data->flow_control; event->param.conn.rnr_retry_count = rep_data->rnr_retry_count; event->param.conn.srq = rep_data->srq; event->param.conn.qp_num = rep_data->remote_qpn; } static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) { struct rdma_id_private *id_priv = cm_id->context; struct rdma_cm_event event; int ret = 0; if ((ib_event->event != IB_CM_TIMEWAIT_EXIT && cma_disable_callback(id_priv, RDMA_CM_CONNECT)) || (ib_event->event == IB_CM_TIMEWAIT_EXIT && cma_disable_callback(id_priv, RDMA_CM_DISCONNECT))) return 0; memset(&event, 0, sizeof event); switch (ib_event->event) { case IB_CM_REQ_ERROR: case IB_CM_REP_ERROR: event.event = RDMA_CM_EVENT_UNREACHABLE; event.status = -ETIMEDOUT; break; case IB_CM_REP_RECEIVED: event.status = cma_verify_rep(id_priv, ib_event->private_data); if (event.status) event.event = RDMA_CM_EVENT_CONNECT_ERROR; else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) { event.status = cma_rep_recv(id_priv); event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR : RDMA_CM_EVENT_ESTABLISHED; } else event.event = RDMA_CM_EVENT_CONNECT_RESPONSE; cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd, ib_event->private_data); break; case IB_CM_RTU_RECEIVED: case IB_CM_USER_ESTABLISHED: event.event = RDMA_CM_EVENT_ESTABLISHED; break; case IB_CM_DREQ_ERROR: event.status = -ETIMEDOUT; /* fall through */ case IB_CM_DREQ_RECEIVED: case IB_CM_DREP_RECEIVED: if (!cma_comp_exch(id_priv, RDMA_CM_CONNECT, RDMA_CM_DISCONNECT)) goto out; event.event = RDMA_CM_EVENT_DISCONNECTED; break; case IB_CM_TIMEWAIT_EXIT: event.event = RDMA_CM_EVENT_TIMEWAIT_EXIT; break; case IB_CM_MRA_RECEIVED: /* ignore event */ goto out; case IB_CM_REJ_RECEIVED: cma_modify_qp_err(id_priv); event.status = ib_event->param.rej_rcvd.reason; event.event = RDMA_CM_EVENT_REJECTED; event.param.conn.private_data = ib_event->private_data; event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE; break; default: printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n", ib_event->event); goto out; } ret = id_priv->id.event_handler(&id_priv->id, &event); if (ret) { /* Destroy the CM ID by returning a non-zero value. */ id_priv->cm_id.ib = NULL; cma_exch(id_priv, RDMA_CM_DESTROYING); mutex_unlock(&id_priv->handler_mutex); rdma_destroy_id(&id_priv->id); return ret; } out: mutex_unlock(&id_priv->handler_mutex); return ret; } static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, struct ib_cm_event *ib_event) { struct rdma_id_private *id_priv; struct rdma_cm_id *id; struct rdma_route *rt; union cma_ip_addr *src, *dst; __be16 port; u8 ip_ver; int ret; if (cma_get_net_info(ib_event->private_data, listen_id->ps, &ip_ver, &port, &src, &dst)) return NULL; id = rdma_create_id(listen_id->event_handler, listen_id->context, listen_id->ps, ib_event->param.req_rcvd.qp_type); if (IS_ERR(id)) return NULL; cma_save_net_info(&id->route.addr, &listen_id->route.addr, ip_ver, port, src, dst); rt = &id->route; rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1; rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths, GFP_KERNEL); if (!rt->path_rec) goto err; rt->path_rec[0] = *ib_event->param.req_rcvd.primary_path; if (rt->num_paths == 2) rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path; if (cma_any_addr((struct sockaddr *) &rt->addr.src_addr)) { rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND; rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid); ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey)); } else { ret = rdma_translate_ip((struct sockaddr *) &rt->addr.src_addr, &rt->addr.dev_addr); if (ret) goto err; } rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); id_priv = container_of(id, struct rdma_id_private, id); id_priv->state = RDMA_CM_CONNECT; return id_priv; err: rdma_destroy_id(id); return NULL; } static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, struct ib_cm_event *ib_event) { struct rdma_id_private *id_priv; struct rdma_cm_id *id; union cma_ip_addr *src, *dst; __be16 port; u8 ip_ver; int ret; id = rdma_create_id(listen_id->event_handler, listen_id->context, listen_id->ps, IB_QPT_UD); if (IS_ERR(id)) return NULL; if (cma_get_net_info(ib_event->private_data, listen_id->ps, &ip_ver, &port, &src, &dst)) goto err; cma_save_net_info(&id->route.addr, &listen_id->route.addr, ip_ver, port, src, dst); if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) { ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr, &id->route.addr.dev_addr); if (ret) goto err; } id_priv = container_of(id, struct rdma_id_private, id); id_priv->state = RDMA_CM_CONNECT; return id_priv; err: rdma_destroy_id(id); return NULL; } static void cma_set_req_event_data(struct rdma_cm_event *event, struct ib_cm_req_event_param *req_data, void *private_data, int offset) { event->param.conn.private_data = private_data + offset; event->param.conn.private_data_len = IB_CM_REQ_PRIVATE_DATA_SIZE - offset; event->param.conn.responder_resources = req_data->responder_resources; event->param.conn.initiator_depth = req_data->initiator_depth; event->param.conn.flow_control = req_data->flow_control; event->param.conn.retry_count = req_data->retry_count; event->param.conn.rnr_retry_count = req_data->rnr_retry_count; event->param.conn.srq = req_data->srq; event->param.conn.qp_num = req_data->remote_qpn; } static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_event) { return (((ib_event->event == IB_CM_REQ_RECEIVED) && (ib_event->param.req_rcvd.qp_type == id->qp_type)) || ((ib_event->event == IB_CM_SIDR_REQ_RECEIVED) && (id->qp_type == IB_QPT_UD)) || (!id->qp_type)); } static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) { struct rdma_id_private *listen_id, *conn_id; struct rdma_cm_event event; int offset, ret; listen_id = cm_id->context; if (!cma_check_req_qp_type(&listen_id->id, ib_event)) return -EINVAL; if (cma_disable_callback(listen_id, RDMA_CM_LISTEN)) return -ECONNABORTED; memset(&event, 0, sizeof event); offset = cma_user_data_offset(listen_id->id.ps); event.event = RDMA_CM_EVENT_CONNECT_REQUEST; if (ib_event->event == IB_CM_SIDR_REQ_RECEIVED) { conn_id = cma_new_udp_id(&listen_id->id, ib_event); event.param.ud.private_data = ib_event->private_data + offset; event.param.ud.private_data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset; } else { conn_id = cma_new_conn_id(&listen_id->id, ib_event); cma_set_req_event_data(&event, &ib_event->param.req_rcvd, ib_event->private_data, offset); } if (!conn_id) { ret = -ENOMEM; goto err1; } mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING); ret = cma_acquire_dev(conn_id); if (ret) goto err2; conn_id->cm_id.ib = cm_id; cm_id->context = conn_id; cm_id->cm_handler = cma_ib_handler; /* * Protect against the user destroying conn_id from another thread * until we're done accessing it. */ atomic_inc(&conn_id->refcount); ret = conn_id->id.event_handler(&conn_id->id, &event); if (ret) goto err3; /* * Acquire mutex to prevent user executing rdma_destroy_id() * while we're accessing the cm_id. */ mutex_lock(&lock); if (cma_comp(conn_id, RDMA_CM_CONNECT) && (conn_id->id.qp_type != IB_QPT_UD)) ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0); mutex_unlock(&lock); mutex_unlock(&conn_id->handler_mutex); mutex_unlock(&listen_id->handler_mutex); cma_deref_id(conn_id); return 0; err3: cma_deref_id(conn_id); /* Destroy the CM ID by returning a non-zero value. */ conn_id->cm_id.ib = NULL; err2: cma_exch(conn_id, RDMA_CM_DESTROYING); mutex_unlock(&conn_id->handler_mutex); err1: mutex_unlock(&listen_id->handler_mutex); if (conn_id) rdma_destroy_id(&conn_id->id); return ret; } static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr) { return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr))); } static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr, struct ib_cm_compare_data *compare) { struct cma_hdr *cma_data, *cma_mask; struct sdp_hh *sdp_data, *sdp_mask; __be32 ip4_addr; struct in6_addr ip6_addr; memset(compare, 0, sizeof *compare); cma_data = (void *) compare->data; cma_mask = (void *) compare->mask; sdp_data = (void *) compare->data; sdp_mask = (void *) compare->mask; switch (addr->sa_family) { case AF_INET: ip4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr; if (ps == RDMA_PS_SDP) { sdp_set_ip_ver(sdp_data, 4); sdp_set_ip_ver(sdp_mask, 0xF); sdp_data->dst_addr.ip4.addr = ip4_addr; sdp_mask->dst_addr.ip4.addr = htonl(~0); } else { cma_set_ip_ver(cma_data, 4); cma_set_ip_ver(cma_mask, 0xF); if (!cma_any_addr(addr)) { cma_data->dst_addr.ip4.addr = ip4_addr; cma_mask->dst_addr.ip4.addr = htonl(~0); } } break; case AF_INET6: ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr; if (ps == RDMA_PS_SDP) { sdp_set_ip_ver(sdp_data, 6); sdp_set_ip_ver(sdp_mask, 0xF); sdp_data->dst_addr.ip6 = ip6_addr; memset(&sdp_mask->dst_addr.ip6, 0xFF, sizeof sdp_mask->dst_addr.ip6); } else { cma_set_ip_ver(cma_data, 6); cma_set_ip_ver(cma_mask, 0xF); if (!cma_any_addr(addr)) { cma_data->dst_addr.ip6 = ip6_addr; memset(&cma_mask->dst_addr.ip6, 0xFF, sizeof cma_mask->dst_addr.ip6); } } break; default: break; } } static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) { struct rdma_id_private *id_priv = iw_id->context; struct rdma_cm_event event; struct sockaddr_in *sin; int ret = 0; if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) return 0; memset(&event, 0, sizeof event); switch (iw_event->event) { case IW_CM_EVENT_CLOSE: event.event = RDMA_CM_EVENT_DISCONNECTED; break; case IW_CM_EVENT_CONNECT_REPLY: sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; *sin = iw_event->local_addr; sin = (struct sockaddr_in *) &id_priv->id.route.addr.dst_addr; *sin = iw_event->remote_addr; switch (iw_event->status) { case 0: event.event = RDMA_CM_EVENT_ESTABLISHED; event.param.conn.initiator_depth = iw_event->ird; event.param.conn.responder_resources = iw_event->ord; break; case -ECONNRESET: case -ECONNREFUSED: event.event = RDMA_CM_EVENT_REJECTED; break; case -ETIMEDOUT: event.event = RDMA_CM_EVENT_UNREACHABLE; break; default: event.event = RDMA_CM_EVENT_CONNECT_ERROR; break; } break; case IW_CM_EVENT_ESTABLISHED: event.event = RDMA_CM_EVENT_ESTABLISHED; event.param.conn.initiator_depth = iw_event->ird; event.param.conn.responder_resources = iw_event->ord; break; default: BUG_ON(1); } event.status = iw_event->status; event.param.conn.private_data = iw_event->private_data; event.param.conn.private_data_len = iw_event->private_data_len; ret = id_priv->id.event_handler(&id_priv->id, &event); if (ret) { /* Destroy the CM ID by returning a non-zero value. */ id_priv->cm_id.iw = NULL; cma_exch(id_priv, RDMA_CM_DESTROYING); mutex_unlock(&id_priv->handler_mutex); rdma_destroy_id(&id_priv->id); return ret; } mutex_unlock(&id_priv->handler_mutex); return ret; } static int iw_conn_req_handler(struct iw_cm_id *cm_id, struct iw_cm_event *iw_event) { struct rdma_cm_id *new_cm_id; struct rdma_id_private *listen_id, *conn_id; struct sockaddr_in *sin; struct net_device *dev = NULL; struct rdma_cm_event event; int ret; struct ib_device_attr attr; listen_id = cm_id->context; if (cma_disable_callback(listen_id, RDMA_CM_LISTEN)) return -ECONNABORTED; /* Create a new RDMA id for the new IW CM ID */ new_cm_id = rdma_create_id(listen_id->id.event_handler, listen_id->id.context, RDMA_PS_TCP, IB_QPT_RC); if (IS_ERR(new_cm_id)) { ret = -ENOMEM; goto out; } conn_id = container_of(new_cm_id, struct rdma_id_private, id); mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING); conn_id->state = RDMA_CM_CONNECT; dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr); if (!dev) { ret = -EADDRNOTAVAIL; mutex_unlock(&conn_id->handler_mutex); rdma_destroy_id(new_cm_id); goto out; } ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL); if (ret) { mutex_unlock(&conn_id->handler_mutex); rdma_destroy_id(new_cm_id); goto out; } ret = cma_acquire_dev(conn_id); if (ret) { mutex_unlock(&conn_id->handler_mutex); rdma_destroy_id(new_cm_id); goto out; } conn_id->cm_id.iw = cm_id; cm_id->context = conn_id; cm_id->cm_handler = cma_iw_handler; sin = (struct sockaddr_in *) &new_cm_id->route.addr.src_addr; *sin = iw_event->local_addr; sin = (struct sockaddr_in *) &new_cm_id->route.addr.dst_addr; *sin = iw_event->remote_addr; ret = ib_query_device(conn_id->id.device, &attr); if (ret) { mutex_unlock(&conn_id->handler_mutex); rdma_destroy_id(new_cm_id); goto out; } memset(&event, 0, sizeof event); event.event = RDMA_CM_EVENT_CONNECT_REQUEST; event.param.conn.private_data = iw_event->private_data; event.param.conn.private_data_len = iw_event->private_data_len; event.param.conn.initiator_depth = iw_event->ird; event.param.conn.responder_resources = iw_event->ord; /* * Protect against the user destroying conn_id from another thread * until we're done accessing it. */ atomic_inc(&conn_id->refcount); ret = conn_id->id.event_handler(&conn_id->id, &event); if (ret) { /* User wants to destroy the CM ID */ conn_id->cm_id.iw = NULL; cma_exch(conn_id, RDMA_CM_DESTROYING); mutex_unlock(&conn_id->handler_mutex); cma_deref_id(conn_id); rdma_destroy_id(&conn_id->id); goto out; } mutex_unlock(&conn_id->handler_mutex); cma_deref_id(conn_id); out: if (dev) dev_put(dev); mutex_unlock(&listen_id->handler_mutex); return ret; } static int cma_ib_listen(struct rdma_id_private *id_priv) { struct ib_cm_compare_data compare_data; struct sockaddr *addr; struct ib_cm_id *id; __be64 svc_id; int ret; id = ib_create_cm_id(id_priv->id.device, cma_req_handler, id_priv); if (IS_ERR(id)) return PTR_ERR(id); id_priv->cm_id.ib = id; addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; svc_id = cma_get_service_id(id_priv->id.ps, addr); if (cma_any_addr(addr) && !id_priv->afonly) ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL); else { cma_set_compare_data(id_priv->id.ps, addr, &compare_data); ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, &compare_data); } if (ret) { ib_destroy_cm_id(id_priv->cm_id.ib); id_priv->cm_id.ib = NULL; } return ret; } static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog) { int ret; struct sockaddr_in *sin; struct iw_cm_id *id; id = iw_create_cm_id(id_priv->id.device, iw_conn_req_handler, id_priv); if (IS_ERR(id)) return PTR_ERR(id); id_priv->cm_id.iw = id; sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; id_priv->cm_id.iw->local_addr = *sin; ret = iw_cm_listen(id_priv->cm_id.iw, backlog); if (ret) { iw_destroy_cm_id(id_priv->cm_id.iw); id_priv->cm_id.iw = NULL; } return ret; } static int cma_listen_handler(struct rdma_cm_id *id, struct rdma_cm_event *event) { struct rdma_id_private *id_priv = id->context; id->context = id_priv->id.context; id->event_handler = id_priv->id.event_handler; return id_priv->id.event_handler(id, event); } static void cma_listen_on_dev(struct rdma_id_private *id_priv, struct cma_device *cma_dev) { struct rdma_id_private *dev_id_priv; struct rdma_cm_id *id; int ret; id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps, id_priv->id.qp_type); if (IS_ERR(id)) return; dev_id_priv = container_of(id, struct rdma_id_private, id); dev_id_priv->state = RDMA_CM_ADDR_BOUND; memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr, ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr)); cma_attach_to_dev(dev_id_priv, cma_dev); list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list); atomic_inc(&id_priv->refcount); dev_id_priv->internal_id = 1; dev_id_priv->afonly = id_priv->afonly; ret = rdma_listen(id, id_priv->backlog); if (ret) printk(KERN_WARNING "RDMA CMA: cma_listen_on_dev, error %d, " "listening on device %s\n", ret, cma_dev->device->name); } static void cma_listen_on_all(struct rdma_id_private *id_priv) { struct cma_device *cma_dev; mutex_lock(&lock); list_add_tail(&id_priv->list, &listen_any_list); list_for_each_entry(cma_dev, &dev_list, list) cma_listen_on_dev(id_priv, cma_dev); mutex_unlock(&lock); } void rdma_set_service_type(struct rdma_cm_id *id, int tos) { struct rdma_id_private *id_priv; id_priv = container_of(id, struct rdma_id_private, id); id_priv->tos = (u8) tos; } EXPORT_SYMBOL(rdma_set_service_type); static void cma_query_handler(int status, struct ib_sa_path_rec *path_rec, void *context) { struct cma_work *work = context; struct rdma_route *route; route = &work->id->id.route; if (!status) { route->num_paths = 1; *route->path_rec = *path_rec; } else { work->old_state = RDMA_CM_ROUTE_QUERY; work->new_state = RDMA_CM_ADDR_RESOLVED; work->event.event = RDMA_CM_EVENT_ROUTE_ERROR; work->event.status = status; } queue_work(cma_wq, &work->work); } static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, struct cma_work *work) { struct rdma_addr *addr = &id_priv->id.route.addr; struct ib_sa_path_rec path_rec; ib_sa_comp_mask comp_mask; struct sockaddr_in6 *sin6; memset(&path_rec, 0, sizeof path_rec); rdma_addr_get_sgid(&addr->dev_addr, &path_rec.sgid); rdma_addr_get_dgid(&addr->dev_addr, &path_rec.dgid); path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr)); path_rec.numb_path = 1; path_rec.reversible = 1; path_rec.service_id = cma_get_service_id(id_priv->id.ps, (struct sockaddr *) &addr->dst_addr); comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID | IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH | IB_SA_PATH_REC_REVERSIBLE | IB_SA_PATH_REC_SERVICE_ID; if (addr->src_addr.ss_family == AF_INET) { path_rec.qos_class = cpu_to_be16((u16) id_priv->tos); comp_mask |= IB_SA_PATH_REC_QOS_CLASS; } else { sin6 = (struct sockaddr_in6 *) &addr->src_addr; path_rec.traffic_class = (u8) (be32_to_cpu(sin6->sin6_flowinfo) >> 20); comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS; } id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device, id_priv->id.port_num, &path_rec, comp_mask, timeout_ms, GFP_KERNEL, cma_query_handler, work, &id_priv->query); return (id_priv->query_id < 0) ? id_priv->query_id : 0; } static void cma_work_handler(struct work_struct *_work) { struct cma_work *work = container_of(_work, struct cma_work, work); struct rdma_id_private *id_priv = work->id; int destroy = 0; mutex_lock(&id_priv->handler_mutex); if (!cma_comp_exch(id_priv, work->old_state, work->new_state)) goto out; if (id_priv->id.event_handler(&id_priv->id, &work->event)) { cma_exch(id_priv, RDMA_CM_DESTROYING); destroy = 1; } out: mutex_unlock(&id_priv->handler_mutex); cma_deref_id(id_priv); if (destroy) rdma_destroy_id(&id_priv->id); kfree(work); } static void cma_ndev_work_handler(struct work_struct *_work) { struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work); struct rdma_id_private *id_priv = work->id; int destroy = 0; mutex_lock(&id_priv->handler_mutex); if (id_priv->state == RDMA_CM_DESTROYING || id_priv->state == RDMA_CM_DEVICE_REMOVAL) goto out; if (id_priv->id.event_handler(&id_priv->id, &work->event)) { cma_exch(id_priv, RDMA_CM_DESTROYING); destroy = 1; } out: mutex_unlock(&id_priv->handler_mutex); cma_deref_id(id_priv); if (destroy) rdma_destroy_id(&id_priv->id); kfree(work); } static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms) { struct rdma_route *route = &id_priv->id.route; struct cma_work *work; int ret; work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; work->id = id_priv; INIT_WORK(&work->work, cma_work_handler); work->old_state = RDMA_CM_ROUTE_QUERY; work->new_state = RDMA_CM_ROUTE_RESOLVED; work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL); if (!route->path_rec) { ret = -ENOMEM; goto err1; } ret = cma_query_ib_route(id_priv, timeout_ms, work); if (ret) goto err2; return 0; err2: kfree(route->path_rec); route->path_rec = NULL; err1: kfree(work); return ret; } int rdma_set_ib_paths(struct rdma_cm_id *id, struct ib_sa_path_rec *path_rec, int num_paths) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED, RDMA_CM_ROUTE_RESOLVED)) return -EINVAL; id->route.path_rec = kmemdup(path_rec, sizeof *path_rec * num_paths, GFP_KERNEL); if (!id->route.path_rec) { ret = -ENOMEM; goto err; } id->route.num_paths = num_paths; return 0; err: cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_ADDR_RESOLVED); return ret; } EXPORT_SYMBOL(rdma_set_ib_paths); static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms) { struct cma_work *work; work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; work->id = id_priv; INIT_WORK(&work->work, cma_work_handler); work->old_state = RDMA_CM_ROUTE_QUERY; work->new_state = RDMA_CM_ROUTE_RESOLVED; work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; queue_work(cma_wq, &work->work); return 0; } static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) { struct rdma_route *route = &id_priv->id.route; struct rdma_addr *addr = &route->addr; struct cma_work *work; int ret; struct sockaddr_in *src_addr = (struct sockaddr_in *)&route->addr.src_addr; struct sockaddr_in *dst_addr = (struct sockaddr_in *)&route->addr.dst_addr; struct net_device *ndev = NULL; u16 vid; if (src_addr->sin_family != dst_addr->sin_family) return -EINVAL; work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; work->id = id_priv; INIT_WORK(&work->work, cma_work_handler); route->path_rec = kzalloc(sizeof *route->path_rec, GFP_KERNEL); if (!route->path_rec) { ret = -ENOMEM; goto err1; } route->num_paths = 1; if (addr->dev_addr.bound_dev_if) ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if); if (!ndev) { ret = -ENODEV; goto err2; } vid = rdma_vlan_dev_vlan_id(ndev); iboe_mac_vlan_to_ll(&route->path_rec->sgid, addr->dev_addr.src_dev_addr, vid); iboe_mac_vlan_to_ll(&route->path_rec->dgid, addr->dev_addr.dst_dev_addr, vid); route->path_rec->hop_limit = 1; route->path_rec->reversible = 1; route->path_rec->pkey = cpu_to_be16(0xffff); route->path_rec->mtu_selector = IB_SA_EQ; route->path_rec->sl = netdev_get_prio_tc_map( ndev->priv_flags & IFF_802_1Q_VLAN ? vlan_dev_real_dev(ndev) : ndev, rt_tos2priority(id_priv->tos)); route->path_rec->mtu = iboe_get_mtu(ndev->mtu); route->path_rec->rate_selector = IB_SA_EQ; route->path_rec->rate = iboe_get_rate(ndev); dev_put(ndev); route->path_rec->packet_life_time_selector = IB_SA_EQ; route->path_rec->packet_life_time = CMA_IBOE_PACKET_LIFETIME; if (!route->path_rec->mtu) { ret = -EINVAL; goto err2; } work->old_state = RDMA_CM_ROUTE_QUERY; work->new_state = RDMA_CM_ROUTE_RESOLVED; work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; work->event.status = 0; queue_work(cma_wq, &work->work); return 0; err2: kfree(route->path_rec); route->path_rec = NULL; err1: kfree(work); return ret; } int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED, RDMA_CM_ROUTE_QUERY)) return -EINVAL; atomic_inc(&id_priv->refcount); switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: switch (rdma_port_get_link_layer(id->device, id->port_num)) { case IB_LINK_LAYER_INFINIBAND: ret = cma_resolve_ib_route(id_priv, timeout_ms); break; case IB_LINK_LAYER_ETHERNET: ret = cma_resolve_iboe_route(id_priv); break; default: ret = -ENOSYS; } break; case RDMA_TRANSPORT_IWARP: ret = cma_resolve_iw_route(id_priv, timeout_ms); break; default: ret = -ENOSYS; break; } if (ret) goto err; return 0; err: cma_comp_exch(id_priv, RDMA_CM_ROUTE_QUERY, RDMA_CM_ADDR_RESOLVED); cma_deref_id(id_priv); return ret; } EXPORT_SYMBOL(rdma_resolve_route); static int cma_bind_loopback(struct rdma_id_private *id_priv) { struct cma_device *cma_dev; struct ib_port_attr port_attr; union ib_gid gid; u16 pkey; int ret; u8 p; mutex_lock(&lock); if (list_empty(&dev_list)) { ret = -ENODEV; goto out; } list_for_each_entry(cma_dev, &dev_list, list) for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p) if (!ib_query_port(cma_dev->device, p, &port_attr) && port_attr.state == IB_PORT_ACTIVE) goto port_found; p = 1; cma_dev = list_entry(dev_list.next, struct cma_device, list); port_found: ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid); if (ret) goto out; ret = ib_get_cached_pkey(cma_dev->device, p, 0, &pkey); if (ret) goto out; id_priv->id.route.addr.dev_addr.dev_type = (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ? ARPHRD_INFINIBAND : ARPHRD_ETHER; rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid); ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); id_priv->id.port_num = p; cma_attach_to_dev(id_priv, cma_dev); out: mutex_unlock(&lock); return ret; } static void addr_handler(int status, struct sockaddr *src_addr, struct rdma_dev_addr *dev_addr, void *context) { struct rdma_id_private *id_priv = context; struct rdma_cm_event event; memset(&event, 0, sizeof event); mutex_lock(&id_priv->handler_mutex); if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY, RDMA_CM_ADDR_RESOLVED)) goto out; if (!status && !id_priv->cma_dev) status = cma_acquire_dev(id_priv); if (status) { if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED, RDMA_CM_ADDR_BOUND)) goto out; event.event = RDMA_CM_EVENT_ADDR_ERROR; event.status = status; } else { memcpy(&id_priv->id.route.addr.src_addr, src_addr, ip_addr_size(src_addr)); event.event = RDMA_CM_EVENT_ADDR_RESOLVED; } if (id_priv->id.event_handler(&id_priv->id, &event)) { cma_exch(id_priv, RDMA_CM_DESTROYING); mutex_unlock(&id_priv->handler_mutex); cma_deref_id(id_priv); rdma_destroy_id(&id_priv->id); return; } out: mutex_unlock(&id_priv->handler_mutex); cma_deref_id(id_priv); } static int cma_resolve_loopback(struct rdma_id_private *id_priv) { struct cma_work *work; struct sockaddr *src, *dst; union ib_gid gid; int ret; work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; if (!id_priv->cma_dev) { ret = cma_bind_loopback(id_priv); if (ret) goto err; } rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid); rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid); src = (struct sockaddr *) &id_priv->id.route.addr.src_addr; if (cma_zero_addr(src)) { dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr; if ((src->sa_family = dst->sa_family) == AF_INET) { ((struct sockaddr_in *)src)->sin_addr = ((struct sockaddr_in *)dst)->sin_addr; } else { ((struct sockaddr_in6 *)src)->sin6_addr = ((struct sockaddr_in6 *)dst)->sin6_addr; } } work->id = id_priv; INIT_WORK(&work->work, cma_work_handler); work->old_state = RDMA_CM_ADDR_QUERY; work->new_state = RDMA_CM_ADDR_RESOLVED; work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED; queue_work(cma_wq, &work->work); return 0; err: kfree(work); return ret; } static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, struct sockaddr *dst_addr) { if (!src_addr || !src_addr->sa_family) { src_addr = (struct sockaddr *) &id->route.addr.src_addr; if ((src_addr->sa_family = dst_addr->sa_family) == AF_INET6) { ((struct sockaddr_in6 *) src_addr)->sin6_scope_id = ((struct sockaddr_in6 *) dst_addr)->sin6_scope_id; } } return rdma_bind_addr(id, src_addr); } int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, struct sockaddr *dst_addr, int timeout_ms) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (id_priv->state == RDMA_CM_IDLE) { ret = cma_bind_addr(id, src_addr, dst_addr); if (ret) return ret; } if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY)) return -EINVAL; atomic_inc(&id_priv->refcount); memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr)); if (cma_any_addr(dst_addr)) ret = cma_resolve_loopback(id_priv); else ret = rdma_resolve_ip(&addr_client, (struct sockaddr *) &id->route.addr.src_addr, dst_addr, &id->route.addr.dev_addr, timeout_ms, addr_handler, id_priv); if (ret) goto err; return 0; err: cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY, RDMA_CM_ADDR_BOUND); cma_deref_id(id_priv); return ret; } EXPORT_SYMBOL(rdma_resolve_addr); int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse) { struct rdma_id_private *id_priv; unsigned long flags; int ret; id_priv = container_of(id, struct rdma_id_private, id); spin_lock_irqsave(&id_priv->lock, flags); if (id_priv->state == RDMA_CM_IDLE) { id_priv->reuseaddr = reuse; ret = 0; } else { ret = -EINVAL; } spin_unlock_irqrestore(&id_priv->lock, flags); return ret; } EXPORT_SYMBOL(rdma_set_reuseaddr); int rdma_set_afonly(struct rdma_cm_id *id, int afonly) { struct rdma_id_private *id_priv; unsigned long flags; int ret; id_priv = container_of(id, struct rdma_id_private, id); spin_lock_irqsave(&id_priv->lock, flags); if (id_priv->state == RDMA_CM_IDLE || id_priv->state == RDMA_CM_ADDR_BOUND) { id_priv->options |= (1 << CMA_OPTION_AFONLY); id_priv->afonly = afonly; ret = 0; } else { ret = -EINVAL; } spin_unlock_irqrestore(&id_priv->lock, flags); return ret; } EXPORT_SYMBOL(rdma_set_afonly); static void cma_bind_port(struct rdma_bind_list *bind_list, struct rdma_id_private *id_priv) { struct sockaddr_in *sin; sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; sin->sin_port = htons(bind_list->port); id_priv->bind_list = bind_list; hlist_add_head(&id_priv->node, &bind_list->owners); } static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv, unsigned short snum) { struct rdma_bind_list *bind_list; int ret; bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL); if (!bind_list) return -ENOMEM; ret = idr_alloc(ps, bind_list, snum, snum + 1, GFP_KERNEL); if (ret < 0) goto err; bind_list->ps = ps; bind_list->port = (unsigned short)ret; cma_bind_port(bind_list, id_priv); return 0; err: kfree(bind_list); return ret == -ENOSPC ? -EADDRNOTAVAIL : ret; } static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv) { static unsigned int last_used_port; int low, high, remaining; unsigned int rover; inet_get_local_port_range(&low, &high); remaining = (high - low) + 1; rover = net_random() % remaining + low; retry: if (last_used_port != rover && !idr_find(ps, (unsigned short) rover)) { int ret = cma_alloc_port(ps, id_priv, rover); /* * Remember previously used port number in order to avoid * re-using same port immediately after it is closed. */ if (!ret) last_used_port = rover; if (ret != -EADDRNOTAVAIL) return ret; } if (--remaining) { rover++; if ((rover < low) || (rover > high)) rover = low; goto retry; } return -EADDRNOTAVAIL; } /* * Check that the requested port is available. This is called when trying to * bind to a specific port, or when trying to listen on a bound port. In * the latter case, the provided id_priv may already be on the bind_list, but * we still need to check that it's okay to start listening. */ static int cma_check_port(struct rdma_bind_list *bind_list, struct rdma_id_private *id_priv, uint8_t reuseaddr) { struct rdma_id_private *cur_id; struct sockaddr *addr, *cur_addr; addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; hlist_for_each_entry(cur_id, &bind_list->owners, node) { if (id_priv == cur_id) continue; if ((cur_id->state != RDMA_CM_LISTEN) && reuseaddr && cur_id->reuseaddr) continue; cur_addr = (struct sockaddr *) &cur_id->id.route.addr.src_addr; if (id_priv->afonly && cur_id->afonly && (addr->sa_family != cur_addr->sa_family)) continue; if (cma_any_addr(addr) || cma_any_addr(cur_addr)) return -EADDRNOTAVAIL; if (!cma_addr_cmp(addr, cur_addr)) return -EADDRINUSE; } return 0; } static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv) { struct rdma_bind_list *bind_list; unsigned short snum; int ret; snum = ntohs(cma_port((struct sockaddr *) &id_priv->id.route.addr.src_addr)); if (snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) return -EACCES; bind_list = idr_find(ps, snum); if (!bind_list) { ret = cma_alloc_port(ps, id_priv, snum); } else { ret = cma_check_port(bind_list, id_priv, id_priv->reuseaddr); if (!ret) cma_bind_port(bind_list, id_priv); } return ret; } static int cma_bind_listen(struct rdma_id_private *id_priv) { struct rdma_bind_list *bind_list = id_priv->bind_list; int ret = 0; mutex_lock(&lock); if (bind_list->owners.first->next) ret = cma_check_port(bind_list, id_priv, 0); mutex_unlock(&lock); return ret; } static int cma_get_port(struct rdma_id_private *id_priv) { struct idr *ps; int ret; switch (id_priv->id.ps) { case RDMA_PS_SDP: ps = &sdp_ps; break; case RDMA_PS_TCP: ps = &tcp_ps; break; case RDMA_PS_UDP: ps = &udp_ps; break; case RDMA_PS_IPOIB: ps = &ipoib_ps; break; case RDMA_PS_IB: ps = &ib_ps; break; default: return -EPROTONOSUPPORT; } mutex_lock(&lock); if (cma_any_port((struct sockaddr *) &id_priv->id.route.addr.src_addr)) ret = cma_alloc_any_port(ps, id_priv); else ret = cma_use_port(ps, id_priv); mutex_unlock(&lock); return ret; } static int cma_check_linklocal(struct rdma_dev_addr *dev_addr, struct sockaddr *addr) { #if IS_ENABLED(CONFIG_IPV6) struct sockaddr_in6 *sin6; if (addr->sa_family != AF_INET6) return 0; sin6 = (struct sockaddr_in6 *) addr; if ((ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && !sin6->sin6_scope_id) return -EINVAL; dev_addr->bound_dev_if = sin6->sin6_scope_id; #endif return 0; } int rdma_listen(struct rdma_cm_id *id, int backlog) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (id_priv->state == RDMA_CM_IDLE) { ((struct sockaddr *) &id->route.addr.src_addr)->sa_family = AF_INET; ret = rdma_bind_addr(id, (struct sockaddr *) &id->route.addr.src_addr); if (ret) return ret; } if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_LISTEN)) return -EINVAL; if (id_priv->reuseaddr) { ret = cma_bind_listen(id_priv); if (ret) goto err; } id_priv->backlog = backlog; if (id->device) { switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: ret = cma_ib_listen(id_priv); if (ret) goto err; break; case RDMA_TRANSPORT_IWARP: ret = cma_iw_listen(id_priv, backlog); if (ret) goto err; break; default: ret = -ENOSYS; goto err; } } else cma_listen_on_all(id_priv); return 0; err: id_priv->backlog = 0; cma_comp_exch(id_priv, RDMA_CM_LISTEN, RDMA_CM_ADDR_BOUND); return ret; } EXPORT_SYMBOL(rdma_listen); int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) { struct rdma_id_private *id_priv; int ret; if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6) return -EAFNOSUPPORT; id_priv = container_of(id, struct rdma_id_private, id); if (!cma_comp_exch(id_priv, RDMA_CM_IDLE, RDMA_CM_ADDR_BOUND)) return -EINVAL; ret = cma_check_linklocal(&id->route.addr.dev_addr, addr); if (ret) goto err1; if (!cma_any_addr(addr)) { ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); if (ret) goto err1; ret = cma_acquire_dev(id_priv); if (ret) goto err1; } memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) { if (addr->sa_family == AF_INET) id_priv->afonly = 1; #if IS_ENABLED(CONFIG_IPV6) else if (addr->sa_family == AF_INET6) id_priv->afonly = init_net.ipv6.sysctl.bindv6only; #endif } ret = cma_get_port(id_priv); if (ret) goto err2; return 0; err2: if (id_priv->cma_dev) cma_release_dev(id_priv); err1: cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_IDLE); return ret; } EXPORT_SYMBOL(rdma_bind_addr); static int cma_format_hdr(void *hdr, enum rdma_port_space ps, struct rdma_route *route) { struct cma_hdr *cma_hdr; struct sdp_hh *sdp_hdr; if (route->addr.src_addr.ss_family == AF_INET) { struct sockaddr_in *src4, *dst4; src4 = (struct sockaddr_in *) &route->addr.src_addr; dst4 = (struct sockaddr_in *) &route->addr.dst_addr; switch (ps) { case RDMA_PS_SDP: sdp_hdr = hdr; if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) return -EINVAL; sdp_set_ip_ver(sdp_hdr, 4); sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr; sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr; sdp_hdr->port = src4->sin_port; break; default: cma_hdr = hdr; cma_hdr->cma_version = CMA_VERSION; cma_set_ip_ver(cma_hdr, 4); cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr; cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr; cma_hdr->port = src4->sin_port; break; } } else { struct sockaddr_in6 *src6, *dst6; src6 = (struct sockaddr_in6 *) &route->addr.src_addr; dst6 = (struct sockaddr_in6 *) &route->addr.dst_addr; switch (ps) { case RDMA_PS_SDP: sdp_hdr = hdr; if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) return -EINVAL; sdp_set_ip_ver(sdp_hdr, 6); sdp_hdr->src_addr.ip6 = src6->sin6_addr; sdp_hdr->dst_addr.ip6 = dst6->sin6_addr; sdp_hdr->port = src6->sin6_port; break; default: cma_hdr = hdr; cma_hdr->cma_version = CMA_VERSION; cma_set_ip_ver(cma_hdr, 6); cma_hdr->src_addr.ip6 = src6->sin6_addr; cma_hdr->dst_addr.ip6 = dst6->sin6_addr; cma_hdr->port = src6->sin6_port; break; } } return 0; } static int cma_sidr_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) { struct rdma_id_private *id_priv = cm_id->context; struct rdma_cm_event event; struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd; int ret = 0; if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) return 0; memset(&event, 0, sizeof event); switch (ib_event->event) { case IB_CM_SIDR_REQ_ERROR: event.event = RDMA_CM_EVENT_UNREACHABLE; event.status = -ETIMEDOUT; break; case IB_CM_SIDR_REP_RECEIVED: event.param.ud.private_data = ib_event->private_data; event.param.ud.private_data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE; if (rep->status != IB_SIDR_SUCCESS) { event.event = RDMA_CM_EVENT_UNREACHABLE; event.status = ib_event->param.sidr_rep_rcvd.status; break; } ret = cma_set_qkey(id_priv); if (ret) { event.event = RDMA_CM_EVENT_ADDR_ERROR; event.status = -EINVAL; break; } if (id_priv->qkey != rep->qkey) { event.event = RDMA_CM_EVENT_UNREACHABLE; event.status = -EINVAL; break; } ib_init_ah_from_path(id_priv->id.device, id_priv->id.port_num, id_priv->id.route.path_rec, &event.param.ud.ah_attr); event.param.ud.qp_num = rep->qpn; event.param.ud.qkey = rep->qkey; event.event = RDMA_CM_EVENT_ESTABLISHED; event.status = 0; break; default: printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n", ib_event->event); goto out; } ret = id_priv->id.event_handler(&id_priv->id, &event); if (ret) { /* Destroy the CM ID by returning a non-zero value. */ id_priv->cm_id.ib = NULL; cma_exch(id_priv, RDMA_CM_DESTROYING); mutex_unlock(&id_priv->handler_mutex); rdma_destroy_id(&id_priv->id); return ret; } out: mutex_unlock(&id_priv->handler_mutex); return ret; } static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct ib_cm_sidr_req_param req; struct rdma_route *route; struct ib_cm_id *id; int ret; req.private_data_len = sizeof(struct cma_hdr) + conn_param->private_data_len; if (req.private_data_len < conn_param->private_data_len) return -EINVAL; req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC); if (!req.private_data) return -ENOMEM; if (conn_param->private_data && conn_param->private_data_len) memcpy((void *) req.private_data + sizeof(struct cma_hdr), conn_param->private_data, conn_param->private_data_len); route = &id_priv->id.route; ret = cma_format_hdr((void *) req.private_data, id_priv->id.ps, route); if (ret) goto out; id = ib_create_cm_id(id_priv->id.device, cma_sidr_rep_handler, id_priv); if (IS_ERR(id)) { ret = PTR_ERR(id); goto out; } id_priv->cm_id.ib = id; req.path = route->path_rec; req.service_id = cma_get_service_id(id_priv->id.ps, (struct sockaddr *) &route->addr.dst_addr); req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8); req.max_cm_retries = CMA_MAX_CM_RETRIES; ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req); if (ret) { ib_destroy_cm_id(id_priv->cm_id.ib); id_priv->cm_id.ib = NULL; } out: kfree(req.private_data); return ret; } static int cma_connect_ib(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct ib_cm_req_param req; struct rdma_route *route; void *private_data; struct ib_cm_id *id; int offset, ret; memset(&req, 0, sizeof req); offset = cma_user_data_offset(id_priv->id.ps); req.private_data_len = offset + conn_param->private_data_len; if (req.private_data_len < conn_param->private_data_len) return -EINVAL; private_data = kzalloc(req.private_data_len, GFP_ATOMIC); if (!private_data) return -ENOMEM; if (conn_param->private_data && conn_param->private_data_len) memcpy(private_data + offset, conn_param->private_data, conn_param->private_data_len); id = ib_create_cm_id(id_priv->id.device, cma_ib_handler, id_priv); if (IS_ERR(id)) { ret = PTR_ERR(id); goto out; } id_priv->cm_id.ib = id; route = &id_priv->id.route; ret = cma_format_hdr(private_data, id_priv->id.ps, route); if (ret) goto out; req.private_data = private_data; req.primary_path = &route->path_rec[0]; if (route->num_paths == 2) req.alternate_path = &route->path_rec[1]; req.service_id = cma_get_service_id(id_priv->id.ps, (struct sockaddr *) &route->addr.dst_addr); req.qp_num = id_priv->qp_num; req.qp_type = id_priv->id.qp_type; req.starting_psn = id_priv->seq_num; req.responder_resources = conn_param->responder_resources; req.initiator_depth = conn_param->initiator_depth; req.flow_control = conn_param->flow_control; req.retry_count = min_t(u8, 7, conn_param->retry_count); req.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count); req.remote_cm_response_timeout = CMA_CM_RESPONSE_TIMEOUT; req.local_cm_response_timeout = CMA_CM_RESPONSE_TIMEOUT; req.max_cm_retries = CMA_MAX_CM_RETRIES; req.srq = id_priv->srq ? 1 : 0; ret = ib_send_cm_req(id_priv->cm_id.ib, &req); out: if (ret && !IS_ERR(id)) { ib_destroy_cm_id(id); id_priv->cm_id.ib = NULL; } kfree(private_data); return ret; } static int cma_connect_iw(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct iw_cm_id *cm_id; struct sockaddr_in* sin; int ret; struct iw_cm_conn_param iw_param; cm_id = iw_create_cm_id(id_priv->id.device, cma_iw_handler, id_priv); if (IS_ERR(cm_id)) return PTR_ERR(cm_id); id_priv->cm_id.iw = cm_id; sin = (struct sockaddr_in*) &id_priv->id.route.addr.src_addr; cm_id->local_addr = *sin; sin = (struct sockaddr_in*) &id_priv->id.route.addr.dst_addr; cm_id->remote_addr = *sin; ret = cma_modify_qp_rtr(id_priv, conn_param); if (ret) goto out; if (conn_param) { iw_param.ord = conn_param->initiator_depth; iw_param.ird = conn_param->responder_resources; iw_param.private_data = conn_param->private_data; iw_param.private_data_len = conn_param->private_data_len; iw_param.qpn = id_priv->id.qp ? id_priv->qp_num : conn_param->qp_num; } else { memset(&iw_param, 0, sizeof iw_param); iw_param.qpn = id_priv->qp_num; } ret = iw_cm_connect(cm_id, &iw_param); out: if (ret) { iw_destroy_cm_id(cm_id); id_priv->cm_id.iw = NULL; } return ret; } int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_CONNECT)) return -EINVAL; if (!id->qp) { id_priv->qp_num = conn_param->qp_num; id_priv->srq = conn_param->srq; } switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: if (id->qp_type == IB_QPT_UD) ret = cma_resolve_ib_udp(id_priv, conn_param); else ret = cma_connect_ib(id_priv, conn_param); break; case RDMA_TRANSPORT_IWARP: ret = cma_connect_iw(id_priv, conn_param); break; default: ret = -ENOSYS; break; } if (ret) goto err; return 0; err: cma_comp_exch(id_priv, RDMA_CM_CONNECT, RDMA_CM_ROUTE_RESOLVED); return ret; } EXPORT_SYMBOL(rdma_connect); static int cma_accept_ib(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct ib_cm_rep_param rep; int ret; ret = cma_modify_qp_rtr(id_priv, conn_param); if (ret) goto out; ret = cma_modify_qp_rts(id_priv, conn_param); if (ret) goto out; memset(&rep, 0, sizeof rep); rep.qp_num = id_priv->qp_num; rep.starting_psn = id_priv->seq_num; rep.private_data = conn_param->private_data; rep.private_data_len = conn_param->private_data_len; rep.responder_resources = conn_param->responder_resources; rep.initiator_depth = conn_param->initiator_depth; rep.failover_accepted = 0; rep.flow_control = conn_param->flow_control; rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count); rep.srq = id_priv->srq ? 1 : 0; ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep); out: return ret; } static int cma_accept_iw(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct iw_cm_conn_param iw_param; int ret; ret = cma_modify_qp_rtr(id_priv, conn_param); if (ret) return ret; iw_param.ord = conn_param->initiator_depth; iw_param.ird = conn_param->responder_resources; iw_param.private_data = conn_param->private_data; iw_param.private_data_len = conn_param->private_data_len; if (id_priv->id.qp) { iw_param.qpn = id_priv->qp_num; } else iw_param.qpn = conn_param->qp_num; return iw_cm_accept(id_priv->cm_id.iw, &iw_param); } static int cma_send_sidr_rep(struct rdma_id_private *id_priv, enum ib_cm_sidr_status status, const void *private_data, int private_data_len) { struct ib_cm_sidr_rep_param rep; int ret; memset(&rep, 0, sizeof rep); rep.status = status; if (status == IB_SIDR_SUCCESS) { ret = cma_set_qkey(id_priv); if (ret) return ret; rep.qp_num = id_priv->qp_num; rep.qkey = id_priv->qkey; } rep.private_data = private_data; rep.private_data_len = private_data_len; return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep); } int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); id_priv->owner = task_pid_nr(current); if (!cma_comp(id_priv, RDMA_CM_CONNECT)) return -EINVAL; if (!id->qp && conn_param) { id_priv->qp_num = conn_param->qp_num; id_priv->srq = conn_param->srq; } switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: if (id->qp_type == IB_QPT_UD) { if (conn_param) ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS, conn_param->private_data, conn_param->private_data_len); else ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS, NULL, 0); } else { if (conn_param) ret = cma_accept_ib(id_priv, conn_param); else ret = cma_rep_recv(id_priv); } break; case RDMA_TRANSPORT_IWARP: ret = cma_accept_iw(id_priv, conn_param); break; default: ret = -ENOSYS; break; } if (ret) goto reject; return 0; reject: cma_modify_qp_err(id_priv); rdma_reject(id, NULL, 0); return ret; } EXPORT_SYMBOL(rdma_accept); int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!id_priv->cm_id.ib) return -EINVAL; switch (id->device->node_type) { case RDMA_NODE_IB_CA: ret = ib_cm_notify(id_priv->cm_id.ib, event); break; default: ret = 0; break; } return ret; } EXPORT_SYMBOL(rdma_notify); int rdma_reject(struct rdma_cm_id *id, const void *private_data, u8 private_data_len) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!id_priv->cm_id.ib) return -EINVAL; switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: if (id->qp_type == IB_QPT_UD) ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, private_data, private_data_len); else ret = ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED, NULL, 0, private_data, private_data_len); break; case RDMA_TRANSPORT_IWARP: ret = iw_cm_reject(id_priv->cm_id.iw, private_data, private_data_len); break; default: ret = -ENOSYS; break; } return ret; } EXPORT_SYMBOL(rdma_reject); int rdma_disconnect(struct rdma_cm_id *id) { struct rdma_id_private *id_priv; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!id_priv->cm_id.ib) return -EINVAL; switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: ret = cma_modify_qp_err(id_priv); if (ret) goto out; /* Initiate or respond to a disconnect. */ if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0); break; case RDMA_TRANSPORT_IWARP: ret = iw_cm_disconnect(id_priv->cm_id.iw, 0); break; default: ret = -EINVAL; break; } out: return ret; } EXPORT_SYMBOL(rdma_disconnect); static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast) { struct rdma_id_private *id_priv; struct cma_multicast *mc = multicast->context; struct rdma_cm_event event; int ret; id_priv = mc->id_priv; if (cma_disable_callback(id_priv, RDMA_CM_ADDR_BOUND) && cma_disable_callback(id_priv, RDMA_CM_ADDR_RESOLVED)) return 0; mutex_lock(&id_priv->qp_mutex); if (!status && id_priv->id.qp) status = ib_attach_mcast(id_priv->id.qp, &multicast->rec.mgid, be16_to_cpu(multicast->rec.mlid)); mutex_unlock(&id_priv->qp_mutex); memset(&event, 0, sizeof event); event.status = status; event.param.ud.private_data = mc->context; if (!status) { event.event = RDMA_CM_EVENT_MULTICAST_JOIN; ib_init_ah_from_mcmember(id_priv->id.device, id_priv->id.port_num, &multicast->rec, &event.param.ud.ah_attr); event.param.ud.qp_num = 0xFFFFFF; event.param.ud.qkey = be32_to_cpu(multicast->rec.qkey); } else event.event = RDMA_CM_EVENT_MULTICAST_ERROR; ret = id_priv->id.event_handler(&id_priv->id, &event); if (ret) { cma_exch(id_priv, RDMA_CM_DESTROYING); mutex_unlock(&id_priv->handler_mutex); rdma_destroy_id(&id_priv->id); return 0; } mutex_unlock(&id_priv->handler_mutex); return 0; } static void cma_set_mgid(struct rdma_id_private *id_priv, struct sockaddr *addr, union ib_gid *mgid) { unsigned char mc_map[MAX_ADDR_LEN]; struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; struct sockaddr_in *sin = (struct sockaddr_in *) addr; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) addr; if (cma_any_addr(addr)) { memset(mgid, 0, sizeof *mgid); } else if ((addr->sa_family == AF_INET6) && ((be32_to_cpu(sin6->sin6_addr.s6_addr32[0]) & 0xFFF0FFFF) == 0xFF10A01B)) { /* IPv6 address is an SA assigned MGID. */ memcpy(mgid, &sin6->sin6_addr, sizeof *mgid); } else if ((addr->sa_family == AF_INET6)) { ipv6_ib_mc_map(&sin6->sin6_addr, dev_addr->broadcast, mc_map); if (id_priv->id.ps == RDMA_PS_UDP) mc_map[7] = 0x01; /* Use RDMA CM signature */ *mgid = *(union ib_gid *) (mc_map + 4); } else { ip_ib_mc_map(sin->sin_addr.s_addr, dev_addr->broadcast, mc_map); if (id_priv->id.ps == RDMA_PS_UDP) mc_map[7] = 0x01; /* Use RDMA CM signature */ *mgid = *(union ib_gid *) (mc_map + 4); } } static int cma_join_ib_multicast(struct rdma_id_private *id_priv, struct cma_multicast *mc) { struct ib_sa_mcmember_rec rec; struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; ib_sa_comp_mask comp_mask; int ret; ib_addr_get_mgid(dev_addr, &rec.mgid); ret = ib_sa_get_mcmember_rec(id_priv->id.device, id_priv->id.port_num, &rec.mgid, &rec); if (ret) return ret; cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid); if (id_priv->id.ps == RDMA_PS_UDP) rec.qkey = cpu_to_be32(RDMA_UDP_QKEY); rdma_addr_get_sgid(dev_addr, &rec.port_gid); rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); rec.join_state = 1; comp_mask = IB_SA_MCMEMBER_REC_MGID | IB_SA_MCMEMBER_REC_PORT_GID | IB_SA_MCMEMBER_REC_PKEY | IB_SA_MCMEMBER_REC_JOIN_STATE | IB_SA_MCMEMBER_REC_QKEY | IB_SA_MCMEMBER_REC_SL | IB_SA_MCMEMBER_REC_FLOW_LABEL | IB_SA_MCMEMBER_REC_TRAFFIC_CLASS; if (id_priv->id.ps == RDMA_PS_IPOIB) comp_mask |= IB_SA_MCMEMBER_REC_RATE | IB_SA_MCMEMBER_REC_RATE_SELECTOR | IB_SA_MCMEMBER_REC_MTU_SELECTOR | IB_SA_MCMEMBER_REC_MTU | IB_SA_MCMEMBER_REC_HOP_LIMIT; mc->multicast.ib = ib_sa_join_multicast(&sa_client, id_priv->id.device, id_priv->id.port_num, &rec, comp_mask, GFP_KERNEL, cma_ib_mc_handler, mc); return PTR_RET(mc->multicast.ib); } static void iboe_mcast_work_handler(struct work_struct *work) { struct iboe_mcast_work *mw = container_of(work, struct iboe_mcast_work, work); struct cma_multicast *mc = mw->mc; struct ib_sa_multicast *m = mc->multicast.ib; mc->multicast.ib->context = mc; cma_ib_mc_handler(0, m); kref_put(&mc->mcref, release_mc); kfree(mw); } static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid) { struct sockaddr_in *sin = (struct sockaddr_in *)addr; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; if (cma_any_addr(addr)) { memset(mgid, 0, sizeof *mgid); } else if (addr->sa_family == AF_INET6) { memcpy(mgid, &sin6->sin6_addr, sizeof *mgid); } else { mgid->raw[0] = 0xff; mgid->raw[1] = 0x0e; mgid->raw[2] = 0; mgid->raw[3] = 0; mgid->raw[4] = 0; mgid->raw[5] = 0; mgid->raw[6] = 0; mgid->raw[7] = 0; mgid->raw[8] = 0; mgid->raw[9] = 0; mgid->raw[10] = 0xff; mgid->raw[11] = 0xff; *(__be32 *)(&mgid->raw[12]) = sin->sin_addr.s_addr; } } static int cma_iboe_join_multicast(struct rdma_id_private *id_priv, struct cma_multicast *mc) { struct iboe_mcast_work *work; struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; int err; struct sockaddr *addr = (struct sockaddr *)&mc->addr; struct net_device *ndev = NULL; if (cma_zero_addr((struct sockaddr *)&mc->addr)) return -EINVAL; work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; mc->multicast.ib = kzalloc(sizeof(struct ib_sa_multicast), GFP_KERNEL); if (!mc->multicast.ib) { err = -ENOMEM; goto out1; } cma_iboe_set_mgid(addr, &mc->multicast.ib->rec.mgid); mc->multicast.ib->rec.pkey = cpu_to_be16(0xffff); if (id_priv->id.ps == RDMA_PS_UDP) mc->multicast.ib->rec.qkey = cpu_to_be32(RDMA_UDP_QKEY); if (dev_addr->bound_dev_if) ndev = dev_get_by_index(&init_net, dev_addr->bound_dev_if); if (!ndev) { err = -ENODEV; goto out2; } mc->multicast.ib->rec.rate = iboe_get_rate(ndev); mc->multicast.ib->rec.hop_limit = 1; mc->multicast.ib->rec.mtu = iboe_get_mtu(ndev->mtu); dev_put(ndev); if (!mc->multicast.ib->rec.mtu) { err = -EINVAL; goto out2; } iboe_addr_get_sgid(dev_addr, &mc->multicast.ib->rec.port_gid); work->id = id_priv; work->mc = mc; INIT_WORK(&work->work, iboe_mcast_work_handler); kref_get(&mc->mcref); queue_work(cma_wq, &work->work); return 0; out2: kfree(mc->multicast.ib); out1: kfree(work); return err; } int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, void *context) { struct rdma_id_private *id_priv; struct cma_multicast *mc; int ret; id_priv = container_of(id, struct rdma_id_private, id); if (!cma_comp(id_priv, RDMA_CM_ADDR_BOUND) && !cma_comp(id_priv, RDMA_CM_ADDR_RESOLVED)) return -EINVAL; mc = kmalloc(sizeof *mc, GFP_KERNEL); if (!mc) return -ENOMEM; memcpy(&mc->addr, addr, ip_addr_size(addr)); mc->context = context; mc->id_priv = id_priv; spin_lock(&id_priv->lock); list_add(&mc->list, &id_priv->mc_list); spin_unlock(&id_priv->lock); switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: switch (rdma_port_get_link_layer(id->device, id->port_num)) { case IB_LINK_LAYER_INFINIBAND: ret = cma_join_ib_multicast(id_priv, mc); break; case IB_LINK_LAYER_ETHERNET: kref_init(&mc->mcref); ret = cma_iboe_join_multicast(id_priv, mc); break; default: ret = -EINVAL; } break; default: ret = -ENOSYS; break; } if (ret) { spin_lock_irq(&id_priv->lock); list_del(&mc->list); spin_unlock_irq(&id_priv->lock); kfree(mc); } return ret; } EXPORT_SYMBOL(rdma_join_multicast); void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) { struct rdma_id_private *id_priv; struct cma_multicast *mc; id_priv = container_of(id, struct rdma_id_private, id); spin_lock_irq(&id_priv->lock); list_for_each_entry(mc, &id_priv->mc_list, list) { if (!memcmp(&mc->addr, addr, ip_addr_size(addr))) { list_del(&mc->list); spin_unlock_irq(&id_priv->lock); if (id->qp) ib_detach_mcast(id->qp, &mc->multicast.ib->rec.mgid, be16_to_cpu(mc->multicast.ib->rec.mlid)); if (rdma_node_get_transport(id_priv->cma_dev->device->node_type) == RDMA_TRANSPORT_IB) { switch (rdma_port_get_link_layer(id->device, id->port_num)) { case IB_LINK_LAYER_INFINIBAND: ib_sa_free_multicast(mc->multicast.ib); kfree(mc); break; case IB_LINK_LAYER_ETHERNET: kref_put(&mc->mcref, release_mc); break; default: break; } } return; } } spin_unlock_irq(&id_priv->lock); } EXPORT_SYMBOL(rdma_leave_multicast); static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id_priv) { struct rdma_dev_addr *dev_addr; struct cma_ndev_work *work; dev_addr = &id_priv->id.route.addr.dev_addr; if ((dev_addr->bound_dev_if == ndev->ifindex) && memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) { printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n", ndev->name, &id_priv->id); work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; INIT_WORK(&work->work, cma_ndev_work_handler); work->id = id_priv; work->event.event = RDMA_CM_EVENT_ADDR_CHANGE; atomic_inc(&id_priv->refcount); queue_work(cma_wq, &work->work); } return 0; } static int cma_netdev_callback(struct notifier_block *self, unsigned long event, void *ctx) { struct net_device *ndev = (struct net_device *)ctx; struct cma_device *cma_dev; struct rdma_id_private *id_priv; int ret = NOTIFY_DONE; if (dev_net(ndev) != &init_net) return NOTIFY_DONE; if (event != NETDEV_BONDING_FAILOVER) return NOTIFY_DONE; if (!(ndev->flags & IFF_MASTER) || !(ndev->priv_flags & IFF_BONDING)) return NOTIFY_DONE; mutex_lock(&lock); list_for_each_entry(cma_dev, &dev_list, list) list_for_each_entry(id_priv, &cma_dev->id_list, list) { ret = cma_netdev_change(ndev, id_priv); if (ret) goto out; } out: mutex_unlock(&lock); return ret; } static struct notifier_block cma_nb = { .notifier_call = cma_netdev_callback }; static void cma_add_one(struct ib_device *device) { struct cma_device *cma_dev; struct rdma_id_private *id_priv; cma_dev = kmalloc(sizeof *cma_dev, GFP_KERNEL); if (!cma_dev) return; cma_dev->device = device; init_completion(&cma_dev->comp); atomic_set(&cma_dev->refcount, 1); INIT_LIST_HEAD(&cma_dev->id_list); ib_set_client_data(device, &cma_client, cma_dev); mutex_lock(&lock); list_add_tail(&cma_dev->list, &dev_list); list_for_each_entry(id_priv, &listen_any_list, list) cma_listen_on_dev(id_priv, cma_dev); mutex_unlock(&lock); } static int cma_remove_id_dev(struct rdma_id_private *id_priv) { struct rdma_cm_event event; enum rdma_cm_state state; int ret = 0; /* Record that we want to remove the device */ state = cma_exch(id_priv, RDMA_CM_DEVICE_REMOVAL); if (state == RDMA_CM_DESTROYING) return 0; cma_cancel_operation(id_priv, state); mutex_lock(&id_priv->handler_mutex); /* Check for destruction from another callback. */ if (!cma_comp(id_priv, RDMA_CM_DEVICE_REMOVAL)) goto out; memset(&event, 0, sizeof event); event.event = RDMA_CM_EVENT_DEVICE_REMOVAL; ret = id_priv->id.event_handler(&id_priv->id, &event); out: mutex_unlock(&id_priv->handler_mutex); return ret; } static void cma_process_remove(struct cma_device *cma_dev) { struct rdma_id_private *id_priv; int ret; mutex_lock(&lock); while (!list_empty(&cma_dev->id_list)) { id_priv = list_entry(cma_dev->id_list.next, struct rdma_id_private, list); list_del(&id_priv->listen_list); list_del_init(&id_priv->list); atomic_inc(&id_priv->refcount); mutex_unlock(&lock); ret = id_priv->internal_id ? 1 : cma_remove_id_dev(id_priv); cma_deref_id(id_priv); if (ret) rdma_destroy_id(&id_priv->id); mutex_lock(&lock); } mutex_unlock(&lock); cma_deref_dev(cma_dev); wait_for_completion(&cma_dev->comp); } static void cma_remove_one(struct ib_device *device) { struct cma_device *cma_dev; cma_dev = ib_get_client_data(device, &cma_client); if (!cma_dev) return; mutex_lock(&lock); list_del(&cma_dev->list); mutex_unlock(&lock); cma_process_remove(cma_dev); kfree(cma_dev); } static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb) { struct nlmsghdr *nlh; struct rdma_cm_id_stats *id_stats; struct rdma_id_private *id_priv; struct rdma_cm_id *id = NULL; struct cma_device *cma_dev; int i_dev = 0, i_id = 0; /* * We export all of the IDs as a sequence of messages. Each * ID gets its own netlink message. */ mutex_lock(&lock); list_for_each_entry(cma_dev, &dev_list, list) { if (i_dev < cb->args[0]) { i_dev++; continue; } i_id = 0; list_for_each_entry(id_priv, &cma_dev->id_list, list) { if (i_id < cb->args[1]) { i_id++; continue; } id_stats = ibnl_put_msg(skb, &nlh, cb->nlh->nlmsg_seq, sizeof *id_stats, RDMA_NL_RDMA_CM, RDMA_NL_RDMA_CM_ID_STATS); if (!id_stats) goto out; memset(id_stats, 0, sizeof *id_stats); id = &id_priv->id; id_stats->node_type = id->route.addr.dev_addr.dev_type; id_stats->port_num = id->port_num; id_stats->bound_dev_if = id->route.addr.dev_addr.bound_dev_if; if (id->route.addr.src_addr.ss_family == AF_INET) { if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in), &id->route.addr.src_addr, RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) { goto out; } if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in), &id->route.addr.dst_addr, RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) { goto out; } } else if (id->route.addr.src_addr.ss_family == AF_INET6) { if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in6), &id->route.addr.src_addr, RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) { goto out; } if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in6), &id->route.addr.dst_addr, RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) { goto out; } } id_stats->pid = id_priv->owner; id_stats->port_space = id->ps; id_stats->cm_state = id_priv->state; id_stats->qp_num = id_priv->qp_num; id_stats->qp_type = id->qp_type; i_id++; } cb->args[1] = 0; i_dev++; } out: mutex_unlock(&lock); cb->args[0] = i_dev; cb->args[1] = i_id; return skb->len; } static const struct ibnl_client_cbs cma_cb_table[] = { [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats, .module = THIS_MODULE }, }; static int __init cma_init(void) { int ret; cma_wq = create_singlethread_workqueue("rdma_cm"); if (!cma_wq) return -ENOMEM; ib_sa_register_client(&sa_client); rdma_addr_register_client(&addr_client); register_netdevice_notifier(&cma_nb); ret = ib_register_client(&cma_client); if (ret) goto err; if (ibnl_add_client(RDMA_NL_RDMA_CM, RDMA_NL_RDMA_CM_NUM_OPS, cma_cb_table)) printk(KERN_WARNING "RDMA CMA: failed to add netlink callback\n"); return 0; err: unregister_netdevice_notifier(&cma_nb); rdma_addr_unregister_client(&addr_client); ib_sa_unregister_client(&sa_client); destroy_workqueue(cma_wq); return ret; } static void __exit cma_cleanup(void) { ibnl_remove_client(RDMA_NL_RDMA_CM); ib_unregister_client(&cma_client); unregister_netdevice_notifier(&cma_nb); rdma_addr_unregister_client(&addr_client); ib_sa_unregister_client(&sa_client); destroy_workqueue(cma_wq); idr_destroy(&sdp_ps); idr_destroy(&tcp_ps); idr_destroy(&udp_ps); idr_destroy(&ipoib_ps); idr_destroy(&ib_ps); } module_init(cma_init); module_exit(cma_cleanup);
aquarism5-dev/android_kernel_bq_piccolo
drivers/infiniband/core/cma.c
C
gpl-2.0
90,820
/* * hdmi_panel.c * * HDMI library support functions for TI OMAP4 processors. * * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/ * Authors: Mythri P k <mythripk@ti.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * 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, see <http://www.gnu.org/licenses/>. */ #include <linux/kernel.h> #include <linux/err.h> #include <linux/io.h> #include <linux/mutex.h> #include <linux/module.h> #include <video/omapdss.h> #include <linux/slab.h> #include "dss.h" static struct { /* This protects the panel ops, mainly when accessing the HDMI IP. */ struct mutex lock; #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO) /* This protects the audio ops, specifically. */ spinlock_t audio_lock; #endif } hdmi; static int hdmi_panel_probe(struct omap_dss_device *dssdev) { /* Initialize default timings to VGA in DVI mode */ const struct omap_video_timings default_timings = { .x_res = 640, .y_res = 480, .pixel_clock = 25175, .hsw = 96, .hfp = 16, .hbp = 48, .vsw = 2, .vfp = 11, .vbp = 31, .vsync_level = OMAPDSS_SIG_ACTIVE_LOW, .hsync_level = OMAPDSS_SIG_ACTIVE_LOW, .interlace = false, }; DSSDBG("ENTER hdmi_panel_probe\n"); dssdev->panel.timings = default_timings; DSSDBG("hdmi_panel_probe x_res= %d y_res = %d\n", dssdev->panel.timings.x_res, dssdev->panel.timings.y_res); omapdss_hdmi_display_set_timing(dssdev, &dssdev->panel.timings); return 0; } static void hdmi_panel_remove(struct omap_dss_device *dssdev) { } #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO) static int hdmi_panel_audio_enable(struct omap_dss_device *dssdev) { unsigned long flags; int r; mutex_lock(&hdmi.lock); spin_lock_irqsave(&hdmi.audio_lock, flags); /* enable audio only if the display is active and supports audio */ if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE || !hdmi_mode_has_audio()) { DSSERR("audio not supported or display is off\n"); r = -EPERM; goto err; } r = hdmi_audio_enable(); if (!r) dssdev->audio_state = OMAP_DSS_AUDIO_ENABLED; err: spin_unlock_irqrestore(&hdmi.audio_lock, flags); mutex_unlock(&hdmi.lock); return r; } static void hdmi_panel_audio_disable(struct omap_dss_device *dssdev) { unsigned long flags; spin_lock_irqsave(&hdmi.audio_lock, flags); hdmi_audio_disable(); dssdev->audio_state = OMAP_DSS_AUDIO_DISABLED; spin_unlock_irqrestore(&hdmi.audio_lock, flags); } static int hdmi_panel_audio_start(struct omap_dss_device *dssdev) { unsigned long flags; int r; spin_lock_irqsave(&hdmi.audio_lock, flags); /* * No need to check the panel state. It was checked when trasitioning * to AUDIO_ENABLED. */ if (dssdev->audio_state != OMAP_DSS_AUDIO_ENABLED) { DSSERR("audio start from invalid state\n"); r = -EPERM; goto err; } r = hdmi_audio_start(); if (!r) dssdev->audio_state = OMAP_DSS_AUDIO_PLAYING; err: spin_unlock_irqrestore(&hdmi.audio_lock, flags); return r; } static void hdmi_panel_audio_stop(struct omap_dss_device *dssdev) { unsigned long flags; spin_lock_irqsave(&hdmi.audio_lock, flags); hdmi_audio_stop(); dssdev->audio_state = OMAP_DSS_AUDIO_ENABLED; spin_unlock_irqrestore(&hdmi.audio_lock, flags); } static bool hdmi_panel_audio_supported(struct omap_dss_device *dssdev) { bool r = false; mutex_lock(&hdmi.lock); if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) goto err; if (!hdmi_mode_has_audio()) goto err; r = true; err: mutex_unlock(&hdmi.lock); return r; } static int hdmi_panel_audio_config(struct omap_dss_device *dssdev, struct omap_dss_audio *audio) { unsigned long flags; int r; mutex_lock(&hdmi.lock); spin_lock_irqsave(&hdmi.audio_lock, flags); /* config audio only if the display is active and supports audio */ if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE || !hdmi_mode_has_audio()) { DSSERR("audio not supported or display is off\n"); r = -EPERM; goto err; } r = hdmi_audio_config(audio); if (!r) dssdev->audio_state = OMAP_DSS_AUDIO_CONFIGURED; err: spin_unlock_irqrestore(&hdmi.audio_lock, flags); mutex_unlock(&hdmi.lock); return r; } #else static int hdmi_panel_audio_enable(struct omap_dss_device *dssdev) { return -EPERM; } static void hdmi_panel_audio_disable(struct omap_dss_device *dssdev) { } static int hdmi_panel_audio_start(struct omap_dss_device *dssdev) { return -EPERM; } static void hdmi_panel_audio_stop(struct omap_dss_device *dssdev) { } static bool hdmi_panel_audio_supported(struct omap_dss_device *dssdev) { return false; } static int hdmi_panel_audio_config(struct omap_dss_device *dssdev, struct omap_dss_audio *audio) { return -EPERM; } #endif static int hdmi_panel_enable(struct omap_dss_device *dssdev) { int r = 0; DSSDBG("ENTER hdmi_panel_enable\n"); mutex_lock(&hdmi.lock); if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) { r = -EINVAL; goto err; } omapdss_hdmi_display_set_timing(dssdev, &dssdev->panel.timings); r = omapdss_hdmi_display_enable(dssdev); if (r) { DSSERR("failed to power on\n"); goto err; } dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; err: mutex_unlock(&hdmi.lock); return r; } static void hdmi_panel_disable(struct omap_dss_device *dssdev) { mutex_lock(&hdmi.lock); if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) { /* * TODO: notify audio users that the display was disabled. For * now, disable audio locally to not break our audio state * machine. */ hdmi_panel_audio_disable(dssdev); omapdss_hdmi_display_disable(dssdev); } dssdev->state = OMAP_DSS_DISPLAY_DISABLED; mutex_unlock(&hdmi.lock); } static void hdmi_get_timings(struct omap_dss_device *dssdev, struct omap_video_timings *timings) { mutex_lock(&hdmi.lock); *timings = dssdev->panel.timings; mutex_unlock(&hdmi.lock); } static void hdmi_set_timings(struct omap_dss_device *dssdev, struct omap_video_timings *timings) { DSSDBG("hdmi_set_timings\n"); mutex_lock(&hdmi.lock); /* * TODO: notify audio users that there was a timings change. For * now, disable audio locally to not break our audio state machine. */ hdmi_panel_audio_disable(dssdev); omapdss_hdmi_display_set_timing(dssdev, timings); dssdev->panel.timings = *timings; mutex_unlock(&hdmi.lock); } static int hdmi_check_timings(struct omap_dss_device *dssdev, struct omap_video_timings *timings) { int r = 0; DSSDBG("hdmi_check_timings\n"); mutex_lock(&hdmi.lock); r = omapdss_hdmi_display_check_timing(dssdev, timings); mutex_unlock(&hdmi.lock); return r; } static int hdmi_read_edid(struct omap_dss_device *dssdev, u8 *buf, int len) { int r; bool need_enable; mutex_lock(&hdmi.lock); need_enable = dssdev->state == OMAP_DSS_DISPLAY_DISABLED; if (need_enable) { r = omapdss_hdmi_core_enable(dssdev); if (r) goto err; } r = omapdss_hdmi_read_edid(buf, len); if (need_enable) omapdss_hdmi_core_disable(dssdev); err: mutex_unlock(&hdmi.lock); return r; } static bool hdmi_detect(struct omap_dss_device *dssdev) { int r; bool need_enable; mutex_lock(&hdmi.lock); need_enable = dssdev->state == OMAP_DSS_DISPLAY_DISABLED; if (need_enable) { r = omapdss_hdmi_core_enable(dssdev); if (r) goto err; } r = omapdss_hdmi_detect(); if (need_enable) omapdss_hdmi_core_disable(dssdev); err: mutex_unlock(&hdmi.lock); return r; } static struct omap_dss_driver hdmi_driver = { .probe = hdmi_panel_probe, .remove = hdmi_panel_remove, .enable = hdmi_panel_enable, .disable = hdmi_panel_disable, .get_timings = hdmi_get_timings, .set_timings = hdmi_set_timings, .check_timings = hdmi_check_timings, .read_edid = hdmi_read_edid, .detect = hdmi_detect, .audio_enable = hdmi_panel_audio_enable, .audio_disable = hdmi_panel_audio_disable, .audio_start = hdmi_panel_audio_start, .audio_stop = hdmi_panel_audio_stop, .audio_supported = hdmi_panel_audio_supported, .audio_config = hdmi_panel_audio_config, .driver = { .name = "hdmi_panel", .owner = THIS_MODULE, }, }; int hdmi_panel_init(void) { mutex_init(&hdmi.lock); #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO) spin_lock_init(&hdmi.audio_lock); #endif return omap_dss_register_driver(&hdmi_driver); } void hdmi_panel_exit(void) { omap_dss_unregister_driver(&hdmi_driver); }
MikeC84/android_kernel_motorola_shamu
drivers/video/omap2/dss/hdmi_panel.c
C
gpl-2.0
8,695
/* cx231xx-core.c - driver for Conexant Cx23100/101/102 USB video capture devices Copyright (C) 2008 <srinivasa.deevi at conexant dot com> Based on em28xx driver 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/init.h> #include <linux/list.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/usb.h> #include <linux/vmalloc.h> #include <media/v4l2-common.h> #include <media/tuner.h> #include "cx231xx.h" #include "cx231xx-reg.h" /* #define ENABLE_DEBUG_ISOC_FRAMES */ static unsigned int core_debug; module_param(core_debug, int, 0644); MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); #define cx231xx_coredbg(fmt, arg...) do {\ if (core_debug) \ printk(KERN_INFO "%s %s :"fmt, \ dev->name, __func__ , ##arg); } while (0) static unsigned int reg_debug; module_param(reg_debug, int, 0644); MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]"); static int alt = CX231XX_PINOUT; module_param(alt, int, 0644); MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); #define cx231xx_isocdbg(fmt, arg...) do {\ if (core_debug) \ printk(KERN_INFO "%s %s :"fmt, \ dev->name, __func__ , ##arg); } while (0) /***************************************************************** * Device control list functions * ******************************************************************/ LIST_HEAD(cx231xx_devlist); static DEFINE_MUTEX(cx231xx_devlist_mutex); /* * cx231xx_realease_resources() * unregisters the v4l2,i2c and usb devices * called when the device gets disconected or at module unload */ void cx231xx_remove_from_devlist(struct cx231xx *dev) { if (dev == NULL) return; if (dev->udev == NULL) return; if (atomic_read(&dev->devlist_count) > 0) { mutex_lock(&cx231xx_devlist_mutex); list_del(&dev->devlist); atomic_dec(&dev->devlist_count); mutex_unlock(&cx231xx_devlist_mutex); } }; void cx231xx_add_into_devlist(struct cx231xx *dev) { mutex_lock(&cx231xx_devlist_mutex); list_add_tail(&dev->devlist, &cx231xx_devlist); atomic_inc(&dev->devlist_count); mutex_unlock(&cx231xx_devlist_mutex); }; static LIST_HEAD(cx231xx_extension_devlist); int cx231xx_register_extension(struct cx231xx_ops *ops) { struct cx231xx *dev = NULL; mutex_lock(&cx231xx_devlist_mutex); list_add_tail(&ops->next, &cx231xx_extension_devlist); list_for_each_entry(dev, &cx231xx_devlist, devlist) ops->init(dev); printk(KERN_INFO DRIVER_NAME ": %s initialized\n", ops->name); mutex_unlock(&cx231xx_devlist_mutex); return 0; } EXPORT_SYMBOL(cx231xx_register_extension); void cx231xx_unregister_extension(struct cx231xx_ops *ops) { struct cx231xx *dev = NULL; mutex_lock(&cx231xx_devlist_mutex); list_for_each_entry(dev, &cx231xx_devlist, devlist) ops->fini(dev); printk(KERN_INFO DRIVER_NAME ": %s removed\n", ops->name); list_del(&ops->next); mutex_unlock(&cx231xx_devlist_mutex); } EXPORT_SYMBOL(cx231xx_unregister_extension); void cx231xx_init_extension(struct cx231xx *dev) { struct cx231xx_ops *ops = NULL; mutex_lock(&cx231xx_devlist_mutex); if (!list_empty(&cx231xx_extension_devlist)) { list_for_each_entry(ops, &cx231xx_extension_devlist, next) { if (ops->init) ops->init(dev); } } mutex_unlock(&cx231xx_devlist_mutex); } void cx231xx_close_extension(struct cx231xx *dev) { struct cx231xx_ops *ops = NULL; mutex_lock(&cx231xx_devlist_mutex); if (!list_empty(&cx231xx_extension_devlist)) { list_for_each_entry(ops, &cx231xx_extension_devlist, next) { if (ops->fini) ops->fini(dev); } } mutex_unlock(&cx231xx_devlist_mutex); } /**************************************************************** * U S B related functions * *****************************************************************/ int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, struct cx231xx_i2c_xfer_data *req_data) { int status = 0; struct cx231xx *dev = i2c_bus->dev; struct VENDOR_REQUEST_IN ven_req; u8 saddr_len = 0; u8 _i2c_period = 0; u8 _i2c_nostop = 0; u8 _i2c_reserve = 0; if (dev->state & DEV_DISCONNECTED) return -ENODEV; /* Get the I2C period, nostop and reserve parameters */ _i2c_period = i2c_bus->i2c_period; _i2c_nostop = i2c_bus->i2c_nostop; _i2c_reserve = i2c_bus->i2c_reserve; saddr_len = req_data->saddr_len; /* Set wValue */ if (saddr_len == 1) /* need check saddr_len == 0 */ ven_req.wValue = req_data-> dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; else ven_req.wValue = req_data-> dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; /* set channel number */ if (req_data->direction & I2C_M_RD) { /* channel number, for read,spec required channel_num +4 */ ven_req.bRequest = i2c_bus->nr + 4; } else ven_req.bRequest = i2c_bus->nr; /* channel number, */ /* set index value */ switch (saddr_len) { case 0: ven_req.wIndex = 0; /* need check */ break; case 1: ven_req.wIndex = (req_data->saddr_dat & 0xff); break; case 2: ven_req.wIndex = req_data->saddr_dat; break; } /* set wLength value */ ven_req.wLength = req_data->buf_size; /* set bData value */ ven_req.bData = 0; /* set the direction */ if (req_data->direction) { ven_req.direction = USB_DIR_IN; memset(req_data->p_buffer, 0x00, ven_req.wLength); } else ven_req.direction = USB_DIR_OUT; /* set the buffer for read / write */ ven_req.pBuff = req_data->p_buffer; /* call common vendor command request */ status = cx231xx_send_vendor_cmd(dev, &ven_req); if (status < 0) { cx231xx_info ("UsbInterface::sendCommand, failed with status -%d\n", status); } return status; } EXPORT_SYMBOL_GPL(cx231xx_send_usb_command); /* * Sends/Receives URB control messages, assuring to use a kalloced buffer * for all operations (dev->urb_buf), to avoid using stacked buffers, as * they aren't safe for usage with USB, due to DMA restrictions. * Also implements the debug code for control URB's. */ static int __usb_control_msg(struct cx231xx *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout) { int rc, i; if (reg_debug) { printk(KERN_DEBUG "%s: (pipe 0x%08x): " "%s: %02x %02x %02x %02x %02x %02x %02x %02x ", dev->name, pipe, (requesttype & USB_DIR_IN) ? "IN" : "OUT", requesttype, request, value & 0xff, value >> 8, index & 0xff, index >> 8, size & 0xff, size >> 8); if (!(requesttype & USB_DIR_IN)) { printk(KERN_CONT ">>>"); for (i = 0; i < size; i++) printk(KERN_CONT " %02x", ((unsigned char *)data)[i]); } } /* Do the real call to usb_control_msg */ mutex_lock(&dev->ctrl_urb_lock); if (!(requesttype & USB_DIR_IN) && size) memcpy(dev->urb_buf, data, size); rc = usb_control_msg(dev->udev, pipe, request, requesttype, value, index, dev->urb_buf, size, timeout); if ((requesttype & USB_DIR_IN) && size) memcpy(data, dev->urb_buf, size); mutex_unlock(&dev->ctrl_urb_lock); if (reg_debug) { if (unlikely(rc < 0)) { printk(KERN_CONT "FAILED!\n"); return rc; } if ((requesttype & USB_DIR_IN)) { printk(KERN_CONT "<<<"); for (i = 0; i < size; i++) printk(KERN_CONT " %02x", ((unsigned char *)data)[i]); } printk(KERN_CONT "\n"); } return rc; } /* * cx231xx_read_ctrl_reg() * reads data from the usb device specifying bRequest and wValue */ int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, int len) { u8 val = 0; int ret; int pipe = usb_rcvctrlpipe(dev->udev, 0); if (dev->state & DEV_DISCONNECTED) return -ENODEV; if (len > URB_MAX_CTRL_SIZE) return -EINVAL; switch (len) { case 1: val = ENABLE_ONE_BYTE; break; case 2: val = ENABLE_TWE_BYTE; break; case 3: val = ENABLE_THREE_BYTE; break; case 4: val = ENABLE_FOUR_BYTE; break; default: val = 0xFF; /* invalid option */ } if (val == 0xFF) return -EINVAL; ret = __usb_control_msg(dev, pipe, req, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, val, reg, buf, len, HZ); return ret; } int cx231xx_send_vendor_cmd(struct cx231xx *dev, struct VENDOR_REQUEST_IN *ven_req) { int ret; int pipe = 0; int unsend_size = 0; u8 *pdata; if (dev->state & DEV_DISCONNECTED) return -ENODEV; if ((ven_req->wLength > URB_MAX_CTRL_SIZE)) return -EINVAL; if (ven_req->direction) pipe = usb_rcvctrlpipe(dev->udev, 0); else pipe = usb_sndctrlpipe(dev->udev, 0); /* * If the cx23102 read more than 4 bytes with i2c bus, * need chop to 4 byte per request */ if ((ven_req->wLength > 4) && ((ven_req->bRequest == 0x4) || (ven_req->bRequest == 0x5) || (ven_req->bRequest == 0x6))) { unsend_size = 0; pdata = ven_req->pBuff; unsend_size = ven_req->wLength; /* the first package */ ven_req->wValue = ven_req->wValue & 0xFFFB; ven_req->wValue = (ven_req->wValue & 0xFFBD) | 0x2; ret = __usb_control_msg(dev, pipe, ven_req->bRequest, ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ven_req->wValue, ven_req->wIndex, pdata, 0x0004, HZ); unsend_size = unsend_size - 4; /* the middle package */ ven_req->wValue = (ven_req->wValue & 0xFFBD) | 0x42; while (unsend_size - 4 > 0) { pdata = pdata + 4; ret = __usb_control_msg(dev, pipe, ven_req->bRequest, ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ven_req->wValue, ven_req->wIndex, pdata, 0x0004, HZ); unsend_size = unsend_size - 4; } /* the last package */ ven_req->wValue = (ven_req->wValue & 0xFFBD) | 0x40; pdata = pdata + 4; ret = __usb_control_msg(dev, pipe, ven_req->bRequest, ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ven_req->wValue, ven_req->wIndex, pdata, unsend_size, HZ); } else { ret = __usb_control_msg(dev, pipe, ven_req->bRequest, ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ven_req->wValue, ven_req->wIndex, ven_req->pBuff, ven_req->wLength, HZ); } return ret; } /* * cx231xx_write_ctrl_reg() * sends data to the usb device, specifying bRequest */ int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, int len) { u8 val = 0; int ret; int pipe = usb_sndctrlpipe(dev->udev, 0); if (dev->state & DEV_DISCONNECTED) return -ENODEV; if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) return -EINVAL; switch (len) { case 1: val = ENABLE_ONE_BYTE; break; case 2: val = ENABLE_TWE_BYTE; break; case 3: val = ENABLE_THREE_BYTE; break; case 4: val = ENABLE_FOUR_BYTE; break; default: val = 0xFF; /* invalid option */ } if (val == 0xFF) return -EINVAL; if (reg_debug) { int byte; cx231xx_isocdbg("(pipe 0x%08x): " "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>", pipe, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, req, 0, val, reg & 0xff, reg >> 8, len & 0xff, len >> 8); for (byte = 0; byte < len; byte++) cx231xx_isocdbg(" %02x", (unsigned char)buf[byte]); cx231xx_isocdbg("\n"); } ret = __usb_control_msg(dev, pipe, req, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, val, reg, buf, len, HZ); return ret; } /**************************************************************** * USB Alternate Setting functions * *****************************************************************/ int cx231xx_set_video_alternate(struct cx231xx *dev) { int errCode, prev_alt = dev->video_mode.alt; unsigned int min_pkt_size = dev->width * 2 + 4; u32 usb_interface_index = 0; /* When image size is bigger than a certain value, the frame size should be increased, otherwise, only green screen will be received. */ if (dev->width * 2 * dev->height > 720 * 240 * 2) min_pkt_size *= 2; if (dev->width > 360) { /* resolutions: 720,704,640 */ dev->video_mode.alt = 3; } else if (dev->width > 180) { /* resolutions: 360,352,320,240 */ dev->video_mode.alt = 2; } else if (dev->width > 0) { /* resolutions: 180,176,160,128,88 */ dev->video_mode.alt = 1; } else { /* Change to alt0 BULK to release USB bandwidth */ dev->video_mode.alt = 0; } if (dev->USE_ISO == 0) dev->video_mode.alt = 0; cx231xx_coredbg("dev->video_mode.alt= %d\n", dev->video_mode.alt); /* Get the correct video interface Index */ usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. video_index + 1; if (dev->video_mode.alt != prev_alt) { cx231xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", min_pkt_size, dev->video_mode.alt); if (dev->video_mode.alt_max_pkt_size != NULL) dev->video_mode.max_pkt_size = dev->video_mode.alt_max_pkt_size[dev->video_mode.alt]; cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", dev->video_mode.alt, dev->video_mode.max_pkt_size); errCode = usb_set_interface(dev->udev, usb_interface_index, dev->video_mode.alt); if (errCode < 0) { cx231xx_errdev ("cannot change alt number to %d (error=%i)\n", dev->video_mode.alt, errCode); return errCode; } } return 0; } int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) { int status = 0; u32 usb_interface_index = 0; u32 max_pkt_size = 0; switch (index) { case INDEX_TS1: usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. ts1_index + 1; dev->ts1_mode.alt = alt; if (dev->ts1_mode.alt_max_pkt_size != NULL) max_pkt_size = dev->ts1_mode.max_pkt_size = dev->ts1_mode.alt_max_pkt_size[dev->ts1_mode.alt]; break; case INDEX_TS2: usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. ts2_index + 1; break; case INDEX_AUDIO: usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. audio_index + 1; dev->adev.alt = alt; if (dev->adev.alt_max_pkt_size != NULL) max_pkt_size = dev->adev.max_pkt_size = dev->adev.alt_max_pkt_size[dev->adev.alt]; break; case INDEX_VIDEO: usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. video_index + 1; dev->video_mode.alt = alt; if (dev->video_mode.alt_max_pkt_size != NULL) max_pkt_size = dev->video_mode.max_pkt_size = dev->video_mode.alt_max_pkt_size[dev->video_mode. alt]; break; case INDEX_VANC: if (dev->board.no_alt_vanc) return 0; usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. vanc_index + 1; dev->vbi_mode.alt = alt; if (dev->vbi_mode.alt_max_pkt_size != NULL) max_pkt_size = dev->vbi_mode.max_pkt_size = dev->vbi_mode.alt_max_pkt_size[dev->vbi_mode.alt]; break; case INDEX_HANC: usb_interface_index = dev->current_pcb_config.hs_config_info[0].interface_info. hanc_index + 1; dev->sliced_cc_mode.alt = alt; if (dev->sliced_cc_mode.alt_max_pkt_size != NULL) max_pkt_size = dev->sliced_cc_mode.max_pkt_size = dev->sliced_cc_mode.alt_max_pkt_size[dev-> sliced_cc_mode. alt]; break; default: break; } if (alt > 0 && max_pkt_size == 0) { cx231xx_errdev ("can't change interface %d alt no. to %d: Max. Pkt size = 0\n", usb_interface_index, alt); /*To workaround error number=-71 on EP0 for videograbber, need add following codes.*/ if (dev->board.no_alt_vanc) return -1; } cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u," "Interface = %d\n", alt, max_pkt_size, usb_interface_index); if (usb_interface_index > 0) { status = usb_set_interface(dev->udev, usb_interface_index, alt); if (status < 0) { cx231xx_errdev ("can't change interface %d alt no. to %d (err=%i)\n", usb_interface_index, alt, status); return status; } } return status; } EXPORT_SYMBOL_GPL(cx231xx_set_alt_setting); int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio) { int rc = 0; if (!gpio) return rc; /* Send GPIO reset sequences specified at board entry */ while (gpio->sleep >= 0) { rc = cx231xx_set_gpio_value(dev, gpio->bit, gpio->val); if (rc < 0) return rc; if (gpio->sleep > 0) msleep(gpio->sleep); gpio++; } return rc; } int cx231xx_demod_reset(struct cx231xx *dev) { u8 status = 0; u8 value[4] = { 0, 0, 0, 0 }; status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, 4); cx231xx_coredbg("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, value[0], value[1], value[2], value[3]); cx231xx_coredbg("Enter cx231xx_demod_reset()\n"); value[1] = (u8) 0x3; status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, value, 4); msleep(10); value[1] = (u8) 0x0; status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, value, 4); msleep(10); value[1] = (u8) 0x3; status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, value, 4); msleep(10); status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, 4); cx231xx_coredbg("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, value[0], value[1], value[2], value[3]); return status; } EXPORT_SYMBOL_GPL(cx231xx_demod_reset); int is_fw_load(struct cx231xx *dev) { return cx231xx_check_fw(dev); } EXPORT_SYMBOL_GPL(is_fw_load); int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode) { int errCode = 0; if (dev->mode == set_mode) return 0; if (set_mode == CX231XX_SUSPEND) { /* Set the chip in power saving mode */ dev->mode = set_mode; } /* Resource is locked */ if (dev->mode != CX231XX_SUSPEND) return -EINVAL; dev->mode = set_mode; if (dev->mode == CX231XX_DIGITAL_MODE)/* Set Digital power mode */ { /* set AGC mode to Digital */ switch (dev->model) { case CX231XX_BOARD_CNXT_CARRAERA: case CX231XX_BOARD_CNXT_RDE_250: case CX231XX_BOARD_CNXT_SHELBY: case CX231XX_BOARD_CNXT_RDU_250: errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); break; case CX231XX_BOARD_CNXT_RDE_253S: case CX231XX_BOARD_CNXT_RDU_253S: errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); break; case CX231XX_BOARD_HAUPPAUGE_EXETER: errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_DIGITAL); break; default: break; } } else/* Set Analog Power mode */ { /* set AGC mode to Analog */ switch (dev->model) { case CX231XX_BOARD_CNXT_CARRAERA: case CX231XX_BOARD_CNXT_RDE_250: case CX231XX_BOARD_CNXT_SHELBY: case CX231XX_BOARD_CNXT_RDU_250: errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); break; case CX231XX_BOARD_CNXT_RDE_253S: case CX231XX_BOARD_CNXT_RDU_253S: case CX231XX_BOARD_HAUPPAUGE_EXETER: case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); break; default: break; } } return errCode ? -EINVAL : 0; } EXPORT_SYMBOL_GPL(cx231xx_set_mode); int cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size) { int errCode = 0; int actlen, ret = -ENOMEM; u32 *buffer; buffer = kzalloc(4096, GFP_KERNEL); if (buffer == NULL) { cx231xx_info("out of mem\n"); return -ENOMEM; } memcpy(&buffer[0], firmware, 4096); ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5), buffer, 4096, &actlen, 2000); if (ret) cx231xx_info("bulk message failed: %d (%d/%d)", ret, size, actlen); else { errCode = actlen != size ? -1 : 0; } kfree(buffer); return errCode; } /***************************************************************** * URB Streaming functions * ******************************************************************/ /* * IRQ callback, called by URB callback */ static void cx231xx_isoc_irq_callback(struct urb *urb) { struct cx231xx_dmaqueue *dma_q = urb->context; struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); int i; switch (urb->status) { case 0: /* success */ case -ETIMEDOUT: /* NAK */ break; case -ECONNRESET: /* kill */ case -ENOENT: case -ESHUTDOWN: return; default: /* error */ cx231xx_isocdbg("urb completition error %d.\n", urb->status); break; } /* Copy data from URB */ spin_lock(&dev->video_mode.slock); dev->video_mode.isoc_ctl.isoc_copy(dev, urb); spin_unlock(&dev->video_mode.slock); /* Reset urb buffers */ for (i = 0; i < urb->number_of_packets; i++) { urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].actual_length = 0; } urb->status = usb_submit_urb(urb, GFP_ATOMIC); if (urb->status) { cx231xx_isocdbg("urb resubmit failed (error=%i)\n", urb->status); } } /***************************************************************** * URB Streaming functions * ******************************************************************/ /* * IRQ callback, called by URB callback */ static void cx231xx_bulk_irq_callback(struct urb *urb) { struct cx231xx_dmaqueue *dma_q = urb->context; struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); switch (urb->status) { case 0: /* success */ case -ETIMEDOUT: /* NAK */ break; case -ECONNRESET: /* kill */ case -ENOENT: case -ESHUTDOWN: return; default: /* error */ cx231xx_isocdbg("urb completition error %d.\n", urb->status); break; } /* Copy data from URB */ spin_lock(&dev->video_mode.slock); dev->video_mode.bulk_ctl.bulk_copy(dev, urb); spin_unlock(&dev->video_mode.slock); /* Reset urb buffers */ urb->status = usb_submit_urb(urb, GFP_ATOMIC); if (urb->status) { cx231xx_isocdbg("urb resubmit failed (error=%i)\n", urb->status); } } /* * Stop and Deallocate URBs */ void cx231xx_uninit_isoc(struct cx231xx *dev) { struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; struct urb *urb; int i; cx231xx_isocdbg("cx231xx: called cx231xx_uninit_isoc\n"); dev->video_mode.isoc_ctl.nfields = -1; for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { urb = dev->video_mode.isoc_ctl.urb[i]; if (urb) { if (!irqs_disabled()) usb_kill_urb(urb); else usb_unlink_urb(urb); if (dev->video_mode.isoc_ctl.transfer_buffer[i]) { usb_free_coherent(dev->udev, urb->transfer_buffer_length, dev->video_mode.isoc_ctl. transfer_buffer[i], urb->transfer_dma); } usb_free_urb(urb); dev->video_mode.isoc_ctl.urb[i] = NULL; } dev->video_mode.isoc_ctl.transfer_buffer[i] = NULL; } kfree(dev->video_mode.isoc_ctl.urb); kfree(dev->video_mode.isoc_ctl.transfer_buffer); kfree(dma_q->p_left_data); dev->video_mode.isoc_ctl.urb = NULL; dev->video_mode.isoc_ctl.transfer_buffer = NULL; dev->video_mode.isoc_ctl.num_bufs = 0; dma_q->p_left_data = NULL; if (dev->mode_tv == 0) cx231xx_capture_start(dev, 0, Raw_Video); else cx231xx_capture_start(dev, 0, TS1_serial_mode); } EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc); /* * Stop and Deallocate URBs */ void cx231xx_uninit_bulk(struct cx231xx *dev) { struct urb *urb; int i; cx231xx_isocdbg("cx231xx: called cx231xx_uninit_bulk\n"); dev->video_mode.bulk_ctl.nfields = -1; for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { urb = dev->video_mode.bulk_ctl.urb[i]; if (urb) { if (!irqs_disabled()) usb_kill_urb(urb); else usb_unlink_urb(urb); if (dev->video_mode.bulk_ctl.transfer_buffer[i]) { usb_free_coherent(dev->udev, urb->transfer_buffer_length, dev->video_mode.isoc_ctl. transfer_buffer[i], urb->transfer_dma); } usb_free_urb(urb); dev->video_mode.bulk_ctl.urb[i] = NULL; } dev->video_mode.bulk_ctl.transfer_buffer[i] = NULL; } kfree(dev->video_mode.bulk_ctl.urb); kfree(dev->video_mode.bulk_ctl.transfer_buffer); dev->video_mode.bulk_ctl.urb = NULL; dev->video_mode.bulk_ctl.transfer_buffer = NULL; dev->video_mode.bulk_ctl.num_bufs = 0; if (dev->mode_tv == 0) cx231xx_capture_start(dev, 0, Raw_Video); else cx231xx_capture_start(dev, 0, TS1_serial_mode); } EXPORT_SYMBOL_GPL(cx231xx_uninit_bulk); /* * Allocate URBs and start IRQ */ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, int num_bufs, int max_pkt_size, int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)) { struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; int i; int sb_size, pipe; struct urb *urb; int j, k; int rc; /* De-allocates all pending stuff */ cx231xx_uninit_isoc(dev); dma_q->p_left_data = kzalloc(4096, GFP_KERNEL); if (dma_q->p_left_data == NULL) { cx231xx_info("out of mem\n"); return -ENOMEM; } dev->video_mode.isoc_ctl.isoc_copy = isoc_copy; dev->video_mode.isoc_ctl.num_bufs = num_bufs; dma_q->pos = 0; dma_q->is_partial_line = 0; dma_q->last_sav = 0; dma_q->current_field = -1; dma_q->field1_done = 0; dma_q->lines_per_field = dev->height / 2; dma_q->bytes_left_in_line = dev->width << 1; dma_q->lines_completed = 0; dma_q->mpeg_buffer_done = 0; dma_q->left_data_count = 0; dma_q->mpeg_buffer_completed = 0; dma_q->add_ps_package_head = CX231XX_NEED_ADD_PS_PACKAGE_HEAD; dma_q->ps_head[0] = 0x00; dma_q->ps_head[1] = 0x00; dma_q->ps_head[2] = 0x01; dma_q->ps_head[3] = 0xBA; for (i = 0; i < 8; i++) dma_q->partial_buf[i] = 0; dev->video_mode.isoc_ctl.urb = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.isoc_ctl.urb) { cx231xx_errdev("cannot alloc memory for usb buffers\n"); return -ENOMEM; } dev->video_mode.isoc_ctl.transfer_buffer = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.isoc_ctl.transfer_buffer) { cx231xx_errdev("cannot allocate memory for usbtransfer\n"); kfree(dev->video_mode.isoc_ctl.urb); return -ENOMEM; } dev->video_mode.isoc_ctl.max_pkt_size = max_pkt_size; dev->video_mode.isoc_ctl.buf = NULL; sb_size = max_packets * dev->video_mode.isoc_ctl.max_pkt_size; if (dev->mode_tv == 1) dev->video_mode.end_point_addr = 0x81; else dev->video_mode.end_point_addr = 0x84; /* allocate urbs and transfer buffers */ for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { urb = usb_alloc_urb(max_packets, GFP_KERNEL); if (!urb) { cx231xx_err("cannot alloc isoc_ctl.urb %i\n", i); cx231xx_uninit_isoc(dev); return -ENOMEM; } dev->video_mode.isoc_ctl.urb[i] = urb; dev->video_mode.isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, &urb->transfer_dma); if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { cx231xx_err("unable to allocate %i bytes for transfer" " buffer %i%s\n", sb_size, i, in_interrupt() ? " while in int" : ""); cx231xx_uninit_isoc(dev); return -ENOMEM; } memset(dev->video_mode.isoc_ctl.transfer_buffer[i], 0, sb_size); pipe = usb_rcvisocpipe(dev->udev, dev->video_mode.end_point_addr); usb_fill_int_urb(urb, dev->udev, pipe, dev->video_mode.isoc_ctl.transfer_buffer[i], sb_size, cx231xx_isoc_irq_callback, dma_q, 1); urb->number_of_packets = max_packets; urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; k = 0; for (j = 0; j < max_packets; j++) { urb->iso_frame_desc[j].offset = k; urb->iso_frame_desc[j].length = dev->video_mode.isoc_ctl.max_pkt_size; k += dev->video_mode.isoc_ctl.max_pkt_size; } } init_waitqueue_head(&dma_q->wq); /* submit urbs and enables IRQ */ for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], GFP_ATOMIC); if (rc) { cx231xx_err("submit of urb %i failed (error=%i)\n", i, rc); cx231xx_uninit_isoc(dev); return rc; } } if (dev->mode_tv == 0) cx231xx_capture_start(dev, 1, Raw_Video); else cx231xx_capture_start(dev, 1, TS1_serial_mode); return 0; } EXPORT_SYMBOL_GPL(cx231xx_init_isoc); /* * Allocate URBs and start IRQ */ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, int num_bufs, int max_pkt_size, int (*bulk_copy) (struct cx231xx *dev, struct urb *urb)) { struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; int i; int sb_size, pipe; struct urb *urb; int rc; dev->video_input = dev->video_input > 2 ? 2 : dev->video_input; cx231xx_coredbg("Setting Video mux to %d\n", dev->video_input); video_mux(dev, dev->video_input); /* De-allocates all pending stuff */ cx231xx_uninit_bulk(dev); dev->video_mode.bulk_ctl.bulk_copy = bulk_copy; dev->video_mode.bulk_ctl.num_bufs = num_bufs; dma_q->pos = 0; dma_q->is_partial_line = 0; dma_q->last_sav = 0; dma_q->current_field = -1; dma_q->field1_done = 0; dma_q->lines_per_field = dev->height / 2; dma_q->bytes_left_in_line = dev->width << 1; dma_q->lines_completed = 0; dma_q->mpeg_buffer_done = 0; dma_q->left_data_count = 0; dma_q->mpeg_buffer_completed = 0; dma_q->ps_head[0] = 0x00; dma_q->ps_head[1] = 0x00; dma_q->ps_head[2] = 0x01; dma_q->ps_head[3] = 0xBA; for (i = 0; i < 8; i++) dma_q->partial_buf[i] = 0; dev->video_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.bulk_ctl.urb) { cx231xx_errdev("cannot alloc memory for usb buffers\n"); return -ENOMEM; } dev->video_mode.bulk_ctl.transfer_buffer = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.bulk_ctl.transfer_buffer) { cx231xx_errdev("cannot allocate memory for usbtransfer\n"); kfree(dev->video_mode.bulk_ctl.urb); return -ENOMEM; } dev->video_mode.bulk_ctl.max_pkt_size = max_pkt_size; dev->video_mode.bulk_ctl.buf = NULL; sb_size = max_packets * dev->video_mode.bulk_ctl.max_pkt_size; if (dev->mode_tv == 1) dev->video_mode.end_point_addr = 0x81; else dev->video_mode.end_point_addr = 0x84; /* allocate urbs and transfer buffers */ for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i); cx231xx_uninit_bulk(dev); return -ENOMEM; } dev->video_mode.bulk_ctl.urb[i] = urb; urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; dev->video_mode.bulk_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, &urb->transfer_dma); if (!dev->video_mode.bulk_ctl.transfer_buffer[i]) { cx231xx_err("unable to allocate %i bytes for transfer" " buffer %i%s\n", sb_size, i, in_interrupt() ? " while in int" : ""); cx231xx_uninit_bulk(dev); return -ENOMEM; } memset(dev->video_mode.bulk_ctl.transfer_buffer[i], 0, sb_size); pipe = usb_rcvbulkpipe(dev->udev, dev->video_mode.end_point_addr); usb_fill_bulk_urb(urb, dev->udev, pipe, dev->video_mode.bulk_ctl.transfer_buffer[i], sb_size, cx231xx_bulk_irq_callback, dma_q); } init_waitqueue_head(&dma_q->wq); /* submit urbs and enables IRQ */ for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { rc = usb_submit_urb(dev->video_mode.bulk_ctl.urb[i], GFP_ATOMIC); if (rc) { cx231xx_err("submit of urb %i failed (error=%i)\n", i, rc); cx231xx_uninit_bulk(dev); return rc; } } if (dev->mode_tv == 0) cx231xx_capture_start(dev, 1, Raw_Video); else cx231xx_capture_start(dev, 1, TS1_serial_mode); return 0; } EXPORT_SYMBOL_GPL(cx231xx_init_bulk); void cx231xx_stop_TS1(struct cx231xx *dev) { u8 val[4] = { 0, 0, 0, 0 }; val[0] = 0x00; val[1] = 0x03; val[2] = 0x00; val[3] = 0x00; cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, TS_MODE_REG, val, 4); val[0] = 0x00; val[1] = 0x70; val[2] = 0x04; val[3] = 0x00; cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, TS1_CFG_REG, val, 4); } /* EXPORT_SYMBOL_GPL(cx231xx_stop_TS1); */ void cx231xx_start_TS1(struct cx231xx *dev) { u8 val[4] = { 0, 0, 0, 0 }; val[0] = 0x03; val[1] = 0x03; val[2] = 0x00; val[3] = 0x00; cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, TS_MODE_REG, val, 4); val[0] = 0x04; val[1] = 0xA3; val[2] = 0x3B; val[3] = 0x00; cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, TS1_CFG_REG, val, 4); } /* EXPORT_SYMBOL_GPL(cx231xx_start_TS1); */ /***************************************************************** * Device Init/UnInit functions * ******************************************************************/ int cx231xx_dev_init(struct cx231xx *dev) { int errCode = 0; /* Initialize I2C bus */ /* External Master 1 Bus */ dev->i2c_bus[0].nr = 0; dev->i2c_bus[0].dev = dev; dev->i2c_bus[0].i2c_period = I2C_SPEED_100K; /* 100 KHz */ dev->i2c_bus[0].i2c_nostop = 0; dev->i2c_bus[0].i2c_reserve = 0; /* External Master 2 Bus */ dev->i2c_bus[1].nr = 1; dev->i2c_bus[1].dev = dev; dev->i2c_bus[1].i2c_period = I2C_SPEED_100K; /* 100 KHz */ dev->i2c_bus[1].i2c_nostop = 0; dev->i2c_bus[1].i2c_reserve = 0; /* Internal Master 3 Bus */ dev->i2c_bus[2].nr = 2; dev->i2c_bus[2].dev = dev; dev->i2c_bus[2].i2c_period = I2C_SPEED_100K; /* 100kHz */ dev->i2c_bus[2].i2c_nostop = 0; dev->i2c_bus[2].i2c_reserve = 0; /* register I2C buses */ cx231xx_i2c_register(&dev->i2c_bus[0]); cx231xx_i2c_register(&dev->i2c_bus[1]); cx231xx_i2c_register(&dev->i2c_bus[2]); /* init hardware */ /* Note : with out calling set power mode function, afe can not be set up correctly */ if (dev->board.external_av) { errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ENXTERNAL_AV); if (errCode < 0) { cx231xx_errdev ("%s: Failed to set Power - errCode [%d]!\n", __func__, errCode); return errCode; } } else { errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); if (errCode < 0) { cx231xx_errdev ("%s: Failed to set Power - errCode [%d]!\n", __func__, errCode); return errCode; } } /* reset the Tuner, if it is a Xceive tuner */ if ((dev->board.tuner_type == TUNER_XC5000) || (dev->board.tuner_type == TUNER_XC2028)) cx231xx_gpio_set(dev, dev->board.tuner_gpio); /* initialize Colibri block */ errCode = cx231xx_afe_init_super_block(dev, 0x23c); if (errCode < 0) { cx231xx_errdev ("%s: cx231xx_afe init super block - errCode [%d]!\n", __func__, errCode); return errCode; } errCode = cx231xx_afe_init_channels(dev); if (errCode < 0) { cx231xx_errdev ("%s: cx231xx_afe init channels - errCode [%d]!\n", __func__, errCode); return errCode; } /* Set DIF in By pass mode */ errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); if (errCode < 0) { cx231xx_errdev ("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", __func__, errCode); return errCode; } /* I2S block related functions */ errCode = cx231xx_i2s_blk_initialize(dev); if (errCode < 0) { cx231xx_errdev ("%s: cx231xx_i2s block initialize - errCode [%d]!\n", __func__, errCode); return errCode; } /* init control pins */ errCode = cx231xx_init_ctrl_pin_status(dev); if (errCode < 0) { cx231xx_errdev("%s: cx231xx_init ctrl pins - errCode [%d]!\n", __func__, errCode); return errCode; } /* set AGC mode to Analog */ switch (dev->model) { case CX231XX_BOARD_CNXT_CARRAERA: case CX231XX_BOARD_CNXT_RDE_250: case CX231XX_BOARD_CNXT_SHELBY: case CX231XX_BOARD_CNXT_RDU_250: errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); break; case CX231XX_BOARD_CNXT_RDE_253S: case CX231XX_BOARD_CNXT_RDU_253S: case CX231XX_BOARD_HAUPPAUGE_EXETER: case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); break; default: break; } if (errCode < 0) { cx231xx_errdev ("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", __func__, errCode); return errCode; } /* set all alternate settings to zero initially */ cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0); cx231xx_set_alt_setting(dev, INDEX_VANC, 0); cx231xx_set_alt_setting(dev, INDEX_HANC, 0); if (dev->board.has_dvb) cx231xx_set_alt_setting(dev, INDEX_TS1, 0); /* set the I2C master port to 3 on channel 1 */ errCode = cx231xx_enable_i2c_port_3(dev, true); return errCode; } EXPORT_SYMBOL_GPL(cx231xx_dev_init); void cx231xx_dev_uninit(struct cx231xx *dev) { /* Un Initialize I2C bus */ cx231xx_i2c_unregister(&dev->i2c_bus[2]); cx231xx_i2c_unregister(&dev->i2c_bus[1]); cx231xx_i2c_unregister(&dev->i2c_bus[0]); } EXPORT_SYMBOL_GPL(cx231xx_dev_uninit); /***************************************************************** * G P I O related functions * ******************************************************************/ int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val, u8 len, u8 request, u8 direction) { int status = 0; struct VENDOR_REQUEST_IN ven_req; /* Set wValue */ ven_req.wValue = (u16) (gpio_bit >> 16 & 0xffff); /* set request */ if (!request) { if (direction) ven_req.bRequest = VRT_GET_GPIO; /* 0x8 gpio */ else ven_req.bRequest = VRT_SET_GPIO; /* 0x9 gpio */ } else { if (direction) ven_req.bRequest = VRT_GET_GPIE; /* 0xa gpie */ else ven_req.bRequest = VRT_SET_GPIE; /* 0xb gpie */ } /* set index value */ ven_req.wIndex = (u16) (gpio_bit & 0xffff); /* set wLength value */ ven_req.wLength = len; /* set bData value */ ven_req.bData = 0; /* set the buffer for read / write */ ven_req.pBuff = gpio_val; /* set the direction */ if (direction) { ven_req.direction = USB_DIR_IN; memset(ven_req.pBuff, 0x00, ven_req.wLength); } else ven_req.direction = USB_DIR_OUT; /* call common vendor command request */ status = cx231xx_send_vendor_cmd(dev, &ven_req); if (status < 0) { cx231xx_info ("UsbInterface::sendCommand, failed with status -%d\n", status); } return status; } EXPORT_SYMBOL_GPL(cx231xx_send_gpio_cmd); /***************************************************************** * C O N T R O L - Register R E A D / W R I T E functions * *****************************************************************/ int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode) { u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; u32 tmp = 0; int status = 0; status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, address, value, 4); if (status < 0) return status; tmp = le32_to_cpu(*((u32 *) value)); tmp |= mode; value[0] = (u8) tmp; value[1] = (u8) (tmp >> 8); value[2] = (u8) (tmp >> 16); value[3] = (u8) (tmp >> 24); status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, address, value, 4); return status; } /***************************************************************** * I 2 C Internal C O N T R O L functions * *****************************************************************/ int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, u8 saddr_len, u32 *data, u8 data_len, int master) { int status = 0; struct cx231xx_i2c_xfer_data req_data; u8 value[64] = "0"; if (saddr_len == 0) saddr = 0; else if (saddr_len == 1) saddr &= 0xff; /* prepare xfer_data struct */ req_data.dev_addr = dev_addr >> 1; req_data.direction = I2C_M_RD; req_data.saddr_len = saddr_len; req_data.saddr_dat = saddr; req_data.buf_size = data_len; req_data.p_buffer = (u8 *) value; /* usb send command */ if (master == 0) status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); else if (master == 1) status = dev->cx231xx_send_usb_command(&dev->i2c_bus[1], &req_data); else if (master == 2) status = dev->cx231xx_send_usb_command(&dev->i2c_bus[2], &req_data); if (status >= 0) { /* Copy the data read back to main buffer */ if (data_len == 1) *data = value[0]; else if (data_len == 4) *data = value[0] | value[1] << 8 | value[2] << 16 | value[3] << 24; else if (data_len > 4) *data = value[saddr]; } return status; } int cx231xx_write_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, u8 saddr_len, u32 data, u8 data_len, int master) { int status = 0; u8 value[4] = { 0, 0, 0, 0 }; struct cx231xx_i2c_xfer_data req_data; value[0] = (u8) data; value[1] = (u8) (data >> 8); value[2] = (u8) (data >> 16); value[3] = (u8) (data >> 24); if (saddr_len == 0) saddr = 0; else if (saddr_len == 1) saddr &= 0xff; /* prepare xfer_data struct */ req_data.dev_addr = dev_addr >> 1; req_data.direction = 0; req_data.saddr_len = saddr_len; req_data.saddr_dat = saddr; req_data.buf_size = data_len; req_data.p_buffer = value; /* usb send command */ if (master == 0) status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); else if (master == 1) status = dev->cx231xx_send_usb_command(&dev->i2c_bus[1], &req_data); else if (master == 2) status = dev->cx231xx_send_usb_command(&dev->i2c_bus[2], &req_data); return status; } int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, u8 saddr_len, u32 *data, u8 data_len) { int status = 0; struct cx231xx_i2c_xfer_data req_data; u8 value[4] = { 0, 0, 0, 0 }; if (saddr_len == 0) saddr = 0; else if (saddr_len == 1) saddr &= 0xff; /* prepare xfer_data struct */ req_data.dev_addr = dev_addr >> 1; req_data.direction = I2C_M_RD; req_data.saddr_len = saddr_len; req_data.saddr_dat = saddr; req_data.buf_size = data_len; req_data.p_buffer = (u8 *) value; /* usb send command */ status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); if (status >= 0) { /* Copy the data read back to main buffer */ if (data_len == 1) *data = value[0]; else *data = value[0] | value[1] << 8 | value[2] << 16 | value[3] << 24; } return status; } int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, u8 saddr_len, u32 data, u8 data_len) { int status = 0; u8 value[4] = { 0, 0, 0, 0 }; struct cx231xx_i2c_xfer_data req_data; value[0] = (u8) data; value[1] = (u8) (data >> 8); value[2] = (u8) (data >> 16); value[3] = (u8) (data >> 24); if (saddr_len == 0) saddr = 0; else if (saddr_len == 1) saddr &= 0xff; /* prepare xfer_data struct */ req_data.dev_addr = dev_addr >> 1; req_data.direction = 0; req_data.saddr_len = saddr_len; req_data.saddr_dat = saddr; req_data.buf_size = data_len; req_data.p_buffer = value; /* usb send command */ status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); return status; } int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, u16 register_address, u8 bit_start, u8 bit_end, u32 value) { int status = 0; u32 tmp; u32 mask = 0; int i; if (bit_start > (size - 1) || bit_end > (size - 1)) return -1; if (size == 8) { status = cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, &tmp, 1); } else { status = cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, &tmp, 4); } if (status < 0) return status; mask = 1 << bit_end; for (i = bit_end; i > bit_start && i > 0; i--) mask = mask + (1 << (i - 1)); value <<= bit_start; if (size == 8) { tmp &= ~mask; tmp |= value; tmp &= 0xff; status = cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, tmp, 1); } else { tmp &= ~mask; tmp |= value; status = cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, tmp, 4); } return status; } int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, u16 saddr, u32 mask, u32 value) { u32 temp; int status = 0; status = cx231xx_read_i2c_data(dev, dev_addr, saddr, 2, &temp, 4); if (status < 0) return status; temp &= ~mask; temp |= value; status = cx231xx_write_i2c_data(dev, dev_addr, saddr, 2, temp, 4); return status; } u32 cx231xx_set_field(u32 field_mask, u32 data) { u32 temp; for (temp = field_mask; (temp & 1) == 0; temp >>= 1) data <<= 1; return data; }
mrimp/N910TUVU1ANIH_kernel
drivers/media/usb/cx231xx/cx231xx-core.c
C
gpl-2.0
44,800
/* mac8390.c: New driver for 8390-based Nubus (or Nubus-alike) Ethernet cards on Linux */ /* Based on the former daynaport.c driver, by Alan Cox. Some code taken from or inspired by skeleton.c by Donald Becker, acenic.c by Jes Sorensen, and ne2k-pci.c by Donald Becker and Paul Gortmaker. This software may be used and distributed according to the terms of the GNU Public License, incorporated herein by reference. */ /* 2000-02-28: support added for Dayna and Kinetics cards by A.G.deWijn@phys.uu.nl */ /* 2000-04-04: support added for Dayna2 by bart@etpmod.phys.tue.nl */ /* 2001-04-18: support for DaynaPort E/LC-M by rayk@knightsmanor.org */ /* 2001-05-15: support for Cabletron ported from old daynaport driver * and fixed access to Sonic Sys card which masquerades as a Farallon * by rayk@knightsmanor.org */ /* 2002-12-30: Try to support more cards, some clues from NetBSD driver */ /* 2003-12-26: Make sure Asante cards always work. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/fcntl.h> #include <linux/interrupt.h> #include <linux/ptrace.h> #include <linux/ioport.h> #include <linux/nubus.h> #include <linux/in.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/bitops.h> #include <linux/io.h> #include <asm/system.h> #include <asm/dma.h> #include <asm/hwtest.h> #include <asm/macints.h> static char version[] = "v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n"; #define EI_SHIFT(x) (ei_local->reg_offset[x]) #define ei_inb(port) in_8(port) #define ei_outb(val, port) out_8(port, val) #define ei_inb_p(port) in_8(port) #define ei_outb_p(val, port) out_8(port, val) #include "lib8390.c" #define WD_START_PG 0x00 /* First page of TX buffer */ #define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */ #define CABLETRON_RX_STOP_PG 0x30 /* Last page +1 of RX ring */ #define CABLETRON_TX_START_PG CABLETRON_RX_STOP_PG /* First page of TX buffer */ /* * Unfortunately it seems we have to hardcode these for the moment * Shouldn't the card know about this? * Does anyone know where to read it off the card? * Do we trust the data provided by the card? */ #define DAYNA_8390_BASE 0x80000 #define DAYNA_8390_MEM 0x00000 #define CABLETRON_8390_BASE 0x90000 #define CABLETRON_8390_MEM 0x00000 #define INTERLAN_8390_BASE 0xE0000 #define INTERLAN_8390_MEM 0xD0000 enum mac8390_type { MAC8390_NONE = -1, MAC8390_APPLE, MAC8390_ASANTE, MAC8390_FARALLON, MAC8390_CABLETRON, MAC8390_DAYNA, MAC8390_INTERLAN, MAC8390_KINETICS, }; static const char *cardname[] = { "apple", "asante", "farallon", "cabletron", "dayna", "interlan", "kinetics", }; static const int word16[] = { 1, /* apple */ 1, /* asante */ 1, /* farallon */ 1, /* cabletron */ 0, /* dayna */ 1, /* interlan */ 0, /* kinetics */ }; /* on which cards do we use NuBus resources? */ static const int useresources[] = { 1, /* apple */ 1, /* asante */ 1, /* farallon */ 0, /* cabletron */ 0, /* dayna */ 0, /* interlan */ 0, /* kinetics */ }; enum mac8390_access { ACCESS_UNKNOWN = 0, ACCESS_32, ACCESS_16, }; extern int mac8390_memtest(struct net_device *dev); static int mac8390_initdev(struct net_device *dev, struct nubus_dev *ndev, enum mac8390_type type); static int mac8390_open(struct net_device *dev); static int mac8390_close(struct net_device *dev); static void mac8390_no_reset(struct net_device *dev); static void interlan_reset(struct net_device *dev); /* Sane (32-bit chunk memory read/write) - Some Farallon and Apple do this*/ static void sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page); static void sane_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset); static void sane_block_output(struct net_device *dev, int count, const unsigned char *buf, const int start_page); /* dayna_memcpy to and from card */ static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, int count); static void dayna_memcpy_tocard(struct net_device *dev, int to, const void *from, int count); /* Dayna - Dayna/Kinetics use this */ static void dayna_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page); static void dayna_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset); static void dayna_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page); #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) #define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c)) /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ static void slow_sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page); static void slow_sane_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset); static void slow_sane_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page); static void word_memcpy_tocard(unsigned long tp, const void *fp, int count); static void word_memcpy_fromcard(void *tp, unsigned long fp, int count); static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev) { switch (dev->dr_sw) { case NUBUS_DRSW_3COM: switch (dev->dr_hw) { case NUBUS_DRHW_APPLE_SONIC_NB: case NUBUS_DRHW_APPLE_SONIC_LC: case NUBUS_DRHW_SONNET: return MAC8390_NONE; break; default: return MAC8390_APPLE; break; } break; case NUBUS_DRSW_APPLE: switch (dev->dr_hw) { case NUBUS_DRHW_ASANTE_LC: return MAC8390_NONE; break; case NUBUS_DRHW_CABLETRON: return MAC8390_CABLETRON; break; default: return MAC8390_APPLE; break; } break; case NUBUS_DRSW_ASANTE: return MAC8390_ASANTE; break; case NUBUS_DRSW_TECHWORKS: case NUBUS_DRSW_DAYNA2: case NUBUS_DRSW_DAYNA_LC: if (dev->dr_hw == NUBUS_DRHW_CABLETRON) return MAC8390_CABLETRON; else return MAC8390_APPLE; break; case NUBUS_DRSW_FARALLON: return MAC8390_FARALLON; break; case NUBUS_DRSW_KINETICS: switch (dev->dr_hw) { case NUBUS_DRHW_INTERLAN: return MAC8390_INTERLAN; break; default: return MAC8390_KINETICS; break; } break; case NUBUS_DRSW_DAYNA: /* * These correspond to Dayna Sonic cards * which use the macsonic driver */ if (dev->dr_hw == NUBUS_DRHW_SMC9194 || dev->dr_hw == NUBUS_DRHW_INTERLAN) return MAC8390_NONE; else return MAC8390_DAYNA; break; } return MAC8390_NONE; } static enum mac8390_access __init mac8390_testio(volatile unsigned long membase) { unsigned long outdata = 0xA5A0B5B0; unsigned long indata = 0x00000000; /* Try writing 32 bits */ memcpy_toio(membase, &outdata, 4); /* Now compare them */ if (memcmp_withio(&outdata, membase, 4) == 0) return ACCESS_32; /* Write 16 bit output */ word_memcpy_tocard(membase, &outdata, 4); /* Now read it back */ word_memcpy_fromcard(&indata, membase, 4); if (outdata == indata) return ACCESS_16; return ACCESS_UNKNOWN; } static int __init mac8390_memsize(unsigned long membase) { unsigned long flags; int i, j; local_irq_save(flags); /* Check up to 32K in 4K increments */ for (i = 0; i < 8; i++) { volatile unsigned short *m = (unsigned short *)(membase + (i * 0x1000)); /* Unwriteable - we have a fully decoded card and the RAM end located */ if (hwreg_present(m) == 0) break; /* write a distinctive byte */ *m = 0xA5A0 | i; /* check that we read back what we wrote */ if (*m != (0xA5A0 | i)) break; /* check for partial decode and wrap */ for (j = 0; j < i; j++) { volatile unsigned short *p = (unsigned short *)(membase + (j * 0x1000)); if (*p != (0xA5A0 | j)) break; } } local_irq_restore(flags); /* * in any case, we stopped once we tried one block too many, * or once we reached 32K */ return i * 0x1000; } static bool __init mac8390_init(struct net_device *dev, struct nubus_dev *ndev, enum mac8390_type cardtype) { struct nubus_dir dir; struct nubus_dirent ent; int offset; volatile unsigned short *i; printk_once(KERN_INFO pr_fmt("%s"), version); dev->irq = SLOT2IRQ(ndev->board->slot); /* This is getting to be a habit */ dev->base_addr = (ndev->board->slot_addr | ((ndev->board->slot & 0xf) << 20)); /* * Get some Nubus info - we will trust the card's idea * of where its memory and registers are. */ if (nubus_get_func_dir(ndev, &dir) == -1) { pr_err("%s: Unable to get Nubus functional directory for slot %X!\n", dev->name, ndev->board->slot); return false; } /* Get the MAC address */ if (nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent) == -1) { pr_info("%s: Couldn't get MAC address!\n", dev->name); return false; } nubus_get_rsrc_mem(dev->dev_addr, &ent, 6); if (useresources[cardtype] == 1) { nubus_rewinddir(&dir); if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS, &ent) == -1) { pr_err("%s: Memory offset resource for slot %X not found!\n", dev->name, ndev->board->slot); return false; } nubus_get_rsrc_mem(&offset, &ent, 4); dev->mem_start = dev->base_addr + offset; /* yes, this is how the Apple driver does it */ dev->base_addr = dev->mem_start + 0x10000; nubus_rewinddir(&dir); if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH, &ent) == -1) { pr_info("%s: Memory length resource for slot %X not found, probing\n", dev->name, ndev->board->slot); offset = mac8390_memsize(dev->mem_start); } else { nubus_get_rsrc_mem(&offset, &ent, 4); } dev->mem_end = dev->mem_start + offset; } else { switch (cardtype) { case MAC8390_KINETICS: case MAC8390_DAYNA: /* it's the same */ dev->base_addr = (int)(ndev->board->slot_addr + DAYNA_8390_BASE); dev->mem_start = (int)(ndev->board->slot_addr + DAYNA_8390_MEM); dev->mem_end = dev->mem_start + mac8390_memsize(dev->mem_start); break; case MAC8390_INTERLAN: dev->base_addr = (int)(ndev->board->slot_addr + INTERLAN_8390_BASE); dev->mem_start = (int)(ndev->board->slot_addr + INTERLAN_8390_MEM); dev->mem_end = dev->mem_start + mac8390_memsize(dev->mem_start); break; case MAC8390_CABLETRON: dev->base_addr = (int)(ndev->board->slot_addr + CABLETRON_8390_BASE); dev->mem_start = (int)(ndev->board->slot_addr + CABLETRON_8390_MEM); /* The base address is unreadable if 0x00 * has been written to the command register * Reset the chip by writing E8390_NODMA + * E8390_PAGE0 + E8390_STOP just to be * sure */ i = (void *)dev->base_addr; *i = 0x21; dev->mem_end = dev->mem_start + mac8390_memsize(dev->mem_start); break; default: pr_err("Card type %s is unsupported, sorry\n", ndev->board->name); return false; } } return true; } struct net_device * __init mac8390_probe(int unit) { struct net_device *dev; struct nubus_dev *ndev = NULL; int err = -ENODEV; static unsigned int slots; enum mac8390_type cardtype; /* probably should check for Nubus instead */ if (!MACH_IS_MAC) return ERR_PTR(-ENODEV); dev = ____alloc_ei_netdev(0); if (!dev) return ERR_PTR(-ENOMEM); if (unit >= 0) sprintf(dev->name, "eth%d", unit); while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET, ndev))) { /* Have we seen it already? */ if (slots & (1 << ndev->board->slot)) continue; slots |= 1 << ndev->board->slot; cardtype = mac8390_ident(ndev); if (cardtype == MAC8390_NONE) continue; if (!mac8390_init(dev, ndev, cardtype)) continue; /* Do the nasty 8390 stuff */ if (!mac8390_initdev(dev, ndev, cardtype)) break; } if (!ndev) goto out; err = register_netdev(dev); if (err) goto out; return dev; out: free_netdev(dev); return ERR_PTR(err); } #ifdef MODULE MODULE_AUTHOR("David Huggins-Daines <dhd@debian.org> and others"); MODULE_DESCRIPTION("Macintosh NS8390-based Nubus Ethernet driver"); MODULE_LICENSE("GPL"); /* overkill, of course */ static struct net_device *dev_mac8390[15]; int init_module(void) { int i; for (i = 0; i < 15; i++) { struct net_device *dev = mac8390_probe(-1); if (IS_ERR(dev)) break; dev_mac890[i] = dev; } if (!i) { pr_notice("No useable cards found, driver NOT installed.\n"); return -ENODEV; } return 0; } void cleanup_module(void) { int i; for (i = 0; i < 15; i++) { struct net_device *dev = dev_mac890[i]; if (dev) { unregister_netdev(dev); free_netdev(dev); } } } #endif /* MODULE */ static const struct net_device_ops mac8390_netdev_ops = { .ndo_open = mac8390_open, .ndo_stop = mac8390_close, .ndo_start_xmit = __ei_start_xmit, .ndo_tx_timeout = __ei_tx_timeout, .ndo_get_stats = __ei_get_stats, .ndo_set_multicast_list = __ei_set_multicast_list, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = eth_change_mtu, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = __ei_poll, #endif }; static int __init mac8390_initdev(struct net_device *dev, struct nubus_dev *ndev, enum mac8390_type type) { static u32 fwrd4_offsets[16] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60 }; static u32 back4_offsets[16] = { 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0 }; static u32 fwrd2_offsets[16] = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 }; int access_bitmode = 0; /* Now fill in our stuff */ dev->netdev_ops = &mac8390_netdev_ops; /* GAR, ei_status is actually a macro even though it looks global */ ei_status.name = cardname[type]; ei_status.word16 = word16[type]; /* Cabletron's TX/RX buffers are backwards */ if (type == MAC8390_CABLETRON) { ei_status.tx_start_page = CABLETRON_TX_START_PG; ei_status.rx_start_page = CABLETRON_RX_START_PG; ei_status.stop_page = CABLETRON_RX_STOP_PG; ei_status.rmem_start = dev->mem_start; ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256; } else { ei_status.tx_start_page = WD_START_PG; ei_status.rx_start_page = WD_START_PG + TX_PAGES; ei_status.stop_page = (dev->mem_end - dev->mem_start)/256; ei_status.rmem_start = dev->mem_start + TX_PAGES*256; ei_status.rmem_end = dev->mem_end; } /* Fill in model-specific information and functions */ switch (type) { case MAC8390_FARALLON: case MAC8390_APPLE: switch (mac8390_testio(dev->mem_start)) { case ACCESS_UNKNOWN: pr_err("Don't know how to access card memory!\n"); return -ENODEV; break; case ACCESS_16: /* 16 bit card, register map is reversed */ ei_status.reset_8390 = mac8390_no_reset; ei_status.block_input = slow_sane_block_input; ei_status.block_output = slow_sane_block_output; ei_status.get_8390_hdr = slow_sane_get_8390_hdr; ei_status.reg_offset = back4_offsets; break; case ACCESS_32: /* 32 bit card, register map is reversed */ ei_status.reset_8390 = mac8390_no_reset; ei_status.block_input = sane_block_input; ei_status.block_output = sane_block_output; ei_status.get_8390_hdr = sane_get_8390_hdr; ei_status.reg_offset = back4_offsets; access_bitmode = 1; break; } break; case MAC8390_ASANTE: /* Some Asante cards pass the 32 bit test * but overwrite system memory when run at 32 bit. * so we run them all at 16 bit. */ ei_status.reset_8390 = mac8390_no_reset; ei_status.block_input = slow_sane_block_input; ei_status.block_output = slow_sane_block_output; ei_status.get_8390_hdr = slow_sane_get_8390_hdr; ei_status.reg_offset = back4_offsets; break; case MAC8390_CABLETRON: /* 16 bit card, register map is short forward */ ei_status.reset_8390 = mac8390_no_reset; ei_status.block_input = slow_sane_block_input; ei_status.block_output = slow_sane_block_output; ei_status.get_8390_hdr = slow_sane_get_8390_hdr; ei_status.reg_offset = fwrd2_offsets; break; case MAC8390_DAYNA: case MAC8390_KINETICS: /* 16 bit memory, register map is forward */ /* dayna and similar */ ei_status.reset_8390 = mac8390_no_reset; ei_status.block_input = dayna_block_input; ei_status.block_output = dayna_block_output; ei_status.get_8390_hdr = dayna_get_8390_hdr; ei_status.reg_offset = fwrd4_offsets; break; case MAC8390_INTERLAN: /* 16 bit memory, register map is forward */ ei_status.reset_8390 = interlan_reset; ei_status.block_input = slow_sane_block_input; ei_status.block_output = slow_sane_block_output; ei_status.get_8390_hdr = slow_sane_get_8390_hdr; ei_status.reg_offset = fwrd4_offsets; break; default: pr_err("Card type %s is unsupported, sorry\n", ndev->board->name); return -ENODEV; } __NS8390_init(dev, 0); /* Good, done, now spit out some messages */ pr_info("%s: %s in slot %X (type %s)\n", dev->name, ndev->board->name, ndev->board->slot, cardname[type]); pr_info("MAC %pM IRQ %d, %d KB shared memory at %#lx, %d-bit access.\n", dev->dev_addr, dev->irq, (unsigned int)(dev->mem_end - dev->mem_start) >> 10, dev->mem_start, access_bitmode ? 32 : 16); return 0; } static int mac8390_open(struct net_device *dev) { int err; __ei_open(dev); err = request_irq(dev->irq, __ei_interrupt, 0, "8390 Ethernet", dev); if (err) pr_err("%s: unable to get IRQ %d\n", dev->name, dev->irq); return err; } static int mac8390_close(struct net_device *dev) { free_irq(dev->irq, dev); __ei_close(dev); return 0; } static void mac8390_no_reset(struct net_device *dev) { ei_status.txing = 0; if (ei_debug > 1) pr_info("reset not supported\n"); } static void interlan_reset(struct net_device *dev) { unsigned char *target = nubus_slot_addr(IRQ2SLOT(dev->irq)); if (ei_debug > 1) pr_info("Need to reset the NS8390 t=%lu...", jiffies); ei_status.txing = 0; target[0xC0000] = 0; if (ei_debug > 1) pr_cont("reset complete\n"); } /* dayna_memcpy_fromio/dayna_memcpy_toio */ /* directly from daynaport.c by Alan Cox */ static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, int count) { volatile unsigned char *ptr; unsigned char *target = to; from <<= 1; /* word, skip overhead */ ptr = (unsigned char *)(dev->mem_start+from); /* Leading byte? */ if (from & 2) { *target++ = ptr[-1]; ptr += 2; count--; } while (count >= 2) { *(unsigned short *)target = *(unsigned short volatile *)ptr; ptr += 4; /* skip cruft */ target += 2; count -= 2; } /* Trailing byte? */ if (count) *target = *ptr; } static void dayna_memcpy_tocard(struct net_device *dev, int to, const void *from, int count) { volatile unsigned short *ptr; const unsigned char *src = from; to <<= 1; /* word, skip overhead */ ptr = (unsigned short *)(dev->mem_start+to); /* Leading byte? */ if (to & 2) { /* avoid a byte write (stomps on other data) */ ptr[-1] = (ptr[-1]&0xFF00)|*src++; ptr++; count--; } while (count >= 2) { *ptr++ = *(unsigned short *)src; /* Copy and */ ptr++; /* skip cruft */ src += 2; count -= 2; } /* Trailing byte? */ if (count) { /* card doesn't like byte writes */ *ptr = (*ptr & 0x00FF) | (*src << 8); } } /* sane block input/output */ static void sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) { unsigned long hdr_start = (ring_page - WD_START_PG)<<8; memcpy_fromio(hdr, dev->mem_start + hdr_start, 4); /* Fix endianness */ hdr->count = swab16(hdr->count); } static void sane_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) { unsigned long xfer_base = ring_offset - (WD_START_PG<<8); unsigned long xfer_start = xfer_base + dev->mem_start; if (xfer_start + count > ei_status.rmem_end) { /* We must wrap the input move. */ int semi_count = ei_status.rmem_end - xfer_start; memcpy_fromio(skb->data, dev->mem_start + xfer_base, semi_count); count -= semi_count; memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count); } else { memcpy_fromio(skb->data, dev->mem_start + xfer_base, count); } } static void sane_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page) { long shmem = (start_page - WD_START_PG)<<8; memcpy_toio(dev->mem_start + shmem, buf, count); } /* dayna block input/output */ static void dayna_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) { unsigned long hdr_start = (ring_page - WD_START_PG)<<8; dayna_memcpy_fromcard(dev, hdr, hdr_start, 4); /* Fix endianness */ hdr->count = (hdr->count & 0xFF) << 8 | (hdr->count >> 8); } static void dayna_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) { unsigned long xfer_base = ring_offset - (WD_START_PG<<8); unsigned long xfer_start = xfer_base+dev->mem_start; /* Note the offset math is done in card memory space which is word per long onto our space. */ if (xfer_start + count > ei_status.rmem_end) { /* We must wrap the input move. */ int semi_count = ei_status.rmem_end - xfer_start; dayna_memcpy_fromcard(dev, skb->data, xfer_base, semi_count); count -= semi_count; dayna_memcpy_fromcard(dev, skb->data + semi_count, ei_status.rmem_start - dev->mem_start, count); } else { dayna_memcpy_fromcard(dev, skb->data, xfer_base, count); } } static void dayna_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page) { long shmem = (start_page - WD_START_PG)<<8; dayna_memcpy_tocard(dev, shmem, buf, count); } /* Cabletron block I/O */ static void slow_sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) { unsigned long hdr_start = (ring_page - WD_START_PG)<<8; word_memcpy_fromcard(hdr, dev->mem_start + hdr_start, 4); /* Register endianism - fix here rather than 8390.c */ hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8); } static void slow_sane_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) { unsigned long xfer_base = ring_offset - (WD_START_PG<<8); unsigned long xfer_start = xfer_base+dev->mem_start; if (xfer_start + count > ei_status.rmem_end) { /* We must wrap the input move. */ int semi_count = ei_status.rmem_end - xfer_start; word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base, semi_count); count -= semi_count; word_memcpy_fromcard(skb->data + semi_count, ei_status.rmem_start, count); } else { word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base, count); } } static void slow_sane_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page) { long shmem = (start_page - WD_START_PG)<<8; word_memcpy_tocard(dev->mem_start + shmem, buf, count); } static void word_memcpy_tocard(unsigned long tp, const void *fp, int count) { volatile unsigned short *to = (void *)tp; const unsigned short *from = fp; count++; count /= 2; while (count--) *to++ = *from++; } static void word_memcpy_fromcard(void *tp, unsigned long fp, int count) { unsigned short *to = tp; const volatile unsigned short *from = (const void *)fp; count++; count /= 2; while (count--) *to++ = *from++; }
XtheOne/enrc2b-3.1.10-42105bd
drivers/net/mac8390.c
C
gpl-2.0
23,770
/* Copyright (c) 2012, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * 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. */ #include <linux/init.h> #include <linux/module.h> #include <linux/device.h> #include <linux/platform_device.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> static int msm_dai_stub_set_channel_map(struct snd_soc_dai *dai, unsigned int tx_num, unsigned int *tx_slot, unsigned int rx_num, unsigned int *rx_slot) { pr_debug("%s:\n", __func__); return 0; } static struct snd_soc_dai_ops msm_dai_stub_ops = { .set_channel_map = msm_dai_stub_set_channel_map, }; static struct snd_soc_dai_driver msm_dai_stub_dai = { .playback = { .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels_min = 1, .channels_max = 2, .rate_min = 8000, .rate_max = 48000, }, .capture = { .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels_min = 1, .channels_max = 2, .rate_min = 8000, .rate_max = 48000, }, .ops = &msm_dai_stub_ops, }; static __devinit int msm_dai_stub_dev_probe(struct platform_device *pdev) { int rc = 0; dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); rc = snd_soc_register_dai(&pdev->dev, &msm_dai_stub_dai); return rc; } static __devexit int msm_dai_stub_dev_remove(struct platform_device *pdev) { pr_debug("%s:\n", __func__); snd_soc_unregister_dai(&pdev->dev); return 0; } static struct platform_driver msm_dai_stub_driver = { .probe = msm_dai_stub_dev_probe, .remove = msm_dai_stub_dev_remove, .driver = { .name = "msm-dai-stub", .owner = THIS_MODULE, }, }; static int __init msm_dai_stub_init(void) { pr_debug("%s:\n", __func__); return platform_driver_register(&msm_dai_stub_driver); } module_init(msm_dai_stub_init); static void __exit msm_dai_stub_exit(void) { pr_debug("%s:\n", __func__); platform_driver_unregister(&msm_dai_stub_driver); } module_exit(msm_dai_stub_exit); /* Module information */ MODULE_DESCRIPTION("MSM Stub DSP DAI driver"); MODULE_LICENSE("GPL v2");
CAF-victara/kernel_msm
sound/soc/msm/msm-dai-stub.c
C
gpl-2.0
2,554
/* ** ----------------------------------------------------------------------------- ** ** Perle Specialix driver for Linux ** Ported from existing RIO Driver for SCO sources. * * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. ** ** Module : riointr.c ** SID : 1.2 ** Last Modified : 11/6/98 10:33:44 ** Retrieved : 11/6/98 10:33:49 ** ** ident @(#)riointr.c 1.2 ** ** ----------------------------------------------------------------------------- */ #include <linux/module.h> #include <linux/errno.h> #include <linux/tty.h> #include <linux/tty_flip.h> #include <asm/io.h> #include <asm/system.h> #include <asm/string.h> #include <asm/uaccess.h> #include <linux/termios.h> #include <linux/serial.h> #include <linux/generic_serial.h> #include <linux/delay.h> #include "linux_compat.h" #include "rio_linux.h" #include "pkt.h" #include "daemon.h" #include "rio.h" #include "riospace.h" #include "cmdpkt.h" #include "map.h" #include "rup.h" #include "port.h" #include "riodrvr.h" #include "rioinfo.h" #include "func.h" #include "errors.h" #include "pci.h" #include "parmmap.h" #include "unixrup.h" #include "board.h" #include "host.h" #include "phb.h" #include "link.h" #include "cmdblk.h" #include "route.h" #include "cirrus.h" #include "rioioctl.h" static void RIOReceive(struct rio_info *, struct Port *); static char *firstchars(char *p, int nch) { static char buf[2][128]; static int t = 0; t = !t; memcpy(buf[t], p, nch); buf[t][nch] = 0; return buf[t]; } #define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) /* Enable and start the transmission of packets */ void RIOTxEnable(char *en) { struct Port *PortP; struct rio_info *p; struct tty_struct *tty; int c; struct PKT __iomem *PacketP; unsigned long flags; PortP = (struct Port *) en; p = (struct rio_info *) PortP->p; tty = PortP->gs.port.tty; rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt); if (!PortP->gs.xmit_cnt) return; /* This routine is an order of magnitude simpler than the specialix version. One of the disadvantages is that this version will send an incomplete packet (usually 64 bytes instead of 72) once for every 4k worth of data. Let's just say that this won't influence performance significantly..... */ rio_spin_lock_irqsave(&PortP->portSem, flags); while (can_add_transmit(&PacketP, PortP)) { c = PortP->gs.xmit_cnt; if (c > PKT_MAX_DATA_LEN) c = PKT_MAX_DATA_LEN; /* Don't copy past the end of the source buffer */ if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail) c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail; { int t; t = (c > 10) ? 10 : c; rio_dprintk(RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n", PortP->PortNum, c, firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail, t), firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail + c - t, t)); } /* If for one reason or another, we can't copy more data, we're done! */ if (c == 0) break; rio_memcpy_toio(PortP->HostP->Caddr, PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); /* udelay (1); */ writeb(c, &(PacketP->len)); if (!(PortP->State & RIO_DELETED)) { add_transmit(PortP); /* ** Count chars tx'd for port statistics reporting */ if (PortP->statsGather) PortP->txchars += c; } PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE - 1); PortP->gs.xmit_cnt -= c; } rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) tty_wakeup(PortP->gs.port.tty); } /* ** RIO Host Service routine. Does all the work traditionally associated with an ** interrupt. */ static int RupIntr; static int RxIntr; static int TxIntr; void RIOServiceHost(struct rio_info *p, struct Host *HostP) { rio_spin_lock(&HostP->HostLock); if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { static int t = 0; rio_spin_unlock(&HostP->HostLock); if ((t++ % 200) == 0) rio_dprintk(RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int) HostP->Flags); return; } rio_spin_unlock(&HostP->HostLock); if (readw(&HostP->ParmMapP->rup_intr)) { writew(0, &HostP->ParmMapP->rup_intr); p->RIORupCount++; RupIntr++; rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts); RIOPollHostCommands(p, HostP); } if (readw(&HostP->ParmMapP->rx_intr)) { int port; writew(0, &HostP->ParmMapP->rx_intr); p->RIORxCount++; RxIntr++; rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts); /* ** Loop through every port. If the port is mapped into ** the system ( i.e. has /dev/ttyXXXX associated ) then it is ** worth checking. If the port isn't open, grab any packets ** hanging on its receive queue and stuff them on the free ** list; check for commands on the way. */ for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { struct Port *PortP = p->RIOPortp[port]; struct tty_struct *ttyP; struct PKT __iomem *PacketP; /* ** not mapped in - most of the RIOPortp[] information ** has not been set up! ** Optimise: ports come in bundles of eight. */ if (!PortP->Mapped) { port += 7; continue; /* with the next port */ } /* ** If the host board isn't THIS host board, check the next one. ** optimise: ports come in bundles of eight. */ if (PortP->HostP != HostP) { port += 7; continue; } /* ** Let us see - is the port open? If not, then don't service it. */ if (!(PortP->PortState & PORT_ISOPEN)) { continue; } /* ** find corresponding tty structure. The process of mapping ** the ports puts these here. */ ttyP = PortP->gs.port.tty; /* ** Lock the port before we begin working on it. */ rio_spin_lock(&PortP->portSem); /* ** Process received data if there is any. */ if (can_remove_receive(&PacketP, PortP)) RIOReceive(p, PortP); /* ** If there is no data left to be read from the port, and ** it's handshake bit is set, then we must clear the handshake, ** so that that downstream RTA is re-enabled. */ if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { /* ** MAGIC! ( Basically, handshake the RX buffer, so that ** the RTAs upstream can be re-enabled. ) */ rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake); } rio_spin_unlock(&PortP->portSem); } } if (readw(&HostP->ParmMapP->tx_intr)) { int port; writew(0, &HostP->ParmMapP->tx_intr); p->RIOTxCount++; TxIntr++; rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts); /* ** Loop through every port. ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX ** associated ) then it is worth checking. */ for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { struct Port *PortP = p->RIOPortp[port]; struct tty_struct *ttyP; struct PKT __iomem *PacketP; /* ** not mapped in - most of the RIOPortp[] information ** has not been set up! */ if (!PortP->Mapped) { port += 7; continue; /* with the next port */ } /* ** If the host board isn't running, then its data structures ** are no use to us - continue quietly. */ if (PortP->HostP != HostP) { port += 7; continue; /* with the next port */ } /* ** Let us see - is the port open? If not, then don't service it. */ if (!(PortP->PortState & PORT_ISOPEN)) { continue; } rio_dprintk(RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port); /* ** Lock the port before we begin working on it. */ rio_spin_lock(&PortP->portSem); /* ** If we can't add anything to the transmit queue, then ** we need do none of this processing. */ if (!can_add_transmit(&PacketP, PortP)) { rio_dprintk(RIO_DEBUG_INTR, "Can't add to port, so skipping.\n"); rio_spin_unlock(&PortP->portSem); continue; } /* ** find corresponding tty structure. The process of mapping ** the ports puts these here. */ ttyP = PortP->gs.port.tty; /* If ttyP is NULL, the port is getting closed. Forget about it. */ if (!ttyP) { rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n"); rio_spin_unlock(&PortP->portSem); continue; } /* ** If there is more room available we start up the transmit ** data process again. This can be direct I/O, if the cookmode ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch ** characters via the line discipline. We must always call ** the line discipline, ** so that user input characters can be echoed correctly. ** ** ++++ Update +++++ ** With the advent of double buffering, we now see if ** TxBufferOut-In is non-zero. If so, then we copy a packet ** to the output place, and set it going. If this empties ** the buffer, then we must issue a wakeup( ) on OUT. ** If it frees space in the buffer then we must issue ** a wakeup( ) on IN. ** ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we ** have to send a WFLUSH command down the PHB, to mark the ** end point of a WFLUSH. We also need to clear out any ** data from the double buffer! ( note that WflushFlag is a ** *count* of the number of WFLUSH commands outstanding! ) ** ** ++++ And there's more! ** If an RTA is powered off, then on again, and rebooted, ** whilst it has ports open, then we need to re-open the ports. ** ( reasonable enough ). We can't do this when we spot the ** re-boot, in interrupt time, because the queue is probably ** full. So, when we come in here, we need to test if any ** ports are in this condition, and re-open the port before ** we try to send any more data to it. Now, the re-booted ** RTA will be discarding packets from the PHB until it ** receives this open packet, but don't worry tooo much ** about that. The one thing that is interesting is the ** combination of this effect and the WFLUSH effect! */ /* For now don't handle RTA reboots. -- REW. Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ if (PortP->MagicFlags) { if (PortP->MagicFlags & MAGIC_REBOOT) { /* ** well, the RTA has been rebooted, and there is room ** on its queue to add the open packet that is required. ** ** The messy part of this line is trying to decide if ** we need to call the Param function as a tty or as ** a modem. ** DONT USE CLOCAL AS A TEST FOR THIS! ** ** If we can't param the port, then move on to the ** next port. */ PortP->InUse = NOT_INUSE; rio_spin_unlock(&PortP->portSem); if (RIOParam(PortP, RIOC_OPEN, ((PortP->Cor2Copy & (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) == (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) continue; /* with next port */ rio_spin_lock(&PortP->portSem); PortP->MagicFlags &= ~MAGIC_REBOOT; } /* ** As mentioned above, this is a tacky hack to cope ** with WFLUSH */ if (PortP->WflushFlag) { rio_dprintk(RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n"); if (PortP->InUse) rio_dprintk(RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n"); } while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) { int p; struct PktCmd __iomem *PktCmdP; rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n"); /* ** make it look just like a WFLUSH command */ PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0]; writeb(RIOC_WFLUSH, &PktCmdP->Command); p = PortP->HostPort % (u16) PORTS_PER_RTA; /* ** If second block of ports for 16 port RTA, add 8 ** to index 8-15. */ if (PortP->SecondBlock) p += PORTS_PER_RTA; writeb(p, &PktCmdP->PhbNum); /* ** to make debuggery easier */ writeb('W', &PacketP->data[2]); writeb('F', &PacketP->data[3]); writeb('L', &PacketP->data[4]); writeb('U', &PacketP->data[5]); writeb('S', &PacketP->data[6]); writeb('H', &PacketP->data[7]); writeb(' ', &PacketP->data[8]); writeb('0' + PortP->WflushFlag, &PacketP->data[9]); writeb(' ', &PacketP->data[10]); writeb(' ', &PacketP->data[11]); writeb('\0', &PacketP->data[12]); /* ** its two bytes long! */ writeb(PKT_CMD_BIT | 2, &PacketP->len); /* ** queue it! */ if (!(PortP->State & RIO_DELETED)) { add_transmit(PortP); /* ** Count chars tx'd for port statistics reporting */ if (PortP->statsGather) PortP->txchars += 2; } if (--(PortP->WflushFlag) == 0) { PortP->MagicFlags &= ~MAGIC_FLUSH; } rio_dprintk(RIO_DEBUG_INTR, "Wflush count now stands at %d\n", PortP->WflushFlag); } if (PortP->MagicFlags & MORE_OUTPUT_EYGOR) { if (PortP->MagicFlags & MAGIC_FLUSH) { PortP->MagicFlags |= MORE_OUTPUT_EYGOR; } else { if (!can_add_transmit(&PacketP, PortP)) { rio_spin_unlock(&PortP->portSem); continue; } rio_spin_unlock(&PortP->portSem); RIOTxEnable((char *) PortP); rio_spin_lock(&PortP->portSem); PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR; } } } /* ** If we can't add anything to the transmit queue, then ** we need do none of the remaining processing. */ if (!can_add_transmit(&PacketP, PortP)) { rio_spin_unlock(&PortP->portSem); continue; } rio_spin_unlock(&PortP->portSem); RIOTxEnable((char *) PortP); } } } /* ** Routine for handling received data for tty drivers */ static void RIOReceive(struct rio_info *p, struct Port *PortP) { struct tty_struct *TtyP; unsigned short transCount; struct PKT __iomem *PacketP; register unsigned int DataCnt; unsigned char __iomem *ptr; unsigned char *buf; int copied = 0; static int intCount, RxIntCnt; /* ** The receive data process is to remove packets from the ** PHB until there aren't any more or the current cblock ** is full. When this occurs, there will be some left over ** data in the packet, that we must do something with. ** As we haven't unhooked the packet from the read list ** yet, we can just leave the packet there, having first ** made a note of how far we got. This means that we need ** a pointer per port saying where we start taking the ** data from - this will normally be zero, but when we ** run out of space it will be set to the offset of the ** next byte to copy from the packet data area. The packet ** length field is decremented by the number of bytes that ** we successfully removed from the packet. When this reaches ** zero, we reset the offset pointer to be zero, and free ** the packet from the front of the queue. */ intCount++; TtyP = PortP->gs.port.tty; if (!TtyP) { rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n"); return; } if (PortP->State & RIO_THROTTLE_RX) { rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n"); return; } if (PortP->State & RIO_DELETED) { while (can_remove_receive(&PacketP, PortP)) { remove_receive(PortP); put_free_end(PortP->HostP, PacketP); } } else { /* ** loop, just so long as: ** i ) there's some data ( i.e. can_remove_receive ) ** ii ) we haven't been blocked ** iii ) there's somewhere to put the data ** iv ) we haven't outstayed our welcome */ transCount = 1; while (can_remove_receive(&PacketP, PortP) && transCount) { RxIntCnt++; /* ** check that it is not a command! */ if (readb(&PacketP->len) & PKT_CMD_BIT) { rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n"); /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */ rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit)); rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port)); rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit)); rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port)); rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len)); rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control)); rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum)); rio_dprintk(RIO_DEBUG_INTR, " data bytes: "); for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++) rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt])); remove_receive(PortP); put_free_end(PortP->HostP, PacketP); continue; /* with next packet */ } /* ** How many characters can we move 'upstream' ? ** ** Determine the minimum of the amount of data ** available and the amount of space in which to ** put it. ** ** 1. Get the packet length by masking 'len' ** for only the length bits. ** 2. Available space is [buffer size] - [space used] ** ** Transfer count is the minimum of packet length ** and available space. */ transCount = tty_buffer_request_room(TtyP, readb(&PacketP->len) & PKT_LEN_MASK); rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); /* ** To use the following 'kkprintfs' for debugging - change the '#undef' ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the ** driver). */ ptr = (unsigned char __iomem *) PacketP->data + PortP->RxDataStart; tty_prepare_flip_string(TtyP, &buf, transCount); rio_memcpy_fromio(buf, ptr, transCount); PortP->RxDataStart += transCount; writeb(readb(&PacketP->len)-transCount, &PacketP->len); copied += transCount; if (readb(&PacketP->len) == 0) { /* ** If we have emptied the packet, then we can ** free it, and reset the start pointer for ** the next packet. */ remove_receive(PortP); put_free_end(PortP->HostP, PacketP); PortP->RxDataStart = 0; } } } if (copied) { rio_dprintk(RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied); tty_flip_buffer_push(TtyP); } return; }
lujji/JXD-7800b-KK-kernel
drivers/staging/generic_serial/rio/riointr.c
C
gpl-2.0
19,476
/* ** ----------------------------------------------------------------------------- ** ** Perle Specialix driver for Linux ** Ported from existing RIO Driver for SCO sources. * * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. ** ** Module : riointr.c ** SID : 1.2 ** Last Modified : 11/6/98 10:33:44 ** Retrieved : 11/6/98 10:33:49 ** ** ident @(#)riointr.c 1.2 ** ** ----------------------------------------------------------------------------- */ #include <linux/module.h> #include <linux/errno.h> #include <linux/tty.h> #include <linux/tty_flip.h> #include <asm/io.h> #include <asm/system.h> #include <asm/string.h> #include <asm/uaccess.h> #include <linux/termios.h> #include <linux/serial.h> #include <linux/generic_serial.h> #include <linux/delay.h> #include "linux_compat.h" #include "rio_linux.h" #include "pkt.h" #include "daemon.h" #include "rio.h" #include "riospace.h" #include "cmdpkt.h" #include "map.h" #include "rup.h" #include "port.h" #include "riodrvr.h" #include "rioinfo.h" #include "func.h" #include "errors.h" #include "pci.h" #include "parmmap.h" #include "unixrup.h" #include "board.h" #include "host.h" #include "phb.h" #include "link.h" #include "cmdblk.h" #include "route.h" #include "cirrus.h" #include "rioioctl.h" static void RIOReceive(struct rio_info *, struct Port *); static char *firstchars(char *p, int nch) { static char buf[2][128]; static int t = 0; t = !t; memcpy(buf[t], p, nch); buf[t][nch] = 0; return buf[t]; } #define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) /* Enable and start the transmission of packets */ void RIOTxEnable(char *en) { struct Port *PortP; struct rio_info *p; struct tty_struct *tty; int c; struct PKT __iomem *PacketP; unsigned long flags; PortP = (struct Port *) en; p = (struct rio_info *) PortP->p; tty = PortP->gs.port.tty; rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt); if (!PortP->gs.xmit_cnt) return; /* This routine is an order of magnitude simpler than the specialix version. One of the disadvantages is that this version will send an incomplete packet (usually 64 bytes instead of 72) once for every 4k worth of data. Let's just say that this won't influence performance significantly..... */ rio_spin_lock_irqsave(&PortP->portSem, flags); while (can_add_transmit(&PacketP, PortP)) { c = PortP->gs.xmit_cnt; if (c > PKT_MAX_DATA_LEN) c = PKT_MAX_DATA_LEN; /* Don't copy past the end of the source buffer */ if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail) c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail; { int t; t = (c > 10) ? 10 : c; rio_dprintk(RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n", PortP->PortNum, c, firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail, t), firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail + c - t, t)); } /* If for one reason or another, we can't copy more data, we're done! */ if (c == 0) break; rio_memcpy_toio(PortP->HostP->Caddr, PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); /* udelay (1); */ writeb(c, &(PacketP->len)); if (!(PortP->State & RIO_DELETED)) { add_transmit(PortP); /* ** Count chars tx'd for port statistics reporting */ if (PortP->statsGather) PortP->txchars += c; } PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE - 1); PortP->gs.xmit_cnt -= c; } rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) tty_wakeup(PortP->gs.port.tty); } /* ** RIO Host Service routine. Does all the work traditionally associated with an ** interrupt. */ static int RupIntr; static int RxIntr; static int TxIntr; void RIOServiceHost(struct rio_info *p, struct Host *HostP) { rio_spin_lock(&HostP->HostLock); if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { static int t = 0; rio_spin_unlock(&HostP->HostLock); if ((t++ % 200) == 0) rio_dprintk(RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int) HostP->Flags); return; } rio_spin_unlock(&HostP->HostLock); if (readw(&HostP->ParmMapP->rup_intr)) { writew(0, &HostP->ParmMapP->rup_intr); p->RIORupCount++; RupIntr++; rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts); RIOPollHostCommands(p, HostP); } if (readw(&HostP->ParmMapP->rx_intr)) { int port; writew(0, &HostP->ParmMapP->rx_intr); p->RIORxCount++; RxIntr++; rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts); /* ** Loop through every port. If the port is mapped into ** the system ( i.e. has /dev/ttyXXXX associated ) then it is ** worth checking. If the port isn't open, grab any packets ** hanging on its receive queue and stuff them on the free ** list; check for commands on the way. */ for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { struct Port *PortP = p->RIOPortp[port]; struct tty_struct *ttyP; struct PKT __iomem *PacketP; /* ** not mapped in - most of the RIOPortp[] information ** has not been set up! ** Optimise: ports come in bundles of eight. */ if (!PortP->Mapped) { port += 7; continue; /* with the next port */ } /* ** If the host board isn't THIS host board, check the next one. ** optimise: ports come in bundles of eight. */ if (PortP->HostP != HostP) { port += 7; continue; } /* ** Let us see - is the port open? If not, then don't service it. */ if (!(PortP->PortState & PORT_ISOPEN)) { continue; } /* ** find corresponding tty structure. The process of mapping ** the ports puts these here. */ ttyP = PortP->gs.port.tty; /* ** Lock the port before we begin working on it. */ rio_spin_lock(&PortP->portSem); /* ** Process received data if there is any. */ if (can_remove_receive(&PacketP, PortP)) RIOReceive(p, PortP); /* ** If there is no data left to be read from the port, and ** it's handshake bit is set, then we must clear the handshake, ** so that that downstream RTA is re-enabled. */ if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { /* ** MAGIC! ( Basically, handshake the RX buffer, so that ** the RTAs upstream can be re-enabled. ) */ rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake); } rio_spin_unlock(&PortP->portSem); } } if (readw(&HostP->ParmMapP->tx_intr)) { int port; writew(0, &HostP->ParmMapP->tx_intr); p->RIOTxCount++; TxIntr++; rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts); /* ** Loop through every port. ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX ** associated ) then it is worth checking. */ for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { struct Port *PortP = p->RIOPortp[port]; struct tty_struct *ttyP; struct PKT __iomem *PacketP; /* ** not mapped in - most of the RIOPortp[] information ** has not been set up! */ if (!PortP->Mapped) { port += 7; continue; /* with the next port */ } /* ** If the host board isn't running, then its data structures ** are no use to us - continue quietly. */ if (PortP->HostP != HostP) { port += 7; continue; /* with the next port */ } /* ** Let us see - is the port open? If not, then don't service it. */ if (!(PortP->PortState & PORT_ISOPEN)) { continue; } rio_dprintk(RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port); /* ** Lock the port before we begin working on it. */ rio_spin_lock(&PortP->portSem); /* ** If we can't add anything to the transmit queue, then ** we need do none of this processing. */ if (!can_add_transmit(&PacketP, PortP)) { rio_dprintk(RIO_DEBUG_INTR, "Can't add to port, so skipping.\n"); rio_spin_unlock(&PortP->portSem); continue; } /* ** find corresponding tty structure. The process of mapping ** the ports puts these here. */ ttyP = PortP->gs.port.tty; /* If ttyP is NULL, the port is getting closed. Forget about it. */ if (!ttyP) { rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n"); rio_spin_unlock(&PortP->portSem); continue; } /* ** If there is more room available we start up the transmit ** data process again. This can be direct I/O, if the cookmode ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch ** characters via the line discipline. We must always call ** the line discipline, ** so that user input characters can be echoed correctly. ** ** ++++ Update +++++ ** With the advent of double buffering, we now see if ** TxBufferOut-In is non-zero. If so, then we copy a packet ** to the output place, and set it going. If this empties ** the buffer, then we must issue a wakeup( ) on OUT. ** If it frees space in the buffer then we must issue ** a wakeup( ) on IN. ** ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we ** have to send a WFLUSH command down the PHB, to mark the ** end point of a WFLUSH. We also need to clear out any ** data from the double buffer! ( note that WflushFlag is a ** *count* of the number of WFLUSH commands outstanding! ) ** ** ++++ And there's more! ** If an RTA is powered off, then on again, and rebooted, ** whilst it has ports open, then we need to re-open the ports. ** ( reasonable enough ). We can't do this when we spot the ** re-boot, in interrupt time, because the queue is probably ** full. So, when we come in here, we need to test if any ** ports are in this condition, and re-open the port before ** we try to send any more data to it. Now, the re-booted ** RTA will be discarding packets from the PHB until it ** receives this open packet, but don't worry tooo much ** about that. The one thing that is interesting is the ** combination of this effect and the WFLUSH effect! */ /* For now don't handle RTA reboots. -- REW. Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ if (PortP->MagicFlags) { if (PortP->MagicFlags & MAGIC_REBOOT) { /* ** well, the RTA has been rebooted, and there is room ** on its queue to add the open packet that is required. ** ** The messy part of this line is trying to decide if ** we need to call the Param function as a tty or as ** a modem. ** DONT USE CLOCAL AS A TEST FOR THIS! ** ** If we can't param the port, then move on to the ** next port. */ PortP->InUse = NOT_INUSE; rio_spin_unlock(&PortP->portSem); if (RIOParam(PortP, RIOC_OPEN, ((PortP->Cor2Copy & (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) == (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) continue; /* with next port */ rio_spin_lock(&PortP->portSem); PortP->MagicFlags &= ~MAGIC_REBOOT; } /* ** As mentioned above, this is a tacky hack to cope ** with WFLUSH */ if (PortP->WflushFlag) { rio_dprintk(RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n"); if (PortP->InUse) rio_dprintk(RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n"); } while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) { int p; struct PktCmd __iomem *PktCmdP; rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n"); /* ** make it look just like a WFLUSH command */ PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0]; writeb(RIOC_WFLUSH, &PktCmdP->Command); p = PortP->HostPort % (u16) PORTS_PER_RTA; /* ** If second block of ports for 16 port RTA, add 8 ** to index 8-15. */ if (PortP->SecondBlock) p += PORTS_PER_RTA; writeb(p, &PktCmdP->PhbNum); /* ** to make debuggery easier */ writeb('W', &PacketP->data[2]); writeb('F', &PacketP->data[3]); writeb('L', &PacketP->data[4]); writeb('U', &PacketP->data[5]); writeb('S', &PacketP->data[6]); writeb('H', &PacketP->data[7]); writeb(' ', &PacketP->data[8]); writeb('0' + PortP->WflushFlag, &PacketP->data[9]); writeb(' ', &PacketP->data[10]); writeb(' ', &PacketP->data[11]); writeb('\0', &PacketP->data[12]); /* ** its two bytes long! */ writeb(PKT_CMD_BIT | 2, &PacketP->len); /* ** queue it! */ if (!(PortP->State & RIO_DELETED)) { add_transmit(PortP); /* ** Count chars tx'd for port statistics reporting */ if (PortP->statsGather) PortP->txchars += 2; } if (--(PortP->WflushFlag) == 0) { PortP->MagicFlags &= ~MAGIC_FLUSH; } rio_dprintk(RIO_DEBUG_INTR, "Wflush count now stands at %d\n", PortP->WflushFlag); } if (PortP->MagicFlags & MORE_OUTPUT_EYGOR) { if (PortP->MagicFlags & MAGIC_FLUSH) { PortP->MagicFlags |= MORE_OUTPUT_EYGOR; } else { if (!can_add_transmit(&PacketP, PortP)) { rio_spin_unlock(&PortP->portSem); continue; } rio_spin_unlock(&PortP->portSem); RIOTxEnable((char *) PortP); rio_spin_lock(&PortP->portSem); PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR; } } } /* ** If we can't add anything to the transmit queue, then ** we need do none of the remaining processing. */ if (!can_add_transmit(&PacketP, PortP)) { rio_spin_unlock(&PortP->portSem); continue; } rio_spin_unlock(&PortP->portSem); RIOTxEnable((char *) PortP); } } } /* ** Routine for handling received data for tty drivers */ static void RIOReceive(struct rio_info *p, struct Port *PortP) { struct tty_struct *TtyP; unsigned short transCount; struct PKT __iomem *PacketP; register unsigned int DataCnt; unsigned char __iomem *ptr; unsigned char *buf; int copied = 0; static int intCount, RxIntCnt; /* ** The receive data process is to remove packets from the ** PHB until there aren't any more or the current cblock ** is full. When this occurs, there will be some left over ** data in the packet, that we must do something with. ** As we haven't unhooked the packet from the read list ** yet, we can just leave the packet there, having first ** made a note of how far we got. This means that we need ** a pointer per port saying where we start taking the ** data from - this will normally be zero, but when we ** run out of space it will be set to the offset of the ** next byte to copy from the packet data area. The packet ** length field is decremented by the number of bytes that ** we successfully removed from the packet. When this reaches ** zero, we reset the offset pointer to be zero, and free ** the packet from the front of the queue. */ intCount++; TtyP = PortP->gs.port.tty; if (!TtyP) { rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n"); return; } if (PortP->State & RIO_THROTTLE_RX) { rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n"); return; } if (PortP->State & RIO_DELETED) { while (can_remove_receive(&PacketP, PortP)) { remove_receive(PortP); put_free_end(PortP->HostP, PacketP); } } else { /* ** loop, just so long as: ** i ) there's some data ( i.e. can_remove_receive ) ** ii ) we haven't been blocked ** iii ) there's somewhere to put the data ** iv ) we haven't outstayed our welcome */ transCount = 1; while (can_remove_receive(&PacketP, PortP) && transCount) { RxIntCnt++; /* ** check that it is not a command! */ if (readb(&PacketP->len) & PKT_CMD_BIT) { rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n"); /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */ rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit)); rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port)); rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit)); rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port)); rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len)); rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control)); rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum)); rio_dprintk(RIO_DEBUG_INTR, " data bytes: "); for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++) rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt])); remove_receive(PortP); put_free_end(PortP->HostP, PacketP); continue; /* with next packet */ } /* ** How many characters can we move 'upstream' ? ** ** Determine the minimum of the amount of data ** available and the amount of space in which to ** put it. ** ** 1. Get the packet length by masking 'len' ** for only the length bits. ** 2. Available space is [buffer size] - [space used] ** ** Transfer count is the minimum of packet length ** and available space. */ transCount = tty_buffer_request_room(TtyP, readb(&PacketP->len) & PKT_LEN_MASK); rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); /* ** To use the following 'kkprintfs' for debugging - change the '#undef' ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the ** driver). */ ptr = (unsigned char __iomem *) PacketP->data + PortP->RxDataStart; tty_prepare_flip_string(TtyP, &buf, transCount); rio_memcpy_fromio(buf, ptr, transCount); PortP->RxDataStart += transCount; writeb(readb(&PacketP->len)-transCount, &PacketP->len); copied += transCount; if (readb(&PacketP->len) == 0) { /* ** If we have emptied the packet, then we can ** free it, and reset the start pointer for ** the next packet. */ remove_receive(PortP); put_free_end(PortP->HostP, PacketP); PortP->RxDataStart = 0; } } } if (copied) { rio_dprintk(RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied); tty_flip_buffer_push(TtyP); } return; }
bigbiff/kernel_asus_tf700t
drivers/staging/generic_serial/rio/riointr.c
C
gpl-2.0
19,476
/* * A iio driver for the light sensor ISL 29018. * * IIO driver for monitoring ambient light intensity in luxi, proximity * sensing and infrared sensing. * * Copyright (c) 2010, NVIDIA Corporation. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <linux/module.h> #include <linux/i2c.h> #include <linux/err.h> #include <linux/mutex.h> #include <linux/delay.h> #include <linux/slab.h> #include "../iio.h" #include "../sysfs.h" #define CONVERSION_TIME_MS 100 #define ISL29018_REG_ADD_COMMAND1 0x00 #define COMMMAND1_OPMODE_SHIFT 5 #define COMMMAND1_OPMODE_MASK (7 << COMMMAND1_OPMODE_SHIFT) #define COMMMAND1_OPMODE_POWER_DOWN 0 #define COMMMAND1_OPMODE_ALS_ONCE 1 #define COMMMAND1_OPMODE_IR_ONCE 2 #define COMMMAND1_OPMODE_PROX_ONCE 3 #define ISL29018_REG_ADD_COMMANDII 0x01 #define COMMANDII_RESOLUTION_SHIFT 2 #define COMMANDII_RESOLUTION_MASK (0x3 << COMMANDII_RESOLUTION_SHIFT) #define COMMANDII_RANGE_SHIFT 0 #define COMMANDII_RANGE_MASK (0x3 << COMMANDII_RANGE_SHIFT) #define COMMANDII_SCHEME_SHIFT 7 #define COMMANDII_SCHEME_MASK (0x1 << COMMANDII_SCHEME_SHIFT) #define ISL29018_REG_ADD_DATA_LSB 0x02 #define ISL29018_REG_ADD_DATA_MSB 0x03 #define ISL29018_MAX_REGS (ISL29018_REG_ADD_DATA_MSB+1) #define ISL29018_REG_TEST 0x08 #define ISL29018_TEST_SHIFT 0 #define ISL29018_TEST_MASK (0xFF << ISL29018_TEST_SHIFT) struct isl29018_chip { struct i2c_client *client; struct mutex lock; unsigned int lux_scale; unsigned int range; unsigned int adc_bit; int prox_scheme; u8 reg_cache[ISL29018_MAX_REGS]; }; static int isl29018_write_data(struct i2c_client *client, u8 reg, u8 val, u8 mask, u8 shift) { u8 regval = val; int ret; struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client)); /* don't cache or mask REG_TEST */ if (reg < ISL29018_MAX_REGS) { regval = chip->reg_cache[reg]; regval &= ~mask; regval |= val << shift; } ret = i2c_smbus_write_byte_data(client, reg, regval); if (ret) { dev_err(&client->dev, "Write to device fails status %x\n", ret); } else { /* don't update cache on err */ if (reg < ISL29018_MAX_REGS) chip->reg_cache[reg] = regval; } return ret; } static int isl29018_set_range(struct i2c_client *client, unsigned long range, unsigned int *new_range) { static const unsigned long supp_ranges[] = {1000, 4000, 16000, 64000}; int i; for (i = 0; i < ARRAY_SIZE(supp_ranges); ++i) { if (range <= supp_ranges[i]) { *new_range = (unsigned int)supp_ranges[i]; break; } } if (i >= ARRAY_SIZE(supp_ranges)) return -EINVAL; return isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII, i, COMMANDII_RANGE_MASK, COMMANDII_RANGE_SHIFT); } static int isl29018_set_resolution(struct i2c_client *client, unsigned long adcbit, unsigned int *conf_adc_bit) { static const unsigned long supp_adcbit[] = {16, 12, 8, 4}; int i; for (i = 0; i < ARRAY_SIZE(supp_adcbit); ++i) { if (adcbit >= supp_adcbit[i]) { *conf_adc_bit = (unsigned int)supp_adcbit[i]; break; } } if (i >= ARRAY_SIZE(supp_adcbit)) return -EINVAL; return isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII, i, COMMANDII_RESOLUTION_MASK, COMMANDII_RESOLUTION_SHIFT); } static int isl29018_read_sensor_input(struct i2c_client *client, int mode) { int status; int lsb; int msb; /* Set mode */ status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1, mode, COMMMAND1_OPMODE_MASK, COMMMAND1_OPMODE_SHIFT); if (status) { dev_err(&client->dev, "Error in setting operating mode\n"); return status; } msleep(CONVERSION_TIME_MS); lsb = i2c_smbus_read_byte_data(client, ISL29018_REG_ADD_DATA_LSB); if (lsb < 0) { dev_err(&client->dev, "Error in reading LSB DATA\n"); return lsb; } msb = i2c_smbus_read_byte_data(client, ISL29018_REG_ADD_DATA_MSB); if (msb < 0) { dev_err(&client->dev, "Error in reading MSB DATA\n"); return msb; } dev_vdbg(&client->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb); return (msb << 8) | lsb; } static int isl29018_read_lux(struct i2c_client *client, int *lux) { int lux_data; struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client)); lux_data = isl29018_read_sensor_input(client, COMMMAND1_OPMODE_ALS_ONCE); if (lux_data < 0) return lux_data; *lux = (lux_data * chip->range * chip->lux_scale) >> chip->adc_bit; return 0; } static int isl29018_read_ir(struct i2c_client *client, int *ir) { int ir_data; ir_data = isl29018_read_sensor_input(client, COMMMAND1_OPMODE_IR_ONCE); if (ir_data < 0) return ir_data; *ir = ir_data; return 0; } static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme, int *near_ir) { int status; int prox_data = -1; int ir_data = -1; /* Do proximity sensing with required scheme */ status = isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII, scheme, COMMANDII_SCHEME_MASK, COMMANDII_SCHEME_SHIFT); if (status) { dev_err(&client->dev, "Error in setting operating mode\n"); return status; } prox_data = isl29018_read_sensor_input(client, COMMMAND1_OPMODE_PROX_ONCE); if (prox_data < 0) return prox_data; if (scheme == 1) { *near_ir = prox_data; return 0; } ir_data = isl29018_read_sensor_input(client, COMMMAND1_OPMODE_IR_ONCE); if (ir_data < 0) return ir_data; if (prox_data >= ir_data) *near_ir = prox_data - ir_data; else *near_ir = 0; return 0; } /* Sysfs interface */ /* range */ static ssize_t show_range(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct isl29018_chip *chip = iio_priv(indio_dev); return sprintf(buf, "%u\n", chip->range); } static ssize_t store_range(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct isl29018_chip *chip = iio_priv(indio_dev); struct i2c_client *client = chip->client; int status; unsigned long lval; unsigned int new_range; if (strict_strtoul(buf, 10, &lval)) return -EINVAL; if (!(lval == 1000UL || lval == 4000UL || lval == 16000UL || lval == 64000UL)) { dev_err(dev, "The range is not supported\n"); return -EINVAL; } mutex_lock(&chip->lock); status = isl29018_set_range(client, lval, &new_range); if (status < 0) { mutex_unlock(&chip->lock); dev_err(dev, "Error in setting max range\n"); return status; } chip->range = new_range; mutex_unlock(&chip->lock); return count; } /* resolution */ static ssize_t show_resolution(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct isl29018_chip *chip = iio_priv(indio_dev); return sprintf(buf, "%u\n", chip->adc_bit); } static ssize_t store_resolution(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct isl29018_chip *chip = iio_priv(indio_dev); struct i2c_client *client = chip->client; int status; unsigned long lval; unsigned int new_adc_bit; if (strict_strtoul(buf, 10, &lval)) return -EINVAL; if (!(lval == 4 || lval == 8 || lval == 12 || lval == 16)) { dev_err(dev, "The resolution is not supported\n"); return -EINVAL; } mutex_lock(&chip->lock); status = isl29018_set_resolution(client, lval, &new_adc_bit); if (status < 0) { mutex_unlock(&chip->lock); dev_err(dev, "Error in setting resolution\n"); return status; } chip->adc_bit = new_adc_bit; mutex_unlock(&chip->lock); return count; } /* proximity scheme */ static ssize_t show_prox_infrared_supression(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct isl29018_chip *chip = iio_priv(indio_dev); /* return the "proximity scheme" i.e. if the chip does on chip infrared supression (1 means perform on chip supression) */ return sprintf(buf, "%d\n", chip->prox_scheme); } static ssize_t store_prox_infrared_supression(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct isl29018_chip *chip = iio_priv(indio_dev); unsigned long lval; if (strict_strtoul(buf, 10, &lval)) return -EINVAL; if (!(lval == 0UL || lval == 1UL)) { dev_err(dev, "The mode is not supported\n"); return -EINVAL; } /* get the "proximity scheme" i.e. if the chip does on chip infrared supression (1 means perform on chip supression) */ mutex_lock(&chip->lock); chip->prox_scheme = (int)lval; mutex_unlock(&chip->lock); return count; } /* Channel IO */ static int isl29018_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { struct isl29018_chip *chip = iio_priv(indio_dev); int ret = -EINVAL; mutex_lock(&chip->lock); if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) { chip->lux_scale = val; ret = 0; } mutex_unlock(&chip->lock); return 0; } static int isl29018_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { int ret = -EINVAL; struct isl29018_chip *chip = iio_priv(indio_dev); struct i2c_client *client = chip->client; mutex_lock(&chip->lock); switch (mask) { case 0: switch (chan->type) { case IIO_LIGHT: ret = isl29018_read_lux(client, val); break; case IIO_INTENSITY: ret = isl29018_read_ir(client, val); break; case IIO_PROXIMITY: ret = isl29018_read_proximity_ir(client, chip->prox_scheme, val); break; default: break; } if (!ret) ret = IIO_VAL_INT; break; case IIO_CHAN_INFO_CALIBSCALE: if (chan->type == IIO_LIGHT) { *val = chip->lux_scale; ret = IIO_VAL_INT; } break; default: break; } mutex_unlock(&chip->lock); return ret; } static const struct iio_chan_spec isl29018_channels[] = { { .type = IIO_LIGHT, .indexed = 1, .channel = 0, .processed_val = IIO_PROCESSED, .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, }, { .type = IIO_INTENSITY, .modified = 1, .channel2 = IIO_MOD_LIGHT_IR, }, { /* Unindexed in current ABI. But perhaps it should be. */ .type = IIO_PROXIMITY, } }; static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0); static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000"); static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16"); static IIO_DEVICE_ATTR(adc_resolution, S_IRUGO | S_IWUSR, show_resolution, store_resolution, 0); static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_supression, S_IRUGO | S_IWUSR, show_prox_infrared_supression, store_prox_infrared_supression, 0); #define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr) #define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr) static struct attribute *isl29018_attributes[] = { ISL29018_DEV_ATTR(range), ISL29018_CONST_ATTR(range_available), ISL29018_DEV_ATTR(adc_resolution), ISL29018_CONST_ATTR(adc_resolution_available), ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_supression), NULL }; static const struct attribute_group isl29108_group = { .attrs = isl29018_attributes, }; static int isl29018_chip_init(struct i2c_client *client) { struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client)); int status; int new_adc_bit; unsigned int new_range; memset(chip->reg_cache, 0, sizeof(chip->reg_cache)); /* Code added per Intersil Application Note 1534: * When VDD sinks to approximately 1.8V or below, some of * the part's registers may change their state. When VDD * recovers to 2.25V (or greater), the part may thus be in an * unknown mode of operation. The user can return the part to * a known mode of operation either by (a) setting VDD = 0V for * 1 second or more and then powering back up with a slew rate * of 0.5V/ms or greater, or (b) via I2C disable all ALS/PROX * conversions, clear the test registers, and then rewrite all * registers to the desired values. * ... * FOR ISL29011, ISL29018, ISL29021, ISL29023 * 1. Write 0x00 to register 0x08 (TEST) * 2. Write 0x00 to register 0x00 (CMD1) * 3. Rewrite all registers to the desired values * * ISL29018 Data Sheet (FN6619.1, Feb 11, 2010) essentially says * the same thing EXCEPT the data sheet asks for a 1ms delay after * writing the CMD1 register. */ status = isl29018_write_data(client, ISL29018_REG_TEST, 0, ISL29018_TEST_MASK, ISL29018_TEST_SHIFT); if (status < 0) { dev_err(&client->dev, "Failed to clear isl29018 TEST reg." "(%d)\n", status); return status; } /* See Intersil AN1534 comments above. * "Operating Mode" (COMMAND1) register is reprogrammed when * data is read from the device. */ status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1, 0, 0xff, 0); if (status < 0) { dev_err(&client->dev, "Failed to clear isl29018 CMD1 reg." "(%d)\n", status); return status; } msleep(1); /* per data sheet, page 10 */ /* set defaults */ status = isl29018_set_range(client, chip->range, &new_range); if (status < 0) { dev_err(&client->dev, "Init of isl29018 fails\n"); return status; } status = isl29018_set_resolution(client, chip->adc_bit, &new_adc_bit); return 0; } static const struct iio_info isl29108_info = { .attrs = &isl29108_group, .driver_module = THIS_MODULE, .read_raw = &isl29018_read_raw, .write_raw = &isl29018_write_raw, }; static int __devinit isl29018_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct isl29018_chip *chip; struct iio_dev *indio_dev; int err; indio_dev = iio_allocate_device(sizeof(*chip)); if (indio_dev == NULL) { dev_err(&client->dev, "iio allocation fails\n"); err = -ENOMEM; goto exit; } chip = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); chip->client = client; mutex_init(&chip->lock); chip->lux_scale = 1; chip->range = 1000; chip->adc_bit = 16; err = isl29018_chip_init(client); if (err) goto exit_iio_free; indio_dev->info = &isl29108_info; indio_dev->channels = isl29018_channels; indio_dev->num_channels = ARRAY_SIZE(isl29018_channels); indio_dev->name = id->name; indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; err = iio_device_register(indio_dev); if (err) { dev_err(&client->dev, "iio registration fails\n"); goto exit_iio_free; } return 0; exit_iio_free: iio_free_device(indio_dev); exit: return err; } static int __devexit isl29018_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); dev_dbg(&client->dev, "%s()\n", __func__); iio_device_unregister(indio_dev); iio_free_device(indio_dev); return 0; } static const struct i2c_device_id isl29018_id[] = { {"isl29018", 0}, {} }; MODULE_DEVICE_TABLE(i2c, isl29018_id); static const struct of_device_id isl29018_of_match[] = { { .compatible = "invn,isl29018", }, { }, }; MODULE_DEVICE_TABLE(of, isl29018_of_match); static struct i2c_driver isl29018_driver = { .class = I2C_CLASS_HWMON, .driver = { .name = "isl29018", .owner = THIS_MODULE, .of_match_table = isl29018_of_match, }, .probe = isl29018_probe, .remove = __devexit_p(isl29018_remove), .id_table = isl29018_id, }; module_i2c_driver(isl29018_driver); MODULE_DESCRIPTION("ISL29018 Ambient Light Sensor driver"); MODULE_LICENSE("GPL");
MuddyPlump/android_kernel_motorola_msm8226
drivers/staging/iio/light/isl29018.c
C
gpl-2.0
16,110
/*! * jQuery UI Accordion 1.11.4 * http://jqueryui.com * * Copyright jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * * http://api.jqueryui.com/accordion/ */ !function(a){"function"==typeof define&&define.amd?define(["jquery","./core","./widget"],a):a(jQuery)}(function(a){return a.widget("ui.accordion",{version:"1.11.4",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var b=this.options;this.prevShow=this.prevHide=a(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),b.collapsible||b.active!==!1&&null!=b.active||(b.active=0),this._processPanels(),b.active<0&&(b.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():a()}},_createIcons:function(){var b=this.options.icons;b&&(a("<span>").addClass("ui-accordion-header-icon ui-icon "+b.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(b.header).addClass(b.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var a;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").removeUniqueId(),this._destroyIcons(),a=this.headers.next().removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&a.css("height","")},_setOption:function(a,b){return"active"===a?void this._activate(b):("event"===a&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(b)),this._super(a,b),"collapsible"!==a||b||this.options.active!==!1||this._activate(0),"icons"===a&&(this._destroyIcons(),b&&this._createIcons()),void("disabled"===a&&(this.element.toggleClass("ui-state-disabled",!!b).attr("aria-disabled",b),this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!b))))},_keydown:function(b){if(!b.altKey&&!b.ctrlKey){var c=a.ui.keyCode,d=this.headers.length,e=this.headers.index(b.target),f=!1;switch(b.keyCode){case c.RIGHT:case c.DOWN:f=this.headers[(e+1)%d];break;case c.LEFT:case c.UP:f=this.headers[(e-1+d)%d];break;case c.SPACE:case c.ENTER:this._eventHandler(b);break;case c.HOME:f=this.headers[0];break;case c.END:f=this.headers[d-1]}f&&(a(b.target).attr("tabIndex",-1),a(f).attr("tabIndex",0),f.focus(),b.preventDefault())}},_panelKeyDown:function(b){b.keyCode===a.ui.keyCode.UP&&b.ctrlKey&&a(b.currentTarget).prev().focus()},refresh:function(){var b=this.options;this._processPanels(),b.active===!1&&b.collapsible===!0||!this.headers.length?(b.active=!1,this.active=a()):b.active===!1?this._activate(0):this.active.length&&!a.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(b.active=!1,this.active=a()):this._activate(Math.max(0,b.active-1)):b.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var a=this.headers,b=this.panels;this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-state-default ui-corner-all"),this.panels=this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide(),b&&(this._off(a.not(this.headers)),this._off(b.not(this.panels)))},_refresh:function(){var b,c=this.options,d=c.heightStyle,e=this.element.parent();this.active=this._findActive(c.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(){var b=a(this),c=b.uniqueId().attr("id"),d=b.next(),e=d.uniqueId().attr("id");b.attr("aria-controls",e),d.attr("aria-labelledby",c)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(c.event),"fill"===d?(b=e.height(),this.element.siblings(":visible").each(function(){var c=a(this),d=c.css("position");"absolute"!==d&&"fixed"!==d&&(b-=c.outerHeight(!0))}),this.headers.each(function(){b-=a(this).outerHeight(!0)}),this.headers.next().each(function(){a(this).height(Math.max(0,b-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")):"auto"===d&&(b=0,this.headers.next().each(function(){b=Math.max(b,a(this).css("height","").height())}).height(b))},_activate:function(b){var c=this._findActive(b)[0];c!==this.active[0]&&(c=c||this.active[0],this._eventHandler({target:c,currentTarget:c,preventDefault:a.noop}))},_findActive:function(b){return"number"==typeof b?this.headers.eq(b):a()},_setupEvents:function(b){var c={keydown:"_keydown"};b&&a.each(b.split(" "),function(a,b){c[b]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,c),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(b){var c=this.options,d=this.active,e=a(b.currentTarget),f=e[0]===d[0],g=f&&c.collapsible,h=g?a():e.next(),i=d.next(),j={oldHeader:d,oldPanel:i,newHeader:g?a():e,newPanel:h};b.preventDefault(),f&&!c.collapsible||this._trigger("beforeActivate",b,j)===!1||(c.active=g?!1:this.headers.index(e),this.active=f?a():e,this._toggle(j),d.removeClass("ui-accordion-header-active ui-state-active"),c.icons&&d.children(".ui-accordion-header-icon").removeClass(c.icons.activeHeader).addClass(c.icons.header),f||(e.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),c.icons&&e.children(".ui-accordion-header-icon").removeClass(c.icons.header).addClass(c.icons.activeHeader),e.next().addClass("ui-accordion-content-active")))},_toggle:function(b){var c=b.newPanel,d=this.prevShow.length?this.prevShow:b.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=c,this.prevHide=d,this.options.animate?this._animate(c,d,b):(d.hide(),c.show(),this._toggleComplete(b)),d.attr({"aria-hidden":"true"}),d.prev().attr({"aria-selected":"false","aria-expanded":"false"}),c.length&&d.length?d.prev().attr({tabIndex:-1,"aria-expanded":"false"}):c.length&&this.headers.filter(function(){return 0===parseInt(a(this).attr("tabIndex"),10)}).attr("tabIndex",-1),c.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(a,b,c){var d,e,f,g=this,h=0,i=a.css("box-sizing"),j=a.length&&(!b.length||a.index()<b.index()),k=this.options.animate||{},l=j&&k.down||k,m=function(){g._toggleComplete(c)};return"number"==typeof l&&(f=l),"string"==typeof l&&(e=l),e=e||l.easing||k.easing,f=f||l.duration||k.duration,b.length?a.length?(d=a.show().outerHeight(),b.animate(this.hideProps,{duration:f,easing:e,step:function(a,b){b.now=Math.round(a)}}),void a.hide().animate(this.showProps,{duration:f,easing:e,complete:m,step:function(a,c){c.now=Math.round(a),"height"!==c.prop?"content-box"===i&&(h+=c.now):"content"!==g.options.heightStyle&&(c.now=Math.round(d-b.outerHeight()-h),h=0)}})):b.animate(this.hideProps,f,e,m):a.animate(this.showProps,f,e,m)},_toggleComplete:function(a){var b=a.oldPanel;b.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),b.length&&(b.parent()[0].className=b.parent()[0].className),this._trigger("activate",null,a)}})});
chriscowellgolfnow/wordpress-multisite
wp-includes/js/jquery/ui/accordion.min.js
JavaScript
gpl-2.0
8,585
/* * TCP Illinois congestion control. * Home page: * http://www.ews.uiuc.edu/~shaoliu/tcpillinois/index.html * * The algorithm is described in: * "TCP-Illinois: A Loss and Delay-Based Congestion Control Algorithm * for High-Speed Networks" * http://www.ifp.illinois.edu/~srikant/Papers/liubassri06perf.pdf * * Implemented from description in paper and ns-2 simulation. * Copyright (C) 2007 Stephen Hemminger <shemminger@linux-foundation.org> */ #include <linux/module.h> #include <linux/skbuff.h> #include <linux/inet_diag.h> #include <asm/div64.h> #include <net/tcp.h> #define ALPHA_SHIFT 7 #define ALPHA_SCALE (1u<<ALPHA_SHIFT) #define ALPHA_MIN ((3*ALPHA_SCALE)/10) /* ~0.3 */ #define ALPHA_MAX (10*ALPHA_SCALE) /* 10.0 */ #define ALPHA_BASE ALPHA_SCALE /* 1.0 */ #define U32_MAX ((u32)~0U) #define RTT_MAX (U32_MAX / ALPHA_MAX) /* 3.3 secs */ #define BETA_SHIFT 6 #define BETA_SCALE (1u<<BETA_SHIFT) #define BETA_MIN (BETA_SCALE/8) /* 0.125 */ #define BETA_MAX (BETA_SCALE/2) /* 0.5 */ #define BETA_BASE BETA_MAX static int win_thresh __read_mostly = 15; module_param(win_thresh, int, 0); MODULE_PARM_DESC(win_thresh, "Window threshold for starting adaptive sizing"); static int theta __read_mostly = 5; module_param(theta, int, 0); MODULE_PARM_DESC(theta, "# of fast RTT's before full growth"); /* TCP Illinois Parameters */ struct illinois { u64 sum_rtt; /* sum of rtt's measured within last rtt */ u16 cnt_rtt; /* # of rtts measured within last rtt */ u32 base_rtt; /* min of all rtt in usec */ u32 max_rtt; /* max of all rtt in usec */ u32 end_seq; /* right edge of current RTT */ u32 alpha; /* Additive increase */ u32 beta; /* Muliplicative decrease */ u16 acked; /* # packets acked by current ACK */ u8 rtt_above; /* average rtt has gone above threshold */ u8 rtt_low; /* # of rtts measurements below threshold */ }; static void rtt_reset(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct illinois *ca = inet_csk_ca(sk); ca->end_seq = tp->snd_nxt; ca->cnt_rtt = 0; ca->sum_rtt = 0; /* TODO: age max_rtt? */ } static void tcp_illinois_init(struct sock *sk) { struct illinois *ca = inet_csk_ca(sk); ca->alpha = ALPHA_MAX; ca->beta = BETA_BASE; ca->base_rtt = 0x7fffffff; ca->max_rtt = 0; ca->acked = 0; ca->rtt_low = 0; ca->rtt_above = 0; rtt_reset(sk); } /* Measure RTT for each ack. */ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, s32 rtt) { struct illinois *ca = inet_csk_ca(sk); ca->acked = pkts_acked; /* dup ack, no rtt sample */ if (rtt < 0) return; /* ignore bogus values, this prevents wraparound in alpha math */ if (rtt > RTT_MAX) rtt = RTT_MAX; /* keep track of minimum RTT seen so far */ if (ca->base_rtt > rtt) ca->base_rtt = rtt; /* and max */ if (ca->max_rtt < rtt) ca->max_rtt = rtt; ++ca->cnt_rtt; ca->sum_rtt += rtt; } /* Maximum queuing delay */ static inline u32 max_delay(const struct illinois *ca) { return ca->max_rtt - ca->base_rtt; } /* Average queuing delay */ static inline u32 avg_delay(const struct illinois *ca) { u64 t = ca->sum_rtt; do_div(t, ca->cnt_rtt); return t - ca->base_rtt; } /* * Compute value of alpha used for additive increase. * If small window then use 1.0, equivalent to Reno. * * For larger windows, adjust based on average delay. * A. If average delay is at minimum (we are uncongested), * then use large alpha (10.0) to increase faster. * B. If average delay is at maximum (getting congested) * then use small alpha (0.3) * * The result is a convex window growth curve. */ static u32 alpha(struct illinois *ca, u32 da, u32 dm) { u32 d1 = dm / 100; /* Low threshold */ if (da <= d1) { /* If never got out of low delay zone, then use max */ if (!ca->rtt_above) return ALPHA_MAX; /* Wait for 5 good RTT's before allowing alpha to go alpha max. * This prevents one good RTT from causing sudden window increase. */ if (++ca->rtt_low < theta) return ca->alpha; ca->rtt_low = 0; ca->rtt_above = 0; return ALPHA_MAX; } ca->rtt_above = 1; /* * Based on: * * (dm - d1) amin amax * k1 = ------------------- * amax - amin * * (dm - d1) amin * k2 = ---------------- - d1 * amax - amin * * k1 * alpha = ---------- * k2 + da */ dm -= d1; da -= d1; return (dm * ALPHA_MAX) / (dm + (da * (ALPHA_MAX - ALPHA_MIN)) / ALPHA_MIN); } /* * Beta used for multiplicative decrease. * For small window sizes returns same value as Reno (0.5) * * If delay is small (10% of max) then beta = 1/8 * If delay is up to 80% of max then beta = 1/2 * In between is a linear function */ static u32 beta(u32 da, u32 dm) { u32 d2, d3; d2 = dm / 10; if (da <= d2) return BETA_MIN; d3 = (8 * dm) / 10; if (da >= d3 || d3 <= d2) return BETA_MAX; /* * Based on: * * bmin d3 - bmax d2 * k3 = ------------------- * d3 - d2 * * bmax - bmin * k4 = ------------- * d3 - d2 * * b = k3 + k4 da */ return (BETA_MIN * d3 - BETA_MAX * d2 + (BETA_MAX - BETA_MIN) * da) / (d3 - d2); } /* Update alpha and beta values once per RTT */ static void update_params(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct illinois *ca = inet_csk_ca(sk); if (tp->snd_cwnd < win_thresh) { ca->alpha = ALPHA_BASE; ca->beta = BETA_BASE; } else if (ca->cnt_rtt > 0) { u32 dm = max_delay(ca); u32 da = avg_delay(ca); ca->alpha = alpha(ca, da, dm); ca->beta = beta(da, dm); } rtt_reset(sk); } /* * In case of loss, reset to default values */ static void tcp_illinois_state(struct sock *sk, u8 new_state) { struct illinois *ca = inet_csk_ca(sk); if (new_state == TCP_CA_Loss) { ca->alpha = ALPHA_BASE; ca->beta = BETA_BASE; ca->rtt_low = 0; ca->rtt_above = 0; rtt_reset(sk); } } /* * Increase window in response to successful acknowledgment. */ static void tcp_illinois_cong_avoid(struct sock *sk, u32 ack, u32 in_flight) { struct tcp_sock *tp = tcp_sk(sk); struct illinois *ca = inet_csk_ca(sk); if (after(ack, ca->end_seq)) update_params(sk); /* RFC2861 only increase cwnd if fully utilized */ if (!tcp_is_cwnd_limited(sk, in_flight)) return; /* In slow start */ if (tp->snd_cwnd <= tp->snd_ssthresh) tcp_slow_start(tp); else { u32 delta; /* snd_cwnd_cnt is # of packets since last cwnd increment */ tp->snd_cwnd_cnt += ca->acked; ca->acked = 1; /* This is close approximation of: * tp->snd_cwnd += alpha/tp->snd_cwnd */ delta = (tp->snd_cwnd_cnt * ca->alpha) >> ALPHA_SHIFT; if (delta >= tp->snd_cwnd) { tp->snd_cwnd = min(tp->snd_cwnd + delta / tp->snd_cwnd, (u32) tp->snd_cwnd_clamp); tp->snd_cwnd_cnt = 0; } } } static u32 tcp_illinois_ssthresh(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct illinois *ca = inet_csk_ca(sk); /* Multiplicative decrease */ return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->beta) >> BETA_SHIFT), 2U); } /* Extract info for Tcp socket info provided via netlink. */ static void tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb) { const struct illinois *ca = inet_csk_ca(sk); if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { struct tcpvegas_info info = { .tcpv_enabled = 1, .tcpv_rttcnt = ca->cnt_rtt, .tcpv_minrtt = ca->base_rtt, }; u64 t = ca->sum_rtt; do_div(t, ca->cnt_rtt); info.tcpv_rtt = t; nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); } } static struct tcp_congestion_ops tcp_illinois __read_mostly = { .flags = TCP_CONG_RTT_STAMP, .init = tcp_illinois_init, .ssthresh = tcp_illinois_ssthresh, .min_cwnd = tcp_reno_min_cwnd, .cong_avoid = tcp_illinois_cong_avoid, .set_state = tcp_illinois_state, .get_info = tcp_illinois_info, .pkts_acked = tcp_illinois_acked, .owner = THIS_MODULE, .name = "illinois", }; static int __init tcp_illinois_register(void) { BUILD_BUG_ON(sizeof(struct illinois) > ICSK_CA_PRIV_SIZE); return tcp_register_congestion_control(&tcp_illinois); } static void __exit tcp_illinois_unregister(void) { tcp_unregister_congestion_control(&tcp_illinois); } module_init(tcp_illinois_register); module_exit(tcp_illinois_unregister); MODULE_AUTHOR("Stephen Hemminger, Shao Liu"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TCP Illinois"); MODULE_VERSION("1.0");
zte8930/msm8930
net/ipv4/tcp_illinois.c
C
gpl-2.0
8,343
/* * SCOM support for A2 platforms * * Copyright 2007-2011 Benjamin Herrenschmidt, David Gibson, * Michael Ellerman, IBM Corp. * * 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. */ #include <linux/cpumask.h> #include <linux/io.h> #include <linux/of.h> #include <linux/spinlock.h> #include <linux/types.h> #include <asm/cputhreads.h> #include <asm/reg_a2.h> #include <asm/scom.h> #include <asm/udbg.h> #include "wsp.h" #define SCOM_RAMC 0x2a /* Ram Command */ #define SCOM_RAMC_TGT1_EXT 0x80000000 #define SCOM_RAMC_SRC1_EXT 0x40000000 #define SCOM_RAMC_SRC2_EXT 0x20000000 #define SCOM_RAMC_SRC3_EXT 0x10000000 #define SCOM_RAMC_ENABLE 0x00080000 #define SCOM_RAMC_THREADSEL 0x00060000 #define SCOM_RAMC_EXECUTE 0x00010000 #define SCOM_RAMC_MSR_OVERRIDE 0x00008000 #define SCOM_RAMC_MSR_PR 0x00004000 #define SCOM_RAMC_MSR_GS 0x00002000 #define SCOM_RAMC_FORCE 0x00001000 #define SCOM_RAMC_FLUSH 0x00000800 #define SCOM_RAMC_INTERRUPT 0x00000004 #define SCOM_RAMC_ERROR 0x00000002 #define SCOM_RAMC_DONE 0x00000001 #define SCOM_RAMI 0x29 /* Ram Instruction */ #define SCOM_RAMIC 0x28 /* Ram Instruction and Command */ #define SCOM_RAMIC_INSN 0xffffffff00000000 #define SCOM_RAMD 0x2d /* Ram Data */ #define SCOM_RAMDH 0x2e /* Ram Data High */ #define SCOM_RAMDL 0x2f /* Ram Data Low */ #define SCOM_PCCR0 0x33 /* PC Configuration Register 0 */ #define SCOM_PCCR0_ENABLE_DEBUG 0x80000000 #define SCOM_PCCR0_ENABLE_RAM 0x40000000 #define SCOM_THRCTL 0x30 /* Thread Control and Status */ #define SCOM_THRCTL_T0_STOP 0x80000000 #define SCOM_THRCTL_T1_STOP 0x40000000 #define SCOM_THRCTL_T2_STOP 0x20000000 #define SCOM_THRCTL_T3_STOP 0x10000000 #define SCOM_THRCTL_T0_STEP 0x08000000 #define SCOM_THRCTL_T1_STEP 0x04000000 #define SCOM_THRCTL_T2_STEP 0x02000000 #define SCOM_THRCTL_T3_STEP 0x01000000 #define SCOM_THRCTL_T0_RUN 0x00800000 #define SCOM_THRCTL_T1_RUN 0x00400000 #define SCOM_THRCTL_T2_RUN 0x00200000 #define SCOM_THRCTL_T3_RUN 0x00100000 #define SCOM_THRCTL_T0_PM 0x00080000 #define SCOM_THRCTL_T1_PM 0x00040000 #define SCOM_THRCTL_T2_PM 0x00020000 #define SCOM_THRCTL_T3_PM 0x00010000 #define SCOM_THRCTL_T0_UDE 0x00008000 #define SCOM_THRCTL_T1_UDE 0x00004000 #define SCOM_THRCTL_T2_UDE 0x00002000 #define SCOM_THRCTL_T3_UDE 0x00001000 #define SCOM_THRCTL_ASYNC_DIS 0x00000800 #define SCOM_THRCTL_TB_DIS 0x00000400 #define SCOM_THRCTL_DEC_DIS 0x00000200 #define SCOM_THRCTL_AND 0x31 /* Thread Control and Status */ #define SCOM_THRCTL_OR 0x32 /* Thread Control and Status */ static DEFINE_PER_CPU(scom_map_t, scom_ptrs); static scom_map_t get_scom(int cpu, struct device_node *np, int *first_thread) { scom_map_t scom = per_cpu(scom_ptrs, cpu); int tcpu; if (scom_map_ok(scom)) { *first_thread = 0; return scom; } *first_thread = 1; scom = scom_map_device(np, 0); for (tcpu = cpu_first_thread_sibling(cpu); tcpu <= cpu_last_thread_sibling(cpu); tcpu++) per_cpu(scom_ptrs, tcpu) = scom; /* Hack: for the boot core, this will actually get called on * the second thread up, not the first so our test above will * set first_thread incorrectly. */ if (cpu_first_thread_sibling(cpu) == 0) *first_thread = 0; return scom; } static int a2_scom_ram(scom_map_t scom, int thread, u32 insn, int extmask) { u64 cmd, mask, val; int n = 0; cmd = ((u64)insn << 32) | (((u64)extmask & 0xf) << 28) | ((u64)thread << 17) | SCOM_RAMC_ENABLE | SCOM_RAMC_EXECUTE; mask = SCOM_RAMC_DONE | SCOM_RAMC_INTERRUPT | SCOM_RAMC_ERROR; scom_write(scom, SCOM_RAMIC, cmd); while (!((val = scom_read(scom, SCOM_RAMC)) & mask)) { pr_devel("Waiting on RAMC = 0x%llx\n", val); if (++n == 3) { pr_err("RAMC timeout on instruction 0x%08x, thread %d\n", insn, thread); return -1; } } if (val & SCOM_RAMC_INTERRUPT) { pr_err("RAMC interrupt on instruction 0x%08x, thread %d\n", insn, thread); return -SCOM_RAMC_INTERRUPT; } if (val & SCOM_RAMC_ERROR) { pr_err("RAMC error on instruction 0x%08x, thread %d\n", insn, thread); return -SCOM_RAMC_ERROR; } return 0; } static int a2_scom_getgpr(scom_map_t scom, int thread, int gpr, int alt, u64 *out_gpr) { int rc; /* or rN, rN, rN */ u32 insn = 0x7c000378 | (gpr << 21) | (gpr << 16) | (gpr << 11); rc = a2_scom_ram(scom, thread, insn, alt ? 0xf : 0x0); if (rc) return rc; *out_gpr = scom_read(scom, SCOM_RAMD); return 0; } static int a2_scom_getspr(scom_map_t scom, int thread, int spr, u64 *out_spr) { int rc, sprhi, sprlo; u32 insn; sprhi = spr >> 5; sprlo = spr & 0x1f; insn = 0x7c2002a6 | (sprlo << 16) | (sprhi << 11); /* mfspr r1,spr */ if (spr == 0x0ff0) insn = 0x7c2000a6; /* mfmsr r1 */ rc = a2_scom_ram(scom, thread, insn, 0xf); if (rc) return rc; return a2_scom_getgpr(scom, thread, 1, 1, out_spr); } static int a2_scom_setgpr(scom_map_t scom, int thread, int gpr, int alt, u64 val) { u32 lis = 0x3c000000 | (gpr << 21); u32 li = 0x38000000 | (gpr << 21); u32 oris = 0x64000000 | (gpr << 21) | (gpr << 16); u32 ori = 0x60000000 | (gpr << 21) | (gpr << 16); u32 rldicr32 = 0x780007c6 | (gpr << 21) | (gpr << 16); u32 highest = val >> 48; u32 higher = (val >> 32) & 0xffff; u32 high = (val >> 16) & 0xffff; u32 low = val & 0xffff; int lext = alt ? 0x8 : 0x0; int oext = alt ? 0xf : 0x0; int rc = 0; if (highest) rc |= a2_scom_ram(scom, thread, lis | highest, lext); if (higher) { if (highest) rc |= a2_scom_ram(scom, thread, oris | higher, oext); else rc |= a2_scom_ram(scom, thread, li | higher, lext); } if (highest || higher) rc |= a2_scom_ram(scom, thread, rldicr32, oext); if (high) { if (highest || higher) rc |= a2_scom_ram(scom, thread, oris | high, oext); else rc |= a2_scom_ram(scom, thread, lis | high, lext); } if (highest || higher || high) rc |= a2_scom_ram(scom, thread, ori | low, oext); else rc |= a2_scom_ram(scom, thread, li | low, lext); return rc; } static int a2_scom_setspr(scom_map_t scom, int thread, int spr, u64 val) { int sprhi = spr >> 5; int sprlo = spr & 0x1f; /* mtspr spr, r1 */ u32 insn = 0x7c2003a6 | (sprlo << 16) | (sprhi << 11); if (spr == 0x0ff0) insn = 0x7c200124; /* mtmsr r1 */ if (a2_scom_setgpr(scom, thread, 1, 1, val)) return -1; return a2_scom_ram(scom, thread, insn, 0xf); } static int a2_scom_initial_tlb(scom_map_t scom, int thread) { extern u32 a2_tlbinit_code_start[], a2_tlbinit_code_end[]; extern u32 a2_tlbinit_after_iprot_flush[]; extern u32 a2_tlbinit_after_linear_map[]; u32 assoc, entries, i; u64 epn, tlbcfg; u32 *p; int rc; /* Invalidate all entries (including iprot) */ rc = a2_scom_getspr(scom, thread, SPRN_TLB0CFG, &tlbcfg); if (rc) goto scom_fail; entries = tlbcfg & TLBnCFG_N_ENTRY; assoc = (tlbcfg & TLBnCFG_ASSOC) >> 24; epn = 0; /* Set MMUCR2 to enable 4K, 64K, 1M, 16M and 1G pages */ a2_scom_setspr(scom, thread, SPRN_MMUCR2, 0x000a7531); /* Set MMUCR3 to write all thids bit to the TLB */ a2_scom_setspr(scom, thread, SPRN_MMUCR3, 0x0000000f); /* Set MAS1 for 1G page size, and MAS2 to our initial EPN */ a2_scom_setspr(scom, thread, SPRN_MAS1, MAS1_TSIZE(BOOK3E_PAGESZ_1GB)); a2_scom_setspr(scom, thread, SPRN_MAS2, epn); for (i = 0; i < entries; i++) { a2_scom_setspr(scom, thread, SPRN_MAS0, MAS0_ESEL(i % assoc)); /* tlbwe */ rc = a2_scom_ram(scom, thread, 0x7c0007a4, 0); if (rc) goto scom_fail; /* Next entry is new address? */ if((i + 1) % assoc == 0) { epn += (1 << 30); a2_scom_setspr(scom, thread, SPRN_MAS2, epn); } } /* Setup args for linear mapping */ rc = a2_scom_setgpr(scom, thread, 3, 0, MAS0_TLBSEL(0)); if (rc) goto scom_fail; /* Linear mapping */ for (p = a2_tlbinit_code_start; p < a2_tlbinit_after_linear_map; p++) { rc = a2_scom_ram(scom, thread, *p, 0); if (rc) goto scom_fail; } /* * For the boot thread, between the linear mapping and the debug * mappings there is a loop to flush iprot mappings. Ramming doesn't do * branches, but the secondary threads don't need to be nearly as smart * (i.e. we don't need to worry about invalidating the mapping we're * standing on). */ /* Debug mappings. Expects r11 = MAS0 from linear map (set above) */ for (p = a2_tlbinit_after_iprot_flush; p < a2_tlbinit_code_end; p++) { rc = a2_scom_ram(scom, thread, *p, 0); if (rc) goto scom_fail; } scom_fail: if (rc) pr_err("Setting up initial TLB failed, err %d\n", rc); if (rc == -SCOM_RAMC_INTERRUPT) { /* Interrupt, dump some status */ int rc[10]; u64 iar, srr0, srr1, esr, mas0, mas1, mas2, mas7_3, mas8, ccr2; rc[0] = a2_scom_getspr(scom, thread, SPRN_IAR, &iar); rc[1] = a2_scom_getspr(scom, thread, SPRN_SRR0, &srr0); rc[2] = a2_scom_getspr(scom, thread, SPRN_SRR1, &srr1); rc[3] = a2_scom_getspr(scom, thread, SPRN_ESR, &esr); rc[4] = a2_scom_getspr(scom, thread, SPRN_MAS0, &mas0); rc[5] = a2_scom_getspr(scom, thread, SPRN_MAS1, &mas1); rc[6] = a2_scom_getspr(scom, thread, SPRN_MAS2, &mas2); rc[7] = a2_scom_getspr(scom, thread, SPRN_MAS7_MAS3, &mas7_3); rc[8] = a2_scom_getspr(scom, thread, SPRN_MAS8, &mas8); rc[9] = a2_scom_getspr(scom, thread, SPRN_A2_CCR2, &ccr2); pr_err(" -> retreived IAR =0x%llx (err %d)\n", iar, rc[0]); pr_err(" retreived SRR0=0x%llx (err %d)\n", srr0, rc[1]); pr_err(" retreived SRR1=0x%llx (err %d)\n", srr1, rc[2]); pr_err(" retreived ESR =0x%llx (err %d)\n", esr, rc[3]); pr_err(" retreived MAS0=0x%llx (err %d)\n", mas0, rc[4]); pr_err(" retreived MAS1=0x%llx (err %d)\n", mas1, rc[5]); pr_err(" retreived MAS2=0x%llx (err %d)\n", mas2, rc[6]); pr_err(" retreived MS73=0x%llx (err %d)\n", mas7_3, rc[7]); pr_err(" retreived MAS8=0x%llx (err %d)\n", mas8, rc[8]); pr_err(" retreived CCR2=0x%llx (err %d)\n", ccr2, rc[9]); } return rc; } int __devinit a2_scom_startup_cpu(unsigned int lcpu, int thr_idx, struct device_node *np) { u64 init_iar, init_msr, init_ccr2; unsigned long start_here; int rc, core_setup; scom_map_t scom; u64 pccr0; scom = get_scom(lcpu, np, &core_setup); if (!scom) { printk(KERN_ERR "Couldn't map SCOM for CPU%d\n", lcpu); return -1; } pr_devel("Bringing up CPU%d using SCOM...\n", lcpu); pccr0 = scom_read(scom, SCOM_PCCR0); scom_write(scom, SCOM_PCCR0, pccr0 | SCOM_PCCR0_ENABLE_DEBUG | SCOM_PCCR0_ENABLE_RAM); /* Stop the thead with THRCTL. If we are setting up the TLB we stop all * threads. We also disable asynchronous interrupts while RAMing. */ if (core_setup) scom_write(scom, SCOM_THRCTL_OR, SCOM_THRCTL_T0_STOP | SCOM_THRCTL_T1_STOP | SCOM_THRCTL_T2_STOP | SCOM_THRCTL_T3_STOP | SCOM_THRCTL_ASYNC_DIS); else scom_write(scom, SCOM_THRCTL_OR, SCOM_THRCTL_T0_STOP >> thr_idx); /* Flush its pipeline just in case */ scom_write(scom, SCOM_RAMC, ((u64)thr_idx << 17) | SCOM_RAMC_FLUSH | SCOM_RAMC_ENABLE); a2_scom_getspr(scom, thr_idx, SPRN_IAR, &init_iar); a2_scom_getspr(scom, thr_idx, 0x0ff0, &init_msr); a2_scom_getspr(scom, thr_idx, SPRN_A2_CCR2, &init_ccr2); /* Set MSR to MSR_CM (0x0ff0 is magic value for MSR_CM) */ rc = a2_scom_setspr(scom, thr_idx, 0x0ff0, MSR_CM); if (rc) { pr_err("Failed to set MSR ! err %d\n", rc); return rc; } /* RAM in an sync/isync for the sake of it */ a2_scom_ram(scom, thr_idx, 0x7c0004ac, 0); a2_scom_ram(scom, thr_idx, 0x4c00012c, 0); if (core_setup) { pr_devel("CPU%d is first thread in core, initializing TLB...\n", lcpu); rc = a2_scom_initial_tlb(scom, thr_idx); if (rc) goto fail; } start_here = *(unsigned long *)(core_setup ? generic_secondary_smp_init : generic_secondary_thread_init); pr_devel("CPU%d entry point at 0x%lx...\n", lcpu, start_here); rc |= a2_scom_setspr(scom, thr_idx, SPRN_IAR, start_here); rc |= a2_scom_setgpr(scom, thr_idx, 3, 0, get_hard_smp_processor_id(lcpu)); /* * Tell book3e_secondary_core_init not to set up the TLB, we've * already done that. */ rc |= a2_scom_setgpr(scom, thr_idx, 4, 0, 1); rc |= a2_scom_setspr(scom, thr_idx, SPRN_TENS, 0x1 << thr_idx); scom_write(scom, SCOM_RAMC, 0); scom_write(scom, SCOM_THRCTL_AND, ~(SCOM_THRCTL_T0_STOP >> thr_idx)); scom_write(scom, SCOM_PCCR0, pccr0); fail: pr_devel(" SCOM initialization %s\n", rc ? "failed" : "succeeded"); if (rc) { pr_err("Old IAR=0x%08llx MSR=0x%08llx CCR2=0x%08llx\n", init_iar, init_msr, init_ccr2); } return rc; }
TeamBliss-Devices/kernel_xiaomi_cancro
arch/powerpc/platforms/wsp/scom_smp.c
C
gpl-2.0
12,664
/* * pata_cmd640.c - CMD640 PCI PATA for new ATA layer * (C) 2007 Red Hat Inc * * Based upon * linux/drivers/ide/pci/cmd640.c Version 1.02 Sep 01, 1996 * * Copyright (C) 1995-1996 Linus Torvalds & authors (see driver) * * This drives only the PCI version of the controller. If you have a * VLB one then we have enough docs to support it but you can write * your own code. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/gfp.h> #include <scsi/scsi_host.h> #include <linux/libata.h> #define DRV_NAME "pata_cmd640" #define DRV_VERSION "0.0.5" struct cmd640_reg { int last; u8 reg58[ATA_MAX_DEVICES]; }; enum { CFR = 0x50, CNTRL = 0x51, CMDTIM = 0x52, ARTIM0 = 0x53, DRWTIM0 = 0x54, ARTIM23 = 0x57, DRWTIM23 = 0x58, BRST = 0x59 }; /** * cmd640_set_piomode - set initial PIO mode data * @ap: ATA port * @adev: ATA device * * Called to do the PIO mode setup. */ static void cmd640_set_piomode(struct ata_port *ap, struct ata_device *adev) { struct cmd640_reg *timing = ap->private_data; struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct ata_timing t; const unsigned long T = 1000000 / 33; const u8 setup_data[] = { 0x40, 0x40, 0x40, 0x80, 0x00 }; u8 reg; int arttim = ARTIM0 + 2 * adev->devno; struct ata_device *pair = ata_dev_pair(adev); if (ata_timing_compute(adev, adev->pio_mode, &t, T, 0) < 0) { printk(KERN_ERR DRV_NAME ": mode computation failed.\n"); return; } /* The second channel has shared timings and the setup timing is messy to switch to merge it for worst case */ if (ap->port_no && pair) { struct ata_timing p; ata_timing_compute(pair, pair->pio_mode, &p, T, 1); ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP); } /* Make the timings fit */ if (t.recover > 16) { t.active += t.recover - 16; t.recover = 16; } if (t.active > 16) t.active = 16; /* Now convert the clocks into values we can actually stuff into the chip */ if (t.recover > 1) t.recover--; /* 640B only */ else t.recover = 15; if (t.setup > 4) t.setup = 0xC0; else t.setup = setup_data[t.setup]; if (ap->port_no == 0) { t.active &= 0x0F; /* 0 = 16 */ /* Load setup timing */ pci_read_config_byte(pdev, arttim, &reg); reg &= 0x3F; reg |= t.setup; pci_write_config_byte(pdev, arttim, reg); /* Load active/recovery */ pci_write_config_byte(pdev, arttim + 1, (t.active << 4) | t.recover); } else { /* Save the shared timings for channel, they will be loaded by qc_issue. Reloading the setup time is expensive so we keep a merged one loaded */ pci_read_config_byte(pdev, ARTIM23, &reg); reg &= 0x3F; reg |= t.setup; pci_write_config_byte(pdev, ARTIM23, reg); timing->reg58[adev->devno] = (t.active << 4) | t.recover; } } /** * cmd640_qc_issue - command preparation hook * @qc: Command to be issued * * Channel 1 has shared timings. We must reprogram the * clock each drive 2/3 switch we do. */ static unsigned int cmd640_qc_issue(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; struct ata_device *adev = qc->dev; struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct cmd640_reg *timing = ap->private_data; if (ap->port_no != 0 && adev->devno != timing->last) { pci_write_config_byte(pdev, DRWTIM23, timing->reg58[adev->devno]); timing->last = adev->devno; } return ata_sff_qc_issue(qc); } /** * cmd640_port_start - port setup * @ap: ATA port being set up * * The CMD640 needs to maintain private data structures so we * allocate space here. */ static int cmd640_port_start(struct ata_port *ap) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct cmd640_reg *timing; timing = devm_kzalloc(&pdev->dev, sizeof(struct cmd640_reg), GFP_KERNEL); if (timing == NULL) return -ENOMEM; timing->last = -1; /* Force a load */ ap->private_data = timing; return 0; } static bool cmd640_sff_irq_check(struct ata_port *ap) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); int irq_reg = ap->port_no ? ARTIM23 : CFR; u8 irq_stat, irq_mask = ap->port_no ? 0x10 : 0x04; pci_read_config_byte(pdev, irq_reg, &irq_stat); return irq_stat & irq_mask; } static struct scsi_host_template cmd640_sht = { ATA_PIO_SHT(DRV_NAME), }; static struct ata_port_operations cmd640_port_ops = { .inherits = &ata_sff_port_ops, /* In theory xfer_noirq is not needed once we kill the prefetcher */ .sff_data_xfer = ata_sff_data_xfer_noirq, .sff_irq_check = cmd640_sff_irq_check, .qc_issue = cmd640_qc_issue, .cable_detect = ata_cable_40wire, .set_piomode = cmd640_set_piomode, .port_start = cmd640_port_start, }; static void cmd640_hardware_init(struct pci_dev *pdev) { u8 ctrl; /* CMD640 detected, commiserations */ pci_write_config_byte(pdev, 0x5B, 0x00); /* PIO0 command cycles */ pci_write_config_byte(pdev, CMDTIM, 0); /* 512 byte bursts (sector) */ pci_write_config_byte(pdev, BRST, 0x40); /* * A reporter a long time ago * Had problems with the data fifo * So don't run the risk * Of putting crap on the disk * For its better just to go slow */ /* Do channel 0 */ pci_read_config_byte(pdev, CNTRL, &ctrl); pci_write_config_byte(pdev, CNTRL, ctrl | 0xC0); /* Ditto for channel 1 */ pci_read_config_byte(pdev, ARTIM23, &ctrl); ctrl |= 0x0C; pci_write_config_byte(pdev, ARTIM23, ctrl); } static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { static const struct ata_port_info info = { .flags = ATA_FLAG_SLAVE_POSS, .pio_mask = ATA_PIO4, .port_ops = &cmd640_port_ops }; const struct ata_port_info *ppi[] = { &info, NULL }; int rc; rc = pcim_enable_device(pdev); if (rc) return rc; cmd640_hardware_init(pdev); return ata_pci_sff_init_one(pdev, ppi, &cmd640_sht, NULL, 0); } #ifdef CONFIG_PM static int cmd640_reinit_one(struct pci_dev *pdev) { struct ata_host *host = dev_get_drvdata(&pdev->dev); int rc; rc = ata_pci_device_do_resume(pdev); if (rc) return rc; cmd640_hardware_init(pdev); ata_host_resume(host); return 0; } #endif static const struct pci_device_id cmd640[] = { { PCI_VDEVICE(CMD, 0x640), 0 }, { }, }; static struct pci_driver cmd640_pci_driver = { .name = DRV_NAME, .id_table = cmd640, .probe = cmd640_init_one, .remove = ata_pci_remove_one, #ifdef CONFIG_PM .suspend = ata_pci_device_suspend, .resume = cmd640_reinit_one, #endif }; static int __init cmd640_init(void) { return pci_register_driver(&cmd640_pci_driver); } static void __exit cmd640_exit(void) { pci_unregister_driver(&cmd640_pci_driver); } MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("low-level driver for CMD640 PATA controllers"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, cmd640); MODULE_VERSION(DRV_VERSION); module_init(cmd640_init); module_exit(cmd640_exit);
kozmikkick/KozmiKG2
drivers/ata/pata_cmd640.c
C
gpl-2.0
6,854
/* * Driver for the NXP SAA7164 PCIe bridge * * Copyright (c) 2010 Steven Toth <stoth@kernellabs.com> * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/io.h> #include "saa7164.h" static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) { struct saa7164_i2c *bus = i2c_adap->algo_data; struct saa7164_dev *dev = bus->dev; int i, retval = 0; dprintk(DBGLVL_I2C, "%s(num = %d)\n", __func__, num); for (i = 0 ; i < num; i++) { dprintk(DBGLVL_I2C, "%s(num = %d) addr = 0x%02x len = 0x%x\n", __func__, num, msgs[i].addr, msgs[i].len); if (msgs[i].flags & I2C_M_RD) { /* Unsupported - Yet*/ printk(KERN_ERR "%s() Unsupported - Yet\n", __func__); continue; } else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && msgs[i].addr == msgs[i + 1].addr) { /* write then read from same address */ retval = saa7164_api_i2c_read(bus, msgs[i].addr, msgs[i].len, msgs[i].buf, msgs[i+1].len, msgs[i+1].buf ); i++; if (retval < 0) goto err; } else { /* write */ retval = saa7164_api_i2c_write(bus, msgs[i].addr, msgs[i].len, msgs[i].buf); } if (retval < 0) goto err; } return num; err: return retval; } void saa7164_call_i2c_clients(struct saa7164_i2c *bus, unsigned int cmd, void *arg) { if (bus->i2c_rc != 0) return; i2c_clients_command(&bus->i2c_adap, cmd, arg); } static u32 saa7164_functionality(struct i2c_adapter *adap) { return I2C_FUNC_I2C; } static struct i2c_algorithm saa7164_i2c_algo_template = { .master_xfer = i2c_xfer, .functionality = saa7164_functionality, }; /* ----------------------------------------------------------------------- */ static struct i2c_adapter saa7164_i2c_adap_template = { .name = "saa7164", .owner = THIS_MODULE, .algo = &saa7164_i2c_algo_template, }; static struct i2c_client saa7164_i2c_client_template = { .name = "saa7164 internal", }; int saa7164_i2c_register(struct saa7164_i2c *bus) { struct saa7164_dev *dev = bus->dev; dprintk(DBGLVL_I2C, "%s(bus = %d)\n", __func__, bus->nr); memcpy(&bus->i2c_adap, &saa7164_i2c_adap_template, sizeof(bus->i2c_adap)); memcpy(&bus->i2c_algo, &saa7164_i2c_algo_template, sizeof(bus->i2c_algo)); memcpy(&bus->i2c_client, &saa7164_i2c_client_template, sizeof(bus->i2c_client)); bus->i2c_adap.dev.parent = &dev->pci->dev; strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); bus->i2c_algo.data = bus; bus->i2c_adap.algo_data = bus; i2c_set_adapdata(&bus->i2c_adap, bus); i2c_add_adapter(&bus->i2c_adap); bus->i2c_client.adapter = &bus->i2c_adap; if (0 != bus->i2c_rc) printk(KERN_ERR "%s: i2c bus %d register FAILED\n", dev->name, bus->nr); return bus->i2c_rc; } int saa7164_i2c_unregister(struct saa7164_i2c *bus) { i2c_del_adapter(&bus->i2c_adap); return 0; }
rosenpapazov/one_plus_one
drivers/media/video/saa7164/saa7164-i2c.c
C
gpl-2.0
3,666
/* * linux/arch/sh/boards/se/7721/setup.c * * Copyright (C) 2008 Renesas Solutions Corp. * * Hitachi UL SolutionEngine 7721 Support. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * */ #include <linux/init.h> #include <linux/platform_device.h> #include <mach-se/mach/se7721.h> #include <mach-se/mach/mrshpc.h> #include <asm/machvec.h> #include <asm/io.h> #include <asm/heartbeat.h> static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 }; static struct heartbeat_data heartbeat_data = { .bit_pos = heartbeat_bit_pos, .nr_bits = ARRAY_SIZE(heartbeat_bit_pos), }; static struct resource heartbeat_resource = { .start = PA_LED, .end = PA_LED, .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT, }; static struct platform_device heartbeat_device = { .name = "heartbeat", .id = -1, .dev = { .platform_data = &heartbeat_data, }, .num_resources = 1, .resource = &heartbeat_resource, }; static struct resource cf_ide_resources[] = { [0] = { .start = PA_MRSHPC_IO + 0x1f0, .end = PA_MRSHPC_IO + 0x1f0 + 8 , .flags = IORESOURCE_IO, }, [1] = { .start = PA_MRSHPC_IO + 0x1f0 + 0x206, .end = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8, .flags = IORESOURCE_IO, }, [2] = { .start = MRSHPC_IRQ0, .flags = IORESOURCE_IRQ, }, }; static struct platform_device cf_ide_device = { .name = "pata_platform", .id = -1, .num_resources = ARRAY_SIZE(cf_ide_resources), .resource = cf_ide_resources, }; static struct platform_device *se7721_devices[] __initdata = { &cf_ide_device, &heartbeat_device }; static int __init se7721_devices_setup(void) { mrshpc_setup_windows(); return platform_add_devices(se7721_devices, ARRAY_SIZE(se7721_devices)); } device_initcall(se7721_devices_setup); static void __init se7721_setup(char **cmdline_p) { /* for USB */ __raw_writew(0x0000, 0xA405010C); /* PGCR */ __raw_writew(0x0000, 0xA405010E); /* PHCR */ __raw_writew(0x00AA, 0xA4050118); /* PPCR */ __raw_writew(0x0000, 0xA4050124); /* PSELA */ } /* * The Machine Vector */ struct sh_machine_vector mv_se7721 __initmv = { .mv_name = "Solution Engine 7721", .mv_setup = se7721_setup, .mv_nr_irqs = 109, .mv_init_irq = init_se7721_IRQ, };
Shamestick/android_kernel_htc_msm8974
arch/sh/boards/mach-se/7721/setup.c
C
gpl-2.0
2,318
/* * linux/arch/sh/boards/se/7721/setup.c * * Copyright (C) 2008 Renesas Solutions Corp. * * Hitachi UL SolutionEngine 7721 Support. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * */ #include <linux/init.h> #include <linux/platform_device.h> #include <mach-se/mach/se7721.h> #include <mach-se/mach/mrshpc.h> #include <asm/machvec.h> #include <asm/io.h> #include <asm/heartbeat.h> static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 }; static struct heartbeat_data heartbeat_data = { .bit_pos = heartbeat_bit_pos, .nr_bits = ARRAY_SIZE(heartbeat_bit_pos), }; static struct resource heartbeat_resource = { .start = PA_LED, .end = PA_LED, .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT, }; static struct platform_device heartbeat_device = { .name = "heartbeat", .id = -1, .dev = { .platform_data = &heartbeat_data, }, .num_resources = 1, .resource = &heartbeat_resource, }; static struct resource cf_ide_resources[] = { [0] = { .start = PA_MRSHPC_IO + 0x1f0, .end = PA_MRSHPC_IO + 0x1f0 + 8 , .flags = IORESOURCE_IO, }, [1] = { .start = PA_MRSHPC_IO + 0x1f0 + 0x206, .end = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8, .flags = IORESOURCE_IO, }, [2] = { .start = MRSHPC_IRQ0, .flags = IORESOURCE_IRQ, }, }; static struct platform_device cf_ide_device = { .name = "pata_platform", .id = -1, .num_resources = ARRAY_SIZE(cf_ide_resources), .resource = cf_ide_resources, }; static struct platform_device *se7721_devices[] __initdata = { &cf_ide_device, &heartbeat_device }; static int __init se7721_devices_setup(void) { mrshpc_setup_windows(); return platform_add_devices(se7721_devices, ARRAY_SIZE(se7721_devices)); } device_initcall(se7721_devices_setup); static void __init se7721_setup(char **cmdline_p) { /* for USB */ __raw_writew(0x0000, 0xA405010C); /* PGCR */ __raw_writew(0x0000, 0xA405010E); /* PHCR */ __raw_writew(0x00AA, 0xA4050118); /* PPCR */ __raw_writew(0x0000, 0xA4050124); /* PSELA */ } /* * The Machine Vector */ struct sh_machine_vector mv_se7721 __initmv = { .mv_name = "Solution Engine 7721", .mv_setup = se7721_setup, .mv_nr_irqs = 109, .mv_init_irq = init_se7721_IRQ, };
pacificIT/Kernel_Unico
arch/sh/boards/mach-se/7721/setup.c
C
gpl-2.0
2,318
/* * (c) Copyright 2003, 2006 Hewlett-Packard Development Company, L.P. * Alex Williamson <alex.williamson@hp.com> * Bjorn Helgaas <bjorn.helgaas@hp.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/module.h> #include <linux/types.h> #include <linux/slab.h> #include <linux/acpi.h> #include <asm/acpi-ext.h> /* * Device CSRs that do not appear in PCI config space should be described * via ACPI. This would normally be done with Address Space Descriptors * marked as "consumer-only," but old versions of Windows and Linux ignore * the producer/consumer flag, so HP invented a vendor-defined resource to * describe the location and size of CSR space. */ struct acpi_vendor_uuid hp_ccsr_uuid = { .subtype = 2, .data = { 0xf9, 0xad, 0xe9, 0x69, 0x4f, 0x92, 0x5f, 0xab, 0xf6, 0x4a, 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad }, }; static acpi_status hp_ccsr_locate(acpi_handle obj, u64 *base, u64 *length) { acpi_status status; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_resource *resource; struct acpi_resource_vendor_typed *vendor; status = acpi_get_vendor_resource(obj, METHOD_NAME__CRS, &hp_ccsr_uuid, &buffer); resource = buffer.pointer; vendor = &resource->data.vendor_typed; if (ACPI_FAILURE(status) || vendor->byte_length < 16) { status = AE_NOT_FOUND; goto exit; } memcpy(base, vendor->byte_data, sizeof(*base)); memcpy(length, vendor->byte_data + 8, sizeof(*length)); exit: kfree(buffer.pointer); return status; } struct csr_space { u64 base; u64 length; }; static acpi_status find_csr_space(struct acpi_resource *resource, void *data) { struct csr_space *space = data; struct acpi_resource_address64 addr; acpi_status status; status = acpi_resource_to_address64(resource, &addr); if (ACPI_SUCCESS(status) && addr.resource_type == ACPI_MEMORY_RANGE && addr.address_length && addr.producer_consumer == ACPI_CONSUMER) { space->base = addr.minimum; space->length = addr.address_length; return AE_CTRL_TERMINATE; } return AE_OK; /* keep looking */ } static acpi_status hp_crs_locate(acpi_handle obj, u64 *base, u64 *length) { struct csr_space space = { 0, 0 }; acpi_walk_resources(obj, METHOD_NAME__CRS, find_csr_space, &space); if (!space.length) return AE_NOT_FOUND; *base = space.base; *length = space.length; return AE_OK; } acpi_status hp_acpi_csr_space(acpi_handle obj, u64 *csr_base, u64 *csr_length) { acpi_status status; status = hp_ccsr_locate(obj, csr_base, csr_length); if (ACPI_SUCCESS(status)) return status; return hp_crs_locate(obj, csr_base, csr_length); } EXPORT_SYMBOL(hp_acpi_csr_space);
khanfrd/android_kernel_xiaomi_kenzo
arch/ia64/kernel/acpi-ext.c
C
gpl-2.0
2,798
/* * The olsr.org Optimized Link-State Routing daemon(olsrd) * Copyright (c) 2004-2011, the olsr.org team - see HISTORY file * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of olsr.org, olsrd nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * Visit http://www.olsr.org for more information. * * If you find this software useful feel free to make a donation * to the project. For more information see the website or contact * the copyright holders. * */ #include <stddef.h> #include <time.h> #include <string.h> #include "common_types.h" #include "list.h" #include "avl.h" static struct avl_node *_avl_find_rec(struct avl_node *node, const void *key, avl_tree_comp comp, void *ptr, int *cmp_result); static void _avl_insert_before(struct avl_tree *tree, struct avl_node *pos_node, struct avl_node *node); static void _avl_insert_after(struct avl_tree *tree, struct avl_node *pos_node, struct avl_node *node); static void _post_insert(struct avl_tree *tree, struct avl_node *node); static void _avl_remove_worker(struct avl_tree *tree, struct avl_node *node); static void _avl_remove(struct avl_tree *tree, struct avl_node *node); static void _avl_rotate_right(struct avl_tree *tree, struct avl_node *node); static void _avl_rotate_left(struct avl_tree *tree, struct avl_node *node); static void _avl_post_remove(struct avl_tree *tree, struct avl_node *node); static struct avl_node *_avl_local_min(struct avl_node *node); /** * Initialize a new avl_tree struct * @param tree pointer to avl-tree * @param comp pointer to comparator for the tree * @param allow_dups true if the tree allows multiple * elements with the same * @param ptr custom parameter for comparator */ void avl_init(struct avl_tree *tree, avl_tree_comp comp, bool allow_dups, void *ptr) { list_init_head(&tree->list_head); tree->root = NULL; tree->count = 0; tree->comp = comp; tree->allow_dups = allow_dups; tree->cmp_ptr = ptr; } /** * Finds a node in an avl-tree with a certain key * @param tree pointer to avl-tree * @param key pointer to key * @return pointer to avl-node with key, NULL if no node with * this key exists. */ struct avl_node * avl_find(const struct avl_tree *tree, const void *key) { struct avl_node *node; int diff; if (tree->root == NULL) return NULL; node = _avl_find_rec(tree->root, key, tree->comp, tree->cmp_ptr, &diff); return diff == 0 ? node : NULL; } /** * Finds the last node in an avl-tree with a key less or equal * than the specified key * @param tree pointer to avl-tree * @param key pointer to specified key * @return pointer to avl-node, NULL if no node with * key less or equal specified key exists. */ struct avl_node * avl_find_lessequal(const struct avl_tree *tree, const void *key) { struct avl_node *node, *next; int diff; if (tree->root == NULL) return NULL; node = _avl_find_rec(tree->root, key, tree->comp, tree->cmp_ptr, &diff); /* go left as long as key<node.key */ while (diff < 0) { if (list_is_first(&tree->list_head, &node->list)) { return NULL; } node = (struct avl_node *)node->list.prev; diff = (*tree->comp) (key, node->key, tree->cmp_ptr); } /* go right as long as key>=next_node.key */ next = node; while (diff >= 0) { node = next; if (list_is_last(&tree->list_head, &node->list)) { break; } next = (struct avl_node *)node->list.next; diff = (*tree->comp) (key, next->key, tree->cmp_ptr); } return node; } /** * Finds the first node in an avl-tree with a key greater or equal * than the specified key * @param tree pointer to avl-tree * @param key pointer to specified key * @return pointer to avl-node, NULL if no node with * key greater or equal specified key exists. */ struct avl_node * avl_find_greaterequal(const struct avl_tree *tree, const void *key) { struct avl_node *node, *next; int diff; if (tree->root == NULL) return NULL; node = _avl_find_rec(tree->root, key, tree->comp, tree->cmp_ptr, &diff); /* go right as long as key>node.key */ while (diff > 0) { if (list_is_last(&tree->list_head, &node->list)) { return NULL; } node = (struct avl_node *)node->list.next; diff = (*tree->comp) (key, node->key, tree->cmp_ptr); } /* go left as long as key<=next_node.key */ next = node; while (diff <= 0) { node = next; if (list_is_first(&tree->list_head, &node->list)) { break; } next = (struct avl_node *)node->list.prev; diff = (*tree->comp) (key, next->key, tree->cmp_ptr); } return node; } /** * Inserts an avl_node into a tree * @param tree pointer to tree * @param new pointer to node * @return 0 if node was inserted successfully, -1 if it was not inserted * because of a key collision */ int avl_insert(struct avl_tree *tree, struct avl_node *new) { struct avl_node *node, *next, *last; int diff; new->parent = NULL; new->left = NULL; new->right = NULL; new->balance = 0; new->follower = false; if (tree->root == NULL) { list_add_head(&tree->list_head, &new->list); tree->root = new; tree->count = 1; return 0; } node = _avl_find_rec(tree->root, new->key, tree->comp, tree->cmp_ptr, &diff); last = node; while (!list_is_last(&tree->list_head, &last->list)) { next = list_next_element(last, list); if (!next->follower) { break; } last = next; } diff = (*tree->comp) (new->key, node->key, tree->cmp_ptr); if (diff == 0) { if (!tree->allow_dups) return -1; new->follower = true; /* add new node outside the tree, because key is already present */ _avl_insert_after(tree, last, new); return 0; } new->parent = node; if (node->balance == 1) { _avl_insert_before(tree, node, new); node->balance = 0; node->left = new; return 0; } if (node->balance == -1) { _avl_insert_after(tree, last, new); node->balance = 0; node->right = new; return 0; } if (diff < 0) { _avl_insert_before(tree, node, new); node->balance = -1; node->left = new; _post_insert(tree, node); } else { /* diff > 0 */ _avl_insert_after(tree, last, new); node->balance = 1; node->right = new; _post_insert(tree, node); } return 0; } /** * Remove a node from an avl tree * @param tree pointer to tree * @param node pointer to node */ void avl_remove(struct avl_tree *tree, struct avl_node *node) { struct avl_node *next; struct avl_node *parent; struct avl_node *left; struct avl_node *right; if (!node->follower) { if (tree->allow_dups && !list_is_last(&tree->list_head, &node->list) && (next = list_next_element(node, list))->follower) { next->follower = false; next->balance = node->balance; parent = node->parent; left = node->left; right = node->right; next->parent = parent; next->left = left; next->right = right; if (parent == NULL) tree->root = next; else { if (node == parent->left) parent->left = next; else parent->right = next; } if (left != NULL) left->parent = next; if (right != NULL) right->parent = next; } else _avl_remove_worker(tree, node); } _avl_remove(tree, node); } /** * Finds a record in an avl_tree corresponding (or close) * to a supplied key. * @param node pointer to avl_node to start tree lookup * @param key pointer to key * @param comp pointer to key comparator * @param cmp_ptr pointer to key comparator custom data * @param cmp_result pointer to an integer to store the final key comparison * @return pointer to result of the lookup (avl_node) */ static struct avl_node * _avl_find_rec(struct avl_node *node, const void *key, avl_tree_comp comp, void *cmp_ptr, int *cmp_result) { int diff; diff = (*comp) (key, node->key, cmp_ptr); *cmp_result = diff; if (diff < 0) { if (node->left != NULL) return _avl_find_rec(node->left, key, comp, cmp_ptr, cmp_result); return node; } if (diff > 0) { if (node->right != NULL) return _avl_find_rec(node->right, key, comp, cmp_ptr, cmp_result); return node; } return node; } /** * Rotate an avl_node to the right inside a avl_tree * @param tree pointer to tree * @param node pointer to node */ static void _avl_rotate_right(struct avl_tree *tree, struct avl_node *node) { struct avl_node *left, *parent; left = node->left; parent = node->parent; left->parent = parent; node->parent = left; if (parent == NULL) tree->root = left; else { if (parent->left == node) parent->left = left; else parent->right = left; } node->left = left->right; left->right = node; if (node->left != NULL) node->left->parent = node; //node->balance += 1 - _avl_min(left->balance, 0); //left->balance += 1 + _avl_max(node->balance, 0); node->balance++; if (left->balance < 0) { node->balance = (signed char)(node->balance - left->balance); } left->balance++; if (node->balance > 0) { left->balance = (signed char)(left->balance + node->balance); } } /** * Rotate an avl_node to the left inside a avl_tree * @param tree pointer to tree * @param node pointer to node */ static void _avl_rotate_left(struct avl_tree *tree, struct avl_node *node) { struct avl_node *right, *parent; right = node->right; parent = node->parent; right->parent = parent; node->parent = right; if (parent == NULL) tree->root = right; else { if (parent->left == node) parent->left = right; else parent->right = right; } node->right = right->left; right->left = node; if (node->right != NULL) node->right->parent = node; //node->balance -= 1 + _avl_max(right->balance, 0); //right->balance -= 1 - _avl_min(node->balance, 0); node->balance--; if (right->balance > 0) { node->balance = (signed char)(node->balance - right->balance); } right->balance--; if (node->balance < 0) { right->balance = (signed char)(right->balance + node->balance); } } /** * Rebalance the avl_tree after an insert * @param tree pointer to avl_tree * @param node pointer to inserted node */ static void _post_insert(struct avl_tree *tree, struct avl_node *node) { struct avl_node *parent = node->parent; if (parent == NULL) return; if (node == parent->left) { parent->balance--; if (parent->balance == 0) return; if (parent->balance == -1) { _post_insert(tree, parent); return; } if (node->balance == -1) { _avl_rotate_right(tree, parent); return; } _avl_rotate_left(tree, node); _avl_rotate_right(tree, node->parent->parent); return; } parent->balance++; if (parent->balance == 0) return; if (parent->balance == 1) { _post_insert(tree, parent); return; } if (node->balance == 1) { _avl_rotate_left(tree, parent); return; } _avl_rotate_right(tree, node); _avl_rotate_left(tree, node->parent->parent); } /** * Add an avl_node into the linked list before another node and * fix the object count of the tree * @param tree pointer to avl_tree * @param pos_node pointer to reference node * @param node pointer to node to be inserted */ static void _avl_insert_before(struct avl_tree *tree, struct avl_node *pos_node, struct avl_node *node) { list_add_before(&pos_node->list, &node->list); tree->count++; } /** * Add an avl_node into the linked list after another node and * fix the object count of the tree * @param tree pointer to avl_tree * @param pos_node pointer to reference node * @param node pointer to node to be inserted */ static void _avl_insert_after(struct avl_tree *tree, struct avl_node *pos_node, struct avl_node *node) { list_add_after(&pos_node->list, &node->list); tree->count++; } /** * Remove an avl_node from the linked list and * fix the object count of the tree * @param tree pointer to avl_tre * @param node pointer to avl_node to be removed */ static void _avl_remove(struct avl_tree *tree, struct avl_node *node) { list_remove(&node->list); tree->count--; } /** * Rebalance the avl_tree after a remove operation * @param tree pointer to avl_tree * @param node pointer to node which childs have to be * rebalanced. */static void _avl_post_remove(struct avl_tree *tree, struct avl_node *node) { struct avl_node *parent; if ((parent = node->parent) == NULL) return; if (node == parent->left) { parent->balance++; if (parent->balance == 0) { _avl_post_remove(tree, parent); return; } if (parent->balance == 1) return; if (parent->right->balance == 0) { _avl_rotate_left(tree, parent); return; } if (parent->right->balance == 1) { _avl_rotate_left(tree, parent); _avl_post_remove(tree, parent->parent); return; } _avl_rotate_right(tree, parent->right); _avl_rotate_left(tree, parent); _avl_post_remove(tree, parent->parent); return; } parent->balance--; if (parent->balance == 0) { _avl_post_remove(tree, parent); return; } if (parent->balance == -1) return; if (parent->left->balance == 0) { _avl_rotate_right(tree, parent); return; } if (parent->left->balance == -1) { _avl_rotate_right(tree, parent); _avl_post_remove(tree, parent->parent); return; } _avl_rotate_left(tree, parent->left); _avl_rotate_right(tree, parent); _avl_post_remove(tree, parent->parent); } /** * Iterate down the the left-most node of a tree * @param node pointer to node to start iterate with * @return left-most child of reference node */ static struct avl_node * _avl_local_min(struct avl_node *node) { while (node->left != NULL) node = node->left; return node; } #if 0 static struct avl_node * avl_local_max(struct avl_node *node) { while (node->right != NULL) node = node->right; return node; } #endif /** * Remove a node from a tree and rebalance it * @param tree pointer to tree * @param node pointer to node to be removed */ static void _avl_remove_worker(struct avl_tree *tree, struct avl_node *node) { struct avl_node *parent, *min; parent = node->parent; if (node->left == NULL && node->right == NULL) { if (parent == NULL) { tree->root = NULL; return; } if (parent->left == node) { parent->left = NULL; parent->balance++; if (parent->balance == 1) return; if (parent->balance == 0) { _avl_post_remove(tree, parent); return; } if (parent->right->balance == 0) { _avl_rotate_left(tree, parent); return; } if (parent->right->balance == 1) { _avl_rotate_left(tree, parent); _avl_post_remove(tree, parent->parent); return; } _avl_rotate_right(tree, parent->right); _avl_rotate_left(tree, parent); _avl_post_remove(tree, parent->parent); return; } if (parent->right == node) { parent->right = NULL; parent->balance--; if (parent->balance == -1) return; if (parent->balance == 0) { _avl_post_remove(tree, parent); return; } if (parent->left->balance == 0) { _avl_rotate_right(tree, parent); return; } if (parent->left->balance == -1) { _avl_rotate_right(tree, parent); _avl_post_remove(tree, parent->parent); return; } _avl_rotate_left(tree, parent->left); _avl_rotate_right(tree, parent); _avl_post_remove(tree, parent->parent); return; } } if (node->left == NULL) { if (parent == NULL) { tree->root = node->right; node->right->parent = NULL; return; } node->right->parent = parent; if (parent->left == node) parent->left = node->right; else parent->right = node->right; _avl_post_remove(tree, node->right); return; } if (node->right == NULL) { if (parent == NULL) { tree->root = node->left; node->left->parent = NULL; return; } node->left->parent = parent; if (parent->left == node) parent->left = node->left; else parent->right = node->left; _avl_post_remove(tree, node->left); return; } min = _avl_local_min(node->right); _avl_remove_worker(tree, min); parent = node->parent; min->balance = node->balance; min->parent = parent; min->left = node->left; min->right = node->right; if (min->left != NULL) min->left->parent = min; if (min->right != NULL) min->right->parent = min; if (parent == NULL) { tree->root = min; return; } if (parent->left == node) { parent->left = min; return; } parent->right = min; }
GraseHotspot/grase-coova-chilli
src/avl/avl.c
C
gpl-2.0
18,330
/* * Copyright (c) 2008-2011 Atheros Communications Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/dma-mapping.h> #include <linux/slab.h> #include <linux/ath9k_platform.h> #include <linux/module.h> #include <linux/relay.h> #include <net/ieee80211_radiotap.h> #include "ath9k.h" struct ath9k_eeprom_ctx { struct completion complete; struct ath_hw *ah; }; static char *dev_info = "ath9k"; MODULE_AUTHOR("Atheros Communications"); MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards."); MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards"); MODULE_LICENSE("Dual BSD/GPL"); static unsigned int ath9k_debug = ATH_DBG_DEFAULT; module_param_named(debug, ath9k_debug, uint, 0); MODULE_PARM_DESC(debug, "Debugging mask"); int ath9k_modparam_nohwcrypt; module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444); MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); int led_blink; module_param_named(blink, led_blink, int, 0444); MODULE_PARM_DESC(blink, "Enable LED blink on activity"); static int ath9k_btcoex_enable; module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444); MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); static int ath9k_bt_ant_diversity; module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444); MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity"); static int ath9k_ps_enable; module_param_named(ps_enable, ath9k_ps_enable, int, 0444); MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave"); bool is_ath9k_unloaded; /* We use the hw_value as an index into our private channel structure */ #define CHAN2G(_freq, _idx) { \ .band = IEEE80211_BAND_2GHZ, \ .center_freq = (_freq), \ .hw_value = (_idx), \ .max_power = 20, \ } #define CHAN5G(_freq, _idx) { \ .band = IEEE80211_BAND_5GHZ, \ .center_freq = (_freq), \ .hw_value = (_idx), \ .max_power = 20, \ } /* Some 2 GHz radios are actually tunable on 2312-2732 * on 5 MHz steps, we support the channels which we know * we have calibration data for all cards though to make * this static */ static const struct ieee80211_channel ath9k_2ghz_chantable[] = { CHAN2G(2412, 0), /* Channel 1 */ CHAN2G(2417, 1), /* Channel 2 */ CHAN2G(2422, 2), /* Channel 3 */ CHAN2G(2427, 3), /* Channel 4 */ CHAN2G(2432, 4), /* Channel 5 */ CHAN2G(2437, 5), /* Channel 6 */ CHAN2G(2442, 6), /* Channel 7 */ CHAN2G(2447, 7), /* Channel 8 */ CHAN2G(2452, 8), /* Channel 9 */ CHAN2G(2457, 9), /* Channel 10 */ CHAN2G(2462, 10), /* Channel 11 */ CHAN2G(2467, 11), /* Channel 12 */ CHAN2G(2472, 12), /* Channel 13 */ CHAN2G(2484, 13), /* Channel 14 */ }; /* Some 5 GHz radios are actually tunable on XXXX-YYYY * on 5 MHz steps, we support the channels which we know * we have calibration data for all cards though to make * this static */ static const struct ieee80211_channel ath9k_5ghz_chantable[] = { /* _We_ call this UNII 1 */ CHAN5G(5180, 14), /* Channel 36 */ CHAN5G(5200, 15), /* Channel 40 */ CHAN5G(5220, 16), /* Channel 44 */ CHAN5G(5240, 17), /* Channel 48 */ /* _We_ call this UNII 2 */ CHAN5G(5260, 18), /* Channel 52 */ CHAN5G(5280, 19), /* Channel 56 */ CHAN5G(5300, 20), /* Channel 60 */ CHAN5G(5320, 21), /* Channel 64 */ /* _We_ call this "Middle band" */ CHAN5G(5500, 22), /* Channel 100 */ CHAN5G(5520, 23), /* Channel 104 */ CHAN5G(5540, 24), /* Channel 108 */ CHAN5G(5560, 25), /* Channel 112 */ CHAN5G(5580, 26), /* Channel 116 */ CHAN5G(5600, 27), /* Channel 120 */ CHAN5G(5620, 28), /* Channel 124 */ CHAN5G(5640, 29), /* Channel 128 */ CHAN5G(5660, 30), /* Channel 132 */ CHAN5G(5680, 31), /* Channel 136 */ CHAN5G(5700, 32), /* Channel 140 */ /* _We_ call this UNII 3 */ CHAN5G(5745, 33), /* Channel 149 */ CHAN5G(5765, 34), /* Channel 153 */ CHAN5G(5785, 35), /* Channel 157 */ CHAN5G(5805, 36), /* Channel 161 */ CHAN5G(5825, 37), /* Channel 165 */ }; /* Atheros hardware rate code addition for short premble */ #define SHPCHECK(__hw_rate, __flags) \ ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0) #define RATE(_bitrate, _hw_rate, _flags) { \ .bitrate = (_bitrate), \ .flags = (_flags), \ .hw_value = (_hw_rate), \ .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \ } static struct ieee80211_rate ath9k_legacy_rates[] = { RATE(10, 0x1b, 0), RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE), RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE), RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE), RATE(60, 0x0b, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(90, 0x0f, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(120, 0x0a, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(180, 0x0e, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(240, 0x09, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(360, 0x0d, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(480, 0x08, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), RATE(540, 0x0c, (IEEE80211_RATE_SUPPORTS_5MHZ | IEEE80211_RATE_SUPPORTS_10MHZ)), }; #ifdef CONFIG_MAC80211_LEDS static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = { { .throughput = 0 * 1024, .blink_time = 334 }, { .throughput = 1 * 1024, .blink_time = 260 }, { .throughput = 5 * 1024, .blink_time = 220 }, { .throughput = 10 * 1024, .blink_time = 190 }, { .throughput = 20 * 1024, .blink_time = 170 }, { .throughput = 50 * 1024, .blink_time = 150 }, { .throughput = 70 * 1024, .blink_time = 130 }, { .throughput = 100 * 1024, .blink_time = 110 }, { .throughput = 200 * 1024, .blink_time = 80 }, { .throughput = 300 * 1024, .blink_time = 50 }, }; #endif static void ath9k_deinit_softc(struct ath_softc *sc); /* * Read and write, they both share the same lock. We do this to serialize * reads and writes on Atheros 802.11n PCI devices only. This is required * as the FIFO on these devices can only accept sanely 2 requests. */ static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath_softc *sc = (struct ath_softc *) common->priv; if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { unsigned long flags; spin_lock_irqsave(&sc->sc_serial_rw, flags); iowrite32(val, sc->mem + reg_offset); spin_unlock_irqrestore(&sc->sc_serial_rw, flags); } else iowrite32(val, sc->mem + reg_offset); } static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath_softc *sc = (struct ath_softc *) common->priv; u32 val; if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { unsigned long flags; spin_lock_irqsave(&sc->sc_serial_rw, flags); val = ioread32(sc->mem + reg_offset); spin_unlock_irqrestore(&sc->sc_serial_rw, flags); } else val = ioread32(sc->mem + reg_offset); return val; } static unsigned int __ath9k_reg_rmw(struct ath_softc *sc, u32 reg_offset, u32 set, u32 clr) { u32 val; val = ioread32(sc->mem + reg_offset); val &= ~clr; val |= set; iowrite32(val, sc->mem + reg_offset); return val; } static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 clr) { struct ath_hw *ah = (struct ath_hw *) hw_priv; struct ath_common *common = ath9k_hw_common(ah); struct ath_softc *sc = (struct ath_softc *) common->priv; unsigned long uninitialized_var(flags); u32 val; if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { spin_lock_irqsave(&sc->sc_serial_rw, flags); val = __ath9k_reg_rmw(sc, reg_offset, set, clr); spin_unlock_irqrestore(&sc->sc_serial_rw, flags); } else val = __ath9k_reg_rmw(sc, reg_offset, set, clr); return val; } /**************************/ /* Initialization */ /**************************/ static void setup_ht_cap(struct ath_softc *sc, struct ieee80211_sta_ht_cap *ht_info) { struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); u8 tx_streams, rx_streams; int i, max_streams; ht_info->ht_supported = true; ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SM_PS | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_DSSSCCK40; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_LDPC) ht_info->cap |= IEEE80211_HT_CAP_LDPC_CODING; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20) ht_info->cap |= IEEE80211_HT_CAP_SGI_20; ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_8; if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) max_streams = 1; else if (AR_SREV_9462(ah)) max_streams = 2; else if (AR_SREV_9300_20_OR_LATER(ah)) max_streams = 3; else max_streams = 2; if (AR_SREV_9280_20_OR_LATER(ah)) { if (max_streams >= 2) ht_info->cap |= IEEE80211_HT_CAP_TX_STBC; ht_info->cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); } /* set up supported mcs set */ memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); tx_streams = ath9k_cmn_count_streams(ah->txchainmask, max_streams); rx_streams = ath9k_cmn_count_streams(ah->rxchainmask, max_streams); ath_dbg(common, CONFIG, "TX streams %d, RX streams: %d\n", tx_streams, rx_streams); if (tx_streams != rx_streams) { ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; ht_info->mcs.tx_params |= ((tx_streams - 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); } for (i = 0; i < rx_streams; i++) ht_info->mcs.rx_mask[i] = 0xff; ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED; } static void ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) { struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); struct ath_softc *sc = hw->priv; struct ath_hw *ah = sc->sc_ah; struct ath_regulatory *reg = ath9k_hw_regulatory(ah); ath_reg_notifier_apply(wiphy, request, reg); /* Set tx power */ if (ah->curchan) { sc->config.txpowlimit = 2 * ah->curchan->chan->max_power; ath9k_ps_wakeup(sc); ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false); sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit; /* synchronize DFS detector if regulatory domain changed */ if (sc->dfs_detector != NULL) sc->dfs_detector->set_dfs_domain(sc->dfs_detector, request->dfs_region); ath9k_ps_restore(sc); } } /* * This function will allocate both the DMA descriptor structure, and the * buffers it contains. These are used to contain the descriptors used * by the system. */ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, struct list_head *head, const char *name, int nbuf, int ndesc, bool is_tx) { struct ath_common *common = ath9k_hw_common(sc->sc_ah); u8 *ds; int i, bsize, desc_len; ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n", name, nbuf, ndesc); INIT_LIST_HEAD(head); if (is_tx) desc_len = sc->sc_ah->caps.tx_desc_len; else desc_len = sizeof(struct ath_desc); /* ath_desc must be a multiple of DWORDs */ if ((desc_len % 4) != 0) { ath_err(common, "ath_desc not DWORD aligned\n"); BUG_ON((desc_len % 4) != 0); return -ENOMEM; } dd->dd_desc_len = desc_len * nbuf * ndesc; /* * Need additional DMA memory because we can't use * descriptors that cross the 4K page boundary. Assume * one skipped descriptor per 4K page. */ if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) { u32 ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dd->dd_desc_len); u32 dma_len; while (ndesc_skipped) { dma_len = ndesc_skipped * desc_len; dd->dd_desc_len += dma_len; ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dma_len); } } /* allocate descriptors */ dd->dd_desc = dmam_alloc_coherent(sc->dev, dd->dd_desc_len, &dd->dd_desc_paddr, GFP_KERNEL); if (!dd->dd_desc) return -ENOMEM; ds = (u8 *) dd->dd_desc; ath_dbg(common, CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n", name, ds, (u32) dd->dd_desc_len, ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len); /* allocate buffers */ if (is_tx) { struct ath_buf *bf; bsize = sizeof(struct ath_buf) * nbuf; bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); if (!bf) return -ENOMEM; for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) { bf->bf_desc = ds; bf->bf_daddr = DS2PHYS(dd, ds); if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) { /* * Skip descriptor addresses which can cause 4KB * boundary crossing (addr + length) with a 32 dword * descriptor fetch. */ while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) { BUG_ON((caddr_t) bf->bf_desc >= ((caddr_t) dd->dd_desc + dd->dd_desc_len)); ds += (desc_len * ndesc); bf->bf_desc = ds; bf->bf_daddr = DS2PHYS(dd, ds); } } list_add_tail(&bf->list, head); } } else { struct ath_rxbuf *bf; bsize = sizeof(struct ath_rxbuf) * nbuf; bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); if (!bf) return -ENOMEM; for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) { bf->bf_desc = ds; bf->bf_daddr = DS2PHYS(dd, ds); if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) { /* * Skip descriptor addresses which can cause 4KB * boundary crossing (addr + length) with a 32 dword * descriptor fetch. */ while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) { BUG_ON((caddr_t) bf->bf_desc >= ((caddr_t) dd->dd_desc + dd->dd_desc_len)); ds += (desc_len * ndesc); bf->bf_desc = ds; bf->bf_daddr = DS2PHYS(dd, ds); } } list_add_tail(&bf->list, head); } } return 0; } static int ath9k_init_queues(struct ath_softc *sc) { int i = 0; sc->beacon.beaconq = ath9k_hw_beaconq_setup(sc->sc_ah); sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0); ath_cabq_update(sc); sc->tx.uapsdq = ath_txq_setup(sc, ATH9K_TX_QUEUE_UAPSD, 0); for (i = 0; i < IEEE80211_NUM_ACS; i++) { sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i); sc->tx.txq_map[i]->mac80211_qnum = i; sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH; } return 0; } static int ath9k_init_channels_rates(struct ath_softc *sc) { void *channels; BUILD_BUG_ON(ARRAY_SIZE(ath9k_2ghz_chantable) + ARRAY_SIZE(ath9k_5ghz_chantable) != ATH9K_NUM_CHANNELS); if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) { channels = devm_kzalloc(sc->dev, sizeof(ath9k_2ghz_chantable), GFP_KERNEL); if (!channels) return -ENOMEM; memcpy(channels, ath9k_2ghz_chantable, sizeof(ath9k_2ghz_chantable)); sc->sbands[IEEE80211_BAND_2GHZ].channels = channels; sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; sc->sbands[IEEE80211_BAND_2GHZ].n_channels = ARRAY_SIZE(ath9k_2ghz_chantable); sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates; sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates = ARRAY_SIZE(ath9k_legacy_rates); } if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) { channels = devm_kzalloc(sc->dev, sizeof(ath9k_5ghz_chantable), GFP_KERNEL); if (!channels) return -ENOMEM; memcpy(channels, ath9k_5ghz_chantable, sizeof(ath9k_5ghz_chantable)); sc->sbands[IEEE80211_BAND_5GHZ].channels = channels; sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; sc->sbands[IEEE80211_BAND_5GHZ].n_channels = ARRAY_SIZE(ath9k_5ghz_chantable); sc->sbands[IEEE80211_BAND_5GHZ].bitrates = ath9k_legacy_rates + 4; sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates = ARRAY_SIZE(ath9k_legacy_rates) - 4; } return 0; } static void ath9k_init_misc(struct ath_softc *sc) { struct ath_common *common = ath9k_hw_common(sc->sc_ah); int i = 0; setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc); sc->last_rssi = ATH_RSSI_DUMMY_MARKER; sc->config.txpowlimit = ATH_TXPOWER_MAX; memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); sc->beacon.slottime = ATH9K_SLOT_TIME_9; for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) sc->beacon.bslot[i] = NULL; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; sc->spec_config.enabled = 0; sc->spec_config.short_repeat = true; sc->spec_config.count = 8; sc->spec_config.endless = false; sc->spec_config.period = 0xFF; sc->spec_config.fft_period = 0xF; } static void ath9k_init_pcoem_platform(struct ath_softc *sc) { struct ath_hw *ah = sc->sc_ah; struct ath9k_hw_capabilities *pCap = &ah->caps; struct ath_common *common = ath9k_hw_common(ah); if (common->bus_ops->ath_bus_type != ATH_PCI) return; if (sc->driver_data & (ATH9K_PCI_CUS198 | ATH9K_PCI_CUS230)) { ah->config.xlna_gpio = 9; ah->config.xatten_margin_cfg = true; ah->config.alt_mingainidx = true; ah->config.ant_ctrl_comm2g_switch_enable = 0x000BBB88; sc->ant_comb.low_rssi_thresh = 20; sc->ant_comb.fast_div_bias = 3; ath_info(common, "Set parameters for %s\n", (sc->driver_data & ATH9K_PCI_CUS198) ? "CUS198" : "CUS230"); } if (sc->driver_data & ATH9K_PCI_CUS217) ath_info(common, "CUS217 card detected\n"); if (sc->driver_data & ATH9K_PCI_CUS252) ath_info(common, "CUS252 card detected\n"); if (sc->driver_data & ATH9K_PCI_AR9565_1ANT) ath_info(common, "WB335 1-ANT card detected\n"); if (sc->driver_data & ATH9K_PCI_AR9565_2ANT) ath_info(common, "WB335 2-ANT card detected\n"); if (sc->driver_data & ATH9K_PCI_KILLER) ath_info(common, "Killer Wireless card detected\n"); /* * Some WB335 cards do not support antenna diversity. Since * we use a hardcoded value for AR9565 instead of using the * EEPROM/OTP data, remove the combining feature from * the HW capabilities bitmap. */ if (sc->driver_data & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { if (!(sc->driver_data & ATH9K_PCI_BT_ANT_DIV)) pCap->hw_caps &= ~ATH9K_HW_CAP_ANT_DIV_COMB; } if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) { pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV; ath_info(common, "Set BT/WLAN RX diversity capability\n"); } if (sc->driver_data & ATH9K_PCI_D3_L1_WAR) { ah->config.pcie_waen = 0x0040473b; ath_info(common, "Enable WAR for ASPM D3/L1\n"); } if (sc->driver_data & ATH9K_PCI_NO_PLL_PWRSAVE) { ah->config.no_pll_pwrsave = true; ath_info(common, "Disable PLL PowerSave\n"); } } static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob, void *ctx) { struct ath9k_eeprom_ctx *ec = ctx; if (eeprom_blob) ec->ah->eeprom_blob = eeprom_blob; complete(&ec->complete); } static int ath9k_eeprom_request(struct ath_softc *sc, const char *name) { struct ath9k_eeprom_ctx ec; struct ath_hw *ah = ah = sc->sc_ah; int err; /* try to load the EEPROM content asynchronously */ init_completion(&ec.complete); ec.ah = sc->sc_ah; err = request_firmware_nowait(THIS_MODULE, 1, name, sc->dev, GFP_KERNEL, &ec, ath9k_eeprom_request_cb); if (err < 0) { ath_err(ath9k_hw_common(ah), "EEPROM request failed\n"); return err; } wait_for_completion(&ec.complete); if (!ah->eeprom_blob) { ath_err(ath9k_hw_common(ah), "Unable to load EEPROM file %s\n", name); return -EINVAL; } return 0; } static void ath9k_eeprom_release(struct ath_softc *sc) { release_firmware(sc->sc_ah->eeprom_blob); } static int ath9k_init_soc_platform(struct ath_softc *sc) { struct ath9k_platform_data *pdata = sc->dev->platform_data; struct ath_hw *ah = sc->sc_ah; int ret = 0; if (!pdata) return 0; if (pdata->eeprom_name) { ret = ath9k_eeprom_request(sc, pdata->eeprom_name); if (ret) return ret; } if (pdata->tx_gain_buffalo) ah->config.tx_gain_buffalo = true; return ret; } static int ath9k_init_softc(u16 devid, struct ath_softc *sc, const struct ath_bus_ops *bus_ops) { struct ath9k_platform_data *pdata = sc->dev->platform_data; struct ath_hw *ah = NULL; struct ath9k_hw_capabilities *pCap; struct ath_common *common; int ret = 0, i; int csz = 0; ah = devm_kzalloc(sc->dev, sizeof(struct ath_hw), GFP_KERNEL); if (!ah) return -ENOMEM; ah->dev = sc->dev; ah->hw = sc->hw; ah->hw_version.devid = devid; ah->reg_ops.read = ath9k_ioread32; ah->reg_ops.write = ath9k_iowrite32; ah->reg_ops.rmw = ath9k_reg_rmw; sc->sc_ah = ah; pCap = &ah->caps; common = ath9k_hw_common(ah); sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET); sc->tx99_power = MAX_RATE_POWER + 1; init_waitqueue_head(&sc->tx_wait); if (!pdata) { ah->ah_flags |= AH_USE_EEPROM; sc->sc_ah->led_pin = -1; } else { sc->sc_ah->gpio_mask = pdata->gpio_mask; sc->sc_ah->gpio_val = pdata->gpio_val; sc->sc_ah->led_pin = pdata->led_pin; ah->is_clk_25mhz = pdata->is_clk_25mhz; ah->get_mac_revision = pdata->get_mac_revision; ah->external_reset = pdata->external_reset; } common->ops = &ah->reg_ops; common->bus_ops = bus_ops; common->ah = ah; common->hw = sc->hw; common->priv = sc; common->debug_mask = ath9k_debug; common->btcoex_enabled = ath9k_btcoex_enable == 1; common->disable_ani = false; /* * Platform quirks. */ ath9k_init_pcoem_platform(sc); ret = ath9k_init_soc_platform(sc); if (ret) return ret; /* * Enable WLAN/BT RX Antenna diversity only when: * * - BTCOEX is disabled. * - the user manually requests the feature. * - the HW cap is set using the platform data. */ if (!common->btcoex_enabled && ath9k_bt_ant_diversity && (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) common->bt_ant_diversity = 1; spin_lock_init(&common->cc_lock); spin_lock_init(&sc->sc_serial_rw); spin_lock_init(&sc->sc_pm_lock); mutex_init(&sc->mutex); tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet, (unsigned long)sc); setup_timer(&sc->sleep_timer, ath_ps_full_sleep, (unsigned long)sc); INIT_WORK(&sc->hw_reset_work, ath_reset_work); INIT_WORK(&sc->paprd_work, ath_paprd_calibrate); INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work); /* * Cache line size is used to size and align various * structures used to communicate with the hardware. */ ath_read_cachesize(common, &csz); common->cachelsz = csz << 2; /* convert to bytes */ /* Initializes the hardware for all supported chipsets */ ret = ath9k_hw_init(ah); if (ret) goto err_hw; if (pdata && pdata->macaddr) memcpy(common->macaddr, pdata->macaddr, ETH_ALEN); ret = ath9k_init_queues(sc); if (ret) goto err_queues; ret = ath9k_init_btcoex(sc); if (ret) goto err_btcoex; ret = ath9k_init_channels_rates(sc); if (ret) goto err_btcoex; ath9k_cmn_init_crypto(sc->sc_ah); ath9k_init_misc(sc); ath_fill_led_pin(sc); if (common->bus_ops->aspm_init) common->bus_ops->aspm_init(common); return 0; err_btcoex: for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) if (ATH_TXQ_SETUP(sc, i)) ath_tx_cleanupq(sc, &sc->tx.txq[i]); err_queues: ath9k_hw_deinit(ah); err_hw: ath9k_eeprom_release(sc); dev_kfree_skb_any(sc->tx99_skb); return ret; } static void ath9k_init_band_txpower(struct ath_softc *sc, int band) { struct ieee80211_supported_band *sband; struct ieee80211_channel *chan; struct ath_hw *ah = sc->sc_ah; struct cfg80211_chan_def chandef; int i; sband = &sc->sbands[band]; for (i = 0; i < sband->n_channels; i++) { chan = &sband->channels[i]; ah->curchan = &ah->channels[chan->hw_value]; cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_HT20); ath9k_cmn_get_channel(sc->hw, ah, &chandef); ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); } } static void ath9k_init_txpower_limits(struct ath_softc *sc) { struct ath_hw *ah = sc->sc_ah; struct ath9k_channel *curchan = ah->curchan; if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ); if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ); ah->curchan = curchan; } void ath9k_reload_chainmask_settings(struct ath_softc *sc) { if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)) return; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap); if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap); } static const struct ieee80211_iface_limit if_limits[] = { { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_WDS) }, { .max = 8, .types = #ifdef CONFIG_MAC80211_MESH BIT(NL80211_IFTYPE_MESH_POINT) | #endif BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_P2P_GO) }, }; static const struct ieee80211_iface_limit if_dfs_limits[] = { { .max = 1, .types = BIT(NL80211_IFTYPE_AP) | #ifdef CONFIG_MAC80211_MESH BIT(NL80211_IFTYPE_MESH_POINT) | #endif BIT(NL80211_IFTYPE_ADHOC) }, }; static const struct ieee80211_iface_combination if_comb[] = { { .limits = if_limits, .n_limits = ARRAY_SIZE(if_limits), .max_interfaces = 2048, .num_different_channels = 1, .beacon_int_infra_match = true, }, { .limits = if_dfs_limits, .n_limits = ARRAY_SIZE(if_dfs_limits), .max_interfaces = 1, .num_different_channels = 1, .beacon_int_infra_match = true, .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | BIT(NL80211_CHAN_WIDTH_20), } }; static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) { struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_PS_NULLFUNC_STACK | IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_REPORTS_TX_ACK_STATUS | IEEE80211_HW_SUPPORTS_RC_TABLE | IEEE80211_HW_SUPPORTS_HT_CCK_RATES; if (ath9k_ps_enable) hw->flags |= IEEE80211_HW_SUPPORTS_PS; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION; if (AR_SREV_9280_20_OR_LATER(ah)) hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_STBC; } if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || ath9k_modparam_nohwcrypt) hw->flags |= IEEE80211_HW_MFP_CAPABLE; hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR; if (!config_enabled(CONFIG_ATH9K_TX99)) { hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_WDS) | BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_MESH_POINT); hw->wiphy->iface_combinations = if_comb; hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); } hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ; hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; hw->queues = 4; hw->max_rates = 4; hw->max_listen_interval = 1; hw->max_rate_tries = 10; hw->sta_data_size = sizeof(struct ath_node); hw->vif_data_size = sizeof(struct ath_vif); hw->extra_tx_headroom = 4; hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1; /* single chain devices with rx diversity */ if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) hw->wiphy->available_antennas_rx = BIT(0) | BIT(1); sc->ant_rx = hw->wiphy->available_antennas_rx; sc->ant_tx = hw->wiphy->available_antennas_tx; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &sc->sbands[IEEE80211_BAND_2GHZ]; if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &sc->sbands[IEEE80211_BAND_5GHZ]; ath9k_init_wow(hw); ath9k_reload_chainmask_settings(sc); SET_IEEE80211_PERM_ADDR(hw, common->macaddr); } int ath9k_init_device(u16 devid, struct ath_softc *sc, const struct ath_bus_ops *bus_ops) { struct ieee80211_hw *hw = sc->hw; struct ath_common *common; struct ath_hw *ah; int error = 0; struct ath_regulatory *reg; /* Bring up device */ error = ath9k_init_softc(devid, sc, bus_ops); if (error) return error; ah = sc->sc_ah; common = ath9k_hw_common(ah); ath9k_set_hw_capab(sc, hw); /* Initialize regulatory */ error = ath_regd_init(&common->regulatory, sc->hw->wiphy, ath9k_reg_notifier); if (error) goto deinit; reg = &common->regulatory; /* Setup TX DMA */ error = ath_tx_init(sc, ATH_TXBUF); if (error != 0) goto deinit; /* Setup RX DMA */ error = ath_rx_init(sc, ATH_RXBUF); if (error != 0) goto deinit; ath9k_init_txpower_limits(sc); #ifdef CONFIG_MAC80211_LEDS /* must be initialized before ieee80211_register_hw */ sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw, IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink, ARRAY_SIZE(ath9k_tpt_blink)); #endif /* Register with mac80211 */ error = ieee80211_register_hw(hw); if (error) goto rx_cleanup; error = ath9k_init_debug(ah); if (error) { ath_err(common, "Unable to create debugfs files\n"); goto unregister; } /* Handle world regulatory */ if (!ath_is_world_regd(reg)) { error = regulatory_hint(hw->wiphy, reg->alpha2); if (error) goto debug_cleanup; } ath_init_leds(sc); ath_start_rfkill_poll(sc); return 0; debug_cleanup: ath9k_deinit_debug(sc); unregister: ieee80211_unregister_hw(hw); rx_cleanup: ath_rx_cleanup(sc); deinit: ath9k_deinit_softc(sc); return error; } /*****************************/ /* De-Initialization */ /*****************************/ static void ath9k_deinit_softc(struct ath_softc *sc) { int i = 0; ath9k_deinit_btcoex(sc); for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) if (ATH_TXQ_SETUP(sc, i)) ath_tx_cleanupq(sc, &sc->tx.txq[i]); del_timer_sync(&sc->sleep_timer); ath9k_hw_deinit(sc->sc_ah); if (sc->dfs_detector != NULL) sc->dfs_detector->exit(sc->dfs_detector); ath9k_eeprom_release(sc); } void ath9k_deinit_device(struct ath_softc *sc) { struct ieee80211_hw *hw = sc->hw; ath9k_ps_wakeup(sc); wiphy_rfkill_stop_polling(sc->hw->wiphy); ath_deinit_leds(sc); ath9k_ps_restore(sc); ath9k_deinit_debug(sc); ieee80211_unregister_hw(hw); ath_rx_cleanup(sc); ath9k_deinit_softc(sc); } /************************/ /* Module Hooks */ /************************/ static int __init ath9k_init(void) { int error; /* Register rate control algorithm */ error = ath_rate_control_register(); if (error != 0) { pr_err("Unable to register rate control algorithm: %d\n", error); goto err_out; } error = ath_pci_init(); if (error < 0) { pr_err("No PCI devices found, driver not installed\n"); error = -ENODEV; goto err_rate_unregister; } error = ath_ahb_init(); if (error < 0) { error = -ENODEV; goto err_pci_exit; } return 0; err_pci_exit: ath_pci_exit(); err_rate_unregister: ath_rate_control_unregister(); err_out: return error; } module_init(ath9k_init); static void __exit ath9k_exit(void) { is_ath9k_unloaded = true; ath_ahb_exit(); ath_pci_exit(); ath_rate_control_unregister(); pr_info("%s: Driver unloaded\n", dev_info); } module_exit(ath9k_exit);
FEDEVEL/openrex-linux-3.14
drivers/net/wireless/ath/ath9k/init.c
C
gpl-2.0
32,112
/* * Gadget Driver for Android * * Copyright (C) 2008 Google, Inc. * Author: Mike Lockwood <lockwood@android.com> * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. * */ /* #define DEBUG */ /* #define VERBOSE_DEBUG */ #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/delay.h> #include <linux/kernel.h> #include <linux/utsname.h> #include <linux/platform_device.h> #include <linux/usb/ch9.h> #include <linux/usb/composite.h> #include <linux/usb/gadget.h> #include <linux/usb/android_composite.h> #include "gadget_chips.h" /* * Kbuild is not very cooperative with respect to linking separately * compiled library objects into one module. So for now we won't use * separate compilation ... ensuring init/exit sections work to shrink * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "composite.c" #include "f_mass_storage.c" #include "u_serial.c" #ifdef CONFIG_USB_DUN_SUPPORT #include "serial_acm.c" #endif #include "f_acm.c" #include "f_adb.c" #ifdef CONFIG_USB_ANDROID_SAMSUNG_MTP #include "f_mtp_samsung.c" #else #include "f_mtp.c" #endif #include "f_accessory.c" #define USB_ETH_RNDIS y #include "f_rndis.c" #include "rndis.c" #include "u_ether.c" MODULE_AUTHOR("Mike Lockwood"); MODULE_DESCRIPTION("Android Composite USB Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION("1.0"); static const char longname[] = "Gadget Android"; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE static int composite_string_index; #endif /* Default vendor and product IDs, overridden by userspace */ #define VENDOR_ID 0x18D1 #define PRODUCT_ID 0x0001 struct android_usb_function { char *name; void *config; struct device *dev; char *dev_name; struct device_attribute **attributes; /* for android_dev.enabled_functions */ struct list_head enabled_list; /* Optional: initialization during gadget bind */ int (*init)(struct android_usb_function *, struct usb_composite_dev *); /* Optional: cleanup during gadget unbind */ void (*cleanup)(struct android_usb_function *); int (*bind_config)(struct android_usb_function *, struct usb_configuration *); /* Optional: called when the configuration is removed */ void (*unbind_config)(struct android_usb_function *, struct usb_configuration *); /* Optional: handle ctrl requests before the device is configured */ int (*ctrlrequest)(struct android_usb_function *, struct usb_composite_dev *, const struct usb_ctrlrequest *); }; struct android_dev { struct android_usb_function **functions; struct list_head enabled_functions; struct usb_composite_dev *cdev; struct device *dev; bool enabled; struct mutex mutex; bool connected; bool sw_connected; struct work_struct work; }; static struct class *android_class; static struct android_dev *_android_dev; static int android_bind_config(struct usb_configuration *c); static void android_unbind_config(struct usb_configuration *c); #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE static struct android_usb_platform_data *android_usb_pdata; #endif /* string IDs are assigned dynamically */ #define STRING_MANUFACTURER_IDX 0 #define STRING_PRODUCT_IDX 1 #define STRING_SERIAL_IDX 2 static char manufacturer_string[256]; static char product_string[256]; static char serial_string[256]; /* String Table */ static struct usb_string strings_dev[] = { [STRING_MANUFACTURER_IDX].s = manufacturer_string, [STRING_PRODUCT_IDX].s = product_string, [STRING_SERIAL_IDX].s = serial_string, { } /* end of list */ }; static struct usb_gadget_strings stringtab_dev = { .language = 0x0409, /* en-us */ .strings = strings_dev, }; static struct usb_gadget_strings *dev_strings[] = { &stringtab_dev, NULL, }; static struct usb_device_descriptor device_desc = { .bLength = sizeof(device_desc), .bDescriptorType = USB_DT_DEVICE, .bcdUSB = __constant_cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PER_INTERFACE, .idVendor = __constant_cpu_to_le16(VENDOR_ID), .idProduct = __constant_cpu_to_le16(PRODUCT_ID), .bcdDevice = __constant_cpu_to_le16(0xffff), .bNumConfigurations = 1, }; static struct usb_configuration android_config_driver = { .label = "android", .unbind = android_unbind_config, .bConfigurationValue = 1, }; static void android_work(struct work_struct *data) { struct android_dev *dev = container_of(data, struct android_dev, work); struct usb_composite_dev *cdev = dev->cdev; char *disconnected[2] = { "USB_STATE=DISCONNECTED", NULL }; char *connected[2] = { "USB_STATE=CONNECTED", NULL }; char *configured[2] = { "USB_STATE=CONFIGURED", NULL }; char **uevent_envp = NULL; unsigned long flags; printk(KERN_DEBUG "usb: %s config=%p,connected=%d,sw_connected=%d\n", __func__, cdev->config, dev->connected, dev->sw_connected); spin_lock_irqsave(&cdev->lock, flags); if (cdev->config) uevent_envp = configured; else if (dev->connected != dev->sw_connected) uevent_envp = dev->connected ? connected : disconnected; dev->sw_connected = dev->connected; spin_unlock_irqrestore(&cdev->lock, flags); if (uevent_envp) { kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, uevent_envp); pr_info("%s: sent uevent %s\n", __func__, uevent_envp[0]); } else { pr_info("%s: did not send uevent (%d %d %p)\n", __func__, dev->connected, dev->sw_connected, cdev->config); } } /*-------------------------------------------------------------------------*/ /* Supported functions initialization */ static int adb_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return adb_setup(); } static void adb_function_cleanup(struct android_usb_function *f) { adb_cleanup(); } static int adb_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return adb_bind_config(c); } static struct android_usb_function adb_function = { .name = "adb", .init = adb_function_init, .cleanup = adb_function_cleanup, .bind_config = adb_function_bind_config, }; #define MAX_ACM_INSTANCES 4 struct acm_function_config { int instances; }; static int acm_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { int ret; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE struct acm_function_config *config; #endif f->config = kzalloc(sizeof(struct acm_function_config), GFP_KERNEL); if (!f->config) return -ENOMEM; ret = gserial_setup(cdev->gadget, MAX_ACM_INSTANCES); #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE /* default setting */ config = f->config; config->instances = 1; #endif return ret; } static void acm_function_cleanup(struct android_usb_function *f) { gserial_cleanup(); kfree(f->config); f->config = NULL; } static int acm_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int i; int ret = 0; struct acm_function_config *config = f->config; for (i = 0; i < config->instances; i++) { ret = acm_bind_config(c, i); if (ret) { pr_err("Could not bind acm%u config\n", i); break; } } return ret; } static ssize_t acm_instances_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct acm_function_config *config = f->config; return sprintf(buf, "%d\n", config->instances); } static ssize_t acm_instances_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct acm_function_config *config = f->config; int value; sscanf(buf, "%d", &value); if (value > MAX_ACM_INSTANCES) value = MAX_ACM_INSTANCES; config->instances = value; return size; } static DEVICE_ATTR(instances, S_IRUGO | S_IWUSR, acm_instances_show, acm_instances_store); static struct device_attribute *acm_function_attributes[] = { &dev_attr_instances, NULL }; static struct android_usb_function acm_function = { .name = "acm", .init = acm_function_init, .cleanup = acm_function_cleanup, .bind_config = acm_function_bind_config, .attributes = acm_function_attributes, }; static int mtp_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return mtp_setup(); } static void mtp_function_cleanup(struct android_usb_function *f) { mtp_cleanup(); } static int mtp_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return mtp_bind_config(c, false); } static int ptp_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { /* nothing to do - initialization is handled by mtp_function_init */ return 0; } static void ptp_function_cleanup(struct android_usb_function *f) { /* nothing to do - cleanup is handled by mtp_function_cleanup */ } static int ptp_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return mtp_bind_config(c, true); } static int mtp_function_ctrlrequest(struct android_usb_function *f, struct usb_composite_dev *cdev, const struct usb_ctrlrequest *c) { return mtp_ctrlrequest(cdev, c); } static struct android_usb_function mtp_function = { .name = "mtp", .init = mtp_function_init, .cleanup = mtp_function_cleanup, .bind_config = mtp_function_bind_config, .ctrlrequest = mtp_function_ctrlrequest, }; /* PTP function is same as MTP with slightly different interface descriptor */ static struct android_usb_function ptp_function = { .name = "ptp", .init = ptp_function_init, .cleanup = ptp_function_cleanup, .bind_config = ptp_function_bind_config, }; struct rndis_function_config { u8 ethaddr[ETH_ALEN]; u32 vendorID; char manufacturer[256]; bool wceis; }; static int rndis_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { f->config = kzalloc(sizeof(struct rndis_function_config), GFP_KERNEL); if (!f->config) return -ENOMEM; return 0; } static void rndis_function_cleanup(struct android_usb_function *f) { kfree(f->config); f->config = NULL; } static int rndis_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int ret; struct rndis_function_config *rndis = f->config; if (!rndis) { pr_err("%s: rndis_pdata\n", __func__); return -1; } ret = gether_setup_name(c->cdev->gadget, rndis->ethaddr, "rndis"); if (ret) { pr_err("%s: gether_setup failed\n", __func__); return ret; } if (rndis->wceis) { /* "Wireless" RNDIS; auto-detected by Windows */ rndis_iad_descriptor.bFunctionClass = USB_CLASS_WIRELESS_CONTROLLER; rndis_iad_descriptor.bFunctionSubClass = 0x01; rndis_iad_descriptor.bFunctionProtocol = 0x03; rndis_control_intf.bInterfaceClass = USB_CLASS_WIRELESS_CONTROLLER; rndis_control_intf.bInterfaceSubClass = 0x01; rndis_control_intf.bInterfaceProtocol = 0x03; } return rndis_bind_config(c, rndis->ethaddr, rndis->vendorID, rndis->manufacturer); } static void rndis_function_unbind_config(struct android_usb_function *f, struct usb_configuration *c) { gether_cleanup(); } static ssize_t rndis_manufacturer_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; return sprintf(buf, "%s\n", config->manufacturer); } static ssize_t rndis_manufacturer_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; if (size >= sizeof(config->manufacturer)) return -EINVAL; if (sscanf(buf, "%s", config->manufacturer) == 1) return size; return -1; } static DEVICE_ATTR(manufacturer, S_IRUGO | S_IWUSR, rndis_manufacturer_show, rndis_manufacturer_store); static ssize_t rndis_wceis_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; return sprintf(buf, "%d\n", config->wceis); } static ssize_t rndis_wceis_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; int value; if (sscanf(buf, "%d", &value) == 1) { config->wceis = value; return size; } return -EINVAL; } static DEVICE_ATTR(wceis, S_IRUGO | S_IWUSR, rndis_wceis_show, rndis_wceis_store); static ssize_t rndis_ethaddr_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *rndis = f->config; return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", rndis->ethaddr[0], rndis->ethaddr[1], rndis->ethaddr[2], rndis->ethaddr[3], rndis->ethaddr[4], rndis->ethaddr[5]); } static ssize_t rndis_ethaddr_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *rndis = f->config; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE int i; char *src; for (i = 0; i < ETH_ALEN; i++) rndis->ethaddr[i] = 0; /* create a fake MAC address from our serial number. * first byte is 0x02 to signify locally administered. */ rndis->ethaddr[0] = 0x02; src = serial_string; for (i = 0; (i < 256) && *src; i++) { /* XOR the USB serial across the remaining bytes */ rndis->ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++; } return size; #else if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", (int *)&rndis->ethaddr[0], (int *)&rndis->ethaddr[1], (int *)&rndis->ethaddr[2], (int *)&rndis->ethaddr[3], (int *)&rndis->ethaddr[4], (int *)&rndis->ethaddr[5]) == 6) { return size; } return -EINVAL; #endif } static DEVICE_ATTR(ethaddr, S_IRUGO | S_IWUSR, rndis_ethaddr_show, rndis_ethaddr_store); static ssize_t rndis_vendorID_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; return sprintf(buf, "%04x\n", config->vendorID); } static ssize_t rndis_vendorID_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; int value; if (sscanf(buf, "%04x", &value) == 1) { config->vendorID = value; return size; } return -EINVAL; } static DEVICE_ATTR(vendorID, S_IRUGO | S_IWUSR, rndis_vendorID_show, rndis_vendorID_store); static struct device_attribute *rndis_function_attributes[] = { &dev_attr_manufacturer, &dev_attr_wceis, &dev_attr_ethaddr, &dev_attr_vendorID, NULL }; static struct android_usb_function rndis_function = { .name = "rndis", .init = rndis_function_init, .cleanup = rndis_function_cleanup, .bind_config = rndis_function_bind_config, .unbind_config = rndis_function_unbind_config, .attributes = rndis_function_attributes, }; struct mass_storage_function_config { struct fsg_config fsg; struct fsg_common *common; }; static int mass_storage_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { struct mass_storage_function_config *config; struct fsg_common *common; int err; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE int i; #endif config = kzalloc(sizeof(struct mass_storage_function_config), GFP_KERNEL); if (!config) return -ENOMEM; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE if (config) { /* All of Nvidia device have SD card slot so we make 2 luns */ config->fsg.nluns = 2; printk(KERN_DEBUG "usb: %s, nluns=%d\n", __func__, config->fsg.nluns); for (i = 0; i < config->fsg.nluns; i++) { config->fsg.luns[i].removable = 1; config->fsg.luns[i].nofua = 1; } common = fsg_common_init(NULL, cdev, &config->fsg); if (IS_ERR(common)) { kfree(config); return PTR_ERR(common); } for (i = 0; i < config->fsg.nluns; i++) { char luns[5]; err = snprintf(luns, 5, "lun%d", i); if (err == 0) { printk(KERN_ERR "usb: %s snprintf error\n", __func__); kfree(config); return err; } err = sysfs_create_link(&f->dev->kobj, &common->luns[i].dev.kobj, luns); if (err) { kfree(config); return err; } } } else { #endif /* original mainline code */ printk(KERN_DEBUG "usb: %s pdata is not available. nluns=1\n", __func__); config->fsg.nluns = 1; config->fsg.luns[0].removable = 1; common = fsg_common_init(NULL, cdev, &config->fsg); if (IS_ERR(common)) { kfree(config); return PTR_ERR(common); } err = sysfs_create_link(&f->dev->kobj, &common->luns[0].dev.kobj, "lun"); if (err) { kfree(config); return err; } #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE } #endif config->common = common; f->config = config; return 0; } static void mass_storage_function_cleanup(struct android_usb_function *f) { kfree(f->config); f->config = NULL; } static int mass_storage_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { struct mass_storage_function_config *config = f->config; return fsg_bind_config(c->cdev, c, config->common); } static ssize_t mass_storage_inquiry_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; return sprintf(buf, "%s\n", config->common->inquiry_string); } static ssize_t mass_storage_inquiry_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; if (size >= sizeof(config->common->inquiry_string)) return -EINVAL; if (sscanf(buf, "%s", config->common->inquiry_string) != 1) return -EINVAL; return size; } static DEVICE_ATTR(inquiry_string, S_IRUGO | S_IWUSR, mass_storage_inquiry_show, mass_storage_inquiry_store); #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE static ssize_t mass_storage_vendor_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; return sprintf(buf, "%s\n", config->common->vendor_string); } static ssize_t mass_storage_vendor_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; if (size >= sizeof(config->common->vendor_string)) return -EINVAL; if (sscanf(buf, "%s", config->common->vendor_string) != 1) return -EINVAL; printk(KERN_DEBUG "%s: vendor %s", __func__, config->common->vendor_string); return size; } static DEVICE_ATTR(vendor_string, S_IRUGO | S_IWUSR, mass_storage_vendor_show, mass_storage_vendor_store); static ssize_t mass_storage_product_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; return sprintf(buf, "%s\n", config->common->product_string); } static ssize_t mass_storage_product_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; if (size >= sizeof(config->common->product_string)) return -EINVAL; if (sscanf(buf, "%s", config->common->product_string) != 1) return -EINVAL; printk(KERN_DEBUG "%s: product %s", __func__, config->common->product_string); return size; } static DEVICE_ATTR(product_string, S_IRUGO | S_IWUSR, mass_storage_product_show, mass_storage_product_store); #endif static struct device_attribute *mass_storage_function_attributes[] = { &dev_attr_inquiry_string, #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE &dev_attr_vendor_string, &dev_attr_product_string, #endif NULL }; static struct android_usb_function mass_storage_function = { .name = "mass_storage", .init = mass_storage_function_init, .cleanup = mass_storage_function_cleanup, .bind_config = mass_storage_function_bind_config, .attributes = mass_storage_function_attributes, }; static int accessory_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return acc_setup(); } static void accessory_function_cleanup(struct android_usb_function *f) { acc_cleanup(); } static int accessory_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return acc_bind_config(c); } static int accessory_function_ctrlrequest(struct android_usb_function *f, struct usb_composite_dev *cdev, const struct usb_ctrlrequest *c) { return acc_ctrlrequest(cdev, c); } static struct android_usb_function accessory_function = { .name = "accessory", .init = accessory_function_init, .cleanup = accessory_function_cleanup, .bind_config = accessory_function_bind_config, .ctrlrequest = accessory_function_ctrlrequest, }; static struct android_usb_function *supported_functions[] = { &adb_function, &acm_function, &mtp_function, &ptp_function, &rndis_function, &mass_storage_function, &accessory_function, NULL }; static int android_init_functions(struct android_usb_function **functions, struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; struct android_usb_function *f; struct device_attribute **attrs; struct device_attribute *attr; int err = 0; int index = 0; for (; (f = *functions++); index++) { f->dev_name = kasprintf(GFP_KERNEL, "f_%s", f->name); f->dev = device_create(android_class, dev->dev, MKDEV(0, index), f, f->dev_name); if (IS_ERR(f->dev)) { pr_err("%s: Failed to create dev %s", __func__, f->dev_name); err = PTR_ERR(f->dev); goto err_create; } if (f->init) { err = f->init(f, cdev); if (err) { pr_err("%s: Failed to init %s", __func__, f->name); goto err_out; } } attrs = f->attributes; if (attrs) { while ((attr = *attrs++) && !err) err = device_create_file(f->dev, attr); } if (err) { pr_err("%s: Failed to create function %s attributes", __func__, f->name); goto err_out; } } return 0; err_out: device_destroy(android_class, f->dev->devt); err_create: kfree(f->dev_name); return err; } static void android_cleanup_functions(struct android_usb_function **functions) { struct android_usb_function *f; while (*functions) { f = *functions++; if (f->dev) { device_destroy(android_class, f->dev->devt); kfree(f->dev_name); } if (f->cleanup) f->cleanup(f); } } static int android_bind_enabled_functions(struct android_dev *dev, struct usb_configuration *c) { struct android_usb_function *f; int ret; list_for_each_entry(f, &dev->enabled_functions, enabled_list) { printk(KERN_DEBUG "usb: %s f:%s\n", __func__, f->name); ret = f->bind_config(f, c); if (ret) { pr_err("%s: %s failed", __func__, f->name); return ret; } } return 0; } static void android_unbind_enabled_functions(struct android_dev *dev, struct usb_configuration *c) { struct android_usb_function *f; list_for_each_entry(f, &dev->enabled_functions, enabled_list) { if (f->unbind_config) f->unbind_config(f, c); } } static int android_enable_function(struct android_dev *dev, char *name) { struct android_usb_function **functions = dev->functions; struct android_usb_function *f; printk(KERN_DEBUG "usb: %s name=%s\n", __func__, name); while ((f = *functions++)) { if (!strcmp(name, f->name)) { list_add_tail(&f->enabled_list, &dev->enabled_functions); return 0; } } return -EINVAL; } /*-------------------------------------------------------------------------*/ /* /sys/class/android_usb/android%d/ interface */ static ssize_t functions_show(struct device *pdev, struct device_attribute *attr, char *buf) { struct android_dev *dev = dev_get_drvdata(pdev); struct android_usb_function *f; char *buff = buf; mutex_lock(&dev->mutex); list_for_each_entry(f, &dev->enabled_functions, enabled_list) { printk(KERN_DEBUG "usb: %s enabled_func=%s\n", __func__, f->name); buff += sprintf(buff, "%s,", f->name); } mutex_unlock(&dev->mutex); if (buff != buf) *(buff-1) = '\n'; return buff - buf; } static ssize_t functions_store(struct device *pdev, struct device_attribute *attr, const char *buff, size_t size) { struct android_dev *dev = dev_get_drvdata(pdev); char *name; char buf[256], *b; int err; mutex_lock(&dev->mutex); if (dev->enabled) { mutex_unlock(&dev->mutex); return -EBUSY; } INIT_LIST_HEAD(&dev->enabled_functions); printk(KERN_DEBUG "usb: %s buff=%s\n", __func__, buff); strncpy(buf, buff, sizeof(buf)); b = strim(buf); while (b) { name = strsep(&b, ","); if (name) { err = android_enable_function(dev, name); if (err) pr_err("android_usb: Cannot enable '%s'", name); #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE /* Enable ACM function, if MTP is enabled. */ if (!strcmp(name, "mtp")) { err = android_enable_function(dev, "acm"); if (err) pr_err( "android_usb: Cannot enable '%s'", name); } #endif } } mutex_unlock(&dev->mutex); return size; } static ssize_t enable_show(struct device *pdev, struct device_attribute *attr, char *buf) { struct android_dev *dev = dev_get_drvdata(pdev); printk(KERN_DEBUG "usb: %s dev->enabled=%d\n", __func__, dev->enabled); return sprintf(buf, "%d\n", dev->enabled); } static int clk_lock_status; static ssize_t enable_store(struct device *pdev, struct device_attribute *attr, const char *buff, size_t size) { struct android_dev *dev = dev_get_drvdata(pdev); struct usb_composite_dev *cdev = dev->cdev; int enabled = 0; mutex_lock(&dev->mutex); sscanf(buff, "%d", &enabled); printk(KERN_DEBUG "usb: %s enabled=%d, !dev->enabled=%d\n", __func__, enabled, !dev->enabled); if (enabled && !dev->enabled) { #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE struct android_usb_function *f; cdev->next_string_id = composite_string_index; #else cdev->next_string_id = 0; #endif /* update values in composite driver's copy of device descriptor */ cdev->desc.idVendor = device_desc.idVendor; cdev->desc.idProduct = device_desc.idProduct; cdev->desc.bcdDevice = device_desc.bcdDevice; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE list_for_each_entry(f, &dev->enabled_functions, enabled_list) { printk(KERN_DEBUG "usb: %s f:%s\n", __func__, f->name); if (!strcmp(f->name, "acm")) { printk(KERN_DEBUG "usb: acm is enabled. (bcdDevice=0x400)\n"); /* Samsung KIES needs fixed bcdDevice number */ cdev->desc.bcdDevice = cpu_to_le16(0x0400); } if (!strcmp(f->name, "rndis")) { /* cpu clock and sclk set max clock */ if (!clk_lock_status) { #ifdef CONFIG_TEGRA_CPU_FREQ_LOCK tegra_cpu_lock_speed(1000000, 0); #endif /* CONFIG_TEGRA_CPU_FREQ_LOCK */ fsl_udc_lock_sclk(240000000); clk_lock_status = true; } } } strncpy(manufacturer_string, "SAMSUNG", sizeof(manufacturer_string) - 1); strncpy(product_string, "SAMSUNG_Android", sizeof(product_string) - 1); #endif cdev->desc.bDeviceClass = device_desc.bDeviceClass; cdev->desc.bDeviceSubClass = device_desc.bDeviceSubClass; cdev->desc.bDeviceProtocol = device_desc.bDeviceProtocol; printk(KERN_DEBUG "usb: %s vendor=%x,product=%x,bcdDevice=%x", __func__, cdev->desc.idVendor, cdev->desc.idProduct, cdev->desc.bcdDevice); printk(KERN_DEBUG ",Class=%x,SubClass=%x,Protocol=%x\n", cdev->desc.bDeviceClass, cdev->desc.bDeviceSubClass, cdev->desc.bDeviceProtocol); printk(KERN_DEBUG "usb: %s next cmd : usb_add_config\n", __func__); usb_add_config(cdev, &android_config_driver, android_bind_config); usb_gadget_connect(cdev->gadget); dev->enabled = true; } else if (!enabled && dev->enabled) { #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE /* avoid sending a disconnect switch event * until after we disconnect. */ cdev->mute_switch = true; #endif usb_gadget_disconnect(cdev->gadget); /* Cancel pending control requests */ usb_ep_dequeue(cdev->gadget->ep0, cdev->req); usb_remove_config(cdev, &android_config_driver); dev->enabled = false; /* cpu clock and sclk restore original clock */ if (clk_lock_status) { #ifdef CONFIG_TEGRA_CPU_FREQ_LOCK tegra_cpu_unlock_speed(); #endif /* CONFIG_TEGRA_CPU_FREQ_LOCK */ fsl_udc_unlock_sclk(); clk_lock_status = false; } } else if (!enabled) { usb_gadget_disconnect(cdev->gadget); dev->enabled = false; /* cpu clock and sclk restore original clock */ if (clk_lock_status) { #ifdef CONFIG_TEGRA_CPU_FREQ_LOCK tegra_cpu_unlock_speed(); #endif /* CONFIG_TEGRA_CPU_FREQ_LOCK */ fsl_udc_unlock_sclk(); clk_lock_status = false; } } else { pr_err("android_usb: already %s\n", dev->enabled ? "enabled" : "disabled"); } mutex_unlock(&dev->mutex); return size; } static ssize_t state_show(struct device *pdev, struct device_attribute *attr, char *buf) { struct android_dev *dev = dev_get_drvdata(pdev); struct usb_composite_dev *cdev = dev->cdev; char *state = "DISCONNECTED"; unsigned long flags; if (!cdev) goto out; spin_lock_irqsave(&cdev->lock, flags); if (cdev->config) state = "CONFIGURED"; else if (dev->connected) state = "CONNECTED"; spin_unlock_irqrestore(&cdev->lock, flags); out: printk(KERN_DEBUG "usb: %s buf=%s\n", __func__, state); return sprintf(buf, "%s\n", state); } #define DESCRIPTOR_ATTR(field, format_string) \ static ssize_t \ field ## _show(struct device *dev, struct device_attribute *attr, \ char *buf) \ { \ return sprintf(buf, format_string, device_desc.field); \ } \ static ssize_t \ field ## _store(struct device *dev, struct device_attribute *attr, \ const char *buf, size_t size) \ { \ int value; \ if (sscanf(buf, format_string, &value) == 1) { \ device_desc.field = value; \ return size; \ } \ return -1; \ } \ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, field ## _show, field ## _store); #define DESCRIPTOR_STRING_ATTR(field, buffer) \ static ssize_t \ field ## _show(struct device *dev, struct device_attribute *attr, \ char *buf) \ { \ return sprintf(buf, "%s", buffer); \ } \ static ssize_t \ field ## _store(struct device *dev, struct device_attribute *attr, \ const char *buf, size_t size) \ { \ if (size >= sizeof(buffer)) return -EINVAL; \ if (sscanf(buf, "%s", buffer) == 1) { \ return size; \ } \ return -1; \ } \ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, field ## _show, field ## _store); DESCRIPTOR_ATTR(idVendor, "%04x\n") DESCRIPTOR_ATTR(idProduct, "%04x\n") DESCRIPTOR_ATTR(bcdDevice, "%04x\n") DESCRIPTOR_ATTR(bDeviceClass, "%d\n") DESCRIPTOR_ATTR(bDeviceSubClass, "%d\n") DESCRIPTOR_ATTR(bDeviceProtocol, "%d\n") DESCRIPTOR_STRING_ATTR(iManufacturer, manufacturer_string) DESCRIPTOR_STRING_ATTR(iProduct, product_string) DESCRIPTOR_STRING_ATTR(iSerial, serial_string) static DEVICE_ATTR(functions, S_IRUGO | S_IWUSR, functions_show, functions_store); static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store); static DEVICE_ATTR(state, S_IRUGO, state_show, NULL); static struct device_attribute *android_usb_attributes[] = { &dev_attr_idVendor, &dev_attr_idProduct, &dev_attr_bcdDevice, &dev_attr_bDeviceClass, &dev_attr_bDeviceSubClass, &dev_attr_bDeviceProtocol, &dev_attr_iManufacturer, &dev_attr_iProduct, &dev_attr_iSerial, &dev_attr_functions, &dev_attr_enable, &dev_attr_state, NULL }; /*-------------------------------------------------------------------------*/ /* Composite driver */ static int android_bind_config(struct usb_configuration *c) { struct android_dev *dev = _android_dev; int ret = 0; ret = android_bind_enabled_functions(dev, c); if (ret) return ret; return 0; } static void android_unbind_config(struct usb_configuration *c) { struct android_dev *dev = _android_dev; android_unbind_enabled_functions(dev, c); } static int android_bind(struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; struct usb_gadget *gadget = cdev->gadget; int gcnum, id, ret; printk(KERN_DEBUG "usb: %s disconnect\n", __func__); usb_gadget_disconnect(gadget); ret = android_init_functions(dev->functions, cdev); if (ret) return ret; /* Allocate string descriptor numbers ... note that string * contents can be overridden by the composite_dev glue. */ id = usb_string_id(cdev); if (id < 0) return id; strings_dev[STRING_MANUFACTURER_IDX].id = id; device_desc.iManufacturer = id; id = usb_string_id(cdev); if (id < 0) return id; strings_dev[STRING_PRODUCT_IDX].id = id; device_desc.iProduct = id; /* Default strings - should be updated by userspace */ strncpy(manufacturer_string, "Android", sizeof(manufacturer_string) - 1); strncpy(product_string, "Android", sizeof(product_string) - 1); #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE sprintf(serial_string, "%08X%08X", system_serial_high, system_serial_low); #else strncpy(serial_string, "0123456789ABCDEF", sizeof(serial_string) - 1); #endif id = usb_string_id(cdev); if (id < 0) return id; strings_dev[STRING_SERIAL_IDX].id = id; device_desc.iSerialNumber = id; gcnum = usb_gadget_controller_number(gadget); if (gcnum >= 0) device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); else { /* gadget zero is so simple (for now, no altsettings) that * it SHOULD NOT have problems with bulk-capable hardware. * so just warn about unrcognized controllers -- don't panic. * * things like configuration and altsetting numbering * can need hardware-specific attention though. */ pr_warning("%s: controller '%s' not recognized\n", longname, gadget->name); device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); } #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE composite_string_index = 4; #endif dev->cdev = cdev; return 0; } static int android_usb_unbind(struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; printk(KERN_DEBUG "usb: %s\n", __func__); cancel_work_sync(&dev->work); android_cleanup_functions(dev->functions); return 0; } static struct usb_composite_driver android_usb_driver = { .name = "android_usb", .dev = &device_desc, .strings = dev_strings, .unbind = android_usb_unbind, .max_speed = USB_SPEED_HIGH, }; static int android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) { struct android_dev *dev = _android_dev; struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_request *req = cdev->req; struct android_usb_function *f; int value = -EOPNOTSUPP; unsigned long flags; req->zero = 0; req->complete = composite_setup_complete; req->length = 0; gadget->ep0->driver_data = cdev; list_for_each_entry(f, &dev->enabled_functions, enabled_list) { if (f->ctrlrequest) { value = f->ctrlrequest(f, cdev, c); if (value >= 0) break; } } /* Special case the accessory function. * It needs to handle control requests before it is enabled. */ if (value < 0) value = acc_ctrlrequest(cdev, c); if (value < 0) value = composite_setup(gadget, c); spin_lock_irqsave(&cdev->lock, flags); #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE if (cdev->mute_switch == true) cdev->mute_switch = false; #endif if (!dev->connected) { dev->connected = 1; schedule_work(&dev->work); } else if (c->bRequest == USB_REQ_SET_CONFIGURATION && cdev->config) { schedule_work(&dev->work); } spin_unlock_irqrestore(&cdev->lock, flags); return value; } static void android_disconnect(struct usb_gadget *gadget) { struct android_dev *dev = _android_dev; struct usb_composite_dev *cdev = get_gadget_data(gadget); unsigned long flags; composite_disconnect(gadget); spin_lock_irqsave(&cdev->lock, flags); dev->connected = 0; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE /* avoid sending a disconnect switch event * until after we disconnect. */ if (cdev->mute_switch) { printk(KERN_DEBUG "usb: %s mute_switch\n", __func__); } else { printk(KERN_DEBUG "usb: %s schedule_work\n", __func__); schedule_work(&dev->work); } #else schedule_work(&dev->work); #endif spin_unlock_irqrestore(&cdev->lock, flags); } static int android_create_device(struct android_dev *dev) { struct device_attribute **attrs = android_usb_attributes; struct device_attribute *attr; int err; dev->dev = device_create(android_class, NULL, MKDEV(0, 0), NULL, "android0"); if (IS_ERR(dev->dev)) return PTR_ERR(dev->dev); dev_set_drvdata(dev->dev, dev); while ((attr = *attrs++)) { err = device_create_file(dev->dev, attr); if (err) { device_destroy(android_class, dev->dev->devt); return err; } } return 0; } #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE static int android_probe(struct platform_device *pdev) { android_usb_pdata = pdev->dev.platform_data; printk(KERN_INFO "usb: %s pdata: %p\n", __func__, android_usb_pdata); if (android_usb_pdata) { printk(KERN_INFO "usb: %s nluns=%d\n", __func__, android_usb_pdata->nluns); } else { printk(KERN_INFO "usb: %s pdata is not available\n", __func__); } return 0; } static struct platform_driver android_platform_driver = { .driver = { .name = "android_usb", }, .probe = android_probe, }; #endif static int __init init(void) { struct android_dev *dev; int err; printk(KERN_DEBUG "%s\n", __func__); android_class = class_create(THIS_MODULE, "android_usb"); if (IS_ERR(android_class)) return PTR_ERR(android_class); dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->functions = supported_functions; INIT_LIST_HEAD(&dev->enabled_functions); INIT_WORK(&dev->work, android_work); mutex_init(&dev->mutex); err = android_create_device(dev); if (err) { class_destroy(android_class); kfree(dev); return err; } _android_dev = dev; /* Override composite driver functions */ composite_driver.setup = android_setup; composite_driver.disconnect = android_disconnect; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE err = platform_driver_register(&android_platform_driver); if (err) { printk(KERN_ERR "usb: %s platform register is failed\n", __func__); return err; } #endif #ifdef CONFIG_USB_DUN_SUPPORT err = modem_misc_register(); if (err) { printk(KERN_ERR "usb: %s modem misc register is failed\n", __func__); return err; } #endif return usb_composite_probe(&android_usb_driver, android_bind); } module_init(init); static void __exit cleanup(void) { usb_composite_unregister(&android_usb_driver); class_destroy(android_class); kfree(_android_dev); _android_dev = NULL; } module_exit(cleanup);
xdajog/samsung_sources_i927
drivers/usb/gadget/android.c
C
gpl-2.0
39,644
<?php /** * @file * Template for Panopoly Geary. * * Variables: * - $css_id: An optional CSS id to use for the layout. * - $content: An array of content, each item in the array is keyed to one * panel of the layout. This layout supports the following sections: */ ?> <div class="panel-display geary clearfix <?php !empty($class) ? print $class : ''; ?>" <?php !empty($css_id) ? print "id=\"$css_id\"" : ''; ?>> <section class="section"> <div class="container"> <div class="row"> <div class="col-sm-<?php print kalatheme_grid_size(KALATHEME_GRID_FULL); ?> geary-main-container"> <?php print $content['header']; ?> </div> </div> </div> </section> <section class="section"> <div class="container"> <div class="row"> <div class="col-sm-<?php print kalatheme_grid_size(KALATHEME_GRID_THIRD, 3); ?> geary-column-content-region-1"> <?php print $content['column1']; ?> </div> <div class="col-sm-<?php print kalatheme_grid_size(KALATHEME_GRID_THIRD, 3); ?> geary-column-content-region-2"> <?php print $content['column2']; ?> </div> <div class="col-sm-<?php print kalatheme_grid_size(KALATHEME_GRID_THIRD, 3); ?> geary-column-content-region-3"> <?php print $content['column3']; ?> </div> </div> </div> </section> </div><!-- /.geary -->
padmanabhan-developer/mattbiz
sites/all/themes/kalatheme/templates/panopoly/geary.tpl.php
PHP
gpl-2.0
1,387
/* * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ace.define('ace/mode/julia', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/julia_highlight_rules', 'ace/mode/folding/cstyle'], function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var Tokenizer = require("../tokenizer").Tokenizer; var JuliaHighlightRules = require("./julia_highlight_rules").JuliaHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = JuliaHighlightRules; this.foldingRules = new FoldMode(); }; oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "#"; this.blockComment = ""; this.$id = "ace/mode/julia"; }).call(Mode.prototype); exports.Mode = Mode; }); ace.define('ace/mode/julia_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var JuliaHighlightRules = function() { this.$rules = { start: [ { include: '#function_decl' }, { include: '#function_call' }, { include: '#type_decl' }, { include: '#keyword' }, { include: '#operator' }, { include: '#number' }, { include: '#string' }, { include: '#comment' } ], '#bracket': [ { token: 'keyword.bracket.julia', regex: '\\(|\\)|\\[|\\]|\\{|\\}|,' } ], '#comment': [ { token: [ 'punctuation.definition.comment.julia', 'comment.line.number-sign.julia' ], regex: '(#)(?!\\{)(.*$)'} ], '#function_call': [ { token: [ 'support.function.julia', 'text' ], regex: '([a-zA-Z0-9_]+!?)(\\w*\\()'} ], '#function_decl': [ { token: [ 'keyword.other.julia', 'meta.function.julia', 'entity.name.function.julia', 'meta.function.julia','text' ], regex: '(function|macro)(\\s*)([a-zA-Z0-9_\\{]+!?)(\\w*)([(\\\\{])'} ], '#keyword': [ { token: 'keyword.other.julia', regex: '\\b(?:function|type|immutable|macro|quote|abstract|bitstype|typealias|module|baremodule|new)\\b' }, { token: 'keyword.control.julia', regex: '\\b(?:if|else|elseif|while|for|in|begin|let|end|do|try|catch|finally|return|break|continue)\\b' }, { token: 'storage.modifier.variable.julia', regex: '\\b(?:global|local|const|export|import|importall|using)\\b' }, { token: 'variable.macro.julia', regex: '@\\w+\\b' } ], '#number': [ { token: 'constant.numeric.julia', regex: '\\b0(?:x|X)[0-9a-fA-F]*|(?:\\b[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]*)?(?:im)?|\\bInf(?:32)?\\b|\\bNaN(?:32)?\\b|\\btrue\\b|\\bfalse\\b' } ], '#operator': [ { token: 'keyword.operator.update.julia', regex: '=|:=|\\+=|-=|\\*=|/=|//=|\\.//=|\\.\\*=|\\\\=|\\.\\\\=|^=|\\.^=|%=|\\|=|&=|\\$=|<<=|>>=' }, { token: 'keyword.operator.ternary.julia', regex: '\\?|:' }, { token: 'keyword.operator.boolean.julia', regex: '\\|\\||&&|!' }, { token: 'keyword.operator.arrow.julia', regex: '->|<-|-->' }, { token: 'keyword.operator.relation.julia', regex: '>|<|>=|<=|==|!=|\\.>|\\.<|\\.>=|\\.>=|\\.==|\\.!=|\\.=|\\.!|<:|:>' }, { token: 'keyword.operator.range.julia', regex: ':' }, { token: 'keyword.operator.shift.julia', regex: '<<|>>' }, { token: 'keyword.operator.bitwise.julia', regex: '\\||\\&|~' }, { token: 'keyword.operator.arithmetic.julia', regex: '\\+|-|\\*|\\.\\*|/|\\./|//|\\.//|%|\\.%|\\\\|\\.\\\\|\\^|\\.\\^' }, { token: 'keyword.operator.isa.julia', regex: '::' }, { token: 'keyword.operator.dots.julia', regex: '\\.(?=[a-zA-Z])|\\.\\.+' }, { token: 'keyword.operator.interpolation.julia', regex: '\\$#?(?=.)' }, { token: [ 'variable', 'keyword.operator.transposed-variable.julia' ], regex: '(\\w+)((?:\'|\\.\')*\\.?\')' }, { token: 'text', regex: '\\[|\\('}, { token: [ 'text', 'keyword.operator.transposed-matrix.julia' ], regex: "([\\]\\)])((?:'|\\.')*\\.?')"} ], '#string': [ { token: 'punctuation.definition.string.begin.julia', regex: '\'', push: [ { token: 'punctuation.definition.string.end.julia', regex: '\'', next: 'pop' }, { include: '#string_escaped_char' }, { defaultToken: 'string.quoted.single.julia' } ] }, { token: 'punctuation.definition.string.begin.julia', regex: '"', push: [ { token: 'punctuation.definition.string.end.julia', regex: '"', next: 'pop' }, { include: '#string_escaped_char' }, { defaultToken: 'string.quoted.double.julia' } ] }, { token: 'punctuation.definition.string.begin.julia', regex: '\\b\\w+"', push: [ { token: 'punctuation.definition.string.end.julia', regex: '"\\w*', next: 'pop' }, { include: '#string_custom_escaped_char' }, { defaultToken: 'string.quoted.custom-double.julia' } ] }, { token: 'punctuation.definition.string.begin.julia', regex: '`', push: [ { token: 'punctuation.definition.string.end.julia', regex: '`', next: 'pop' }, { include: '#string_escaped_char' }, { defaultToken: 'string.quoted.backtick.julia' } ] } ], '#string_custom_escaped_char': [ { token: 'constant.character.escape.julia', regex: '\\\\"' } ], '#string_escaped_char': [ { token: 'constant.character.escape.julia', regex: '\\\\(?:\\\\|[0-3]\\d{,2}|[4-7]\\d?|x[a-fA-F0-9]{,2}|u[a-fA-F0-9]{,4}|U[a-fA-F0-9]{,8}|.)' } ], '#type_decl': [ { token: [ 'keyword.control.type.julia', 'meta.type.julia', 'entity.name.type.julia', 'entity.other.inherited-class.julia', 'punctuation.separator.inheritance.julia', 'entity.other.inherited-class.julia' ], regex: '(type|immutable)(\\s+)([a-zA-Z0-9_]+)(?:(\\s*)(<:)(\\s*[.a-zA-Z0-9_:]+))?' }, { token: [ 'other.typed-variable.julia', 'support.type.julia' ], regex: '([a-zA-Z0-9_]+)(::[a-zA-Z0-9_{}]+)' } ] } this.normalizeRules(); }; JuliaHighlightRules.metaData = { fileTypes: [ 'jl' ], firstLineMatch: '^#!.*\\bjulia\\s*$', foldingStartMarker: '^\\s*(?:if|while|for|begin|function|macro|module|baremodule|type|immutable|let)\\b(?!.*\\bend\\b).*$', foldingStopMarker: '^\\s*(?:end)\\b.*$', name: 'Julia', scopeName: 'source.julia' } oop.inherits(JuliaHighlightRules, TextHighlightRules); exports.JuliaHighlightRules = JuliaHighlightRules; }); ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { var oop = require("../../lib/oop"); var Range = require("../../range").Range; var BaseFoldMode = require("./fold_mode").FoldMode; var FoldMode = exports.FoldMode = function(commentRegex) { if (commentRegex) { this.foldingStartMarker = new RegExp( this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) ); this.foldingStopMarker = new RegExp( this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) ); } }; oop.inherits(FoldMode, BaseFoldMode); (function() { this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { var line = session.getLine(row); var match = line.match(this.foldingStartMarker); if (match) { var i = match.index; if (match[1]) return this.openingBracketBlock(session, match[1], row, i); var range = session.getCommentFoldRange(row, i + match[0].length, 1); if (range && !range.isMultiLine()) { if (forceMultiline) { range = this.getSectionRange(session, row); } else if (foldStyle != "all") range = null; } return range; } if (foldStyle === "markbegin") return; var match = line.match(this.foldingStopMarker); if (match) { var i = match.index + match[0].length; if (match[1]) return this.closingBracketBlock(session, match[1], row, i); return session.getCommentFoldRange(row, i, -1); } }; this.getSectionRange = function(session, row) { var line = session.getLine(row); var startIndent = line.search(/\S/); var startRow = row; var startColumn = line.length; row = row + 1; var endRow = row; var maxRow = session.getLength(); while (++row < maxRow) { line = session.getLine(row); var indent = line.search(/\S/); if (indent === -1) continue; if (startIndent > indent) break; var subRange = this.getFoldWidgetRange(session, "all", row); if (subRange) { if (subRange.start.row <= startRow) { break; } else if (subRange.isMultiLine()) { row = subRange.end.row; } else if (startIndent == indent) { break; } } endRow = row; } return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); }; }).call(FoldMode.prototype); });
onekweb/rhemawebb.se-in-joomla3
plugins/editors/rokpad/ace/mode-julia.js
JavaScript
gpl-2.0
11,760
/* Hash tables for the CPP library. Copyright (C) 1986-2014 Free Software Foundation, Inc. Written by Per Bothner, 1994. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 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 3, 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; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */ #include "config.h" #include "system.h" #include "cpplib.h" #include "internal.h" static hashnode alloc_node (cpp_hash_table *); /* Return an identifier node for hashtable.c. Used by cpplib except when integrated with the C front ends. */ static hashnode alloc_node (cpp_hash_table *table) { cpp_hashnode *node; node = XOBNEW (&table->pfile->hash_ob, cpp_hashnode); memset (node, 0, sizeof (cpp_hashnode)); return HT_NODE (node); } /* Set up the identifier hash table. Use TABLE if non-null, otherwise create our own. */ void _cpp_init_hashtable (cpp_reader *pfile, cpp_hash_table *table) { struct spec_nodes *s; if (table == NULL) { pfile->our_hashtable = 1; table = ht_create (13); /* 8K (=2^13) entries. */ table->alloc_node = alloc_node; _obstack_begin (&pfile->hash_ob, 0, 0, (void *(*) (long)) xmalloc, (void (*) (void *)) free); } table->pfile = pfile; pfile->hash_table = table; /* Now we can initialize things that use the hash table. */ _cpp_init_directives (pfile); _cpp_init_internal_pragmas (pfile); s = &pfile->spec_nodes; s->n_defined = cpp_lookup (pfile, DSC("defined")); s->n_true = cpp_lookup (pfile, DSC("true")); s->n_false = cpp_lookup (pfile, DSC("false")); s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__")); s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC; } /* Tear down the identifier hash table. */ void _cpp_destroy_hashtable (cpp_reader *pfile) { if (pfile->our_hashtable) { ht_destroy (pfile->hash_table); obstack_free (&pfile->hash_ob, 0); } } /* Returns the hash entry for the STR of length LEN, creating one if necessary. */ cpp_hashnode * cpp_lookup (cpp_reader *pfile, const unsigned char *str, unsigned int len) { /* ht_lookup cannot return NULL. */ return CPP_HASHNODE (ht_lookup (pfile->hash_table, str, len, HT_ALLOC)); } /* Determine whether the str STR, of length LEN, is a defined macro. */ int cpp_defined (cpp_reader *pfile, const unsigned char *str, int len) { cpp_hashnode *node; node = CPP_HASHNODE (ht_lookup (pfile->hash_table, str, len, HT_NO_INSERT)); /* If it's of type NT_MACRO, it cannot be poisoned. */ return node && node->type == NT_MACRO; } /* We don't need a proxy since the hash table's identifier comes first in cpp_hashnode. However, in case this is ever changed, we have a static assertion for it. */ extern char proxy_assertion_broken[offsetof (struct cpp_hashnode, ident) == 0 ? 1 : -1]; /* For all nodes in the hashtable, callback CB with parameters PFILE, the node, and V. */ void cpp_forall_identifiers (cpp_reader *pfile, cpp_cb cb, void *v) { ht_forall (pfile->hash_table, (ht_cb) cb, v); }
emb-team/loongson-gccgo
libcpp/identifiers.c
C
gpl-2.0
3,785
/* * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * Copyright (C) 2004-2011 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.sun.xml.internal.rngom.binary; import com.sun.xml.internal.rngom.binary.visitor.PatternFunction; import com.sun.xml.internal.rngom.binary.visitor.PatternVisitor; public class ErrorPattern extends Pattern { ErrorPattern() { super(false, EMPTY_CONTENT_TYPE, ERROR_HASH_CODE); } boolean samePattern(Pattern other) { return other instanceof ErrorPattern; } public void accept(PatternVisitor visitor) { visitor.visitError(); } public Object apply(PatternFunction f) { return f.caseError(this); } }
YouDiSN/OpenJDK-Research
jdk9/jaxws/src/jdk.xml.bind/share/classes/com/sun/xml/internal/rngom/binary/ErrorPattern.java
Java
gpl-2.0
2,861
/* Do not modify this file directly. It is compiled from other files. */ /* global idcL10n, jQuery, analytics, history, wpCookies */ !function(e){function i(){u.prop("disabled",!0)}function c(){u.prop("disabled",!1)}function n(){v.hide(),s("confirm_safe_mode");var n=p+"jetpack/v4/identity-crisis/confirm-safe-mode";i(),e.ajax({method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",d)},url:n,data:{},success:function(){l.hide(),h.removeClass("hide"),window.location.search&&1===window.location.search.indexOf("page=jetpack")&&window.location.reload()},error:function(e){g="confirm",r(e),c()}})}function t(){v.hide(),s("migrate");var n=p+"jetpack/v4/identity-crisis/migrate";i(),e.ajax({method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",d)},url:n,data:{},success:function(){l.hide(),e("body").hasClass("toplevel_page_jetpack")&&window.location.reload(!0)},error:function(e){g="migrate",r(e),c()}})}function o(){v.hide(),s("fix_connection"),l.addClass("jp-idc-show-second-step")}function a(){v.hide(),s("start_fresh");var n=p+"jetpack/v4/identity-crisis/start-fresh";i(),e.ajax({method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",d)},url:n,data:{},success:function(e){window.location=e+"&from=idc-notice"},error:function(e){g="start-fresh",r(e),c()}})}function r(i){var c=e(".jp-idc-error__desc");i&&i.responseJSON&&i.responseJSON.message?c.html(i.responseJSON.message):c.html(""),v.css("display","flex")}function s(e,i){void 0!==i&&"object"==typeof i||(i={}),e&&e.length&&"undefined"!=typeof analytics&&analytics.tracks&&analytics.mc&&(e=e.replace(/-/g,"_"),e=0!==e.indexOf("jetpack_idc_")?"jetpack_idc_"+e:e,analytics.tracks.recordEvent(e,i),e=e.replace("jetpack_idc_",""),e=e.replace(/_/g,"-"),analytics.mc.bumpStat("jetpack-idc",e))}var d=idcL10n.nonce,f=idcL10n.currentUrl,p=idcL10n.apiRoot,l=e(".jp-idc-notice"),u=e(".jp-idc-notice .dops-button"),m=idcL10n.tracksUserData,_=idcL10n.tracksEventData,h=e("#wp-admin-bar-jetpack-idc"),j=e("#jp-idc-confirm-safe-mode-action"),k=e("#jp-idc-fix-connection-action"),w=e("#jp-idc-migrate-action"),y=e("#jp-idc-reconnect-site-action"),v=e(".jp-idc-error__notice"),g=!1;"undefined"!=typeof analytics&&analytics.initialize(m.userid,m.username),_.isAdmin?s("notice_view"):s("non_admin_notice_view",{page:_.currentScreen}),function(e){e=void 0!==e&&e,window.location.search&&-1!==window.location.search.indexOf("jetpack_idc_clear_confirmation")&&(s("clear_confirmation_clicked"),history&&history.pushState?history.pushState({},"",f):e&&(window.location.href=f))}(),l.on("click",".notice-dismiss",function(){var e="https:"===window.location.protocol;wpCookies.set("jetpack_idc_dismiss_notice","1",604800,!1,!1,e),s("non_admin_notice_dismiss",{page:_.currentScreen})}),l.on("click","#jp-idc-error__action",function(){switch(v.hide(),g){case"confirm":n();break;case"start-fresh":a();break;case"migrate":t();break;default:return}}),j.on("click",n),k.on("click",o),y.on("click",a),w.on("click",t)}(jQuery);
pcutler/baseball
wp-content/plugins/jetpack/_inc/build/idc-notice.min.js
JavaScript
gpl-2.0
2,993
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/ /*** Copyright 2009 Lennart Poettering Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***/ #include <string.h> #include <unistd.h> #include <errno.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> #include "ardouralsautil/reserve.h" #ifndef DBUS_TIMEOUT_USE_DEFAULT #define DBUS_TIMEOUT_USE_DEFAULT (-1) #endif struct rd_device { int ref; char *device_name; char *application_name; char *application_device_name; char *service_name; char *object_path; int32_t priority; DBusConnection *connection; unsigned owning:1; unsigned registered:1; unsigned filtering:1; unsigned gave_up:1; rd_request_cb_t request_cb; void *userdata; }; #define SERVICE_PREFIX "org.freedesktop.ReserveDevice1." #define OBJECT_PREFIX "/org/freedesktop/ReserveDevice1/" static const char introspection[] = DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE "<node>" " <!-- If you are looking for documentation make sure to check out\n" " http://git.0pointer.de/?p=reserve.git;a=blob;f=reserve.txt -->\n" " <interface name=\"org.freedesktop.ReserveDevice1\">" " <method name=\"RequestRelease\">" " <arg name=\"priority\" type=\"i\" direction=\"in\"/>" " <arg name=\"result\" type=\"b\" direction=\"out\"/>" " </method>" " <property name=\"Priority\" type=\"i\" access=\"read\"/>" " <property name=\"ApplicationName\" type=\"s\" access=\"read\"/>" " <property name=\"ApplicationDeviceName\" type=\"s\" access=\"read\"/>" " </interface>" " <interface name=\"org.freedesktop.DBus.Properties\">" " <method name=\"Get\">" " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" " <arg name=\"property\" direction=\"in\" type=\"s\"/>" " <arg name=\"value\" direction=\"out\" type=\"v\"/>" " </method>" " </interface>" " <interface name=\"org.freedesktop.DBus.Introspectable\">" " <method name=\"Introspect\">" " <arg name=\"data\" type=\"s\" direction=\"out\"/>" " </method>" " </interface>" "</node>"; static dbus_bool_t add_variant( DBusMessage *m, int type, const void *data) { DBusMessageIter iter, sub; char t[2]; t[0] = (char) type; t[1] = 0; dbus_message_iter_init_append(m, &iter); if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, t, &sub)) return FALSE; if (!dbus_message_iter_append_basic(&sub, type, data)) return FALSE; if (!dbus_message_iter_close_container(&iter, &sub)) return FALSE; return TRUE; } static DBusHandlerResult object_handler( DBusConnection *c, DBusMessage *m, void *userdata) { rd_device *d; DBusError error; DBusMessage *reply = NULL; dbus_error_init(&error); d = userdata; assert(d->ref >= 1); if (dbus_message_is_method_call( m, "org.freedesktop.ReserveDevice1", "RequestRelease")) { int32_t priority; dbus_bool_t ret; if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &priority, DBUS_TYPE_INVALID)) goto invalid; ret = FALSE; if (priority > d->priority && d->request_cb) { d->ref++; if (d->request_cb(d, 0) > 0) { ret = TRUE; d->gave_up = 1; } rd_release(d); } if (!(reply = dbus_message_new_method_return(m))) goto oom; if (!dbus_message_append_args( reply, DBUS_TYPE_BOOLEAN, &ret, DBUS_TYPE_INVALID)) goto oom; if (!dbus_connection_send(c, reply, NULL)) goto oom; dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call( m, "org.freedesktop.DBus.Properties", "Get")) { const char *interface, *property; if (!dbus_message_get_args( m, &error, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID)) goto invalid; if (strcmp(interface, "org.freedesktop.ReserveDevice1") == 0) { const char *empty = ""; if (strcmp(property, "ApplicationName") == 0 && d->application_name) { if (!(reply = dbus_message_new_method_return(m))) goto oom; if (!add_variant( reply, DBUS_TYPE_STRING, d->application_name ? (const char * const *) &d->application_name : &empty)) goto oom; } else if (strcmp(property, "ApplicationDeviceName") == 0) { if (!(reply = dbus_message_new_method_return(m))) goto oom; if (!add_variant( reply, DBUS_TYPE_STRING, d->application_device_name ? (const char * const *) &d->application_device_name : &empty)) goto oom; } else if (strcmp(property, "Priority") == 0) { if (!(reply = dbus_message_new_method_return(m))) goto oom; if (!add_variant( reply, DBUS_TYPE_INT32, &d->priority)) goto oom; } else { if (!(reply = dbus_message_new_error_printf( m, DBUS_ERROR_UNKNOWN_METHOD, "Unknown property %s", property))) goto oom; } if (!dbus_connection_send(c, reply, NULL)) goto oom; dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } } else if (dbus_message_is_method_call( m, "org.freedesktop.DBus.Introspectable", "Introspect")) { const char *i = introspection; if (!(reply = dbus_message_new_method_return(m))) goto oom; if (!dbus_message_append_args( reply, DBUS_TYPE_STRING, &i, DBUS_TYPE_INVALID)) goto oom; if (!dbus_connection_send(c, reply, NULL)) goto oom; dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; invalid: if (reply) dbus_message_unref(reply); if (!(reply = dbus_message_new_error( m, DBUS_ERROR_INVALID_ARGS, "Invalid arguments"))) goto oom; if (!dbus_connection_send(c, reply, NULL)) goto oom; dbus_message_unref(reply); dbus_error_free(&error); return DBUS_HANDLER_RESULT_HANDLED; oom: if (reply) dbus_message_unref(reply); dbus_error_free(&error); return DBUS_HANDLER_RESULT_NEED_MEMORY; } static DBusHandlerResult filter_handler( DBusConnection *c, DBusMessage *m, void *userdata) { rd_device *d; DBusError error; char *name_owner = NULL; dbus_error_init(&error); d = userdata; assert(d->ref >= 1); if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameLost")) { const char *name; if (!dbus_message_get_args( m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) goto invalid; if (strcmp(name, d->service_name) == 0 && d->owning) { /* Verify the actual owner of the name to avoid leaked NameLost * signals from previous reservations. The D-Bus daemon will send * all messages asynchronously in the correct order, but we could * potentially process them too late due to the pseudo-blocking * call mechanism used during both acquisition and release. This * can happen if we release the device and immediately after * reacquire it before NameLost is processed. */ if (!d->gave_up) { const char *un; if ((un = dbus_bus_get_unique_name(c)) && rd_dbus_get_name_owner(c, d->service_name, &name_owner, &error) == 0) if (name_owner && strcmp(name_owner, un) == 0) goto invalid; /* Name still owned by us */ } d->owning = 0; if (!d->gave_up) { d->ref++; if (d->request_cb) d->request_cb(d, 1); d->gave_up = 1; rd_release(d); } } } invalid: free(name_owner); dbus_error_free(&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static const struct DBusObjectPathVTable vtable ={ .message_function = object_handler }; int rd_acquire( rd_device **_d, DBusConnection *connection, const char *device_name, const char *application_name, int32_t priority, rd_request_cb_t request_cb, DBusError *error) { rd_device *d = NULL; int r, k; DBusError _error; DBusMessage *m = NULL, *reply = NULL; dbus_bool_t good; if (!error) error = &_error; dbus_error_init(error); if (!_d) return -EINVAL; if (!connection) return -EINVAL; if (!device_name) return -EINVAL; if (!request_cb && priority != INT32_MAX) return -EINVAL; if (!(d = calloc(sizeof(rd_device), 1))) return -ENOMEM; d->ref = 1; if (!(d->device_name = strdup(device_name))) { r = -ENOMEM; goto fail; } if (!(d->application_name = strdup(application_name))) { r = -ENOMEM; goto fail; } d->priority = priority; d->connection = dbus_connection_ref(connection); d->request_cb = request_cb; if (!(d->service_name = malloc(sizeof(SERVICE_PREFIX) + strlen(device_name)))) { r = -ENOMEM; goto fail; } sprintf(d->service_name, SERVICE_PREFIX "%s", d->device_name); if (!(d->object_path = malloc(sizeof(OBJECT_PREFIX) + strlen(device_name)))) { r = -ENOMEM; goto fail; } sprintf(d->object_path, OBJECT_PREFIX "%s", d->device_name); if ((k = dbus_bus_request_name( d->connection, d->service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE| (priority < INT32_MAX ? DBUS_NAME_FLAG_ALLOW_REPLACEMENT : 0), error)) < 0) { r = -EIO; goto fail; } if (k == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) goto success; if (k != DBUS_REQUEST_NAME_REPLY_EXISTS) { r = -EIO; goto fail; } if (priority <= INT32_MIN) { r = -EBUSY; goto fail; } if (!(m = dbus_message_new_method_call( d->service_name, d->object_path, "org.freedesktop.ReserveDevice1", "RequestRelease"))) { r = -ENOMEM; goto fail; } if (!dbus_message_append_args( m, DBUS_TYPE_INT32, &d->priority, DBUS_TYPE_INVALID)) { r = -ENOMEM; goto fail; } if (!(reply = dbus_connection_send_with_reply_and_block( d->connection, m, 5000, /* 5s */ error))) { if (dbus_error_has_name(error, DBUS_ERROR_TIMED_OUT) || dbus_error_has_name(error, DBUS_ERROR_UNKNOWN_METHOD) || dbus_error_has_name(error, DBUS_ERROR_NO_REPLY)) { /* This must be treated as denied. */ r = -EBUSY; goto fail; } r = -EIO; goto fail; } if (!dbus_message_get_args( reply, error, DBUS_TYPE_BOOLEAN, &good, DBUS_TYPE_INVALID)) { r = -EIO; goto fail; } if (!good) { r = -EBUSY; goto fail; } if ((k = dbus_bus_request_name( d->connection, d->service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE| (priority < INT32_MAX ? DBUS_NAME_FLAG_ALLOW_REPLACEMENT : 0)| DBUS_NAME_FLAG_REPLACE_EXISTING, error)) < 0) { r = -EIO; goto fail; } if (k != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { r = -EIO; goto fail; } success: d->owning = 1; if (!(dbus_connection_register_object_path( d->connection, d->object_path, &vtable, d))) { r = -ENOMEM; goto fail; } d->registered = 1; if (!dbus_connection_add_filter( d->connection, filter_handler, d, NULL)) { r = -ENOMEM; goto fail; } d->filtering = 1; *_d = d; return 0; fail: if (m) dbus_message_unref(m); if (reply) dbus_message_unref(reply); if (&_error == error) dbus_error_free(&_error); if (d) rd_release(d); return r; } void rd_release( rd_device *d) { if (!d) return; assert(d->ref > 0); if (--d->ref > 0) return; if (d->filtering) dbus_connection_remove_filter( d->connection, filter_handler, d); if (d->registered) dbus_connection_unregister_object_path( d->connection, d->object_path); if (d->owning) dbus_bus_release_name( d->connection, d->service_name, NULL); free(d->device_name); free(d->application_name); free(d->application_device_name); free(d->service_name); free(d->object_path); if (d->connection) dbus_connection_unref(d->connection); free(d); } int rd_set_application_device_name(rd_device *d, const char *n) { char *t; if (!d) return -EINVAL; assert(d->ref > 0); if (!(t = strdup(n))) return -ENOMEM; free(d->application_device_name); d->application_device_name = t; return 0; } void rd_set_userdata(rd_device *d, void *userdata) { if (!d) return; assert(d->ref > 0); d->userdata = userdata; } void* rd_get_userdata(rd_device *d) { if (!d) return NULL; assert(d->ref > 0); return d->userdata; } int rd_dbus_get_name_owner( DBusConnection *connection, const char *name, char **name_owner, DBusError *error) { DBusMessage *msg, *reply; int r; *name_owner = NULL; if (!(msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetNameOwner"))) { r = -ENOMEM; goto fail; } if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { r = -ENOMEM; goto fail; } reply = dbus_connection_send_with_reply_and_block(connection, msg, DBUS_TIMEOUT_USE_DEFAULT, error); dbus_message_unref(msg); msg = NULL; if (reply) { if (!dbus_message_get_args(reply, error, DBUS_TYPE_STRING, name_owner, DBUS_TYPE_INVALID)) { dbus_message_unref(reply); r = -EIO; goto fail; } *name_owner = strdup(*name_owner); dbus_message_unref(reply); if (!*name_owner) { r = -ENOMEM; goto fail; } } else if (dbus_error_has_name(error, "org.freedesktop.DBus.Error.NameHasNoOwner")) dbus_error_free(error); else { r = -EIO; goto fail; } return 0; fail: if (msg) dbus_message_unref(msg); return r; }
CadishShank/Ardour-5.0.2.0-Cad
libs/ardouralsautil/reserve.c
C
gpl-2.0
14,311
<?php /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * * @author Remon <no@email.local> */ $lang['server'] = 'De MySQL server'; $lang['user'] = 'MySql gebruikersnaam'; $lang['password'] = 'Wachtwoord van bovenstaande gebruiker'; $lang['database'] = 'Te gebruiken database'; $lang['charset'] = 'Tekenset voor database'; $lang['debug'] = 'Tonen aanvullende debuginformatie'; $lang['forwardClearPass'] = 'Wachtwoorden als leesbare tekst in SQL commando\'s opnemen in plaats van versleutelde tekens'; $lang['TablesToLock'] = 'Kommagescheiden lijst van tabellen die gelocked moeten worden bij schrijfacties'; $lang['checkPass'] = 'SQL commando voor het verifiëren van wachtwoorden'; $lang['getUserInfo'] = 'SQL commando voor het ophalen van gebruikersinformatie'; $lang['getGroups'] = 'SQL commando voor het ophalen van groepslidmaatschappen'; $lang['getUsers'] = 'SQL commando voor het tonen van alle gebruikers'; $lang['FilterLogin'] = 'SQL clausule voor het filteren van gebruikers op inlognaam'; $lang['FilterName'] = 'SQL clausule voor het filteren van gebruikers op volledige naam'; $lang['FilterEmail'] = 'SQL clausule voor het filteren van gebruikers op e-mailadres'; $lang['FilterGroup'] = 'SQL clausule voor het filteren van gebruikers op groepslidmaatschap'; $lang['SortOrder'] = 'SQL clausule voor het sorteren van gebruikers'; $lang['addUser'] = 'SQL commando om een nieuwe gebruiker toe te voegen'; $lang['addGroup'] = 'SQL commando om een nieuwe groep toe te voegen'; $lang['addUserGroup'] = 'SQL commando om een gebruiker aan een bestaande groep toe te voegen'; $lang['delGroup'] = 'SQL commando om een groep te verwijderen'; $lang['getUserID'] = 'SQL commando om de de primaire sleutel van een gebruiker op te halen'; $lang['delUser'] = 'SQL commando om een gebruiker te verwijderen'; $lang['delUserRefs'] = 'SQL commando om een gebruiker uit alle groepen te verwijderen'; $lang['updateUser'] = 'SQL commando om een gebruikersprofiel bij te werken'; $lang['UpdateLogin'] = 'Bijwerkcommando om de inlognaam van de gebruiker bij te werken'; $lang['UpdatePass'] = 'Bijwerkcommando om het wachtwoord van de gebruiker bij te werken'; $lang['UpdateEmail'] = 'Bijwerkcommando om het e-mailadres van de gebruiker bij te werken'; $lang['UpdateName'] = 'Bijwerkcommando om de volledige naam van de gebruiker bij te werken'; $lang['UpdateTarget'] = 'Beperkingsclausule om de gebruiker te identificeren voor bijwerken'; $lang['delUserGroup'] = 'SQL commando om een gebruiker uit een bepaalde groep te verwijderen'; $lang['getGroupID'] = 'SQL commando om de primaire sletel van een bepaalde groep op te halen'; $lang['debug_o_0'] = 'geen'; $lang['debug_o_1'] = 'alleen bij fouten'; $lang['debug_o_2'] = 'alle SQL queries';
claudehohl/dokuwiki-kickstart
lib/plugins/authmysql/lang/nl/settings.php
PHP
gpl-2.0
3,149
/* * $Id$ * * Copyright (C) 2006 Voice Sistem SRL * * This file is part of Kamailio, a free SIP server. * * Kamailio 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. * * Kamailio 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * History: * --------- * 2006-09-25 first version (bogdan) */ /*! * \file * \brief MI_FIFO :: Fifo API for the Kamailio manager interface * \ingroup mi */ #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <signal.h> #include "../../sr_module.h" #include "../../dprint.h" #include "../../ut.h" #include "../../pt.h" #include "../../globals.h" #include "../../mem/mem.h" #include "../../mem/shm_mem.h" #include "../../cfg/cfg_struct.h" #include "../../lib/kmi/mi.h" #include "mi_fifo.h" #include "mi_parser.h" #include "mi_writer.h" #include "fifo_fnc.h" static int mi_mod_init(void); static int mi_child_init(int rank); static void fifo_process(int rank); static int mi_destroy(void); /* FIFO server vars */ static char *mi_fifo = NAME "_fifo"; /*!< FIFO name */ static char *mi_fifo_reply_dir = DEFAULT_MI_REPLY_DIR; /*!< dir where reply fifos are allowed */ static char *mi_reply_indent = DEFAULT_MI_REPLY_IDENT; static int mi_fifo_uid = -1; /*!< Fifo default UID */ static char *mi_fifo_uid_s = 0; /*!< Fifo default User ID name */ static int mi_fifo_gid = -1; /*!< Fifo default Group ID */ static char *mi_fifo_gid_s = 0; /*!< Fifo default Group ID name */ static int mi_fifo_mode = S_IRUSR| S_IWUSR| S_IRGRP| S_IWGRP; /* Default file mode rw-rw---- */ static int read_buf_size = MAX_MI_FIFO_READ; MODULE_VERSION /*! \brief Configuration parameters in .cfg file */ static param_export_t mi_params[] = { {"fifo_name", PARAM_STRING, &mi_fifo}, {"fifo_mode", INT_PARAM, &mi_fifo_mode}, {"fifo_group", PARAM_STRING, &mi_fifo_gid_s}, {"fifo_group", INT_PARAM, &mi_fifo_gid}, {"fifo_user", PARAM_STRING, &mi_fifo_uid_s}, {"fifo_user", INT_PARAM, &mi_fifo_uid}, {"reply_dir", PARAM_STRING, &mi_fifo_reply_dir}, {"reply_indent", PARAM_STRING, &mi_reply_indent}, {0,0,0} }; static proc_export_t mi_procs[] = { {"MI FIFO", 0, 0, fifo_process, 1 }, {0,0,0,0,0} }; struct module_exports exports = { "mi_fifo", /*!< module name */ DEFAULT_DLFLAGS, /*!< dlopen flags */ 0, /*!< exported functions */ mi_params, /*!< exported parameters */ 0, /*!< exported statistics */ 0, /*!< exported MI functions */ 0, /*!< exported pseudo-variables */ mi_procs, /*!< extra processes */ mi_mod_init, /*!< module initialization function */ 0, /*!< response handling function */ (destroy_function) mi_destroy, /*!< destroy function */ mi_child_init /*!< per-child init function */ }; /*! \brief Initialize mi_fifo module */ static int mi_mod_init(void) { int n; struct stat filestat; int len; int sep; char *p; /* checking the mi_fifo module param */ if (mi_fifo==NULL || *mi_fifo == 0) { LM_ERR("No MI fifo configured\n"); return -1; } if(*mi_fifo != '/') { if(runtime_dir!=NULL && *runtime_dir!=0) { len = strlen(runtime_dir); sep = 0; if(runtime_dir[len-1]!='/') { sep = 1; } len += sep + strlen(mi_fifo); p = pkg_malloc(len + 1); if(p==NULL) { LM_ERR("no more pkg\n"); return -1; } strcpy(p, runtime_dir); if(sep) strcat(p, "/"); strcat(p, mi_fifo); mi_fifo = p; LM_DBG("fifo path is [%s]\n", mi_fifo); } } LM_DBG("testing mi_fifo existance ...\n"); n=stat(mi_fifo, &filestat); if (n==0) { /* FIFO exist, delete it (safer) if no config check */ if(config_check==0) { if (unlink(mi_fifo)<0){ LM_ERR("Cannot delete old MI fifo (%s): %s\n", mi_fifo, strerror(errno)); return -1; } } } else if (n<0 && errno!=ENOENT){ LM_ERR("MI FIFO stat failed: %s\n", strerror(errno)); return -1; } /* checking the mi_fifo_reply_dir param */ if(!mi_fifo_reply_dir || *mi_fifo_reply_dir == 0) { LM_ERR("mi_fifo_reply_dir parameter is empty\n"); return -1; } /* Check if the directory for the reply fifo exists */ n = stat(mi_fifo_reply_dir, &filestat); if(n < 0){ LM_ERR("Directory stat for MI Fifo reply failed: %s\n", strerror(errno)); return -1; } if(S_ISDIR(filestat.st_mode) == 0){ LM_ERR("mi_fifo_reply_dir parameter is not a directory\n"); return -1; } /* check mi_fifo_mode */ if(!mi_fifo_mode){ LM_WARN("cannot specify mi_fifo_mode = 0, forcing it to rw-------\n"); mi_fifo_mode = S_IRUSR| S_IWUSR; } if (mi_fifo_uid_s){ if (user2uid(&mi_fifo_uid, &mi_fifo_gid, mi_fifo_uid_s)<0){ LM_ERR("Bad user name %s\n", mi_fifo_uid_s); return -1; } } if (mi_fifo_gid_s){ if (group2gid(&mi_fifo_gid, mi_fifo_gid_s)<0){ LM_ERR("Bad group name %s\n", mi_fifo_gid_s); return -1; } } /* add space for one extra process */ register_procs(1); /* add child to update local config framework structures */ cfg_register_child(1); return 0; } /*! \brief Initialize module for child processes */ static int mi_child_init(int rank) { int pid; if (rank==PROC_TIMER || rank>0 ) { if ( mi_writer_init(read_buf_size, mi_reply_indent)!=0 ) { LM_CRIT("failed to init the reply writer\n"); return -1; } } if (rank==PROC_MAIN) { pid=fork_process(PROC_NOCHLDINIT, "MI FIFO", 1); if (pid<0) return -1; /* error */ if(pid==0){ /* child */ /* initialize the config framework */ if (cfg_child_init()) return -1; fifo_process(1); } } return 0; } static void fifo_process(int rank) { FILE *fifo_stream; LM_DBG("new process with pid = %d created\n",getpid()); fifo_stream = mi_init_fifo_server( mi_fifo, mi_fifo_mode, mi_fifo_uid, mi_fifo_gid, mi_fifo_reply_dir); if ( fifo_stream==NULL ) { LM_CRIT("The function mi_init_fifo_server returned with error!!!\n"); exit(-1); } if( init_mi_child(PROC_NOCHLDINIT, 1)!=0) { LM_CRIT("Failed to init the mi process\n"); exit(-1); } if ( mi_parser_init(read_buf_size)!=0 ) { LM_CRIT("Failed to init the command parser\n"); exit(-1); } if ( mi_writer_init(read_buf_size, mi_reply_indent)!=0 ) { LM_CRIT("Failed to init the reply writer\n"); exit(-1); } mi_fifo_server( fifo_stream ); LM_CRIT("the function mi_fifo_server returned with error!!!\n"); exit(-1); } static int mi_destroy(void) { int n; struct stat filestat; /* destroying the fifo file */ n=stat(mi_fifo, &filestat); if (n==0){ /* FIFO exist, delete it (safer) if not config check */ if(config_check==0) { if (unlink(mi_fifo)<0){ LM_ERR("cannot delete the fifo (%s): %s\n", mi_fifo, strerror(errno)); goto error; } } } else if (n<0 && errno!=ENOENT) { LM_ERR("FIFO stat failed: %s\n", strerror(errno)); goto error; } return 0; error: return -1; }
axler00/kamailio
modules/mi_fifo/mi_fifo.c
C
gpl-2.0
7,667
/* * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * * 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 "DebugCmdLogger.h" using namespace G3D; namespace VMAP { bool CommandFileRW::appendCmd(const Command& #ifdef _DEBUG pCommand #endif ) { #ifdef _DEBUG bool result = false; if(iWritingEnabled || pCommand.isCoreCmd()) { FILE* f = fopen(iFileName.c_str(), "ab"); if(f) { result = true; if(fwrite(&pCommand, sizeof(Command), 1, f) != 1) { result = false; } fclose(f); } } else { result = true; } return result; #else return true; #endif } //========================================================= bool CommandFileRW::appendCmds(const Array<Command>& #ifdef _DEBUG pCmdArray #endif ) { #ifdef _DEBUG bool result = false; if(iWritingEnabled) { FILE* f; if(resetfile) f = fopen(iFileName.c_str(), "wb"); else f = fopen(iFileName.c_str(), "ab"); resetfile = false; if(f) { result = true; for(int i=0; i<pCmdArray.size(); ++i) { if(fwrite(&pCmdArray[i], sizeof(Command), 1, f) != 1) { result = false; break; } } fclose(f); } } else { result = true; } return result; #else return true; #endif } //========================================================= bool CommandFileRW::getNewCommands(Array<Command>& pCmdArray) { bool result = false; FILE* f = fopen(iFileName.c_str(), "rb"); if(f) { Command cmd; if(fseek(f, iLastPos, SEEK_SET) == 0) { result = true; } while(result) { if(fread(&cmd, sizeof(Command), 1, f) != 1) { result = false; } iLastPos = ftell(f); if(cmd.getType() == STOP) { break; } pCmdArray.append(cmd); } fclose(f); } if(result) { iCommandArray.append(pCmdArray); } return(result); } //======================================================== }
DarkQuantum/hotmangos
src/shared/vmap/DebugCmdLogger.cpp
C++
gpl-2.0
3,285
/* MPU6050 motion sensor driver * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. * */ #include <linux/interrupt.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/irq.h> #include <linux/miscdevice.h> #include <asm/uaccess.h> #include <linux/delay.h> #include <linux/input.h> #include <linux/workqueue.h> #include <linux/kobject.h> #include <linux/earlysuspend.h> #include <linux/platform_device.h> #include <asm/atomic.h> #include <cust_acc.h> #include <linux/hwmsensor.h> #include <linux/hwmsen_dev.h> #include <linux/sensors_io.h> #include "mpu6050.h" #include "mpu6xxx_hwselftest.h" #include <linux/hwmsen_helper.h> #include <mach/mt_typedefs.h> #include <mach/mt_gpio.h> #include <mach/mt_pm_ldo.h> #define POWER_NONE_MACRO MT65XX_POWER_NONE /*----------------------------------------------------------------------------*/ #define DEBUG 1 /*----------------------------------------------------------------------------*/ #define CONFIG_MPU6050_LOWPASS /*apply low pass filter on output*/ #define SW_CALIBRATION /*----------------------------------------------------------------------------*/ #define MPU6050_AXIS_X 0 #define MPU6050_AXIS_Y 1 #define MPU6050_AXIS_Z 2 #define MPU6050_AXES_NUM 3 #define MPU6050_DATA_LEN 6 #define MPU6050_DEV_NAME "MPU6050G" /* name must different with gyro mpu6050 */ /*----------------------------------------------------------------------------*/ static const struct i2c_device_id mpu6050_i2c_id[] = {{MPU6050_DEV_NAME,0},{}}; static struct i2c_board_info __initdata i2c_mpu6050={ I2C_BOARD_INFO(MPU6050_DEV_NAME, (MPU6050_I2C_SLAVE_ADDR>>1))}; /*----------------------------------------------------------------------------*/ static int mpu6050_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id); static int mpu6050_i2c_remove(struct i2c_client *client); static int mpu6050_i2c_detect(struct i2c_client *client, struct i2c_board_info *info); #ifndef USE_EARLY_SUSPEND static int mpu6050_suspend(struct i2c_client *client, pm_message_t msg) ; static int mpu6050_resume(struct i2c_client *client); #endif /*----------------------------------------------------------------------------*/ typedef enum { MPU6050_TRC_FILTER = 0x01, MPU6050_TRC_RAWDATA = 0x02, MPU6050_TRC_IOCTL = 0x04, MPU6050_TRC_CALI = 0X08, MPU6050_TRC_INFO = 0X10, } MPU6050_TRC; /*----------------------------------------------------------------------------*/ struct scale_factor { u8 whole; u8 fraction; }; /*----------------------------------------------------------------------------*/ struct data_resolution { struct scale_factor scalefactor; int sensitivity; }; /*----------------------------------------------------------------------------*/ #define C_MAX_FIR_LENGTH (32) /*----------------------------------------------------------------------------*/ struct data_filter { s16 raw[C_MAX_FIR_LENGTH][MPU6050_AXES_NUM]; int sum[MPU6050_AXES_NUM]; int num; int idx; }; /*----------------------------------------------------------------------------*/ struct mpu6050_i2c_data { struct i2c_client *client; struct acc_hw *hw; struct hwmsen_convert cvt; /*misc*/ struct data_resolution *reso; atomic_t trace; atomic_t suspend; atomic_t selftest; atomic_t filter; s16 cali_sw[MPU6050_AXES_NUM+1]; /*data*/ s8 offset[MPU6050_AXES_NUM+1]; /*+1: for 4-byte alignment*/ s16 data[MPU6050_AXES_NUM+1]; #if defined(CONFIG_MPU6050_LOWPASS) atomic_t firlen; atomic_t fir_en; struct data_filter fir; #endif /*early suspend*/ #if defined(USE_EARLY_SUSPEND) struct early_suspend early_drv; #endif u8 bandwidth; #if MPU6XXX_HWSELFTEST struct inv_selftest_device mpu_selftest_device; #endif }; /*----------------------------------------------------------------------------*/ static struct i2c_driver mpu6050_i2c_driver = { .driver = { .name = MPU6050_DEV_NAME, }, .probe = mpu6050_i2c_probe, .remove = mpu6050_i2c_remove, .detect = mpu6050_i2c_detect, #if !defined(USE_EARLY_SUSPEND) .suspend = mpu6050_suspend, .resume = mpu6050_resume, #endif .id_table = mpu6050_i2c_id, }; /*----------------------------------------------------------------------------*/ static struct i2c_client *mpu6050_i2c_client = NULL; static struct platform_driver mpu6050_gsensor_driver; static struct mpu6050_i2c_data *obj_i2c_data = NULL; static bool sensor_power = false; static GSENSOR_VECTOR3D gsensor_gain; static char selftestRes[8]= {0}; /*----------------------------------------------------------------------------*/ #define GSE_TAG "[Gsensor] " #define GSE_FUN(f) printk(GSE_TAG"%s\n", __FUNCTION__) #define GSE_ERR(fmt, args...) printk(GSE_TAG"%s %d : "fmt, __FUNCTION__, __LINE__, ##args) #define GSE_LOG(fmt, args...) printk(GSE_TAG fmt, ##args) /*----------------------------------------------------------------------------*/ static struct data_resolution mpu6050_data_resolution[] = { /*8 combination by {FULL_RES,RANGE}*/ {{ 0, 6}, 16384}, /*+/-2g in 16-bit resolution: 0.06 mg/LSB*/ {{ 0, 12}, 8192}, /*+/-4g in 16-bit resolution: 0.12 mg/LSB*/ {{ 0, 24}, 4096}, /*+/-8g in 16-bit resolution: 0.24 mg/LSB*/ {{ 0, 5}, 2048}, /*+/-16g in 16-bit resolution: 0.49 mg/LSB*/ }; /*----------------------------------------------------------------------------*/ static struct data_resolution mpu6050_offset_resolution = {{ 0, 5}, 2048}; static unsigned int power_on = 0; extern int MPU6050_gyro_power(void); extern int MPU6050_gyro_mode(void); int MPU6050_gse_power( void) { return(power_on); } EXPORT_SYMBOL(MPU6050_gse_power); int MPU6050_gse_mode(void) { return sensor_power; } EXPORT_SYMBOL(MPU6050_gse_mode); int MPU6050_i2c_master_send(u8 *buf, u8 len) { int res = 0; if (NULL == mpu6050_i2c_client) { GSE_ERR("MPU6050_i2c_master_send null ptr!!\n"); } else { res = i2c_master_send(mpu6050_i2c_client, buf, len); } return res; } EXPORT_SYMBOL(MPU6050_i2c_master_send); int MPU6050_i2c_master_recv(u8 *buf, u8 len) { int res = 0; if (NULL == mpu6050_i2c_client) { GSE_ERR("MPU6050_i2c_master_recv null ptr!!\n"); } else { res = i2c_master_recv(mpu6050_i2c_client, buf, len); } return res; } EXPORT_SYMBOL(MPU6050_i2c_master_recv); /*----------------------------------------------------------------------------*/ static int mpu_i2c_read_block(struct i2c_client *client, u8 addr, u8 *data, u8 len){ u8 beg = addr; struct i2c_msg msgs[2] = { { .addr = client->addr, .flags = 0, .len = 1, .buf = &beg }, { .addr = client->addr, .flags = I2C_M_RD, .len = len, .buf = data, } }; int err; if (!client) return -EINVAL; else if (len > C_I2C_FIFO_SIZE) { GSE_ERR(" length %d exceeds %d\n", len, C_I2C_FIFO_SIZE); return -EINVAL; } err = i2c_transfer(client->adapter, msgs, sizeof(msgs)/sizeof(msgs[0])); if (err != 2) { GSE_ERR("i2c_transfer error: (%d %p %d) %d\n", addr, data, len, err); err = -EIO; } else { err = 0; } return err; } int MPU6050_hwmsen_read_block(u8 addr, u8 *buf, u8 len) { if (NULL == mpu6050_i2c_client) { GSE_ERR("MPU6050_hwmsen_read_block null ptr!!\n"); return MPU6050_ERR_I2C; } return mpu_i2c_read_block(mpu6050_i2c_client, addr, buf, len); } EXPORT_SYMBOL(MPU6050_hwmsen_read_block); int MPU6050_hwmsen_read_byte(u8 addr, u8 *buf) { if (NULL == mpu6050_i2c_client) { GSE_ERR("MPU6050_hwmsen_read_byte null ptr!!\n"); return MPU6050_ERR_I2C; } return mpu_i2c_read_block(mpu6050_i2c_client, addr, buf, 1); } EXPORT_SYMBOL(MPU6050_hwmsen_read_byte); /*--------------------mpu6050 power control function----------------------------------*/ static void MPU6050_power(struct acc_hw *hw, unsigned int on) { if (hw->power_id != POWER_NONE_MACRO) // have externel LDO { GSE_LOG("power %s\n", on ? "on" : "off"); if (power_on == on) // power status not change { GSE_LOG("ignore power control: %d\n", on); } else if (on) // power on { if (!hwPowerOn(hw->power_id, hw->power_vol, "MPU6050G")) { GSE_ERR("power on fails!!\n"); } } else // power off { if (MPU6050_gyro_power() == false) { if (!hwPowerDown(hw->power_id, "MPU6050G")) { GSE_ERR("power off fail!!\n"); } } } } power_on = on; } /*----------------------------------------------------------------------------*/ static int MPU6050_SetPowerMode(struct i2c_client *client, bool enable) { u8 databuf[2]; int res = 0; //u8 addr = MPU6050_REG_POWER_CTL; struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); if (enable == sensor_power) { GSE_LOG("Sensor power status is newest!\n"); return MPU6050_SUCCESS; } databuf[0] = MPU6050_REG_POWER_CTL; res = i2c_master_send(client, databuf, 0x1); if (res <= 0) { return MPU6050_ERR_I2C; } udelay(500); databuf[0] = 0x0; /* res = i2c_master_recv(client, databuf, 1); if (res <= 0) { return MPU6050_ERR_I2C; } */ databuf[0] &= ~MPU6050_SLEEP; if (enable == FALSE) { if (MPU6050_gyro_mode() == false) { databuf[0] |= MPU6050_SLEEP; } } else { // do nothing } databuf[1] = databuf[0]; databuf[0] = MPU6050_REG_POWER_CTL; res = i2c_master_send(client, databuf, 0x2); if (res <= 0) { GSE_LOG("set power mode failed!\n"); return MPU6050_ERR_I2C; } else if (atomic_read(&obj->trace) & MPU6050_TRC_INFO) { GSE_LOG("set power mode ok %d!\n", databuf[1]); } if (enable == true) { msleep(50); } sensor_power = enable; return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int MPU6050_SetDataResolution(struct mpu6050_i2c_data *obj) { int err; u8 dat, reso; if ((err = mpu_i2c_read_block(obj->client, MPU6050_REG_DATA_FORMAT, &dat, 1))) { GSE_ERR("write data format fail!!\n"); return err; } /*the data_reso is combined by 3 bits: {FULL_RES, DATA_RANGE}*/ reso = 0x00; reso = (dat & MPU6050_RANGE_16G) >> 3; if (reso < sizeof(mpu6050_data_resolution)/sizeof(mpu6050_data_resolution[0])) { obj->reso = &mpu6050_data_resolution[reso]; return 0; } else { return -EINVAL; } } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadData(struct i2c_client *client, s16 data[MPU6050_AXES_NUM]) { struct mpu6050_i2c_data *priv = i2c_get_clientdata(client); u8 buf[MPU6050_DATA_LEN] = {0}; int err = 0; if (NULL == client) { return -EINVAL; } { /* write then burst read */ mpu_i2c_read_block(client, MPU6050_REG_DATAX0, buf, MPU6050_DATA_LEN); data[MPU6050_AXIS_X] = (s16)((buf[MPU6050_AXIS_X*2] << 8) | (buf[MPU6050_AXIS_X*2+1] )); data[MPU6050_AXIS_Y] = (s16)((buf[MPU6050_AXIS_Y*2] << 8) | (buf[MPU6050_AXIS_Y*2+1] )); data[MPU6050_AXIS_Z] = (s16)((buf[MPU6050_AXIS_Z*2] << 8) | (buf[MPU6050_AXIS_Z*2+1] )); if (atomic_read(&priv->trace) & MPU6050_TRC_RAWDATA) { GSE_LOG("[%08X %08X %08X] => [%5d %5d %5d]\n", data[MPU6050_AXIS_X], data[MPU6050_AXIS_Y], data[MPU6050_AXIS_Z], data[MPU6050_AXIS_X], data[MPU6050_AXIS_Y], data[MPU6050_AXIS_Z]); } #ifdef CONFIG_MPU6050_LOWPASS if (atomic_read(&priv->filter)) { if (atomic_read(&priv->fir_en) && !atomic_read(&priv->suspend)) { int idx, firlen = atomic_read(&priv->firlen); if (priv->fir.num < firlen) { priv->fir.raw[priv->fir.num][MPU6050_AXIS_X] = data[MPU6050_AXIS_X]; priv->fir.raw[priv->fir.num][MPU6050_AXIS_Y] = data[MPU6050_AXIS_Y]; priv->fir.raw[priv->fir.num][MPU6050_AXIS_Z] = data[MPU6050_AXIS_Z]; priv->fir.sum[MPU6050_AXIS_X] += data[MPU6050_AXIS_X]; priv->fir.sum[MPU6050_AXIS_Y] += data[MPU6050_AXIS_Y]; priv->fir.sum[MPU6050_AXIS_Z] += data[MPU6050_AXIS_Z]; if (atomic_read(&priv->trace) & MPU6050_TRC_FILTER) { GSE_LOG("add [%2d] [%5d %5d %5d] => [%5d %5d %5d]\n", priv->fir.num, priv->fir.raw[priv->fir.num][MPU6050_AXIS_X], priv->fir.raw[priv->fir.num][MPU6050_AXIS_Y], priv->fir.raw[priv->fir.num][MPU6050_AXIS_Z], priv->fir.sum[MPU6050_AXIS_X], priv->fir.sum[MPU6050_AXIS_Y], priv->fir.sum[MPU6050_AXIS_Z]); } priv->fir.num++; priv->fir.idx++; } else { idx = priv->fir.idx % firlen; priv->fir.sum[MPU6050_AXIS_X] -= priv->fir.raw[idx][MPU6050_AXIS_X]; priv->fir.sum[MPU6050_AXIS_Y] -= priv->fir.raw[idx][MPU6050_AXIS_Y]; priv->fir.sum[MPU6050_AXIS_Z] -= priv->fir.raw[idx][MPU6050_AXIS_Z]; priv->fir.raw[idx][MPU6050_AXIS_X] = data[MPU6050_AXIS_X]; priv->fir.raw[idx][MPU6050_AXIS_Y] = data[MPU6050_AXIS_Y]; priv->fir.raw[idx][MPU6050_AXIS_Z] = data[MPU6050_AXIS_Z]; priv->fir.sum[MPU6050_AXIS_X] += data[MPU6050_AXIS_X]; priv->fir.sum[MPU6050_AXIS_Y] += data[MPU6050_AXIS_Y]; priv->fir.sum[MPU6050_AXIS_Z] += data[MPU6050_AXIS_Z]; priv->fir.idx++; data[MPU6050_AXIS_X] = priv->fir.sum[MPU6050_AXIS_X]/firlen; data[MPU6050_AXIS_Y] = priv->fir.sum[MPU6050_AXIS_Y]/firlen; data[MPU6050_AXIS_Z] = priv->fir.sum[MPU6050_AXIS_Z]/firlen; if (atomic_read(&priv->trace) & MPU6050_TRC_FILTER) { GSE_LOG("add [%2d] [%5d %5d %5d] => [%5d %5d %5d] : [%5d %5d %5d]\n", idx, priv->fir.raw[idx][MPU6050_AXIS_X], priv->fir.raw[idx][MPU6050_AXIS_Y], priv->fir.raw[idx][MPU6050_AXIS_Z], priv->fir.sum[MPU6050_AXIS_X], priv->fir.sum[MPU6050_AXIS_Y], priv->fir.sum[MPU6050_AXIS_Z], data[MPU6050_AXIS_X], data[MPU6050_AXIS_Y], data[MPU6050_AXIS_Z]); } } } } #endif } return err; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadOffset(struct i2c_client *client, s8 ofs[MPU6050_AXES_NUM]) { int err = 0; #ifdef SW_CALIBRATION ofs[0]=ofs[1]=ofs[2]=0x0; #else if ((err = mpu_i2c_read_block(client, MPU6050_REG_OFSX, ofs, MPU6050_AXES_NUM))) { GSE_ERR("error: %d\n", err); } #endif //GSE_LOG("offesx=%x, y=%x, z=%x",ofs[0],ofs[1],ofs[2]); return err; } /*----------------------------------------------------------------------------*/ static int MPU6050_ResetCalibration(struct i2c_client *client) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); #ifndef SW_CALIBRATION s8 ofs[MPU6050_AXES_NUM] = {0x00, 0x00, 0x00}; #endif int err = 0; #ifdef SW_CALIBRATION /* do not thing */ #else if ((err = hwmsen_write_block(client, MPU6050_REG_OFSX, ofs, MPU6050_AXES_NUM))) { GSE_ERR("error: %d\n", err); } #endif memset(obj->cali_sw, 0x00, sizeof(obj->cali_sw)); memset(obj->offset, 0x00, sizeof(obj->offset)); return err; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadCalibration(struct i2c_client *client, int dat[MPU6050_AXES_NUM]) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); #ifdef SW_CALIBRATION int mul; #else int err; #endif #ifdef SW_CALIBRATION mul = 0;//only SW Calibration, disable HW Calibration #else if ((err = MPU6050_ReadOffset(client, obj->offset))) { GSE_ERR("read offset fail, %d\n", err); return err; } mul = obj->reso->sensitivity/mpu6050_offset_resolution.sensitivity; #endif dat[obj->cvt.map[MPU6050_AXIS_X]] = obj->cvt.sign[MPU6050_AXIS_X]*(obj->offset[MPU6050_AXIS_X]*mul*GRAVITY_EARTH_1000/(obj->reso->sensitivity) + obj->cali_sw[MPU6050_AXIS_X]); dat[obj->cvt.map[MPU6050_AXIS_Y]] = obj->cvt.sign[MPU6050_AXIS_Y]*(obj->offset[MPU6050_AXIS_Y]*mul*GRAVITY_EARTH_1000/(obj->reso->sensitivity) + obj->cali_sw[MPU6050_AXIS_Y]); dat[obj->cvt.map[MPU6050_AXIS_Z]] = obj->cvt.sign[MPU6050_AXIS_Z]*(obj->offset[MPU6050_AXIS_Z]*mul*GRAVITY_EARTH_1000/(obj->reso->sensitivity) + obj->cali_sw[MPU6050_AXIS_Z]); return 0; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadCalibrationEx(struct i2c_client *client, int act[MPU6050_AXES_NUM], int raw[MPU6050_AXES_NUM]) { /*raw: the raw calibration data; act: the actual calibration data*/ struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); #ifdef SW_CALIBRATION int mul; #else int err; #endif #ifdef SW_CALIBRATION mul = 0;//only SW Calibration, disable HW Calibration #else if ((err = MPU6050_ReadOffset(client, obj->offset))) { GSE_ERR("read offset fail, %d\n", err); return err; } mul = obj->reso->sensitivity/mpu6050_offset_resolution.sensitivity; #endif raw[MPU6050_AXIS_X] = obj->offset[MPU6050_AXIS_X]*mul*GRAVITY_EARTH_1000/(obj->reso->sensitivity) + obj->cali_sw[MPU6050_AXIS_X]; raw[MPU6050_AXIS_Y] = obj->offset[MPU6050_AXIS_Y]*mul*GRAVITY_EARTH_1000/(obj->reso->sensitivity) + obj->cali_sw[MPU6050_AXIS_Y]; raw[MPU6050_AXIS_Z] = obj->offset[MPU6050_AXIS_Z]*mul*GRAVITY_EARTH_1000/(obj->reso->sensitivity) + obj->cali_sw[MPU6050_AXIS_Z]; act[obj->cvt.map[MPU6050_AXIS_X]] = obj->cvt.sign[MPU6050_AXIS_X]*raw[MPU6050_AXIS_X]; act[obj->cvt.map[MPU6050_AXIS_Y]] = obj->cvt.sign[MPU6050_AXIS_Y]*raw[MPU6050_AXIS_Y]; act[obj->cvt.map[MPU6050_AXIS_Z]] = obj->cvt.sign[MPU6050_AXIS_Z]*raw[MPU6050_AXIS_Z]; return 0; } /*----------------------------------------------------------------------------*/ static int MPU6050_WriteCalibration(struct i2c_client *client, int dat[MPU6050_AXES_NUM]) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); int err; int cali[MPU6050_AXES_NUM], raw[MPU6050_AXES_NUM]; #ifndef SW_CALIBRATION int lsb = mpu6050_offset_resolution.sensitivity; int divisor = obj->reso->sensitivity/lsb; #endif if ((err = MPU6050_ReadCalibrationEx(client, cali, raw))) /*offset will be updated in obj->offset*/ { GSE_ERR("read offset fail, %d\n", err); return err; } GSE_LOG("OLDOFF: (%+3d %+3d %+3d): (%+3d %+3d %+3d) / (%+3d %+3d %+3d)\n", raw[MPU6050_AXIS_X], raw[MPU6050_AXIS_Y], raw[MPU6050_AXIS_Z], obj->offset[MPU6050_AXIS_X], obj->offset[MPU6050_AXIS_Y], obj->offset[MPU6050_AXIS_Z], obj->cali_sw[MPU6050_AXIS_X], obj->cali_sw[MPU6050_AXIS_Y], obj->cali_sw[MPU6050_AXIS_Z]); /*calculate the real offset expected by caller*/ #if 0 cali[MPU6050_AXIS_X] = cali[MPU6050_AXIS_X] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; cali[MPU6050_AXIS_Y] = cali[MPU6050_AXIS_Y] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; cali[MPU6050_AXIS_Z] = cali[MPU6050_AXIS_Z] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; #endif cali[MPU6050_AXIS_X] += dat[MPU6050_AXIS_X]; cali[MPU6050_AXIS_Y] += dat[MPU6050_AXIS_Y]; cali[MPU6050_AXIS_Z] += dat[MPU6050_AXIS_Z]; GSE_LOG("UPDATE: (%+3d %+3d %+3d)\n", dat[MPU6050_AXIS_X], dat[MPU6050_AXIS_Y], dat[MPU6050_AXIS_Z]); #ifdef SW_CALIBRATION obj->cali_sw[MPU6050_AXIS_X] = obj->cvt.sign[MPU6050_AXIS_X]*(cali[obj->cvt.map[MPU6050_AXIS_X]]); obj->cali_sw[MPU6050_AXIS_Y] = obj->cvt.sign[MPU6050_AXIS_Y]*(cali[obj->cvt.map[MPU6050_AXIS_Y]]); obj->cali_sw[MPU6050_AXIS_Z] = obj->cvt.sign[MPU6050_AXIS_Z]*(cali[obj->cvt.map[MPU6050_AXIS_Z]]); #else obj->offset[MPU6050_AXIS_X] = (s8)(obj->cvt.sign[MPU6050_AXIS_X]*(cali[obj->cvt.map[MPU6050_AXIS_X]])*(obj->reso->sensitivity)/GRAVITY_EARTH_1000/(divisor)); obj->offset[MPU6050_AXIS_Y] = (s8)(obj->cvt.sign[MPU6050_AXIS_Y]*(cali[obj->cvt.map[MPU6050_AXIS_Y]])*(obj->reso->sensitivity)/GRAVITY_EARTH_1000/(divisor)); obj->offset[MPU6050_AXIS_Z] = (s8)(obj->cvt.sign[MPU6050_AXIS_Z]*(cali[obj->cvt.map[MPU6050_AXIS_Z]])*(obj->reso->sensitivity)/GRAVITY_EARTH_1000/(divisor)); /*convert software calibration using standard calibration*/ obj->cali_sw[MPU6050_AXIS_X] = obj->cvt.sign[MPU6050_AXIS_X]*(cali[obj->cvt.map[MPU6050_AXIS_X]])%(divisor); obj->cali_sw[MPU6050_AXIS_Y] = obj->cvt.sign[MPU6050_AXIS_Y]*(cali[obj->cvt.map[MPU6050_AXIS_Y]])%(divisor); obj->cali_sw[MPU6050_AXIS_Z] = obj->cvt.sign[MPU6050_AXIS_Z]*(cali[obj->cvt.map[MPU6050_AXIS_Z]])%(divisor); GSE_LOG("NEWOFF: (%+3d %+3d %+3d): (%+3d %+3d %+3d) / (%+3d %+3d %+3d)\n", obj->offset[MPU6050_AXIS_X]*divisor + obj->cali_sw[MPU6050_AXIS_X], obj->offset[MPU6050_AXIS_Y]*divisor + obj->cali_sw[MPU6050_AXIS_Y], obj->offset[MPU6050_AXIS_Z]*divisor + obj->cali_sw[MPU6050_AXIS_Z], obj->offset[MPU6050_AXIS_X], obj->offset[MPU6050_AXIS_Y], obj->offset[MPU6050_AXIS_Z], obj->cali_sw[MPU6050_AXIS_X], obj->cali_sw[MPU6050_AXIS_Y], obj->cali_sw[MPU6050_AXIS_Z]); if ((err = hwmsen_write_block(obj->client, MPU6050_REG_OFSX, obj->offset, MPU6050_AXES_NUM))) { GSE_ERR("write offset fail: %d\n", err); return err; } #endif return err; } /*----------------------------------------------------------------------------*/ static int MPU6050_CheckDeviceID(struct i2c_client *client) { u8 databuf[10]; int res = 0; memset(databuf, 0, sizeof(u8)*10); databuf[0] = MPU6050_REG_DEVID; res = i2c_master_send(client, databuf, 0x1); if (res <= 0) { goto exit_MPU6050_CheckDeviceID; } udelay(500); databuf[0] = 0x0; res = i2c_master_recv(client, databuf, 0x01); if (res <= 0) { goto exit_MPU6050_CheckDeviceID; } GSE_LOG("MPU6050_CheckDeviceID 0x%x\n", databuf[0]); exit_MPU6050_CheckDeviceID: if (res <= 0) { return MPU6050_ERR_I2C; } return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int MPU6050_SetDataFormat(struct i2c_client *client, u8 dataformat) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); u8 databuf[2]; int res = 0; memset(databuf, 0, sizeof(u8)*2); databuf[0] = MPU6050_REG_DATA_FORMAT; res = i2c_master_send(client, databuf, 0x1); if (res <= 0) { return MPU6050_ERR_I2C; } udelay(500); databuf[0] = 0x0; res = i2c_master_recv(client, databuf, 0x01); if (res <= 0) { return MPU6050_ERR_I2C; } /* write */ databuf[1] = databuf[0] | dataformat; databuf[0] = MPU6050_REG_DATA_FORMAT; res = i2c_master_send(client, databuf, 0x2); if (res <= 0) { return MPU6050_ERR_I2C; } return MPU6050_SetDataResolution(obj); } /*----------------------------------------------------------------------------*/ static int MPU6050_SetBWRate(struct i2c_client *client, u8 bwrate) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); u8 databuf[10]; int res = 0; if( (obj->bandwidth != bwrate) || (atomic_read(&obj->suspend)) ) { memset(databuf, 0, sizeof(u8)*10); /* read */ databuf[0] = MPU6050_REG_BW_RATE; res = i2c_master_send(client, databuf, 0x1); if (res <= 0) { return MPU6050_ERR_I2C; } udelay(500); databuf[0] = 0x0; res = i2c_master_recv(client, databuf, 0x01); if (res <= 0) { return MPU6050_ERR_I2C; } /* write */ databuf[1] = databuf[0] | bwrate; databuf[0] = MPU6050_REG_BW_RATE; res = i2c_master_send(client, databuf, 0x2); if (res <= 0) { return MPU6050_ERR_I2C; } obj->bandwidth = bwrate; } return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int MPU6050_Dev_Reset(struct i2c_client *client) { u8 databuf[10]; int res = 0; memset(databuf, 0, sizeof(u8)*10); /* read */ databuf[0] = MPU6050_REG_POWER_CTL; res = i2c_master_send(client, databuf, 0x1); if (res <= 0) { return MPU6050_ERR_I2C; } udelay(500); databuf[0] = 0x0; res = i2c_master_recv(client, databuf, 0x01); if (res <= 0) { return MPU6050_ERR_I2C; } /* write */ databuf[1] = databuf[0] | MPU6050_DEV_RESET; databuf[0] = MPU6050_REG_POWER_CTL; res = i2c_master_send(client, databuf, 0x2); if (res <= 0) { return MPU6050_ERR_I2C; } do { databuf[0] = MPU6050_REG_POWER_CTL; res = i2c_master_send(client, databuf, 0x1); udelay(500); databuf[0] = 0x0; res = i2c_master_recv(client, databuf, 0x01); printk("[Gsensor] check reset bit"); }while((databuf[0]&MPU6050_DEV_RESET) != 0); msleep(50); return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int MPU6050_Reset(struct i2c_client *client) { u8 databuf[10]; int res = 0; /* write */ databuf[1] = 0x7; /* reset gyro, g-sensor, temperature */ databuf[0] = MPU6050_REG_RESET; res = i2c_master_send(client, databuf, 0x2); if (res <= 0) { return MPU6050_ERR_I2C; } msleep(20); return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int MPU6050_SetIntEnable(struct i2c_client *client, u8 intenable) { u8 databuf[2]; int res = 0; memset(databuf, 0, sizeof(u8)*2); databuf[0] = MPU6050_REG_INT_ENABLE; databuf[1] = intenable; res = i2c_master_send(client, databuf, 0x2); if (res <= 0) { return MPU6050_ERR_I2C; } return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int mpu6050_gpio_config(void) { //because we donot use EINT to support low power // config to GPIO input mode + PD //set to GPIO_GSE_1_EINT_PIN /* mt_set_gpio_mode(GPIO_GSE_1_EINT_PIN, GPIO_GSE_1_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_GSE_1_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_GSE_1_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_GSE_1_EINT_PIN, GPIO_PULL_DOWN); */ //set to GPIO_GSE_2_EINT_PIN /* mt_set_gpio_mode(GPIO_GSE_2_EINT_PIN, GPIO_GSE_2_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_GSE_2_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_GSE_2_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_GSE_2_EINT_PIN, GPIO_PULL_DOWN); */ return 0; } static int mpu6050_init_client(struct i2c_client *client, int reset_cali) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); int res = 0; bool sensor_power_org; mpu6050_gpio_config(); sensor_power_org = sensor_power; res = MPU6050_SetPowerMode(client, true); if (res != MPU6050_SUCCESS) { GSE_ERR("set power error\n"); return res; } res = MPU6050_CheckDeviceID(client); if (res != MPU6050_SUCCESS) { GSE_ERR("Check ID error\n"); return res; } res = MPU6050_SetBWRate(client, MPU6050_BW_184HZ); if (res != MPU6050_SUCCESS ) //0x2C->BW=100Hz { GSE_ERR("set power error\n"); return res; } res = MPU6050_SetDataFormat(client, MPU6050_RANGE_16G); if (res != MPU6050_SUCCESS) //0x2C->BW=100Hz { GSE_ERR("set data format error\n"); return res; } gsensor_gain.x = gsensor_gain.y = gsensor_gain.z = obj->reso->sensitivity; res = MPU6050_SetIntEnable(client, 0x00);//disable INT if (res != MPU6050_SUCCESS) { GSE_ERR("mpu6050_SetIntEnable error\n"); return res; } if (0 != reset_cali) { /*reset calibration only in power on*/ res = MPU6050_ResetCalibration(client); if (res != MPU6050_SUCCESS) { return res; } } res = MPU6050_SetPowerMode(client, sensor_power_org); if (res != MPU6050_SUCCESS) { GSE_ERR("set power error\n"); return res; } #ifdef CONFIG_MPU6050_LOWPASS memset(&obj->fir, 0x00, sizeof(obj->fir)); #endif return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadAllReg(struct i2c_client *client, char *buf, int bufsize) { u8 total_len= 0x5C; //(0x75-0x19); u8 addr = 0x19; u8 buff[total_len+1]; int err = 0; int i; if (sensor_power == FALSE) { err = MPU6050_SetPowerMode(client, true); if (err) { GSE_ERR("Power on mpu6050 error %d!\n", err); } } mpu_i2c_read_block(client, addr, buff, total_len); for ( i=0; i<=total_len; i++) { GSE_LOG("MPU6050 reg=0x%x, data=0x%x \n",(addr+i), buff[i]); } return 0; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadChipInfo(struct i2c_client *client, char *buf, int bufsize) { u8 databuf[10]; memset(databuf, 0, sizeof(u8)*10); if ((NULL == buf)||(bufsize<=30)) { return -1; } if (NULL == client) { *buf = 0; return -2; } sprintf(buf, "MPU6050 Chip"); return 0; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadSensorData(struct i2c_client *client, char *buf, int bufsize) { struct mpu6050_i2c_data *obj = obj_i2c_data; //(struct mpu6050_i2c_data*)i2c_get_clientdata(client); int acc[MPU6050_AXES_NUM]; int res = 0; client = obj->client; if (atomic_read(&obj->suspend)) { return -3; } if (NULL == buf) { return -1; } if (NULL == client) { *buf = 0; return -2; } if (sensor_power == FALSE) { res = MPU6050_SetPowerMode(client, true); if (res) { GSE_ERR("Power on mpu6050 error %d!\n", res); } } if ((res = MPU6050_ReadData(client, obj->data))) { GSE_ERR("I2C error: ret value=%d", res); return -3; } else { #if 1 obj->data[MPU6050_AXIS_X] = obj->data[MPU6050_AXIS_X] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; obj->data[MPU6050_AXIS_Y] = obj->data[MPU6050_AXIS_Y] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; obj->data[MPU6050_AXIS_Z] = obj->data[MPU6050_AXIS_Z] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; #endif obj->data[MPU6050_AXIS_X] += obj->cali_sw[MPU6050_AXIS_X]; obj->data[MPU6050_AXIS_Y] += obj->cali_sw[MPU6050_AXIS_Y]; obj->data[MPU6050_AXIS_Z] += obj->cali_sw[MPU6050_AXIS_Z]; /*remap coordinate*/ acc[obj->cvt.map[MPU6050_AXIS_X]] = obj->cvt.sign[MPU6050_AXIS_X]*obj->data[MPU6050_AXIS_X]; acc[obj->cvt.map[MPU6050_AXIS_Y]] = obj->cvt.sign[MPU6050_AXIS_Y]*obj->data[MPU6050_AXIS_Y]; acc[obj->cvt.map[MPU6050_AXIS_Z]] = obj->cvt.sign[MPU6050_AXIS_Z]*obj->data[MPU6050_AXIS_Z]; //Out put the mg #if 0 acc[MPU6050_AXIS_X] = acc[MPU6050_AXIS_X] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; acc[MPU6050_AXIS_Y] = acc[MPU6050_AXIS_Y] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; acc[MPU6050_AXIS_Z] = acc[MPU6050_AXIS_Z] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; #endif sprintf(buf, "%04x %04x %04x", acc[MPU6050_AXIS_X], acc[MPU6050_AXIS_Y], acc[MPU6050_AXIS_Z]); if (atomic_read(&obj->trace) & MPU6050_TRC_IOCTL) { GSE_LOG("gsensor data: %s!\n", buf); } } return 0; } /*----------------------------------------------------------------------------*/ static int MPU6050_ReadRawData(struct i2c_client *client, char *buf) { struct mpu6050_i2c_data *obj = (struct mpu6050_i2c_data*)i2c_get_clientdata(client); int res = 0; if (!buf || !client) { return EINVAL; } if (atomic_read(&obj->suspend)) { return EIO; } if ((res = MPU6050_ReadData(client, obj->data))) { GSE_ERR("I2C error: ret value=%d", res); return EIO; } else { sprintf(buf, "%04x %04x %04x", obj->data[MPU6050_AXIS_X], obj->data[MPU6050_AXIS_Y], obj->data[MPU6050_AXIS_Z]); } return 0; } /*----------------------------------------------------------------------------*/ static int MPU6050_InitSelfTest(struct i2c_client *client) { int res = 0; u8 data; res = MPU6050_SetPowerMode(client, true); if (res != MPU6050_SUCCESS) { GSE_ERR("set power error\n"); return res; } res = MPU6050_SetBWRate(client, MPU6050_BW_184HZ); if (res != MPU6050_SUCCESS ) //0x2C->BW=100Hz { return res; } res = mpu_i2c_read_block(client, MPU6050_REG_DATA_FORMAT, &data, 1); if (res != MPU6050_SUCCESS) { return res; } return MPU6050_SUCCESS; } /*----------------------------------------------------------------------------*/ #if !MPU6XXX_HWSELFTEST static int MPU6050_JudgeTestResult(struct i2c_client *client, s32 prv[MPU6050_AXES_NUM], s32 nxt[MPU6050_AXES_NUM]) { struct criteria { int min; int max; }; struct criteria self[4][3] = { {{ 0, 540}, { 0, 540}, { 0, 875}}, {{ 0, 270}, { 0, 270}, { 0, 438}}, {{ 0, 135}, { 0, 135}, { 0, 219}}, {{ 0, 67}, { 0, 67}, { 0, 110}}, }; struct criteria (*ptr)[3] = NULL; u8 format; int res; if ((res = mpu_i2c_read_block(client, MPU6050_REG_DATA_FORMAT, &format, 1))) return res; format = format & MPU6050_RANGE_16G; switch (format) { case MPU6050_RANGE_2G: GSE_LOG("format use self[0]\n"); ptr = &self[0]; break; case MPU6050_RANGE_4G: GSE_LOG("format use self[1]\n"); ptr = &self[1]; break; case MPU6050_RANGE_8G: GSE_LOG("format use self[2]\n"); ptr = &self[2]; break; case MPU6050_RANGE_16G: GSE_LOG("format use self[3]\n"); ptr = &self[3]; break; default: GSE_LOG("format unknow use \n"); break; } if (!ptr) { GSE_ERR("null pointer\n"); return -EINVAL; } GSE_LOG("format=0x%x\n",format); GSE_LOG("X diff is %ld\n",abs(nxt[MPU6050_AXIS_X] - prv[MPU6050_AXIS_X])); GSE_LOG("Y diff is %ld\n",abs(nxt[MPU6050_AXIS_Y] - prv[MPU6050_AXIS_Y])); GSE_LOG("Z diff is %ld\n",abs(nxt[MPU6050_AXIS_Z] - prv[MPU6050_AXIS_Z])); if ((abs(nxt[MPU6050_AXIS_X] - prv[MPU6050_AXIS_X]) > (*ptr)[MPU6050_AXIS_X].max) || (abs(nxt[MPU6050_AXIS_X] - prv[MPU6050_AXIS_X]) < (*ptr)[MPU6050_AXIS_X].min)) { GSE_ERR("X is over range\n"); res = -EINVAL; } if ((abs(nxt[MPU6050_AXIS_Y] - prv[MPU6050_AXIS_Y]) > (*ptr)[MPU6050_AXIS_Y].max) || (abs(nxt[MPU6050_AXIS_Y] - prv[MPU6050_AXIS_Y]) < (*ptr)[MPU6050_AXIS_Y].min)) { GSE_ERR("Y is over range\n"); res = -EINVAL; } if ((abs(nxt[MPU6050_AXIS_Z] - prv[MPU6050_AXIS_Z]) > (*ptr)[MPU6050_AXIS_Z].max) || (abs(nxt[MPU6050_AXIS_Z] - prv[MPU6050_AXIS_Z]) < (*ptr)[MPU6050_AXIS_Z].min)) { GSE_ERR("Z is over range\n"); res = -EINVAL; } return res; } #endif /*----------------------------------------------------------------------------*/ static ssize_t show_chipinfo_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = mpu6050_i2c_client; char strbuf[MPU6050_BUFSIZE]; if (NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } if (sensor_power == false) { MPU6050_SetPowerMode(client, true); } MPU6050_ReadAllReg(client, strbuf, MPU6050_BUFSIZE); MPU6050_ReadChipInfo(client, strbuf, MPU6050_BUFSIZE); return snprintf(buf, PAGE_SIZE, "%s\n", strbuf); } /*----------------------------------------------------------------------------*/ static ssize_t show_sensordata_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = mpu6050_i2c_client; char strbuf[MPU6050_BUFSIZE]; if (NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } MPU6050_ReadSensorData(client, strbuf, MPU6050_BUFSIZE); return snprintf(buf, PAGE_SIZE, "%s\n", strbuf); } /*----------------------------------------------------------------------------*/ static ssize_t show_cali_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = mpu6050_i2c_client; struct mpu6050_i2c_data *obj; int err, len = 0, mul; int tmp[MPU6050_AXES_NUM]; if (NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } obj = i2c_get_clientdata(client); if ((err = MPU6050_ReadOffset(client, obj->offset))) { return -EINVAL; } else if ((err = MPU6050_ReadCalibration(client, tmp))) { return -EINVAL; } else { mul = obj->reso->sensitivity/mpu6050_offset_resolution.sensitivity; len += snprintf(buf+len, PAGE_SIZE-len, "[HW ][%d] (%+3d, %+3d, %+3d) : (0x%02X, 0x%02X, 0x%02X)\n", mul, obj->offset[MPU6050_AXIS_X], obj->offset[MPU6050_AXIS_Y], obj->offset[MPU6050_AXIS_Z], obj->offset[MPU6050_AXIS_X], obj->offset[MPU6050_AXIS_Y], obj->offset[MPU6050_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[SW ][%d] (%+3d, %+3d, %+3d)\n", 1, obj->cali_sw[MPU6050_AXIS_X], obj->cali_sw[MPU6050_AXIS_Y], obj->cali_sw[MPU6050_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[ALL] (%+3d, %+3d, %+3d) : (%+3d, %+3d, %+3d)\n", obj->offset[MPU6050_AXIS_X]*mul + obj->cali_sw[MPU6050_AXIS_X], obj->offset[MPU6050_AXIS_Y]*mul + obj->cali_sw[MPU6050_AXIS_Y], obj->offset[MPU6050_AXIS_Z]*mul + obj->cali_sw[MPU6050_AXIS_Z], tmp[MPU6050_AXIS_X], tmp[MPU6050_AXIS_Y], tmp[MPU6050_AXIS_Z]); return len; } } /*----------------------------------------------------------------------------*/ static ssize_t store_cali_value(struct device_driver *ddri, const char *buf, size_t count) { struct i2c_client *client = mpu6050_i2c_client; int err, x, y, z; int dat[MPU6050_AXES_NUM]; if (!strncmp(buf, "rst", 3)) { if ((err = MPU6050_ResetCalibration(client))) { GSE_ERR("reset offset err = %d\n", err); } } else if (3 == sscanf(buf, "0x%02X 0x%02X 0x%02X", &x, &y, &z)) { dat[MPU6050_AXIS_X] = x; dat[MPU6050_AXIS_Y] = y; dat[MPU6050_AXIS_Z] = z; if ((err = MPU6050_WriteCalibration(client, dat))) { GSE_ERR("write calibration err = %d\n", err); } } else { GSE_ERR("invalid format\n"); } return count; } /*----------------------------------------------------------------------------*/ #if MPU6XXX_HWSELFTEST extern int inv_hw_self_test(struct inv_selftest_device *st); int selftestret=0; static ssize_t show_self_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = mpu6050_i2c_client; struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); int len = 0; if (NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } if(selftestret & 0x1) len += snprintf(buf+len, PAGE_SIZE-len, "Self-Test result=%d- Gyro = PASS \t",selftestret); else len += snprintf(buf+len, PAGE_SIZE-len, "Self-Test result=%d- Gyro = FAIL \t",selftestret); if(selftestret & 0x2) len += snprintf(buf+len, PAGE_SIZE-len, "Accel = PASS\n"); else len += snprintf(buf+len, PAGE_SIZE-len, "Accel = FAIL\n"); len += snprintf(buf+len, PAGE_SIZE-len, "[gyro_bias](%+3d, %+3d, %+3d)\n",obj->mpu_selftest_device.gyro_bias[MPU6050_AXIS_X], obj->mpu_selftest_device.gyro_bias[MPU6050_AXIS_Y], obj->mpu_selftest_device.gyro_bias[MPU6050_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[accel_bias](%+3d, %+3d, %+3d)\n",obj->mpu_selftest_device.accel_bias[MPU6050_AXIS_X], obj->mpu_selftest_device.accel_bias[MPU6050_AXIS_Y], obj->mpu_selftest_device.accel_bias[MPU6050_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[gyro_bias_st](%+3d, %+3d, %+3d)\n",obj->mpu_selftest_device.gyro_bias_st[MPU6050_AXIS_X], obj->mpu_selftest_device.gyro_bias_st[MPU6050_AXIS_Y], obj->mpu_selftest_device.gyro_bias_st[MPU6050_AXIS_Z]); len += snprintf(buf+len, PAGE_SIZE-len, "[accel_bias_st](%+3d, %+3d, %+3d)\n",obj->mpu_selftest_device.accel_bias_st[MPU6050_AXIS_X], obj->mpu_selftest_device.accel_bias_st[MPU6050_AXIS_Y], obj->mpu_selftest_device.accel_bias_st[MPU6050_AXIS_Z]); return len; } /*----------------------------------------------------------------------------*/ static ssize_t store_self_value(struct device_driver *ddri, const char *buf, size_t count) { struct i2c_client *client = mpu6050_i2c_client; struct mpu6050_i2c_data *priv = i2c_get_clientdata(client); int ret; //u8 databuf[2] = {0}; //u8 data; #if 1 MPU6050_SetPowerMode(client,true); ret = inv_hw_self_test(&(priv->mpu_selftest_device)); selftestret = ret; if (ret == 3) { GSE_LOG("SELFTEST : PASS\n"); strcpy(selftestRes,"y"); } else { GSE_LOG("SELFTEST : FAIL\n"); strcpy(selftestRes,"n"); } #endif return count; } #else /*----------------------------------------------------------------------------*/ static ssize_t show_self_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = mpu6050_i2c_client; if (NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } return snprintf(buf, 8, "%s\n", selftestRes); } /*----------------------------------------------------------------------------*/ static ssize_t store_self_value(struct device_driver *ddri, const char *buf, size_t count) { /*write anything to this register will trigger the process*/ struct item { s16 raw[MPU6050_AXES_NUM]; }; struct i2c_client *client = mpu6050_i2c_client; int idx, res, num; struct item *prv = NULL, *nxt = NULL; s32 avg_prv[MPU6050_AXES_NUM] = {0, 0, 0}; s32 avg_nxt[MPU6050_AXES_NUM] = {0, 0, 0}; if (1 != sscanf(buf, "%d", &num)) { GSE_ERR("parse number fail\n"); return count; } else if (num == 0) { GSE_ERR("invalid data count\n"); return count; } prv = kzalloc(sizeof(*prv) * num, GFP_KERNEL); nxt = kzalloc(sizeof(*nxt) * num, GFP_KERNEL); if (!prv || !nxt) { goto exit; } GSE_LOG("NORMAL:\n"); MPU6050_SetPowerMode(client,true); for (idx = 0; idx < num; idx++) { if ((res = MPU6050_ReadData(client, prv[idx].raw))) { GSE_ERR("read data fail: %d\n", res); goto exit; } avg_prv[MPU6050_AXIS_X] += prv[idx].raw[MPU6050_AXIS_X]; avg_prv[MPU6050_AXIS_Y] += prv[idx].raw[MPU6050_AXIS_Y]; avg_prv[MPU6050_AXIS_Z] += prv[idx].raw[MPU6050_AXIS_Z]; GSE_LOG("[%5d %5d %5d]\n", prv[idx].raw[MPU6050_AXIS_X], prv[idx].raw[MPU6050_AXIS_Y], prv[idx].raw[MPU6050_AXIS_Z]); } avg_prv[MPU6050_AXIS_X] /= num; avg_prv[MPU6050_AXIS_Y] /= num; avg_prv[MPU6050_AXIS_Z] /= num; /*initial setting for self test*/ GSE_LOG("SELFTEST:\n"); for (idx = 0; idx < num; idx++) { if ((res = MPU6050_ReadData(client, nxt[idx].raw))) { GSE_ERR("read data fail: %d\n", res); goto exit; } avg_nxt[MPU6050_AXIS_X] += nxt[idx].raw[MPU6050_AXIS_X]; avg_nxt[MPU6050_AXIS_Y] += nxt[idx].raw[MPU6050_AXIS_Y]; avg_nxt[MPU6050_AXIS_Z] += nxt[idx].raw[MPU6050_AXIS_Z]; GSE_LOG("[%5d %5d %5d]\n", nxt[idx].raw[MPU6050_AXIS_X], nxt[idx].raw[MPU6050_AXIS_Y], nxt[idx].raw[MPU6050_AXIS_Z]); } avg_nxt[MPU6050_AXIS_X] /= num; avg_nxt[MPU6050_AXIS_Y] /= num; avg_nxt[MPU6050_AXIS_Z] /= num; GSE_LOG("X: %5d - %5d = %5d \n", avg_nxt[MPU6050_AXIS_X], avg_prv[MPU6050_AXIS_X], avg_nxt[MPU6050_AXIS_X] - avg_prv[MPU6050_AXIS_X]); GSE_LOG("Y: %5d - %5d = %5d \n", avg_nxt[MPU6050_AXIS_Y], avg_prv[MPU6050_AXIS_Y], avg_nxt[MPU6050_AXIS_Y] - avg_prv[MPU6050_AXIS_Y]); GSE_LOG("Z: %5d - %5d = %5d \n", avg_nxt[MPU6050_AXIS_Z], avg_prv[MPU6050_AXIS_Z], avg_nxt[MPU6050_AXIS_Z] - avg_prv[MPU6050_AXIS_Z]); if (!MPU6050_JudgeTestResult(client, avg_prv, avg_nxt)) { GSE_LOG("SELFTEST : PASS\n"); strcpy(selftestRes,"y"); } else { GSE_LOG("SELFTEST : FAIL\n"); strcpy(selftestRes,"n"); } exit: /*restore the setting*/ mpu6050_init_client(client, 0); kfree(prv); kfree(nxt); return count; } #endif /*----------------------------------------------------------------------------*/ static ssize_t show_selftest_value(struct device_driver *ddri, char *buf) { struct i2c_client *client = mpu6050_i2c_client; struct mpu6050_i2c_data *obj; if (NULL == client) { GSE_ERR("i2c client is null!!\n"); return 0; } obj = i2c_get_clientdata(client); return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&obj->selftest)); } /*----------------------------------------------------------------------------*/ static ssize_t store_selftest_value(struct device_driver *ddri, const char *buf, size_t count) { struct mpu6050_i2c_data *obj = obj_i2c_data; int tmp; if (NULL == obj) { GSE_ERR("i2c data obj is null!!\n"); return 0; } if (1 == sscanf(buf, "%d", &tmp)) { if (atomic_read(&obj->selftest) && !tmp) { /*enable -> disable*/ mpu6050_init_client(obj->client, 0); } else if (!atomic_read(&obj->selftest) && tmp) { /*disable -> enable*/ MPU6050_InitSelfTest(obj->client); } GSE_LOG("selftest: %d => %d\n", atomic_read(&obj->selftest), tmp); atomic_set(&obj->selftest, tmp); } else { GSE_ERR("invalid content: '%s', length = %d\n", buf, count); } return count; } /*----------------------------------------------------------------------------*/ static ssize_t show_firlen_value(struct device_driver *ddri, char *buf) { #ifdef CONFIG_MPU6050_LOWPASS struct i2c_client *client = mpu6050_i2c_client; struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); if (atomic_read(&obj->firlen)) { int idx, len = atomic_read(&obj->firlen); GSE_LOG("len = %2d, idx = %2d\n", obj->fir.num, obj->fir.idx); for (idx = 0; idx < len; idx++) { GSE_LOG("[%5d %5d %5d]\n", obj->fir.raw[idx][MPU6050_AXIS_X], obj->fir.raw[idx][MPU6050_AXIS_Y], obj->fir.raw[idx][MPU6050_AXIS_Z]); } GSE_LOG("sum = [%5d %5d %5d]\n", obj->fir.sum[MPU6050_AXIS_X], obj->fir.sum[MPU6050_AXIS_Y], obj->fir.sum[MPU6050_AXIS_Z]); GSE_LOG("avg = [%5d %5d %5d]\n", obj->fir.sum[MPU6050_AXIS_X]/len, obj->fir.sum[MPU6050_AXIS_Y]/len, obj->fir.sum[MPU6050_AXIS_Z]/len); } return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&obj->firlen)); #else return snprintf(buf, PAGE_SIZE, "not support\n"); #endif } /*----------------------------------------------------------------------------*/ static ssize_t store_firlen_value(struct device_driver *ddri, const char *buf, size_t count) { #ifdef CONFIG_MPU6050_LOWPASS struct i2c_client *client = mpu6050_i2c_client; struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); int firlen; if (1 != sscanf(buf, "%d", &firlen)) { GSE_ERR("invallid format\n"); } else if (firlen > C_MAX_FIR_LENGTH) { GSE_ERR("exceeds maximum filter length\n"); } else { atomic_set(&obj->firlen, firlen); if (0 == firlen) { atomic_set(&obj->fir_en, 0); } else { memset(&obj->fir, 0x00, sizeof(obj->fir)); atomic_set(&obj->fir_en, 1); } } #endif return count; } /*----------------------------------------------------------------------------*/ static ssize_t show_trace_value(struct device_driver *ddri, char *buf) { ssize_t res; struct mpu6050_i2c_data *obj = obj_i2c_data; if (obj == NULL) { GSE_ERR("i2c_data obj is null!!\n"); return 0; } res = snprintf(buf, PAGE_SIZE, "0x%04X\n", atomic_read(&obj->trace)); return res; } /*----------------------------------------------------------------------------*/ static ssize_t store_trace_value(struct device_driver *ddri, const char *buf, size_t count) { struct mpu6050_i2c_data *obj = obj_i2c_data; int trace; if (obj == NULL) { GSE_ERR("i2c_data obj is null!!\n"); return 0; } if (1 == sscanf(buf, "0x%x", &trace)) { atomic_set(&obj->trace, trace); } else { GSE_ERR("invalid content: '%s', length = %d\n", buf, count); } return count; } /*----------------------------------------------------------------------------*/ static ssize_t show_status_value(struct device_driver *ddri, char *buf) { ssize_t len = 0; struct mpu6050_i2c_data *obj = obj_i2c_data; if (obj == NULL) { GSE_ERR("i2c_data obj is null!!\n"); return 0; } if (obj->hw) { len += snprintf(buf+len, PAGE_SIZE-len, "CUST: %d %d (%d %d)\n", obj->hw->i2c_num, obj->hw->direction, obj->hw->power_id, obj->hw->power_vol); } else { len += snprintf(buf+len, PAGE_SIZE-len, "CUST: NULL\n"); } return len; } /*----------------------------------------------------------------------------*/ static DRIVER_ATTR(chipinfo, S_IRUGO, show_chipinfo_value, NULL); static DRIVER_ATTR(sensordata, S_IRUGO, show_sensordata_value, NULL); static DRIVER_ATTR(cali, S_IWUSR | S_IRUGO, show_cali_value, store_cali_value); static DRIVER_ATTR(self, S_IWUSR | S_IRUGO, show_selftest_value, store_selftest_value); static DRIVER_ATTR(selftest, S_IWUSR | S_IRUGO, show_self_value , store_self_value ); static DRIVER_ATTR(firlen, S_IWUSR | S_IRUGO, show_firlen_value, store_firlen_value); static DRIVER_ATTR(trace, S_IWUSR | S_IRUGO, show_trace_value, store_trace_value); static DRIVER_ATTR(status, S_IRUGO, show_status_value, NULL); /*----------------------------------------------------------------------------*/ static struct driver_attribute *mpu6050_attr_list[] = { &driver_attr_chipinfo, /*chip information*/ &driver_attr_sensordata, /*dump sensor data*/ &driver_attr_cali, /*show calibration data*/ &driver_attr_self, /*self test demo*/ &driver_attr_selftest, /*self control: 0: disable, 1: enable*/ &driver_attr_firlen, /*filter length: 0: disable, others: enable*/ &driver_attr_trace, /*trace log*/ &driver_attr_status, }; /*----------------------------------------------------------------------------*/ static int mpu6050_create_attr(struct device_driver *driver) { int idx, err = 0; int num = (int)(sizeof(mpu6050_attr_list)/sizeof(mpu6050_attr_list[0])); if (driver == NULL) { return -EINVAL; } for (idx = 0; idx < num; idx++) { if (0 != (err = driver_create_file(driver, mpu6050_attr_list[idx]))) { GSE_ERR("driver_create_file (%s) = %d\n", mpu6050_attr_list[idx]->attr.name, err); break; } } return err; } /*----------------------------------------------------------------------------*/ static int mpu6050_delete_attr(struct device_driver *driver) { int idx ,err = 0; int num = (int)(sizeof(mpu6050_attr_list)/sizeof(mpu6050_attr_list[0])); if (driver == NULL) { return -EINVAL; } for (idx = 0; idx < num; idx++) { driver_remove_file(driver, mpu6050_attr_list[idx]); } return err; } /*----------------------------------------------------------------------------*/ int gsensor_operate(void* self, uint32_t command, void* buff_in, int size_in, void* buff_out, int size_out, int* actualout) { int err = 0; int value, sample_delay; struct mpu6050_i2c_data *priv = (struct mpu6050_i2c_data*)self; hwm_sensor_data* gsensor_data; char buff[MPU6050_BUFSIZE]; switch (command) { case SENSOR_DELAY: if ((buff_in == NULL) || (size_in < sizeof(int))) { GSE_ERR("Set delay parameter error!\n"); err = -EINVAL; } else { value = *(int *)buff_in; if(value <= 5) { sample_delay = MPU6050_BW_184HZ; } else if(value <= 10) { sample_delay = MPU6050_BW_94HZ; } else { sample_delay = MPU6050_BW_44HZ; } GSE_LOG("Set delay parameter value:%d \n", value); err = MPU6050_SetBWRate(priv->client, sample_delay); if (err != MPU6050_SUCCESS ) //0x2C->BW=100Hz { GSE_ERR("Set delay parameter error!\n"); } if (value >= 50) { atomic_set(&priv->filter, 0); } else { #if defined(CONFIG_MPU6050_LOWPASS) priv->fir.num = 0; priv->fir.idx = 0; priv->fir.sum[MPU6050_AXIS_X] = 0; priv->fir.sum[MPU6050_AXIS_Y] = 0; priv->fir.sum[MPU6050_AXIS_Z] = 0; #endif atomic_set(&priv->filter, 1); } } break; case SENSOR_ENABLE: if ((buff_in == NULL) || (size_in < sizeof(int))) { GSE_ERR("Enable sensor parameter error!\n"); err = -EINVAL; } else { value = *(int *)buff_in; if (((value == 0) && (sensor_power == false)) ||((value == 1) && (sensor_power == true))) { GSE_LOG("Gsensor device have updated!\n"); } else { err = MPU6050_SetPowerMode( priv->client, !sensor_power); } } break; case SENSOR_GET_DATA: if ((buff_out == NULL) || (size_out< sizeof(hwm_sensor_data))) { GSE_ERR("get sensor data parameter error!\n"); err = -EINVAL; } else { gsensor_data = (hwm_sensor_data *)buff_out; err = MPU6050_ReadSensorData(priv->client, buff, MPU6050_BUFSIZE); if (!err) { sscanf(buff, "%x %x %x", &gsensor_data->values[0], &gsensor_data->values[1], &gsensor_data->values[2]); gsensor_data->status = SENSOR_STATUS_ACCURACY_MEDIUM; gsensor_data->value_divide = 1000; } } break; default: GSE_ERR("gsensor operate function no this parameter %d!\n", command); err = -1; break; } return err; } /****************************************************************************** * Function Configuration ******************************************************************************/ static int mpu6050_open(struct inode *inode, struct file *file) { file->private_data = mpu6050_i2c_client; if (file->private_data == NULL) { GSE_ERR("null pointer!!\n"); return -EINVAL; } return nonseekable_open(inode, file); } /*----------------------------------------------------------------------------*/ static int mpu6050_release(struct inode *inode, struct file *file) { file->private_data = NULL; return 0; } /*----------------------------------------------------------------------------*/ static long mpu6050_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct i2c_client *client = (struct i2c_client*)file->private_data; struct mpu6050_i2c_data *obj = (struct mpu6050_i2c_data*)i2c_get_clientdata(client); char strbuf[MPU6050_BUFSIZE]; void __user *data; SENSOR_DATA sensor_data; long err = 0; int cali[3]; memset(strbuf, 0, MPU6050_BUFSIZE); if (_IOC_DIR(cmd) & _IOC_READ) { err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); } else if (_IOC_DIR(cmd) & _IOC_WRITE) { err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); } if (err) { GSE_ERR("access error: %08X, (%2d, %2d)\n", cmd, _IOC_DIR(cmd), _IOC_SIZE(cmd)); return -EFAULT; } switch (cmd) { case GSENSOR_IOCTL_INIT: mpu6050_init_client(client, 0); break; case GSENSOR_IOCTL_READ_CHIPINFO: data = (void __user *) arg; if (data == NULL) { err = -EINVAL; break; } MPU6050_ReadChipInfo(client, strbuf, MPU6050_BUFSIZE); if (copy_to_user(data, strbuf, strlen(strbuf)+1)) { err = -EFAULT; break; } break; case GSENSOR_IOCTL_READ_SENSORDATA: data = (void __user *) arg; if (data == NULL) { err = -EINVAL; break; } MPU6050_ReadSensorData(client, strbuf, MPU6050_BUFSIZE); if (copy_to_user(data, strbuf, strlen(strbuf)+1)) { err = -EFAULT; break; } break; case GSENSOR_IOCTL_READ_GAIN: data = (void __user *) arg; if (data == NULL) { err = -EINVAL; break; } if (copy_to_user(data, &gsensor_gain, sizeof(GSENSOR_VECTOR3D))) { err = -EFAULT; break; } break; case GSENSOR_IOCTL_READ_RAW_DATA: data = (void __user *) arg; if (data == NULL) { err = -EINVAL; break; } if (atomic_read(&obj->suspend)) { err = -EINVAL; } else { MPU6050_ReadRawData(client, strbuf); if (copy_to_user(data, strbuf, strlen(strbuf)+1)) { err = -EFAULT; break; } } break; case GSENSOR_IOCTL_SET_CALI: data = (void __user*)arg; if (data == NULL) { err = -EINVAL; break; } if (copy_from_user(&sensor_data, data, sizeof(sensor_data))) { err = -EFAULT; break; } if (atomic_read(&obj->suspend)) { GSE_ERR("Perform calibration in suspend state!!\n"); err = -EINVAL; } else { #if 0 cali[MPU6050_AXIS_X] = sensor_data.x * obj->reso->sensitivity / GRAVITY_EARTH_1000; cali[MPU6050_AXIS_Y] = sensor_data.y * obj->reso->sensitivity / GRAVITY_EARTH_1000; cali[MPU6050_AXIS_Z] = sensor_data.z * obj->reso->sensitivity / GRAVITY_EARTH_1000; #else cali[MPU6050_AXIS_X] = sensor_data.x; cali[MPU6050_AXIS_Y] = sensor_data.y; cali[MPU6050_AXIS_Z] = sensor_data.z; #endif err = MPU6050_WriteCalibration(client, cali); } break; case GSENSOR_IOCTL_CLR_CALI: err = MPU6050_ResetCalibration(client); break; case GSENSOR_IOCTL_GET_CALI: data = (void __user*)arg; if (data == NULL) { err = -EINVAL; break; } if ((err = MPU6050_ReadCalibration(client, cali))) { break; } #if 0 sensor_data.x = cali[MPU6050_AXIS_X] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; sensor_data.y = cali[MPU6050_AXIS_Y] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; sensor_data.z = cali[MPU6050_AXIS_Z] * GRAVITY_EARTH_1000 / obj->reso->sensitivity; #else sensor_data.x = cali[MPU6050_AXIS_X]; sensor_data.y = cali[MPU6050_AXIS_Y]; sensor_data.z = cali[MPU6050_AXIS_Z]; #endif if (copy_to_user(data, &sensor_data, sizeof(sensor_data))) { err = -EFAULT; break; } break; default: GSE_ERR("unknown IOCTL: 0x%08x\n", cmd); err = -ENOIOCTLCMD; break; } return err; } /*----------------------------------------------------------------------------*/ static struct file_operations mpu6050_fops = { .open = mpu6050_open, .release = mpu6050_release, .unlocked_ioctl = mpu6050_unlocked_ioctl, }; /*----------------------------------------------------------------------------*/ static struct miscdevice mpu6050_device = { .minor = MISC_DYNAMIC_MINOR, .name = "gsensor", .fops = &mpu6050_fops, }; /*----------------------------------------------------------------------------*/ #ifndef USE_EARLY_SUSPEND /*----------------------------------------------------------------------------*/ static int mpu6050_suspend(struct i2c_client *client, pm_message_t msg) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); int err = 0; GSE_FUN(); if (msg.event == PM_EVENT_SUSPEND) { if (obj == NULL) { GSE_ERR("null pointer!!\n"); return -EINVAL; } atomic_set(&obj->suspend, 1); if ((err = MPU6050_SetPowerMode(obj->client, false))) { GSE_ERR("write power control fail!!\n"); return err; } MPU6050_power(obj->hw, 0); GSE_LOG("mpu6050_suspend ok\n"); } return err; } /*----------------------------------------------------------------------------*/ static int mpu6050_resume(struct i2c_client *client) { struct mpu6050_i2c_data *obj = i2c_get_clientdata(client); int err; GSE_FUN(); if (obj == NULL) { GSE_ERR("null pointer!!\n"); return -EINVAL; } MPU6050_power(obj->hw, 1); if ((err = mpu6050_init_client(client, 0))) { GSE_ERR("initialize client fail!!\n"); return err; } atomic_set(&obj->suspend, 0); GSE_LOG("mpu6050_resume ok\n"); return 0; } /*----------------------------------------------------------------------------*/ #else /*CONFIG_HAS_EARLY_SUSPEND is defined*/ /*----------------------------------------------------------------------------*/ static void mpu6050_early_suspend(struct early_suspend *h) { struct mpu6050_i2c_data *obj = container_of(h, struct mpu6050_i2c_data, early_drv); int err; GSE_FUN(); if (obj == NULL) { GSE_ERR("null pointer!!\n"); return; } atomic_set(&obj->suspend, 1); if ((err = MPU6050_SetPowerMode(obj->client, false))) { GSE_ERR("write power control fail!!\n"); return; } /* if (MPU6050_gyro_mode() == false) { MPU6050_Dev_Reset(obj->client); MPU6050_Reset(obj->client); } */ obj->bandwidth = 0; sensor_power = false; MPU6050_power(obj->hw, 0); } /*----------------------------------------------------------------------------*/ static void mpu6050_late_resume(struct early_suspend *h) { struct mpu6050_i2c_data *obj = container_of(h, struct mpu6050_i2c_data, early_drv); int err; GSE_FUN(); if (obj == NULL) { GSE_ERR("null pointer!!\n"); return; } MPU6050_power(obj->hw, 1); if ((err = mpu6050_init_client(obj->client, 0))) { GSE_ERR("initialize client fail!!\n"); return; } atomic_set(&obj->suspend, 0); } /*----------------------------------------------------------------------------*/ #endif /*CONFIG_HAS_EARLYSUSPEND*/ /*----------------------------------------------------------------------------*/ static int mpu6050_i2c_detect(struct i2c_client *client, struct i2c_board_info *info) { strcpy(info->type, MPU6050_DEV_NAME); return 0; } /*----------------------------------------------------------------------------*/ static int mpu6050_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_client *new_client; struct mpu6050_i2c_data *obj; struct hwmsen_object sobj; int err = 0; GSE_FUN(); if (!(obj = kzalloc(sizeof(*obj), GFP_KERNEL))) { err = -ENOMEM; goto exit; } memset(obj, 0, sizeof(struct mpu6050_i2c_data)); obj->hw = get_cust_acc_hw(); if ((err = hwmsen_get_convert(obj->hw->direction, &obj->cvt))) { GSE_ERR("invalid direction: %d\n", obj->hw->direction); goto exit; } obj_i2c_data = obj; obj->client = client; obj->client->timing = 400; new_client = obj->client; i2c_set_clientdata(new_client,obj); atomic_set(&obj->trace, 0); atomic_set(&obj->suspend, 0); #ifdef CONFIG_MPU6050_LOWPASS if (obj->hw->firlen > C_MAX_FIR_LENGTH) { atomic_set(&obj->firlen, C_MAX_FIR_LENGTH); } else { atomic_set(&obj->firlen, obj->hw->firlen); } if (atomic_read(&obj->firlen) > 0) { atomic_set(&obj->fir_en, 1); } #endif mpu6050_i2c_client = new_client; MPU6050_Dev_Reset(new_client); MPU6050_Reset(new_client); if ((err = mpu6050_init_client(new_client, 1))) { goto exit_init_failed; } if ((err = misc_register(&mpu6050_device))) { GSE_ERR("mpu6050_device register failed\n"); goto exit_misc_device_register_failed; } if ((err = mpu6050_create_attr(&mpu6050_gsensor_driver.driver))) { GSE_ERR("create attribute err = %d\n", err); goto exit_create_attr_failed; } sobj.self = obj; sobj.polling = 1; sobj.sensor_operate = gsensor_operate; if ((err = hwmsen_attach(ID_ACCELEROMETER, &sobj))) { GSE_ERR("attach fail = %d\n", err); goto exit_kfree; } #ifdef USE_EARLY_SUSPEND obj->early_drv.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING - 2, obj->early_drv.suspend = mpu6050_early_suspend, obj->early_drv.resume = mpu6050_late_resume, register_early_suspend(&obj->early_drv); #endif #if MPU6XXX_HWSELFTEST obj->mpu_selftest_device.name = "MPU6XXX"; obj->mpu_selftest_device.chip_type = INV_MPU6500;//MPU6515 don't need to modify this chip_type obj->mpu_selftest_device.samples = INIT_ST_SAMPLES; #endif GSE_LOG("%s: OK\n", __func__); return 0; exit_create_attr_failed: misc_deregister(&mpu6050_device); exit_misc_device_register_failed: exit_init_failed: //i2c_detach_client(new_client); exit_kfree: kfree(obj); exit: GSE_ERR("%s: err = %d\n", __func__, err); return err; } /*----------------------------------------------------------------------------*/ static int mpu6050_i2c_remove(struct i2c_client *client) { int err = 0; if ((err = mpu6050_delete_attr(&mpu6050_gsensor_driver.driver))) { GSE_ERR("mpu6050_delete_attr fail: %d\n", err); } if ((err = misc_deregister(&mpu6050_device))) { GSE_ERR("misc_deregister fail: %d\n", err); } if ((err = hwmsen_detach(ID_ACCELEROMETER))) { GSE_ERR("hwmsen_detach fail: %d\n", err); } mpu6050_i2c_client = NULL; i2c_unregister_device(client); kfree(i2c_get_clientdata(client)); return 0; } /*----------------------------------------------------------------------------*/ static int mpu6050_probe(struct platform_device *pdev) { struct acc_hw *hw = get_cust_acc_hw(); GSE_FUN(); MPU6050_power(hw, 1); if (i2c_add_driver(&mpu6050_i2c_driver)) { GSE_ERR("add driver error\n"); return -1; } return 0; } /*----------------------------------------------------------------------------*/ static int mpu6050_remove(struct platform_device *pdev) { struct acc_hw *hw = get_cust_acc_hw(); GSE_FUN(); MPU6050_power(hw, 0); i2c_del_driver(&mpu6050_i2c_driver); return 0; } /*----------------------------------------------------------------------------*/ #if 1 #ifdef CONFIG_OF static const struct of_device_id gsensor_of_match[] = { { .compatible = "mediatek,gsensor", }, {}, }; #endif static struct platform_driver mpu6050_gsensor_driver = { .probe = mpu6050_probe, .remove = mpu6050_remove, .driver = { .name = "gsensor", // .owner = THIS_MODULE, #ifdef CONFIG_OF .of_match_table = gsensor_of_match, #endif } }; #else static struct platform_driver mpu6050_gsensor_driver = { .probe = mpu6050_probe, .remove = mpu6050_remove, .driver = { .name = "gsensor", } }; #endif /*----------------------------------------------------------------------------*/ static int __init mpu6050gse_init(void) { struct acc_hw *hw = get_cust_acc_hw(); GSE_LOG("%s: i2c_number=%d\n", __func__,hw->i2c_num); i2c_register_board_info(hw->i2c_num, &i2c_mpu6050, 1); if (platform_driver_register(&mpu6050_gsensor_driver)) { GSE_ERR("failed to register driver"); return -ENODEV; } return 0; } /*----------------------------------------------------------------------------*/ static void __exit mpu6050gse_exit(void) { GSE_FUN(); platform_driver_unregister(&mpu6050_gsensor_driver); } /*----------------------------------------------------------------------------*/ module_init(mpu6050gse_init); module_exit(mpu6050gse_exit); /*----------------------------------------------------------------------------*/ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("MPU6050 gse driver"); MODULE_AUTHOR("Yucong.Xiong@mediatek.com");
profglavcho/mt6577-kernel-3.10.61
drivers/misc/mediatek/accelerometer/mpu6050g/mpu6050.c
C
gpl-2.0
72,755
/* * The DSP56001 Device Driver, saviour of the Free World(tm) * * Authors: Fredrik Noring <noring@nocrew.org> * lars brinkhoff <lars@nocrew.org> * Tomas Berndtsson <tomas@nocrew.org> * * First version May 1996 * * History: * 97-01-29 Tomas Berndtsson, * Integrated with Linux 2.1.21 kernel sources. * 97-02-15 Tomas Berndtsson, * Fixed for kernel 2.1.26 * * BUGS: * Hmm... there must be something here :) * * Copyright (C) 1996,1997 Fredrik Noring, lars brinkhoff & Tomas Berndtsson * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. */ #include <linux/module.h> #include <linux/slab.h> /* for kmalloc() and kfree() */ #include <linux/major.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/delay.h> /* guess what */ #include <linux/fs.h> #include <linux/mm.h> #include <linux/init.h> #include <linux/device.h> #include <linux/smp_lock.h> #include <linux/firmware.h> #include <linux/platform_device.h> #include <linux/uaccess.h> /* For put_user and get_user */ #include <asm/atarihw.h> #include <asm/traps.h> #include <asm/dsp56k.h> /* minor devices */ #define DSP56K_DEV_56001 0 /* The only device so far */ #define TIMEOUT 10 /* Host port timeout in number of tries */ #define MAXIO 2048 /* Maximum number of words before sleep */ #define DSP56K_MAX_BINARY_LENGTH (3*64*1024) #define DSP56K_TX_INT_ON dsp56k_host_interface.icr |= DSP56K_ICR_TREQ #define DSP56K_RX_INT_ON dsp56k_host_interface.icr |= DSP56K_ICR_RREQ #define DSP56K_TX_INT_OFF dsp56k_host_interface.icr &= ~DSP56K_ICR_TREQ #define DSP56K_RX_INT_OFF dsp56k_host_interface.icr &= ~DSP56K_ICR_RREQ #define DSP56K_TRANSMIT (dsp56k_host_interface.isr & DSP56K_ISR_TXDE) #define DSP56K_RECEIVE (dsp56k_host_interface.isr & DSP56K_ISR_RXDF) #define handshake(count, maxio, timeout, ENABLE, f) \ { \ long i, t, m; \ while (count > 0) { \ m = min_t(unsigned long, count, maxio); \ for (i = 0; i < m; i++) { \ for (t = 0; t < timeout && !ENABLE; t++) \ msleep(20); \ if(!ENABLE) \ return -EIO; \ f; \ } \ count -= m; \ if (m == maxio) msleep(20); \ } \ } #define tx_wait(n) \ { \ int t; \ for(t = 0; t < n && !DSP56K_TRANSMIT; t++) \ msleep(10); \ if(!DSP56K_TRANSMIT) { \ return -EIO; \ } \ } #define rx_wait(n) \ { \ int t; \ for(t = 0; t < n && !DSP56K_RECEIVE; t++) \ msleep(10); \ if(!DSP56K_RECEIVE) { \ return -EIO; \ } \ } static struct dsp56k_device { unsigned long in_use; long maxio, timeout; int tx_wsize, rx_wsize; } dsp56k; static struct class *dsp56k_class; static int dsp56k_reset(void) { u_char status; /* Power down the DSP */ sound_ym.rd_data_reg_sel = 14; status = sound_ym.rd_data_reg_sel & 0xef; sound_ym.wd_data = status; sound_ym.wd_data = status | 0x10; udelay(10); /* Power up the DSP */ sound_ym.rd_data_reg_sel = 14; sound_ym.wd_data = sound_ym.rd_data_reg_sel & 0xef; return 0; } static int dsp56k_upload(u_char __user *bin, int len) { struct platform_device *pdev; const struct firmware *fw; const char fw_name[] = "dsp56k/bootstrap.bin"; int err; int i; dsp56k_reset(); pdev = platform_device_register_simple("dsp56k", 0, NULL, 0); if (IS_ERR(pdev)) { printk(KERN_ERR "Failed to register device for \"%s\"\n", fw_name); return -EINVAL; } err = request_firmware(&fw, fw_name, &pdev->dev); platform_device_unregister(pdev); if (err) { printk(KERN_ERR "Failed to load image \"%s\" err %d\n", fw_name, err); return err; } if (fw->size % 3) { printk(KERN_ERR "Bogus length %d in image \"%s\"\n", fw->size, fw_name); release_firmware(fw); return -EINVAL; } for (i = 0; i < fw->size; i = i + 3) { /* tx_wait(10); */ dsp56k_host_interface.data.b[1] = fw->data[i]; dsp56k_host_interface.data.b[2] = fw->data[i + 1]; dsp56k_host_interface.data.b[3] = fw->data[i + 2]; } release_firmware(fw); for (; i < 512; i++) { /* tx_wait(10); */ dsp56k_host_interface.data.b[1] = 0; dsp56k_host_interface.data.b[2] = 0; dsp56k_host_interface.data.b[3] = 0; } for (i = 0; i < len; i++) { tx_wait(10); get_user(dsp56k_host_interface.data.b[1], bin++); get_user(dsp56k_host_interface.data.b[2], bin++); get_user(dsp56k_host_interface.data.b[3], bin++); } tx_wait(10); dsp56k_host_interface.data.l = 3; /* Magic execute */ return 0; } static ssize_t dsp56k_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct inode *inode = file->f_path.dentry->d_inode; int dev = iminor(inode) & 0x0f; switch(dev) { case DSP56K_DEV_56001: { long n; /* Don't do anything if nothing is to be done */ if (!count) return 0; n = 0; switch (dsp56k.rx_wsize) { case 1: /* 8 bit */ { handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_RECEIVE, put_user(dsp56k_host_interface.data.b[3], buf+n++)); return n; } case 2: /* 16 bit */ { short __user *data; count /= 2; data = (short __user *) buf; handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_RECEIVE, put_user(dsp56k_host_interface.data.w[1], data+n++)); return 2*n; } case 3: /* 24 bit */ { count /= 3; handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_RECEIVE, put_user(dsp56k_host_interface.data.b[1], buf+n++); put_user(dsp56k_host_interface.data.b[2], buf+n++); put_user(dsp56k_host_interface.data.b[3], buf+n++)); return 3*n; } case 4: /* 32 bit */ { long __user *data; count /= 4; data = (long __user *) buf; handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_RECEIVE, put_user(dsp56k_host_interface.data.l, data+n++)); return 4*n; } } return -EFAULT; } default: printk(KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev); return -ENXIO; } } static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct inode *inode = file->f_path.dentry->d_inode; int dev = iminor(inode) & 0x0f; switch(dev) { case DSP56K_DEV_56001: { long n; /* Don't do anything if nothing is to be done */ if (!count) return 0; n = 0; switch (dsp56k.tx_wsize) { case 1: /* 8 bit */ { handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_TRANSMIT, get_user(dsp56k_host_interface.data.b[3], buf+n++)); return n; } case 2: /* 16 bit */ { const short __user *data; count /= 2; data = (const short __user *)buf; handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_TRANSMIT, get_user(dsp56k_host_interface.data.w[1], data+n++)); return 2*n; } case 3: /* 24 bit */ { count /= 3; handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_TRANSMIT, get_user(dsp56k_host_interface.data.b[1], buf+n++); get_user(dsp56k_host_interface.data.b[2], buf+n++); get_user(dsp56k_host_interface.data.b[3], buf+n++)); return 3*n; } case 4: /* 32 bit */ { const long __user *data; count /= 4; data = (const long __user *)buf; handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_TRANSMIT, get_user(dsp56k_host_interface.data.l, data+n++)); return 4*n; } } return -EFAULT; } default: printk(KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev); return -ENXIO; } } static long dsp56k_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int dev = iminor(file->f_path.dentry->d_inode) & 0x0f; void __user *argp = (void __user *)arg; switch(dev) { case DSP56K_DEV_56001: switch(cmd) { case DSP56K_UPLOAD: { char __user *bin; int r, len; struct dsp56k_upload __user *binary = argp; if(get_user(len, &binary->len) < 0) return -EFAULT; if(get_user(bin, &binary->bin) < 0) return -EFAULT; if (len == 0) { return -EINVAL; /* nothing to upload?!? */ } if (len > DSP56K_MAX_BINARY_LENGTH) { return -EINVAL; } lock_kernel(); r = dsp56k_upload(bin, len); unlock_kernel(); if (r < 0) { return r; } break; } case DSP56K_SET_TX_WSIZE: if (arg > 4 || arg < 1) return -EINVAL; lock_kernel(); dsp56k.tx_wsize = (int) arg; unlock_kernel(); break; case DSP56K_SET_RX_WSIZE: if (arg > 4 || arg < 1) return -EINVAL; lock_kernel(); dsp56k.rx_wsize = (int) arg; unlock_kernel(); break; case DSP56K_HOST_FLAGS: { int dir, out, status; struct dsp56k_host_flags __user *hf = argp; if(get_user(dir, &hf->dir) < 0) return -EFAULT; if(get_user(out, &hf->out) < 0) return -EFAULT; lock_kernel(); if ((dir & 0x1) && (out & 0x1)) dsp56k_host_interface.icr |= DSP56K_ICR_HF0; else if (dir & 0x1) dsp56k_host_interface.icr &= ~DSP56K_ICR_HF0; if ((dir & 0x2) && (out & 0x2)) dsp56k_host_interface.icr |= DSP56K_ICR_HF1; else if (dir & 0x2) dsp56k_host_interface.icr &= ~DSP56K_ICR_HF1; status = 0; if (dsp56k_host_interface.icr & DSP56K_ICR_HF0) status |= 0x1; if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; unlock_kernel(); return put_user(status, &hf->status); } case DSP56K_HOST_CMD: if (arg > 31 || arg < 0) return -EINVAL; lock_kernel(); dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | DSP56K_CVR_HC); unlock_kernel(); break; default: return -EINVAL; } return 0; default: printk(KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev); return -ENXIO; } } /* As of 2.1.26 this should be dsp56k_poll, * but how do I then check device minor number? * Do I need this function at all??? */ #if 0 static unsigned int dsp56k_poll(struct file *file, poll_table *wait) { int dev = iminor(file->f_path.dentry->d_inode) & 0x0f; switch(dev) { case DSP56K_DEV_56001: /* poll_wait(file, ???, wait); */ return POLLIN | POLLRDNORM | POLLOUT; default: printk("DSP56k driver: Unknown minor device: %d\n", dev); return 0; } } #endif static int dsp56k_open(struct inode *inode, struct file *file) { int dev = iminor(inode) & 0x0f; int ret = 0; lock_kernel(); switch(dev) { case DSP56K_DEV_56001: if (test_and_set_bit(0, &dsp56k.in_use)) { ret = -EBUSY; goto out; } dsp56k.timeout = TIMEOUT; dsp56k.maxio = MAXIO; dsp56k.rx_wsize = dsp56k.tx_wsize = 4; DSP56K_TX_INT_OFF; DSP56K_RX_INT_OFF; /* Zero host flags */ dsp56k_host_interface.icr &= ~DSP56K_ICR_HF0; dsp56k_host_interface.icr &= ~DSP56K_ICR_HF1; break; default: ret = -ENODEV; } out: unlock_kernel(); return ret; } static int dsp56k_release(struct inode *inode, struct file *file) { int dev = iminor(inode) & 0x0f; switch(dev) { case DSP56K_DEV_56001: clear_bit(0, &dsp56k.in_use); break; default: printk(KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev); return -ENXIO; } return 0; } static const struct file_operations dsp56k_fops = { .owner = THIS_MODULE, .read = dsp56k_read, .write = dsp56k_write, .unlocked_ioctl = dsp56k_ioctl, .open = dsp56k_open, .release = dsp56k_release, }; /****** Init and module functions ******/ static char banner[] __initdata = KERN_INFO "DSP56k driver installed\n"; static int __init dsp56k_init_driver(void) { int err = 0; if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) { printk("DSP56k driver: Hardware not present\n"); return -ENODEV; } if(register_chrdev(DSP56K_MAJOR, "dsp56k", &dsp56k_fops)) { printk("DSP56k driver: Unable to register driver\n"); return -ENODEV; } dsp56k_class = class_create(THIS_MODULE, "dsp56k"); if (IS_ERR(dsp56k_class)) { err = PTR_ERR(dsp56k_class); goto out_chrdev; } device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); printk(banner); goto out; out_chrdev: unregister_chrdev(DSP56K_MAJOR, "dsp56k"); out: return err; } module_init(dsp56k_init_driver); static void __exit dsp56k_cleanup_driver(void) { device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); class_destroy(dsp56k_class); unregister_chrdev(DSP56K_MAJOR, "dsp56k"); } module_exit(dsp56k_cleanup_driver); MODULE_LICENSE("GPL"); MODULE_FIRMWARE("dsp56k/bootstrap.bin");
croniccorey/bandit-kernel
drivers/char/dsp56k.c
C
gpl-2.0
12,404
/* nebula.h - Keytable for nebula Remote Controller * * keymap imported from ir-keymaps.c * * Copyright (c) 2010 by Mauro Carvalho Chehab * * 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. */ #include <media/rc-map.h> #include <linux/module.h> static struct rc_map_table nebula[] = { { 0x0000, KEY_0 }, { 0x0001, KEY_1 }, { 0x0002, KEY_2 }, { 0x0003, KEY_3 }, { 0x0004, KEY_4 }, { 0x0005, KEY_5 }, { 0x0006, KEY_6 }, { 0x0007, KEY_7 }, { 0x0008, KEY_8 }, { 0x0009, KEY_9 }, { 0x000a, KEY_TV }, { 0x000b, KEY_AUX }, { 0x000c, KEY_DVD }, { 0x000d, KEY_POWER }, { 0x000e, KEY_CAMERA }, /* labelled 'Picture' */ { 0x000f, KEY_AUDIO }, { 0x0010, KEY_INFO }, { 0x0011, KEY_F13 }, /* 16:9 */ { 0x0012, KEY_F14 }, /* 14:9 */ { 0x0013, KEY_EPG }, { 0x0014, KEY_EXIT }, { 0x0015, KEY_MENU }, { 0x0016, KEY_UP }, { 0x0017, KEY_DOWN }, { 0x0018, KEY_LEFT }, { 0x0019, KEY_RIGHT }, { 0x001a, KEY_ENTER }, { 0x001b, KEY_CHANNELUP }, { 0x001c, KEY_CHANNELDOWN }, { 0x001d, KEY_VOLUMEUP }, { 0x001e, KEY_VOLUMEDOWN }, { 0x001f, KEY_RED }, { 0x0020, KEY_GREEN }, { 0x0021, KEY_YELLOW }, { 0x0022, KEY_BLUE }, { 0x0023, KEY_SUBTITLE }, { 0x0024, KEY_F15 }, /* AD */ { 0x0025, KEY_TEXT }, { 0x0026, KEY_MUTE }, { 0x0027, KEY_REWIND }, { 0x0028, KEY_STOP }, { 0x0029, KEY_PLAY }, { 0x002a, KEY_FASTFORWARD }, { 0x002b, KEY_F16 }, /* chapter */ { 0x002c, KEY_PAUSE }, { 0x002d, KEY_PLAY }, { 0x002e, KEY_RECORD }, { 0x002f, KEY_F17 }, /* picture in picture */ { 0x0030, KEY_KPPLUS }, /* zoom in */ { 0x0031, KEY_KPMINUS }, /* zoom out */ { 0x0032, KEY_F18 }, /* capture */ { 0x0033, KEY_F19 }, /* web */ { 0x0034, KEY_EMAIL }, { 0x0035, KEY_PHONE }, { 0x0036, KEY_PC }, }; static struct rc_map_list nebula_map = { .map = { .scan = nebula, .size = ARRAY_SIZE(nebula), .rc_type = RC_TYPE_RC5, .name = RC_MAP_NEBULA, } }; static int __init init_rc_map_nebula(void) { return rc_map_register(&nebula_map); } static void __exit exit_rc_map_nebula(void) { rc_map_unregister(&nebula_map); } module_init(init_rc_map_nebula) module_exit(exit_rc_map_nebula) MODULE_LICENSE("GPL"); MODULE_AUTHOR("Mauro Carvalho Chehab");
hikerockies/linux
drivers/media/rc/keymaps/rc-nebula.c
C
gpl-2.0
2,381
/* * POWER platform energy management driver * Copyright (C) 2010 IBM Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This pseries platform device driver provides access to * platform energy management capabilities. */ #include <linux/module.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/seq_file.h> #include <linux/device.h> #include <linux/cpu.h> #include <linux/of.h> #include <asm/cputhreads.h> #include <asm/page.h> #include <asm/hvcall.h> #include <asm/firmware.h> #define MODULE_VERS "1.0" #define MODULE_NAME "pseries_energy" /* Driver flags */ static int sysfs_entries; /* Helper routines */ /* Helper Routines to convert between drc_index to cpu numbers */ static u32 cpu_to_drc_index(int cpu) { struct device_node *dn = NULL; const int *indexes; int i; int rc = 1; u32 ret = 0; dn = of_find_node_by_path("/cpus"); if (dn == NULL) goto err; indexes = of_get_property(dn, "ibm,drc-indexes", NULL); if (indexes == NULL) goto err_of_node_put; /* Convert logical cpu number to core number */ i = cpu_core_index_of_thread(cpu); /* * The first element indexes[0] is the number of drc_indexes * returned in the list. Hence i+1 will get the drc_index * corresponding to core number i. */ WARN_ON(i > indexes[0]); ret = indexes[i + 1]; rc = 0; err_of_node_put: of_node_put(dn); err: if (rc) printk(KERN_WARNING "cpu_to_drc_index(%d) failed", cpu); return ret; } static int drc_index_to_cpu(u32 drc_index) { struct device_node *dn = NULL; const int *indexes; int i, cpu = 0; int rc = 1; dn = of_find_node_by_path("/cpus"); if (dn == NULL) goto err; indexes = of_get_property(dn, "ibm,drc-indexes", NULL); if (indexes == NULL) goto err_of_node_put; /* * First element in the array is the number of drc_indexes * returned. Search through the list to find the matching * drc_index and get the core number */ for (i = 0; i < indexes[0]; i++) { if (indexes[i + 1] == drc_index) break; } /* Convert core number to logical cpu number */ cpu = cpu_first_thread_of_core(i); rc = 0; err_of_node_put: of_node_put(dn); err: if (rc) printk(KERN_WARNING "drc_index_to_cpu(%d) failed", drc_index); return cpu; } /* * pseries hypervisor call H_BEST_ENERGY provides hints to OS on * preferred logical cpus to activate or deactivate for optimized * energy consumption. */ #define FLAGS_MODE1 0x004E200000080E01 #define FLAGS_MODE2 0x004E200000080401 #define FLAGS_ACTIVATE 0x100 static ssize_t get_best_energy_list(char *page, int activate) { int rc, cnt, i, cpu; unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; unsigned long flags = 0; u32 *buf_page; char *s = page; buf_page = (u32 *) get_zeroed_page(GFP_KERNEL); if (!buf_page) return -ENOMEM; flags = FLAGS_MODE1; if (activate) flags |= FLAGS_ACTIVATE; rc = plpar_hcall9(H_BEST_ENERGY, retbuf, flags, 0, __pa(buf_page), 0, 0, 0, 0, 0, 0); if (rc != H_SUCCESS) { free_page((unsigned long) buf_page); return -EINVAL; } cnt = retbuf[0]; for (i = 0; i < cnt; i++) { cpu = drc_index_to_cpu(buf_page[2*i+1]); if ((cpu_online(cpu) && !activate) || (!cpu_online(cpu) && activate)) s += sprintf(s, "%d,", cpu); } if (s > page) { /* Something to show */ s--; /* Suppress last comma */ s += sprintf(s, "\n"); } free_page((unsigned long) buf_page); return s-page; } static ssize_t get_best_energy_data(struct device *dev, char *page, int activate) { int rc; unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; unsigned long flags = 0; flags = FLAGS_MODE2; if (activate) flags |= FLAGS_ACTIVATE; rc = plpar_hcall9(H_BEST_ENERGY, retbuf, flags, cpu_to_drc_index(dev->id), 0, 0, 0, 0, 0, 0, 0); if (rc != H_SUCCESS) return -EINVAL; return sprintf(page, "%lu\n", retbuf[1] >> 32); } /* Wrapper functions */ static ssize_t cpu_activate_hint_list_show(struct device *dev, struct device_attribute *attr, char *page) { return get_best_energy_list(page, 1); } static ssize_t cpu_deactivate_hint_list_show(struct device *dev, struct device_attribute *attr, char *page) { return get_best_energy_list(page, 0); } static ssize_t percpu_activate_hint_show(struct device *dev, struct device_attribute *attr, char *page) { return get_best_energy_data(dev, page, 1); } static ssize_t percpu_deactivate_hint_show(struct device *dev, struct device_attribute *attr, char *page) { return get_best_energy_data(dev, page, 0); } /* * Create sysfs interface: * /sys/devices/system/cpu/pseries_activate_hint_list * /sys/devices/system/cpu/pseries_deactivate_hint_list * Comma separated list of cpus to activate or deactivate * /sys/devices/system/cpu/cpuN/pseries_activate_hint * /sys/devices/system/cpu/cpuN/pseries_deactivate_hint * Per-cpu value of the hint */ struct device_attribute attr_cpu_activate_hint_list = __ATTR(pseries_activate_hint_list, 0444, cpu_activate_hint_list_show, NULL); struct device_attribute attr_cpu_deactivate_hint_list = __ATTR(pseries_deactivate_hint_list, 0444, cpu_deactivate_hint_list_show, NULL); struct device_attribute attr_percpu_activate_hint = __ATTR(pseries_activate_hint, 0444, percpu_activate_hint_show, NULL); struct device_attribute attr_percpu_deactivate_hint = __ATTR(pseries_deactivate_hint, 0444, percpu_deactivate_hint_show, NULL); static int __init pseries_energy_init(void) { int cpu, err; struct device *cpu_dev; if (!firmware_has_feature(FW_FEATURE_BEST_ENERGY)) { printk(KERN_INFO "Hypercall H_BEST_ENERGY not supported\n"); return 0; } /* Create the sysfs files */ err = device_create_file(cpu_subsys.dev_root, &attr_cpu_activate_hint_list); if (!err) err = device_create_file(cpu_subsys.dev_root, &attr_cpu_deactivate_hint_list); if (err) return err; for_each_possible_cpu(cpu) { cpu_dev = get_cpu_device(cpu); err = device_create_file(cpu_dev, &attr_percpu_activate_hint); if (err) break; err = device_create_file(cpu_dev, &attr_percpu_deactivate_hint); if (err) break; } if (err) return err; sysfs_entries = 1; /* Removed entries on cleanup */ return 0; } static void __exit pseries_energy_cleanup(void) { int cpu; struct device *cpu_dev; if (!sysfs_entries) return; /* Remove the sysfs files */ device_remove_file(cpu_subsys.dev_root, &attr_cpu_activate_hint_list); device_remove_file(cpu_subsys.dev_root, &attr_cpu_deactivate_hint_list); for_each_possible_cpu(cpu) { cpu_dev = get_cpu_device(cpu); sysfs_remove_file(&cpu_dev->kobj, &attr_percpu_activate_hint.attr); sysfs_remove_file(&cpu_dev->kobj, &attr_percpu_deactivate_hint.attr); } } module_init(pseries_energy_init); module_exit(pseries_energy_cleanup); MODULE_DESCRIPTION("Driver for pSeries platform energy management"); MODULE_AUTHOR("Vaidyanathan Srinivasan"); MODULE_LICENSE("GPL");
CTXz/Degaswifi-CPU-tweaks
arch/powerpc/platforms/pseries/pseries_energy.c
C
gpl-2.0
7,017
/* $Id: w6692.c,v 1.18.2.4 2004/02/11 13:21:34 keil Exp $ * * Winbond W6692 specific routines * * Author Petr Novak * Copyright by Petr Novak <petr.novak@i.cz> * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #include <linux/init.h> #include "hisax.h" #include "w6692.h" #include "isdnl1.h" #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/slab.h> /* table entry in the PCI devices list */ typedef struct { int vendor_id; int device_id; char *vendor_name; char *card_name; } PCI_ENTRY; static const PCI_ENTRY id_list[] = { {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, "Winbond", "W6692"}, {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, "Dynalink/AsusCom", "IS64PH"}, {0, 0, "U.S.Robotics", "ISDN PCI Card TA"} }; #define W6692_SV_USR 0x16ec #define W6692_SD_USR 0x3409 #define W6692_WINBOND 0 #define W6692_DYNALINK 1 #define W6692_USR 2 static const char *w6692_revision = "$Revision: 1.18.2.4 $"; #define DBUSY_TIMER_VALUE 80 static char *W6692Ver[] = {"W6692 V00", "W6692 V01", "W6692 V10", "W6692 V11"}; static void W6692Version(struct IsdnCardState *cs, char *s) { int val; val = cs->readW6692(cs, W_D_RBCH); printk(KERN_INFO "%s Winbond W6692 version (%x): %s\n", s, val, W6692Ver[(val >> 6) & 3]); } static void ph_command(struct IsdnCardState *cs, unsigned int command) { if (cs->debug & L1_DEB_ISAC) debugl1(cs, "ph_command %x", command); cs->writeisac(cs, W_CIX, command); } static void W6692_new_ph(struct IsdnCardState *cs) { switch (cs->dc.w6692.ph_state) { case (W_L1CMD_RST): ph_command(cs, W_L1CMD_DRC); l1_msg(cs, HW_RESET | INDICATION, NULL); /* fallthru */ case (W_L1IND_CD): l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); break; case (W_L1IND_DRD): l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); break; case (W_L1IND_CE): l1_msg(cs, HW_POWERUP | CONFIRM, NULL); break; case (W_L1IND_LD): l1_msg(cs, HW_RSYNC | INDICATION, NULL); break; case (W_L1IND_ARD): l1_msg(cs, HW_INFO2 | INDICATION, NULL); break; case (W_L1IND_AI8): l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); break; case (W_L1IND_AI10): l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL); break; default: break; } } static void W6692_bh(struct work_struct *work) { struct IsdnCardState *cs = container_of(work, struct IsdnCardState, tqueue); struct PStack *stptr; if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { if (cs->debug) debugl1(cs, "D-Channel Busy cleared"); stptr = cs->stlist; while (stptr != NULL) { stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL); stptr = stptr->next; } } if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) W6692_new_ph(cs); if (test_and_clear_bit(D_RCVBUFREADY, &cs->event)) DChannel_proc_rcv(cs); if (test_and_clear_bit(D_XMTBUFREADY, &cs->event)) DChannel_proc_xmt(cs); /* if (test_and_clear_bit(D_RX_MON1, &cs->event)) arcofi_fsm(cs, ARCOFI_RX_END, NULL); if (test_and_clear_bit(D_TX_MON1, &cs->event)) arcofi_fsm(cs, ARCOFI_TX_END, NULL); */ } static void W6692_empty_fifo(struct IsdnCardState *cs, int count) { u_char *ptr; if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO)) debugl1(cs, "W6692_empty_fifo"); if ((cs->rcvidx + count) >= MAX_DFRAME_LEN_L1) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692_empty_fifo overrun %d", cs->rcvidx + count); cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK); cs->rcvidx = 0; return; } ptr = cs->rcvbuf + cs->rcvidx; cs->rcvidx += count; cs->readW6692fifo(cs, ptr, count); cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK); if (cs->debug & L1_DEB_ISAC_FIFO) { char *t = cs->dlog; t += sprintf(t, "W6692_empty_fifo cnt %d", count); QuickHex(t, ptr, count); debugl1(cs, cs->dlog); } } static void W6692_fill_fifo(struct IsdnCardState *cs) { int count, more; u_char *ptr; if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO)) debugl1(cs, "W6692_fill_fifo"); if (!cs->tx_skb) return; count = cs->tx_skb->len; if (count <= 0) return; more = 0; if (count > W_D_FIFO_THRESH) { more = !0; count = W_D_FIFO_THRESH; } ptr = cs->tx_skb->data; skb_pull(cs->tx_skb, count); cs->tx_cnt += count; cs->writeW6692fifo(cs, ptr, count); cs->writeW6692(cs, W_D_CMDR, more ? W_D_CMDR_XMS : (W_D_CMDR_XMS | W_D_CMDR_XME)); if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { debugl1(cs, "W6692_fill_fifo dbusytimer running"); del_timer(&cs->dbusytimer); } init_timer(&cs->dbusytimer); cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ) / 1000); add_timer(&cs->dbusytimer); if (cs->debug & L1_DEB_ISAC_FIFO) { char *t = cs->dlog; t += sprintf(t, "W6692_fill_fifo cnt %d", count); QuickHex(t, ptr, count); debugl1(cs, cs->dlog); } } static void W6692B_empty_fifo(struct BCState *bcs, int count) { u_char *ptr; struct IsdnCardState *cs = bcs->cs; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "W6692B_empty_fifo"); if (bcs->hw.w6692.rcvidx + count > HSCX_BUFMAX) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692B_empty_fifo: incoming packet too large"); cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT); bcs->hw.w6692.rcvidx = 0; return; } ptr = bcs->hw.w6692.rcvbuf + bcs->hw.w6692.rcvidx; bcs->hw.w6692.rcvidx += count; READW6692BFIFO(cs, bcs->channel, ptr, count); cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT); if (cs->debug & L1_DEB_HSCX_FIFO) { char *t = bcs->blog; t += sprintf(t, "W6692B_empty_fifo %c cnt %d", bcs->channel + '1', count); QuickHex(t, ptr, count); debugl1(cs, bcs->blog); } } static void W6692B_fill_fifo(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; int more, count; u_char *ptr; if (!bcs->tx_skb) return; if (bcs->tx_skb->len <= 0) return; more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0; if (bcs->tx_skb->len > W_B_FIFO_THRESH) { more = 1; count = W_B_FIFO_THRESH; } else count = bcs->tx_skb->len; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "W6692B_fill_fifo%s%d", (more ? " " : " last "), count); ptr = bcs->tx_skb->data; skb_pull(bcs->tx_skb, count); bcs->tx_cnt -= count; bcs->hw.w6692.count += count; WRITEW6692BFIFO(cs, bcs->channel, ptr, count); cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACT | W_B_CMDR_XMS | (more ? 0 : W_B_CMDR_XME)); if (cs->debug & L1_DEB_HSCX_FIFO) { char *t = bcs->blog; t += sprintf(t, "W6692B_fill_fifo %c cnt %d", bcs->channel + '1', count); QuickHex(t, ptr, count); debugl1(cs, bcs->blog); } } static void W6692B_interrupt(struct IsdnCardState *cs, u_char bchan) { u_char val; u_char r; struct BCState *bcs; struct sk_buff *skb; int count; bcs = (cs->bcs->channel == bchan) ? cs->bcs : (cs->bcs + 1); val = cs->BC_Read_Reg(cs, bchan, W_B_EXIR); debugl1(cs, "W6692B chan %d B_EXIR 0x%02X", bchan, val); if (!test_bit(BC_FLG_INIT, &bcs->Flag)) { debugl1(cs, "W6692B not INIT yet"); return; } if (val & W_B_EXI_RME) { /* RME */ r = cs->BC_Read_Reg(cs, bchan, W_B_STAR); if (r & (W_B_STAR_RDOV | W_B_STAR_CRCE | W_B_STAR_RMB)) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 B STAR %x", r); if ((r & W_B_STAR_RDOV) && bcs->mode) if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 B RDOV mode=%d", bcs->mode); if (r & W_B_STAR_CRCE) if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 B CRC error"); cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT); } else { count = cs->BC_Read_Reg(cs, bchan, W_B_RBCL) & (W_B_FIFO_THRESH - 1); if (count == 0) count = W_B_FIFO_THRESH; W6692B_empty_fifo(bcs, count); if ((count = bcs->hw.w6692.rcvidx) > 0) { if (cs->debug & L1_DEB_HSCX_FIFO) debugl1(cs, "W6692 Bchan Frame %d", count); if (!(skb = dev_alloc_skb(count))) printk(KERN_WARNING "W6692: Bchan receive out of memory\n"); else { memcpy(skb_put(skb, count), bcs->hw.w6692.rcvbuf, count); skb_queue_tail(&bcs->rqueue, skb); } } } bcs->hw.w6692.rcvidx = 0; schedule_event(bcs, B_RCVBUFREADY); } if (val & W_B_EXI_RMR) { /* RMR */ W6692B_empty_fifo(bcs, W_B_FIFO_THRESH); r = cs->BC_Read_Reg(cs, bchan, W_B_STAR); if (r & W_B_STAR_RDOV) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 B RDOV(RMR) mode=%d", bcs->mode); cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT); if (bcs->mode != L1_MODE_TRANS) bcs->hw.w6692.rcvidx = 0; } if (bcs->mode == L1_MODE_TRANS) { /* receive audio data */ if (!(skb = dev_alloc_skb(W_B_FIFO_THRESH))) printk(KERN_WARNING "HiSax: receive out of memory\n"); else { memcpy(skb_put(skb, W_B_FIFO_THRESH), bcs->hw.w6692.rcvbuf, W_B_FIFO_THRESH); skb_queue_tail(&bcs->rqueue, skb); } bcs->hw.w6692.rcvidx = 0; schedule_event(bcs, B_RCVBUFREADY); } } if (val & W_B_EXI_XDUN) { /* XDUN */ cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT); if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 B EXIR %x Lost TX", val); if (bcs->mode == 1) W6692B_fill_fifo(bcs); else { /* Here we lost an TX interrupt, so * restart transmitting the whole frame. */ if (bcs->tx_skb) { skb_push(bcs->tx_skb, bcs->hw.w6692.count); bcs->tx_cnt += bcs->hw.w6692.count; bcs->hw.w6692.count = 0; } } return; } if (val & W_B_EXI_XFR) { /* XFR */ r = cs->BC_Read_Reg(cs, bchan, W_B_STAR); if (r & W_B_STAR_XDOW) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 B STAR %x XDOW", r); cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT); if (bcs->tx_skb && (bcs->mode != 1)) { skb_push(bcs->tx_skb, bcs->hw.w6692.count); bcs->tx_cnt += bcs->hw.w6692.count; bcs->hw.w6692.count = 0; } } if (bcs->tx_skb) { if (bcs->tx_skb->len) { W6692B_fill_fifo(bcs); return; } else { if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.w6692.count; spin_unlock_irqrestore(&bcs->aclock, flags); schedule_event(bcs, B_ACKPENDING); } dev_kfree_skb_irq(bcs->tx_skb); bcs->hw.w6692.count = 0; bcs->tx_skb = NULL; } } if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { bcs->hw.w6692.count = 0; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); W6692B_fill_fifo(bcs); } else { test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); schedule_event(bcs, B_XMTBUFREADY); } } } static irqreturn_t W6692_interrupt(int intno, void *dev_id) { struct IsdnCardState *cs = dev_id; u_char val, exval, v1; struct sk_buff *skb; u_int count; u_long flags; int icnt = 5; spin_lock_irqsave(&cs->lock, flags); val = cs->readW6692(cs, W_ISTA); if (!val) { spin_unlock_irqrestore(&cs->lock, flags); return IRQ_NONE; } StartW6692: if (cs->debug & L1_DEB_ISAC) debugl1(cs, "W6692 ISTA %x", val); if (val & W_INT_D_RME) { /* RME */ exval = cs->readW6692(cs, W_D_RSTA); if (exval & (W_D_RSTA_RDOV | W_D_RSTA_CRCE | W_D_RSTA_RMB)) { if (exval & W_D_RSTA_RDOV) if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 RDOV"); if (exval & W_D_RSTA_CRCE) if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 D-channel CRC error"); if (exval & W_D_RSTA_RMB) if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 D-channel ABORT"); cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK | W_D_CMDR_RRST); } else { count = cs->readW6692(cs, W_D_RBCL) & (W_D_FIFO_THRESH - 1); if (count == 0) count = W_D_FIFO_THRESH; W6692_empty_fifo(cs, count); if ((count = cs->rcvidx) > 0) { cs->rcvidx = 0; if (!(skb = alloc_skb(count, GFP_ATOMIC))) printk(KERN_WARNING "HiSax: D receive out of memory\n"); else { memcpy(skb_put(skb, count), cs->rcvbuf, count); skb_queue_tail(&cs->rq, skb); } } } cs->rcvidx = 0; schedule_event(cs, D_RCVBUFREADY); } if (val & W_INT_D_RMR) { /* RMR */ W6692_empty_fifo(cs, W_D_FIFO_THRESH); } if (val & W_INT_D_XFR) { /* XFR */ if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) del_timer(&cs->dbusytimer); if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) schedule_event(cs, D_CLEARBUSY); if (cs->tx_skb) { if (cs->tx_skb->len) { W6692_fill_fifo(cs); goto afterXFR; } else { dev_kfree_skb_irq(cs->tx_skb); cs->tx_cnt = 0; cs->tx_skb = NULL; } } if ((cs->tx_skb = skb_dequeue(&cs->sq))) { cs->tx_cnt = 0; W6692_fill_fifo(cs); } else schedule_event(cs, D_XMTBUFREADY); } afterXFR: if (val & (W_INT_XINT0 | W_INT_XINT1)) { /* XINT0/1 - never */ if (cs->debug & L1_DEB_ISAC) debugl1(cs, "W6692 spurious XINT!"); } if (val & W_INT_D_EXI) { /* EXI */ exval = cs->readW6692(cs, W_D_EXIR); if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692 D_EXIR %02x", exval); if (exval & (W_D_EXI_XDUN | W_D_EXI_XCOL)) { /* Transmit underrun/collision */ debugl1(cs, "W6692 D-chan underrun/collision"); printk(KERN_WARNING "HiSax: W6692 XDUN/XCOL\n"); if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) del_timer(&cs->dbusytimer); if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) schedule_event(cs, D_CLEARBUSY); if (cs->tx_skb) { /* Restart frame */ skb_push(cs->tx_skb, cs->tx_cnt); cs->tx_cnt = 0; W6692_fill_fifo(cs); } else { printk(KERN_WARNING "HiSax: W6692 XDUN/XCOL no skb\n"); debugl1(cs, "W6692 XDUN/XCOL no skb"); cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST); } } if (exval & W_D_EXI_RDOV) { /* RDOV */ debugl1(cs, "W6692 D-channel RDOV"); printk(KERN_WARNING "HiSax: W6692 D-RDOV\n"); cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST); } if (exval & W_D_EXI_TIN2) { /* TIN2 - never */ debugl1(cs, "W6692 spurious TIN2 interrupt"); } if (exval & W_D_EXI_MOC) { /* MOC - not supported */ debugl1(cs, "W6692 spurious MOC interrupt"); v1 = cs->readW6692(cs, W_MOSR); debugl1(cs, "W6692 MOSR %02x", v1); } if (exval & W_D_EXI_ISC) { /* ISC - Level1 change */ v1 = cs->readW6692(cs, W_CIR); if (cs->debug & L1_DEB_ISAC) debugl1(cs, "W6692 ISC CIR=0x%02X", v1); if (v1 & W_CIR_ICC) { cs->dc.w6692.ph_state = v1 & W_CIR_COD_MASK; if (cs->debug & L1_DEB_ISAC) debugl1(cs, "ph_state_change %x", cs->dc.w6692.ph_state); schedule_event(cs, D_L1STATECHANGE); } if (v1 & W_CIR_SCC) { v1 = cs->readW6692(cs, W_SQR); debugl1(cs, "W6692 SCC SQR=0x%02X", v1); } } if (exval & W_D_EXI_WEXP) { debugl1(cs, "W6692 spurious WEXP interrupt!"); } if (exval & W_D_EXI_TEXP) { debugl1(cs, "W6692 spurious TEXP interrupt!"); } } if (val & W_INT_B1_EXI) { debugl1(cs, "W6692 B channel 1 interrupt"); W6692B_interrupt(cs, 0); } if (val & W_INT_B2_EXI) { debugl1(cs, "W6692 B channel 2 interrupt"); W6692B_interrupt(cs, 1); } val = cs->readW6692(cs, W_ISTA); if (val && icnt) { icnt--; goto StartW6692; } if (!icnt) { printk(KERN_WARNING "W6692 IRQ LOOP\n"); cs->writeW6692(cs, W_IMASK, 0xff); } spin_unlock_irqrestore(&cs->lock, flags); return IRQ_HANDLED; } static void W6692_l1hw(struct PStack *st, int pr, void *arg) { struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; struct sk_buff *skb = arg; u_long flags; int val; switch (pr) { case (PH_DATA | REQUEST): if (cs->debug & DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len); if (cs->debug & DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0); spin_lock_irqsave(&cs->lock, flags); if (cs->tx_skb) { skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA", 0); #endif W6692_fill_fifo(cs); } spin_unlock_irqrestore(&cs->lock, flags); break; case (PH_PULL | INDICATION): spin_lock_irqsave(&cs->lock, flags); if (cs->tx_skb) { if (cs->debug & L1_DEB_WARN) debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; } if (cs->debug & DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len); if (cs->debug & DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0); cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif W6692_fill_fifo(cs); spin_unlock_irqrestore(&cs->lock, flags); break; case (PH_PULL | REQUEST): #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) debugl1(cs, "-> PH_REQUEST_PULL"); #endif if (!cs->tx_skb) { test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); } else test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); break; case (HW_RESET | REQUEST): spin_lock_irqsave(&cs->lock, flags); if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) { ph_command(cs, W_L1CMD_ECK); spin_unlock_irqrestore(&cs->lock, flags); } else { ph_command(cs, W_L1CMD_RST); cs->dc.w6692.ph_state = W_L1CMD_RST; spin_unlock_irqrestore(&cs->lock, flags); W6692_new_ph(cs); } break; case (HW_ENABLE | REQUEST): spin_lock_irqsave(&cs->lock, flags); ph_command(cs, W_L1CMD_ECK); spin_unlock_irqrestore(&cs->lock, flags); break; case (HW_INFO3 | REQUEST): spin_lock_irqsave(&cs->lock, flags); ph_command(cs, W_L1CMD_AR8); spin_unlock_irqrestore(&cs->lock, flags); break; case (HW_TESTLOOP | REQUEST): val = 0; if (1 & (long) arg) val |= 0x0c; if (2 & (long) arg) val |= 0x3; /* !!! not implemented yet */ break; case (HW_DEACTIVATE | RESPONSE): skb_queue_purge(&cs->rq); skb_queue_purge(&cs->sq); if (cs->tx_skb) { dev_kfree_skb_any(cs->tx_skb); cs->tx_skb = NULL; } if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) del_timer(&cs->dbusytimer); if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) schedule_event(cs, D_CLEARBUSY); break; default: if (cs->debug & L1_DEB_WARN) debugl1(cs, "W6692_l1hw unknown %04x", pr); break; } } static void setstack_W6692(struct PStack *st, struct IsdnCardState *cs) { st->l1.l1hw = W6692_l1hw; } static void DC_Close_W6692(struct IsdnCardState *cs) { } static void dbusy_timer_handler(struct IsdnCardState *cs) { struct PStack *stptr; int rbch, star; u_long flags; spin_lock_irqsave(&cs->lock, flags); if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { rbch = cs->readW6692(cs, W_D_RBCH); star = cs->readW6692(cs, W_D_STAR); if (cs->debug) debugl1(cs, "D-Channel Busy D_RBCH %02x D_STAR %02x", rbch, star); if (star & W_D_STAR_XBZ) { /* D-Channel Busy */ test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags); stptr = cs->stlist; while (stptr != NULL) { stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL); stptr = stptr->next; } } else { /* discard frame; reset transceiver */ test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags); if (cs->tx_skb) { dev_kfree_skb_any(cs->tx_skb); cs->tx_cnt = 0; cs->tx_skb = NULL; } else { printk(KERN_WARNING "HiSax: W6692 D-Channel Busy no skb\n"); debugl1(cs, "D-Channel Busy no skb"); } cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST); /* Transmitter reset */ spin_unlock_irqrestore(&cs->lock, flags); cs->irq_func(cs->irq, cs); return; } } spin_unlock_irqrestore(&cs->lock, flags); } static void W6692Bmode(struct BCState *bcs, int mode, int bchan) { struct IsdnCardState *cs = bcs->cs; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "w6692 %c mode %d ichan %d", '1' + bchan, mode, bchan); bcs->mode = mode; bcs->channel = bchan; bcs->hw.w6692.bchan = bchan; switch (mode) { case (L1_MODE_NULL): cs->BC_Write_Reg(cs, bchan, W_B_MODE, 0); break; case (L1_MODE_TRANS): cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_MMS); break; case (L1_MODE_HDLC): cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_ITF); cs->BC_Write_Reg(cs, bchan, W_B_ADM1, 0xff); cs->BC_Write_Reg(cs, bchan, W_B_ADM2, 0xff); break; } if (mode) cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_RACT | W_B_CMDR_XRST); cs->BC_Write_Reg(cs, bchan, W_B_EXIM, 0x00); } static void W6692_l2l1(struct PStack *st, int pr, void *arg) { struct sk_buff *skb = arg; struct BCState *bcs = st->l1.bcs; u_long flags; switch (pr) { case (PH_DATA | REQUEST): spin_lock_irqsave(&bcs->cs->lock, flags); if (bcs->tx_skb) { skb_queue_tail(&bcs->squeue, skb); } else { bcs->tx_skb = skb; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); bcs->hw.w6692.count = 0; bcs->cs->BC_Send_Data(bcs); } spin_unlock_irqrestore(&bcs->cs->lock, flags); break; case (PH_PULL | INDICATION): if (bcs->tx_skb) { printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n"); break; } spin_lock_irqsave(&bcs->cs->lock, flags); test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); bcs->tx_skb = skb; bcs->hw.w6692.count = 0; bcs->cs->BC_Send_Data(bcs); spin_unlock_irqrestore(&bcs->cs->lock, flags); break; case (PH_PULL | REQUEST): if (!bcs->tx_skb) { test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); } else test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); break; case (PH_ACTIVATE | REQUEST): spin_lock_irqsave(&bcs->cs->lock, flags); test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); W6692Bmode(bcs, st->l1.mode, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); l1_msg_b(st, pr, arg); break; case (PH_DEACTIVATE | REQUEST): l1_msg_b(st, pr, arg); break; case (PH_DEACTIVATE | CONFIRM): spin_lock_irqsave(&bcs->cs->lock, flags); test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); W6692Bmode(bcs, 0, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); break; } } static void close_w6692state(struct BCState *bcs) { W6692Bmode(bcs, 0, bcs->channel); if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { kfree(bcs->hw.w6692.rcvbuf); bcs->hw.w6692.rcvbuf = NULL; kfree(bcs->blog); bcs->blog = NULL; skb_queue_purge(&bcs->rqueue); skb_queue_purge(&bcs->squeue); if (bcs->tx_skb) { dev_kfree_skb_any(bcs->tx_skb); bcs->tx_skb = NULL; test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); } } } static int open_w6692state(struct IsdnCardState *cs, struct BCState *bcs) { if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { if (!(bcs->hw.w6692.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) { printk(KERN_WARNING "HiSax: No memory for w6692.rcvbuf\n"); test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); return (1); } if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) { printk(KERN_WARNING "HiSax: No memory for bcs->blog\n"); test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); kfree(bcs->hw.w6692.rcvbuf); bcs->hw.w6692.rcvbuf = NULL; return (2); } skb_queue_head_init(&bcs->rqueue); skb_queue_head_init(&bcs->squeue); } bcs->tx_skb = NULL; test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); bcs->event = 0; bcs->hw.w6692.rcvidx = 0; bcs->tx_cnt = 0; return (0); } static int setstack_w6692(struct PStack *st, struct BCState *bcs) { bcs->channel = st->l1.bc; if (open_w6692state(st->l1.hardware, bcs)) return (-1); st->l1.bcs = bcs; st->l2.l2l1 = W6692_l2l1; setstack_manager(st); bcs->st = st; setstack_l1_B(st); return (0); } static void resetW6692(struct IsdnCardState *cs) { cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST); mdelay(10); cs->writeW6692(cs, W_D_CTL, 0x00); mdelay(10); cs->writeW6692(cs, W_IMASK, 0xff); cs->writeW6692(cs, W_D_SAM, 0xff); cs->writeW6692(cs, W_D_TAM, 0xff); cs->writeW6692(cs, W_D_EXIM, 0x00); cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT); cs->writeW6692(cs, W_IMASK, 0x18); if (cs->subtyp == W6692_USR) { /* seems that USR implemented some power control features * Pin 79 is connected to the oscilator circuit so we * have to handle it here */ cs->writeW6692(cs, W_PCTL, 0x80); cs->writeW6692(cs, W_XDATA, 0x00); } } static void initW6692(struct IsdnCardState *cs, int part) { if (part & 1) { cs->setstack_d = setstack_W6692; cs->DC_Close = DC_Close_W6692; cs->dbusytimer.function = (void *) dbusy_timer_handler; cs->dbusytimer.data = (long) cs; init_timer(&cs->dbusytimer); resetW6692(cs); ph_command(cs, W_L1CMD_RST); cs->dc.w6692.ph_state = W_L1CMD_RST; W6692_new_ph(cs); ph_command(cs, W_L1CMD_ECK); cs->bcs[0].BC_SetStack = setstack_w6692; cs->bcs[1].BC_SetStack = setstack_w6692; cs->bcs[0].BC_Close = close_w6692state; cs->bcs[1].BC_Close = close_w6692state; W6692Bmode(cs->bcs, 0, 0); W6692Bmode(cs->bcs + 1, 0, 0); } if (part & 2) { /* Reenable all IRQ */ cs->writeW6692(cs, W_IMASK, 0x18); cs->writeW6692(cs, W_D_EXIM, 0x00); cs->BC_Write_Reg(cs, 0, W_B_EXIM, 0x00); cs->BC_Write_Reg(cs, 1, W_B_EXIM, 0x00); /* Reset D-chan receiver and transmitter */ cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST | W_D_CMDR_XRST); } } /* Interface functions */ static u_char ReadW6692(struct IsdnCardState *cs, u_char offset) { return (inb(cs->hw.w6692.iobase + offset)); } static void WriteW6692(struct IsdnCardState *cs, u_char offset, u_char value) { outb(value, cs->hw.w6692.iobase + offset); } static void ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { insb(cs->hw.w6692.iobase + W_D_RFIFO, data, size); } static void WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { outsb(cs->hw.w6692.iobase + W_D_XFIFO, data, size); } static u_char ReadW6692B(struct IsdnCardState *cs, int bchan, u_char offset) { return (inb(cs->hw.w6692.iobase + (bchan ? 0x40 : 0) + offset)); } static void WriteW6692B(struct IsdnCardState *cs, int bchan, u_char offset, u_char value) { outb(value, cs->hw.w6692.iobase + (bchan ? 0x40 : 0) + offset); } static int w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg) { switch (mt) { case CARD_RESET: resetW6692(cs); return (0); case CARD_RELEASE: cs->writeW6692(cs, W_IMASK, 0xff); release_region(cs->hw.w6692.iobase, 256); if (cs->subtyp == W6692_USR) { cs->writeW6692(cs, W_XDATA, 0x04); } return (0); case CARD_INIT: initW6692(cs, 3); return (0); case CARD_TEST: return (0); } return (0); } static int id_idx; static struct pci_dev *dev_w6692 = NULL; int setup_w6692(struct IsdnCard *card) { struct IsdnCardState *cs = card->cs; char tmp[64]; u_char found = 0; u_char pci_irq = 0; u_int pci_ioaddr = 0; strcpy(tmp, w6692_revision); printk(KERN_INFO "HiSax: W6692 driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_W6692) return (0); while (id_list[id_idx].vendor_id) { dev_w6692 = hisax_find_pci_device(id_list[id_idx].vendor_id, id_list[id_idx].device_id, dev_w6692); if (dev_w6692) { if (pci_enable_device(dev_w6692)) continue; cs->subtyp = id_idx; break; } id_idx++; } if (dev_w6692) { found = 1; pci_irq = dev_w6692->irq; /* I think address 0 is allways the configuration area */ /* and address 1 is the real IO space KKe 03.09.99 */ pci_ioaddr = pci_resource_start(dev_w6692, 1); /* USR ISDN PCI card TA need some special handling */ if (cs->subtyp == W6692_WINBOND) { if ((W6692_SV_USR == dev_w6692->subsystem_vendor) && (W6692_SD_USR == dev_w6692->subsystem_device)) { cs->subtyp = W6692_USR; } } } if (!found) { printk(KERN_WARNING "W6692: No PCI card found\n"); return (0); } cs->irq = pci_irq; if (!cs->irq) { printk(KERN_WARNING "W6692: No IRQ for PCI card found\n"); return (0); } if (!pci_ioaddr) { printk(KERN_WARNING "W6692: NO I/O Base Address found\n"); return (0); } cs->hw.w6692.iobase = pci_ioaddr; printk(KERN_INFO "Found: %s %s, I/O base: 0x%x, irq: %d\n", id_list[cs->subtyp].vendor_name, id_list[cs->subtyp].card_name, pci_ioaddr, pci_irq); if (!request_region(cs->hw.w6692.iobase, 256, id_list[cs->subtyp].card_name)) { printk(KERN_WARNING "HiSax: %s I/O ports %x-%x already in use\n", id_list[cs->subtyp].card_name, cs->hw.w6692.iobase, cs->hw.w6692.iobase + 255); return (0); } printk(KERN_INFO "HiSax: %s config irq:%d I/O:%x\n", id_list[cs->subtyp].card_name, cs->irq, cs->hw.w6692.iobase); INIT_WORK(&cs->tqueue, W6692_bh); cs->readW6692 = &ReadW6692; cs->writeW6692 = &WriteW6692; cs->readisacfifo = &ReadISACfifo; cs->writeisacfifo = &WriteISACfifo; cs->BC_Read_Reg = &ReadW6692B; cs->BC_Write_Reg = &WriteW6692B; cs->BC_Send_Data = &W6692B_fill_fifo; cs->cardmsg = &w6692_card_msg; cs->irq_func = &W6692_interrupt; cs->irq_flags |= IRQF_SHARED; W6692Version(cs, "W6692:"); printk(KERN_INFO "W6692 ISTA=0x%X\n", ReadW6692(cs, W_ISTA)); printk(KERN_INFO "W6692 IMASK=0x%X\n", ReadW6692(cs, W_IMASK)); printk(KERN_INFO "W6692 D_EXIR=0x%X\n", ReadW6692(cs, W_D_EXIR)); printk(KERN_INFO "W6692 D_EXIM=0x%X\n", ReadW6692(cs, W_D_EXIM)); printk(KERN_INFO "W6692 D_RSTA=0x%X\n", ReadW6692(cs, W_D_RSTA)); return (1); }
KaijiHakaroku/kernel_acer_picasso
drivers/isdn/hisax/w6692.c
C
gpl-2.0
29,382
/* * Copyright (c) 2010 Cisco Systems, Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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., * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ /* XXX TBD some includes may be extraneous */ #include <linux/module.h> #include <linux/moduleparam.h> #include <generated/utsrelease.h> #include <linux/utsname.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/kthread.h> #include <linux/types.h> #include <linux/string.h> #include <linux/configfs.h> #include <linux/ctype.h> #include <linux/hash.h> #include <asm/unaligned.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h> #include <scsi/scsi_device.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_tcq.h> #include <scsi/libfc.h> #include <scsi/fc_encode.h> #include <target/target_core_base.h> #include <target/target_core_fabric.h> #include <target/target_core_configfs.h> #include <target/configfs_macros.h> #include "tcm_fc.h" /* * Dump cmd state for debugging. */ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) { struct fc_exch *ep; struct fc_seq *sp; struct se_cmd *se_cmd; struct scatterlist *sg; int count; se_cmd = &cmd->se_cmd; pr_debug("%s: cmd %p sess %p seq %p se_cmd %p\n", caller, cmd, cmd->sess, cmd->seq, se_cmd); pr_debug("%s: cmd %p data_nents %u len %u se_cmd_flags <0x%x>\n", caller, cmd, se_cmd->t_data_nents, se_cmd->data_length, se_cmd->se_cmd_flags); for_each_sg(se_cmd->t_data_sg, sg, se_cmd->t_data_nents, count) pr_debug("%s: cmd %p sg %p page %p " "len 0x%x off 0x%x\n", caller, cmd, sg, sg_page(sg), sg->length, sg->offset); sp = cmd->seq; if (sp) { ep = fc_seq_exch(sp); pr_debug("%s: cmd %p sid %x did %x " "ox_id %x rx_id %x seq_id %x e_stat %x\n", caller, cmd, ep->sid, ep->did, ep->oxid, ep->rxid, sp->id, ep->esb_stat); } } static void ft_free_cmd(struct ft_cmd *cmd) { struct fc_frame *fp; struct fc_lport *lport; if (!cmd) return; fp = cmd->req_frame; lport = fr_dev(fp); if (fr_seq(fp)) lport->tt.seq_release(fr_seq(fp)); fc_frame_free(fp); ft_sess_put(cmd->sess); /* undo get from lookup at recv */ kfree(cmd); } void ft_release_cmd(struct se_cmd *se_cmd) { struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); ft_free_cmd(cmd); } int ft_check_stop_free(struct se_cmd *se_cmd) { transport_generic_free_cmd(se_cmd, 0); return 1; } /* * Send response. */ int ft_queue_status(struct se_cmd *se_cmd) { struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); struct fc_frame *fp; struct fcp_resp_with_ext *fcp; struct fc_lport *lport; struct fc_exch *ep; size_t len; if (cmd->aborted) return 0; ft_dump_cmd(cmd, __func__); ep = fc_seq_exch(cmd->seq); lport = ep->lp; len = sizeof(*fcp) + se_cmd->scsi_sense_length; fp = fc_frame_alloc(lport, len); if (!fp) { /* XXX shouldn't just drop it - requeue and retry? */ return 0; } fcp = fc_frame_payload_get(fp, len); memset(fcp, 0, len); fcp->resp.fr_status = se_cmd->scsi_status; len = se_cmd->scsi_sense_length; if (len) { fcp->resp.fr_flags |= FCP_SNS_LEN_VAL; fcp->ext.fr_sns_len = htonl(len); memcpy((fcp + 1), se_cmd->sense_buffer, len); } /* * Test underflow and overflow with one mask. Usually both are off. * Bidirectional commands are not handled yet. */ if (se_cmd->se_cmd_flags & (SCF_OVERFLOW_BIT | SCF_UNDERFLOW_BIT)) { if (se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) fcp->resp.fr_flags |= FCP_RESID_OVER; else fcp->resp.fr_flags |= FCP_RESID_UNDER; fcp->ext.fr_resid = cpu_to_be32(se_cmd->residual_count); } /* * Send response. */ cmd->seq = lport->tt.seq_start_next(cmd->seq); fc_fill_fc_hdr(fp, FC_RCTL_DD_CMD_STATUS, ep->did, ep->sid, FC_TYPE_FCP, FC_FC_EX_CTX | FC_FC_LAST_SEQ | FC_FC_END_SEQ, 0); lport->tt.seq_send(lport, cmd->seq, fp); lport->tt.exch_done(cmd->seq); return 0; } int ft_write_pending_status(struct se_cmd *se_cmd) { struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); return cmd->write_data_len != se_cmd->data_length; } /* * Send TX_RDY (transfer ready). */ int ft_write_pending(struct se_cmd *se_cmd) { struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); struct fc_frame *fp; struct fcp_txrdy *txrdy; struct fc_lport *lport; struct fc_exch *ep; struct fc_frame_header *fh; u32 f_ctl; ft_dump_cmd(cmd, __func__); if (cmd->aborted) return 0; ep = fc_seq_exch(cmd->seq); lport = ep->lp; fp = fc_frame_alloc(lport, sizeof(*txrdy)); if (!fp) return -ENOMEM; /* Signal QUEUE_FULL */ txrdy = fc_frame_payload_get(fp, sizeof(*txrdy)); memset(txrdy, 0, sizeof(*txrdy)); txrdy->ft_burst_len = htonl(se_cmd->data_length); cmd->seq = lport->tt.seq_start_next(cmd->seq); fc_fill_fc_hdr(fp, FC_RCTL_DD_DATA_DESC, ep->did, ep->sid, FC_TYPE_FCP, FC_FC_EX_CTX | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); fh = fc_frame_header_get(fp); f_ctl = ntoh24(fh->fh_f_ctl); /* Only if it is 'Exchange Responder' */ if (f_ctl & FC_FC_EX_CTX) { /* Target is 'exchange responder' and sending XFER_READY * to 'exchange initiator (initiator)' */ if ((ep->xid <= lport->lro_xid) && (fh->fh_r_ctl == FC_RCTL_DD_DATA_DESC)) { if (se_cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) { /* * cmd may have been broken up into multiple * tasks. Link their sgs together so we can * operate on them all at once. */ transport_do_task_sg_chain(se_cmd); cmd->sg = se_cmd->t_tasks_sg_chained; cmd->sg_cnt = se_cmd->t_tasks_sg_chained_no; } if (cmd->sg && lport->tt.ddp_target(lport, ep->xid, cmd->sg, cmd->sg_cnt)) cmd->was_ddp_setup = 1; } } lport->tt.seq_send(lport, cmd->seq, fp); return 0; } u32 ft_get_task_tag(struct se_cmd *se_cmd) { struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); return fc_seq_exch(cmd->seq)->rxid; } int ft_get_cmd_state(struct se_cmd *se_cmd) { return 0; } /* * FC sequence response handler for follow-on sequences (data) and aborts. */ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) { struct ft_cmd *cmd = arg; struct fc_frame_header *fh; if (unlikely(IS_ERR(fp))) { /* XXX need to find cmd if queued */ cmd->seq = NULL; cmd->aborted = true; return; } fh = fc_frame_header_get(fp); switch (fh->fh_r_ctl) { case FC_RCTL_DD_SOL_DATA: /* write data */ ft_recv_write_data(cmd, fp); break; case FC_RCTL_DD_UNSOL_CTL: /* command */ case FC_RCTL_DD_SOL_CTL: /* transfer ready */ case FC_RCTL_DD_DATA_DESC: /* transfer ready */ default: pr_debug("%s: unhandled frame r_ctl %x\n", __func__, fh->fh_r_ctl); ft_invl_hw_context(cmd); fc_frame_free(fp); transport_generic_free_cmd(&cmd->se_cmd, 0); break; } } /* * Send a FCP response including SCSI status and optional FCP rsp_code. * status is SAM_STAT_GOOD (zero) iff code is valid. * This is used in error cases, such as allocation failures. */ static void ft_send_resp_status(struct fc_lport *lport, const struct fc_frame *rx_fp, u32 status, enum fcp_resp_rsp_codes code) { struct fc_frame *fp; struct fc_seq *sp; const struct fc_frame_header *fh; size_t len; struct fcp_resp_with_ext *fcp; struct fcp_resp_rsp_info *info; fh = fc_frame_header_get(rx_fp); pr_debug("FCP error response: did %x oxid %x status %x code %x\n", ntoh24(fh->fh_s_id), ntohs(fh->fh_ox_id), status, code); len = sizeof(*fcp); if (status == SAM_STAT_GOOD) len += sizeof(*info); fp = fc_frame_alloc(lport, len); if (!fp) return; fcp = fc_frame_payload_get(fp, len); memset(fcp, 0, len); fcp->resp.fr_status = status; if (status == SAM_STAT_GOOD) { fcp->ext.fr_rsp_len = htonl(sizeof(*info)); fcp->resp.fr_flags |= FCP_RSP_LEN_VAL; info = (struct fcp_resp_rsp_info *)(fcp + 1); info->rsp_code = code; } fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_DD_CMD_STATUS, 0); sp = fr_seq(fp); if (sp) { lport->tt.seq_send(lport, sp, fp); lport->tt.exch_done(sp); } else { lport->tt.frame_send(lport, fp); } } /* * Send error or task management response. */ static void ft_send_resp_code(struct ft_cmd *cmd, enum fcp_resp_rsp_codes code) { ft_send_resp_status(cmd->sess->tport->lport, cmd->req_frame, SAM_STAT_GOOD, code); } /* * Send error or task management response. * Always frees the cmd and associated state. */ static void ft_send_resp_code_and_free(struct ft_cmd *cmd, enum fcp_resp_rsp_codes code) { ft_send_resp_code(cmd, code); ft_free_cmd(cmd); } /* * Handle Task Management Request. */ static void ft_send_tm(struct ft_cmd *cmd) { struct fcp_cmnd *fcp; int rc; u8 tm_func; fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); switch (fcp->fc_tm_flags) { case FCP_TMF_LUN_RESET: tm_func = TMR_LUN_RESET; break; case FCP_TMF_TGT_RESET: tm_func = TMR_TARGET_WARM_RESET; break; case FCP_TMF_CLR_TASK_SET: tm_func = TMR_CLEAR_TASK_SET; break; case FCP_TMF_ABT_TASK_SET: tm_func = TMR_ABORT_TASK_SET; break; case FCP_TMF_CLR_ACA: tm_func = TMR_CLEAR_ACA; break; default: /* * FCP4r01 indicates having a combination of * tm_flags set is invalid. */ pr_debug("invalid FCP tm_flags %x\n", fcp->fc_tm_flags); ft_send_resp_code_and_free(cmd, FCP_CMND_FIELDS_INVALID); return; } /* FIXME: Add referenced task tag for ABORT_TASK */ rc = target_submit_tmr(&cmd->se_cmd, cmd->sess->se_sess, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), cmd, tm_func, GFP_KERNEL, 0, 0); if (rc < 0) ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); } /* * Send status from completed task management request. */ int ft_queue_tm_resp(struct se_cmd *se_cmd) { struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); struct se_tmr_req *tmr = se_cmd->se_tmr_req; enum fcp_resp_rsp_codes code; if (cmd->aborted) return 0; switch (tmr->response) { case TMR_FUNCTION_COMPLETE: code = FCP_TMF_CMPL; break; case TMR_LUN_DOES_NOT_EXIST: code = FCP_TMF_INVALID_LUN; break; case TMR_FUNCTION_REJECTED: code = FCP_TMF_REJECTED; break; case TMR_TASK_DOES_NOT_EXIST: case TMR_TASK_STILL_ALLEGIANT: case TMR_TASK_FAILOVER_NOT_SUPPORTED: case TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED: case TMR_FUNCTION_AUTHORIZATION_FAILED: default: code = FCP_TMF_FAILED; break; } pr_debug("tmr fn %d resp %d fcp code %d\n", tmr->function, tmr->response, code); ft_send_resp_code(cmd, code); return 0; } static void ft_send_work(struct work_struct *work); /* * Handle incoming FCP command. */ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp) { struct ft_cmd *cmd; struct fc_lport *lport = sess->tport->lport; cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC); if (!cmd) goto busy; cmd->sess = sess; cmd->seq = lport->tt.seq_assign(lport, fp); if (!cmd->seq) { kfree(cmd); goto busy; } cmd->req_frame = fp; /* hold frame during cmd */ INIT_WORK(&cmd->work, ft_send_work); queue_work(sess->tport->tpg->workqueue, &cmd->work); return; busy: pr_debug("cmd or seq allocation failure - sending BUSY\n"); ft_send_resp_status(lport, fp, SAM_STAT_BUSY, 0); fc_frame_free(fp); ft_sess_put(sess); /* undo get from lookup */ } /* * Handle incoming FCP frame. * Caller has verified that the frame is type FCP. */ void ft_recv_req(struct ft_sess *sess, struct fc_frame *fp) { struct fc_frame_header *fh = fc_frame_header_get(fp); switch (fh->fh_r_ctl) { case FC_RCTL_DD_UNSOL_CMD: /* command */ ft_recv_cmd(sess, fp); break; case FC_RCTL_DD_SOL_DATA: /* write data */ case FC_RCTL_DD_UNSOL_CTL: case FC_RCTL_DD_SOL_CTL: case FC_RCTL_DD_DATA_DESC: /* transfer ready */ case FC_RCTL_ELS4_REQ: /* SRR, perhaps */ default: pr_debug("%s: unhandled frame r_ctl %x\n", __func__, fh->fh_r_ctl); fc_frame_free(fp); ft_sess_put(sess); /* undo get from lookup */ break; } } /* * Send new command to target. */ static void ft_send_work(struct work_struct *work) { struct ft_cmd *cmd = container_of(work, struct ft_cmd, work); struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); struct fcp_cmnd *fcp; int data_dir = 0; int task_attr; fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); if (!fcp) goto err; if (fcp->fc_flags & FCP_CFL_LEN_MASK) goto err; /* not handling longer CDBs yet */ /* * Check for FCP task management flags */ if (fcp->fc_tm_flags) { ft_send_tm(cmd); return; } switch (fcp->fc_flags & (FCP_CFL_RDDATA | FCP_CFL_WRDATA)) { case 0: data_dir = DMA_NONE; break; case FCP_CFL_RDDATA: data_dir = DMA_FROM_DEVICE; break; case FCP_CFL_WRDATA: data_dir = DMA_TO_DEVICE; break; case FCP_CFL_WRDATA | FCP_CFL_RDDATA: goto err; /* TBD not supported by tcm_fc yet */ } /* * Locate the SAM Task Attr from fc_pri_ta */ switch (fcp->fc_pri_ta & FCP_PTA_MASK) { case FCP_PTA_HEADQ: task_attr = MSG_HEAD_TAG; break; case FCP_PTA_ORDERED: task_attr = MSG_ORDERED_TAG; break; case FCP_PTA_ACA: task_attr = MSG_ACA_TAG; break; case FCP_PTA_SIMPLE: /* Fallthrough */ default: task_attr = MSG_SIMPLE_TAG; } fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); /* * Use a single se_cmd->cmd_kref as we expect to release se_cmd * directly from ft_check_stop_free callback in response path. */ target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, fcp->fc_cdb, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), ntohl(fcp->fc_dl), task_attr, data_dir, 0); pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl); return; err: ft_send_resp_code_and_free(cmd, FCP_CMND_FIELDS_INVALID); }
Algesat/BladeApex2
drivers/target/tcm_fc/tfc_cmd.c
C
gpl-2.0
14,140
/* ir-jvc-decoder.c - handle JVC IR Pulse/Space protocol * * Copyright (C) 2010 by David Härdeman <david@hardeman.nu> * * 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 version 2 of the License. * * 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. */ #include <linux/bitrev.h> #include "rc-core-priv.h" #define JVC_NBITS 16 /* dev(8) + func(8) */ #define JVC_UNIT 525000 /* ns */ #define JVC_HEADER_PULSE (16 * JVC_UNIT) /* lack of header -> repeat */ #define JVC_HEADER_SPACE (8 * JVC_UNIT) #define JVC_BIT_PULSE (1 * JVC_UNIT) #define JVC_BIT_0_SPACE (1 * JVC_UNIT) #define JVC_BIT_1_SPACE (3 * JVC_UNIT) #define JVC_TRAILER_PULSE (1 * JVC_UNIT) #define JVC_TRAILER_SPACE (35 * JVC_UNIT) enum jvc_state { STATE_INACTIVE, STATE_HEADER_SPACE, STATE_BIT_PULSE, STATE_BIT_SPACE, STATE_TRAILER_PULSE, STATE_TRAILER_SPACE, STATE_CHECK_REPEAT, }; /** * ir_jvc_decode() - Decode one JVC pulse or space * @dev: the struct rc_dev descriptor of the device * @duration: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev) { struct jvc_dec *data = &dev->raw->jvc; if (!(dev->raw->enabled_protocols & RC_TYPE_JVC)) return 0; if (!is_timing_event(ev)) { if (ev.reset) data->state = STATE_INACTIVE; return 0; } if (!geq_margin(ev.duration, JVC_UNIT, JVC_UNIT / 2)) goto out; IR_dprintk(2, "JVC decode started at state %d (%uus %s)\n", data->state, TO_US(ev.duration), TO_STR(ev.pulse)); again: switch (data->state) { case STATE_INACTIVE: if (!ev.pulse) break; if (!eq_margin(ev.duration, JVC_HEADER_PULSE, JVC_UNIT / 2)) break; data->count = 0; data->first = true; data->toggle = !data->toggle; data->state = STATE_HEADER_SPACE; return 0; case STATE_HEADER_SPACE: if (ev.pulse) break; if (!eq_margin(ev.duration, JVC_HEADER_SPACE, JVC_UNIT / 2)) break; data->state = STATE_BIT_PULSE; return 0; case STATE_BIT_PULSE: if (!ev.pulse) break; if (!eq_margin(ev.duration, JVC_BIT_PULSE, JVC_UNIT / 2)) break; data->state = STATE_BIT_SPACE; return 0; case STATE_BIT_SPACE: if (ev.pulse) break; data->bits <<= 1; if (eq_margin(ev.duration, JVC_BIT_1_SPACE, JVC_UNIT / 2)) { data->bits |= 1; decrease_duration(&ev, JVC_BIT_1_SPACE); } else if (eq_margin(ev.duration, JVC_BIT_0_SPACE, JVC_UNIT / 2)) decrease_duration(&ev, JVC_BIT_0_SPACE); else break; data->count++; if (data->count == JVC_NBITS) data->state = STATE_TRAILER_PULSE; else data->state = STATE_BIT_PULSE; return 0; case STATE_TRAILER_PULSE: if (!ev.pulse) break; if (!eq_margin(ev.duration, JVC_TRAILER_PULSE, JVC_UNIT / 2)) break; data->state = STATE_TRAILER_SPACE; return 0; case STATE_TRAILER_SPACE: if (ev.pulse) break; if (!geq_margin(ev.duration, JVC_TRAILER_SPACE, JVC_UNIT / 2)) break; if (data->first) { u32 scancode; scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | (bitrev8((data->bits >> 0) & 0xff) << 0); IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); rc_keydown(dev, scancode, data->toggle); data->first = false; data->old_bits = data->bits; } else if (data->bits == data->old_bits) { IR_dprintk(1, "JVC repeat\n"); rc_repeat(dev); } else { IR_dprintk(1, "JVC invalid repeat msg\n"); break; } data->count = 0; data->state = STATE_CHECK_REPEAT; return 0; case STATE_CHECK_REPEAT: if (!ev.pulse) break; if (eq_margin(ev.duration, JVC_HEADER_PULSE, JVC_UNIT / 2)) data->state = STATE_INACTIVE; else data->state = STATE_BIT_PULSE; goto again; } out: IR_dprintk(1, "JVC decode failed at state %d (%uus %s)\n", data->state, TO_US(ev.duration), TO_STR(ev.pulse)); data->state = STATE_INACTIVE; return -EINVAL; } static struct ir_raw_handler jvc_handler = { .protocols = RC_TYPE_JVC, .decode = ir_jvc_decode, }; static int __init ir_jvc_decode_init(void) { ir_raw_handler_register(&jvc_handler); printk(KERN_INFO "IR JVC protocol handler initialized\n"); return 0; } static void __exit ir_jvc_decode_exit(void) { ir_raw_handler_unregister(&jvc_handler); } module_init(ir_jvc_decode_init); module_exit(ir_jvc_decode_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Härdeman <david@hardeman.nu>"); MODULE_DESCRIPTION("JVC IR protocol decoder");
wjb/mx-common
drivers/media/rc/ir-jvc-decoder.c
C
gpl-2.0
4,765
/* * Copyright (C) 2005, 2006 * Avishay Traeger (avishay@gmail.com) * Copyright (C) 2008, 2009 * Boaz Harrosh <bharrosh@panasas.com> * * Copyrights for code taken from ext2: * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * from * linux/fs/minix/inode.c * Copyright (C) 1991, 1992 Linus Torvalds * * This file is part of exofs. * * exofs 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. Since it is based on ext2, and the only * valid version of GPL for the Linux kernel is version 2, the only valid * version of GPL for exofs is version 2. * * exofs 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 exofs; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "exofs.h" static inline int exofs_add_nondir(struct dentry *dentry, struct inode *inode) { int err = exofs_add_link(dentry, inode); if (!err) { d_instantiate(dentry, inode); return 0; } inode_dec_link_count(inode); iput(inode); return err; } static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct inode *inode; ino_t ino; if (dentry->d_name.len > EXOFS_NAME_LEN) return ERR_PTR(-ENAMETOOLONG); ino = exofs_inode_by_name(dir, dentry); inode = ino ? exofs_iget(dir->i_sb, ino) : NULL; return d_splice_alias(inode, dentry); } static int exofs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) { struct inode *inode = exofs_new_inode(dir, mode); int err = PTR_ERR(inode); if (!IS_ERR(inode)) { inode->i_op = &exofs_file_inode_operations; inode->i_fop = &exofs_file_operations; inode->i_mapping->a_ops = &exofs_aops; mark_inode_dirty(inode); err = exofs_add_nondir(dentry, inode); } return err; } static int exofs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; int err; if (!new_valid_dev(rdev)) return -EINVAL; inode = exofs_new_inode(dir, mode); err = PTR_ERR(inode); if (!IS_ERR(inode)) { init_special_inode(inode, inode->i_mode, rdev); mark_inode_dirty(inode); err = exofs_add_nondir(dentry, inode); } return err; } static int exofs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { struct super_block *sb = dir->i_sb; int err = -ENAMETOOLONG; unsigned l = strlen(symname)+1; struct inode *inode; struct exofs_i_info *oi; if (l > sb->s_blocksize) goto out; inode = exofs_new_inode(dir, S_IFLNK | S_IRWXUGO); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out; oi = exofs_i(inode); if (l > sizeof(oi->i_data)) { /* slow symlink */ inode->i_op = &exofs_symlink_inode_operations; inode->i_mapping->a_ops = &exofs_aops; memset(oi->i_data, 0, sizeof(oi->i_data)); err = page_symlink(inode, symname, l); if (err) goto out_fail; } else { /* fast symlink */ inode->i_op = &exofs_fast_symlink_inode_operations; memcpy(oi->i_data, symname, l); inode->i_size = l-1; } mark_inode_dirty(inode); err = exofs_add_nondir(dentry, inode); out: return err; out_fail: inode_dec_link_count(inode); iput(inode); goto out; } static int exofs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { struct inode *inode = old_dentry->d_inode; inode->i_ctime = CURRENT_TIME; inode_inc_link_count(inode); ihold(inode); return exofs_add_nondir(dentry, inode); } static int exofs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; int err; inode_inc_link_count(dir); inode = exofs_new_inode(dir, S_IFDIR | mode); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out_dir; inode->i_op = &exofs_dir_inode_operations; inode->i_fop = &exofs_dir_operations; inode->i_mapping->a_ops = &exofs_aops; inode_inc_link_count(inode); err = exofs_make_empty(inode, dir); if (err) goto out_fail; err = exofs_add_link(dentry, inode); if (err) goto out_fail; d_instantiate(dentry, inode); out: return err; out_fail: inode_dec_link_count(inode); inode_dec_link_count(inode); iput(inode); out_dir: inode_dec_link_count(dir); goto out; } static int exofs_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; struct exofs_dir_entry *de; struct page *page; int err = -ENOENT; de = exofs_find_entry(dir, dentry, &page); if (!de) goto out; err = exofs_delete_entry(de, page); if (err) goto out; inode->i_ctime = dir->i_ctime; inode_dec_link_count(inode); err = 0; out: return err; } static int exofs_rmdir(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; int err = -ENOTEMPTY; if (exofs_empty_dir(inode)) { err = exofs_unlink(dir, dentry); if (!err) { inode->i_size = 0; inode_dec_link_count(inode); inode_dec_link_count(dir); } } return err; } static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) { struct inode *old_inode = old_dentry->d_inode; struct inode *new_inode = new_dentry->d_inode; struct page *dir_page = NULL; struct exofs_dir_entry *dir_de = NULL; struct page *old_page; struct exofs_dir_entry *old_de; int err = -ENOENT; old_de = exofs_find_entry(old_dir, old_dentry, &old_page); if (!old_de) goto out; if (S_ISDIR(old_inode->i_mode)) { err = -EIO; dir_de = exofs_dotdot(old_inode, &dir_page); if (!dir_de) goto out_old; } if (new_inode) { struct page *new_page; struct exofs_dir_entry *new_de; err = -ENOTEMPTY; if (dir_de && !exofs_empty_dir(new_inode)) goto out_dir; err = -ENOENT; new_de = exofs_find_entry(new_dir, new_dentry, &new_page); if (!new_de) goto out_dir; err = exofs_set_link(new_dir, new_de, new_page, old_inode); new_inode->i_ctime = CURRENT_TIME; if (dir_de) drop_nlink(new_inode); inode_dec_link_count(new_inode); if (err) goto out_dir; } else { err = exofs_add_link(new_dentry, old_inode); if (err) goto out_dir; if (dir_de) inode_inc_link_count(new_dir); } old_inode->i_ctime = CURRENT_TIME; exofs_delete_entry(old_de, old_page); mark_inode_dirty(old_inode); if (dir_de) { err = exofs_set_link(old_inode, dir_de, dir_page, new_dir); inode_dec_link_count(old_dir); if (err) goto out_dir; } return 0; out_dir: if (dir_de) { kunmap(dir_page); page_cache_release(dir_page); } out_old: kunmap(old_page); page_cache_release(old_page); out: return err; } const struct inode_operations exofs_dir_inode_operations = { .create = exofs_create, .lookup = exofs_lookup, .link = exofs_link, .unlink = exofs_unlink, .symlink = exofs_symlink, .mkdir = exofs_mkdir, .rmdir = exofs_rmdir, .mknod = exofs_mknod, .rename = exofs_rename, .setattr = exofs_setattr, }; const struct inode_operations exofs_special_inode_operations = { .setattr = exofs_setattr, };
Alucard24/Dorimanx-SG2-I9100-Kernel
fs/exofs/namei.c
C
gpl-2.0
7,398
/* * Copyright (C) 2005, 2006 * Avishay Traeger (avishay@gmail.com) * Copyright (C) 2008, 2009 * Boaz Harrosh <bharrosh@panasas.com> * * Copyrights for code taken from ext2: * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * from * linux/fs/minix/inode.c * Copyright (C) 1991, 1992 Linus Torvalds * * This file is part of exofs. * * exofs 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. Since it is based on ext2, and the only * valid version of GPL for the Linux kernel is version 2, the only valid * version of GPL for exofs is version 2. * * exofs 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 exofs; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "exofs.h" static inline int exofs_add_nondir(struct dentry *dentry, struct inode *inode) { int err = exofs_add_link(dentry, inode); if (!err) { d_instantiate(dentry, inode); return 0; } inode_dec_link_count(inode); iput(inode); return err; } static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct inode *inode; ino_t ino; if (dentry->d_name.len > EXOFS_NAME_LEN) return ERR_PTR(-ENAMETOOLONG); ino = exofs_inode_by_name(dir, dentry); inode = ino ? exofs_iget(dir->i_sb, ino) : NULL; return d_splice_alias(inode, dentry); } static int exofs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) { struct inode *inode = exofs_new_inode(dir, mode); int err = PTR_ERR(inode); if (!IS_ERR(inode)) { inode->i_op = &exofs_file_inode_operations; inode->i_fop = &exofs_file_operations; inode->i_mapping->a_ops = &exofs_aops; mark_inode_dirty(inode); err = exofs_add_nondir(dentry, inode); } return err; } static int exofs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; int err; if (!new_valid_dev(rdev)) return -EINVAL; inode = exofs_new_inode(dir, mode); err = PTR_ERR(inode); if (!IS_ERR(inode)) { init_special_inode(inode, inode->i_mode, rdev); mark_inode_dirty(inode); err = exofs_add_nondir(dentry, inode); } return err; } static int exofs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { struct super_block *sb = dir->i_sb; int err = -ENAMETOOLONG; unsigned l = strlen(symname)+1; struct inode *inode; struct exofs_i_info *oi; if (l > sb->s_blocksize) goto out; inode = exofs_new_inode(dir, S_IFLNK | S_IRWXUGO); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out; oi = exofs_i(inode); if (l > sizeof(oi->i_data)) { /* slow symlink */ inode->i_op = &exofs_symlink_inode_operations; inode->i_mapping->a_ops = &exofs_aops; memset(oi->i_data, 0, sizeof(oi->i_data)); err = page_symlink(inode, symname, l); if (err) goto out_fail; } else { /* fast symlink */ inode->i_op = &exofs_fast_symlink_inode_operations; memcpy(oi->i_data, symname, l); inode->i_size = l-1; } mark_inode_dirty(inode); err = exofs_add_nondir(dentry, inode); out: return err; out_fail: inode_dec_link_count(inode); iput(inode); goto out; } static int exofs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { struct inode *inode = old_dentry->d_inode; inode->i_ctime = CURRENT_TIME; inode_inc_link_count(inode); ihold(inode); return exofs_add_nondir(dentry, inode); } static int exofs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; int err; inode_inc_link_count(dir); inode = exofs_new_inode(dir, S_IFDIR | mode); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out_dir; inode->i_op = &exofs_dir_inode_operations; inode->i_fop = &exofs_dir_operations; inode->i_mapping->a_ops = &exofs_aops; inode_inc_link_count(inode); err = exofs_make_empty(inode, dir); if (err) goto out_fail; err = exofs_add_link(dentry, inode); if (err) goto out_fail; d_instantiate(dentry, inode); out: return err; out_fail: inode_dec_link_count(inode); inode_dec_link_count(inode); iput(inode); out_dir: inode_dec_link_count(dir); goto out; } static int exofs_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; struct exofs_dir_entry *de; struct page *page; int err = -ENOENT; de = exofs_find_entry(dir, dentry, &page); if (!de) goto out; err = exofs_delete_entry(de, page); if (err) goto out; inode->i_ctime = dir->i_ctime; inode_dec_link_count(inode); err = 0; out: return err; } static int exofs_rmdir(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; int err = -ENOTEMPTY; if (exofs_empty_dir(inode)) { err = exofs_unlink(dir, dentry); if (!err) { inode->i_size = 0; inode_dec_link_count(inode); inode_dec_link_count(dir); } } return err; } static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) { struct inode *old_inode = old_dentry->d_inode; struct inode *new_inode = new_dentry->d_inode; struct page *dir_page = NULL; struct exofs_dir_entry *dir_de = NULL; struct page *old_page; struct exofs_dir_entry *old_de; int err = -ENOENT; old_de = exofs_find_entry(old_dir, old_dentry, &old_page); if (!old_de) goto out; if (S_ISDIR(old_inode->i_mode)) { err = -EIO; dir_de = exofs_dotdot(old_inode, &dir_page); if (!dir_de) goto out_old; } if (new_inode) { struct page *new_page; struct exofs_dir_entry *new_de; err = -ENOTEMPTY; if (dir_de && !exofs_empty_dir(new_inode)) goto out_dir; err = -ENOENT; new_de = exofs_find_entry(new_dir, new_dentry, &new_page); if (!new_de) goto out_dir; err = exofs_set_link(new_dir, new_de, new_page, old_inode); new_inode->i_ctime = CURRENT_TIME; if (dir_de) drop_nlink(new_inode); inode_dec_link_count(new_inode); if (err) goto out_dir; } else { err = exofs_add_link(new_dentry, old_inode); if (err) goto out_dir; if (dir_de) inode_inc_link_count(new_dir); } old_inode->i_ctime = CURRENT_TIME; exofs_delete_entry(old_de, old_page); mark_inode_dirty(old_inode); if (dir_de) { err = exofs_set_link(old_inode, dir_de, dir_page, new_dir); inode_dec_link_count(old_dir); if (err) goto out_dir; } return 0; out_dir: if (dir_de) { kunmap(dir_page); page_cache_release(dir_page); } out_old: kunmap(old_page); page_cache_release(old_page); out: return err; } const struct inode_operations exofs_dir_inode_operations = { .create = exofs_create, .lookup = exofs_lookup, .link = exofs_link, .unlink = exofs_unlink, .symlink = exofs_symlink, .mkdir = exofs_mkdir, .rmdir = exofs_rmdir, .mknod = exofs_mknod, .rename = exofs_rename, .setattr = exofs_setattr, }; const struct inode_operations exofs_special_inode_operations = { .setattr = exofs_setattr, };
KimLemon/AKL-Kernel
fs/exofs/namei.c
C
gpl-2.0
7,398
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2004, 2005 Ralf Baechle * Copyright (C) 2005 MIPS Technologies, Inc. */ #include <linux/compiler.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/oprofile.h> #include <linux/smp.h> #include <asm/cpu-info.h> #include "op_impl.h" extern struct op_mips_model op_model_mipsxx_ops __weak; extern struct op_mips_model op_model_rm9000_ops __weak; extern struct op_mips_model op_model_loongson2_ops __weak; static struct op_mips_model *model; static struct op_counter_config ctr[20]; static int op_mips_setup(void) { /* Pre-compute the values to stuff in the hardware registers. */ model->reg_setup(ctr); /* Configure the registers on all cpus. */ on_each_cpu(model->cpu_setup, NULL, 1); return 0; } static int op_mips_create_files(struct super_block *sb, struct dentry *root) { int i; for (i = 0; i < model->num_counters; ++i) { struct dentry *dir; char buf[4]; snprintf(buf, sizeof buf, "%d", i); dir = oprofilefs_mkdir(sb, root, buf); oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled); oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event); oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count); oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel); oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user); oprofilefs_create_ulong(sb, dir, "exl", &ctr[i].exl); /* Dummy. */ oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask); } return 0; } static int op_mips_start(void) { on_each_cpu(model->cpu_start, NULL, 1); return 0; } static void op_mips_stop(void) { /* Disable performance monitoring for all counters. */ on_each_cpu(model->cpu_stop, NULL, 1); } int __init oprofile_arch_init(struct oprofile_operations *ops) { struct op_mips_model *lmodel = NULL; int res; switch (current_cpu_type()) { case CPU_5KC: case CPU_20KC: case CPU_24K: case CPU_25KF: case CPU_34K: case CPU_1004K: case CPU_74K: case CPU_SB1: case CPU_SB1A: case CPU_R10000: case CPU_R12000: case CPU_R14000: lmodel = &op_model_mipsxx_ops; break; case CPU_RM9000: lmodel = &op_model_rm9000_ops; break; case CPU_LOONGSON2: lmodel = &op_model_loongson2_ops; break; }; if (!lmodel) return -ENODEV; res = lmodel->init(); if (res) return res; model = lmodel; ops->create_files = op_mips_create_files; ops->setup = op_mips_setup; //ops->shutdown = op_mips_shutdown; ops->start = op_mips_start; ops->stop = op_mips_stop; ops->cpu_type = lmodel->cpu_type; printk(KERN_INFO "oprofile: using %s performance monitoring.\n", lmodel->cpu_type); return 0; } void oprofile_arch_exit(void) { if (model) model->exit(); }
budi79/deka-kernel-msm7x30-3.0
arch/mips/oprofile/common.c
C
gpl-2.0
2,862
/* * Intel Wireless WiMAX Connection 2400m * SDIO RX handling * * * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * Intel Corporation <linux-wimax@intel.com> * Dirk Brandewie <dirk.j.brandewie@intel.com> * - Initial implementation * * * This handles the RX path on SDIO. * * The SDIO bus driver calls the "irq" routine when data is available. * This is not a traditional interrupt routine since the SDIO bus * driver calls us from its irq thread context. Because of this * sleeping in the SDIO RX IRQ routine is okay. * * From there on, we obtain the size of the data that is available, * allocate an skb, copy it and then pass it to the generic driver's * RX routine [i2400m_rx()]. * * ROADMAP * * i2400ms_irq() * i2400ms_rx() * __i2400ms_rx_get_size() * i2400m_is_boot_barker() * i2400m_rx() * * i2400ms_rx_setup() * * i2400ms_rx_release() */ #include <linux/workqueue.h> #include <linux/wait.h> #include <linux/skbuff.h> #include <linux/mmc/sdio.h> #include <linux/mmc/sdio_func.h> #include <linux/slab.h> #include "i2400m-sdio.h" #define D_SUBMODULE rx #include "sdio-debug-levels.h" static const __le32 i2400m_ACK_BARKER[4] = { __constant_cpu_to_le32(I2400M_ACK_BARKER), __constant_cpu_to_le32(I2400M_ACK_BARKER), __constant_cpu_to_le32(I2400M_ACK_BARKER), __constant_cpu_to_le32(I2400M_ACK_BARKER) }; /* * Read and return the amount of bytes available for RX * * The RX size has to be read like this: byte reads of three * sequential locations; then glue'em together. * * sdio_readl() doesn't work. */ static ssize_t __i2400ms_rx_get_size(struct i2400ms *i2400ms) { int ret, cnt, val; ssize_t rx_size; unsigned xfer_size_addr; struct sdio_func *func = i2400ms->func; struct device *dev = &i2400ms->func->dev; d_fnstart(7, dev, "(i2400ms %p)\n", i2400ms); xfer_size_addr = I2400MS_INTR_GET_SIZE_ADDR; rx_size = 0; for (cnt = 0; cnt < 3; cnt++) { val = sdio_readb(func, xfer_size_addr + cnt, &ret); if (ret < 0) { dev_err(dev, "RX: Can't read byte %d of RX size from " "0x%08x: %d\n", cnt, xfer_size_addr + cnt, ret); rx_size = ret; goto error_read; } rx_size = rx_size << 8 | (val & 0xff); } d_printf(6, dev, "RX: rx_size is %ld\n", (long) rx_size); error_read: d_fnend(7, dev, "(i2400ms %p) = %ld\n", i2400ms, (long) rx_size); return rx_size; } /* * Read data from the device (when in normal) * * Allocate an SKB of the right size, read the data in and then * deliver it to the generic layer. * * We also check for a reboot barker. That means the device died and * we have to reboot it. */ static void i2400ms_rx(struct i2400ms *i2400ms) { int ret; struct sdio_func *func = i2400ms->func; struct device *dev = &func->dev; struct i2400m *i2400m = &i2400ms->i2400m; struct sk_buff *skb; ssize_t rx_size; d_fnstart(7, dev, "(i2400ms %p)\n", i2400ms); rx_size = __i2400ms_rx_get_size(i2400ms); if (rx_size < 0) { ret = rx_size; goto error_get_size; } /* * Hardware quirk: make sure to clear the INTR status register * AFTER getting the data transfer size. */ sdio_writeb(func, 1, I2400MS_INTR_CLEAR_ADDR, &ret); ret = -ENOMEM; skb = alloc_skb(rx_size, GFP_ATOMIC); if (NULL == skb) { dev_err(dev, "RX: unable to alloc skb\n"); goto error_alloc_skb; } ret = sdio_memcpy_fromio(func, skb->data, I2400MS_DATA_ADDR, rx_size); if (ret < 0) { dev_err(dev, "RX: SDIO data read failed: %d\n", ret); goto error_memcpy_fromio; } rmb(); /* make sure we get boot_mode from dev_reset_handle */ if (unlikely(i2400m->boot_mode == 1)) { spin_lock(&i2400m->rx_lock); i2400ms->bm_ack_size = rx_size; spin_unlock(&i2400m->rx_lock); memcpy(i2400m->bm_ack_buf, skb->data, rx_size); wake_up(&i2400ms->bm_wfa_wq); d_printf(5, dev, "RX: SDIO boot mode message\n"); kfree_skb(skb); goto out; } ret = -EIO; if (unlikely(rx_size < sizeof(__le32))) { dev_err(dev, "HW BUG? only %zu bytes received\n", rx_size); goto error_bad_size; } if (likely(i2400m_is_d2h_barker(skb->data))) { skb_put(skb, rx_size); i2400m_rx(i2400m, skb); } else if (unlikely(i2400m_is_boot_barker(i2400m, skb->data, rx_size))) { ret = i2400m_dev_reset_handle(i2400m, "device rebooted"); dev_err(dev, "RX: SDIO reboot barker\n"); kfree_skb(skb); } else { i2400m_unknown_barker(i2400m, skb->data, rx_size); kfree_skb(skb); } out: d_fnend(7, dev, "(i2400ms %p) = void\n", i2400ms); return; error_memcpy_fromio: kfree_skb(skb); error_alloc_skb: error_get_size: error_bad_size: d_fnend(7, dev, "(i2400ms %p) = %d\n", i2400ms, ret); } /* * Process an interrupt from the SDIO card * * FIXME: need to process other events that are not just ready-to-read * * Checks there is data ready and then proceeds to read it. */ static void i2400ms_irq(struct sdio_func *func) { int ret; struct i2400ms *i2400ms = sdio_get_drvdata(func); struct device *dev = &func->dev; int val; d_fnstart(6, dev, "(i2400ms %p)\n", i2400ms); val = sdio_readb(func, I2400MS_INTR_STATUS_ADDR, &ret); if (ret < 0) { dev_err(dev, "RX: Can't read interrupt status: %d\n", ret); goto error_no_irq; } if (!val) { dev_err(dev, "RX: BUG? got IRQ but no interrupt ready?\n"); goto error_no_irq; } i2400ms_rx(i2400ms); error_no_irq: d_fnend(6, dev, "(i2400ms %p) = void\n", i2400ms); } /* * Setup SDIO RX * * Hooks up the IRQ handler and then enables IRQs. */ int i2400ms_rx_setup(struct i2400ms *i2400ms) { int result; struct sdio_func *func = i2400ms->func; struct device *dev = &func->dev; struct i2400m *i2400m = &i2400ms->i2400m; d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms); init_waitqueue_head(&i2400ms->bm_wfa_wq); spin_lock(&i2400m->rx_lock); i2400ms->bm_wait_result = -EINPROGRESS; /* * Before we are about to enable the RX interrupt, make sure * bm_ack_size is cleared to -EINPROGRESS which indicates * no RX interrupt happened yet or the previous interrupt * has been handled, we are ready to take the new interrupt */ i2400ms->bm_ack_size = -EINPROGRESS; spin_unlock(&i2400m->rx_lock); sdio_claim_host(func); result = sdio_claim_irq(func, i2400ms_irq); if (result < 0) { dev_err(dev, "Cannot claim IRQ: %d\n", result); goto error_irq_claim; } result = 0; sdio_writeb(func, 1, I2400MS_INTR_ENABLE_ADDR, &result); if (result < 0) { sdio_release_irq(func); dev_err(dev, "Failed to enable interrupts %d\n", result); } error_irq_claim: sdio_release_host(func); d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result); return result; } /* * Tear down SDIO RX * * Disables IRQs in the device and removes the IRQ handler. */ void i2400ms_rx_release(struct i2400ms *i2400ms) { int result; struct sdio_func *func = i2400ms->func; struct device *dev = &func->dev; struct i2400m *i2400m = &i2400ms->i2400m; d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms); spin_lock(&i2400m->rx_lock); i2400ms->bm_ack_size = -EINTR; spin_unlock(&i2400m->rx_lock); wake_up_all(&i2400ms->bm_wfa_wq); sdio_claim_host(func); sdio_writeb(func, 0, I2400MS_INTR_ENABLE_ADDR, &result); sdio_release_irq(func); sdio_release_host(func); d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result); }
CyanideL/android_kernel_lge_g3
drivers/net/wimax/i2400m/sdio-rx.c
C
gpl-2.0
8,727
<?php /** * @file * Hooks provided by the Options module. */ /** * Returns the list of options to be displayed for a field. * * Field types willing to enable one or several of the widgets defined in * options.module (select, radios/checkboxes, on/off checkbox) need to * implement this hook to specify the list of options to display in the * widgets. * * @param $field * The field definition. * @param $instance * (optional) The instance definition. The hook might be called without an * $instance parameter in contexts where no specific instance can be targeted. * It is recommended to only use instance level properties to filter out * values from a list defined by field level properties. * @param $entity_type * The entity type the field is attached to. * @param $entity * The entity object the field is attached to, or NULL if no entity * exists (e.g. in field settings page). * * @return * The array of options for the field. Array keys are the values to be * stored, and should be of the data type (string, number...) expected by * the first 'column' for the field type. Array values are the labels to * display within the widgets. The labels should NOT be sanitized, * options.module takes care of sanitation according to the needs of each * widget. The HTML tags defined in _field_filter_xss_allowed_tags() are * allowed, other tags will be filtered. */ function hook_options_list($field, $instance, $entity_type, $entity) { // Sample structure. $options = array( 0 => t('Zero'), 1 => t('One'), 2 => t('Two'), 3 => t('Three'), ); // Sample structure with groups. Only one level of nesting is allowed. This // is only supported by the 'options_select' widget. Other widgets will // flatten the array. $options = array( t('First group') => array( 0 => t('Zero'), ), t('Second group') => array( 1 => t('One'), 2 => t('Two'), ), 3 => t('Three'), ); // In actual implementations, the array of options will most probably depend // on properties of the field. Example from taxonomy.module: $options = array(); foreach ($field['settings']['allowed_values'] as $tree) { $terms = taxonomy_get_tree($tree['vid'], $tree['parent']); if ($terms) { foreach ($terms as $term) { $options[$term->tid] = str_repeat('-', $term->depth) . $term->name; } } } return $options; }
ravyg/drupal-commerce
modules/field/modules/options/options.api.php
PHP
gpl-2.0
2,445
/* * Carsten Langgaard, carstenl@mips.com * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. * Copyright (C) 2008 Dmitri Vorobiev * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope 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 <linux/cpu.h> #include <linux/init.h> #include <linux/sched.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/pci.h> #include <linux/screen_info.h> #include <linux/time.h> #include <asm/bootinfo.h> #include <asm/mips-boards/generic.h> #include <asm/mips-boards/prom.h> #include <asm/mips-boards/malta.h> #include <asm/mips-boards/maltaint.h> #include <asm/dma.h> #include <asm/traps.h> #ifdef CONFIG_VT #include <linux/console.h> #endif extern void malta_be_init(void); extern int malta_be_handler(struct pt_regs *regs, int is_fixup); static struct resource standard_io_resources[] = { { .name = "dma1", .start = 0x00, .end = 0x1f, .flags = IORESOURCE_BUSY }, { .name = "timer", .start = 0x40, .end = 0x5f, .flags = IORESOURCE_BUSY }, { .name = "keyboard", .start = 0x60, .end = 0x6f, .flags = IORESOURCE_BUSY }, { .name = "dma page reg", .start = 0x80, .end = 0x8f, .flags = IORESOURCE_BUSY }, { .name = "dma2", .start = 0xc0, .end = 0xdf, .flags = IORESOURCE_BUSY }, }; const char *get_system_type(void) { return "MIPS Malta"; } #if defined(CONFIG_MIPS_MT_SMTC) const char display_string[] = " SMTC LINUX ON MALTA "; #else const char display_string[] = " LINUX ON MALTA "; #endif /* CONFIG_MIPS_MT_SMTC */ #ifdef CONFIG_BLK_DEV_FD static void __init fd_activate(void) { /* * Activate Floppy Controller in the SMSC FDC37M817 Super I/O * Controller. * Done by YAMON 2.00 onwards */ /* Entering config state. */ SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG); /* Activate floppy controller. */ SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG); SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG); SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG); SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG); /* Exit config state. */ SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG); } #endif #ifdef CONFIG_BLK_DEV_IDE static void __init pci_clock_check(void) { unsigned int __iomem *jmpr_p = (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int)); int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07; static const int pciclocks[] __initdata = { 33, 20, 25, 30, 12, 16, 37, 10 }; int pciclock = pciclocks[jmpr]; char *argptr = prom_getcmdline(); if (pciclock != 33 && !strstr(argptr, "idebus=")) { printk(KERN_WARNING "WARNING: PCI clock is %dMHz, " "setting idebus\n", pciclock); argptr += strlen(argptr); sprintf(argptr, " idebus=%d", pciclock); if (pciclock < 20 || pciclock > 66) printk(KERN_WARNING "WARNING: IDE timing " "calculations will be incorrect\n"); } } #endif #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) static void __init screen_info_setup(void) { screen_info = (struct screen_info) { .orig_x = 0, .orig_y = 25, .ext_mem_k = 0, .orig_video_page = 0, .orig_video_mode = 0, .orig_video_cols = 80, .unused2 = 0, .orig_video_ega_bx = 0, .unused3 = 0, .orig_video_lines = 25, .orig_video_isVGA = VIDEO_TYPE_VGAC, .orig_video_points = 16 }; } #endif static void __init bonito_quirks_setup(void) { char *argptr; argptr = prom_getcmdline(); if (strstr(argptr, "debug")) { BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE; printk(KERN_INFO "Enabled Bonito debug mode\n"); } else BONITO_BONGENCFG &= ~BONITO_BONGENCFG_DEBUGMODE; #ifdef CONFIG_DMA_COHERENT if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) { BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN; printk(KERN_INFO "Enabled Bonito CPU coherency\n"); argptr = prom_getcmdline(); if (strstr(argptr, "iobcuncached")) { BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN; BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG & ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); printk(KERN_INFO "Disabled Bonito IOBC coherency\n"); } else { BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN; BONITO_PCIMEMBASECFG |= (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); printk(KERN_INFO "Enabled Bonito IOBC coherency\n"); } } else panic("Hardware DMA cache coherency not supported"); #endif } void __init plat_mem_setup(void) { unsigned int i; mips_pcibios_init(); /* Request I/O space for devices used on the Malta board. */ for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++) request_resource(&ioport_resource, standard_io_resources+i); /* * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge. */ enable_dma(4); #ifdef CONFIG_DMA_COHERENT if (mips_revision_sconid != MIPS_REVISION_SCON_BONITO) panic("Hardware DMA cache coherency not supported"); #endif if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO) bonito_quirks_setup(); #ifdef CONFIG_BLK_DEV_IDE pci_clock_check(); #endif #ifdef CONFIG_BLK_DEV_FD fd_activate(); #endif #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) screen_info_setup(); #endif board_be_init = malta_be_init; board_be_handler = malta_be_handler; }
ISTweak/android_kernel_sharp_msm7x30
arch/mips/mti-malta/malta-setup.c
C
gpl-2.0
5,831
/* -*- mode: c; c-basic-offset: 8 -*- */ /* NCR Quad 720 MCA SCSI Driver * * Copyright (C) 2003 by James.Bottomley@HansenPartnership.com */ #include <linux/blkdev.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/mca.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/init.h> #include <linux/delay.h> #include <asm/io.h> #include "scsi.h" #include <scsi/scsi_host.h> #include "ncr53c8xx.h" #include "NCR_Q720.h" static struct ncr_chip q720_chip __initdata = { .revision_id = 0x0f, .burst_max = 3, .offset_max = 8, .nr_divisor = 4, .features = FE_WIDE | FE_DIFF | FE_VARCLK, }; MODULE_AUTHOR("James Bottomley"); MODULE_DESCRIPTION("NCR Quad 720 SCSI Driver"); MODULE_LICENSE("GPL"); #define NCR_Q720_VERSION "0.9" /* We needs this helper because we have up to four hosts per struct device */ struct NCR_Q720_private { struct device *dev; void __iomem * mem_base; __u32 phys_mem_base; __u32 mem_size; __u8 irq; __u8 siops; __u8 irq_enable; struct Scsi_Host *hosts[4]; }; static struct scsi_host_template NCR_Q720_tpnt = { .module = THIS_MODULE, .proc_name = "NCR_Q720", }; static irqreturn_t NCR_Q720_intr(int irq, void *data) { struct NCR_Q720_private *p = (struct NCR_Q720_private *)data; __u8 sir = (readb(p->mem_base + 0x0d) & 0xf0) >> 4; __u8 siop; sir |= ~p->irq_enable; if(sir == 0xff) return IRQ_NONE; while((siop = ffz(sir)) < p->siops) { sir |= 1<<siop; ncr53c8xx_intr(irq, p->hosts[siop]); } return IRQ_HANDLED; } static int __init NCR_Q720_probe_one(struct NCR_Q720_private *p, int siop, int irq, int slot, __u32 paddr, void __iomem *vaddr) { struct ncr_device device; __u8 scsi_id; static int unit = 0; __u8 scsr1 = readb(vaddr + NCR_Q720_SCSR_OFFSET + 1); __u8 differential = readb(vaddr + NCR_Q720_SCSR_OFFSET) & 0x20; __u8 version; int error; scsi_id = scsr1 >> 4; /* enable burst length 16 (FIXME: should allow this) */ scsr1 |= 0x02; /* force a siop reset */ scsr1 |= 0x04; writeb(scsr1, vaddr + NCR_Q720_SCSR_OFFSET + 1); udelay(10); version = readb(vaddr + 0x18) >> 4; memset(&device, 0, sizeof(struct ncr_device)); /* Initialise ncr_device structure with items required by ncr_attach. */ device.chip = q720_chip; device.chip.revision_id = version; device.host_id = scsi_id; device.dev = p->dev; device.slot.base = paddr; device.slot.base_c = paddr; device.slot.base_v = vaddr; device.slot.irq = irq; device.differential = differential ? 2 : 0; printk("Q720 probe unit %d (siop%d) at 0x%lx, diff = %d, vers = %d\n", unit, siop, (unsigned long)paddr, differential, version); p->hosts[siop] = ncr_attach(&NCR_Q720_tpnt, unit++, &device); if (!p->hosts[siop]) goto fail; p->irq_enable |= (1<<siop); scsr1 = readb(vaddr + NCR_Q720_SCSR_OFFSET + 1); /* clear the disable interrupt bit */ scsr1 &= ~0x01; writeb(scsr1, vaddr + NCR_Q720_SCSR_OFFSET + 1); error = scsi_add_host(p->hosts[siop], p->dev); if (error) ncr53c8xx_release(p->hosts[siop]); else scsi_scan_host(p->hosts[siop]); return error; fail: return -ENODEV; } /* Detect a Q720 card. Note, because of the setup --- the chips are * essentially connectecd to the MCA bus independently, it is easier * to set them up as two separate host adapters, rather than one * adapter with two channels */ static int __init NCR_Q720_probe(struct device *dev) { struct NCR_Q720_private *p; static int banner = 1; struct mca_device *mca_dev = to_mca_device(dev); int slot = mca_dev->slot; int found = 0; int irq, i, siops; __u8 pos2, pos4, asr2, asr9, asr10; __u16 io_base; __u32 base_addr, mem_size; void __iomem *mem_base; p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) return -ENOMEM; pos2 = mca_device_read_pos(mca_dev, 2); /* enable device */ pos2 |= NCR_Q720_POS2_BOARD_ENABLE | NCR_Q720_POS2_INTERRUPT_ENABLE; mca_device_write_pos(mca_dev, 2, pos2); io_base = (pos2 & NCR_Q720_POS2_IO_MASK) << NCR_Q720_POS2_IO_SHIFT; if(banner) { printk(KERN_NOTICE "NCR Q720: Driver Version " NCR_Q720_VERSION "\n" "NCR Q720: Copyright (c) 2003 by James.Bottomley@HansenPartnership.com\n" "NCR Q720:\n"); banner = 0; } io_base = mca_device_transform_ioport(mca_dev, io_base); /* OK, this is phase one of the bootstrap, we now know the * I/O space base address. All the configuration registers * are mapped here (including pos) */ /* sanity check I/O mapping */ i = inb(io_base) | (inb(io_base+1)<<8); if(i != NCR_Q720_MCA_ID) { printk(KERN_ERR "NCR_Q720, adapter failed to I/O map registers correctly at 0x%x(0x%x)\n", io_base, i); kfree(p); return -ENODEV; } /* Phase II, find the ram base and memory map the board register */ pos4 = inb(io_base + 4); /* enable streaming data */ pos4 |= 0x01; outb(pos4, io_base + 4); base_addr = (pos4 & 0x7e) << 20; base_addr += (pos4 & 0x80) << 23; asr10 = inb(io_base + 0x12); base_addr += (asr10 & 0x80) << 24; base_addr += (asr10 & 0x70) << 23; /* OK, got the base addr, now we need to find the ram size, * enable and map it */ asr9 = inb(io_base + 0x11); i = (asr9 & 0xc0) >> 6; if(i == 0) mem_size = 1024; else mem_size = 1 << (19 + i); /* enable the sram mapping */ asr9 |= 0x20; /* disable the rom mapping */ asr9 &= ~0x10; outb(asr9, io_base + 0x11); if(!request_mem_region(base_addr, mem_size, "NCR_Q720")) { printk(KERN_ERR "NCR_Q720: Failed to claim memory region 0x%lx\n-0x%lx", (unsigned long)base_addr, (unsigned long)(base_addr + mem_size)); goto out_free; } if (dma_declare_coherent_memory(dev, base_addr, base_addr, mem_size, DMA_MEMORY_MAP) != DMA_MEMORY_MAP) { printk(KERN_ERR "NCR_Q720: DMA declare memory failed\n"); goto out_release_region; } /* The first 1k of the memory buffer is a memory map of the registers */ mem_base = dma_mark_declared_memory_occupied(dev, base_addr, 1024); if (IS_ERR(mem_base)) { printk("NCR_Q720 failed to reserve memory mapped region\n"); goto out_release; } /* now also enable accesses in asr 2 */ asr2 = inb(io_base + 0x0a); asr2 |= 0x01; outb(asr2, io_base + 0x0a); /* get the number of SIOPs (this should be 2 or 4) */ siops = ((asr2 & 0xe0) >> 5) + 1; /* sanity check mapping (again) */ i = readw(mem_base); if(i != NCR_Q720_MCA_ID) { printk(KERN_ERR "NCR_Q720, adapter failed to memory map registers correctly at 0x%lx(0x%x)\n", (unsigned long)base_addr, i); goto out_release; } irq = readb(mem_base + 5) & 0x0f; /* now do the bus related transforms */ irq = mca_device_transform_irq(mca_dev, irq); printk(KERN_NOTICE "NCR Q720: found in slot %d irq = %d mem base = 0x%lx siops = %d\n", slot, irq, (unsigned long)base_addr, siops); printk(KERN_NOTICE "NCR Q720: On board ram %dk\n", mem_size/1024); p->dev = dev; p->mem_base = mem_base; p->phys_mem_base = base_addr; p->mem_size = mem_size; p->irq = irq; p->siops = siops; if (request_irq(irq, NCR_Q720_intr, IRQF_SHARED, "NCR_Q720", p)) { printk(KERN_ERR "NCR_Q720: request irq %d failed\n", irq); goto out_release; } /* disable all the siop interrupts */ for(i = 0; i < siops; i++) { void __iomem *reg_scsr1 = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET + i*NCR_Q720_SIOP_SHIFT + NCR_Q720_SCSR_OFFSET + 1; __u8 scsr1 = readb(reg_scsr1); scsr1 |= 0x01; writeb(scsr1, reg_scsr1); } /* plumb in all 720 chips */ for (i = 0; i < siops; i++) { void __iomem *siop_v_base = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET + i*NCR_Q720_SIOP_SHIFT; __u32 siop_p_base = base_addr + NCR_Q720_CHIP_REGISTER_OFFSET + i*NCR_Q720_SIOP_SHIFT; __u16 port = io_base + NCR_Q720_CHIP_REGISTER_OFFSET + i*NCR_Q720_SIOP_SHIFT; int err; outb(0xff, port + 0x40); outb(0x07, port + 0x41); if ((err = NCR_Q720_probe_one(p, i, irq, slot, siop_p_base, siop_v_base)) != 0) printk("Q720: SIOP%d: probe failed, error = %d\n", i, err); else found++; } if (!found) { kfree(p); return -ENODEV; } mca_device_set_claim(mca_dev, 1); mca_device_set_name(mca_dev, "NCR_Q720"); dev_set_drvdata(dev, p); return 0; out_release: dma_release_declared_memory(dev); out_release_region: release_mem_region(base_addr, mem_size); out_free: kfree(p); return -ENODEV; } static void __exit NCR_Q720_remove_one(struct Scsi_Host *host) { scsi_remove_host(host); ncr53c8xx_release(host); } static int __exit NCR_Q720_remove(struct device *dev) { struct NCR_Q720_private *p = dev_get_drvdata(dev); int i; for (i = 0; i < p->siops; i++) if(p->hosts[i]) NCR_Q720_remove_one(p->hosts[i]); dma_release_declared_memory(dev); release_mem_region(p->phys_mem_base, p->mem_size); free_irq(p->irq, p); kfree(p); return 0; } static short NCR_Q720_id_table[] = { NCR_Q720_MCA_ID, 0 }; static struct mca_driver NCR_Q720_driver = { .id_table = NCR_Q720_id_table, .driver = { .name = "NCR_Q720", .bus = &mca_bus_type, .probe = NCR_Q720_probe, .remove = __devexit_p(NCR_Q720_remove), }, }; static int __init NCR_Q720_init(void) { int ret = ncr53c8xx_init(); if (!ret) ret = mca_register_driver(&NCR_Q720_driver); if (ret) ncr53c8xx_exit(); return ret; } static void __exit NCR_Q720_exit(void) { mca_unregister_driver(&NCR_Q720_driver); ncr53c8xx_exit(); } module_init(NCR_Q720_init); module_exit(NCR_Q720_exit);
neobuddy89/vibrant_fluid_kernel
drivers/scsi/NCR_Q720.c
C
gpl-2.0
9,384
/* * Copyright (C) 2006, 2008 Atmel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/clk.h> #include <linux/err.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/platform_device.h> #include <linux/syscore_ops.h> #include <linux/export.h> #include <asm/io.h> #include "intc.h" struct intc { void __iomem *regs; struct irq_chip chip; #ifdef CONFIG_PM unsigned long suspend_ipr; unsigned long saved_ipr[64]; #endif }; extern struct platform_device at32_intc0_device; /* * TODO: We may be able to implement mask/unmask by setting IxM flags * in the status register. */ static void intc_mask_irq(struct irq_data *d) { } static void intc_unmask_irq(struct irq_data *d) { } static struct intc intc0 = { .chip = { .name = "intc", .irq_mask = intc_mask_irq, .irq_unmask = intc_unmask_irq, }, }; /* * All interrupts go via intc at some point. */ asmlinkage void do_IRQ(int level, struct pt_regs *regs) { struct pt_regs *old_regs; unsigned int irq; unsigned long status_reg; local_irq_disable(); old_regs = set_irq_regs(regs); irq_enter(); irq = intc_readl(&intc0, INTCAUSE0 - 4 * level); generic_handle_irq(irq); /* * Clear all interrupt level masks so that we may handle * interrupts during softirq processing. If this is a nested * interrupt, interrupts must stay globally disabled until we * return. */ status_reg = sysreg_read(SR); status_reg &= ~(SYSREG_BIT(I0M) | SYSREG_BIT(I1M) | SYSREG_BIT(I2M) | SYSREG_BIT(I3M)); sysreg_write(SR, status_reg); irq_exit(); set_irq_regs(old_regs); } void __init init_IRQ(void) { extern void _evba(void); extern void irq_level0(void); struct resource *regs; struct clk *pclk; unsigned int i; u32 offset, readback; regs = platform_get_resource(&at32_intc0_device, IORESOURCE_MEM, 0); if (!regs) { printk(KERN_EMERG "intc: no mmio resource defined\n"); goto fail; } pclk = clk_get(&at32_intc0_device.dev, "pclk"); if (IS_ERR(pclk)) { printk(KERN_EMERG "intc: no clock defined\n"); goto fail; } clk_enable(pclk); intc0.regs = ioremap(regs->start, resource_size(regs)); if (!intc0.regs) { printk(KERN_EMERG "intc: failed to map registers (0x%08lx)\n", (unsigned long)regs->start); goto fail; } /* * Initialize all interrupts to level 0 (lowest priority). The * priority level may be changed by calling * irq_set_priority(). * */ offset = (unsigned long)&irq_level0 - (unsigned long)&_evba; for (i = 0; i < NR_INTERNAL_IRQS; i++) { intc_writel(&intc0, INTPR0 + 4 * i, offset); readback = intc_readl(&intc0, INTPR0 + 4 * i); if (readback == offset) irq_set_chip_and_handler(i, &intc0.chip, handle_simple_irq); } /* Unmask all interrupt levels */ sysreg_write(SR, (sysreg_read(SR) & ~(SR_I3M | SR_I2M | SR_I1M | SR_I0M))); return; fail: panic("Interrupt controller initialization failed!\n"); } #ifdef CONFIG_PM void intc_set_suspend_handler(unsigned long offset) { intc0.suspend_ipr = offset; } static int intc_suspend(void) { int i; if (unlikely(!irqs_disabled())) { pr_err("intc_suspend: called with interrupts enabled\n"); return -EINVAL; } if (unlikely(!intc0.suspend_ipr)) { pr_err("intc_suspend: suspend_ipr not initialized\n"); return -EINVAL; } for (i = 0; i < 64; i++) { intc0.saved_ipr[i] = intc_readl(&intc0, INTPR0 + 4 * i); intc_writel(&intc0, INTPR0 + 4 * i, intc0.suspend_ipr); } return 0; } static void intc_resume(void) { int i; for (i = 0; i < 64; i++) intc_writel(&intc0, INTPR0 + 4 * i, intc0.saved_ipr[i]); } #else #define intc_suspend NULL #define intc_resume NULL #endif static struct syscore_ops intc_syscore_ops = { .suspend = intc_suspend, .resume = intc_resume, }; static int __init intc_init_syscore(void) { register_syscore_ops(&intc_syscore_ops); return 0; } device_initcall(intc_init_syscore); unsigned long intc_get_pending(unsigned int group) { return intc_readl(&intc0, INTREQ0 + 4 * group); } EXPORT_SYMBOL_GPL(intc_get_pending);
Kurre/kernel_exynos_OLD
arch/avr32/mach-at32ap/intc.c
C
gpl-2.0
4,204
/* Linux driver for Philips webcam (C) 2004-2006 Luc Saillard (luc@saillard.org) NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx driver and thus may have bugs that are not present in the original version. Please send bug reports and support requests to <luc@saillard.org>. The decompression routines have been implemented by reverse-engineering the Nemosoft binary pwcx module. Caveat emptor. 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 */ /* This tables contains entries for the 730/740/750 (Kiara) camera, with 4 different qualities (no compression, low, medium, high). It lists the bandwidth requirements for said mode by its alternate interface number. An alternate of 0 means that the mode is unavailable. There are 6 * 4 * 4 entries: 6 different resolutions subqcif, qsif, qcif, sif, cif, vga 6 framerates: 5, 10, 15, 20, 25, 30 4 compression modi: none, low, medium, high When an uncompressed mode is not available, the next available compressed mode will be chosen (unless the decompressor is absent). Sometimes there are only 1 or 2 compressed modes available; in that case entries are duplicated. */ #include "pwc-kiara.h" const unsigned int Kiara_fps_vector[PWC_FPS_MAX_KIARA] = { 5, 10, 15, 20, 25, 30 }; const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] = { /* SQCIF */ { /* 5 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 10 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 15 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 20 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 25 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 30 fps */ { {0, }, {0, }, {0, }, {0, }, }, }, /* QSIF */ { /* 5 fps */ { {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}}, }, /* 10 fps */ { {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}}, {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}}, {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}}, {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}}, }, /* 15 fps */ { {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}}, {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}}, {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}}, {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}}, }, /* 20 fps */ { {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}}, {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}}, {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}}, {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}}, }, /* 25 fps */ { {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}}, {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}}, {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}}, {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}}, }, /* 30 fps */ { {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}}, {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}}, {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}}, {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}}, }, }, /* QCIF */ { /* 5 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 10 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 15 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 20 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 25 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 30 fps */ { {0, }, {0, }, {0, }, {0, }, }, }, /* SIF */ { /* 5 fps */ { {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}}, {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}}, {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}}, {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}}, }, /* 10 fps */ { {0, }, {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}}, {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}}, {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}}, }, /* 15 fps */ { {0, }, {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}}, {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}}, {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}}, }, /* 20 fps */ { {0, }, {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}}, {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}}, {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}}, }, /* 25 fps */ { {0, }, {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}}, {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}}, {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}}, }, /* 30 fps */ { {0, }, {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}}, {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}}, {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}}, }, }, /* CIF */ { /* 5 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 10 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 15 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 20 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 25 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 30 fps */ { {0, }, {0, }, {0, }, {0, }, }, }, /* VGA */ { /* 5 fps */ { {0, }, {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}}, {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}}, {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}}, }, /* 10 fps */ { {0, }, {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}}, {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}}, {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}}, }, /* 15 fps */ { {0, }, {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}}, {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}}, {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}}, }, /* 20 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 25 fps */ { {0, }, {0, }, {0, }, {0, }, }, /* 30 fps */ { {0, }, {0, }, {0, }, {0, }, }, }, }; /* * Rom table for kiara chips * * 32 roms tables (one for each resolution ?) * 2 tables per roms (one for each passes) (Y, and U&V) * 128 bytes per passes */ const unsigned int KiaraRomTable [8][2][16][8] = { { /* version 0 */ { /* version 0, passes 0 */ {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000001,0x00000001}, {0x00000000,0x00000000,0x00000009,0x00000009, 0x00000009,0x00000009,0x00000009,0x00000009}, {0x00000000,0x00000000,0x00000009,0x00000049, 0x00000049,0x00000049,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000249,0x0000024a,0x00000049}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000249,0x00000249,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00000049,0x00000249, 0x00000249,0x0000124a,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00000049,0x00000249, 0x0000124a,0x00009252,0x00001252,0x00001252}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00009252,0x00009292,0x00009292,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x00009292,0x00009292,0x00009493,0x000124db}, {0x00000000,0x00000000,0x00000249,0x0000924a, 0x00009492,0x0000a49b,0x0000a49b,0x000124db}, {0x00000000,0x00000000,0x00001249,0x00009252, 0x0000a493,0x000124db,0x000124db,0x000126dc}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x000124db,0x000126dc,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000124db,0x000136e4,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x0001b724,0x0001b92d,0x0001b925}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000136e4,0x0001b925,0x0001c96e,0x0001c92d}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 0, passes 1 */ {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000}, {0x00000000,0x00000000,0x00000001,0x00000009, 0x00000009,0x00000009,0x00000009,0x00000001}, {0x00000000,0x00000000,0x00000009,0x00000009, 0x00000049,0x00000049,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000049,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000249,0x00000249,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00000049,0x00000249, 0x00000249,0x00000249,0x0000024a,0x00001252}, {0x00000000,0x00000000,0x00000049,0x00001249, 0x0000124a,0x0000124a,0x00001252,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x00009252,0x00009252,0x00009292,0x00009493}, {0x00000000,0x00000000,0x00000249,0x0000924a, 0x00009292,0x00009292,0x00009292,0x00009493}, {0x00000000,0x00000000,0x00000249,0x00009292, 0x00009492,0x00009493,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x0000a493,0x000124db,0x000126dc,0x000126dc}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000126dc,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x00009252,0x00009493, 0x000126dc,0x000126dc,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000136e4,0x000136e4,0x0001b725,0x0001b724}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 1 */ { /* version 1, passes 0 */ {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000001}, {0x00000000,0x00000000,0x00000009,0x00000009, 0x00000009,0x00000009,0x00000009,0x00000009}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000049,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000249,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00000049,0x00000249, 0x00000249,0x00000249,0x0000024a,0x00001252}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x0000124a,0x00001252,0x00001252}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x0000124a,0x0000124a,0x00009292,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x0000124a,0x00009252,0x00009292,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x00009252,0x00009292,0x00009292,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x00009252,0x00009292,0x00009493,0x00009493}, {0x00000000,0x00000000,0x00000249,0x0000924a, 0x00009252,0x00009493,0x00009493,0x00009493}, {0x00000000,0x00000000,0x00000249,0x0000924a, 0x00009292,0x00009493,0x00009493,0x00009493}, {0x00000000,0x00000000,0x00000249,0x00009252, 0x00009492,0x00009493,0x0000a49b,0x0000a49b}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x000124db,0x000124db,0x000124db}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000126dc,0x000126dc,0x000126dc}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 1, passes 1 */ {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000}, {0x00000000,0x00000000,0x00000049,0x00000009, 0x00000049,0x00000009,0x00000001,0x00000000}, {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000049,0x00000049,0x00000000}, {0x00000000,0x00000000,0x00000249,0x00000049, 0x00000249,0x00000049,0x0000024a,0x00000001}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x00000249,0x0000024a,0x00000001}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x00000249,0x0000024a,0x00000001}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x00000249,0x0000024a,0x00000009}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x0000124a,0x0000124a,0x0000024a,0x00000009}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x0000124a,0x0000124a,0x0000024a,0x00000009}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x00009252,0x00001252,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x00009292,0x00001252,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x00009292,0x00001252,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00001252,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009292,0x00009292,0x00001252,0x0000024a}, {0x00000000,0x00000000,0x0000924a,0x0000924a, 0x00009492,0x00009493,0x00009292,0x00001252}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 2 */ { /* version 2, passes 0 */ {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000049,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x0000124a,0x00001252,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x0000124a,0x00009252,0x00009292,0x00009292}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x0000124a,0x00009292,0x00009493,0x00009493}, {0x00000000,0x00000000,0x00000249,0x00001249, 0x00009252,0x00009493,0x00009493,0x0000a49b}, {0x00000000,0x00000000,0x00000249,0x0000924a, 0x00009292,0x00009493,0x0000a49b,0x0000a49b}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009292,0x00009493,0x0000a49b,0x000124db}, {0x00000000,0x00000000,0x00001249,0x00009252, 0x00009492,0x0000a49b,0x0000a49b,0x000124db}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x000124db,0x000124db,0x000126dc}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x0000a493,0x000124db,0x000126dc,0x000126dc}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x000136e4}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000126dc,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0001249b,0x000126dc,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000124db,0x000136e4,0x000136e4,0x0001b724}, {0x00000000,0x00000000,0x00009252,0x000124db, 0x000126dc,0x0001b724,0x0001b725,0x0001b925}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 2, passes 1 */ {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000049,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x00000249,0x0000024a,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00000249, 0x0000124a,0x0000124a,0x00001252,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x0000124a,0x00009292,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00009292,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x0000a49b,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009292,0x00009493,0x0000a49b,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009292,0x00009493,0x0000a49b,0x00001252}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009492,0x0000a49b,0x0000a49b,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00009252, 0x00009492,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x0000a49b,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000124db,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x00009252,0x0000a49b, 0x0001249b,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 3 */ { /* version 3, passes 0 */ {0x00000000,0x00000000,0x00000249,0x00000249, 0x0000124a,0x0000124a,0x00009292,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009292,0x00009493,0x0000a49b,0x0000a49b}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009492,0x0000a49b,0x0000a49b,0x000124db}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x000124db,0x000126dc,0x000126dc}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x000126dc}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000126dc,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000126dc,0x000136e4,0x0001b724}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0001249b,0x000126dc,0x000136e4,0x0001b724}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000126dc,0x000136e4,0x0001b724}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000136e4,0x0001b725,0x0001b724}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000124db,0x000136e4,0x0001b725,0x0001b925}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x000136e4,0x0001b92d,0x0001b925}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d}, {0x00000000,0x00000000,0x0000a492,0x000126db, 0x000136e4,0x0001b925,0x00025bb6,0x00024b77}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 3, passes 1 */ {0x00000000,0x00000000,0x00001249,0x00000249, 0x0000124a,0x0000124a,0x00001252,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00009292,0x00001252}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009492,0x00009493,0x0000a49b,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00009252, 0x00009492,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x0000a49b,0x000126dc,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x0000a49b,0x000126dc,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x0000a49b,0x000126dc,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x000124db,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000126dc,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000124db,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x00009492,0x0000a49b, 0x000136e4,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x0000a492,0x000124db, 0x0001b724,0x0001b724,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 4 */ { /* version 4, passes 0 */ {0x00000000,0x00000000,0x00000049,0x00000049, 0x00000049,0x00000049,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00000249,0x00000049, 0x00000249,0x00000249,0x0000024a,0x00000049}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x0000124a,0x00009252,0x00001252,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00009493,0x00001252}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009292,0x00009493,0x00009493,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000124db,0x000124db,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0001249b,0x000126dc,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x00009252,0x00009493, 0x000124db,0x000136e4,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00009252,0x0000a49b, 0x000124db,0x000136e4,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x000136e4,0x000136e4,0x000136e4}, {0x00000000,0x00000000,0x00009492,0x0000a49b, 0x000126dc,0x0001b724,0x0001b725,0x0001b724}, {0x00000000,0x00000000,0x0000a492,0x000124db, 0x000136e4,0x0001b925,0x0001b92d,0x0001b925}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 4, passes 1 */ {0x00000000,0x00000000,0x00000249,0x00000049, 0x00000009,0x00000009,0x00000009,0x00000009}, {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000049,0x00000049,0x00000009,0x00000009}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x00000249,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x0000124a,0x00000049,0x00000049}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x0000124a,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009252,0x0000124a,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x00009252,0x00001252,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x00009292,0x00009292,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x00009292,0x00009292,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x00009493,0x00009493,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009493,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000124db,0x0000a49b,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000136e4,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00009252,0x000124db, 0x0001b724,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 5 */ { /* version 5, passes 0 */ {0x00000000,0x00000000,0x00000249,0x00000249, 0x00000249,0x00000249,0x00001252,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00009292,0x00001252}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009492,0x0000a49b,0x0000a49b,0x00009292}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x0000a49b,0x000124db,0x00009493}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000126dc,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000126dc,0x000136e4,0x000124db}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000126dc,0x000136e4,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x000136e4,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x0001b724,0x0001b725,0x000136e4}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000136e4,0x0001b724,0x0001b92d,0x0001b724}, {0x00000000,0x00000000,0x00009492,0x0000a49b, 0x000136e4,0x0001b724,0x0001b92d,0x0001b724}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000136e4,0x0001b925,0x0001c96e,0x0001b925}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d}, {0x00000000,0x00000000,0x0000a492,0x000126db, 0x0001c924,0x0002496d,0x00025bb6,0x00024b77}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 5, passes 1 */ {0x00000000,0x00000000,0x00001249,0x00000249, 0x00000249,0x00000249,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x0000124a,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x0000924a, 0x00009252,0x00009252,0x0000024a,0x0000024a}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x0000a49b,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x0000a49b,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x0000a49b,0x00009292,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009292,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009493,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000124db,0x00009493,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000124db,0x00009493,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000124db,0x000124db,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000126dc,0x000126dc,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000136e4,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00009292,0x000124db, 0x000136e4,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00009492,0x000126db, 0x0001b724,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 6 */ { /* version 6, passes 0 */ {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00009493,0x00009493}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x0000a493,0x0000a49b,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000124db,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x000126dc,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000126dc,0x000136e4,0x000124db}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000126dc,0x000136e4,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000126dc,0x0001b724,0x0001b725,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000136e4,0x0001b724,0x0001b92d,0x000136e4}, {0x00000000,0x00000000,0x00009492,0x0000a49b, 0x000136e4,0x0001b724,0x0001b92d,0x0001b724}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000136e4,0x0001b724,0x0001b92d,0x0001b724}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000136e4,0x0001b925,0x0001b92d,0x0001b925}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d}, {0x00000000,0x00000000,0x0000a492,0x000124db, 0x0001b724,0x0001c92d,0x0001c96e,0x0001c92d}, {0x00000000,0x00000000,0x0000a492,0x000124db, 0x0001b724,0x0001c92d,0x00024b76,0x0002496e}, {0x00000000,0x00000000,0x00012492,0x000126db, 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 6, passes 1 */ {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x0000124a,0x00001252,0x00001252}, {0x00000000,0x00000000,0x00001249,0x00009292, 0x00009492,0x00009252,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x0000a493,0x00009292,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009292,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009292,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x0000a49b,0x00009493,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000124db,0x000124db,0x00009493,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000124db,0x000124db,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000126dc,0x000124db,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000126dc,0x000126dc,0x0000a49b,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000136e4,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00009492,0x000126db, 0x000136e4,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00009492,0x000126db, 0x0001b724,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x00009492,0x000126db, 0x0001b724,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x0000a492,0x000136db, 0x0001c924,0x0001b724,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } }, { /* version 7 */ { /* version 7, passes 0 */ {0x00000000,0x00000000,0x00001249,0x00001249, 0x00009252,0x00009292,0x00009493,0x00009493}, {0x00000000,0x00000000,0x00001249,0x00009493, 0x0000a493,0x000124db,0x000126dc,0x00009493}, {0x00000000,0x00000000,0x00001249,0x0000a49b, 0x0001249b,0x000126dc,0x000126dc,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0001249b,0x000126dc,0x000136e4,0x0000a49b}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000126dc,0x000136e4,0x0001b725,0x000124db}, {0x00000000,0x00000000,0x00009292,0x0000a49b, 0x000136e4,0x0001b724,0x0001b725,0x000126dc}, {0x00000000,0x00000000,0x00009292,0x000124db, 0x000136e4,0x0001b724,0x0001b725,0x000126dc}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000136e4,0x0001b724,0x0001c96e,0x000136e4}, {0x00000000,0x00000000,0x00009492,0x000124db, 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724}, {0x00000000,0x00000000,0x0000a492,0x000124db, 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724}, {0x00000000,0x00000000,0x0000a492,0x000124db, 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925}, {0x00000000,0x00000000,0x0000a492,0x000126db, 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d}, {0x00000000,0x00000000,0x0000a492,0x000126db, 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d}, {0x00000000,0x00000000,0x0000a492,0x000126db, 0x0001b924,0x0001c92d,0x00024b76,0x0002496e}, {0x00000000,0x00000000,0x00012492,0x000136db, 0x00024924,0x00024b6d,0x0002ddb6,0x00025bbf}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} }, { /* version 7, passes 1 */ {0x00000000,0x00000000,0x00001249,0x00001249, 0x0000124a,0x0000124a,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x00009493, 0x00009492,0x00009292,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00001252,0x00001252}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009292,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x0000a493,0x0000a49b,0x00009292,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x0000a49b, 0x000126dc,0x0000a49b,0x00009493,0x00009292}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000126dc,0x000124db,0x00009493,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000124db, 0x000136e4,0x000124db,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000136db, 0x0001b724,0x000124db,0x0000a49b,0x00009493}, {0x00000000,0x00000000,0x0000924a,0x000136db, 0x0001b724,0x000126dc,0x0000a49b,0x0000a49b}, {0x00000000,0x00000000,0x00009292,0x000136db, 0x0001b724,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x00009492,0x000136db, 0x0001b724,0x000126dc,0x000124db,0x0000a49b}, {0x00000000,0x00000000,0x0000a492,0x000136db, 0x0001b724,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x0000a492,0x000136db, 0x0001b724,0x000136e4,0x000126dc,0x000124db}, {0x00000000,0x00000000,0x00012492,0x0001b6db, 0x0001c924,0x0001b724,0x000136e4,0x000126dc}, {0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000} } } };
gorbi/android_kernel_htc_endeavoru
drivers/media/video/pwc/pwc-kiara.c
C
gpl-2.0
35,376
/* * linux/arch/unicore32/mm/pgd.c * * Code specific to PKUnity SoC and UniCore ISA * * Copyright (C) 2001-2010 GUAN Xue-tao * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/mm.h> #include <linux/gfp.h> #include <linux/highmem.h> #include <asm/pgalloc.h> #include <asm/page.h> #include <asm/tlbflush.h> #include "mm.h" #define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD) /* * need to get a 4k page for level 1 */ pgd_t *get_pgd_slow(struct mm_struct *mm) { pgd_t *new_pgd, *init_pgd; pmd_t *new_pmd, *init_pmd; pte_t *new_pte, *init_pte; new_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL, 0); if (!new_pgd) goto no_pgd; memset(new_pgd, 0, FIRST_KERNEL_PGD_NR * sizeof(pgd_t)); /* * Copy over the kernel and IO PGD entries */ init_pgd = pgd_offset_k(0); memcpy(new_pgd + FIRST_KERNEL_PGD_NR, init_pgd + FIRST_KERNEL_PGD_NR, (PTRS_PER_PGD - FIRST_KERNEL_PGD_NR) * sizeof(pgd_t)); clean_dcache_area(new_pgd, PTRS_PER_PGD * sizeof(pgd_t)); if (!vectors_high()) { /* * On UniCore, first page must always be allocated since it * contains the machine vectors. */ new_pmd = pmd_alloc(mm, (pud_t *)new_pgd, 0); if (!new_pmd) goto no_pmd; new_pte = pte_alloc_map(mm, NULL, new_pmd, 0); if (!new_pte) goto no_pte; init_pmd = pmd_offset((pud_t *)init_pgd, 0); init_pte = pte_offset_map(init_pmd, 0); set_pte(new_pte, *init_pte); pte_unmap(init_pte); pte_unmap(new_pte); } return new_pgd; no_pte: pmd_free(mm, new_pmd); no_pmd: free_pages((unsigned long)new_pgd, 0); no_pgd: return NULL; } void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd) { pmd_t *pmd; pgtable_t pte; if (!pgd) return; /* pgd is always present and good */ pmd = pmd_off(pgd, 0); if (pmd_none(*pmd)) goto free; if (pmd_bad(*pmd)) { pmd_ERROR(*pmd); pmd_clear(pmd); goto free; } pte = pmd_pgtable(*pmd); pmd_clear(pmd); pte_free(mm, pte); pmd_free(mm, pmd); free: free_pages((unsigned long) pgd, 0); }
Biktorgj/Tizen_b2_Kernel
arch/unicore32/mm/pgd.c
C
gpl-2.0
2,145
#include <linux/init.h> #include <linux/io.h> #include <linux/mm.h> #include <asm/processor-cyrix.h> #include <asm/processor-flags.h> #include <asm/mtrr.h> #include <asm/msr.h> #include "mtrr.h" static void cyrix_get_arr(unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type * type) { unsigned char arr, ccr3, rcr, shift; unsigned long flags; arr = CX86_ARR_BASE + (reg << 1) + reg; /* avoid multiplication by 3 */ local_irq_save(flags); ccr3 = getCx86(CX86_CCR3); setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ ((unsigned char *)base)[3] = getCx86(arr); ((unsigned char *)base)[2] = getCx86(arr + 1); ((unsigned char *)base)[1] = getCx86(arr + 2); rcr = getCx86(CX86_RCR_BASE + reg); setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ local_irq_restore(flags); shift = ((unsigned char *) base)[1] & 0x0f; *base >>= PAGE_SHIFT; /* * Power of two, at least 4K on ARR0-ARR6, 256K on ARR7 * Note: shift==0xf means 4G, this is unsupported. */ if (shift) *size = (reg < 7 ? 0x1UL : 0x40UL) << (shift - 1); else *size = 0; /* Bit 0 is Cache Enable on ARR7, Cache Disable on ARR0-ARR6 */ if (reg < 7) { switch (rcr) { case 1: *type = MTRR_TYPE_UNCACHABLE; break; case 8: *type = MTRR_TYPE_WRBACK; break; case 9: *type = MTRR_TYPE_WRCOMB; break; case 24: default: *type = MTRR_TYPE_WRTHROUGH; break; } } else { switch (rcr) { case 0: *type = MTRR_TYPE_UNCACHABLE; break; case 8: *type = MTRR_TYPE_WRCOMB; break; case 9: *type = MTRR_TYPE_WRBACK; break; case 25: default: *type = MTRR_TYPE_WRTHROUGH; break; } } } /* * cyrix_get_free_region - get a free ARR. * * @base: the starting (base) address of the region. * @size: the size (in bytes) of the region. * * Returns: the index of the region on success, else -1 on error. */ static int cyrix_get_free_region(unsigned long base, unsigned long size, int replace_reg) { unsigned long lbase, lsize; mtrr_type ltype; int i; switch (replace_reg) { case 7: if (size < 0x40) break; case 6: case 5: case 4: return replace_reg; case 3: case 2: case 1: case 0: return replace_reg; } /* If we are to set up a region >32M then look at ARR7 immediately */ if (size > 0x2000) { cyrix_get_arr(7, &lbase, &lsize, &ltype); if (lsize == 0) return 7; /* Else try ARR0-ARR6 first */ } else { for (i = 0; i < 7; i++) { cyrix_get_arr(i, &lbase, &lsize, &ltype); if (lsize == 0) return i; } /* * ARR0-ARR6 isn't free * try ARR7 but its size must be at least 256K */ cyrix_get_arr(i, &lbase, &lsize, &ltype); if ((lsize == 0) && (size >= 0x40)) return i; } return -ENOSPC; } static u32 cr4, ccr3; static void prepare_set(void) { u32 cr0; /* Save value of CR4 and clear Page Global Enable (bit 7) */ if (cpu_has_pge) { cr4 = read_cr4(); write_cr4(cr4 & ~X86_CR4_PGE); } /* * Disable and flush caches. * Note that wbinvd flushes the TLBs as a side-effect */ cr0 = read_cr0() | X86_CR0_CD; wbinvd(); write_cr0(cr0); wbinvd(); /* Cyrix ARRs - everything else was excluded at the top */ ccr3 = getCx86(CX86_CCR3); /* Cyrix ARRs - everything else was excluded at the top */ setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); } static void post_set(void) { /* Flush caches and TLBs */ wbinvd(); /* Cyrix ARRs - everything else was excluded at the top */ setCx86(CX86_CCR3, ccr3); /* Enable caches */ write_cr0(read_cr0() & 0xbfffffff); /* Restore value of CR4 */ if (cpu_has_pge) write_cr4(cr4); } static void cyrix_set_arr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type type) { unsigned char arr, arr_type, arr_size; arr = CX86_ARR_BASE + (reg << 1) + reg; /* avoid multiplication by 3 */ /* count down from 32M (ARR0-ARR6) or from 2G (ARR7) */ if (reg >= 7) size >>= 6; size &= 0x7fff; /* make sure arr_size <= 14 */ for (arr_size = 0; size; arr_size++, size >>= 1) ; if (reg < 7) { switch (type) { case MTRR_TYPE_UNCACHABLE: arr_type = 1; break; case MTRR_TYPE_WRCOMB: arr_type = 9; break; case MTRR_TYPE_WRTHROUGH: arr_type = 24; break; default: arr_type = 8; break; } } else { switch (type) { case MTRR_TYPE_UNCACHABLE: arr_type = 0; break; case MTRR_TYPE_WRCOMB: arr_type = 8; break; case MTRR_TYPE_WRTHROUGH: arr_type = 25; break; default: arr_type = 9; break; } } prepare_set(); base <<= PAGE_SHIFT; setCx86(arr + 0, ((unsigned char *)&base)[3]); setCx86(arr + 1, ((unsigned char *)&base)[2]); setCx86(arr + 2, (((unsigned char *)&base)[1]) | arr_size); setCx86(CX86_RCR_BASE + reg, arr_type); post_set(); } typedef struct { unsigned long base; unsigned long size; mtrr_type type; } arr_state_t; static arr_state_t arr_state[8] = { {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL} }; static unsigned char ccr_state[7] = { 0, 0, 0, 0, 0, 0, 0 }; static void cyrix_set_all(void) { int i; prepare_set(); /* the CCRs are not contiguous */ for (i = 0; i < 4; i++) setCx86(CX86_CCR0 + i, ccr_state[i]); for (; i < 7; i++) setCx86(CX86_CCR4 + i, ccr_state[i]); for (i = 0; i < 8; i++) { cyrix_set_arr(i, arr_state[i].base, arr_state[i].size, arr_state[i].type); } post_set(); } static const struct mtrr_ops cyrix_mtrr_ops = { .vendor = X86_VENDOR_CYRIX, .set_all = cyrix_set_all, .set = cyrix_set_arr, .get = cyrix_get_arr, .get_free_region = cyrix_get_free_region, .validate_add_page = generic_validate_add_page, .have_wrcomb = positive_have_wrcomb, }; int __init cyrix_init_mtrr(void) { set_mtrr_ops(&cyrix_mtrr_ops); return 0; }
jakew02/android_kernel_lge_msm8992
arch/x86/kernel/cpu/mtrr/cyrix.c
C
gpl-2.0
5,820
/********************************************************************* * * Filename: act200l.c * Version: 0.8 * Description: Implementation for the ACTiSYS ACT-IR200L dongle * Status: Experimental. * Author: SHIMIZU Takuya <tshimizu@ga2.so-net.ne.jp> * Created at: Fri Aug 3 17:35:42 2001 * Modified at: Fri Aug 17 10:22:40 2001 * Modified by: SHIMIZU Takuya <tshimizu@ga2.so-net.ne.jp> * * Copyright (c) 2001 SHIMIZU Takuya, All Rights Reserved. * * 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. * ********************************************************************/ #include <linux/module.h> #include <linux/delay.h> #include <linux/init.h> #include <net/irda/irda.h> #include "sir-dev.h" static int act200l_reset(struct sir_dev *dev); static int act200l_open(struct sir_dev *dev); static int act200l_close(struct sir_dev *dev); static int act200l_change_speed(struct sir_dev *dev, unsigned speed); /* Regsiter 0: Control register #1 */ #define ACT200L_REG0 0x00 #define ACT200L_TXEN 0x01 /* Enable transmitter */ #define ACT200L_RXEN 0x02 /* Enable receiver */ /* Register 1: Control register #2 */ #define ACT200L_REG1 0x10 #define ACT200L_LODB 0x01 /* Load new baud rate count value */ #define ACT200L_WIDE 0x04 /* Expand the maximum allowable pulse */ /* Register 4: Output Power register */ #define ACT200L_REG4 0x40 #define ACT200L_OP0 0x01 /* Enable LED1C output */ #define ACT200L_OP1 0x02 /* Enable LED2C output */ #define ACT200L_BLKR 0x04 /* Register 5: Receive Mode register */ #define ACT200L_REG5 0x50 #define ACT200L_RWIDL 0x01 /* fixed 1.6us pulse mode */ /* Register 6: Receive Sensitivity register #1 */ #define ACT200L_REG6 0x60 #define ACT200L_RS0 0x01 /* receive threshold bit 0 */ #define ACT200L_RS1 0x02 /* receive threshold bit 1 */ /* Register 7: Receive Sensitivity register #2 */ #define ACT200L_REG7 0x70 #define ACT200L_ENPOS 0x04 /* Ignore the falling edge */ /* Register 8,9: Baud Rate Dvider register #1,#2 */ #define ACT200L_REG8 0x80 #define ACT200L_REG9 0x90 #define ACT200L_2400 0x5f #define ACT200L_9600 0x17 #define ACT200L_19200 0x0b #define ACT200L_38400 0x05 #define ACT200L_57600 0x03 #define ACT200L_115200 0x01 /* Register 13: Control register #3 */ #define ACT200L_REG13 0xd0 #define ACT200L_SHDW 0x01 /* Enable access to shadow registers */ /* Register 15: Status register */ #define ACT200L_REG15 0xf0 /* Register 21: Control register #4 */ #define ACT200L_REG21 0x50 #define ACT200L_EXCK 0x02 /* Disable clock output driver */ #define ACT200L_OSCL 0x04 /* oscillator in low power, medium accuracy mode */ static struct dongle_driver act200l = { .owner = THIS_MODULE, .driver_name = "ACTiSYS ACT-IR200L", .type = IRDA_ACT200L_DONGLE, .open = act200l_open, .close = act200l_close, .reset = act200l_reset, .set_speed = act200l_change_speed, }; static int __init act200l_sir_init(void) { return irda_register_dongle(&act200l); } static void __exit act200l_sir_cleanup(void) { irda_unregister_dongle(&act200l); } static int act200l_open(struct sir_dev *dev) { struct qos_info *qos = &dev->qos; IRDA_DEBUG(2, "%s()\n", __func__ ); /* Power on the dongle */ sirdev_set_dtr_rts(dev, TRUE, TRUE); /* Set the speeds we can accept */ qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200; qos->min_turn_time.bits = 0x03; irda_qos_bits_to_value(qos); /* irda thread waits 50 msec for power settling */ return 0; } static int act200l_close(struct sir_dev *dev) { IRDA_DEBUG(2, "%s()\n", __func__ ); /* Power off the dongle */ sirdev_set_dtr_rts(dev, FALSE, FALSE); return 0; } /* * Function act200l_change_speed (dev, speed) * * Set the speed for the ACTiSYS ACT-IR200L type dongle. * */ static int act200l_change_speed(struct sir_dev *dev, unsigned speed) { u8 control[3]; int ret = 0; IRDA_DEBUG(2, "%s()\n", __func__ ); /* Clear DTR and set RTS to enter command mode */ sirdev_set_dtr_rts(dev, FALSE, TRUE); switch (speed) { default: ret = -EINVAL; /* fall through */ case 9600: control[0] = ACT200L_REG8 | (ACT200L_9600 & 0x0f); control[1] = ACT200L_REG9 | ((ACT200L_9600 >> 4) & 0x0f); break; case 19200: control[0] = ACT200L_REG8 | (ACT200L_19200 & 0x0f); control[1] = ACT200L_REG9 | ((ACT200L_19200 >> 4) & 0x0f); break; case 38400: control[0] = ACT200L_REG8 | (ACT200L_38400 & 0x0f); control[1] = ACT200L_REG9 | ((ACT200L_38400 >> 4) & 0x0f); break; case 57600: control[0] = ACT200L_REG8 | (ACT200L_57600 & 0x0f); control[1] = ACT200L_REG9 | ((ACT200L_57600 >> 4) & 0x0f); break; case 115200: control[0] = ACT200L_REG8 | (ACT200L_115200 & 0x0f); control[1] = ACT200L_REG9 | ((ACT200L_115200 >> 4) & 0x0f); break; } control[2] = ACT200L_REG1 | ACT200L_LODB | ACT200L_WIDE; /* Write control bytes */ sirdev_raw_write(dev, control, 3); msleep(5); /* Go back to normal mode */ sirdev_set_dtr_rts(dev, TRUE, TRUE); dev->speed = speed; return ret; } /* * Function act200l_reset (driver) * * Reset the ACTiSYS ACT-IR200L type dongle. */ #define ACT200L_STATE_WAIT1_RESET (SIRDEV_STATE_DONGLE_RESET+1) #define ACT200L_STATE_WAIT2_RESET (SIRDEV_STATE_DONGLE_RESET+2) static int act200l_reset(struct sir_dev *dev) { unsigned state = dev->fsm.substate; unsigned delay = 0; static const u8 control[9] = { ACT200L_REG15, ACT200L_REG13 | ACT200L_SHDW, ACT200L_REG21 | ACT200L_EXCK | ACT200L_OSCL, ACT200L_REG13, ACT200L_REG7 | ACT200L_ENPOS, ACT200L_REG6 | ACT200L_RS0 | ACT200L_RS1, ACT200L_REG5 | ACT200L_RWIDL, ACT200L_REG4 | ACT200L_OP0 | ACT200L_OP1 | ACT200L_BLKR, ACT200L_REG0 | ACT200L_TXEN | ACT200L_RXEN }; int ret = 0; IRDA_DEBUG(2, "%s()\n", __func__ ); switch (state) { case SIRDEV_STATE_DONGLE_RESET: /* Reset the dongle : set RTS low for 25 ms */ sirdev_set_dtr_rts(dev, TRUE, FALSE); state = ACT200L_STATE_WAIT1_RESET; delay = 50; break; case ACT200L_STATE_WAIT1_RESET: /* Clear DTR and set RTS to enter command mode */ sirdev_set_dtr_rts(dev, FALSE, TRUE); udelay(25); /* better wait for some short while */ /* Write control bytes */ sirdev_raw_write(dev, control, sizeof(control)); state = ACT200L_STATE_WAIT2_RESET; delay = 15; break; case ACT200L_STATE_WAIT2_RESET: /* Go back to normal mode */ sirdev_set_dtr_rts(dev, TRUE, TRUE); dev->speed = 9600; break; default: IRDA_ERROR("%s(), unknown state %d\n", __func__, state); ret = -1; break; } dev->fsm.substate = state; return (delay > 0) ? delay : ret; } MODULE_AUTHOR("SHIMIZU Takuya <tshimizu@ga2.so-net.ne.jp>"); MODULE_DESCRIPTION("ACTiSYS ACT-IR200L dongle driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("irda-dongle-10"); /* IRDA_ACT200L_DONGLE */ module_init(act200l_sir_init); module_exit(act200l_sir_cleanup);
siburu/livedump-kernel
drivers/net/irda/act200l-sir.c
C
gpl-2.0
7,155
/* * Memory preserving reboot related code. * * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) * Copyright (C) IBM Corporation, 2004. All rights reserved */ #include <linux/errno.h> #include <linux/crash_dump.h> #include <linux/uaccess.h> #include <linux/io.h> /** * copy_oldmem_page - copy one page from "oldmem" * @pfn: page frame number to be copied * @buf: target memory address for the copy; this can be in kernel address * space or user address space (see @userbuf) * @csize: number of bytes to copy * @offset: offset in bytes into the page (based on pfn) to begin the copy * @userbuf: if set, @buf is in user address space, use copy_to_user(), * otherwise @buf is in kernel address space, use memcpy(). * * Copy a page from "oldmem". For this page, there is no pte mapped * in the current kernel. We stitch up a pte, similar to kmap_atomic. */ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize, unsigned long offset, int userbuf) { void *vaddr; if (!csize) return 0; vaddr = ioremap_cache(pfn << PAGE_SHIFT, PAGE_SIZE); if (!vaddr) return -ENOMEM; if (userbuf) { if (copy_to_user(buf, vaddr + offset, csize)) { iounmap(vaddr); return -EFAULT; } } else memcpy(buf, vaddr + offset, csize); set_iounmap_nonlazy(); iounmap(vaddr); return csize; }
cocafe/i9070_Kernel_CoCore-E
arch/x86/kernel/crash_dump_64.c
C
gpl-2.0
1,327
/* * Filename: ks0108.c * Version: 0.1.0 * Description: ks0108 LCD Controller driver * License: GPLv2 * Depends: parport * * Author: Copyright (C) Miguel Ojeda Sandonis * Date: 2006-10-31 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * 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 <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/fs.h> #include <linux/io.h> #include <linux/parport.h> #include <linux/uaccess.h> #include <linux/ks0108.h> #define KS0108_NAME "ks0108" /* * Module Parameters */ static unsigned int ks0108_port = CONFIG_KS0108_PORT; module_param(ks0108_port, uint, S_IRUGO); MODULE_PARM_DESC(ks0108_port, "Parallel port where the LCD is connected"); static unsigned int ks0108_delay = CONFIG_KS0108_DELAY; module_param(ks0108_delay, uint, S_IRUGO); MODULE_PARM_DESC(ks0108_delay, "Delay between each control writing (microseconds)"); /* * Device */ static struct parport *ks0108_parport; static struct pardevice *ks0108_pardevice; /* * ks0108 Exported Commands (don't lock) * * You _should_ lock in the top driver: This functions _should not_ * get race conditions in any way. Locking for each byte here would be * so slow and useless. * * There are not bit definitions because they are not flags, * just arbitrary combinations defined by the documentation for each * function in the ks0108 LCD controller. If you want to know what means * a specific combination, look at the function's name. * * The ks0108_writecontrol bits need to be reverted ^(0,1,3) because * the parallel port also revert them using a "not" logic gate. */ #define bit(n) (((unsigned char)1)<<(n)) void ks0108_writedata(unsigned char byte) { parport_write_data(ks0108_parport, byte); } void ks0108_writecontrol(unsigned char byte) { udelay(ks0108_delay); parport_write_control(ks0108_parport, byte ^ (bit(0) | bit(1) | bit(3))); } void ks0108_displaystate(unsigned char state) { ks0108_writedata((state ? bit(0) : 0) | bit(1) | bit(2) | bit(3) | bit(4) | bit(5)); } void ks0108_startline(unsigned char startline) { ks0108_writedata(min(startline,(unsigned char)63) | bit(6) | bit(7)); } void ks0108_address(unsigned char address) { ks0108_writedata(min(address,(unsigned char)63) | bit(6)); } void ks0108_page(unsigned char page) { ks0108_writedata(min(page,(unsigned char)7) | bit(3) | bit(4) | bit(5) | bit(7)); } EXPORT_SYMBOL_GPL(ks0108_writedata); EXPORT_SYMBOL_GPL(ks0108_writecontrol); EXPORT_SYMBOL_GPL(ks0108_displaystate); EXPORT_SYMBOL_GPL(ks0108_startline); EXPORT_SYMBOL_GPL(ks0108_address); EXPORT_SYMBOL_GPL(ks0108_page); /* * Is the module inited? */ static unsigned char ks0108_inited; unsigned char ks0108_isinited(void) { return ks0108_inited; } EXPORT_SYMBOL_GPL(ks0108_isinited); /* * Module Init & Exit */ static int __init ks0108_init(void) { int result; int ret = -EINVAL; ks0108_parport = parport_find_base(ks0108_port); if (ks0108_parport == NULL) { printk(KERN_ERR KS0108_NAME ": ERROR: " "parport didn't find %i port\n", ks0108_port); goto none; } ks0108_pardevice = parport_register_device(ks0108_parport, KS0108_NAME, NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); if (ks0108_pardevice == NULL) { printk(KERN_ERR KS0108_NAME ": ERROR: " "parport didn't register new device\n"); goto none; } result = parport_claim(ks0108_pardevice); if (result != 0) { printk(KERN_ERR KS0108_NAME ": ERROR: " "can't claim %i parport, maybe in use\n", ks0108_port); ret = result; goto registered; } ks0108_inited = 1; return 0; registered: parport_unregister_device(ks0108_pardevice); none: return ret; } static void __exit ks0108_exit(void) { parport_release(ks0108_pardevice); parport_unregister_device(ks0108_pardevice); } module_init(ks0108_init); module_exit(ks0108_exit); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>"); MODULE_DESCRIPTION("ks0108 LCD Controller driver");
bozont/2.6.35
drivers/auxdisplay/ks0108.c
C
gpl-2.0
4,622
/* * Filename: ks0108.c * Version: 0.1.0 * Description: ks0108 LCD Controller driver * License: GPLv2 * Depends: parport * * Author: Copyright (C) Miguel Ojeda Sandonis * Date: 2006-10-31 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * 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 <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/fs.h> #include <linux/io.h> #include <linux/parport.h> #include <linux/uaccess.h> #include <linux/ks0108.h> #define KS0108_NAME "ks0108" /* * Module Parameters */ static unsigned int ks0108_port = CONFIG_KS0108_PORT; module_param(ks0108_port, uint, S_IRUGO); MODULE_PARM_DESC(ks0108_port, "Parallel port where the LCD is connected"); static unsigned int ks0108_delay = CONFIG_KS0108_DELAY; module_param(ks0108_delay, uint, S_IRUGO); MODULE_PARM_DESC(ks0108_delay, "Delay between each control writing (microseconds)"); /* * Device */ static struct parport *ks0108_parport; static struct pardevice *ks0108_pardevice; /* * ks0108 Exported Commands (don't lock) * * You _should_ lock in the top driver: This functions _should not_ * get race conditions in any way. Locking for each byte here would be * so slow and useless. * * There are not bit definitions because they are not flags, * just arbitrary combinations defined by the documentation for each * function in the ks0108 LCD controller. If you want to know what means * a specific combination, look at the function's name. * * The ks0108_writecontrol bits need to be reverted ^(0,1,3) because * the parallel port also revert them using a "not" logic gate. */ #define bit(n) (((unsigned char)1)<<(n)) void ks0108_writedata(unsigned char byte) { parport_write_data(ks0108_parport, byte); } void ks0108_writecontrol(unsigned char byte) { udelay(ks0108_delay); parport_write_control(ks0108_parport, byte ^ (bit(0) | bit(1) | bit(3))); } void ks0108_displaystate(unsigned char state) { ks0108_writedata((state ? bit(0) : 0) | bit(1) | bit(2) | bit(3) | bit(4) | bit(5)); } void ks0108_startline(unsigned char startline) { ks0108_writedata(min(startline,(unsigned char)63) | bit(6) | bit(7)); } void ks0108_address(unsigned char address) { ks0108_writedata(min(address,(unsigned char)63) | bit(6)); } void ks0108_page(unsigned char page) { ks0108_writedata(min(page,(unsigned char)7) | bit(3) | bit(4) | bit(5) | bit(7)); } EXPORT_SYMBOL_GPL(ks0108_writedata); EXPORT_SYMBOL_GPL(ks0108_writecontrol); EXPORT_SYMBOL_GPL(ks0108_displaystate); EXPORT_SYMBOL_GPL(ks0108_startline); EXPORT_SYMBOL_GPL(ks0108_address); EXPORT_SYMBOL_GPL(ks0108_page); /* * Is the module inited? */ static unsigned char ks0108_inited; unsigned char ks0108_isinited(void) { return ks0108_inited; } EXPORT_SYMBOL_GPL(ks0108_isinited); /* * Module Init & Exit */ static int __init ks0108_init(void) { int result; int ret = -EINVAL; ks0108_parport = parport_find_base(ks0108_port); if (ks0108_parport == NULL) { printk(KERN_ERR KS0108_NAME ": ERROR: " "parport didn't find %i port\n", ks0108_port); goto none; } ks0108_pardevice = parport_register_device(ks0108_parport, KS0108_NAME, NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); if (ks0108_pardevice == NULL) { printk(KERN_ERR KS0108_NAME ": ERROR: " "parport didn't register new device\n"); goto none; } result = parport_claim(ks0108_pardevice); if (result != 0) { printk(KERN_ERR KS0108_NAME ": ERROR: " "can't claim %i parport, maybe in use\n", ks0108_port); ret = result; goto registered; } ks0108_inited = 1; return 0; registered: parport_unregister_device(ks0108_pardevice); none: return ret; } static void __exit ks0108_exit(void) { parport_release(ks0108_pardevice); parport_unregister_device(ks0108_pardevice); } module_init(ks0108_init); module_exit(ks0108_exit); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>"); MODULE_DESCRIPTION("ks0108 LCD Controller driver");
leonardoafa/android_kernel_motorola_msm8974
drivers/auxdisplay/ks0108.c
C
gpl-2.0
4,622
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/spinlock.h> #include <linux/log2.h> #include <bcm63xx_cpu.h> #include <bcm63xx_io.h> #include <bcm63xx_regs.h> #include <bcm63xx_cs.h> static DEFINE_SPINLOCK(bcm63xx_cs_lock); /* * check if given chip select exists */ static int is_valid_cs(unsigned int cs) { if (cs > 6) return 0; return 1; } /* * Configure chipselect base address and size (bytes). * Size must be a power of two between 8k and 256M. */ int bcm63xx_set_cs_base(unsigned int cs, u32 base, unsigned int size) { unsigned long flags; u32 val; if (!is_valid_cs(cs)) return -EINVAL; /* sanity check on size */ if (size != roundup_pow_of_two(size)) return -EINVAL; if (size < 8 * 1024 || size > 256 * 1024 * 1024) return -EINVAL; val = (base & MPI_CSBASE_BASE_MASK); /* 8k => 0 - 256M => 15 */ val |= (ilog2(size) - ilog2(8 * 1024)) << MPI_CSBASE_SIZE_SHIFT; spin_lock_irqsave(&bcm63xx_cs_lock, flags); bcm_mpi_writel(val, MPI_CSBASE_REG(cs)); spin_unlock_irqrestore(&bcm63xx_cs_lock, flags); return 0; } EXPORT_SYMBOL(bcm63xx_set_cs_base); /* * configure chipselect timing (ns) */ int bcm63xx_set_cs_timing(unsigned int cs, unsigned int wait, unsigned int setup, unsigned int hold) { unsigned long flags; u32 val; if (!is_valid_cs(cs)) return -EINVAL; spin_lock_irqsave(&bcm63xx_cs_lock, flags); val = bcm_mpi_readl(MPI_CSCTL_REG(cs)); val &= ~(MPI_CSCTL_WAIT_MASK); val &= ~(MPI_CSCTL_SETUP_MASK); val &= ~(MPI_CSCTL_HOLD_MASK); val |= wait << MPI_CSCTL_WAIT_SHIFT; val |= setup << MPI_CSCTL_SETUP_SHIFT; val |= hold << MPI_CSCTL_HOLD_SHIFT; bcm_mpi_writel(val, MPI_CSCTL_REG(cs)); spin_unlock_irqrestore(&bcm63xx_cs_lock, flags); return 0; } EXPORT_SYMBOL(bcm63xx_set_cs_timing); /* * configure other chipselect parameter (data bus size, ...) */ int bcm63xx_set_cs_param(unsigned int cs, u32 params) { unsigned long flags; u32 val; if (!is_valid_cs(cs)) return -EINVAL; /* none of this fields apply to pcmcia */ if (cs == MPI_CS_PCMCIA_COMMON || cs == MPI_CS_PCMCIA_ATTR || cs == MPI_CS_PCMCIA_IO) return -EINVAL; spin_lock_irqsave(&bcm63xx_cs_lock, flags); val = bcm_mpi_readl(MPI_CSCTL_REG(cs)); val &= ~(MPI_CSCTL_DATA16_MASK); val &= ~(MPI_CSCTL_SYNCMODE_MASK); val &= ~(MPI_CSCTL_TSIZE_MASK); val &= ~(MPI_CSCTL_ENDIANSWAP_MASK); val |= params; bcm_mpi_writel(val, MPI_CSCTL_REG(cs)); spin_unlock_irqrestore(&bcm63xx_cs_lock, flags); return 0; } EXPORT_SYMBOL(bcm63xx_set_cs_param); /* * set cs status (enable/disable) */ int bcm63xx_set_cs_status(unsigned int cs, int enable) { unsigned long flags; u32 val; if (!is_valid_cs(cs)) return -EINVAL; spin_lock_irqsave(&bcm63xx_cs_lock, flags); val = bcm_mpi_readl(MPI_CSCTL_REG(cs)); if (enable) val |= MPI_CSCTL_ENABLE_MASK; else val &= ~MPI_CSCTL_ENABLE_MASK; bcm_mpi_writel(val, MPI_CSCTL_REG(cs)); spin_unlock_irqrestore(&bcm63xx_cs_lock, flags); return 0; } EXPORT_SYMBOL(bcm63xx_set_cs_status);
danysan2000/linux-danysan
arch/mips/bcm63xx/cs.c
C
gpl-2.0
3,250
/* SourceGiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class. Copyright (C) 2006, 2008 Free Software Foundation This file is part of GNU Classpath. GNU Classpath 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, or (at your option) any later version. GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package gnu.classpath.tools.rmic; import gnu.classpath.tools.rmic.AbstractMethodGenerator; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.rmi.Remote; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeSet; /** * Provides the extended rmic functionality to generate the POA - based classes * for GIOP (javax.rmi.CORBA package). * * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org) */ public class SourceGiopRmicCompiler extends Generator implements Comparator, RmicBackend { /** The package name. */ protected String packag; /** * The "basic" name (normally, the interface name, unless several Remote - * derived interfaces are implemented. */ protected String name; /** * The name (without package) of the class, passed as the parameter. */ protected String implName; /** * The proposed name for the stub. */ protected String stubName; /** * The Remote's, implemented by this class. */ protected Collection implementedRemotes = new HashSet(); /** * The extra classes that must be imported. */ protected Collection extraImports = new HashSet(); /** * The methods we must implement. */ protected Collection methods = new HashSet(); /** * The map of all code generator variables. */ public Properties vars = new Properties(); /** * If this flag is set (true by default), the compiler generates the Servant * based classes. If set to false, the compiler generates the old style * ObjectImpl based classes. */ protected boolean poaMode = true; /** * If this flag is set (true by default), the compiler emits warnings. */ protected boolean warnings = true; /** * If this flag is set (false by default), the compiler does not * write output files. */ protected boolean noWrite = false; /** * If this flag is set (false by default), the compiler keeps source * output files. For SourceGiopRmicCompiler this overrides * -nowrite, since -nowrite doesn't apply to sources kept with * -keep. */ protected boolean keep = false; /** * Verbose output */ protected boolean verbose = false; /** * Force mode - do not check the exceptions */ protected boolean force = false; /** * The output directory for generated files. */ protected String outputDirectory; /** * The class loader to load the class being compiled. */ ClassLoader classLoader; /** * Clear data, preparing for the next compilation. */ public synchronized void reset() { packag = name = implName = stubName = null; implementedRemotes.clear(); extraImports.clear(); methods.clear(); vars.clear(); } /** * Set the class path (handle the -classpath key) * * @param classPath the class path to set. */ public void setClassPath(String classPath) { classLoader = Thread.currentThread().getContextClassLoader(); StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator, true); ArrayList urls = new ArrayList(tok.countTokens()); String s = null; try { while (tok.hasMoreTokens()) { s = tok.nextToken(); if (s.equals(File.pathSeparator)) urls.add(new File(".").toURL()); else { urls.add(new File(s).toURL()); if (tok.hasMoreTokens()) { // Skip the separator. tok.nextToken(); // If the classpath ended with a separator, // append the current directory. if (! tok.hasMoreTokens()) urls.add(new File(".").toURL()); } } } } catch (MalformedURLException ex) { System.err.println("Malformed path '" + s + "' in classpath '" + classPath + "'"); System.exit(1); } URL[] u = new URL[urls.size()]; for (int i = 0; i < u.length; i++) { u[i] = (URL) urls.get(i); } classLoader = new URLClassLoader(u, classLoader); } /** * Loads the class with the given name (uses class path, if applicable) * * @param name the name of the class. */ public Class loadClass(String name) { ClassLoader loader = classLoader; if (loader == null) loader = Thread.currentThread().getContextClassLoader(); try { return loader.loadClass(name); } catch (ClassNotFoundException e) { System.err.println(name+" not found on "+loader); System.exit(1); // Unreacheable code. return null; } } /** * Compile the given class (the instance of Remote), generating the stub and * tie for it. * * @param remote * the class to compile. */ public synchronized void compile(Class remote) { reset(); String s; // Get the package. s = remote.getName(); int p = s.lastIndexOf('.'); if (p < 0) { // Root package. packag = ""; implName = name = s; } else { packag = s.substring(0, p); implName = name = s.substring(p + 1); } name = convertStubName(name); stubName = name; vars.put("#name", name); vars.put("#package", packag); vars.put("#implName", implName); if (verbose) System.out.println("Package " + packag + ", name " + name + " impl " + implName); // Get the implemented remotes. Class[] interfaces = remote.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (Remote.class.isAssignableFrom(interfaces[i])) { if (! interfaces[i].equals(Remote.class)) { implementedRemotes.add(interfaces[i]); } } } vars.put("#idList", getIdList(implementedRemotes)); // Collect and process methods. Iterator iter = implementedRemotes.iterator(); while (iter.hasNext()) { Class c = (Class) iter.next(); Method[] m = c.getMethods(); // Check if throws RemoteException. for (int i = 0; i < m.length; i++) { Class[] exc = m[i].getExceptionTypes(); boolean remEx = false; for (int j = 0; j < exc.length; j++) { if (exc[j].isAssignableFrom(RemoteException.class)) { remEx = true; break; } } if (! remEx && !force) throw new CompilationError(m[i].getName() + ", defined in " + c.getName() + ", does not throw " + RemoteException.class.getName()); AbstractMethodGenerator mm = createMethodGenerator(m[i]); methods.add(mm); } } } /** * Create the method generator for the given method. * * @param m the method * * @return the created method generator */ protected AbstractMethodGenerator createMethodGenerator(Method m) { return new MethodGenerator(m, this); } /** * Get the name of the given class. The class is added to imports, if not * already present and not from java.lang and not from the current package. * * @param nameIt * the class to name * @return the name of class as it should appear in java language */ public synchronized String name(Class nameIt) { if (nameIt.isArray()) { // Mesure dimensions: int dimension = 0; Class finalComponent = nameIt; while (finalComponent.isArray()) { finalComponent = finalComponent.getComponentType(); dimension++; } StringBuilder brackets = new StringBuilder(); for (int i = 0; i < dimension; i++) { brackets.append("[]"); } return name(finalComponent) + " " + brackets; } else { String n = nameIt.getName(); if (! nameIt.isArray() && ! nameIt.isPrimitive()) if (! n.startsWith("java.lang") && ! (packag != null && n.startsWith(packag))) extraImports.add(n); int p = n.lastIndexOf('.'); if (p < 0) return n; else return n.substring(p + 1); } } /** * Get the RMI-style repository Id for the given class. * * @param c * the interface, for that the repository Id must be created. * @return the repository id */ public String getId(Class c) { return "RMI:" + c.getName() + ":0000000000000000"; } /** * Get repository Id string array declaration. * * @param remotes * the collection of interfaces * @return the fully formatted string array. */ public String getIdList(Collection remotes) { StringBuilder b = new StringBuilder(); // Keep the Ids sorted, ensuring, that the same order will be preserved // between compilations. TreeSet sortedIds = new TreeSet(); Iterator iter = remotes.iterator(); while (iter.hasNext()) { sortedIds.add(getId((Class) iter.next())); } iter = sortedIds.iterator(); while (iter.hasNext()) { b.append(" \"" + iter.next() + "\""); if (iter.hasNext()) b.append(", \n"); } return b.toString(); } /** * Generate stub. Can only be called from {@link #compile}. * * @return the string, containing the text of the generated stub. */ public String generateStub() { String template = getResource("Stub.jav"); // Generate methods. StringBuilder b = new StringBuilder(); Iterator iter = methods.iterator(); while (iter.hasNext()) { AbstractMethodGenerator m = (AbstractMethodGenerator) iter.next(); b.append(m.generateStubMethod()); } vars.put("#stub_methods", b.toString()); vars.put("#imports", getImportStatements()); vars.put("#interfaces", getAllInterfaces()); String output = replaceAll(template, vars); return output; } /** * Get the list of all interfaces, implemented by the class, that are * derived from Remote. * * @return the string - all interfaces. */ public String getAllInterfaces() { StringBuilder b = new StringBuilder(); Iterator iter = implementedRemotes.iterator(); while (iter.hasNext()) { b.append(name((Class) iter.next())); if (iter.hasNext()) b.append(", "); } return b.toString(); } /** * Generate Tie. Can only be called from {@link #compile}. * * @return the string, containing the text of the generated Tie. */ public String generateTie() { String template; if (poaMode) template = getResource("Tie.jav"); else template = getResource("ImplTie.jav"); // Generate methods. HashFinder hashFinder = new HashFinder(); // Find the hash character position: Iterator iter = methods.iterator(); String[] names = new String[methods.size()]; int p = 0; for (int i = 0; i < names.length; i++) names[i] = ((MethodGenerator) iter.next()).getGiopMethodName(); int hashCharPosition = hashFinder.findHashCharPosition(names); iter = methods.iterator(); while (iter.hasNext()) ((MethodGenerator) iter.next()).hashCharPosition = hashCharPosition; vars.put("#hashCharPos", Integer.toString(hashCharPosition)); ArrayList sortedMethods = new ArrayList(methods); Collections.sort(sortedMethods, this); iter = sortedMethods.iterator(); StringBuilder b = new StringBuilder(); MethodGenerator prev = null; while (iter.hasNext()) { MethodGenerator m = (MethodGenerator) iter.next(); m.previous = prev; m.hashCharPosition = hashCharPosition; prev = m; b.append(m.generateTieMethod()); } vars.put("#tie_methods", b.toString()); vars.put("#imports", getImportStatements()); String output = replaceAll(template, vars); return output; } public int compare(Object a, Object b) { MethodGenerator g1 = (MethodGenerator) a; MethodGenerator g2 = (MethodGenerator) b; return g1.getHashChar() - g2.getHashChar(); } /** * Import the extra classes, used as the method parameters and return values. * * @return the additional import block. */ protected String getImportStatements() { TreeSet imp = new TreeSet(); Iterator it = extraImports.iterator(); while (it.hasNext()) { String ic = it.next().toString(); imp.add("import " + ic + ";\n"); } StringBuilder b = new StringBuilder(); it = imp.iterator(); while (it.hasNext()) { b.append(it.next()); } return b.toString(); } /** * If this flag is set (true by default), the compiler generates the Servant * based classes. If set to false, the compiler generates the old style * ObjectImpl based classes. */ public void setPoaMode(boolean mode) { poaMode = mode; } /** * Set the verbose output mode (false by default) * * @param isVerbose the verbose output mode */ public void setVerbose(boolean isVerbose) { verbose = isVerbose; } /** * If this flag is set (true by default), the compiler emits warnings. */ public void setWarnings(boolean warn) { warnings = warn; } /** * Set the error ignore mode. */ public void setForce(boolean isforce) { force = isforce; } /** * Get the package name. */ public String getPackageName() { return packag; } /** * Get the proposed stub name */ public String getStubName() { return stubName; } /** * Additional processing of the stub name. */ public String convertStubName(String name) { // Drop the Impl suffix, if one exists. if (name.endsWith("Impl")) return name.substring(0, name.length() - "Impl".length()); else return name; } /** * Assumes that output directory is already created. */ protected boolean outputTie(File fw, Class c) { try { String tie = generateTie(); String tieName = "_" + name(c) + "_Tie.java"; OutputStream out = new FileOutputStream(new File(fw, tieName)); out.write(tie.getBytes()); out.close(); } catch (IOException ioex) { System.err.println("Output path not accessible"); ioex.printStackTrace(); return false; } return true; } public void setup(boolean keep, boolean need11Stubs, boolean need12Stubs, boolean iiop, boolean poa, boolean debug, boolean warnings, boolean noWrite, boolean verbose, boolean force, String classpath, String bootclasspath, String extdirs, String outputDirectory) { setWarnings(warnings); setVerbose(verbose); setForce(force); setClassPath(classpath); setPoaMode(poa); this.outputDirectory = outputDirectory; this.noWrite = noWrite; this.keep = keep; } public boolean run(String[] inputFiles) { for (int i = 0; i < inputFiles.length; i++) { reset(); Class c = loadClass(inputFiles[i]); compile(c); String packag = getPackageName().replace('.', '/'); File fw = new File(outputDirectory, packag); // Generate stub. String stub = generateStub(); String subName = getStubName() + "_Stub.java"; // -keep overrides -nowrite for sources. if (!noWrite || keep) { try { fw.mkdirs(); OutputStream out = new FileOutputStream(new File(fw, subName)); out.write(stub.getBytes()); out.close(); // Generate tie if (!outputTie(fw, c)) return false; } catch (IOException ioex) { System.err.println("Output path not accessible"); ioex.printStackTrace(); return false; } } } return true; } }
fedya/aircam-openwrt
build_dir/toolchain-arm_v5te_gcc-linaro_uClibc-0.9.32_eabi/gcc-linaro-4.5-2011.02-0/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
Java
gpl-2.0
17,756
/* * Procedures for maintaining information about logical memory blocks. * * Peter Bergner, IBM Corp. June 2001. * Copyright (C) 2001 Peter Bergner. * * 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. */ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/bitops.h> #include <linux/poison.h> #include <linux/pfn.h> #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/memblock.h> #include <asm-generic/sections.h> static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; struct memblock memblock __initdata_memblock = { .memory.regions = memblock_memory_init_regions, .memory.cnt = 1, /* empty dummy entry */ .memory.max = INIT_MEMBLOCK_REGIONS, .reserved.regions = memblock_reserved_init_regions, .reserved.cnt = 1, /* empty dummy entry */ .reserved.max = INIT_MEMBLOCK_REGIONS, .bottom_up = false, .current_limit = MEMBLOCK_ALLOC_ANYWHERE, }; int memblock_debug __initdata_memblock; static int memblock_can_resize __initdata_memblock; static int memblock_memory_in_slab __initdata_memblock = 0; static int memblock_reserved_in_slab __initdata_memblock = 0; /* inline so we don't get a warning when pr_debug is compiled out */ static __init_memblock const char * memblock_type_name(struct memblock_type *type) { if (type == &memblock.memory) return "memory"; else if (type == &memblock.reserved) return "reserved"; else return "unknown"; } /* adjust *@size so that (@base + *@size) doesn't overflow, return new size */ static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size) { return *size = min(*size, (phys_addr_t)ULLONG_MAX - base); } /* * Address comparison utilities */ static unsigned long __init_memblock memblock_addrs_overlap(phys_addr_t base1, phys_addr_t size1, phys_addr_t base2, phys_addr_t size2) { return ((base1 < (base2 + size2)) && (base2 < (base1 + size1))); } static long __init_memblock memblock_overlaps_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size) { unsigned long i; for (i = 0; i < type->cnt; i++) { phys_addr_t rgnbase = type->regions[i].base; phys_addr_t rgnsize = type->regions[i].size; if (memblock_addrs_overlap(base, size, rgnbase, rgnsize)) break; } return (i < type->cnt) ? i : -1; } /* * __memblock_find_range_bottom_up - find free area utility in bottom-up * @start: start of candidate range * @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE} * @size: size of free area to find * @align: alignment of free area to find * @nid: nid of the free area to find, %MAX_NUMNODES for any node * * Utility called from memblock_find_in_range_node(), find free area bottom-up. * * RETURNS: * Found address on success, 0 on failure. */ static phys_addr_t __init_memblock __memblock_find_range_bottom_up(phys_addr_t start, phys_addr_t end, phys_addr_t size, phys_addr_t align, int nid) { phys_addr_t this_start, this_end, cand; u64 i; for_each_free_mem_range(i, nid, &this_start, &this_end, NULL) { this_start = clamp(this_start, start, end); this_end = clamp(this_end, start, end); cand = round_up(this_start, align); if (cand < this_end && this_end - cand >= size) return cand; } return 0; } /** * __memblock_find_range_top_down - find free area utility, in top-down * @start: start of candidate range * @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE} * @size: size of free area to find * @align: alignment of free area to find * @nid: nid of the free area to find, %MAX_NUMNODES for any node * * Utility called from memblock_find_in_range_node(), find free area top-down. * * RETURNS: * Found address on success, 0 on failure. */ static phys_addr_t __init_memblock __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end, phys_addr_t size, phys_addr_t align, int nid) { phys_addr_t this_start, this_end, cand; u64 i; for_each_free_mem_range_reverse(i, nid, &this_start, &this_end, NULL) { this_start = clamp(this_start, start, end); this_end = clamp(this_end, start, end); if (this_end < size) continue; cand = round_down(this_end - size, align); if (cand >= this_start) return cand; } return 0; } /** * memblock_find_in_range_node - find free area in given range and node * @start: start of candidate range * @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE} * @size: size of free area to find * @align: alignment of free area to find * @nid: nid of the free area to find, %MAX_NUMNODES for any node * * Find @size free area aligned to @align in the specified range and node. * * When allocation direction is bottom-up, the @start should be greater * than the end of the kernel image. Otherwise, it will be trimmed. The * reason is that we want the bottom-up allocation just near the kernel * image so it is highly likely that the allocated memory and the kernel * will reside in the same node. * * If bottom-up allocation failed, will try to allocate memory top-down. * * RETURNS: * Found address on success, 0 on failure. */ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start, phys_addr_t end, phys_addr_t size, phys_addr_t align, int nid) { int ret; phys_addr_t kernel_end; /* pump up @end */ if (end == MEMBLOCK_ALLOC_ACCESSIBLE) end = memblock.current_limit; /* avoid allocating the first page */ start = max_t(phys_addr_t, start, PAGE_SIZE); end = max(start, end); kernel_end = __pa_symbol(_end); /* * try bottom-up allocation only when bottom-up mode * is set and @end is above the kernel image. */ if (memblock_bottom_up() && end > kernel_end) { phys_addr_t bottom_up_start; /* make sure we will allocate above the kernel */ bottom_up_start = max(start, kernel_end); /* ok, try bottom-up allocation first */ ret = __memblock_find_range_bottom_up(bottom_up_start, end, size, align, nid); if (ret) return ret; /* * we always limit bottom-up allocation above the kernel, * but top-down allocation doesn't have the limit, so * retrying top-down allocation may succeed when bottom-up * allocation failed. * * bottom-up allocation is expected to be fail very rarely, * so we use WARN_ONCE() here to see the stack trace if * fail happens. */ WARN_ONCE(1, "memblock: bottom-up allocation failed, " "memory hotunplug may be affected\n"); } return __memblock_find_range_top_down(start, end, size, align, nid); } /** * memblock_find_in_range - find free area in given range * @start: start of candidate range * @end: end of candidate range, can be %MEMBLOCK_ALLOC_{ANYWHERE|ACCESSIBLE} * @size: size of free area to find * @align: alignment of free area to find * * Find @size free area aligned to @align in the specified range. * * RETURNS: * Found address on success, 0 on failure. */ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start, phys_addr_t end, phys_addr_t size, phys_addr_t align) { return memblock_find_in_range_node(start, end, size, align, MAX_NUMNODES); } static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r) { type->total_size -= type->regions[r].size; memmove(&type->regions[r], &type->regions[r + 1], (type->cnt - (r + 1)) * sizeof(type->regions[r])); type->cnt--; /* Special case for empty arrays */ if (type->cnt == 0) { WARN_ON(type->total_size != 0); type->cnt = 1; type->regions[0].base = 0; type->regions[0].size = 0; memblock_set_region_node(&type->regions[0], MAX_NUMNODES); } } phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info( phys_addr_t *addr) { if (memblock.reserved.regions == memblock_reserved_init_regions) return 0; *addr = __pa(memblock.reserved.regions); return PAGE_ALIGN(sizeof(struct memblock_region) * memblock.reserved.max); } /** * memblock_double_array - double the size of the memblock regions array * @type: memblock type of the regions array being doubled * @new_area_start: starting address of memory range to avoid overlap with * @new_area_size: size of memory range to avoid overlap with * * Double the size of the @type regions array. If memblock is being used to * allocate memory for a new reserved regions array and there is a previously * allocated memory range [@new_area_start,@new_area_start+@new_area_size] * waiting to be reserved, ensure the memory used by the new array does * not overlap. * * RETURNS: * 0 on success, -1 on failure. */ static int __init_memblock memblock_double_array(struct memblock_type *type, phys_addr_t new_area_start, phys_addr_t new_area_size) { struct memblock_region *new_array, *old_array; phys_addr_t old_alloc_size, new_alloc_size; phys_addr_t old_size, new_size, addr; int use_slab = slab_is_available(); int *in_slab; /* We don't allow resizing until we know about the reserved regions * of memory that aren't suitable for allocation */ if (!memblock_can_resize) return -1; /* Calculate new doubled size */ old_size = type->max * sizeof(struct memblock_region); new_size = old_size << 1; /* * We need to allocated new one align to PAGE_SIZE, * so we can free them completely later. */ old_alloc_size = PAGE_ALIGN(old_size); new_alloc_size = PAGE_ALIGN(new_size); /* Retrieve the slab flag */ if (type == &memblock.memory) in_slab = &memblock_memory_in_slab; else in_slab = &memblock_reserved_in_slab; /* Try to find some space for it. * * WARNING: We assume that either slab_is_available() and we use it or * we use MEMBLOCK for allocations. That means that this is unsafe to * use when bootmem is currently active (unless bootmem itself is * implemented on top of MEMBLOCK which isn't the case yet) * * This should however not be an issue for now, as we currently only * call into MEMBLOCK while it's still active, or much later when slab * is active for memory hotplug operations */ if (use_slab) { new_array = kmalloc(new_size, GFP_KERNEL); addr = new_array ? __pa(new_array) : 0; } else { /* only exclude range when trying to double reserved.regions */ if (type != &memblock.reserved) new_area_start = new_area_size = 0; addr = memblock_find_in_range(new_area_start + new_area_size, memblock.current_limit, new_alloc_size, PAGE_SIZE); if (!addr && new_area_size) addr = memblock_find_in_range(0, min(new_area_start, memblock.current_limit), new_alloc_size, PAGE_SIZE); new_array = addr ? __va(addr) : NULL; } if (!addr) { pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", memblock_type_name(type), type->max, type->max * 2); return -1; } memblock_dbg("memblock: %s is doubled to %ld at [%#010llx-%#010llx]", memblock_type_name(type), type->max * 2, (u64)addr, (u64)addr + new_size - 1); /* * Found space, we now need to move the array over before we add the * reserved region since it may be our reserved array itself that is * full. */ memcpy(new_array, type->regions, old_size); memset(new_array + type->max, 0, old_size); old_array = type->regions; type->regions = new_array; type->max <<= 1; /* Free old array. We needn't free it if the array is the static one */ if (*in_slab) kfree(old_array); else if (old_array != memblock_memory_init_regions && old_array != memblock_reserved_init_regions) memblock_free(__pa(old_array), old_alloc_size); /* * Reserve the new array if that comes from the memblock. Otherwise, we * needn't do it */ if (!use_slab) BUG_ON(memblock_reserve(addr, new_alloc_size)); /* Update slab flag */ *in_slab = use_slab; return 0; } /** * memblock_merge_regions - merge neighboring compatible regions * @type: memblock type to scan * * Scan @type and merge neighboring compatible regions. */ static void __init_memblock memblock_merge_regions(struct memblock_type *type) { int i = 0; /* cnt never goes below 1 */ while (i < type->cnt - 1) { struct memblock_region *this = &type->regions[i]; struct memblock_region *next = &type->regions[i + 1]; if (this->base + this->size != next->base || memblock_get_region_node(this) != memblock_get_region_node(next)) { BUG_ON(this->base + this->size > next->base); i++; continue; } this->size += next->size; /* move forward from next + 1, index of which is i + 2 */ memmove(next, next + 1, (type->cnt - (i + 2)) * sizeof(*next)); type->cnt--; } } /** * memblock_insert_region - insert new memblock region * @type: memblock type to insert into * @idx: index for the insertion point * @base: base address of the new region * @size: size of the new region * @nid: node id of the new region * * Insert new memblock region [@base,@base+@size) into @type at @idx. * @type must already have extra room to accomodate the new region. */ static void __init_memblock memblock_insert_region(struct memblock_type *type, int idx, phys_addr_t base, phys_addr_t size, int nid) { struct memblock_region *rgn = &type->regions[idx]; BUG_ON(type->cnt >= type->max); memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn)); rgn->base = base; rgn->size = size; memblock_set_region_node(rgn, nid); type->cnt++; type->total_size += size; } /** * memblock_add_region - add new memblock region * @type: memblock type to add new region into * @base: base address of the new region * @size: size of the new region * @nid: nid of the new region * * Add new memblock region [@base,@base+@size) into @type. The new region * is allowed to overlap with existing ones - overlaps don't affect already * existing regions. @type is guaranteed to be minimal (all neighbouring * compatible regions are merged) after the addition. * * RETURNS: * 0 on success, -errno on failure. */ static int __init_memblock memblock_add_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size, int nid) { bool insert = false; phys_addr_t obase = base; phys_addr_t end = base + memblock_cap_size(base, &size); int i, nr_new; if (!size) return 0; /* special case for empty array */ if (type->regions[0].size == 0) { WARN_ON(type->cnt != 1 || type->total_size); type->regions[0].base = base; type->regions[0].size = size; memblock_set_region_node(&type->regions[0], nid); type->total_size = size; return 0; } repeat: /* * The following is executed twice. Once with %false @insert and * then with %true. The first counts the number of regions needed * to accomodate the new area. The second actually inserts them. */ base = obase; nr_new = 0; for (i = 0; i < type->cnt; i++) { struct memblock_region *rgn = &type->regions[i]; phys_addr_t rbase = rgn->base; phys_addr_t rend = rbase + rgn->size; if (rbase >= end) break; if (rend <= base) continue; /* * @rgn overlaps. If it separates the lower part of new * area, insert that portion. */ if (rbase > base) { nr_new++; if (insert) memblock_insert_region(type, i++, base, rbase - base, nid); } /* area below @rend is dealt with, forget about it */ base = min(rend, end); } /* insert the remaining portion */ if (base < end) { nr_new++; if (insert) memblock_insert_region(type, i, base, end - base, nid); } /* * If this was the first round, resize array and repeat for actual * insertions; otherwise, merge and return. */ if (!insert) { while (type->cnt + nr_new > type->max) if (memblock_double_array(type, obase, size) < 0) return -ENOMEM; insert = true; goto repeat; } else { memblock_merge_regions(type); return 0; } } int __init_memblock memblock_add_node(phys_addr_t base, phys_addr_t size, int nid) { return memblock_add_region(&memblock.memory, base, size, nid); } int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size) { return memblock_add_region(&memblock.memory, base, size, MAX_NUMNODES); } /** * memblock_isolate_range - isolate given range into disjoint memblocks * @type: memblock type to isolate range for * @base: base of range to isolate * @size: size of range to isolate * @start_rgn: out parameter for the start of isolated region * @end_rgn: out parameter for the end of isolated region * * Walk @type and ensure that regions don't cross the boundaries defined by * [@base,@base+@size). Crossing regions are split at the boundaries, * which may create at most two more regions. The index of the first * region inside the range is returned in *@start_rgn and end in *@end_rgn. * * RETURNS: * 0 on success, -errno on failure. */ static int __init_memblock memblock_isolate_range(struct memblock_type *type, phys_addr_t base, phys_addr_t size, int *start_rgn, int *end_rgn) { phys_addr_t end = base + memblock_cap_size(base, &size); int i; *start_rgn = *end_rgn = 0; if (!size) return 0; /* we'll create at most two more regions */ while (type->cnt + 2 > type->max) if (memblock_double_array(type, base, size) < 0) return -ENOMEM; for (i = 0; i < type->cnt; i++) { struct memblock_region *rgn = &type->regions[i]; phys_addr_t rbase = rgn->base; phys_addr_t rend = rbase + rgn->size; if (rbase >= end) break; if (rend <= base) continue; if (rbase < base) { /* * @rgn intersects from below. Split and continue * to process the next region - the new top half. */ rgn->base = base; rgn->size -= base - rbase; type->total_size -= base - rbase; memblock_insert_region(type, i, rbase, base - rbase, memblock_get_region_node(rgn)); } else if (rend > end) { /* * @rgn intersects from above. Split and redo the * current region - the new bottom half. */ rgn->base = end; rgn->size -= end - rbase; type->total_size -= end - rbase; memblock_insert_region(type, i--, rbase, end - rbase, memblock_get_region_node(rgn)); } else { /* @rgn is fully contained, record it */ if (!*end_rgn) *start_rgn = i; *end_rgn = i + 1; } } return 0; } static int __init_memblock __memblock_remove(struct memblock_type *type, phys_addr_t base, phys_addr_t size) { int start_rgn, end_rgn; int i, ret; ret = memblock_isolate_range(type, base, size, &start_rgn, &end_rgn); if (ret) return ret; for (i = end_rgn - 1; i >= start_rgn; i--) memblock_remove_region(type, i); return 0; } int __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size) { return __memblock_remove(&memblock.memory, base, size); } int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size) { memblock_dbg(" memblock_free: [%#016llx-%#016llx] %pF\n", (unsigned long long)base, (unsigned long long)base + size, (void *)_RET_IP_); return __memblock_remove(&memblock.reserved, base, size); } int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size) { struct memblock_type *_rgn = &memblock.reserved; memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n", (unsigned long long)base, (unsigned long long)base + size, (void *)_RET_IP_); return memblock_add_region(_rgn, base, size, MAX_NUMNODES); } /** * __next_free_mem_range - next function for for_each_free_mem_range() * @idx: pointer to u64 loop variable * @nid: node selector, %MAX_NUMNODES for all nodes * @out_start: ptr to phys_addr_t for start address of the range, can be %NULL * @out_end: ptr to phys_addr_t for end address of the range, can be %NULL * @out_nid: ptr to int for nid of the range, can be %NULL * * Find the first free area from *@idx which matches @nid, fill the out * parameters, and update *@idx for the next iteration. The lower 32bit of * *@idx contains index into memory region and the upper 32bit indexes the * areas before each reserved region. For example, if reserved regions * look like the following, * * 0:[0-16), 1:[32-48), 2:[128-130) * * The upper 32bit indexes the following regions. * * 0:[0-0), 1:[16-32), 2:[48-128), 3:[130-MAX) * * As both region arrays are sorted, the function advances the two indices * in lockstep and returns each intersection. */ void __init_memblock __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start, phys_addr_t *out_end, int *out_nid) { struct memblock_type *mem = &memblock.memory; struct memblock_type *rsv = &memblock.reserved; int mi = *idx & 0xffffffff; int ri = *idx >> 32; for ( ; mi < mem->cnt; mi++) { struct memblock_region *m = &mem->regions[mi]; phys_addr_t m_start = m->base; phys_addr_t m_end = m->base + m->size; /* only memory regions are associated with nodes, check it */ if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m)) continue; /* scan areas before each reservation for intersection */ for ( ; ri < rsv->cnt + 1; ri++) { struct memblock_region *r = &rsv->regions[ri]; phys_addr_t r_start = ri ? r[-1].base + r[-1].size : 0; phys_addr_t r_end = ri < rsv->cnt ? r->base : ULLONG_MAX; /* if ri advanced past mi, break out to advance mi */ if (r_start >= m_end) break; /* if the two regions intersect, we're done */ if (m_start < r_end) { if (out_start) *out_start = max(m_start, r_start); if (out_end) *out_end = min(m_end, r_end); if (out_nid) *out_nid = memblock_get_region_node(m); /* * The region which ends first is advanced * for the next iteration. */ if (m_end <= r_end) mi++; else ri++; *idx = (u32)mi | (u64)ri << 32; return; } } } /* signal end of iteration */ *idx = ULLONG_MAX; } /** * __next_free_mem_range_rev - next function for for_each_free_mem_range_reverse() * @idx: pointer to u64 loop variable * @nid: nid: node selector, %MAX_NUMNODES for all nodes * @out_start: ptr to phys_addr_t for start address of the range, can be %NULL * @out_end: ptr to phys_addr_t for end address of the range, can be %NULL * @out_nid: ptr to int for nid of the range, can be %NULL * * Reverse of __next_free_mem_range(). */ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid, phys_addr_t *out_start, phys_addr_t *out_end, int *out_nid) { struct memblock_type *mem = &memblock.memory; struct memblock_type *rsv = &memblock.reserved; int mi = *idx & 0xffffffff; int ri = *idx >> 32; if (*idx == (u64)ULLONG_MAX) { mi = mem->cnt - 1; ri = rsv->cnt; } for ( ; mi >= 0; mi--) { struct memblock_region *m = &mem->regions[mi]; phys_addr_t m_start = m->base; phys_addr_t m_end = m->base + m->size; /* only memory regions are associated with nodes, check it */ if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m)) continue; /* scan areas before each reservation for intersection */ for ( ; ri >= 0; ri--) { struct memblock_region *r = &rsv->regions[ri]; phys_addr_t r_start = ri ? r[-1].base + r[-1].size : 0; phys_addr_t r_end = ri < rsv->cnt ? r->base : ULLONG_MAX; /* if ri advanced past mi, break out to advance mi */ if (r_end <= m_start) break; /* if the two regions intersect, we're done */ if (m_end > r_start) { if (out_start) *out_start = max(m_start, r_start); if (out_end) *out_end = min(m_end, r_end); if (out_nid) *out_nid = memblock_get_region_node(m); if (m_start >= r_start) mi--; else ri--; *idx = (u32)mi | (u64)ri << 32; return; } } } *idx = ULLONG_MAX; } #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP /* * Common iterator interface used to define for_each_mem_range(). */ void __init_memblock __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, unsigned long *out_end_pfn, int *out_nid) { struct memblock_type *type = &memblock.memory; struct memblock_region *r; while (++*idx < type->cnt) { r = &type->regions[*idx]; if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size)) continue; if (nid == MAX_NUMNODES || nid == r->nid) break; } if (*idx >= type->cnt) { *idx = -1; return; } if (out_start_pfn) *out_start_pfn = PFN_UP(r->base); if (out_end_pfn) *out_end_pfn = PFN_DOWN(r->base + r->size); if (out_nid) *out_nid = r->nid; } /** * memblock_set_node - set node ID on memblock regions * @base: base of area to set node ID for * @size: size of area to set node ID for * @nid: node ID to set * * Set the nid of memblock memory regions in [@base,@base+@size) to @nid. * Regions which cross the area boundaries are split as necessary. * * RETURNS: * 0 on success, -errno on failure. */ int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size, int nid) { struct memblock_type *type = &memblock.memory; int start_rgn, end_rgn; int i, ret; ret = memblock_isolate_range(type, base, size, &start_rgn, &end_rgn); if (ret) return ret; for (i = start_rgn; i < end_rgn; i++) memblock_set_region_node(&type->regions[i], nid); memblock_merge_regions(type); return 0; } #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr, int nid) { phys_addr_t found; if (WARN_ON(!align)) align = __alignof__(long long); /* align @size to avoid excessive fragmentation on reserved array */ size = round_up(size, align); found = memblock_find_in_range_node(0, max_addr, size, align, nid); if (found && !memblock_reserve(found, size)) return found; return 0; } phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid) { return memblock_alloc_base_nid(size, align, MEMBLOCK_ALLOC_ACCESSIBLE, nid); } phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr) { return memblock_alloc_base_nid(size, align, max_addr, MAX_NUMNODES); } phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr) { phys_addr_t alloc; alloc = __memblock_alloc_base(size, align, max_addr); if (alloc == 0) panic("ERROR: Failed to allocate 0x%llx bytes below 0x%llx.\n", (unsigned long long) size, (unsigned long long) max_addr); return alloc; } phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align) { return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); } phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid) { phys_addr_t res = memblock_alloc_nid(size, align, nid); if (res) return res; return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); } /* * Remaining API functions */ phys_addr_t __init memblock_phys_mem_size(void) { return memblock.memory.total_size; } phys_addr_t __init memblock_mem_size(unsigned long limit_pfn) { unsigned long pages = 0; struct memblock_region *r; unsigned long start_pfn, end_pfn; for_each_memblock(memory, r) { start_pfn = memblock_region_memory_base_pfn(r); end_pfn = memblock_region_memory_end_pfn(r); start_pfn = min_t(unsigned long, start_pfn, limit_pfn); end_pfn = min_t(unsigned long, end_pfn, limit_pfn); pages += end_pfn - start_pfn; } return (phys_addr_t)pages << PAGE_SHIFT; } /* lowest address */ phys_addr_t __init_memblock memblock_start_of_DRAM(void) { return memblock.memory.regions[0].base; } phys_addr_t __init_memblock memblock_end_of_DRAM(void) { int idx = memblock.memory.cnt - 1; return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size); } void __init memblock_enforce_memory_limit(phys_addr_t limit) { unsigned long i; phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX; if (!limit) return; /* find out max address */ for (i = 0; i < memblock.memory.cnt; i++) { struct memblock_region *r = &memblock.memory.regions[i]; if (limit <= r->size) { max_addr = r->base + limit; break; } limit -= r->size; } /* truncate both memory and reserved regions */ __memblock_remove(&memblock.memory, max_addr, (phys_addr_t)ULLONG_MAX); __memblock_remove(&memblock.reserved, max_addr, (phys_addr_t)ULLONG_MAX); } static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr) { unsigned int left = 0, right = type->cnt; do { unsigned int mid = (right + left) / 2; if (addr < type->regions[mid].base) right = mid; else if (addr >= (type->regions[mid].base + type->regions[mid].size)) left = mid + 1; else return mid; } while (left < right); return -1; } int __init memblock_is_reserved(phys_addr_t addr) { return memblock_search(&memblock.reserved, addr) != -1; } int __init_memblock memblock_is_memory(phys_addr_t addr) { return memblock_search(&memblock.memory, addr) != -1; } #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP int __init_memblock memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn, unsigned long *end_pfn) { struct memblock_type *type = &memblock.memory; int mid = memblock_search(type, (phys_addr_t)pfn << PAGE_SHIFT); if (mid == -1) return -1; *start_pfn = type->regions[mid].base >> PAGE_SHIFT; *end_pfn = (type->regions[mid].base + type->regions[mid].size) >> PAGE_SHIFT; return type->regions[mid].nid; } #endif /** * memblock_is_region_memory - check if a region is a subset of memory * @base: base of region to check * @size: size of region to check * * Check if the region [@base, @base+@size) is a subset of a memory block. * * RETURNS: * 0 if false, non-zero if true */ int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size) { int idx = memblock_search(&memblock.memory, base); phys_addr_t end = base + memblock_cap_size(base, &size); if (idx == -1) return 0; return memblock.memory.regions[idx].base <= base && (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size) >= end; } int __init_memblock memblock_overlaps_memory(phys_addr_t base, phys_addr_t size) { memblock_cap_size(base, &size); return memblock_overlaps_region(&memblock.memory, base, size) >= 0; } /** * memblock_is_region_reserved - check if a region intersects reserved memory * @base: base of region to check * @size: size of region to check * * Check if the region [@base, @base+@size) intersects a reserved memory block. * * RETURNS: * 0 if false, non-zero if true */ int __init_memblock memblock_is_region_reserved(phys_addr_t base, phys_addr_t size) { memblock_cap_size(base, &size); return memblock_overlaps_region(&memblock.reserved, base, size) >= 0; } void __init_memblock memblock_trim_memory(phys_addr_t align) { int i; phys_addr_t start, end, orig_start, orig_end; struct memblock_type *mem = &memblock.memory; for (i = 0; i < mem->cnt; i++) { orig_start = mem->regions[i].base; orig_end = mem->regions[i].base + mem->regions[i].size; start = round_up(orig_start, align); end = round_down(orig_end, align); if (start == orig_start && end == orig_end) continue; if (start < end) { mem->regions[i].base = start; mem->regions[i].size = end - start; } else { memblock_remove_region(mem, i); i--; } } } void __init_memblock memblock_set_current_limit(phys_addr_t limit) { memblock.current_limit = limit; } static void __init_memblock memblock_dump(struct memblock_type *type, char *name) { unsigned long long base, size; int i; pr_info(" %s.cnt = 0x%lx\n", name, type->cnt); for (i = 0; i < type->cnt; i++) { struct memblock_region *rgn = &type->regions[i]; char nid_buf[32] = ""; base = rgn->base; size = rgn->size; #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP if (memblock_get_region_node(rgn) != MAX_NUMNODES) snprintf(nid_buf, sizeof(nid_buf), " on node %d", memblock_get_region_node(rgn)); #endif pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes%s\n", name, i, base, base + size - 1, size, nid_buf); } } void __init_memblock __memblock_dump_all(void) { pr_info("MEMBLOCK configuration:\n"); pr_info(" memory size = %#llx reserved size = %#llx\n", (unsigned long long)memblock.memory.total_size, (unsigned long long)memblock.reserved.total_size); memblock_dump(&memblock.memory, "memory"); memblock_dump(&memblock.reserved, "reserved"); } void __init memblock_allow_resize(void) { memblock_can_resize = 1; } static int __init early_memblock(char *p) { if (p && strstr(p, "debug")) memblock_debug = 1; return 0; } early_param("memblock", early_memblock); #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) static int memblock_debug_show(struct seq_file *m, void *private) { struct memblock_type *type = m->private; struct memblock_region *reg; int i; for (i = 0; i < type->cnt; i++) { reg = &type->regions[i]; seq_printf(m, "%4d: ", i); if (sizeof(phys_addr_t) == 4) seq_printf(m, "0x%08lx..0x%08lx\n", (unsigned long)reg->base, (unsigned long)(reg->base + reg->size - 1)); else seq_printf(m, "0x%016llx..0x%016llx\n", (unsigned long long)reg->base, (unsigned long long)(reg->base + reg->size - 1)); } return 0; } static int memblock_debug_open(struct inode *inode, struct file *file) { return single_open(file, memblock_debug_show, inode->i_private); } static const struct file_operations memblock_debug_fops = { .open = memblock_debug_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int __init memblock_init_debugfs(void) { struct dentry *root = debugfs_create_dir("memblock", NULL); if (!root) return -ENXIO; debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops); debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops); return 0; } __initcall(memblock_init_debugfs); #endif /* CONFIG_DEBUG_FS */
KangDroid/android_kernel_moto_shamu
mm/memblock.c
C
gpl-2.0
34,128
const unsigned char dumpbc[41010]={ 0x49,0x46,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x08,0x00,0x00,0x00, 0x7a,0x0c,0x00,0x00,0xff,0xff,0xff,0xff,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x11,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x19,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0x11,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0xc0,0xa8, 0x02,0x01,0x11,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x11,0x00,0x00,0x00,0xc0,0xa8, 0x00,0x01,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00, 0x00,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00, 0x00,0x00,0x1e,0x02,0x02,0x00,0x05,0x00,0x00,0x00,0x2e,0x05,0x00,0x00,0x00,0x2e, 0x05,0x00,0x00,0x00,0x2e,0x05,0x00,0x00,0x00,0x2e,0x05,0x00,0x00,0x00,0x3a,0x05, 0x00,0x00,0x00,0x2e,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x2e,0x01,0x00,0x00, 0x00,0x05,0x00,0x00,0x00,0x2e,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x20,0x09, 0x00,0x00,0x00,0x20,0x20,0x05,0x00,0x00,0x00,0x20,0x05,0x00,0x00,0x00,0x20,0x09, 0x00,0x00,0x00,0x20,0x20,0x05,0x00,0x00,0x00,0x2e,0x01,0x00,0x00,0x00,0x41,0x00, 0x00,0x00,0x23,0x23,0x20,0x44,0x55,0x4d,0x50,0x53,0x43,0x41,0x4e,0x20,0x3e,0x3e, 0x3e,0x3e,0x21,0x00,0x00,0x00,0x23,0x23,0x20,0x53,0x43,0x41,0x4e,0x20,0x11,0x00, 0x00,0x00,0x6d,0x61,0x63,0x3a,0x19,0x00,0x00,0x00,0x62,0x73,0x73,0x69,0x64,0x3a, 0x15,0x00,0x00,0x00,0x72,0x73,0x73,0x69,0x3a,0x21,0x00,0x00,0x00,0x63,0x68,0x61, 0x6e,0x6e,0x65,0x6c,0x3a,0x21,0x00,0x00,0x00,0x72,0x61,0x74,0x65,0x73,0x65,0x74, 0x3a,0x2d,0x00,0x00,0x00,0x65,0x6e,0x63,0x72,0x79,0x70,0x74,0x69,0x6f,0x6e,0x3a, 0x00,0x00,0x00,0x00,0x52,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x5c,0x00,0x00,0x00, 0x64,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0xb4,0x00,0x00,0x00, 0xb6,0x00,0x00,0x00,0xb8,0x00,0x00,0x00,0x38,0x01,0x00,0x00,0x3a,0x01,0x00,0x00, 0x42,0x01,0x00,0x00,0x46,0x01,0x00,0x00,0x52,0x01,0x00,0x00,0x5e,0x01,0x00,0x00, 0x9e,0x01,0x00,0x00,0xa0,0x01,0x00,0x00,0xff,0xff,0xff,0xff,0x55,0x00,0x00,0x00, 0x23,0x23,0x20,0x73,0x61,0x76,0x65,0x20,0x63,0x6f,0x6e,0x66,0x69,0x67,0x75,0x72, 0x61,0x74,0x69,0x6f,0x6e,0x21,0x00,0x00,0x00,0x63,0x6f,0x6e,0x66,0x2e,0x62,0x69, 0x6e,0x21,0x00,0x00,0x00,0x63,0x6f,0x6e,0x66,0x2e,0x62,0x69,0x6e,0x05,0x00,0x00, 0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x3d,0x00,0x00,0x00,0xaa,0xaa,0x03,0x00,0x00,0x00,0x08,0x06,0x00,0x01, 0x08,0x00,0x06,0x04,0x00,0x4d,0x00,0x00,0x00,0x66,0x6f,0x75,0x6e,0x64,0x20,0x4d, 0x41,0x43,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x20,0x3a,0x20,0x09,0x00,0x00,0x00, 0x3c,0x61,0x31,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x20,0x73,0x75,0x62,0x6e,0x65, 0x74,0x20,0x51,0x00,0x00,0x00,0xaa,0xaa,0x03,0x00,0x00,0x00,0x08,0x00,0x45,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x11,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x11,0x09,0x00,0x00,0x00, 0x3e,0x75,0xff,0xff,0xff,0xff,0x09,0x00,0x00,0x00,0x3c,0x75,0x02,0x00,0x00,0x00, 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00, 0x40,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x01,0x00, 0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0xfe,0xff,0xff,0xff,0x04,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x51,0x00,0x00,0x00, 0xaa,0xaa,0x03,0x00,0x00,0x00,0x08,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x64,0x06,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x02,0x04,0x05,0xb4, 0x09,0x00,0x00,0x00,0x00,0x06,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x31,0x00, 0x00,0x00,0x23,0x23,0x20,0x73,0x65,0x6e,0x64,0x63,0x6c,0x6f,0x73,0x65,0x05,0x00, 0x00,0x00,0x74,0x15,0x00,0x00,0x00,0x73,0x74,0x73,0x79,0x6e,0x25,0x00,0x00,0x00, 0x23,0x23,0x62,0x61,0x64,0x20,0x61,0x63,0x6b,0x15,0x00,0x00,0x00,0x23,0x23,0x62, 0x73,0x2f,0x15,0x00,0x00,0x00,0x53,0x54,0x46,0x49,0x4e,0x02,0x00,0x00,0x00,0x04, 0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x0d, 0x00,0x00,0x00,0x01,0x01,0x06,0x19,0x00,0x00,0x00,0x63,0x82,0x53,0x63,0x35,0x01, 0x0d,0x00,0x00,0x00,0x3d,0x07,0x01,0x39,0x00,0x00,0x00,0x0c,0x07,0x50,0x61,0x62, 0x63,0x64,0x65,0x66,0x37,0x03,0x01,0x03,0x06,0x09,0x00,0x00,0x00,0x36,0x04,0x09, 0x00,0x00,0x00,0x32,0x04,0x05,0x00,0x00,0x00,0xff,0x05,0x00,0x00,0x00,0xff,0x0d, 0x00,0x00,0x00,0x02,0x01,0x06,0x19,0x00,0x00,0x00,0x63,0x82,0x53,0x63,0x35,0x01, 0x09,0x00,0x00,0x00,0x36,0x04,0x21,0x00,0x00,0x00,0x33,0x04,0x00,0x01,0x51,0x80, 0x01,0x04,0x09,0x00,0x00,0x00,0x03,0x04,0x09,0x00,0x00,0x00,0x06,0x04,0x1d,0x00, 0x00,0x00,0x0f,0x04,0x68,0x6f,0x6d,0x65,0xff,0x15,0x00,0x00,0x00,0x3c,0x64,0x68, 0x63,0x70,0x51,0x00,0x00,0x00,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e, 0x3e,0x3e,0x3e,0x3e,0x3e,0x4f,0x46,0x46,0x45,0x52,0x49,0x00,0x00,0x00,0x3e,0x3e, 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x41,0x43,0x4b, 0x29,0x00,0x00,0x00,0x73,0x65,0x72,0x76,0x65,0x72,0x20,0x20,0x20,0x20,0x29,0x00, 0x00,0x00,0x69,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x29,0x00,0x00,0x00, 0x74,0x79,0x70,0x65,0x20,0x20,0x20,0x20,0x20,0x20,0x29,0x00,0x00,0x00,0x6c,0x65, 0x61,0x73,0x65,0x74,0x69,0x6d,0x65,0x20,0x29,0x00,0x00,0x00,0x73,0x75,0x62,0x6d, 0x61,0x73,0x6b,0x20,0x20,0x20,0x29,0x00,0x00,0x00,0x64,0x6e,0x73,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x29,0x00,0x00,0x00,0x67,0x61,0x74,0x65,0x77,0x61,0x79,0x20, 0x20,0x20,0x15,0x00,0x00,0x00,0x3c,0x64,0x68,0x63,0x70,0x5d,0x00,0x00,0x00,0x3e, 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x44,0x49, 0x53,0x43,0x4f,0x56,0x45,0x52,0x59,0x00,0x00,0x00,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e, 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x52,0x45,0x51,0x55,0x45,0x53,0x54, 0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x6e,0x20,0x05,0x00, 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x2e,0x05,0x00,0x00, 0x00,0x2e,0x05,0x00,0x00,0x00,0x2e,0x05,0x00,0x00,0x00,0x2e,0x29,0x00,0x00,0x00, 0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00, 0x01,0x00,0x01,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00, 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x11,0x00,0x00,0x00,0x0d, 0x0a,0x0d,0x0a,0x1d,0x00,0x00,0x00,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x05,0x00, 0x00,0x00,0x2f,0x05,0x00,0x00,0x00,0x3a,0x05,0x00,0x00,0x00,0x2f,0x85,0x00,0x00, 0x00,0x66,0x6f,0x75,0x6e,0x64,0x20,0x69,0x70,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e, 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e, 0x3e,0x3e,0x1d,0x00,0x00,0x00,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x05,0x00,0x00, 0x00,0x3a,0x05,0x00,0x00,0x00,0x20,0x11,0x01,0x00,0x00,0x20,0x48,0x54,0x54,0x50, 0x2f,0x31,0x2e,0x30,0x0d,0x0a,0x55,0x73,0x65,0x72,0x2d,0x41,0x67,0x65,0x6e,0x74, 0x3a,0x20,0x4d,0x54,0x4c,0x0d,0x0a,0x50,0x72,0x61,0x67,0x6d,0x61,0x3a,0x20,0x6e, 0x6f,0x2d,0x63,0x61,0x63,0x68,0x65,0x0d,0x0a,0x49,0x63,0x79,0x2d,0x4d,0x65,0x74, 0x61,0x44,0x61,0x74,0x61,0x3a,0x31,0x0d,0x0a,0x48,0x6f,0x73,0x74,0x3a,0x20,0x09, 0x00,0x00,0x00,0x0d,0x0a,0x09,0x00,0x00,0x00,0x0d,0x0a,0x41,0x00,0x00,0x00,0x43, 0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x6c,0x65,0x6e,0x67,0x74,0x68,0x3a,0x20,0x11, 0x00,0x00,0x00,0x0d,0x0a,0x0d,0x0a,0x11,0x00,0x00,0x00,0x0d,0x0a,0x0d,0x0a,0xff, 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0x05,0x00,0x00,0x00,0x21,0x2d,0x00,0x00,0x00,0x6d,0x6b,0x72,0x69, 0x66,0x66,0x20,0x6c,0x65,0x6e,0x3d,0x11,0x00,0x00,0x00,0x52,0x49,0x46,0x46,0x81, 0x00,0x00,0x00,0x57,0x41,0x56,0x45,0x66,0x6d,0x74,0x20,0x14,0x00,0x00,0x00,0x11, 0x00,0x01,0x00,0x40,0x1f,0x00,0x00,0xd7,0x0f,0x00,0x00,0x00,0x01,0x04,0x00,0x02, 0x00,0xf9,0x01,0x21,0x00,0x00,0x00,0x66,0x61,0x63,0x74,0x04,0x00,0x00,0x00,0x11, 0x00,0x00,0x00,0x64,0x61,0x74,0x61,0x19,0x00,0x00,0x00,0x72,0x65,0x63,0x6f,0x72, 0x64,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x71,0x02, 0x00,0x00,0x35,0x0c,0x00,0xe8,0x03,0x00,0x00,0x20,0x4e,0x00,0x00,0xff,0xff,0xff, 0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x23,0x23,0x23, 0x77,0x61,0x76,0x73,0x74,0x6f,0x70,0x4d,0x00,0x00,0x00,0x23,0x23,0x23,0x77,0x61, 0x76,0x20,0x64,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x20,0x65,0x6e,0x64,0x71,0x00, 0x00,0x00,0x3e,0x3e,0x3e,0x3e,0x62,0x75,0x66,0x66,0x65,0x72,0x69,0x6e,0x67,0x2e, 0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0xa5,0x00, 0x00,0x00,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e, 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3c, 0x65,0x6e,0x64,0x20,0x6f,0x66,0x20,0x66,0x69,0x6c,0x65,0x61,0x00,0x00,0x00,0x0a, 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x68,0x74, 0x74,0x70,0x20,0x77,0x61,0x69,0x74,0x0d,0x00,0x00,0x00,0x47,0x45,0x54,0x45,0x00, 0x00,0x00,0x23,0x23,0x23,0x23,0x77,0x61,0x76,0x68,0x74,0x74,0x70,0x20,0x61,0x62, 0x6f,0x72,0x74,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x22,0x00,0x00,0x00,0xa0,0x0f,0x00,0x00,0x04,0x00,0x00,0x00,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0x21,0x00,0x00,0x00,0x65,0x61,0x72,0x52,0x65,0x73,0x65,0x74,0x21, 0x00,0x00,0x00,0x6e,0x65,0x77,0x20,0x76,0x61,0x6c,0x20,0x39,0x00,0x00,0x00,0x41, 0x63,0x71,0x75,0x69,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x09,0x00,0x00, 0x00,0x2c,0x20,0x21,0x00,0x00,0x00,0x62,0x72,0x6f,0x6b,0x65,0x6e,0x20,0x3a,0x1d, 0x00,0x00,0x00,0x65,0x61,0x72,0x53,0x74,0x6f,0x70,0x19,0x00,0x00,0x00,0x65,0x61, 0x72,0x47,0x6f,0x20,0x25,0x00,0x00,0x00,0x20,0x62,0x72,0x6f,0x6b,0x65,0x6e,0x20, 0x21,0x19,0x00,0x00,0x00,0x65,0x61,0x72,0x47,0x6f,0x20,0x11,0x00,0x00,0x00,0x20, 0x74,0x6f,0x20,0x15,0x00,0x00,0x00,0x20,0x64,0x69,0x72,0x20,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x01, 0x00,0xfe,0x01,0x00,0x00,0xfe,0xff,0x01,0xfe,0x01,0x00,0x00,0xfe,0x01,0xfe,0x01, 0xfe,0xff,0x01,0x00,0xfe,0xff,0xff,0x01,0x00,0x01,0x01,0x01,0x00,0x01,0xff,0x01, 0x00,0xff,0x01,0x01,0x00,0xff,0xff,0x01,0xfe,0x01,0x01,0x01,0xfe,0x01,0xff,0x01, 0xfe,0xff,0x01,0x01,0x00,0x00,0xff,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x14,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x20,0x3a,0x20,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x08, 0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xff, 0xff,0xff,0xff,0x05,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x05,0x00,0x00,0x00,0x3a,0x01,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x77,0x69,0x66, 0x69,0x20,0x73,0x74,0x61,0x74,0x65,0x3d,0x21,0x00,0x00,0x00,0x4e,0x61,0x62,0x61, 0x7a,0x74,0x61,0x67,0x55,0x00,0x00,0x00,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d, 0x2d,0x2d,0x2d,0x2d,0x2d,0x67,0x6f,0x6d,0x61,0x73,0x74,0x65,0x72,0x5d,0x00,0x00, 0x00,0x3a,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x67, 0x6f,0x73,0x74,0x61,0x74,0x69,0x6f,0x6e,0x4d,0x00,0x00,0x00,0x2d,0x2d,0x2d,0x2d, 0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x6d,0x61,0x73,0x74,0x65,0x72,0x45, 0x00,0x00,0x00,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d, 0x64,0x68,0x63,0x70,0x51,0x00,0x00,0x00,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d, 0x2d,0x2d,0x2d,0x2d,0x2d,0x73,0x74,0x61,0x74,0x69,0x6f,0x6e,0x5d,0x00,0x00,0x00, 0x3a,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x67,0x6f, 0x73,0x74,0x61,0x74,0x69,0x6f,0x6e,0x1c,0x00,0x00,0x00,0x03,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04, 0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0a, 0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x12, 0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x1e, 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x2a, 0x00,0x00,0x00,0x2e,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x3a, 0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x42,0x00,0x00,0x00,0x46,0x00,0x00,0x00,0x4a, 0x00,0x00,0x00,0x4e,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x5c, 0x00,0x00,0x00,0x62,0x00,0x00,0x00,0x66,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x70, 0x00,0x00,0x00,0x76,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x86, 0x00,0x00,0x00,0x8c,0x00,0x00,0x00,0x92,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x9e, 0x00,0x00,0x00,0xa2,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0xae,0x00,0x00,0x00,0xb4, 0x00,0x00,0x00,0xba,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0xc6,0x00,0x00,0x00,0xce, 0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0xda,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0xe6, 0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xf2,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0xcd, 0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01, 0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x5d,0x00,0xff,0x51,0x03,0x10,0x59,0x43, 0x00,0xc0,0x09,0x02,0x90,0x58,0x5a,0x12,0x48,0x62,0x31,0x60,0x62,0x0a,0x80,0x58, 0x78,0x2c,0x90,0x58,0x52,0x12,0x80,0x60,0x54,0x43,0x90,0x60,0x49,0x04,0x80,0x58, 0x6c,0x33,0x90,0x58,0x45,0x05,0x80,0x60,0x6a,0x81,0x00,0x90,0x60,0x40,0x22,0x80, 0x58,0x6f,0x7a,0x90,0x5d,0x58,0x03,0x80,0x48,0x49,0x04,0x60,0x52,0x0b,0x90,0x4f, 0x48,0x84,0x24,0x80,0x5d,0x4d,0x11,0x4f,0x76,0x81,0x3a,0x90,0x30,0x01,0x74,0x80, 0x30,0x40,0x00,0xff,0x2f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x08,0x00, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x25,0x00,0x00,0x00,0x62,0x72,0x6f,0x61,0x64,0x63,0x61,0x73,0x74,0x80, 0x38,0x01,0x00,0xfe,0xff,0xff,0xff,0xfc,0xff,0xff,0xff,0x78,0x00,0x00,0x00,0x78, 0x00,0x00,0x00,0xb0,0x04,0x00,0x00,0x02,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x24, 0x00,0x00,0x00,0x26,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x23,0x00,0x00,0x00,0x63, 0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x3e,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0xe4, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xe4,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x3e,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x18, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x63,0x00,0x00,0x00,0xbe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x24, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x7e,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0xbe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xbe,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x00,0x00,0xfc, 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x04,0x00,0x00,0x00,0xe6,0x01,0x00,0x00,0x88, 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x0c,0x00,0x00,0x00,0x0e, 0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x54, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0xb4,0x01,0x00,0x00,0x0a, 0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x9e,0x01,0x00,0x00,0x0c,0x00,0x00,0x00,0x14, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63, 0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x36,0x01,0x00,0x00,0x24,0x00,0x00,0x00,0xfe, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x01,0x00,0x00,0xe6, 0x01,0x00,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x36,0x01,0x00,0x00,0x24, 0x00,0x00,0x00,0xf8,0x01,0x00,0x00,0xe6,0x01,0x00,0x00,0x0a,0x00,0x00,0x00,0xfe, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x36, 0x01,0x00,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x63,0x00,0x00,0x00,0xf8,0x01,0x00,0x00,0xdc,0x01,0x00,0x00,0x8e, 0x00,0x00,0x00,0x9c,0x01,0x00,0x00,0x76,0x00,0x00,0x00,0x8a,0x00,0x00,0x00,0xaa, 0x00,0x00,0x00,0x88,0x00,0x00,0x00,0xa8,0x01,0x00,0x00,0x9c,0x00,0x00,0x00,0x4e, 0x01,0x00,0x00,0xa4,0x00,0x00,0x00,0xe6,0x01,0x00,0x00,0x96,0x00,0x00,0x00,0x32, 0x01,0x00,0x00,0x2e,0x01,0x00,0x00,0x8e,0x00,0x00,0x00,0x88,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x00,0x98,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xcc,0x00,0x00,0x00,0x98,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x32,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x66, 0x00,0x00,0x00,0x98,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32, 0x01,0x00,0x00,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x00,0x00,0x00,0xfc,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x00,0x98,0x01,0x00,0x00,0xfe, 0x01,0x00,0x00,0xcc,0x00,0x00,0x00,0x98,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x32,0x01,0x00,0x00,0xfe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x66, 0x00,0x00,0x00,0x98,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32, 0x01,0x00,0x00,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x00,0x00,0x00,0xfc,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1d,0x02,0x00,0x00,0x4d,0x54,0x68,0x64,0x00, 0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00, 0x71,0x00,0xff,0x03,0x07,0x63,0x6f,0x6d,0x70,0x72,0x69,0x73,0x00,0xff,0x51,0x03, 0x07,0xa1,0x20,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x0c,0x7a,0x90, 0x34,0x50,0x6f,0x53,0x1a,0x08,0x80,0x34,0x40,0x81,0x02,0x53,0x40,0x15,0x90,0x64, 0x27,0x81,0x02,0x54,0x37,0x08,0x80,0x64,0x40,0x81,0x02,0x54,0x40,0x15,0x90,0x34, 0x50,0x81,0x02,0x53,0x2b,0x07,0x80,0x34,0x40,0x81,0x02,0x53,0x40,0x16,0x90,0x43, 0x3f,0x81,0x02,0x64,0x60,0x07,0x80,0x43,0x40,0x81,0x02,0x64,0x40,0x15,0x90,0x54, 0x5c,0x55,0x80,0x54,0x40,0x83,0x39,0x90,0x25,0x01,0x74,0x80,0x25,0x40,0x00,0xff, 0x2f,0x00,0xc1,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00, 0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x5a,0x00,0xff,0x03,0x05, 0x73,0x74,0x6f,0x70,0x30,0x00,0xff,0x51,0x03,0x07,0xa1,0x20,0x00,0xff,0x58,0x04, 0x04,0x02,0x18,0x08,0x00,0xc9,0x00,0x00,0xc4,0x09,0x03,0x99,0x2a,0x7f,0x00,0x2c, 0x7f,0x00,0x56,0x7f,0x00,0x94,0x24,0x7f,0x00,0x28,0x64,0x00,0x2d,0x64,0x01,0x99, 0x3c,0x64,0x0a,0x84,0x24,0x40,0x01,0x28,0x40,0x01,0x2d,0x40,0x0b,0x89,0x2a,0x40, 0x00,0x56,0x40,0x01,0x2c,0x40,0x00,0x3c,0x40,0x81,0x52,0x99,0x2c,0x01,0x1a,0x89, 0x2c,0x40,0x00,0xff,0x2f,0x00,0xc5,0x02,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00, 0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x9b, 0x00,0xff,0x03,0x0b,0x63,0x6f,0x6d,0x6d,0x75,0x6e,0x69,0x6f,0x6e,0x30,0x30,0x00, 0xff,0x51,0x03,0x10,0x59,0x43,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0, 0x0c,0x02,0x90,0x60,0x67,0x04,0x48,0x6a,0x7b,0x5f,0x4d,0x12,0x80,0x60,0x65,0x2a, 0x90,0x5d,0x51,0x0b,0x80,0x5f,0x76,0x18,0x48,0x2b,0x10,0x5d,0x7f,0x07,0x90,0x60, 0x64,0x08,0x4f,0x5e,0x7c,0x5f,0x52,0x15,0x80,0x60,0x71,0x19,0x90,0x5d,0x56,0x1a, 0x80,0x5f,0x6c,0x15,0x5d,0x7f,0x0e,0x90,0x58,0x56,0x0c,0x80,0x4f,0x7c,0x14,0x90, 0x4d,0x5e,0x6e,0x80,0x58,0x73,0x01,0x90,0x5d,0x62,0x75,0x80,0x5d,0x7a,0x0d,0x4d, 0x67,0x05,0x90,0x5b,0x5a,0x05,0x54,0x60,0x2a,0x80,0x5b,0x65,0x81,0x1e,0x54,0x60, 0x51,0x90,0x58,0x60,0x15,0x4c,0x6a,0x81,0x1e,0x80,0x58,0x63,0x0e,0x4c,0x45,0x4d, 0x90,0x24,0x01,0x72,0x80,0x24,0x40,0x00,0xff,0x2f,0x00,0xc5,0x02,0x00,0x00,0x4d, 0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72, 0x6b,0x00,0x00,0x00,0x9b,0x00,0xff,0x03,0x0b,0x63,0x6f,0x6d,0x6d,0x75,0x6e,0x69, 0x6f,0x6e,0x30,0x30,0x00,0xff,0x51,0x03,0x10,0x59,0x43,0x00,0xff,0x58,0x04,0x04, 0x02,0x18,0x08,0x00,0xc0,0x0c,0x02,0x90,0x60,0x67,0x04,0x48,0x6a,0x7b,0x5f,0x4d, 0x12,0x80,0x60,0x65,0x2a,0x90,0x5d,0x51,0x0b,0x80,0x5f,0x76,0x18,0x48,0x2b,0x10, 0x5d,0x7f,0x07,0x90,0x60,0x64,0x08,0x4f,0x5e,0x7c,0x5f,0x52,0x15,0x80,0x60,0x71, 0x19,0x90,0x5d,0x56,0x1a,0x80,0x5f,0x6c,0x15,0x5d,0x7f,0x0e,0x90,0x58,0x56,0x0c, 0x80,0x4f,0x7c,0x14,0x90,0x4d,0x5e,0x6e,0x80,0x58,0x73,0x01,0x90,0x5d,0x62,0x75, 0x80,0x5d,0x7a,0x0d,0x4d,0x67,0x05,0x90,0x5b,0x5a,0x05,0x54,0x60,0x2a,0x80,0x5b, 0x65,0x81,0x1e,0x54,0x60,0x51,0x90,0x58,0x60,0x15,0x4c,0x6a,0x81,0x1e,0x80,0x58, 0x63,0x0e,0x4c,0x45,0x4d,0x90,0x24,0x01,0x72,0x80,0x24,0x40,0x00,0xff,0x2f,0x00, 0xad,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01, 0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x55,0x00,0xff,0x03,0x07,0x65,0x66, 0x66,0x61,0x63,0x65,0x30,0x00,0xff,0x51,0x03,0x10,0x59,0x43,0x00,0xff,0x58,0x04, 0x04,0x02,0x18,0x08,0x00,0x90,0x3c,0x7f,0x00,0x41,0x7f,0x00,0x48,0x7f,0x00,0x4f, 0x7f,0x00,0x54,0x7f,0x00,0xc0,0x77,0x00,0xc1,0x74,0x84,0x54,0x80,0x4f,0x40,0x40, 0x91,0x30,0x7f,0x00,0x53,0x64,0x1a,0x80,0x41,0x40,0x00,0x54,0x40,0x00,0x81,0x30, 0x40,0x00,0x53,0x40,0x3c,0x80,0x48,0x40,0x1e,0x3c,0x40,0x00,0xff,0x2f,0x00,0xdd, 0x3d,0x00,0x00,0x00,0x00,0x0f,0x6f,0x00,0x01,0x0a,0x00,0x10,0x00,0x01,0x04,0x01, 0x07,0x04,0x00,0x33,0xff,0x00,0x00,0x00,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x00, 0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0xee,0x00,0x00,0x00,0x00, 0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x03,0x00,0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x33,0xff,0x00,0x00,0x01, 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x01, 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x03,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01, 0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xee,0x00,0x00,0x00,0x01, 0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0xee,0x00,0x00,0x00,0x01, 0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x01,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x01, 0x07,0x04,0x00,0x33,0xff,0x00,0x00,0x00,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x00, 0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0xee,0x00,0x00,0x00,0x00, 0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x03,0x00,0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x33,0xff,0x00,0x00,0x01, 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x01, 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x03,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01, 0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xee,0x00,0x00,0x00,0x01, 0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0xee,0x00,0x00,0x00,0x01, 0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x01,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x0a,0x00,0x12,0x00,0x03,0x43,0x00,0x01,0x08,0x00,0x07,0x04,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00, 0x00,0x00,0x00,0x11,0x01,0x04,0x00,0x11,0x00,0x04,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x20,0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x04,0x00,0x11, 0x00,0x04,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x07,0x04,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00, 0x00,0x00,0x00,0x11,0x01,0x05,0x00,0x11,0x00,0x05,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x20,0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x04,0x00,0x11, 0x00,0x04,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x07,0x04,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xee,0x00,0x00, 0x00,0x00,0x00,0x07,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xee,0x00,0x00, 0x00,0x00,0x01,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x01,0x01,0x6b,0x00, 0x01,0x14,0x00,0x07,0x02,0x00,0xee,0x00,0x00,0x00,0x00,0x11,0x01,0x06,0x00,0x11, 0x00,0x06,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x99,0xff,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0xcc,0x00,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xff,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x05,0x00,0x11, 0x00,0x05,0x01,0x07,0x02,0xff,0xcc,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x99,0xff,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xee,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xcc,0x00,0xff,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0xff,0xff,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0xcc,0x00,0x00,0x00,0x00,0x11,0x01,0x06,0x00,0x11, 0x00,0x06,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0xcc,0x00,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xff,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0xff,0xcc,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0xcc,0x00,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xff,0xff, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x02,0x02,0x6b,0x00, 0x01,0x10,0x00,0x11,0x01,0x02,0x07,0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11, 0x00,0x02,0x07,0x11,0x01,0x02,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07, 0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x07,0x11,0x01,0x02,0x01,0x07, 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11, 0x00,0x02,0x07,0x11,0x01,0x03,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07, 0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11,0x00,0x03,0x07,0x11,0x01,0x02,0x01,0x07, 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11, 0x00,0x02,0x07,0x11,0x01,0x04,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07, 0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11,0x00,0x04,0x07,0x11,0x01,0x02,0x01,0x07, 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07, 0x01,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x11, 0x00,0x02,0x08,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x03,0x01,0x1b,0x00, 0x01,0x10,0x00,0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x02,0x07,0x07, 0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x01,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x06,0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x02,0x01,0x07, 0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11, 0x00,0x02,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x03,0xff,0x00,0x00, 0x00,0x00,0x00,0x11,0x01,0x02,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x07, 0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x01,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x06,0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x03,0x01,0x07, 0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11, 0x00,0x03,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x03,0xff,0x00,0x00, 0x00,0x00,0x00,0x11,0x01,0x02,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x07, 0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x01,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x06,0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x04,0x01,0x07, 0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11, 0x00,0x04,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x03,0xff,0x00,0x00, 0x00,0x00,0x00,0x11,0x01,0x02,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x07, 0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x01,0x07,0x03,0x00,0x00,0x00, 0x00,0x00,0x07,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x04,0x01,0x03,0x00, 0x01,0x08,0x00,0x11,0x01,0x04,0x00,0x11,0x00,0x04,0x1e,0x07,0x03,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x01,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x01,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x01,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x01,0x00,0xee,0x00, 0x00,0x00,0x01,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x0d,0x00,0x11, 0x00,0x0d,0x00,0x12,0x05,0x01,0x03,0x00,0x01,0x08,0x00,0x11,0x01,0x04,0x00,0x11, 0x00,0x04,0x1e,0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x02,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00, 0x00,0x00,0x01,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x11,0x01,0x0d,0x00,0x11,0x00,0x0d,0x01,0x13,0x00,0x01,0x0a,0x00, 0x10,0x00,0x01,0x04,0x01,0x07,0x04,0x00,0x33,0xff,0x00,0x00,0x00,0x07,0x02,0xff, 0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0x00, 0xee,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00, 0x33,0xff,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xff, 0xff,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x03,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff, 0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00, 0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x33,0xff,0x00,0x00,0x00,0x07,0x02,0xff, 0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xff,0xff,0x00,0x00,0x00,0x01,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x04,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x02,0x00, 0xee,0x00,0x00,0x00,0x00,0x07,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x04,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00, 0x33,0xff,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x04,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0xff, 0xff,0x00,0x00,0x00,0x01,0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x03,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x02,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0xff, 0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x07,0x03,0xee,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00, 0xee,0x00,0x00,0x00,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x02,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x33,0xff,0x00,0x00,0x01,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x01,0x13,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x35,0x0d, 0x00,0x00,0x00,0x04,0xff,0x66,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x01,0xff,0xff, 0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x02,0xff,0xff,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01, 0x03,0xff,0xff,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x02, 0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x01,0xff, 0xff,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x04,0xff,0x66,0x00,0x01,0x00,0x00,0x00, 0x00,0x01,0x03,0xff,0xff,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x02,0xff,0xff,0x00, 0x00,0x00,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x01,0xff,0xff,0x00,0x01, 0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x04, 0xff,0x66,0x00,0x00,0x01,0xff,0xff,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x02,0xff, 0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x03,0xff,0xff, 0x00,0x01,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00, 0x00,0x02,0xff,0xff,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00, 0x01,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00,0x04,0xff,0x66,0x00,0x00,0x02,0xff,0xff,0x00,0x01,0x02,0x00, 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x03,0xff,0xff,0x00,0x00,0x02,0xff,0xff, 0x00,0x00,0x01,0xff,0xff,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x00,0x01,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x02, 0x00,0x00,0x00,0x00,0x00,0x04,0xff,0x66,0x00,0x02,0x00,0xff,0x00,0x00,0x01,0x03, 0xff,0xff,0x00,0x00,0x01,0xff,0xff,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00, 0x00,0x00,0x00,0x02,0xff,0xff,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0xff,0x66,0x00,0x00,0x03,0xff,0xff,0x00, 0x00,0x00,0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x02,0xff,0xff,0x00,0x01, 0x02,0x00,0x00,0x00,0x00,0x01,0xff,0xff,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x02,0x04,0x00,0x00,0x00,0x00,0x01,0xff,0xff,0x00,0x00,0x00,0xff, 0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x02,0xff,0xff,0x00,0x01,0x02,0x00,0x00, 0x00,0x00,0x04,0xff,0x66,0x00,0x00,0x03,0xff,0xff,0x00,0x01,0x04,0x00,0x00,0x00, 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x04,0xff,0xff,0x00,0x00, 0x03,0xff,0x00,0x00,0x00,0x01,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x03, 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00, 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x03,0xff,0x00,0x00,0x01,0x03,0x00,0x00, 0x00,0x00,0x02,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x02,0x00,0x00,0x00, 0x00,0x01,0xff,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00,0x01,0x04,0xff,0xff,0x00,0x01,0x00,0xff,0xff,0xff,0x03,0x00, 0x00,0x00,0x00,0x01,0x01,0xff,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x02,0xff, 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0x00,0x00, 0x00,0x00,0x03,0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00, 0x01,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x03,0xff,0x00,0x00,0x00, 0x01,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x00,0x00, 0x00,0x00,0x01,0x03,0xff,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x00,0x01,0xff,0x00, 0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xff,0x02,0x04,0xff,0xff,0x00,0x00,0x03,0xff,0x00,0x00,0x00, 0x01,0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x00,0xff, 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x01,0x03,0xff,0x00, 0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x04,0xff,0xff,0x00, 0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x01,0xff,0x00,0x00,0x01, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0xff,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0x01,0x01,0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00, 0x00,0x00,0x00,0x03,0xff,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x02,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0b, 0x00,0x00,0x00,0x85,0x0d,0x00,0x00,0x00,0x04,0xff,0xff,0x00,0x00,0x03,0xff,0x00, 0x00,0x00,0x01,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00, 0x00,0x01,0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00,0x01,0x03,0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x02, 0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x02,0x00,0x00,0x00,0x00,0x01,0xff, 0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x01,0x04,0xff,0xff,0x00,0x01,0x00,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00, 0x01,0x01,0xff,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x03, 0xff,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x02,0xff, 0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x03,0xff,0x00,0x00,0x00,0x01,0xff,0x00, 0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01, 0x03,0xff,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x00,0x01,0xff,0x00,0x00,0x01,0x03, 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0xff, 0xff,0xff,0x02,0x04,0xff,0xff,0x00,0x00,0x03,0xff,0x00,0x00,0x00,0x01,0xff,0x00, 0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x00,0xff,0xff,0xff,0x03, 0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x01,0x03,0xff,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x04,0xff,0xff,0x00,0x00,0x02,0xff, 0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x01,0xff,0x00,0x00,0x01,0x01,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff, 0x01,0x01,0x00,0x00,0x00,0x00,0x02,0xff,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00, 0x03,0xff,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x06,0x04,0xff,0x00,0x00,0x00,0x03,0xff,0xff,0xff,0x00,0x01,0xff, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x01,0x02,0xff,0xff,0xff,0x01,0x00,0x00,0x00, 0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00, 0x01,0x03,0xff,0xff,0xff,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0xff,0xff,0xff,0x00, 0x00,0xff,0xff,0x00,0x01,0x01,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x04,0xff, 0x00,0x00,0x02,0x00,0xff,0xff,0x00,0x01,0x01,0xff,0xff,0xff,0x01,0x00,0x00,0x00, 0x00,0x00,0x02,0xff,0xff,0xff,0x01,0x03,0xff,0xff,0xff,0x01,0x01,0x00,0x00,0x00, 0x01,0x04,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00, 0x00,0xff,0xff,0x00,0x01,0x02,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x03, 0xff,0xff,0xff,0x00,0x01,0xff,0xff,0xff,0x01,0x04,0xff,0x00,0x00,0x01,0x02,0x00, 0x00,0x00,0x01,0x02,0xff,0xff,0xff,0x01,0x00,0xff,0xff,0x00,0x01,0x03,0x00,0x00, 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x04,0x00,0x00,0x00,0x02,0x03,0xff,0xff,0xff,0x00,0x02,0xff,0xff,0xff,0x00, 0x01,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x01,0x04,0xff,0x00,0x00,0x01,0x00, 0x00,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x01,0x00, 0x00,0x00,0x03,0x00,0xff,0xff,0x00,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xff,0xff,0xff,0x01,0x02,0xff,0xff,0xff,0x01,0x03,0xff,0xff,0xff, 0x01,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x01, 0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x03,0xff,0xff,0xff,0x01,0x02, 0xff,0xff,0xff,0x01,0x01,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0xff, 0xff,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x04,0xff,0x00,0x00,0x03,0x03,0xff,0xff,0xff,0x00,0x01,0xff,0xff,0xff, 0x01,0x02,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x02,0x03,0x00,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x02, 0x00,0x00,0x00,0x03,0x00,0xff,0xff,0x00,0x01,0x04,0xff,0x00,0x00,0x00,0x03,0xff, 0xff,0xff,0x00,0x01,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x02,0xff,0xff, 0xff,0x02,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00, 0x01,0x00,0xff,0xff,0x00,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04, 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x03, 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0xed,0x09,0x00,0x00, 0x00,0x04,0xff,0x00,0x00,0x00,0x03,0xff,0xff,0xff,0x00,0x01,0xff,0xff,0xff,0x00, 0x00,0xff,0xff,0x00,0x01,0x02,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x01,0x03, 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x03,0xff, 0xff,0xff,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0xff,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x01,0x01,0xff,0xff,0xff,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x02,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x04,0xff,0x00,0x00,0x02, 0x04,0x00,0x00,0x00,0x42,0x04,0xff,0xcc,0x00,0x00,0x01,0xff,0xcc,0x00,0x00,0x00, 0xff,0x00,0x00,0x01,0x02,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0xff, 0xcc,0x00,0x02,0x01,0x00,0x00,0x00,0x00,0x04,0xff,0xcc,0x00,0x01,0x02,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, 0x01,0x00,0xff,0x00,0x00,0x01,0x04,0xff,0xcc,0x00,0x00,0x03,0xff,0xcc,0x00,0x01, 0x02,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x01,0xff,0xcc,0x00,0x01,0x03, 0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00, 0x00,0x00,0x01,0x00,0xff,0x00,0x00,0x01,0x01,0xff,0xcc,0x00,0x01,0x04,0xff,0xcc, 0x00,0x00,0x02,0xff,0xcc,0x00,0x01,0x03,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00, 0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00, 0x04,0xff,0xcc,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x04, 0x00,0x00,0x00,0x01,0x03,0xff,0xcc,0x00,0x01,0x04,0xff,0xcc,0x00,0x00,0x02,0xff, 0xcc,0x00,0x01,0x01,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, 0x00,0x00,0xff,0x00,0x00,0x04,0x04,0xff,0xcc,0x00,0x00,0x03,0xff,0xcc,0x00,0x00, 0x01,0xff,0xcc,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x02,0xff,0xcc,0x00,0x01,0x04, 0x00,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0xff, 0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x04,0xff,0xcc,0x00,0x01,0x03,0xff,0xcc, 0x00,0x00,0x01,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0xff,0xcc,0x00, 0x02,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x04,0xff,0xcc,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03, 0xff,0xcc,0x00,0x00,0x01,0xff,0xcc,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x02,0xff, 0xcc,0x00,0x02,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00, 0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0xff,0xcc,0x00,0x00,0x01,0xff,0xcc,0x00, 0x01,0x04,0xff,0xcc,0x00,0x00,0x02,0xff,0xcc,0x00,0x01,0x00,0xff,0x00,0x00,0x01, 0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02, 0x00,0x00,0x00,0x01,0x04,0xff,0xcc,0x00,0x00,0x03,0xff,0xcc,0x00,0x00,0x01,0xff, 0xcc,0x00,0x01,0x02,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00, 0x00,0x04,0xff,0xcc,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x03,0xff,0xcc,0x00,0x00, 0x01,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0xff,0xcc,0x00,0x02,0x03, 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x02,0x00,0x00, 0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x5d, 0x08,0x00,0x00,0x00,0x04,0xff,0xcc,0x00,0x00,0x01,0xff,0xcc,0x00,0x00,0x00,0xff, 0x00,0x00,0x01,0x02,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0xff,0xcc, 0x00,0x02,0x01,0x00,0x00,0x00,0x00,0x04,0xff,0xcc,0x00,0x01,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01, 0x00,0xff,0x00,0x00,0x01,0x04,0xff,0xcc,0x00,0x00,0x03,0xff,0xcc,0x00,0x01,0x02, 0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x01,0xff,0xcc,0x00,0x01,0x03,0x00, 0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00, 0x00,0x01,0x00,0xff,0x00,0x00,0x01,0x01,0xff,0xcc,0x00,0x01,0x04,0xff,0xcc,0x00, 0x00,0x02,0xff,0xcc,0x00,0x01,0x03,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x01, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x04, 0xff,0xcc,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x04,0x00, 0x00,0x00,0x01,0x03,0xff,0xcc,0x00,0x01,0x04,0xff,0xcc,0x00,0x00,0x02,0xff,0xcc, 0x00,0x01,0x01,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00, 0x00,0xff,0x00,0x00,0x04,0x04,0xff,0xcc,0x00,0x00,0x03,0xff,0xcc,0x00,0x00,0x01, 0xff,0xcc,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x02,0xff,0xcc,0x00,0x01,0x04,0x00, 0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0xff,0x00, 0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x04,0xff,0xcc,0x00,0x01,0x03,0xff,0xcc,0x00, 0x00,0x01,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0xff,0xcc,0x00,0x02, 0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04, 0xff,0xcc,0x00,0x01,0x02,0x00,0x00,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x03,0xff, 0xcc,0x00,0x00,0x01,0xff,0xcc,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x02,0xff,0xcc, 0x00,0x02,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x03,0xff,0xcc,0x00,0x00,0x01,0xff,0xcc,0x00,0x01, 0x04,0xff,0xcc,0x00,0x00,0x02,0xff,0xcc,0x00,0x01,0x00,0xff,0x00,0x00,0x01,0x04, 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00, 0x00,0x00,0x01,0x04,0xff,0xcc,0x00,0x00,0x03,0xff,0xcc,0x00,0x00,0x01,0xff,0xcc, 0x00,0x01,0x02,0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00, 0x04,0xff,0xcc,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0x03,0xff,0xcc,0x00,0x00,0x01, 0xff,0xcc,0x00,0x01,0x04,0x00,0x00,0x00,0x00,0x02,0xff,0xcc,0x00,0x02,0x03,0x00, 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x00,0x03,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,0x01, 0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0, 0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x2a,0x00,0xff,0x03,0x07,0x31,0x6e,0x6f,0x74, 0x65,0x41,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02, 0x18,0x08,0x00,0xc0,0x09,0x14,0x90,0x51,0x78,0x82,0x4a,0x80,0x51,0x49,0x00,0xff, 0x2f,0x00,0x01,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00, 0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x2a,0x00,0xff,0x03,0x07, 0x31,0x6e,0x6f,0x74,0x65,0x42,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff, 0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x0a,0x90,0x5f,0x76,0x82,0x5d,0x80, 0x5f,0x4d,0x00,0xff,0x2f,0x00,0x05,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00, 0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x2b, 0x00,0xff,0x03,0x08,0x31,0x6e,0x6f,0x74,0x65,0x42,0x62,0x34,0x00,0xff,0x51,0x03, 0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x14,0x90, 0x52,0x64,0x82,0x7a,0x80,0x52,0x49,0x00,0xff,0x2f,0x00,0x01,0x01,0x00,0x00,0x4d, 0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72, 0x6b,0x00,0x00,0x00,0x2a,0x00,0xff,0x03,0x07,0x31,0x6e,0x6f,0x74,0x65,0x43,0x36, 0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00, 0xc0,0x09,0x0d,0x90,0x54,0x7a,0x83,0x39,0x80,0x54,0x76,0x00,0xff,0x2f,0x00,0xfd, 0x00,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01, 0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x29,0x00,0xff,0x03,0x06,0x4e,0x6f,0x74, 0x65,0x31,0x41,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02, 0x18,0x08,0x00,0xc0,0x09,0x11,0x90,0x4c,0x7f,0x82,0x56,0x80,0x4c,0x76,0x00,0xff, 0x2f,0x00,0x05,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00, 0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x2b,0x00,0xff,0x03,0x08, 0x31,0x6e,0x6f,0x74,0x65,0x46,0x23,0x34,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00, 0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x12,0x90,0x4e,0x6e,0x82,0x46, 0x80,0x4e,0x49,0x00,0xff,0x2f,0x00,0x01,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00, 0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00, 0x2a,0x00,0xff,0x03,0x07,0x31,0x6e,0x6f,0x74,0x65,0x46,0x35,0x00,0xff,0x51,0x03, 0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x12,0x90, 0x59,0x70,0x81,0x7f,0x80,0x59,0x49,0x00,0xff,0x2f,0x00,0x01,0x01,0x00,0x00,0x4d, 0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72, 0x6b,0x00,0x00,0x00,0x2a,0x00,0xff,0x03,0x07,0x31,0x6e,0x6f,0x74,0x65,0x47,0x35, 0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00, 0xc0,0x09,0x0f,0x90,0x5b,0x7b,0x82,0x20,0x80,0x5b,0x4d,0x00,0xff,0x2f,0x00,0x29, 0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01, 0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x34,0x00,0xff,0x03,0x0a,0x32,0x6e,0x6f, 0x74,0x65,0x73,0x43,0x36,0x43,0x34,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff, 0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x11,0x90,0x60,0x63,0x81,0x06,0x48, 0x53,0x82,0x0a,0x80,0x60,0x4d,0x5e,0x48,0x76,0x00,0xff,0x2f,0x00,0x29,0x01,0x00, 0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d, 0x54,0x72,0x6b,0x00,0x00,0x00,0x34,0x00,0xff,0x03,0x0b,0x32,0x6e,0x6f,0x74,0x65, 0x73,0x43,0x36,0x46,0x23,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58, 0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x14,0x90,0x60,0x5d,0x38,0x5a,0x67,0x02, 0x80,0x60,0x6a,0x81,0x23,0x5a,0x6f,0x00,0xff,0x2f,0x00,0x25,0x01,0x00,0x00,0x4d, 0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72, 0x6b,0x00,0x00,0x00,0x33,0x00,0xff,0x03,0x0a,0x32,0x6e,0x6f,0x74,0x65,0x73,0x44, 0x34,0x41,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02, 0x18,0x08,0x00,0xc0,0x09,0x45,0x90,0x4a,0x5b,0x81,0x70,0x5d,0x69,0x06,0x80,0x4a, 0x49,0x78,0x5d,0x52,0x00,0xff,0x2f,0x00,0x31,0x01,0x00,0x00,0x4d,0x54,0x68,0x64, 0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00, 0x00,0x36,0x00,0xff,0x03,0x0a,0x32,0x6e,0x6f,0x74,0x65,0x73,0x44,0x34,0x47,0x34, 0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00, 0xc0,0x09,0x15,0x90,0x4a,0x62,0x84,0x15,0x80,0x4a,0x49,0x10,0x90,0x4f,0x71,0x84, 0x33,0x80,0x4f,0x76,0x00,0xff,0x2f,0x00,0x21,0x01,0x00,0x00,0x4d,0x54,0x68,0x64, 0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00, 0x00,0x32,0x00,0xff,0x03,0x0a,0x32,0x6e,0x6f,0x74,0x65,0x73,0x44,0x35,0x47,0x34, 0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00, 0xc0,0x09,0x08,0x90,0x56,0x5f,0x3d,0x4f,0x5a,0x0e,0x80,0x56,0x78,0x49,0x4f,0x6c, 0x00,0xff,0x2f,0x00,0x25,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x33,0x00,0xff, 0x03,0x0a,0x32,0x6e,0x6f,0x74,0x65,0x73,0x41,0x35,0x45,0x35,0x00,0xff,0x51,0x03, 0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x14,0x90, 0x58,0x59,0x81,0x03,0x5d,0x58,0x22,0x80,0x58,0x6f,0x7f,0x5d,0x52,0x00,0xff,0x2f, 0x00,0x21,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00, 0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x32,0x00,0xff,0x03,0x0a,0x32, 0x6e,0x6f,0x74,0x65,0x73,0x45,0x35,0x43,0x36,0x00,0xff,0x51,0x03,0x10,0x59,0x42, 0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x02,0x90,0x58,0x5a,0x43, 0x60,0x62,0x08,0x80,0x58,0x78,0x61,0x60,0x54,0x00,0xff,0x2f,0x00,0x25,0x01,0x00, 0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d, 0x54,0x72,0x6b,0x00,0x00,0x00,0x33,0x00,0xff,0x03,0x0a,0x32,0x6e,0x6f,0x74,0x65, 0x73,0x45,0x35,0x45,0x34,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04, 0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x02,0x90,0x58,0x5a,0x2c,0x4c,0x62,0x1f,0x80, 0x58,0x78,0x83,0x76,0x4c,0x49,0x00,0xff,0x2f,0x00,0x49,0x01,0x00,0x00,0x4d,0x54, 0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b, 0x00,0x00,0x00,0x3c,0x00,0xff,0x03,0x0c,0x33,0x6e,0x6f,0x74,0x65,0x73,0x41,0x34, 0x47,0x35,0x47,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04, 0x02,0x18,0x08,0x00,0xc0,0x09,0x11,0x90,0x51,0x62,0x6c,0x5b,0x52,0x57,0x80,0x5b, 0x6c,0x54,0x90,0x5b,0x62,0x46,0x80,0x5b,0x54,0x56,0x51,0x49,0x00,0xff,0x2f,0x00, 0x49,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01, 0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x3c,0x00,0xff,0x03,0x0c,0x33,0x6e, 0x6f,0x74,0x65,0x73,0x42,0x35,0x41,0x35,0x46,0x35,0x00,0xff,0x51,0x03,0x10,0x59, 0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x10,0x90,0x5f,0x49, 0x27,0x5d,0x62,0x13,0x80,0x5f,0x6a,0x2b,0x90,0x59,0x5a,0x08,0x80,0x5d,0x54,0x44, 0x59,0x78,0x00,0xff,0x2f,0x00,0x49,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00, 0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x3c, 0x00,0xff,0x03,0x0c,0x33,0x6e,0x6f,0x74,0x65,0x73,0x42,0x35,0x44,0x35,0x43,0x36, 0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00, 0xc0,0x09,0x14,0x90,0x5f,0x62,0x28,0x56,0x52,0x10,0x80,0x5f,0x54,0x32,0x90,0x60, 0x5a,0x15,0x80,0x56,0x6c,0x46,0x60,0x6a,0x00,0xff,0x2f,0x00,0x49,0x01,0x00,0x00, 0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54, 0x72,0x6b,0x00,0x00,0x00,0x3c,0x00,0xff,0x03,0x0c,0x33,0x6e,0x6f,0x74,0x65,0x73, 0x44,0x34,0x45,0x34,0x47,0x34,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58, 0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x03,0x90,0x4a,0x5a,0x28,0x4c,0x52,0x23, 0x80,0x4a,0x78,0x01,0x90,0x4f,0x62,0x33,0x80,0x4c,0x6c,0x13,0x4f,0x54,0x00,0xff, 0x2f,0x00,0x5d,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00, 0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x41,0x00,0xff,0x03,0x0c, 0x33,0x6e,0x6f,0x74,0x65,0x73,0x45,0x35,0x41,0x35,0x43,0x36,0x00,0xff,0x51,0x03, 0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x02,0x90, 0x58,0x5a,0x4b,0x80,0x58,0x78,0x81,0x01,0x90,0x5d,0x49,0x3a,0x80,0x5d,0x6a,0x82, 0x22,0x90,0x60,0x58,0x81,0x77,0x80,0x60,0x4d,0x00,0xff,0x2f,0x00,0x4d,0x01,0x00, 0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d, 0x54,0x72,0x6b,0x00,0x00,0x00,0x3d,0x00,0xff,0x03,0x0c,0x33,0x6e,0x6f,0x74,0x65, 0x73,0x45,0x35,0x43,0x36,0x44,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff, 0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x02,0x90,0x58,0x5a,0x43,0x60,0x62, 0x08,0x80,0x58,0x78,0x26,0x90,0x56,0x48,0x18,0x80,0x60,0x54,0x82,0x3b,0x56,0x76, 0x00,0xff,0x2f,0x00,0x51,0x01,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x3e,0x00,0xff, 0x03,0x0c,0x33,0x6e,0x6f,0x74,0x65,0x73,0x45,0x35,0x44,0x35,0x41,0x35,0x00,0xff, 0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09, 0x0b,0x90,0x58,0x40,0x36,0x56,0x58,0x6b,0x80,0x58,0x52,0x54,0x90,0x5d,0x48,0x81, 0x72,0x80,0x56,0x4d,0x81,0x5c,0x5d,0x76,0x00,0xff,0x2f,0x00,0x49,0x01,0x00,0x00, 0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54, 0x72,0x6b,0x00,0x00,0x00,0x3c,0x00,0xff,0x03,0x0c,0x33,0x6e,0x6f,0x74,0x65,0x73, 0x46,0x35,0x43,0x36,0x47,0x35,0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58, 0x04,0x04,0x02,0x18,0x08,0x00,0xc0,0x09,0x04,0x90,0x59,0x5a,0x41,0x60,0x62,0x0a, 0x80,0x59,0x78,0x2f,0x90,0x5b,0x52,0x0d,0x80,0x60,0x54,0x4a,0x5b,0x6c,0x00,0xff, 0x2f,0x00,0xd5,0x02,0x00,0x00,0x4d,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00, 0x00,0x01,0x03,0xc0,0x4d,0x54,0x72,0x6b,0x00,0x00,0x00,0x9f,0x00,0xc0,0x11,0x00, 0xb0,0x0a,0x40,0x00,0xb0,0x65,0x00,0x00,0xb0,0x64,0x02,0x00,0xb0,0x06,0x40,0x00, 0xb0,0x65,0x00,0x00,0xb0,0x64,0x01,0x00,0xb0,0x06,0x40,0x00,0xb0,0x26,0x00,0x00, 0xb0,0x65,0x00,0x00,0xb0,0x64,0x00,0x00,0xb0,0x06,0x02,0x00,0xb0,0x26,0x00,0x00, 0xff,0x51,0x03,0x09,0x27,0xc0,0x1e,0x90,0x4f,0x7f,0x00,0xb0,0x0b,0x7f,0x00,0xe0, 0x00,0x3f,0x1e,0xb0,0x0b,0x7a,0x00,0xe0,0x00,0x40,0x1e,0xb0,0x0b,0x52,0x1e,0xb0, 0x0b,0x69,0x3c,0x80,0x4f,0x7b,0x00,0x90,0x51,0x7b,0x00,0xb0,0x0b,0x7f,0x00,0xe0, 0x00,0x3b,0x1e,0xb0,0x0b,0x65,0x00,0xe0,0x00,0x3c,0x1e,0xb0,0x0b,0x5d,0x00,0xe0, 0x00,0x40,0x1e,0xe0,0x00,0x3d,0x3c,0x80,0x51,0x5b,0x1e,0xb0,0x0b,0x7f,0x00,0xe0, 0x00,0x3e,0x1e,0xb0,0x0b,0x5e,0x00,0xe0,0x00,0x40,0x1e,0xb0,0x0b,0x34,0x00,0x90, 0x54,0x7f,0x83,0x60,0x80,0x54,0x00,0x00,0xff,0x2f,0x00,0xdd,0x01,0x00,0x00,0x4d, 0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72, 0x6b,0x00,0x00,0x00,0x61,0x00,0xff,0x03,0x07,0x52,0x65,0x63,0x46,0x69,0x6e,0x31, 0x00,0xff,0x51,0x03,0x10,0x59,0x42,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00, 0xc0,0x71,0x00,0x90,0x48,0x7f,0x1a,0x80,0x48,0x40,0x04,0x90,0x4a,0x72,0x1a,0x80, 0x4a,0x40,0x04,0x90,0x4d,0x7b,0x1a,0x80,0x4d,0x40,0x04,0x90,0x4f,0x7f,0x1a,0x80, 0x4f,0x40,0x04,0x90,0x51,0x76,0x1a,0x80,0x51,0x40,0x04,0x90,0x53,0x7b,0x1a,0x80, 0x53,0x40,0x04,0x90,0x54,0x7f,0x1a,0x80,0x54,0x40,0x22,0x91,0x24,0x01,0x54,0x81, 0x24,0x40,0x00,0xff,0x2f,0x00,0x45,0x34,0x00,0x00,0x49,0x44,0x33,0x03,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0x00,0x00,0x00,0x02,0x58,0x01,0x40,0x00, 0x00,0x16,0x83,0x41,0x61,0x80,0x07,0xfe,0xb1,0x30,0x32,0x63,0x6c,0x84,0xff,0xfe, 0x9b,0x81,0x51,0x83,0x99,0xff,0xff,0x0c,0xb4,0xcc,0xc9,0x41,0x7b,0x2d,0xc0,0x28, 0x60,0x19,0x06,0x80,0x70,0x8d,0x7d,0x48,0x20,0x07,0x81,0x10,0x18,0xd5,0x20,0x04, 0xec,0x00,0x8c,0xfd,0x66,0xe9,0x98,0x1a,0x01,0x9f,0x26,0x25,0xc0,0x14,0x9c,0x2f, 0x98,0x03,0x0f,0xfc,0xd0,0xcc,0xdc,0xdd,0x08,0x2c,0x90,0x21,0x18,0x06,0xb0,0xa0, 0x1e,0x79,0x60,0x6d,0xd6,0x81,0x9d,0x03,0xfd,0x9e,0xd6,0x82,0x88,0x01,0xb6,0x62, 0xde,0x07,0xfb,0x00,0x1c,0x47,0x00,0x6b,0x03,0x01,0x91,0x4b,0xff,0x5a,0x6e,0xab, 0x3b,0x20,0x06,0xbd,0x08,0x2c,0x2c,0x01,0x94,0x00,0x28,0xb0,0x1a,0x0e,0x06,0xb0, 0x20,0x06,0x87,0x02,0x40,0xff,0xf3,0x66,0xc0,0x84,0x3e,0x64,0x2a,0x7a,0x21,0x9b, 0xa0,0x00,0xc0,0xcb,0x10,0xff,0xf5,0xa6,0x9a,0xad,0xbe,0xc0,0x63,0x08,0x00,0x12, 0x40,0x35,0xaf,0xc0,0xe8,0xc9,0x03,0x56,0x0c,0x0d,0x31,0xc0,0x32,0xc4,0x80,0x38, 0xc0,0x19,0x11,0x60,0x61,0xc1,0x85,0x8f,0x80,0x30,0x8f,0xff,0xf5,0xbb,0xaa,0xdf, 0x6f,0x17,0x08,0xf6,0x06,0x94,0x88,0x36,0x3e,0x1b,0x78,0x05,0x0c,0x14,0xa1,0x04, 0x0b,0x2b,0x25,0xce,0x81,0xae,0x28,0x24,0xa5,0x70,0xb9,0xc0,0xc0,0x1f,0xff,0xff, 0xff,0x7f,0xff,0xc3,0xa4,0x03,0x0e,0x0c,0x0c,0x08,0x30,0x1a,0x06,0x06,0x80,0x90, 0x0a,0x00,0x10,0x00,0x0c,0xc9,0xb0,0x33,0xa4,0xc0,0xb0,0x30,0x6d,0x40,0x6c,0x80, 0xc1,0x00,0x34,0x0d,0x02,0x2e,0x5f,0x70,0x00,0x6a,0x01,0x6a,0x23,0x6f,0xfe,0xac, 0x8f,0xf9,0x98,0x4f,0xff,0x81,0xff,0xf3,0x66,0xc0,0x0e,0x1d,0x4a,0x9b,0x06,0x7f, 0xc1,0xa0,0x00,0x18,0x7e,0xc0,0x61,0xc1,0x81,0xbe,0x30,0x28,0x12,0xaa,0x53,0x15, 0xbb,0xcd,0x52,0x06,0xdc,0x13,0x24,0xab,0x35,0x28,0x97,0x4d,0x56,0x62,0x89,0xaa, 0x57,0x30,0x1c,0xe3,0x64,0x92,0x49,0x96,0x8a,0x28,0xb2,0x4a,0x33,0x3e,0x74,0xd5, 0x03,0x22,0xf4,0x88,0x93,0xa4,0x44,0x8a,0x97,0x59,0x12,0x88,0xb9,0xcc,0x4d,0x4c, 0x8d,0x9d,0x03,0x62,0x91,0x06,0x36,0x75,0x22,0x2b,0x53,0x1d,0x66,0xa3,0xa4,0x70, 0x9a,0xae,0xa7,0x55,0xbf,0xf4,0x46,0x74,0xbc,0x92,0x49,0x25,0xd1,0xfa,0xdf,0xff, 0xeb,0x41,0x27,0x5a,0x06,0xff,0xff,0x2b,0xff,0xf5,0x80,0xb8,0x83,0x56,0xe0,0x00, 0x44,0x60,0xc6,0x3b,0x45,0xc6,0xab,0xcc,0x96,0x7a,0xc3,0x58,0xde,0x26,0xfe,0x2d, 0xb8,0x52,0x63,0xef,0x63,0xa1,0x24,0xff,0xf3,0x66,0xc0,0x1c,0x18,0x4b,0x7a,0xce, 0xec,0x7c,0xd4,0xd8,0x80,0xac,0x43,0x94,0x5f,0xe8,0xa2,0x80,0x5f,0xe2,0xb5,0x9b, 0xfd,0x4d,0x29,0x08,0x54,0xd9,0x05,0x37,0xf3,0x23,0xf5,0xb2,0x92,0x73,0x86,0xa6, 0x44,0x55,0x47,0x19,0x82,0x81,0x4a,0x7d,0xfd,0x85,0xa1,0xf7,0x88,0xe2,0xd9,0xdf, 0x4f,0xfe,0x75,0xd7,0xe4,0x63,0x8f,0xff,0xff,0xfe,0x84,0xd6,0xff,0xff,0xfe,0x83, 0xe7,0xff,0xff,0xff,0xc4,0x91,0x37,0xff,0xc8,0x80,0xa5,0x54,0x67,0x80,0x00,0x00, 0xcc,0x26,0x49,0x01,0x81,0x40,0x83,0x3b,0xdb,0x5d,0x34,0x4e,0x3d,0xee,0xb3,0x13, 0x57,0x55,0x66,0xc6,0x28,0x1d,0x14,0x08,0x0b,0xdc,0x04,0x53,0x42,0xd8,0x17,0x52, 0xf6,0x94,0x48,0x80,0xa9,0x3f,0xfe,0xa2,0xf2,0x44,0x90,0x29,0xc2,0xf8,0x58,0x39, 0xa2,0x1f,0xa9,0x26,0xea,0x52,0x6a,0x48,0xff,0xf3,0x66,0xc0,0x3e,0x18,0x9a,0x2a, 0xb7,0x04,0x5d,0x1a,0xb4,0x9a,0xa7,0xac,0xba,0x81,0x2c,0x75,0x77,0xe8,0xf8,0xfa, 0x4a,0xf5,0x92,0x21,0xc2,0x53,0xfd,0x2f,0xff,0xea,0xe3,0xb4,0x71,0x3f,0xff,0xd8, 0xa2,0xbf,0xf9,0x52,0x3f,0xfe,0xb3,0xbf,0xfd,0x40,0x73,0x44,0x78,0x80,0x00,0x01, 0x93,0x98,0x42,0x0e,0x6e,0xbf,0xb7,0x3c,0xe3,0x5d,0x4d,0x38,0x60,0x89,0xc9,0x48, 0x83,0x13,0x29,0x11,0x60,0xf8,0x40,0x34,0x2c,0x06,0x4f,0x74,0x01,0xa6,0x02,0xc0, 0x61,0x80,0x00,0xc7,0x99,0x2e,0xce,0xa5,0x13,0x41,0x8c,0x8b,0x5d,0x1f,0xd7,0x93, 0x22,0x95,0x22,0xa4,0x44,0x5b,0xc0,0x6c,0x1d,0xea,0x43,0xea,0x5a,0x15,0x2c,0xb6, 0x69,0x62,0x8b,0x2f,0xac,0xba,0x6a,0x64,0x6e,0x64,0x9e,0x82,0x1a,0x8a,0xc4,0xdb, 0xe8,0x92,0xa2,0x3b,0x10,0xe6,0x57,0xff,0xff,0xff,0xf3,0x66,0xc0,0x5f,0x19,0xf2, 0x2e,0x9f,0x00,0x5d,0x60,0xb4,0xa6,0xd9,0x88,0x62,0x93,0xe7,0xff,0xf8,0x90,0x96, 0x98,0x8a,0x90,0x00,0x04,0x13,0x78,0xe2,0x2d,0xc6,0x94,0xd1,0x62,0xe1,0x82,0x36, 0xb3,0xac,0x6e,0x4b,0x5d,0xdf,0x7f,0xfb,0xbf,0xc7,0x19,0x53,0x58,0x30,0x32,0xa3, 0x4f,0x2e,0x18,0x83,0x36,0xb4,0x53,0x25,0x01,0x70,0x38,0xce,0xeb,0x63,0x94,0xdc, 0x38,0xe6,0x53,0xf3,0x0e,0xff,0xff,0xff,0xff,0x7d,0x92,0x49,0x33,0x51,0x25,0x24, 0x84,0x98,0x5e,0x18,0x73,0xe5,0xc6,0x7f,0x74,0xd6,0xcc,0xc7,0x51,0xab,0xea,0x7a, 0x92,0x9f,0xa6,0x82,0x06,0x2b,0x43,0x5a,0x24,0x80,0x48,0xc9,0x77,0xff,0xff,0xff, 0x50,0x54,0x87,0x21,0xdf,0xfe,0x54,0xb9,0xbb,0x9c,0xc0,0x00,0x04,0x11,0x66,0xbe, 0x9c,0x56,0x3c,0x66,0xf1,0x5f,0xea,0xd7,0xf6,0x89,0xff,0xf3,0x66,0xc0,0x7b,0x19, 0xf2,0x2e,0xa7,0x00,0x7e,0xda,0xb4,0x1a,0xf5,0xb2,0xcf,0x9f,0xff,0xff,0xfa,0x7f, 0x9d,0xb6,0x04,0x2a,0x14,0xd0,0x17,0x35,0xb4,0x8c,0x20,0xb0,0xc2,0x8d,0xa3,0xb3, 0x7e,0xc6,0x9e,0x25,0xc6,0x1c,0x70,0xcd,0x06,0x31,0x2a,0xcd,0x8a,0x90,0xe4,0xe5, 0xfc,0x79,0x6d,0x5e,0xee,0xff,0xf6,0xcd,0x38,0xd0,0x5c,0x00,0xc0,0x04,0x0e,0xc3, 0x02,0x5c,0xc3,0x19,0x68,0xba,0x2b,0x73,0xee,0xe6,0x29,0xe7,0x9e,0x7a,0x22,0x38, 0xe9,0x73,0x75,0x53,0x98,0x03,0x8c,0xcf,0x14,0x10,0x4f,0xff,0xfe,0xa0,0x36,0x82, 0xb1,0xb8,0x97,0x48,0x8b,0xb0,0x00,0x06,0x91,0x4f,0x30,0x8d,0xe6,0x5f,0xfe,0x64, 0x5d,0x38,0x44,0xd7,0x9e,0x94,0xc6,0xe7,0x37,0xff,0xff,0xff,0xf5,0x72,0x8c,0xdc, 0x7e,0xd9,0xa1,0x83,0x8a,0x15,0x80,0x3a,0xea,0x6a,0xed,0xff,0xf3,0x66,0xc0,0x97, 0x1b,0x6a,0x3e,0xab,0x00,0x7e,0x8e,0xb4,0x2d,0x76,0x94,0xa1,0xe8,0xaa,0x82,0xc9, 0x38,0x62,0x63,0x46,0x12,0x28,0x6a,0x70,0x46,0x8e,0xda,0x64,0x0c,0xc6,0xbc,0x8c, 0x02,0x50,0x62,0x76,0xd8,0x64,0xea,0x2f,0xa2,0x9a,0xd3,0x8e,0x72,0x15,0x25,0x15, 0x4a,0x11,0xb9,0x9f,0xea,0x61,0x3b,0x51,0x48,0x47,0xa5,0x05,0xa1,0xe9,0x09,0x31, 0x84,0xaf,0xd1,0xd4,0x84,0xdd,0x47,0xa1,0x24,0x45,0xa2,0xff,0xff,0xe7,0x51,0xc2, 0x72,0x40,0x75,0x76,0x69,0x90,0x00,0x04,0x60,0xa9,0x14,0x11,0xad,0xc8,0xea,0x22, 0x61,0x6d,0x3a,0x68,0xed,0xa7,0x73,0xf8,0x63,0xff,0xff,0xff,0x72,0xac,0xa6,0x55, 0x02,0x3e,0xab,0x04,0xe4,0xaf,0x66,0xc5,0x49,0x4d,0x01,0xbb,0x31,0x56,0x94,0xed, 0x30,0xb6,0x40,0x8c,0x4f,0xc0,0xc0,0x59,0x96,0x13,0x98,0x41,0xff,0xf3,0x66,0xc0, 0xad,0x1c,0x92,0x3e,0x9f,0x00,0x7e,0xd4,0xb4,0x79,0xb5,0x4e,0x98,0xd3,0xb1,0xb0, 0x8b,0x87,0x07,0xa8,0x30,0xa6,0x81,0xbe,0x04,0x99,0x41,0x1c,0xfb,0x24,0xb4,0x14, 0x8d,0x34,0x92,0x44,0x87,0x09,0xb8,0x82,0x95,0xd9,0xff,0x69,0x1a,0x93,0x7f,0x5a, 0x27,0x4c,0x9d,0x6a,0xa0,0xdf,0xa2,0xb1,0xd2,0x33,0x1a,0x6f,0xff,0xff,0x5a,0x46, 0xc3,0x4d,0x40,0xf6,0xdb,0xe1,0x40,0x01,0xf1,0x0e,0x8a,0x89,0xb1,0x26,0x0c,0x88, 0x98,0xbc,0x8f,0x7c,0x2e,0x70,0x94,0xbf,0x85,0x65,0x4e,0x74,0x81,0x9a,0x1c,0x27, 0x8d,0x8b,0xa3,0x9a,0x66,0x70,0x77,0x13,0x23,0xa4,0xd4,0x4a,0x22,0x95,0x24,0x88, 0x30,0x84,0x63,0x32,0x2e,0x21,0x08,0x40,0x58,0x68,0x1a,0x02,0x20,0x60,0x12,0x80, 0x11,0xc0,0x24,0x58,0x04,0x39,0x04,0x88,0x81,0x85,0x88,0x06,0x90,0xff,0xf3,0x66, 0xc0,0xbe,0x1c,0xda,0x4a,0x93,0x00,0x66,0xe2,0xb4,0x20,0x72,0x85,0xa2,0x60,0x8a, 0x1a,0x37,0xf4,0x52,0x91,0xc2,0xe6,0x1c,0x4c,0x99,0x06,0x1a,0x0b,0xf6,0x59,0x75, 0x16,0x4f,0xfa,0x27,0xba,0x5a,0x2f,0xe9,0x51,0x38,0x6c,0x99,0x44,0xac,0x87,0xff, 0xfd,0x68,0x98,0xa0,0x3a,0x4a,0xe9,0x80,0x56,0x08,0x70,0x88,0x08,0x80,0x00,0x00, 0x00,0x00,0x04,0x46,0x2c,0x26,0x18,0x12,0x07,0xa7,0xb2,0x58,0x62,0xa5,0x4e,0x2b, 0x65,0x5c,0xaa,0x6c,0x89,0x5a,0xa6,0x6a,0x56,0x20,0x63,0x2e,0x32,0x7c,0xb2,0xa2, 0x54,0xd1,0x12,0xa9,0x4c,0xbd,0x4a,0xb2,0x70,0x4f,0x84,0xb8,0x74,0x45,0x13,0xeb, 0x28,0x9b,0x90,0x64,0x4c,0x52,0x78,0x0b,0x05,0x03,0x58,0xd0,0x0e,0x31,0x70,0xb9, 0x92,0x4a,0x20,0x80,0x00,0x9c,0x03,0x66,0x4c,0x36,0x21,0xa6,0x6e,0x3e,0xff,0xf3, 0x66,0xc0,0xce,0x1d,0xca,0x56,0x8a,0x61,0x49,0xa0,0x00,0x84,0xa4,0x23,0x14,0x51, 0x45,0x69,0x13,0x44,0xd1,0xbd,0x65,0xc5,0x32,0x8a,0xc6,0x86,0x6a,0x49,0x2a,0x28, 0xcc,0x9e,0x9e,0x7f,0x28,0xbd,0x6e,0x83,0x6b,0x45,0x49,0x25,0x52,0x52,0xc9,0x08, 0x8f,0xd4,0x34,0xb4,0x0b,0xac,0xee,0xd9,0x80,0xf4,0xc9,0xd5,0xfa,0x96,0x8f,0xff, 0xfd,0x34,0xd9,0x6b,0x41,0x06,0x7d,0x34,0xdd,0x0d,0x15,0x24,0x97,0xa2,0x8f,0xff, 0xff,0xff,0x98,0x17,0x0d,0x09,0xf3,0x74,0xd6,0x5f,0x37,0x22,0x85,0xc6,0x02,0x19, 0xcb,0x65,0x40,0x0c,0x04,0x04,0x2a,0xaa,0xc6,0x5f,0xdb,0xaa,0xa7,0x55,0x57,0x8c, 0xdb,0x35,0xff,0x0c,0xb5,0x0c,0x2c,0x74,0x87,0x20,0xd4,0xe2,0x45,0x69,0x9a,0x43, 0x90,0x6a,0x74,0xc0,0x2a,0x00,0x60,0x16,0x1e,0x0e,0x80,0x04,0x17,0x07,0xc7,0xff, 0xf3,0x66,0xc0,0xda,0x2b,0x53,0xbe,0x83,0x07,0x8f,0xa0,0x00,0x35,0xf0,0x51,0xd0, 0x1d,0x07,0xc7,0x5a,0xd3,0x0b,0x2e,0xcc,0xd7,0x22,0xa2,0xb6,0x48,0xaa,0xc3,0x5a, 0x8a,0xb6,0xaa,0xbc,0x33,0x53,0x33,0x6b,0x50,0xd5,0xb7,0xff,0xff,0xff,0xff,0xff, 0xff,0xf0,0xcd,0x2a,0x2a,0x05,0x05,0x4b,0x3c,0x37,0xc1,0xa2,0xc1,0xdf,0xc1,0x55, 0x86,0xbf,0x06,0x94,0x1d,0xe4,0xb1,0x2f,0x2c,0x78,0x44,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xf3,0x66,0xc0,0xb0,0x1a,0xba,0x65,0xe4,0x01,0xc3,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xff,0xf3,0x66,0xc0,0xc9,0x00,0x00,0x02,0x58,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02,0x58,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02,0x58,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02,0x58,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02,0x58,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02,0x58,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02,0x58, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00,0x02, 0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xf3,0x66,0xc0,0xff,0x00,0x00, 0x02,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0xff,0xf3,0x66,0xc0,0xff,0x00, 0x00,0x02,0x58,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x49,0x01,0x00,0x00,0x4d, 0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x01,0xe0,0x4d,0x54,0x72, 0x6b,0x00,0x00,0x00,0x3c,0x00,0xff,0x03,0x06,0x52,0x46,0x49,0x44,0x6f,0x6b,0x00, 0xff,0x51,0x03,0x07,0xa1,0x20,0x00,0xff,0x58,0x04,0x04,0x02,0x18,0x08,0x00,0xc9, 0x00,0x0c,0x99,0x47,0x79,0x03,0x45,0x7f,0x02,0x52,0x79,0x67,0x89,0x47,0x00,0x04, 0x45,0x00,0x01,0x52,0x00,0x24,0x99,0x18,0x01,0x47,0x89,0x18,0x00,0x00,0xff,0x2f, 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00, 0x00,0x08,0x00,0x00,0x00,0xe8,0x03,0x00,0x00,0xb8,0x0b,0x00,0x00,0x3d,0x00,0x00, 0x00,0x2f,0x6c,0x6f,0x63,0x61,0x74,0x65,0x2e,0x6a,0x73,0x70,0x3f,0x73,0x6e,0x3d, 0x0d,0x00,0x00,0x00,0x26,0x68,0x3d,0x21,0x00,0x00,0x00,0x37,0x66,0x66,0x66,0x66, 0x66,0x66,0x66,0x21,0x00,0x00,0x00,0x37,0x66,0x66,0x66,0x66,0x66,0x66,0x65,0x39, 0x00,0x00,0x00,0x2f,0x76,0x6c,0x2f,0x70,0x34,0x2e,0x6a,0x73,0x70,0x3f,0x73,0x6e, 0x3d,0x0d,0x00,0x00,0x00,0x26,0x76,0x3d,0x25,0x00,0x00,0x00,0x26,0x73,0x74,0x3d, 0x31,0x26,0x73,0x64,0x3d,0x11,0x00,0x00,0x00,0x26,0x74,0x63,0x3d,0x0d,0x00,0x00, 0x00,0x26,0x68,0x3d,0x49,0x00,0x00,0x00,0x2f,0x76,0x6c,0x2f,0x72,0x65,0x63,0x6f, 0x72,0x64,0x2e,0x6a,0x73,0x70,0x3f,0x73,0x6e,0x3d,0x0d,0x00,0x00,0x00,0x26,0x76, 0x3d,0x0d,0x00,0x00,0x00,0x26,0x68,0x3d,0x0d,0x00,0x00,0x00,0x26,0x6d,0x3d,0x41, 0x00,0x00,0x00,0x2f,0x76,0x6c,0x2f,0x72,0x66,0x69,0x64,0x2e,0x6a,0x73,0x70,0x3f, 0x73,0x6e,0x3d,0x0d,0x00,0x00,0x00,0x26,0x76,0x3d,0x0d,0x00,0x00,0x00,0x26,0x68, 0x3d,0x0d,0x00,0x00,0x00,0x26,0x74,0x3d,0x05,0x00,0x00,0x00,0x20,0x05,0x00,0x00, 0x00,0x0a,0x05,0x00,0x00,0x00,0x0d,0x01,0x00,0x00,0x00,0x39,0x00,0x00,0x00,0x23, 0x23,0x64,0x75,0x6d,0x70,0x63,0x6f,0x6e,0x66,0x69,0x67,0x20,0x3a,0x0d,0x00,0x00, 0x00,0x20,0x3d,0x20,0x1d,0x00,0x00,0x00,0x63,0x6f,0x6e,0x66,0x69,0x67,0x3d,0x11, 0x00,0x00,0x00,0x70,0x69,0x6e,0x67,0x15,0x00,0x00,0x00,0x62,0x72,0x6f,0x61,0x64, 0x0d,0x00,0x00,0x00,0x47,0x45,0x54,0x5d,0x00,0x00,0x00,0x23,0x23,0x74,0x69,0x6d, 0x65,0x6f,0x75,0x74,0x20,0x6f,0x6e,0x20,0x63,0x6f,0x6e,0x66,0x69,0x67,0x77,0x61, 0x69,0x74,0x09,0x00,0x00,0x00,0x4d,0x55,0x09,0x00,0x00,0x00,0x43,0x48,0x09,0x00, 0x00,0x00,0x4d,0x43,0x6d,0x00,0x00,0x00,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23, 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x6d,0x73,0x67,0x49, 0x6e,0x69,0x74,0x09,0x00,0x00,0x00,0x49,0x44,0x1d,0x00,0x00,0x00,0x2d,0x3e,0x20, 0x69,0x64,0x6c,0x65,0x25,0x00,0x00,0x00,0x2d,0x3e,0x20,0x61,0x73,0x6c,0x65,0x65, 0x70,0x09,0x00,0x00,0x00,0x49,0x44,0x39,0x00,0x00,0x00,0x52,0x65,0x61,0x64,0x79, 0x20,0x74,0x6f,0x20,0x72,0x75,0x6e,0x20,0x21,0x0d,0x00,0x00,0x00,0x47,0x45,0x54, 0x51,0x00,0x00,0x00,0x23,0x23,0x74,0x69,0x6d,0x65,0x6f,0x75,0x74,0x20,0x6f,0x6e, 0x20,0x6d,0x73,0x67,0x6c,0x6f,0x61,0x64,0x0d,0x00,0x00,0x00,0x47,0x45,0x54,0x65, 0x00,0x00,0x00,0x23,0x23,0x74,0x69,0x6d,0x65,0x6f,0x75,0x74,0x20,0x6f,0x6e,0x20, 0x70,0x69,0x6e,0x67,0x73,0x65,0x6e,0x64,0x77,0x61,0x69,0x74,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x4d,0x00,0x00,0x00,0x23,0x23,0x74,0x69,0x6d,0x65,0x6f,0x75, 0x74,0x20,0x6f,0x6e,0x20,0x75,0x70,0x6c,0x6f,0x61,0x64,0x11,0x00,0x00,0x00,0x50, 0x4f,0x53,0x54,0x11,0x00,0x00,0x00,0x50,0x4f,0x53,0x54,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0x31,0x00,0x00,0x00,0x74,0x61,0x69,0x63,0x68,0x69,0x73,0x74,0x61, 0x72,0x74,0x20,0x5d,0x00,0x00,0x00,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23, 0x23,0x23,0x23,0x73,0x65,0x74,0x70,0x61,0x6c,0x65,0x74,0x74,0x65,0x20,0x55,0x00, 0x00,0x00,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x73,0x65, 0x74,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x11,0x00,0x00,0x00,0x20,0x3d,0x20,0x24,0x21, 0x00,0x00,0x00,0x72,0x61,0x6e,0x64,0x6d,0x69,0x64,0x69,0x19,0x00,0x00,0x00,0x61, 0x76,0x61,0x6e,0x63,0x65,0x15,0x00,0x00,0x00,0x69,0x66,0x6e,0x65,0x20,0x19,0x00, 0x00,0x00,0x61,0x74,0x74,0x65,0x6e,0x64,0x39,0x00,0x00,0x00,0x73,0x74,0x72,0x65, 0x61,0x6d,0x69,0x6e,0x67,0x20,0x70,0x69,0x6e,0x67,0x09,0x00,0x00,0x00,0x49,0x44, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x49,0x00,0x00,0x00,0x53,0x74,0x61,0x72,0x74,0x20,0x43,0x68, 0x6f,0x72,0x20,0x53,0x74,0x72,0x65,0x61,0x6d,0x20,0x19,0x00,0x00,0x00,0x74,0x65, 0x6d,0x70,0x6f,0x20,0x1d,0x00,0x00,0x00,0x72,0x65,0x70,0x65,0x61,0x74,0x20,0x1d, 0x00,0x00,0x00,0x72,0x65,0x70,0x65,0x61,0x74,0x20,0x0d,0x00,0x00,0x00,0x47,0x45, 0x54,0x09,0x00,0x00,0x00,0x4d,0x55,0x09,0x00,0x00,0x00,0x4d,0x43,0x59,0x00,0x00, 0x00,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x53,0x74,0x61,0x72, 0x74,0x20,0x6d,0x75,0x73,0x69,0x63,0x2d,0x00,0x00,0x00,0x23,0x23,0x23,0x6e,0x69, 0x6c,0x6d,0x75,0x73,0x69,0x63,0x09,0x00,0x00,0x00,0x53,0x54,0x81,0x00,0x00,0x00, 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x53,0x74,0x61,0x72,0x74, 0x20,0x73,0x74,0x72,0x65,0x61,0x6d,0x69,0x6e,0x67,0x20,0x6d,0x75,0x73,0x69,0x63, 0x09,0x00,0x00,0x00,0x4d,0x57,0x09,0x00,0x00,0x00,0x43,0x48,0x09,0x00,0x00,0x00, 0x50,0x4c,0x09,0x00,0x00,0x00,0x43,0x4c,0xff,0xff,0xff,0xff,0x31,0x00,0x00,0x00, 0x63,0x68,0x65,0x63,0x6b,0x74,0x61,0x69,0x63,0x68,0x69,0x20,0x15,0x00,0x00,0x00, 0x70,0x69,0x6e,0x67,0x3d,0x0d,0x00,0x00,0x00,0x20,0x3a,0x20,0x0d,0x00,0x00,0x00, 0x47,0x45,0x54,0x55,0x00,0x00,0x00,0x23,0x23,0x74,0x69,0x6d,0x65,0x6f,0x75,0x74, 0x20,0x6f,0x6e,0x20,0x70,0x69,0x6e,0x67,0x77,0x61,0x69,0x74,0xff,0xff,0xff,0xff, 0x0d,0x00,0x00,0x00,0x47,0x45,0x54,0x2d,0x00,0x00,0x00,0x63,0x6f,0x6e,0x74,0x72, 0x6f,0x6c,0x70,0x6c,0x61,0x79,0x2d,0x00,0x00,0x00,0x63,0x6f,0x6e,0x74,0x72,0x6f, 0x6c,0x77,0x61,0x69,0x74,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x4d,0x00,0x00, 0x00,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x20,0x77,0x69,0x66,0x69,0x20, 0x6c,0x6f,0x73,0x74,0x21,0x00,0x00,0x00,0x3a,0x73,0x74,0x61,0x72,0x74,0x65,0x64, 0x15,0x00,0x00,0x00,0x3a,0x64,0x6f,0x6e,0x65,0xc3,0x55,0x00,0x00,0x00,0x00,0x00, 0x6a,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x05,0x02,0x10,0x02,0x00,0x2a,0x05,0x03, 0xd2,0x01,0x00,0x00,0x25,0x60,0x05,0x02,0x20,0x00,0x05,0x02,0x00,0x02,0xbe,0x00, 0x05,0x02,0xcd,0x5e,0x05,0x02,0xa0,0x00,0x05,0x02,0xae,0x00,0x05,0x02,0x69,0x00, 0x05,0x02,0x77,0x00,0x05,0x03,0xd3,0x01,0x00,0x00,0x25,0x60,0x05,0x35,0x3c,0x05, 0x02,0x8f,0x00,0x05,0x24,0x15,0x02,0x1e,0x00,0x05,0x02,0xd5,0x00,0x05,0x02,0x00, 0x01,0x00,0x00,0x00,0x02,0xcb,0x00,0x05,0x03,0x67,0x01,0x00,0x00,0x25,0x04,0x17, 0x1d,0x15,0x00,0x02,0xcd,0x00,0x1c,0x16,0x00,0x04,0x05,0x02,0x00,0x01,0x03,0x00, 0x00,0x07,0x00,0x07,0x02,0x07,0x01,0x02,0x00,0x04,0x42,0x01,0x01,0x00,0x00,0x07, 0x00,0x04,0x16,0x1d,0x0f,0x00,0x02,0x30,0x04,0x20,0x02,0x1c,0x11,0x00,0x07,0x00, 0x01,0x01,0x00,0x00,0x07,0x00,0x04,0x16,0x1d,0x0c,0x00,0x02,0x00,0x1c,0x15,0x00, 0x02,0x01,0x07,0x00,0x2e,0x02,0x04,0x00,0x09,0x01,0x02,0x00,0x00,0x07,0x00,0x04, 0x17,0x1d,0x26,0x00,0x07,0x01,0x07,0x00,0x2d,0x16,0x1d,0x16,0x00,0x07,0x00,0x2e, 0x1c,0x23,0x00,0x07,0x00,0x2d,0x07,0x00,0x2e,0x07,0x01,0x02,0x05,0x00,0x20,0x02, 0x1c,0x27,0x00,0x04,0x01,0x01,0x00,0x00,0x07,0x00,0x04,0x16,0x1d,0x0c,0x00,0x02, 0x00,0x1c,0x17,0x00,0x07,0x00,0x2d,0x44,0x07,0x00,0x2e,0x02,0x06,0x00,0x09,0x01, 0x02,0x00,0x00,0x07,0x01,0x15,0x1d,0x0c,0x00,0x07,0x00,0x2d,0x1c,0x23,0x00,0x07, 0x01,0x02,0x00,0x19,0x1d,0x22,0x00,0x07,0x00,0x2e,0x07,0x01,0x02,0x01,0x0a,0x02, 0x07,0x00,0x1c,0x23,0x00,0x04,0x01,0x01,0x03,0x00,0x07,0x00,0x02,0x04,0x00,0x3e, 0x28,0x01,0x02,0x00,0x28,0x02,0x07,0x00,0x28,0x03,0x04,0x07,0x03,0x04,0x17,0x1d, 0x38,0x00,0x1c,0x23,0x00,0x07,0x03,0x2e,0x28,0x03,0x1c,0x11,0x00,0x05,0x07,0x01, 0x07,0x02,0x07,0x03,0x2d,0x3f,0x05,0x02,0x02,0x07,0x02,0x02,0x01,0x09,0x2f,0x1c, 0x1b,0x00,0x05,0x07,0x01,0x01,0x01,0x00,0x00,0x07,0x00,0x75,0x7b,0x01,0x03,0x01, 0x00,0x07,0x00,0x07,0x01,0x07,0x02,0x02,0x02,0x00,0x28,0x03,0x07,0x03,0x04,0x16, 0x1d,0x17,0x00,0x02,0x00,0x1c,0x27,0x00,0x02,0x01,0x07,0x00,0x07,0x01,0x07,0x03, 0x07,0x01,0x44,0x09,0x02,0x0a,0x00,0x09,0x01,0x06,0x02,0x00,0x07,0x04,0x07,0x01, 0x44,0x18,0x1d,0x70,0x00,0x07,0x01,0x07,0x02,0x07,0x04,0x02,0x02,0x00,0x28,0x06, 0x07,0x06,0x04,0x16,0x1d,0x21,0x00,0x07,0x01,0x44,0x1c,0x23,0x00,0x07,0x06,0x28, 0x07,0x07,0x00,0x07,0x05,0x07,0x01,0x07,0x04,0x07,0x07,0x07,0x04,0x0a,0x40,0x05, 0x07,0x06,0x04,0x17,0x1d,0x4e,0x00,0x07,0x00,0x07,0x05,0x07,0x07,0x09,0x07,0x04, 0x0a,0x07,0x03,0x02,0x00,0x04,0x40,0x1c,0x4f,0x00,0x04,0x05,0x07,0x00,0x07,0x01, 0x07,0x02,0x07,0x03,0x07,0x07,0x07,0x02,0x44,0x09,0x07,0x05,0x07,0x07,0x09,0x07, 0x04,0x0a,0x07,0x03,0x44,0x09,0x02,0x0b,0x00,0x1c,0x71,0x00,0x04,0x01,0x03,0x02, 0x00,0x07,0x00,0x07,0x01,0x02,0x00,0x02,0x0a,0x00,0x28,0x03,0x07,0x03,0x15,0x1d, 0x16,0x00,0x07,0x00,0x1c,0x39,0x00,0x07,0x00,0x44,0x07,0x02,0x44,0x07,0x01,0x44, 0x0a,0x07,0x03,0x0b,0x09,0x3e,0x28,0x04,0x07,0x04,0x07,0x00,0x07,0x01,0x07,0x02, 0x02,0x00,0x02,0x00,0x02,0x0b,0x00,0x05,0x07,0x04,0x01,0x02,0x00,0x00,0x07,0x00, 0x04,0x16,0x1d,0x0c,0x00,0x07,0x01,0x1c,0x19,0x00,0x07,0x00,0x2e,0x07,0x00,0x2d, 0x07,0x01,0x20,0x02,0x02,0x0d,0x00,0x01,0x02,0x00,0x00,0x07,0x00,0x04,0x17,0x1d, 0x26,0x00,0x07,0x01,0x07,0x00,0x2d,0x16,0x1d,0x16,0x00,0x07,0x00,0x2e,0x1c,0x23, 0x00,0x07,0x00,0x2d,0x07,0x00,0x2e,0x07,0x01,0x02,0x0e,0x00,0x20,0x02,0x1c,0x27, 0x00,0x04,0x01,0x03,0x01,0x00,0x07,0x01,0x04,0x16,0x1d,0x0f,0x00,0x07,0x00,0x04, 0x20,0x02,0x1c,0x4f,0x00,0x07,0x02,0x07,0x00,0x07,0x01,0x2d,0x32,0x02,0x28,0x03, 0x07,0x03,0x02,0x00,0x19,0x1d,0x34,0x00,0x07,0x01,0x2d,0x07,0x00,0x07,0x01,0x2e, 0x07,0x02,0x02,0x0f,0x00,0x20,0x02,0x1c,0x4f,0x00,0x07,0x03,0x02,0x00,0x18,0x1d, 0x45,0x00,0x07,0x00,0x07,0x01,0x20,0x02,0x1c,0x4f,0x00,0x07,0x00,0x07,0x01,0x2e, 0x07,0x02,0x02,0x0f,0x00,0x01,0x02,0x00,0x00,0x07,0x00,0x04,0x17,0x1d,0x1a,0x00, 0x07,0x00,0x2d,0x07,0x00,0x2e,0x07,0x01,0x02,0x10,0x00,0x07,0x01,0x02,0x0f,0x00, 0x1c,0x1b,0x00,0x04,0x01,0x03,0x01,0x00,0x07,0x00,0x04,0x17,0x1d,0x35,0x00,0x07, 0x00,0x2d,0x28,0x03,0x07,0x02,0x07,0x03,0x07,0x01,0x32,0x02,0x1d,0x28,0x00,0x07, 0x03,0x07,0x00,0x2e,0x07,0x01,0x07,0x02,0x02,0x11,0x00,0x20,0x02,0x1c,0x32,0x00, 0x07,0x00,0x2e,0x07,0x01,0x07,0x02,0x02,0x11,0x00,0x1c,0x36,0x00,0x04,0x01,0x02, 0x00,0x00,0x07,0x00,0x04,0x16,0x1d,0x0c,0x00,0x07,0x01,0x1c,0x19,0x00,0x07,0x00, 0x2d,0x07,0x00,0x2e,0x07,0x01,0x02,0x12,0x00,0x20,0x02,0x01,0x04,0x01,0x00,0x07, 0x01,0x02,0x04,0x18,0x1d,0x50,0x00,0x07,0x02,0x24,0x1e,0x07,0x03,0x02,0x02,0x00, 0x28,0x04,0x07,0x00,0x07,0x01,0x07,0x02,0x07,0x03,0x07,0x04,0x04,0x16,0x1d,0x26, 0x00,0x04,0x1c,0x2b,0x00,0x07,0x04,0x07,0x03,0x0a,0x46,0x75,0x3f,0x05,0x07,0x00, 0x07,0x01,0x02,0x01,0x09,0x07,0x02,0x07,0x04,0x04,0x16,0x1d,0x45,0x00,0x07,0x02, 0x44,0x1c,0x4a,0x00,0x07,0x04,0x02,0x01,0x09,0x02,0x13,0x00,0x1c,0x51,0x00,0x04, 0x01,0x01,0x01,0x00,0x02,0x04,0x3e,0x28,0x01,0x07,0x01,0x02,0x00,0x07,0x00,0x02, 0x00,0x02,0x13,0x00,0x05,0x07,0x01,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x00,0x45, 0x77,0x24,0x1f,0x07,0x00,0x02,0x01,0x45,0x77,0x24,0x20,0x07,0x00,0x02,0x02,0x45, 0x77,0x24,0x21,0x07,0x00,0x02,0x03,0x45,0x77,0x04,0x20,0x02,0x20,0x02,0x20,0x02, 0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x02,0x00,0x00,0x07,0x01,0x07, 0x00,0x44,0x18,0x1d,0x3b,0x00,0x07,0x00,0x07,0x01,0x45,0x7a,0x07,0x01,0x02,0x01, 0x09,0x07,0x00,0x44,0x18,0x1d,0x2c,0x00,0x24,0x22,0x07,0x00,0x07,0x01,0x02,0x01, 0x09,0x02,0x16,0x00,0x20,0x02,0x1c,0x36,0x00,0x07,0x00,0x07,0x01,0x02,0x01,0x09, 0x02,0x16,0x00,0x20,0x02,0x1c,0x3c,0x00,0x04,0x01,0x01,0x00,0x00,0x07,0x00,0x02, 0x00,0x02,0x16,0x00,0x49,0x01,0x01,0x01,0x00,0x02,0x00,0x28,0x01,0x04,0x07,0x01, 0x02,0x05,0x18,0x1d,0x1d,0x00,0x05,0x07,0x01,0x07,0x00,0x4a,0x07,0x01,0x02,0x01, 0x09,0x28,0x01,0x1c,0x05,0x00,0x01,0x03,0x01,0x00,0x02,0x00,0x28,0x03,0x04,0x07, 0x03,0x02,0x06,0x18,0x1d,0x26,0x00,0x05,0x07,0x00,0x07,0x01,0x07,0x03,0x09,0x45, 0x7a,0x26,0x05,0x24,0x23,0x26,0x07,0x03,0x02,0x01,0x09,0x28,0x03,0x1c,0x05,0x00, 0x05,0x07,0x02,0x1d,0x32,0x00,0x24,0x24,0x60,0x1c,0x33,0x00,0x04,0x05,0x07,0x00, 0x01,0x03,0x01,0x00,0x02,0x00,0x28,0x03,0x04,0x07,0x03,0x02,0x04,0x18,0x1d,0x26, 0x00,0x05,0x07,0x00,0x07,0x01,0x07,0x03,0x09,0x45,0x7a,0x26,0x05,0x24,0x25,0x26, 0x07,0x03,0x02,0x01,0x09,0x28,0x03,0x1c,0x05,0x00,0x05,0x07,0x02,0x1d,0x32,0x00, 0x24,0x26,0x60,0x1c,0x33,0x00,0x04,0x05,0x07,0x00,0x01,0x03,0x01,0x00,0x02,0x00, 0x28,0x03,0x04,0x07,0x03,0x02,0x04,0x18,0x1d,0x25,0x00,0x05,0x07,0x00,0x07,0x01, 0x07,0x03,0x09,0x45,0x27,0x05,0x24,0x27,0x26,0x07,0x03,0x02,0x01,0x09,0x28,0x03, 0x1c,0x05,0x00,0x05,0x07,0x02,0x1d,0x31,0x00,0x24,0x28,0x60,0x1c,0x32,0x00,0x04, 0x05,0x07,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x18,0x12,0x7a,0x07,0x00,0x02, 0x10,0x12,0x7a,0x07,0x00,0x02,0x08,0x12,0x7a,0x07,0x00,0x7a,0x04,0x20,0x02,0x20, 0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x01,0x03,0x00,0x02,0x00,0x28,0x01,0x04,0x07, 0x01,0x07,0x00,0x44,0x18,0x1d,0xa8,0x00,0x1c,0x1b,0x00,0x07,0x01,0x02,0x10,0x09, 0x28,0x01,0x1c,0x05,0x00,0x05,0x07,0x01,0x02,0x1c,0x00,0x26,0x05,0x24,0x29,0x26, 0x05,0x02,0x00,0x28,0x02,0x04,0x07,0x02,0x02,0x10,0x18,0x1d,0x5d,0x00,0x05,0x07, 0x00,0x07,0x01,0x07,0x02,0x09,0x45,0x28,0x03,0x07,0x03,0x04,0x16,0x1d,0x4b,0x00, 0x24,0x2a,0x1c,0x4e,0x00,0x07,0x03,0x7a,0x26,0x05,0x24,0x2b,0x26,0x07,0x02,0x02, 0x01,0x09,0x28,0x02,0x1c,0x2c,0x00,0x05,0x24,0x2c,0x26,0x05,0x02,0x00,0x28,0x02, 0x04,0x07,0x02,0x02,0x10,0x18,0x1d,0xa1,0x00,0x05,0x07,0x00,0x07,0x01,0x07,0x02, 0x09,0x45,0x28,0x03,0x07,0x03,0x04,0x16,0x1d,0x86,0x00,0x24,0x2d,0x1c,0x96,0x00, 0x07,0x03,0x02,0x20,0x18,0x1d,0x93,0x00,0x24,0x2e,0x1c,0x96,0x00,0x07,0x03,0x78, 0x26,0x07,0x02,0x02,0x01,0x09,0x28,0x02,0x1c,0x67,0x00,0x05,0x24,0x2f,0x60,0x1c, 0x11,0x00,0x05,0x07,0x00,0x01,0x01,0x08,0x00,0x24,0x30,0x60,0x05,0x07,0x00,0x28, 0x01,0x04,0x07,0x01,0x04,0x17,0x1d,0x89,0x00,0x1c,0x1b,0x00,0x07,0x01,0x2e,0x28, 0x01,0x1c,0x09,0x00,0x05,0x07,0x01,0x2d,0x06,0x22,0x00,0x28,0x02,0x06,0x22,0x01, 0x28,0x03,0x06,0x22,0x02,0x28,0x04,0x06,0x22,0x03,0x28,0x05,0x06,0x22,0x04,0x28, 0x06,0x06,0x22,0x05,0x28,0x07,0x06,0x22,0x06,0x28,0x08,0x05,0x24,0x31,0x26,0x05, 0x07,0x02,0x60,0x05,0x24,0x32,0x26,0x05,0x07,0x03,0x02,0x00,0x02,0x01,0x02,0x19, 0x00,0x05,0x24,0x33,0x26,0x05,0x07,0x04,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x05, 0x24,0x34,0x26,0x05,0x07,0x05,0x5f,0x05,0x24,0x35,0x26,0x05,0x07,0x06,0x5f,0x05, 0x24,0x36,0x26,0x05,0x07,0x07,0x5f,0x05,0x24,0x37,0x26,0x05,0x07,0x08,0x5f,0x1c, 0x13,0x00,0x05,0x07,0x00,0x01,0x00,0x00,0x00,0x24,0x4b,0x60,0x05,0x24,0x4a,0x02, 0x1d,0x00,0x05,0x24,0x4a,0x02,0x00,0x24,0x4c,0x02,0x00,0x24,0x49,0x5c,0x01,0x00, 0x00,0x00,0x02,0x4a,0x24,0x49,0x3e,0x2a,0x05,0x24,0x4a,0x02,0x00,0x24,0x4d,0x02, 0x00,0x24,0x49,0x52,0x05,0x24,0x4a,0x02,0x1d,0x00,0x01,0x02,0x00,0x00,0x24,0x4a, 0x07,0x00,0x07,0x01,0x46,0x01,0x02,0x00,0x00,0x24,0x4a,0x07,0x00,0x07,0x01,0x46, 0x01,0x02,0x01,0x00,0x24,0x4a,0x24,0x4e,0x07,0x00,0x02,0x02,0x00,0x28,0x02,0x24, 0x4a,0x07,0x00,0x07,0x02,0x04,0x16,0x1d,0x1b,0x00,0x07,0x01,0x1c,0x23,0x00,0x07, 0x01,0x07,0x02,0x07,0x00,0x0a,0x3a,0x46,0x01,0x03,0x00,0x00,0x24,0x4a,0x07,0x00, 0x07,0x01,0x02,0x00,0x07,0x02,0x40,0x01,0x03,0x00,0x00,0x24,0x4a,0x07,0x00,0x07, 0x01,0x02,0x00,0x07,0x02,0x40,0x01,0x03,0x01,0x00,0x07,0x01,0x44,0x07,0x02,0x02, 0x01,0x0a,0x3a,0x28,0x03,0x24,0x4a,0x07,0x00,0x07,0x01,0x02,0x00,0x07,0x03,0x40, 0x05,0x24,0x4a,0x07,0x00,0x07,0x03,0x09,0x02,0x00,0x3f,0x01,0x01,0x00,0x00,0x07, 0x00,0x02,0x00,0x45,0x02,0x08,0x11,0x07,0x00,0x02,0x01,0x45,0x09,0x01,0x00,0x00, 0x00,0x24,0x3e,0x02,0x20,0x02,0x23,0x00,0x01,0x00,0x00,0x00,0x24,0x40,0x02,0x01, 0x02,0x21,0x00,0x02,0x00,0x45,0x01,0x00,0x00,0x00,0x24,0x41,0x02,0x40,0x02,0x23, 0x00,0x01,0x00,0x00,0x00,0x24,0x3f,0x02,0x01,0x02,0x21,0x00,0x02,0x00,0x45,0x01, 0x00,0x00,0x00,0x24,0x47,0x02,0x20,0x02,0x22,0x00,0x01,0x00,0x00,0x00,0x24,0x39, 0x02,0x01,0x02,0x21,0x00,0x02,0x00,0x45,0x01,0x00,0x00,0x00,0x24,0x3a,0x02,0x04, 0x02,0x21,0x00,0x01,0x00,0x00,0x00,0x24,0x3b,0x02,0x04,0x02,0x21,0x00,0x01,0x00, 0x00,0x00,0x24,0x3c,0x02,0x04,0x02,0x21,0x00,0x01,0x00,0x00,0x00,0x24,0x3d,0x02, 0x04,0x02,0x21,0x00,0x01,0x00,0x00,0x00,0x24,0x38,0x02,0x28,0x02,0x23,0x00,0x01, 0x00,0x00,0x00,0x24,0x45,0x02,0x06,0x02,0x21,0x00,0x01,0x00,0x00,0x00,0x24,0x46, 0x02,0x06,0x02,0x21,0x00,0x01,0x00,0x00,0x00,0x24,0x42,0x02,0x01,0x02,0x21,0x00, 0x02,0x00,0x45,0x01,0x00,0x00,0x00,0x24,0x43,0x02,0x04,0x02,0x21,0x00,0x01,0x00, 0x00,0x00,0x24,0x44,0x02,0x02,0x02,0x21,0x00,0x02,0x27,0x00,0x01,0x03,0x00,0x00, 0x07,0x00,0x07,0x01,0x07,0x02,0x02,0x08,0x12,0x14,0x3f,0x05,0x07,0x00,0x07,0x01, 0x02,0x01,0x09,0x07,0x02,0x14,0x3f,0x05,0x02,0x00,0x01,0x04,0x00,0x00,0x24,0x53, 0x07,0x00,0x78,0x24,0x0d,0x24,0x09,0x07,0x02,0x07,0x03,0x04,0x20,0x02,0x20,0x02, 0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x01,0x00,0x00,0x24,0x4f,0x24, 0x09,0x24,0x0e,0x07,0x00,0x02,0x39,0x00,0x02,0x00,0x04,0x24,0x0e,0x02,0x00,0x02, 0x01,0x68,0x01,0x02,0x01,0x00,0x07,0x00,0x04,0x17,0x1d,0x3d,0x00,0x07,0x00,0x2d, 0x06,0x22,0x00,0x28,0x02,0x05,0x07,0x01,0x02,0x08,0x02,0x0e,0x09,0x07,0x02,0x02, 0x00,0x02,0x04,0x41,0x15,0x1d,0x2d,0x00,0x07,0x00,0x2e,0x07,0x01,0x02,0x3b,0x00, 0x1c,0x3a,0x00,0x07,0x00,0x2d,0x07,0x00,0x2e,0x07,0x01,0x02,0x3b,0x00,0x20,0x02, 0x1c,0x3e,0x00,0x04,0x01,0x02,0x03,0x00,0x07,0x00,0x04,0x17,0x1d,0x65,0x00,0x07, 0x00,0x2d,0x06,0x22,0x00,0x28,0x02,0x06,0x22,0x02,0x28,0x03,0x05,0x07,0x01,0x02, 0x08,0x02,0x0e,0x09,0x07,0x02,0x02,0x00,0x02,0x04,0x41,0x15,0x1d,0x58,0x00,0x07, 0x01,0x02,0x08,0x02,0x08,0x09,0x02,0x06,0x46,0x28,0x04,0x24,0x54,0x26,0x05,0x07, 0x04,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x05,0x02,0x51,0x07,0x02,0x07,0x04,0x20, 0x02,0x24,0x51,0x20,0x02,0x2a,0x05,0x07,0x03,0x07,0x04,0x32,0x01,0x1c,0x59,0x00, 0x04,0x05,0x07,0x00,0x2e,0x07,0x01,0x02,0x3c,0x00,0x1c,0x66,0x00,0x04,0x01,0x02, 0x02,0x00,0x24,0x55,0x26,0x05,0x07,0x00,0x02,0x08,0x02,0x07,0x09,0x45,0x28,0x02, 0x07,0x02,0x02,0x01,0x16,0x1d,0x4d,0x00,0x07,0x00,0x02,0x20,0x24,0x09,0x02,0x00, 0x02,0x04,0x41,0x15,0x1d,0x47,0x00,0x24,0x50,0x24,0x09,0x07,0x00,0x02,0x10,0x02, 0x06,0x46,0x07,0x00,0x02,0x16,0x02,0x04,0x46,0x02,0x39,0x00,0x02,0x00,0x04,0x07, 0x01,0x02,0x00,0x02,0x01,0x68,0x1c,0x48,0x00,0x04,0x05,0x04,0x1c,0x6f,0x00,0x07, 0x02,0x02,0x02,0x16,0x1d,0x6e,0x00,0x24,0x52,0x28,0x03,0x02,0x52,0x24,0x52,0x07, 0x00,0x02,0x3b,0x00,0x2a,0x05,0x07,0x03,0x07,0x00,0x02,0x3c,0x00,0x1c,0x6f,0x00, 0x04,0x01,0x02,0x00,0x00,0x07,0x01,0x02,0x00,0x18,0x1d,0x0d,0x00,0x02,0x01,0x1c, 0x30,0x00,0x07,0x00,0x07,0x01,0x45,0x24,0x09,0x07,0x01,0x45,0x10,0x24,0x0a,0x07, 0x01,0x45,0x0e,0x1d,0x26,0x00,0x02,0x00,0x1c,0x30,0x00,0x07,0x00,0x07,0x01,0x02, 0x01,0x0a,0x02,0x3e,0x00,0x01,0x01,0x00,0x00,0x24,0x56,0x26,0x05,0x07,0x00,0x02, 0x00,0x02,0x01,0x02,0x1b,0x00,0x05,0x07,0x00,0x02,0x03,0x02,0x3e,0x00,0x5f,0x01, 0x02,0x02,0x00,0x07,0x00,0x02,0x3f,0x00,0x1d,0x0d,0x00,0x07,0x00,0x1c,0x0f,0x00, 0x24,0x0b,0x02,0x00,0x02,0x01,0x02,0x1b,0x00,0x28,0x02,0x24,0x51,0x07,0x02,0x7d, 0x28,0x03,0x07,0x03,0x04,0x17,0x1d,0x2f,0x00,0x07,0x01,0x07,0x03,0x32,0x01,0x1c, 0x46,0x00,0x07,0x02,0x02,0x3a,0x00,0x05,0x02,0x52,0x07,0x02,0x3d,0x07,0x01,0x20, 0x03,0x24,0x52,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x02,0x02,0x00,0x07,0x00,0x04, 0x17,0x1d,0x40,0x00,0x07,0x00,0x2d,0x06,0x22,0x00,0x28,0x02,0x06,0x22,0x01,0x28, 0x03,0x05,0x3d,0x07,0x03,0x0a,0x07,0x01,0x19,0x1d,0x2a,0x00,0x07,0x00,0x2e,0x07, 0x01,0x02,0x41,0x00,0x1c,0x3d,0x00,0x07,0x02,0x02,0x3a,0x00,0x05,0x07,0x00,0x2d, 0x07,0x00,0x2e,0x07,0x01,0x02,0x41,0x00,0x20,0x02,0x1c,0x41,0x00,0x04,0x01,0x00, 0x00,0x00,0x02,0x52,0x24,0x52,0x02,0x0a,0x02,0x41,0x00,0x2a,0x01,0x00,0x00,0x00, 0x02,0x51,0x04,0x2a,0x05,0x02,0x52,0x04,0x2a,0x05,0x02,0x00,0x01,0x05,0x01,0x00, 0x24,0x57,0x07,0x00,0x07,0x01,0x24,0x58,0x07,0x04,0x04,0x20,0x02,0x20,0x02,0x20, 0x02,0x20,0x02,0x20,0x02,0x49,0x28,0x05,0x07,0x05,0x02,0x08,0x02,0x02,0x09,0x02, 0x1c,0x07,0x04,0x44,0x09,0x74,0x05,0x07,0x05,0x02,0x08,0x02,0x14,0x09,0x07,0x02, 0x74,0x05,0x07,0x05,0x02,0x08,0x02,0x16,0x09,0x07,0x03,0x74,0x05,0x07,0x05,0x02, 0x08,0x02,0x18,0x09,0x02,0x08,0x07,0x04,0x44,0x09,0x74,0x05,0x07,0x05,0x02,0x08, 0x02,0x0a,0x09,0x07,0x05,0x02,0x08,0x02,0x14,0x02,0x00,0x6b,0x02,0x38,0x00,0x05, 0x07,0x05,0x02,0x08,0x02,0x1a,0x09,0x07,0x05,0x02,0x08,0x02,0x14,0x09,0x02,0x08, 0x07,0x04,0x44,0x09,0x07,0x05,0x02,0x08,0x02,0x18,0x09,0x02,0x02,0x24,0x59,0x02, 0x00,0x04,0x07,0x05,0x02,0x08,0x02,0x0c,0x09,0x02,0x08,0x02,0x00,0x6b,0x6b,0x6b, 0x6b,0x02,0x38,0x00,0x05,0x07,0x05,0x01,0x02,0x00,0x00,0x24,0x5a,0x26,0x05,0x07, 0x01,0x02,0x00,0x04,0x07,0x00,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x02,0x00,0x02, 0x01,0x68,0x01,0x06,0x02,0x00,0x07,0x00,0x07,0x02,0x07,0x01,0x07,0x03,0x07,0x04, 0x02,0x44,0x00,0x28,0x06,0x07,0x05,0x04,0x17,0x1d,0x20,0x00,0x07,0x05,0x07,0x06, 0x02,0x45,0x00,0x1c,0x2e,0x00,0x07,0x02,0x28,0x07,0x07,0x07,0x02,0x45,0x07,0x06, 0x37,0x02,0x40,0x00,0x01,0x02,0x01,0x00,0x07,0x00,0x04,0x17,0x1d,0x33,0x00,0x07, 0x00,0x2d,0x06,0x22,0x00,0x28,0x02,0x05,0x07,0x02,0x07,0x01,0x16,0x1d,0x23,0x00, 0x07,0x00,0x2e,0x07,0x01,0x02,0x47,0x00,0x1c,0x30,0x00,0x07,0x00,0x2d,0x07,0x00, 0x2e,0x07,0x01,0x02,0x47,0x00,0x20,0x02,0x1c,0x34,0x00,0x04,0x01,0x02,0x00,0x00, 0x02,0x5b,0x07,0x00,0x07,0x01,0x20,0x02,0x24,0x5b,0x07,0x00,0x02,0x47,0x00,0x20, 0x02,0x2a,0x01,0x01,0x00,0x00,0x02,0x5b,0x24,0x5b,0x07,0x00,0x02,0x47,0x00,0x2a, 0x01,0x00,0x00,0x00,0x02,0x5b,0x04,0x2a,0x01,0x02,0x02,0x00,0x24,0x5c,0x26,0x05, 0x07,0x00,0x02,0x08,0x02,0x14,0x09,0x02,0x02,0x09,0x73,0x5f,0x28,0x02,0x24,0x5b, 0x07,0x02,0x7c,0x28,0x03,0x07,0x03,0x07,0x00,0x02,0x08,0x02,0x14,0x09,0x02,0x08, 0x09,0x04,0x46,0x07,0x01,0x07,0x00,0x02,0x14,0x02,0x04,0x46,0x32,0x03,0x01,0x08, 0x03,0x00,0x24,0x6f,0x07,0x00,0x07,0x01,0x24,0x70,0x07,0x04,0x07,0x05,0x24,0x71, 0x07,0x06,0x24,0x5e,0x0e,0x1d,0x22,0x00,0x24,0x72,0x07,0x07,0x04,0x20,0x02,0x20, 0x02,0x1c,0x27,0x00,0x07,0x07,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20, 0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x28,0x08,0x07,0x08,0x44,0x28,0x09,0x07, 0x08,0x02,0x08,0x02,0x02,0x09,0x07,0x09,0x02,0x08,0x0a,0x74,0x05,0x07,0x08,0x02, 0x08,0x02,0x14,0x09,0x07,0x02,0x74,0x05,0x07,0x08,0x02,0x08,0x02,0x16,0x09,0x07, 0x03,0x74,0x05,0x07,0x08,0x02,0x08,0x02,0x20,0x09,0x02,0x04,0x07,0x06,0x24,0x5e, 0x0e,0x1d,0x77,0x00,0x02,0x18,0x1c,0x79,0x00,0x02,0x14,0x0b,0x3f,0x05,0x07,0x08, 0x02,0x08,0x02,0x21,0x09,0x07,0x06,0x3f,0x05,0x07,0x08,0x02,0x08,0x02,0x0a,0x09, 0x07,0x08,0x02,0x08,0x02,0x14,0x02,0x00,0x6b,0x02,0x38,0x00,0x05,0x02,0x02,0x3e, 0x28,0x0a,0x07,0x0a,0x02,0x00,0x07,0x09,0x02,0x1c,0x0a,0x74,0x05,0x07,0x08,0x02, 0x08,0x02,0x24,0x09,0x07,0x08,0x02,0x08,0x02,0x14,0x09,0x07,0x09,0x02,0x1c,0x0a, 0x07,0x0a,0x02,0x00,0x02,0x02,0x24,0x73,0x02,0x00,0x04,0x07,0x08,0x02,0x08,0x02, 0x0c,0x09,0x02,0x08,0x02,0x00,0x6b,0x6b,0x6b,0x6b,0x02,0x38,0x00,0x05,0x07,0x08, 0x01,0x03,0x00,0x00,0x07,0x00,0x22,0x01,0x07,0x00,0x22,0x02,0x07,0x00,0x22,0x03, 0x07,0x00,0x22,0x04,0x07,0x00,0x22,0x05,0x07,0x00,0x22,0x06,0x07,0x01,0x07,0x02, 0x02,0x4c,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x22,0x09,0x02,0x00,0x04,0x07,0x00, 0x22,0x08,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x02,0x00,0x02,0x01,0x68,0x05,0x02, 0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x08,0x02,0x20,0x09,0x45,0x02,0x04,0x12, 0x02,0x02,0x11,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x0a,0x73,0x02,0x14,0x0a,0x07, 0x00,0x02,0x4f,0x00,0x0a,0x01,0x02,0x01,0x00,0x07,0x01,0x02,0x00,0x04,0x07,0x00, 0x22,0x08,0x02,0x00,0x02,0x01,0x68,0x05,0x07,0x01,0x02,0x08,0x02,0x21,0x09,0x45, 0x28,0x02,0x07,0x00,0x02,0x05,0x07,0x00,0x22,0x05,0x07,0x01,0x02,0x50,0x00,0x07, 0x02,0x24,0x5e,0x24,0x5d,0x0f,0x0e,0x1d,0x36,0x00,0x02,0x01,0x1c,0x38,0x00,0x02, 0x00,0x09,0x72,0x30,0x05,0x02,0x00,0x01,0x02,0x00,0x00,0x07,0x00,0x02,0x09,0x07, 0x01,0x30,0x05,0x07,0x00,0x02,0x0a,0x04,0x30,0x05,0x07,0x00,0x07,0x01,0x02,0x51, 0x00,0x01,0x03,0x00,0x00,0x07,0x01,0x02,0x08,0x07,0x00,0x30,0x05,0x07,0x01,0x07, 0x02,0x02,0x52,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x00,0x24,0x63,0x30,0x05, 0x02,0x74,0x24,0x74,0x07,0x00,0x02,0x0e,0x00,0x2a,0x01,0x05,0x04,0x00,0x07,0x01, 0x04,0x16,0x1d,0x29,0x00,0x03,0x00,0x04,0x00,0x00,0x02,0x75,0x24,0x75,0x04,0x16, 0x1d,0x19,0x00,0x35,0x1c,0x1b,0x00,0x24,0x75,0x02,0x01,0x09,0x03,0xff,0x3f,0x00, 0x00,0x0e,0x2a,0x09,0x1c,0x2b,0x00,0x07,0x01,0x28,0x05,0x1e,0x0d,0x24,0x64,0x2b, 0x00,0x07,0x00,0x2b,0x01,0x07,0x02,0x2b,0x02,0x07,0x05,0x2b,0x03,0x07,0x03,0x2b, 0x04,0x24,0x68,0x2b,0x05,0x24,0x69,0x2b,0x06,0x07,0x04,0x2b,0x07,0x02,0x01,0x2b, 0x0c,0x28,0x06,0x07,0x06,0x24,0x5e,0x04,0x02,0x4d,0x00,0x28,0x07,0x07,0x02,0x28, 0x08,0x02,0x74,0x07,0x06,0x24,0x74,0x20,0x02,0x2a,0x05,0x07,0x08,0x02,0x53,0x07, 0x07,0x37,0x07,0x06,0x37,0x02,0x40,0x00,0x05,0x07,0x06,0x01,0x02,0x01,0x00,0x1e, 0x0d,0x24,0x66,0x2b,0x00,0x07,0x00,0x2b,0x03,0x07,0x01,0x2b,0x07,0x02,0x01,0x2b, 0x0c,0x28,0x02,0x02,0x74,0x07,0x02,0x24,0x74,0x20,0x02,0x2a,0x01,0x04,0x01,0x00, 0x07,0x00,0x04,0x17,0x1d,0x7d,0x00,0x07,0x00,0x2d,0x28,0x04,0x07,0x04,0x22,0x03, 0x07,0x01,0x16,0x06,0x1d,0x1f,0x00,0x05,0x07,0x04,0x22,0x04,0x07,0x02,0x16,0x06, 0x1d,0x35,0x00,0x05,0x07,0x03,0x02,0x08,0x02,0x10,0x09,0x07,0x04,0x22,0x01,0x02, 0x00,0x02,0x04,0x41,0x15,0x06,0x1d,0x4b,0x00,0x05,0x07,0x03,0x02,0x08,0x02,0x0c, 0x09,0x07,0x04,0x22,0x02,0x02,0x00,0x02,0x04,0x41,0x15,0x1d,0x53,0x00,0x07,0x04, 0x1c,0x7a,0x00,0x07,0x04,0x22,0x00,0x24,0x66,0x16,0x06,0x1d,0x66,0x00,0x05,0x07, 0x04,0x22,0x03,0x07,0x01,0x16,0x1d,0x6e,0x00,0x07,0x04,0x1c,0x7a,0x00,0x07,0x00, 0x2e,0x07,0x01,0x07,0x02,0x07,0x03,0x02,0x57,0x00,0x1c,0x7e,0x00,0x04,0x01,0x01, 0x00,0x00,0x24,0x76,0x60,0x05,0x07,0x00,0x07,0x00,0x24,0x5d,0x24,0x61,0x09,0x04, 0x02,0x4d,0x00,0x02,0x51,0x00,0x05,0x07,0x00,0x02,0x00,0x24,0x67,0x30,0x05,0x02, 0x00,0x01,0x02,0x0c,0x00,0x24,0x77,0x26,0x05,0x07,0x00,0x02,0x08,0x02,0x14,0x09, 0x02,0x02,0x09,0x73,0x28,0x02,0x07,0x00,0x02,0x08,0x02,0x14,0x09,0x02,0x00,0x09, 0x73,0x28,0x03,0x24,0x74,0x07,0x02,0x07,0x03,0x07,0x00,0x02,0x57,0x00,0x28,0x04, 0x07,0x04,0x04,0x17,0x06,0x1d,0x38,0x00,0x05,0x07,0x04,0x22,0x0c,0x1d,0x0b,0x03, 0x07,0x04,0x22,0x00,0x28,0x05,0x07,0x00,0x02,0x08,0x02,0x21,0x09,0x45,0x28,0x06, 0x07,0x00,0x02,0x08,0x02,0x18,0x09,0x02,0x04,0x46,0x28,0x07,0x07,0x00,0x02,0x08, 0x02,0x1c,0x09,0x02,0x04,0x46,0x28,0x08,0x07,0x05,0x24,0x64,0x16,0x1d,0xec,0x00, 0x24,0x78,0x60,0x05,0x07,0x06,0x24,0x5e,0x24,0x61,0x09,0x16,0x06,0x1d,0x91,0x00, 0x05,0x07,0x04,0x22,0x05,0x02,0x00,0x02,0x01,0x02,0x1a,0x00,0x02,0x00,0x07,0x08, 0x02,0x00,0x02,0x04,0x41,0x15,0x1d,0xd1,0x00,0x07,0x04,0x02,0x06,0x07,0x07,0x02, 0x01,0x72,0x02,0x00,0x02,0x01,0x02,0x1a,0x00,0x30,0x05,0x07,0x04,0x07,0x04,0x24, 0x61,0x04,0x02,0x4d,0x00,0x02,0x51,0x00,0x05,0x07,0x04,0x02,0x00,0x24,0x65,0x30, 0x05,0x07,0x04,0x02,0x09,0x04,0x30,0x05,0x07,0x04,0x22,0x07,0x07,0x04,0x24,0x6a, 0x04,0x32,0x03,0x1c,0xe9,0x00,0x07,0x04,0x07,0x04,0x24,0x5f,0x24,0x61,0x09,0x04, 0x02,0x4d,0x00,0x02,0x51,0x00,0x05,0x07,0x04,0x02,0x54,0x00,0x05,0x04,0x1c,0x08, 0x03,0x07,0x05,0x24,0x65,0x16,0x1d,0x53,0x02,0x07,0x04,0x22,0x06,0x02,0x00,0x07, 0x07,0x02,0x00,0x02,0x04,0x41,0x15,0x1d,0x3d,0x02,0x07,0x00,0x02,0x0a,0x73,0x28, 0x09,0x07,0x00,0x02,0x08,0x02,0x20,0x09,0x45,0x02,0x04,0x12,0x02,0x02,0x11,0x28, 0x0a,0x07,0x00,0x02,0x50,0x00,0x28,0x0b,0x07,0x0b,0x1d,0x37,0x01,0x07,0x04,0x02, 0x06,0x07,0x04,0x22,0x06,0x07,0x0b,0x72,0x30,0x1c,0x38,0x01,0x04,0x05,0x07,0x06, 0x24,0x5d,0x0e,0x1d,0x52,0x01,0x07,0x04,0x02,0x06,0x07,0x04,0x22,0x06,0x02,0x01, 0x72,0x30,0x05,0x04,0x1c,0xbd,0x01,0x07,0x04,0x22,0x05,0x02,0x00,0x07,0x08,0x02, 0x00,0x02,0x04,0x41,0x15,0x1d,0xa2,0x01,0x07,0x04,0x02,0x09,0x04,0x30,0x05,0x07, 0x04,0x22,0x0b,0x02,0x01,0x16,0x1d,0x8a,0x01,0x07,0x04,0x02,0x0b,0x02,0x00,0x30, 0x05,0x07,0x04,0x22,0x07,0x07,0x04,0x24,0x6a,0x04,0x32,0x03,0x1c,0x9f,0x01,0x07, 0x04,0x22,0x0b,0x02,0x02,0x16,0x1d,0x9e,0x01,0x07,0x04,0x02,0x58,0x00,0x05,0x04, 0x1c,0x9f,0x01,0x04,0x1c,0xbd,0x01,0x24,0x79,0x60,0x05,0x07,0x04,0x22,0x05,0x02, 0x00,0x02,0x01,0x02,0x1a,0x00,0x05,0x07,0x08,0x02,0x00,0x02,0x01,0x02,0x1a,0x00, 0x05,0x04,0x05,0x07,0x0b,0x1d,0xe8,0x01,0x02,0x08,0x02,0x14,0x09,0x07,0x00,0x02, 0x4f,0x00,0x09,0x28,0x0c,0x07,0x00,0x07,0x0c,0x07,0x0b,0x46,0x28,0x0d,0x07,0x04, 0x22,0x07,0x07,0x04,0x24,0x6b,0x07,0x0d,0x32,0x03,0x1c,0xe9,0x01,0x04,0x05,0x07, 0x0b,0x06,0x15,0x1d,0xf7,0x01,0x05,0x07,0x06,0x24,0x5d,0x0e,0x1d,0x0a,0x02,0x07, 0x04,0x07,0x04,0x24,0x61,0x04,0x02,0x4d,0x00,0x02,0x51,0x00,0x1c,0x0b,0x02,0x04, 0x05,0x07,0x06,0x24,0x5d,0x0e,0x1d,0x39,0x02,0x07,0x04,0x07,0x04,0x24,0x5d,0x24, 0x61,0x09,0x04,0x02,0x4d,0x00,0x02,0x51,0x00,0x05,0x07,0x04,0x02,0x54,0x00,0x05, 0x07,0x04,0x22,0x07,0x07,0x04,0x24,0x6c,0x04,0x32,0x03,0x1c,0x3a,0x02,0x04,0x1c, 0x50,0x02,0x24,0x7a,0x26,0x05,0x07,0x04,0x07,0x04,0x24,0x61,0x04,0x02,0x4d,0x00, 0x02,0x51,0x00,0x05,0x04,0x1c,0x08,0x03,0x07,0x05,0x24,0x67,0x16,0x1d,0x89,0x02, 0x24,0x7b,0x60,0x05,0x07,0x04,0x02,0x06,0x07,0x07,0x02,0x01,0x72,0x02,0x00,0x02, 0x01,0x02,0x1a,0x00,0x30,0x05,0x07,0x04,0x07,0x04,0x24,0x61,0x04,0x02,0x4d,0x00, 0x02,0x51,0x00,0x05,0x07,0x04,0x02,0x54,0x00,0x05,0x04,0x1c,0x08,0x03,0x07,0x05, 0x24,0x66,0x16,0x1d,0x07,0x03,0x07,0x06,0x24,0x5e,0x0e,0x1d,0x03,0x03,0x1e,0x0d, 0x24,0x65,0x2b,0x00,0x07,0x00,0x02,0x08,0x02,0x10,0x09,0x02,0x04,0x46,0x2b,0x01, 0x07,0x00,0x02,0x08,0x02,0x0c,0x09,0x02,0x04,0x46,0x2b,0x02,0x07,0x02,0x2b,0x03, 0x07,0x03,0x2b,0x04,0x24,0x68,0x2b,0x05,0x07,0x07,0x02,0x01,0x72,0x2b,0x06,0x07, 0x04,0x22,0x07,0x2b,0x07,0x07,0x01,0x2b,0x08,0x02,0x01,0x2b,0x0c,0x28,0x09,0x02, 0x74,0x07,0x09,0x24,0x74,0x20,0x02,0x2a,0x05,0x07,0x09,0x07,0x09,0x24,0x61,0x24, 0x5e,0x09,0x04,0x02,0x4d,0x00,0x02,0x52,0x00,0x05,0x07,0x09,0x22,0x07,0x07,0x09, 0x24,0x6d,0x04,0x32,0x03,0x1c,0x04,0x03,0x04,0x1c,0x08,0x03,0x04,0x1c,0x0c,0x03, 0x04,0x01,0x03,0x03,0x00,0x07,0x00,0x22,0x00,0x24,0x65,0x17,0x1d,0x0e,0x00,0x04, 0x1c,0x5f,0x00,0x07,0x00,0x22,0x09,0x04,0x17,0x1d,0x24,0x00,0x07,0x00,0x02,0x0b, 0x02,0x01,0x30,0x05,0x07,0x02,0x1c,0x5f,0x00,0x07,0x01,0x07,0x02,0x24,0x6e,0x46, 0x28,0x03,0x07,0x00,0x24,0x61,0x07,0x03,0x02,0x4d,0x00,0x28,0x04,0x07,0x00,0x07, 0x04,0x02,0x52,0x00,0x05,0x07,0x02,0x07,0x03,0x44,0x09,0x28,0x05,0x07,0x05,0x07, 0x01,0x44,0x17,0x1d,0x5b,0x00,0x07,0x00,0x02,0x0b,0x02,0x01,0x30,0x1c,0x5c,0x00, 0x04,0x05,0x07,0x05,0x01,0x01,0x00,0x00,0x07,0x00,0x22,0x00,0x24,0x65,0x17,0x1d, 0x0f,0x00,0x02,0x00,0x1c,0x2a,0x00,0x07,0x00,0x22,0x09,0x04,0x17,0x1d,0x25,0x00, 0x07,0x00,0x02,0x0b,0x02,0x02,0x30,0x05,0x02,0x00,0x1c,0x2a,0x00,0x07,0x00,0x02, 0x58,0x00,0x05,0x02,0x00,0x01,0x02,0x00,0x00,0x07,0x00,0x02,0x07,0x07,0x01,0x30, 0x01,0x02,0x00,0x00,0x07,0x00,0x02,0x0c,0x07,0x01,0x30,0x01,0x00,0x02,0x00,0x24, 0x74,0x28,0x00,0x04,0x07,0x00,0x04,0x17,0x1d,0x72,0x00,0x1c,0x17,0x00,0x07,0x00, 0x2e,0x28,0x00,0x1c,0x05,0x00,0x05,0x07,0x00,0x2d,0x28,0x01,0x07,0x01,0x22,0x09, 0x04,0x17,0x1d,0x6e,0x00,0x07,0x01,0x22,0x0a,0x04,0x17,0x1d,0x64,0x00,0x07,0x01, 0x02,0x0a,0x02,0x01,0x07,0x01,0x22,0x0a,0x09,0x30,0x05,0x07,0x01,0x22,0x0a,0x02, 0x0a,0x19,0x1d,0x5c,0x00,0x07,0x01,0x02,0x54,0x00,0x05,0x07,0x01,0x22,0x07,0x07, 0x01,0x24,0x6c,0x04,0x32,0x03,0x05,0x04,0x1c,0x61,0x00,0x07,0x01,0x02,0x4e,0x00, 0x1c,0x6b,0x00,0x07,0x01,0x02,0x0a,0x02,0x00,0x30,0x1c,0x6f,0x00,0x04,0x1c,0x0f, 0x00,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0x74,0x04,0x2a,0x05,0x02,0x00,0x01, 0x04,0x03,0x00,0x02,0xec,0x02,0x10,0x09,0x02,0x0e,0x09,0x28,0x04,0x07,0x04,0x3e, 0x28,0x05,0x02,0x00,0x28,0x06,0x04,0x07,0x06,0x07,0x04,0x18,0x1d,0x2e,0x00,0x05, 0x07,0x05,0x07,0x06,0x02,0x00,0x3f,0x07,0x06,0x02,0x01,0x09,0x28,0x06,0x1c,0x14, 0x00,0x05,0x07,0x05,0x02,0x00,0x24,0x81,0x02,0x00,0x02,0x03,0x40,0x05,0x07,0x05, 0x02,0x0c,0x07,0x01,0x02,0x00,0x02,0x04,0x40,0x05,0x07,0x05,0x02,0x0c,0x02,0x10, 0x09,0x24,0x0d,0x02,0x00,0x02,0x06,0x40,0x05,0x07,0x05,0x02,0xec,0x24,0x82,0x02, 0x00,0x02,0x06,0x40,0x05,0x07,0x05,0x02,0xec,0x02,0x06,0x09,0x07,0x00,0x3f,0x05, 0x07,0x05,0x02,0xec,0x02,0x07,0x09,0x24,0x83,0x02,0x00,0x02,0x03,0x40,0x05,0x07, 0x05,0x02,0xec,0x02,0x0a,0x09,0x24,0x0d,0x02,0x00,0x02,0x06,0x40,0x05,0x07,0x05, 0x02,0xec,0x02,0x10,0x09,0x24,0x84,0x02,0x00,0x02,0x0e,0x40,0x05,0x07,0x00,0x24, 0x7e,0x16,0x1d,0xbf,0x00,0x07,0x05,0x24,0x85,0x07,0x02,0x24,0x86,0x07,0x03,0x24, 0x87,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x1c, 0xc4,0x00,0x07,0x05,0x24,0x88,0x47,0x01,0x04,0x03,0x00,0x02,0xec,0x02,0x07,0x09, 0x28,0x04,0x07,0x04,0x3e,0x28,0x05,0x02,0x00,0x28,0x06,0x04,0x07,0x06,0x07,0x04, 0x18,0x1d,0x2b,0x00,0x05,0x07,0x05,0x07,0x06,0x02,0x00,0x3f,0x07,0x06,0x02,0x01, 0x09,0x28,0x06,0x1c,0x11,0x00,0x05,0x07,0x05,0x02,0x00,0x24,0x89,0x02,0x00,0x02, 0x03,0x40,0x05,0x07,0x05,0x02,0x04,0x07,0x01,0x02,0x00,0x02,0x04,0x40,0x05,0x07, 0x05,0x02,0x10,0x07,0x02,0x02,0x00,0x02,0x04,0x40,0x05,0x07,0x05,0x02,0x0c,0x02, 0x10,0x09,0x07,0x03,0x02,0x00,0x02,0x06,0x40,0x05,0x07,0x05,0x02,0xec,0x24,0x8a, 0x02,0x00,0x02,0x06,0x40,0x05,0x07,0x05,0x02,0xec,0x02,0x06,0x09,0x07,0x00,0x3f, 0x05,0x07,0x05,0x24,0x8b,0x07,0x02,0x24,0x8c,0x24,0x0a,0x24,0x8d,0x24,0x09,0x24, 0x8e,0x24,0x09,0x24,0x8f,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02, 0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x08,0x03,0x00,0x07, 0x01,0x07,0x00,0x44,0x18,0x1d,0x36,0x01,0x07,0x00,0x07,0x01,0x45,0x28,0x08,0x07, 0x08,0x02,0xff,0x16,0x1d,0x29,0x00,0x07,0x02,0x07,0x03,0x07,0x04,0x07,0x05,0x07, 0x06,0x07,0x07,0x20,0x06,0x1c,0x33,0x01,0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x45, 0x28,0x09,0x07,0x01,0x02,0x02,0x09,0x28,0x0a,0x07,0x08,0x02,0x35,0x16,0x1d,0x5e, 0x00,0x07,0x00,0x07,0x0a,0x07,0x09,0x09,0x07,0x00,0x07,0x0a,0x45,0x07,0x03,0x07, 0x04,0x07,0x05,0x07,0x06,0x07,0x07,0x02,0x62,0x00,0x1c,0x33,0x01,0x07,0x08,0x02, 0x33,0x16,0x1d,0x82,0x00,0x07,0x00,0x07,0x0a,0x07,0x09,0x09,0x07,0x02,0x07,0x00, 0x07,0x0a,0x73,0x07,0x04,0x07,0x05,0x07,0x06,0x07,0x07,0x02,0x62,0x00,0x1c,0x33, 0x01,0x07,0x08,0x02,0x01,0x16,0x1d,0xa8,0x00,0x07,0x00,0x07,0x0a,0x07,0x09,0x09, 0x07,0x02,0x07,0x03,0x07,0x00,0x07,0x0a,0x02,0x04,0x46,0x07,0x05,0x07,0x06,0x07, 0x07,0x02,0x62,0x00,0x1c,0x33,0x01,0x07,0x08,0x02,0x06,0x16,0x1d,0xce,0x00,0x07, 0x00,0x07,0x0a,0x07,0x09,0x09,0x07,0x02,0x07,0x03,0x07,0x04,0x07,0x00,0x07,0x0a, 0x02,0x04,0x46,0x07,0x06,0x07,0x07,0x02,0x62,0x00,0x1c,0x33,0x01,0x07,0x08,0x02, 0x03,0x16,0x1d,0xf4,0x00,0x07,0x00,0x07,0x0a,0x07,0x09,0x09,0x07,0x02,0x07,0x03, 0x07,0x04,0x07,0x05,0x07,0x00,0x07,0x0a,0x02,0x04,0x46,0x07,0x07,0x02,0x62,0x00, 0x1c,0x33,0x01,0x07,0x08,0x02,0x3d,0x16,0x1d,0x1d,0x01,0x07,0x00,0x07,0x0a,0x07, 0x09,0x09,0x07,0x02,0x07,0x03,0x07,0x04,0x07,0x05,0x07,0x06,0x07,0x00,0x07,0x0a, 0x02,0x01,0x09,0x02,0x06,0x46,0x02,0x62,0x00,0x1c,0x33,0x01,0x07,0x00,0x07,0x0a, 0x07,0x09,0x09,0x07,0x02,0x07,0x03,0x07,0x04,0x07,0x05,0x07,0x06,0x07,0x07,0x02, 0x62,0x00,0x1c,0x37,0x01,0x04,0x01,0x01,0x01,0x00,0x02,0x04,0x3e,0x28,0x01,0x07, 0x01,0x02,0x00,0x24,0x09,0x02,0x00,0x02,0x04,0x40,0x05,0x07,0x01,0x02,0x03,0x07, 0x00,0x02,0x05,0x45,0x02,0x7f,0x0e,0x02,0x64,0x09,0x3f,0x05,0x07,0x01,0x01,0x03, 0x08,0x00,0x24,0x90,0x60,0x05,0x07,0x01,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x05, 0x07,0x00,0x02,0x00,0x45,0x28,0x03,0x07,0x00,0x02,0x1c,0x02,0x06,0x46,0x02,0x00, 0x02,0x01,0x02,0x19,0x00,0x28,0x04,0x07,0x03,0x02,0x02,0x16,0x06,0x1d,0x35,0x00, 0x05,0x07,0x04,0x24,0x0d,0x89,0x15,0x1d,0x0f,0x01,0x07,0x00,0x02,0x10,0x02,0x04, 0x46,0x02,0x00,0x02,0x01,0x02,0x1b,0x00,0x28,0x05,0x07,0x00,0x02,0xf0,0x02,0x00, 0x04,0x04,0x04,0x04,0x04,0x02,0x62,0x00,0x06,0x22,0x00,0x28,0x06,0x06,0x22,0x01, 0x28,0x07,0x06,0x22,0x02,0x28,0x08,0x06,0x22,0x03,0x28,0x09,0x06,0x22,0x04,0x28, 0x0a,0x05,0x07,0x06,0x24,0x7d,0x16,0x1d,0x99,0x00,0x24,0x91,0x60,0x05,0x24,0x09, 0x02,0x44,0x24,0x0f,0x02,0x43,0x24,0x7e,0x24,0x09,0x07,0x02,0x07,0x05,0x02,0x60, 0x00,0x24,0x0e,0x02,0x46,0x00,0x05,0x04,0x1c,0x0c,0x01,0x07,0x06,0x24,0x80,0x16, 0x1d,0x0b,0x01,0x24,0x92,0x60,0x05,0x24,0x93,0x26,0x05,0x07,0x02,0x02,0x00,0x02, 0x01,0x02,0x1b,0x00,0x05,0x24,0x94,0x26,0x05,0x02,0x09,0x07,0x05,0x2a,0x02,0x00, 0x02,0x01,0x02,0x1b,0x00,0x05,0x24,0x95,0x26,0x05,0x07,0x06,0x5f,0x05,0x24,0x96, 0x26,0x05,0x07,0x07,0x5f,0x05,0x24,0x97,0x26,0x05,0x02,0x0a,0x07,0x08,0x2a,0x02, 0x00,0x02,0x01,0x02,0x1b,0x00,0x05,0x24,0x98,0x26,0x05,0x02,0x0c,0x07,0x09,0x2a, 0x02,0x00,0x02,0x01,0x02,0x1b,0x00,0x05,0x24,0x99,0x26,0x05,0x02,0x0b,0x07,0x0a, 0x2a,0x02,0x00,0x02,0x01,0x02,0x1b,0x00,0x05,0x04,0x1c,0x0c,0x01,0x04,0x1c,0x10, 0x01,0x04,0x01,0x03,0x06,0x00,0x24,0x9a,0x60,0x05,0x07,0x01,0x02,0x00,0x02,0x01, 0x02,0x19,0x00,0x05,0x07,0x00,0x02,0x00,0x45,0x28,0x03,0x07,0x00,0x02,0x1c,0x02, 0x06,0x46,0x02,0x00,0x02,0x01,0x02,0x19,0x00,0x28,0x04,0x07,0x03,0x02,0x01,0x16, 0x1d,0xac,0x00,0x07,0x00,0x02,0xf0,0x02,0x00,0x04,0x04,0x04,0x04,0x04,0x02,0x62, 0x00,0x06,0x22,0x00,0x28,0x05,0x06,0x22,0x05,0x28,0x06,0x05,0x07,0x00,0x02,0x04, 0x02,0x04,0x46,0x28,0x07,0x07,0x01,0x02,0x63,0x00,0x28,0x08,0x07,0x05,0x24,0x7c, 0x16,0x1d,0x7f,0x00,0x24,0x9b,0x60,0x05,0x24,0x09,0x02,0x43,0x24,0x0f,0x02,0x44, 0x24,0x7d,0x07,0x07,0x07,0x08,0x07,0x06,0x02,0x61,0x00,0x24,0x0e,0x02,0x46,0x00, 0x05,0x04,0x1c,0xa9,0x00,0x07,0x05,0x24,0x7e,0x16,0x1d,0xa8,0x00,0x24,0x9c,0x60, 0x05,0x24,0x09,0x02,0x43,0x24,0x0f,0x02,0x44,0x24,0x80,0x07,0x07,0x07,0x08,0x07, 0x06,0x02,0x61,0x00,0x24,0x0e,0x02,0x46,0x00,0x05,0x04,0x1c,0xa9,0x00,0x04,0x1c, 0xad,0x00,0x04,0x01,0x00,0x00,0x00,0x24,0x09,0x02,0x44,0x24,0x0f,0x02,0x43,0x24, 0x7c,0x24,0x9d,0x04,0x04,0x02,0x60,0x00,0x24,0x0e,0x02,0x46,0x00,0x05,0x02,0x44, 0x02,0x64,0x02,0x48,0x00,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0x43,0x02,0x65, 0x02,0x48,0x00,0x05,0x02,0x00,0x01,0x02,0x02,0x00,0x24,0x9e,0x26,0x05,0x07,0x00, 0x02,0x07,0x45,0x28,0x02,0x07,0x02,0x02,0x06,0x16,0x1d,0x1d,0x00,0x07,0x00,0x07, 0x01,0x02,0x3d,0x00,0x1c,0x55,0x00,0x07,0x02,0x02,0x00,0x16,0x1d,0x54,0x00,0x07, 0x00,0x02,0x11,0x45,0x28,0x03,0x07,0x03,0x02,0x06,0x16,0x1d,0x3e,0x00,0x07,0x00, 0x07,0x01,0x02,0x59,0x00,0x1c,0x51,0x00,0x07,0x03,0x02,0x11,0x16,0x1d,0x50,0x00, 0x07,0x00,0x07,0x01,0x02,0x4b,0x00,0x1c,0x51,0x00,0x04,0x1c,0x55,0x00,0x04,0x05, 0x02,0x00,0x05,0x02,0x01,0x00,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0x68,0x67, 0x05,0x02,0x43,0x00,0x05,0x02,0x5f,0x00,0x05,0x02,0x4a,0x00,0x05,0x02,0x00,0x01, 0x00,0x00,0x00,0x02,0x42,0x00,0x05,0x02,0x5e,0x00,0x05,0x02,0x00,0x01,0x02,0x01, 0x00,0x07,0x00,0x07,0x01,0x24,0x9f,0x02,0x00,0x04,0x42,0x28,0x02,0x07,0x02,0x02, 0x05,0x09,0x01,0x03,0x00,0x00,0x07,0x02,0x02,0x00,0x1a,0x1d,0x0d,0x00,0x07,0x01, 0x1c,0x1e,0x00,0x07,0x00,0x07,0x00,0x07,0x01,0x02,0x6b,0x00,0x07,0x02,0x02,0x01, 0x0a,0x02,0x6c,0x00,0x01,0x02,0x01,0x00,0x07,0x00,0x07,0x01,0x73,0x28,0x02,0x07, 0x02,0x03,0x00,0xc0,0x00,0x00,0x0e,0x03,0x00,0xc0,0x00,0x00,0x16,0x1d,0x20,0x00, 0x07,0x01,0x02,0x02,0x09,0x1c,0x2d,0x00,0x07,0x00,0x07,0x01,0x24,0xa0,0x02,0x00, 0x04,0x42,0x02,0x01,0x09,0x01,0x03,0x02,0x00,0x07,0x02,0x02,0x00,0x1a,0x1d,0x0c, 0x00,0x04,0x1c,0x79,0x00,0x07,0x00,0x07,0x01,0x02,0x6d,0x00,0x28,0x03,0x07,0x00, 0x07,0x03,0x73,0x28,0x04,0x07,0x04,0x02,0x01,0x16,0x1d,0x61,0x00,0x07,0x00,0x07, 0x03,0x02,0x0a,0x09,0x45,0x77,0x24,0xa1,0x07,0x00,0x07,0x03,0x02,0x0b,0x09,0x45, 0x77,0x24,0xa2,0x07,0x00,0x07,0x03,0x02,0x0c,0x09,0x45,0x77,0x24,0xa3,0x07,0x00, 0x07,0x03,0x02,0x0d,0x09,0x45,0x77,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02, 0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x1c,0x79,0x00,0x07,0x00,0x07,0x03,0x02,0x0a, 0x09,0x07,0x00,0x07,0x03,0x02,0x08,0x09,0x73,0x09,0x07,0x02,0x02,0x01,0x0a,0x02, 0x6e,0x00,0x01,0x01,0x05,0x00,0x07,0x00,0x02,0x00,0x73,0x28,0x01,0x07,0x00,0x02, 0x02,0x73,0x28,0x02,0x07,0x00,0x02,0x04,0x73,0x28,0x03,0x07,0x00,0x02,0x06,0x73, 0x28,0x04,0x07,0x04,0x02,0x00,0x16,0x1d,0x28,0x00,0x04,0x1c,0x3c,0x00,0x07,0x00, 0x02,0x0c,0x07,0x03,0x02,0x6c,0x00,0x28,0x05,0x07,0x00,0x07,0x05,0x07,0x04,0x02, 0x6e,0x00,0x01,0x01,0x01,0x00,0x07,0x00,0x02,0x00,0x24,0xa4,0x02,0x00,0x04,0x42, 0x28,0x01,0x07,0x01,0x04,0x17,0x1d,0x2e,0x00,0x07,0x01,0x78,0x07,0x00,0x02,0x00, 0x07,0x01,0x46,0x47,0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x04,0x46,0x02,0x70,0x00, 0x47,0x1c,0x35,0x00,0x07,0x00,0x44,0x78,0x07,0x00,0x47,0x01,0x02,0x00,0x00,0x07, 0x00,0x7b,0x24,0xa5,0x07,0x01,0x02,0x70,0x00,0x24,0xa6,0x04,0x20,0x02,0x20,0x02, 0x20,0x02,0x20,0x02,0x49,0x01,0x02,0x02,0x00,0x02,0xa7,0x24,0xa7,0x04,0x16,0x1d, 0x0d,0x00,0x35,0x1c,0x12,0x00,0x24,0xa7,0x02,0x01,0x09,0x2a,0x05,0x24,0xa9,0x07, 0x00,0x7d,0x28,0x02,0x07,0x02,0x04,0x17,0x1d,0x2b,0x00,0x07,0x01,0x07,0x02,0x32, 0x01,0x1c,0x67,0x00,0x24,0xa7,0x07,0x00,0x02,0x71,0x00,0x02,0x1d,0x00,0x28,0x03, 0x24,0x09,0x24,0x07,0x24,0x0c,0x02,0x35,0x07,0x03,0x04,0x02,0x46,0x00,0x05,0x02, 0xa8,0x1e,0x05,0x24,0xa7,0x2b,0x00,0x07,0x00,0x2b,0x01,0x07,0x03,0x2b,0x02,0x3d, 0x02,0x05,0x09,0x2b,0x03,0x07,0x01,0x2b,0x04,0x24,0xa8,0x20,0x02,0x2a,0x05,0x04, 0x05,0x02,0x00,0x01,0x02,0x00,0x00,0x07,0x00,0x22,0x00,0x07,0x01,0x16,0x01,0x03, 0x03,0x00,0x07,0x00,0x02,0x00,0x73,0x28,0x03,0x07,0x00,0x02,0x6f,0x00,0x28,0x04, 0x24,0xa8,0x07,0x03,0x02,0x73,0x02,0x11,0x00,0x2d,0x28,0x05,0x07,0x05,0x04,0x17, 0x1d,0x52,0x00,0x02,0xa8,0x24,0xa8,0x07,0x05,0x02,0x05,0x00,0x2a,0x05,0x07,0x04, 0x04,0x17,0x1d,0x45,0x00,0x02,0xa9,0x07,0x05,0x22,0x01,0x07,0x04,0x20,0x02,0x24, 0xa9,0x20,0x02,0x2a,0x1c,0x46,0x00,0x04,0x05,0x07,0x05,0x22,0x04,0x07,0x04,0x32, 0x01,0x1c,0x53,0x00,0x04,0x05,0x02,0x00,0x01,0x01,0x01,0x00,0x07,0x00,0x04,0x17, 0x1d,0x2c,0x00,0x07,0x00,0x2d,0x28,0x01,0x07,0x01,0x22,0x03,0x04,0x16,0x1d,0x1e, 0x00,0x07,0x00,0x2e,0x02,0x75,0x00,0x1c,0x29,0x00,0x07,0x00,0x2d,0x07,0x00,0x2e, 0x02,0x75,0x00,0x20,0x02,0x1c,0x2d,0x00,0x04,0x01,0x00,0x02,0x00,0x24,0xa8,0x28, 0x00,0x04,0x07,0x00,0x04,0x17,0x1d,0x3e,0x00,0x1c,0x17,0x00,0x07,0x00,0x2e,0x28, 0x00,0x1c,0x05,0x00,0x05,0x07,0x00,0x2d,0x28,0x01,0x3d,0x07,0x01,0x22,0x03,0x0a, 0x02,0x00,0x1b,0x1d,0x3a,0x00,0x07,0x01,0x02,0x03,0x04,0x30,0x05,0x07,0x01,0x22, 0x04,0x04,0x32,0x01,0x1c,0x3b,0x00,0x04,0x1c,0x0f,0x00,0x05,0x02,0xa8,0x24,0xa8, 0x02,0x75,0x00,0x2a,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x24,0x07,0x02,0x74,0x02, 0x48,0x00,0x05,0x02,0xa8,0x04,0x2a,0x05,0x02,0xa9,0x04,0x2a,0x05,0x02,0x00,0x01, 0x03,0x02,0x00,0x07,0x01,0x04,0x16,0x06,0x15,0x1d,0x10,0x00,0x05,0x02,0x00,0x07, 0x01,0x44,0x16,0x1d,0x43,0x00,0x07,0x00,0x02,0x5b,0x00,0x05,0x07,0x02,0x22,0x05, 0x24,0xaa,0x16,0x1d,0x37,0x00,0x07,0x02,0x22,0x04,0x07,0x02,0x07,0x02,0x22,0x01, 0x04,0x02,0x0d,0x00,0x49,0x32,0x02,0x1c,0x40,0x00,0x07,0x02,0x22,0x04,0x07,0x02, 0x04,0x32,0x02,0x1c,0xef,0x00,0x02,0xb0,0x3d,0x2a,0x05,0x07,0x02,0x02,0x07,0x35, 0x30,0x05,0x07,0x02,0x22,0x05,0x24,0xaa,0x16,0x1d,0x69,0x00,0x07,0x02,0x02,0x01, 0x07,0x01,0x07,0x02,0x22,0x01,0x20,0x02,0x30,0x1c,0xed,0x00,0x07,0x02,0x22,0x05, 0x24,0xac,0x16,0x1d,0x82,0x00,0x07,0x02,0x22,0x04,0x07,0x02,0x07,0x01,0x32,0x02, 0x05,0x04,0x1c,0xed,0x00,0x07,0x02,0x22,0x01,0x2d,0x07,0x01,0x47,0x28,0x03,0x07, 0x03,0x24,0xb1,0x02,0x00,0x02,0x02,0x00,0x28,0x04,0x07,0x04,0x04,0x16,0x1d,0xab, 0x00,0x07,0x02,0x02,0x01,0x07,0x03,0x04,0x20,0x02,0x30,0x1c,0xed,0x00,0x07,0x02, 0x02,0x01,0x04,0x30,0x05,0x07,0x02,0x02,0x05,0x24,0xac,0x30,0x05,0x07,0x02,0x22, 0x04,0x07,0x02,0x07,0x03,0x02,0x00,0x07,0x04,0x46,0x32,0x02,0x05,0x07,0x04,0x02, 0x04,0x09,0x07,0x03,0x44,0x18,0x1d,0xea,0x00,0x07,0x02,0x22,0x04,0x07,0x02,0x07, 0x03,0x07,0x04,0x02,0x04,0x09,0x04,0x46,0x32,0x02,0x1c,0xeb,0x00,0x04,0x05,0x04, 0x05,0x04,0x01,0x02,0x00,0x00,0x07,0x01,0x02,0x06,0x24,0xaf,0x30,0x05,0x07,0x01, 0x02,0x07,0x35,0x30,0x05,0x07,0x01,0x22,0x02,0x04,0x17,0x1d,0x69,0x00,0x07,0x01, 0x02,0x03,0x07,0x00,0x07,0x01,0x22,0x02,0x07,0x01,0x22,0x03,0x02,0x5a,0x00,0x30, 0x05,0x07,0x01,0x22,0x03,0x04,0x16,0x1d,0x46,0x00,0x07,0x00,0x02,0x5b,0x00,0x05, 0x07,0x01,0x22,0x04,0x07,0x01,0x04,0x32,0x02,0x1c,0x66,0x00,0x07,0x01,0x22,0x03, 0x07,0x01,0x22,0x02,0x44,0x1b,0x1d,0x65,0x00,0x07,0x01,0x02,0x03,0x04,0x30,0x05, 0x07,0x01,0x02,0x02,0x04,0x30,0x05,0x04,0x1c,0x66,0x00,0x04,0x1c,0x6a,0x00,0x04, 0x01,0x02,0x01,0x00,0x07,0x01,0x07,0x00,0x44,0x1b,0x1d,0x0e,0x00,0x02,0x01,0x1c, 0x41,0x00,0x07,0x00,0x07,0x01,0x45,0x28,0x02,0x07,0x02,0x02,0x30,0x18,0x06,0x15, 0x1d,0x25,0x00,0x05,0x07,0x02,0x02,0x39,0x19,0x06,0x1d,0x2f,0x00,0x05,0x07,0x02, 0x02,0x2e,0x17,0x1d,0x37,0x00,0x02,0x00,0x1c,0x41,0x00,0x07,0x00,0x07,0x01,0x02, 0x01,0x09,0x02,0x7a,0x00,0x01,0x01,0x06,0x00,0x07,0x00,0x02,0x00,0x24,0xb2,0x44, 0x46,0x24,0xb2,0x89,0x15,0x1d,0x1e,0x00,0x07,0x00,0x24,0xb2,0x44,0x07,0x00,0x44, 0x46,0x02,0x7b,0x00,0x1c,0x97,0x00,0x07,0x00,0x24,0xb3,0x02,0x00,0x02,0x02,0x00, 0x28,0x01,0x07,0x01,0x04,0x16,0x1d,0x35,0x00,0x07,0x00,0x1c,0x3c,0x00,0x07,0x00, 0x02,0x00,0x07,0x01,0x46,0x28,0x02,0x07,0x02,0x24,0xb4,0x02,0x00,0x02,0x02,0x00, 0x28,0x03,0x07,0x03,0x04,0x16,0x1d,0x59,0x00,0x07,0x02,0x02,0x50,0x20,0x02,0x1c, 0x6e,0x00,0x07,0x02,0x02,0x00,0x07,0x03,0x46,0x07,0x02,0x07,0x03,0x02,0x01,0x09, 0x07,0x02,0x44,0x46,0x75,0x20,0x02,0x06,0x22,0x00,0x28,0x04,0x06,0x22,0x01,0x28, 0x05,0x05,0x07,0x01,0x04,0x16,0x1d,0x85,0x00,0x24,0xb5,0x1c,0x8d,0x00,0x07,0x00, 0x07,0x01,0x07,0x00,0x44,0x46,0x28,0x06,0x07,0x04,0x07,0x05,0x07,0x06,0x20,0x03, 0x01,0x04,0x00,0x00,0x07,0x01,0x24,0x6a,0x16,0x1d,0x12,0x00,0x07,0x00,0x07,0x03, 0x02,0x79,0x00,0x1c,0x2e,0x00,0x07,0x01,0x24,0x6c,0x16,0x1d,0x25,0x00,0x07,0x00, 0x04,0x07,0x03,0x02,0x78,0x00,0x1c,0x2e,0x00,0x07,0x00,0x07,0x02,0x07,0x03,0x02, 0x78,0x00,0x05,0x02,0x00,0x01,0x02,0x02,0x00,0x24,0xb6,0x26,0x05,0x07,0x00,0x60, 0x05,0x07,0x01,0x06,0x22,0x00,0x28,0x02,0x06,0x22,0x01,0x28,0x03,0x05,0x07,0x00, 0x04,0x16,0x1d,0x2a,0x00,0x07,0x03,0x22,0x04,0x07,0x03,0x04,0x32,0x02,0x05,0x04, 0x1c,0x4b,0x00,0x07,0x03,0x02,0x00,0x24,0x09,0x04,0x07,0x00,0x02,0x14,0x00,0x07, 0x02,0x02,0x7c,0x07,0x03,0x37,0x02,0x55,0x00,0x30,0x05,0x07,0x03,0x02,0x06,0x24, 0xae,0x30,0x05,0x04,0x05,0x02,0x00,0x01,0x05,0x08,0x00,0x07,0x01,0x02,0x7b,0x00, 0x06,0x22,0x00,0x28,0x05,0x06,0x22,0x01,0x28,0x06,0x06,0x22,0x02,0x28,0x07,0x05, 0x02,0x35,0x00,0x1d,0x35,0x00,0x24,0xb7,0x07,0x05,0x24,0xb8,0x07,0x06,0x77,0x07, 0x07,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x1c,0x37,0x00, 0x07,0x07,0x28,0x08,0x07,0x00,0x24,0xb9,0x07,0x08,0x24,0xba,0x07,0x05,0x24,0xbb, 0x07,0x02,0x04,0x16,0x1d,0x54,0x00,0x24,0xbc,0x04,0x20,0x02,0x1c,0x67,0x00,0x24, 0xbd,0x07,0x02,0x44,0x77,0x24,0xbe,0x07,0x02,0x04,0x20,0x02,0x20,0x02,0x20,0x02, 0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x28, 0x09,0x02,0x35,0x00,0x1d,0x85,0x00,0x02,0x36,0x00,0x02,0x15,0x00,0x1c,0x87,0x00, 0x07,0x05,0x28,0x0a,0x02,0x35,0x00,0x1d,0x95,0x00,0x02,0x37,0x00,0x1c,0x97,0x00, 0x07,0x06,0x28,0x0b,0x1e,0x08,0x07,0x09,0x2b,0x02,0x02,0x00,0x2b,0x03,0x07,0x03, 0x2b,0x04,0x07,0x04,0x2b,0x05,0x24,0xad,0x2b,0x06,0x35,0x2b,0x07,0x28,0x0c,0x07, 0x0a,0x02,0x00,0x02,0x7a,0x00,0x1d,0xcc,0x00,0x07,0x0a,0x07,0x0b,0x07,0x0c,0x20, 0x02,0x02,0x7d,0x00,0x1c,0xdc,0x00,0x07,0x0a,0x02,0x7d,0x07,0x0b,0x07,0x0c,0x20, 0x02,0x37,0x02,0x72,0x00,0x05,0x04,0x05,0x07,0x0c,0x01,0x01,0x00,0x00,0x07,0x00, 0x22,0x00,0x02,0x5b,0x00,0x01,0x02,0x00,0x00,0x07,0x00,0x22,0x00,0x07,0x01,0x02, 0x5d,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x22,0x06,0x01,0x01,0x00,0x00,0x35,0x07, 0x00,0x22,0x07,0x0a,0x01,0x01,0x01,0x00,0x07,0x00,0x24,0xbf,0x02,0x00,0x02,0x02, 0x00,0x28,0x01,0x07,0x01,0x04,0x16,0x1d,0x17,0x00,0x07,0x00,0x1c,0x22,0x00,0x07, 0x00,0x02,0x00,0x07,0x01,0x24,0xbf,0x44,0x09,0x46,0x01,0x01,0x01,0x00,0x07,0x00, 0x24,0xbf,0x02,0x00,0x02,0x02,0x00,0x28,0x01,0x07,0x01,0x04,0x16,0x1d,0x16,0x00, 0x04,0x1c,0x22,0x00,0x07,0x00,0x07,0x01,0x24,0xbf,0x44,0x09,0x07,0x00,0x44,0x46, 0x01,0x03,0x01,0x00,0x07,0x01,0x07,0x02,0x09,0x02,0x01,0x12,0x28,0x03,0x07,0x03, 0x07,0x01,0x16,0x1d,0x17,0x00,0x07,0x01,0x1c,0x37,0x00,0x07,0x03,0x07,0x03,0x0b, 0x07,0x00,0x19,0x1d,0x2e,0x00,0x07,0x00,0x07,0x01,0x07,0x03,0x02,0x85,0x00,0x1c, 0x37,0x00,0x07,0x00,0x07,0x03,0x07,0x02,0x02,0x85,0x00,0x01,0x01,0x00,0x00,0x07, 0x00,0x02,0x00,0x03,0x00,0x01,0x00,0x00,0x02,0x85,0x00,0x01,0x01,0x03,0x00,0x07, 0x00,0x44,0x27,0x05,0x24,0xc5,0x26,0x05,0x02,0xff,0x07,0x00,0x02,0x00,0x71,0x02, 0x86,0x00,0x5f,0x0a,0x28,0x01,0x02,0xff,0x07,0x01,0x07,0x01,0x0b,0x02,0x08,0x12, 0x0a,0x28,0x02,0x07,0x02,0x02,0x10,0x11,0x28,0x03,0x02,0x01,0x07,0x03,0x4a,0x05, 0x02,0x02,0x07,0x03,0x4a,0x05,0x02,0x03,0x07,0x03,0x4a,0x05,0x02,0xc0,0x07,0x00, 0x24,0xc0,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x01,0x01,0x00,0x02,0x04,0x3e,0x28, 0x01,0x07,0x01,0x02,0x00,0x07,0x00,0x3f,0x05,0x07,0x01,0x02,0x01,0x07,0x00,0x02, 0x08,0x12,0x3f,0x05,0x07,0x01,0x02,0x02,0x07,0x00,0x02,0x10,0x12,0x3f,0x05,0x07, 0x01,0x02,0x03,0x07,0x00,0x02,0x18,0x12,0x3f,0x05,0x07,0x01,0x01,0x02,0x00,0x00, 0x07,0x00,0x04,0x16,0x1d,0x0c,0x00,0x07,0x01,0x1c,0x19,0x00,0x07,0x00,0x2e,0x07, 0x01,0x07,0x00,0x2d,0x44,0x09,0x02,0x89,0x00,0x01,0x01,0x01,0x00,0x24,0xc6,0x26, 0x05,0x07,0x00,0x02,0x00,0x02,0x89,0x00,0x5f,0x28,0x01,0x24,0xc7,0x07,0x01,0x02, 0x34,0x09,0x02,0x88,0x00,0x24,0xc8,0x24,0xc9,0x07,0x01,0x02,0x08,0x12,0x03,0xf9, 0x01,0x00,0x00,0x0b,0x02,0x88,0x00,0x24,0xca,0x07,0x01,0x02,0x88,0x00,0x04,0x20, 0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x07,0x00, 0x20,0x02,0x01,0x00,0x00,0x00,0x70,0x05,0x24,0xcb,0x60,0x05,0x02,0xc1,0x02,0x01, 0x2a,0x05,0x02,0xc0,0x04,0x2a,0x05,0x03,0x40,0x1f,0x00,0x00,0x02,0x00,0x02,0x87, 0x6f,0x01,0x00,0x00,0x00,0x02,0xc1,0x02,0x00,0x2a,0x05,0x70,0x01,0x00,0x01,0x00, 0x24,0xc0,0x04,0x02,0x0d,0x00,0x02,0x8a,0x00,0x28,0x00,0x02,0xc0,0x04,0x2a,0x05, 0x07,0x00,0x01,0x01,0x01,0x00,0x02,0xff,0x07,0x00,0x0a,0x28,0x01,0x02,0xff,0x07, 0x01,0x07,0x01,0x0b,0x02,0x08,0x12,0x0a,0x01,0x00,0x01,0x00,0x4e,0x28,0x00,0x24, 0xdd,0x15,0x06,0x1d,0x10,0x00,0x05,0x07,0x00,0x24,0xdc,0x17,0x06,0x1d,0x18,0x00, 0x05,0x24,0xc1,0x15,0x06,0x1d,0x2d,0x00,0x05,0x24,0xdc,0x02,0xff,0x17,0x06,0x15, 0x1d,0x2d,0x00,0x05,0x07,0x00,0x02,0xfa,0x18,0x1d,0x3f,0x00,0x02,0xdc,0x07,0x00, 0x2a,0x05,0x07,0x00,0x02,0x8e,0x00,0x64,0x1c,0x40,0x00,0x04,0x01,0x01,0x00,0x00, 0x4e,0x07,0x00,0x0b,0x02,0x08,0x12,0x02,0x8e,0x00,0x64,0x05,0x02,0xdd,0x02,0x01, 0x2a,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0xdd,0x02,0x00,0x2a,0x05,0x02,0xdc, 0x04,0x2a,0x05,0x02,0x00,0x01,0x00,0x01,0x00,0x24,0xdb,0x04,0x16,0x1d,0x36,0x00, 0x02,0xdb,0x03,0x00,0x08,0x00,0x00,0x3e,0x2a,0x05,0x02,0x00,0x28,0x00,0x04,0x07, 0x00,0x03,0x00,0x08,0x00,0x00,0x18,0x1d,0x33,0x00,0x05,0x24,0xdb,0x07,0x00,0x02, 0x00,0x3f,0x07,0x00,0x02,0x01,0x09,0x28,0x00,0x1c,0x16,0x00,0x1c,0x37,0x00,0x04, 0x05,0x24,0xdb,0x01,0x00,0x00,0x00,0x24,0xde,0x60,0x05,0x24,0xd4,0x24,0xcc,0x17, 0x1d,0x2c,0x00,0x51,0x05,0x24,0xd5,0x04,0x17,0x1d,0x1d,0x00,0x24,0xd5,0x02,0x7f, 0x00,0x1c,0x1e,0x00,0x04,0x05,0x02,0xd5,0x04,0x2a,0x05,0x02,0xd4,0x24,0xcc,0x2a, 0x1c,0x2d,0x00,0x04,0x01,0x00,0x00,0x00,0x24,0xd4,0x24,0xcc,0x16,0x1d,0x0d,0x00, 0x02,0x00,0x1c,0x48,0x00,0x24,0xd6,0x04,0x16,0x06,0x1d,0x1b,0x00,0x05,0x24,0xd4, 0x24,0xce,0x16,0x06,0x1d,0x27,0x00,0x05,0x35,0x24,0xd9,0x0a,0x24,0xd3,0x19,0x1d, 0x37,0x00,0x24,0xdf,0x60,0x05,0x02,0x93,0x00,0x05,0x02,0x00,0x1c,0x48,0x00,0x24, 0xd9,0x04,0x16,0x1d,0x46,0x00,0x03,0xff,0xff,0xff,0xff,0x1c,0x48,0x00,0x02,0x01, 0x01,0x01,0x02,0x00,0x02,0xd9,0x35,0x2a,0x05,0x24,0xd6,0x04,0x16,0x1d,0x31,0x00, 0x24,0xd4,0x24,0xce,0x16,0x1d,0x1b,0x00,0x04,0x04,0x04,0x50,0x1c,0x2e,0x00,0x24, 0xd7,0x15,0x1d,0x27,0x00,0x24,0xe0,0x60,0x1c,0x28,0x00,0x04,0x05,0x02,0xd7,0x02, 0x01,0x2a,0x1c,0xbf,0x00,0x24,0xd7,0x06,0x1d,0x4b,0x00,0x05,0x24,0xd4,0x24,0xce, 0x16,0x06,0x15,0x1d,0x4b,0x00,0x05,0x24,0xd6,0x02,0x06,0x00,0x24,0xcf,0x1b,0x1d, 0x56,0x00,0x02,0xd7,0x02,0x00,0x2a,0x1c,0x57,0x00,0x04,0x05,0x24,0xd7,0x15,0x1d, 0xbe,0x00,0x24,0xd6,0x2d,0x28,0x01,0x07,0x01,0x44,0x28,0x02,0x24,0xd8,0x07,0x02, 0x18,0x1d,0x7f,0x00,0x02,0xd8,0x24,0xd8,0x07,0x01,0x24,0xd8,0x04,0x50,0x09,0x2a, 0x1c,0x80,0x00,0x04,0x05,0x24,0xd8,0x07,0x02,0x1b,0x1d,0xba,0x00,0x02,0xd8,0x02, 0x00,0x2a,0x05,0x02,0xd6,0x24,0xd6,0x2e,0x2a,0x05,0x24,0xd5,0x04,0x17,0x1d,0xb6, 0x00,0x24,0xd6,0x02,0x06,0x00,0x24,0xd0,0x18,0x1d,0xb2,0x00,0x24,0xd5,0x02,0x01, 0x02,0x80,0x00,0x1c,0xb3,0x00,0x04,0x1c,0xb7,0x00,0x04,0x1c,0xbb,0x00,0x04,0x1c, 0xbf,0x00,0x04,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0xd8,0x02,0x00,0x2a,0x05, 0x02,0xd7,0x02,0x01,0x2a,0x05,0x03,0x00,0x04,0x00,0x00,0x02,0x95,0x4f,0x01,0x02, 0x00,0x00,0x02,0x93,0x00,0x05,0x02,0xd3,0x07,0x01,0x2a,0x05,0x02,0xd6,0x07,0x00, 0x02,0x92,0x00,0x04,0x20,0x02,0x02,0x12,0x00,0x2a,0x05,0x02,0xd4,0x24,0xce,0x2a, 0x05,0x02,0xd9,0x35,0x2a,0x05,0x02,0xd5,0x04,0x2a,0x05,0x02,0x96,0x00,0x01,0x01, 0x00,0x00,0x07,0x00,0x24,0xd1,0x02,0x97,0x00,0x01,0x02,0x01,0x00,0x02,0xda,0x35, 0x2a,0x05,0x07,0x01,0x04,0x16,0x1d,0x58,0x00,0x24,0xe1,0x60,0x05,0x02,0xd4,0x24, 0xce,0x2a,0x05,0x24,0xd6,0x04,0x17,0x1d,0x2e,0x00,0x02,0xd6,0x24,0xd6,0x02,0x92, 0x00,0x04,0x20,0x02,0x02,0x12,0x00,0x2a,0x1c,0x2f,0x00,0x04,0x05,0x24,0xd8,0x04, 0x16,0x1d,0x51,0x00,0x02,0xd6,0x24,0xd6,0x2e,0x2a,0x05,0x24,0xd6,0x04,0x16,0x1d, 0x4b,0x00,0x02,0x93,0x00,0x1c,0x4e,0x00,0x02,0x96,0x00,0x1c,0x52,0x00,0x04,0x05, 0x02,0x00,0x1c,0xa4,0x00,0x02,0xd6,0x24,0xd6,0x07,0x01,0x04,0x20,0x02,0x02,0x12, 0x00,0x2a,0x05,0x24,0xd6,0x02,0x06,0x00,0x28,0x02,0x24,0xd8,0x04,0x16,0x06,0x1d, 0x7b,0x00,0x05,0x07,0x02,0x24,0xcf,0x19,0x1d,0x8b,0x00,0x02,0xd6,0x24,0xd6,0x2e, 0x2a,0x05,0x02,0x96,0x00,0x1c,0xa2,0x00,0x07,0x02,0x24,0xd0,0x19,0x1d,0xa1,0x00, 0x24,0xe2,0x60,0x05,0x07,0x00,0x02,0x00,0x02,0x80,0x00,0x1c,0xa2,0x00,0x04,0x05, 0x04,0x05,0x02,0x8f,0x00,0x05,0x02,0x00,0x01,0x01,0x00,0x00,0x02,0x93,0x00,0x05, 0x02,0xd3,0x24,0xd1,0x2a,0x05,0x02,0xd6,0x04,0x2a,0x05,0x02,0xd4,0x24,0xcd,0x2a, 0x05,0x02,0xd8,0x04,0x2a,0x05,0x02,0xd7,0x02,0x01,0x2a,0x05,0x02,0xd9,0x04,0x2a, 0x05,0x02,0xda,0x35,0x2a,0x05,0x02,0xd5,0x24,0xe3,0x07,0x00,0x04,0x02,0x99,0x24, 0xab,0x02,0x7e,0x00,0x2a,0x01,0x00,0x00,0x00,0x24,0xd5,0x04,0x17,0x06,0x1d,0x0e, 0x00,0x05,0x24,0xd4,0x24,0xcd,0x16,0x06,0x1d,0x1a,0x00,0x05,0x35,0x24,0xda,0x0a, 0x24,0xd2,0x19,0x1d,0x43,0x00,0x24,0xd5,0x04,0x17,0x1d,0x3f,0x00,0x24,0xe4,0x60, 0x05,0x24,0xd5,0x02,0x7f,0x00,0x05,0x02,0xd5,0x04,0x2a,0x05,0x24,0xd5,0x04,0x02, 0x99,0x00,0x05,0x02,0x00,0x1c,0x40,0x00,0x04,0x1c,0x44,0x00,0x04,0x05,0x02,0x00, 0x01,0x00,0x01,0x00,0x24,0xf0,0x28,0x00,0x02,0xf0,0x04,0x2a,0x05,0x07,0x00,0x01, 0x01,0x00,0x00,0x07,0x00,0x02,0x00,0x18,0x1d,0x13,0x00,0x07,0x00,0x24,0xe9,0x09, 0x02,0x9d,0x00,0x1c,0x28,0x00,0x07,0x00,0x24,0xe9,0x1b,0x1d,0x26,0x00,0x07,0x00, 0x24,0xe9,0x0a,0x02,0x9d,0x00,0x1c,0x28,0x00,0x07,0x00,0x01,0x02,0x00,0x00,0x07, 0x00,0x02,0x01,0x07,0x01,0x30,0x05,0x07,0x00,0x22,0x00,0x07,0x01,0x4b,0x01,0x00, 0x02,0x00,0x24,0xf1,0x60,0x05,0x02,0xed,0x24,0xe5,0x2a,0x05,0x02,0x00,0x28,0x00, 0x04,0x07,0x00,0x02,0x02,0x18,0x1d,0x56,0x00,0x05,0x24,0xec,0x07,0x00,0x23,0x28, 0x01,0x07,0x01,0x02,0x01,0x02,0x9e,0x00,0x05,0x07,0x01,0x02,0x08,0x02,0x00,0x30, 0x05,0x07,0x01,0x02,0x02,0x04,0x30,0x05,0x07,0x01,0x02,0x04,0x07,0x00,0x4c,0x30, 0x05,0x07,0x01,0x02,0x05,0x04,0x30,0x05,0x07,0x01,0x02,0x06,0x35,0x30,0x07,0x00, 0x02,0x01,0x09,0x28,0x00,0x1c,0x0f,0x00,0x01,0x00,0x01,0x00,0x02,0xec,0x04,0x02, 0x02,0x36,0x2a,0x05,0x02,0x00,0x28,0x00,0x04,0x07,0x00,0x02,0x02,0x18,0x1d,0x2b, 0x00,0x05,0x24,0xec,0x07,0x00,0x1e,0x09,0x07,0x00,0x2b,0x00,0x30,0x07,0x00,0x02, 0x01,0x09,0x28,0x00,0x1c,0x0d,0x00,0x05,0x02,0x9f,0x00,0x01,0x00,0x00,0x00,0x03, 0x00,0x80,0xff,0x00,0x02,0x18,0x00,0x05,0x02,0xed,0x24,0xe8,0x2a,0x05,0x02,0xef, 0x35,0x2a,0x05,0x02,0xee,0x02,0x00,0x4c,0x02,0x01,0x4c,0x09,0x2a,0x01,0x00,0x05, 0x00,0x24,0xef,0x04,0x17,0x1d,0x9c,0x00,0x02,0x00,0x4c,0x02,0x01,0x4c,0x09,0x28, 0x00,0x07,0x00,0x24,0xee,0x17,0x1d,0x2d,0x00,0x24,0xf2,0x26,0x05,0x07,0x00,0x5f, 0x05,0x02,0xee,0x07,0x00,0x2a,0x05,0x02,0xef,0x35,0x2a,0x1c,0x99,0x00,0x35,0x24, 0xef,0x0a,0x24,0xea,0x19,0x1d,0x98,0x00,0x02,0xef,0x04,0x2a,0x05,0x02,0x00,0x28, 0x01,0x04,0x07,0x01,0x02,0x02,0x18,0x1d,0x95,0x00,0x05,0x24,0xec,0x07,0x01,0x23, 0x28,0x02,0x07,0x02,0x22,0x08,0x02,0x01,0x17,0x1d,0x8a,0x00,0x07,0x02,0x02,0x04, 0x07,0x01,0x4c,0x30,0x05,0x07,0x02,0x02,0x05,0x02,0x00,0x30,0x05,0x07,0x02,0x02, 0x06,0x35,0x30,0x05,0x07,0x02,0x02,0x01,0x02,0x9e,0x00,0x05,0x07,0x02,0x02,0x07, 0x07,0x02,0x22,0x04,0x24,0xe9,0x09,0x30,0x1c,0x8b,0x00,0x04,0x07,0x01,0x02,0x01, 0x09,0x28,0x01,0x1c,0x41,0x00,0x1c,0x99,0x00,0x04,0x1c,0xa5,0x01,0x02,0x00,0x28, 0x00,0x04,0x07,0x00,0x02,0x02,0x18,0x1d,0x49,0x01,0x05,0x24,0xec,0x07,0x00,0x23, 0x28,0x01,0x07,0x01,0x22,0x08,0x02,0x01,0x17,0x1d,0x3e,0x01,0x07,0x01,0x22,0x01, 0x1d,0x3a,0x01,0x07,0x00,0x4c,0x28,0x02,0x07,0x02,0x07,0x01,0x22,0x04,0x17,0x1d, 0x36,0x01,0x35,0x28,0x03,0x07,0x03,0x07,0x01,0x22,0x06,0x0a,0x28,0x04,0x07,0x04, 0x07,0x01,0x22,0x05,0x19,0x1d,0x09,0x01,0x07,0x01,0x02,0x03,0x07,0x01,0x22,0x07, 0x07,0x01,0x22,0x04,0x0a,0x24,0xeb,0x0a,0x02,0x01,0x0a,0x02,0x9d,0x00,0x30,0x05, 0x07,0x01,0x02,0x05,0x07,0x04,0x30,0x1c,0x0a,0x01,0x04,0x05,0x07,0x01,0x02,0x06, 0x07,0x03,0x30,0x05,0x07,0x01,0x02,0x04,0x07,0x02,0x30,0x05,0x07,0x02,0x07,0x01, 0x22,0x07,0x0a,0x02,0x00,0x1b,0x1d,0x32,0x01,0x07,0x01,0x02,0x00,0x02,0x9e,0x00, 0x1c,0x33,0x01,0x04,0x1c,0x37,0x01,0x04,0x1c,0x3b,0x01,0x04,0x1c,0x3f,0x01,0x04, 0x07,0x00,0x02,0x01,0x09,0x28,0x00,0x1c,0xa1,0x00,0x05,0x24,0xec,0x02,0x00,0x23, 0x22,0x01,0x02,0x00,0x16,0x06,0x1d,0x63,0x01,0x05,0x24,0xec,0x02,0x01,0x23,0x22, 0x01,0x02,0x00,0x16,0x1d,0xa4,0x01,0x02,0xf0,0x03,0x00,0x80,0x00,0x00,0x24,0xec, 0x02,0x00,0x23,0x22,0x03,0x02,0x08,0x11,0x09,0x24,0xec,0x02,0x01,0x23,0x22,0x03, 0x09,0x2a,0x05,0x24,0xf3,0x26,0x05,0x24,0xec,0x02,0x00,0x23,0x22,0x03,0x27,0x05, 0x24,0xf4,0x26,0x05,0x24,0xec,0x02,0x01,0x23,0x22,0x03,0x5f,0x05,0x02,0xed,0x24, 0xe7,0x2a,0x1c,0xa5,0x01,0x04,0x01,0x00,0x05,0x00,0x02,0x00,0x28,0x00,0x04,0x07, 0x00,0x02,0x02,0x18,0x1d,0x2a,0x01,0x05,0x24,0xec,0x07,0x00,0x23,0x28,0x01,0x07, 0x01,0x22,0x01,0x1d,0x1f,0x01,0x07,0x00,0x4c,0x28,0x02,0x07,0x02,0x07,0x01,0x22, 0x04,0x16,0x1d,0x80,0x00,0x35,0x28,0x03,0x07,0x03,0x07,0x01,0x22,0x06,0x0a,0x28, 0x04,0x07,0x04,0x03,0x88,0x13,0x00,0x00,0x19,0x1d,0x7c,0x00,0x24,0xf5,0x60,0x05, 0x07,0x00,0x5f,0x05,0x07,0x01,0x02,0x08,0x02,0x01,0x30,0x05,0x07,0x01,0x02,0x03, 0x02,0x00,0x30,0x05,0x07,0x01,0x02,0x04,0x07,0x02,0x30,0x05,0x07,0x01,0x02,0x02, 0x02,0x00,0x30,0x05,0x07,0x01,0x02,0x05,0x02,0x00,0x30,0x05,0x07,0x01,0x02,0x00, 0x02,0x9e,0x00,0x1c,0x7d,0x00,0x04,0x1c,0x1c,0x01,0x07,0x01,0x22,0x02,0x04,0x17, 0x1d,0xc0,0x00,0x07,0x01,0x02,0x03,0x07,0x01,0x22,0x03,0x07,0x02,0x09,0x07,0x01, 0x22,0x04,0x0a,0x02,0x9d,0x00,0x30,0x05,0x07,0x01,0x02,0x04,0x07,0x02,0x30,0x05, 0x07,0x01,0x22,0x03,0x07,0x01,0x22,0x02,0x16,0x1d,0xbc,0x00,0x07,0x01,0x02,0x00, 0x02,0x9e,0x00,0x1c,0xbd,0x00,0x04,0x1c,0x1c,0x01,0x35,0x28,0x03,0x07,0x03,0x07, 0x01,0x22,0x06,0x0a,0x28,0x04,0x07,0x04,0x03,0x10,0x27,0x00,0x00,0x18,0x06,0x1d, 0xe1,0x00,0x05,0x07,0x04,0x03,0x58,0x02,0x00,0x00,0x19,0x06,0x1d,0xec,0x00,0x05, 0x04,0x07,0x01,0x22,0x05,0x17,0x1d,0x05,0x01,0x07,0x01,0x02,0x03,0x24,0xeb,0x13, 0x02,0x9d,0x00,0x30,0x05,0x07,0x01,0x02,0x02,0x02,0x00,0x30,0x1c,0x0c,0x01,0x07, 0x01,0x02,0x06,0x07,0x03,0x30,0x05,0x07,0x01,0x02,0x04,0x07,0x02,0x30,0x05,0x07, 0x01,0x02,0x05,0x07,0x04,0x30,0x1c,0x20,0x01,0x04,0x07,0x00,0x02,0x01,0x09,0x28, 0x00,0x1c,0x05,0x00,0x05,0x24,0xec,0x02,0x00,0x23,0x22,0x01,0x02,0x00,0x16,0x06, 0x1d,0x44,0x01,0x05,0x24,0xec,0x02,0x01,0x23,0x22,0x01,0x02,0x00,0x16,0x1d,0x4f, 0x01,0x02,0xed,0x24,0xe6,0x2a,0x1c,0x50,0x01,0x04,0x01,0x00,0x04,0x00,0x02,0x00, 0x28,0x00,0x04,0x07,0x00,0x02,0x02,0x18,0x1d,0xb5,0x00,0x05,0x24,0xec,0x07,0x00, 0x23,0x28,0x01,0x07,0x01,0x22,0x08,0x02,0x01,0x17,0x1d,0xaa,0x00,0x07,0x00,0x4c, 0x28,0x02,0x07,0x02,0x07,0x01,0x22,0x04,0x17,0x1d,0xa6,0x00,0x07,0x02,0x07,0x01, 0x22,0x04,0x0a,0x28,0x03,0x07,0x01,0x22,0x01,0x1d,0x80,0x00,0x07,0x01,0x02,0x04, 0x07,0x02,0x30,0x05,0x07,0x01,0x02,0x03,0x07,0x01,0x22,0x03,0x07,0x01,0x22,0x01, 0x02,0x00,0x19,0x1d,0x5d,0x00,0x07,0x03,0x1c,0x60,0x00,0x07,0x03,0x13,0x09,0x02, 0x9d,0x00,0x30,0x05,0x07,0x01,0x22,0x03,0x07,0x01,0x22,0x02,0x16,0x1d,0x7c,0x00, 0x07,0x01,0x02,0x00,0x02,0x9e,0x00,0x1c,0x7d,0x00,0x04,0x1c,0xa3,0x00,0x07,0x03, 0x02,0x02,0x19,0x1d,0xa2,0x00,0x07,0x01,0x02,0x04,0x07,0x02,0x30,0x05,0x24,0xed, 0x24,0xe7,0x16,0x1d,0x9e,0x00,0x02,0xa1,0x00,0x1c,0x9f,0x00,0x04,0x1c,0xa3,0x00, 0x04,0x1c,0xa7,0x00,0x04,0x1c,0xab,0x00,0x04,0x07,0x00,0x02,0x01,0x09,0x28,0x00, 0x1c,0x05,0x00,0x01,0x00,0x00,0x00,0x24,0xed,0x24,0xe5,0x16,0x1d,0x0e,0x00,0x02, 0xa3,0x00,0x1c,0x1f,0x00,0x24,0xed,0x24,0xe8,0x16,0x1d,0x1c,0x00,0x02,0xa2,0x00, 0x1c,0x1f,0x00,0x02,0xa4,0x00,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x24,0xed,0x24, 0xe5,0x17,0x01,0x00,0x00,0x00,0x24,0xed,0x24,0xe8,0x16,0x01,0x00,0x00,0x00,0x02, 0xa6,0x00,0x06,0x1d,0x10,0x00,0x05,0x24,0xec,0x02,0x00,0x23,0x22,0x01,0x15,0x06, 0x1d,0x1d,0x00,0x05,0x24,0xec,0x02,0x01,0x23,0x22,0x01,0x15,0x01,0x00,0x00,0x00, 0x24,0xed,0x24,0xe6,0x16,0x1d,0x10,0x00,0x02,0xed,0x24,0xe7,0x2a,0x1c,0x11,0x00, 0x04,0x01,0x00,0x00,0x00,0x24,0xed,0x24,0xe7,0x16,0x1d,0x10,0x00,0x02,0xed,0x24, 0xe6,0x2a,0x1c,0x11,0x00,0x04,0x01,0x00,0x01,0x00,0x24,0xf6,0x60,0x05,0x24,0xed, 0x24,0xe5,0x17,0x1d,0x31,0x00,0x02,0x00,0x28,0x00,0x04,0x07,0x00,0x02,0x02,0x18, 0x1d,0x2e,0x00,0x05,0x24,0xec,0x07,0x00,0x23,0x02,0x00,0x02,0x9e,0x00,0x07,0x00, 0x02,0x01,0x09,0x28,0x00,0x1c,0x11,0x00,0x1c,0x32,0x00,0x04,0x05,0x02,0x00,0x01, 0x01,0x00,0x00,0x24,0xec,0x07,0x00,0x23,0x22,0x02,0x01,0x03,0x02,0x00,0x24,0xed, 0x24,0xe6,0x16,0x06,0x15,0x1d,0x10,0x00,0x05,0x24,0xed,0x24,0xe7,0x16,0x1d,0x8f, 0x00,0x24,0xec,0x07,0x00,0x23,0x28,0x03,0x07,0x01,0x02,0x9d,0x00,0x28,0x04,0x07, 0x03,0x22,0x08,0x02,0x01,0x16,0x1d,0x3b,0x00,0x24,0xf7,0x26,0x05,0x07,0x00,0x27, 0x05,0x24,0xf8,0x60,0x05,0x04,0x1c,0x8c,0x00,0x07,0x04,0x07,0x03,0x22,0x02,0x17, 0x1d,0x8b,0x00,0x24,0xf9,0x26,0x05,0x07,0x00,0x27,0x05,0x24,0xfa,0x26,0x05,0x07, 0x04,0x27,0x05,0x24,0xfb,0x26,0x05,0x07,0x02,0x5f,0x05,0x07,0x03,0x02,0x02,0x07, 0x04,0x30,0x05,0x07,0x03,0x07,0x04,0x07,0x03,0x22,0x03,0x16,0x1d,0x76,0x00,0x02, 0x00,0x1c,0x85,0x00,0x07,0x02,0x1d,0x83,0x00,0x03,0xff,0xff,0xff,0xff,0x1c,0x85, 0x00,0x02,0x01,0x02,0x9e,0x00,0x1c,0x8c,0x00,0x04,0x1c,0x90,0x00,0x04,0x05,0x02, 0x00,0x01,0x00,0x00,0x00,0x02,0xfd,0x02,0x00,0x02,0x20,0x36,0x2a,0x05,0x02,0xfc, 0x02,0x00,0x02,0x04,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x00,0x02,0x00,0x02,0x00, 0x20,0x06,0x20,0x02,0x02,0x04,0x02,0x00,0x02,0x03,0x02,0x00,0x02,0x04,0x02,0x00, 0x02,0x04,0x20,0x06,0x20,0x02,0x02,0x03,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04, 0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x00,0x02,0x00,0x02,0x00, 0x20,0x0c,0x20,0x02,0x02,0x03,0x02,0x04,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x04,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x00,0x02,0x04, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x00,0x02,0x04, 0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x18,0x20,0x02,0x02,0x04,0x02,0x04,0x02,0x00, 0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x00,0x02,0x04,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x04,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x00,0x02,0x04,0x02,0x00, 0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x00,0x02,0x04,0x02,0x00,0x20,0x18,0x20,0x02, 0x02,0x03,0x02,0x00,0x02,0x03,0x02,0x04,0x02,0x03,0x02,0x04,0x02,0xd5,0x02,0x47, 0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x03,0x02,0x00,0x02,0x00,0x02,0x04,0x02,0x03, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x03,0x02,0x04,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x00,0x20,0x18,0x20,0x02,0x20,0x06,0x20,0x02,0x02,0x01,0x02,0x01,0x02,0x00, 0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00, 0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x02,0x02,0x00,0x02,0x00, 0x02,0x0b,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x03,0x02,0x00,0x02,0x00,0x02,0x0b, 0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x04,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00, 0x02,0x00,0x02,0x00,0x20,0x06,0x20,0x02,0x02,0x03,0x02,0x0b,0x02,0x00,0x02,0x00, 0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00, 0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x02,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00, 0x20,0x0c,0x20,0x02,0x02,0x01,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x0b, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x0b,0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c, 0x20,0x02,0x20,0x07,0x20,0x02,0x02,0x02,0x02,0x06,0x02,0x09,0x02,0x00,0x02,0x09, 0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x06,0x20,0x02,0x02,0x05,0x02,0x00,0x02,0x09, 0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x04,0x02,0x00,0x02,0x09,0x02,0x00, 0x02,0x09,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x03,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09, 0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00, 0x20,0x0c,0x20,0x02,0x02,0x02,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09,0x02,0x00, 0x02,0x09,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c, 0x20,0x02,0x02,0x01,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02, 0x02,0x00,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09,0x02,0x00,0x02,0x09,0x02,0x00, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x20,0x07, 0x20,0x02,0x02,0x05,0x02,0x03,0x02,0x05,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x05, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x05,0x02,0x00,0x02,0x05,0x02,0x00,0x20,0x0c, 0x20,0x02,0x02,0x03,0x02,0x00,0x02,0x05,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00, 0x20,0x06,0x20,0x02,0x02,0x03,0x02,0x05,0x02,0x00,0x02,0x05,0x02,0x00,0x02,0x00, 0x02,0x00,0x20,0x06,0x20,0x02,0x02,0x03,0x02,0x05,0x02,0x05,0x02,0x05,0x02,0x00, 0x02,0x00,0x02,0x00,0x20,0x06,0x20,0x02,0x20,0x04,0x20,0x02,0x02,0x06,0x02,0x04, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06, 0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x04,0x02,0x06, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06, 0x02,0x00,0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x04,0x02,0x06,0x02,0x06, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00, 0x02,0x00,0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x04,0x02,0x06,0x02,0x06,0x02,0x06, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x00, 0x02,0x00,0x20,0x0c,0x20,0x02,0x02,0x04,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x00, 0x20,0x0c,0x20,0x02,0x02,0x03,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x06, 0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00, 0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06, 0x02,0x06,0x02,0x06,0x02,0x06,0x20,0x18,0x20,0x02,0x02,0x03,0x02,0x06,0x02,0x00, 0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06, 0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x06, 0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x20,0x18,0x20,0x02, 0x02,0x03,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x00,0x02,0x06, 0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06, 0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06, 0x02,0x06,0x20,0x18,0x20,0x02,0x02,0x02,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x00, 0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06, 0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x20,0x18,0x20,0x02,0x02,0x02,0x02,0x06, 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00, 0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x00, 0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x06,0x20,0x18, 0x20,0x02,0x02,0x02,0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x00, 0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06, 0x02,0x06,0x02,0x00,0x02,0x00,0x02,0x06,0x02,0x06,0x02,0x00,0x02,0x06,0x02,0x06, 0x02,0x06,0x02,0x06,0x20,0x18,0x20,0x02,0x20,0x0b,0x20,0x02,0x04,0x20,0x02,0x20, 0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x2a,0x01,0x01,0x00,0x00,0x24,0xfc,0x07,0x00, 0x7c,0x01,0x02,0x01,0x00,0x07,0x01,0x02,0x02,0x09,0x28,0x02,0x07,0x02,0x02,0x10, 0x1b,0x1d,0x14,0x00,0x02,0x00,0x1c,0x28,0x00,0x07,0x00,0x07,0x02,0x23,0x1d,0x21, 0x00,0x07,0x02,0x1c,0x28,0x00,0x07,0x00,0x07,0x02,0x02,0xb0,0x00,0x01,0x00,0x02, 0x00,0x03,0x04,0x01,0x00,0x00,0x24,0xfd,0x03,0x04,0x01,0x00,0x00,0x25,0x02,0xb0, 0x00,0x2a,0x05,0x02,0xff,0x24,0xfd,0x03,0x04,0x01,0x00,0x00,0x25,0x23,0x02,0x01, 0x0a,0x2a,0x05,0x03,0x00,0x01,0x00,0x00,0x24,0xfd,0x03,0x04,0x01,0x00,0x00,0x25, 0x02,0x01,0x09,0x23,0x2a,0x05,0x03,0x03,0x01,0x00,0x00,0x3d,0x2a,0x05,0x03,0x01, 0x01,0x00,0x00,0x02,0x00,0x2a,0x05,0x24,0xff,0x02,0xaf,0x00,0x28,0x00,0x07,0x00, 0x04,0x16,0x1d,0x5e,0x00,0x03,0x03,0x01,0x00,0x00,0x04,0x2a,0x1c,0x78,0x00,0x03, 0x02,0x01,0x00,0x00,0x07,0x00,0x03,0x00,0x01,0x00,0x00,0x25,0x23,0x06,0x22,0x00, 0x28,0x01,0x05,0x02,0x02,0x07,0x01,0x11,0x2a,0x05,0x02,0x00,0x01,0x00,0x01,0x00, 0x02,0x00,0x28,0x00,0x04,0x07,0x00,0x02,0x10,0x18,0x1d,0x26,0x00,0x05,0x24,0xfd, 0x07,0x00,0x23,0x27,0x05,0x03,0x06,0x01,0x00,0x00,0x25,0x26,0x07,0x00,0x02,0x01, 0x09,0x28,0x00,0x1c,0x05,0x00,0x05,0x03,0x07,0x01,0x00,0x00,0x25,0x60,0x01,0x00, 0x03,0x00,0x02,0xa7,0x00,0x15,0x1d,0x7d,0x01,0x02,0xff,0x24,0xfd,0x03,0x04,0x01, 0x00,0x00,0x25,0x23,0x02,0x01,0x0a,0x2a,0x05,0x03,0x03,0x01,0x00,0x00,0x25,0x04, 0x16,0x06,0x15,0x1d,0x34,0x00,0x05,0x3d,0x03,0x03,0x01,0x00,0x00,0x25,0x0a,0x03, 0x05,0x01,0x00,0x00,0x25,0x19,0x06,0x15,0x1d,0x3f,0x00,0x05,0x24,0xff,0x02,0x00, 0x18,0x1d,0x48,0x00,0x02,0xb1,0x00,0x1c,0x49,0x00,0x04,0x05,0x24,0xfd,0x02,0x10, 0x02,0x02,0x09,0x23,0x28,0x00,0x24,0xfd,0x02,0x10,0x02,0x03,0x09,0x23,0x28,0x01, 0x35,0x02,0x08,0x12,0x02,0x07,0x0e,0x28,0x02,0x02,0x00,0x07,0x02,0x02,0x01,0x16, 0x06,0x1d,0x75,0x00,0x05,0x07,0x00,0x06,0x15,0x1d,0x8e,0x00,0x05,0x07,0x02,0x02, 0x03,0x16,0x06,0x1d,0x87,0x00,0x05,0x07,0x00,0x06,0x1d,0x8e,0x00,0x05,0x07,0x01, 0x1d,0x99,0x00,0x03,0xff,0x00,0xff,0x00,0x1c,0x9b,0x00,0x02,0x00,0x4a,0x05,0x02, 0xff,0x24,0xfd,0x03,0x04,0x01,0x00,0x00,0x25,0x23,0x02,0x01,0x0a,0x2a,0x05,0x03, 0x00,0x01,0x00,0x00,0x24,0xfd,0x03,0x04,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x23, 0x2a,0x05,0x24,0xff,0x02,0xaf,0x00,0x28,0x00,0x07,0x00,0x03,0x00,0x01,0x00,0x00, 0x25,0x23,0x06,0x22,0x00,0x28,0x01,0x06,0x22,0x01,0x28,0x02,0x05,0x07,0x02,0x04, 0x17,0x1d,0x69,0x01,0x02,0x01,0x24,0xfe,0x07,0x02,0x03,0x01,0x01,0x00,0x00,0x25, 0x23,0x23,0x4a,0x05,0x02,0x02,0x24,0xfe,0x07,0x02,0x02,0x01,0x03,0x01,0x01,0x00, 0x00,0x25,0x09,0x23,0x23,0x4a,0x05,0x02,0x03,0x24,0xfe,0x07,0x02,0x02,0x02,0x03, 0x01,0x01,0x00,0x00,0x25,0x09,0x23,0x23,0x4a,0x05,0x03,0x02,0x01,0x00,0x00,0x03, 0x02,0x01,0x00,0x00,0x25,0x02,0x01,0x0a,0x2a,0x02,0x00,0x1a,0x1d,0x65,0x01,0x03, 0x01,0x01,0x00,0x00,0x03,0x01,0x01,0x00,0x00,0x25,0x02,0x03,0x09,0x2a,0x05,0x03, 0x02,0x01,0x00,0x00,0x02,0x02,0x07,0x01,0x11,0x2a,0x05,0x03,0x01,0x01,0x00,0x00, 0x25,0x07,0x02,0x48,0x1b,0x1d,0x61,0x01,0x03,0x01,0x01,0x00,0x00,0x02,0x00,0x2a, 0x1c,0x62,0x01,0x04,0x1c,0x66,0x01,0x04,0x1c,0x7a,0x01,0x02,0x03,0x02,0x00,0x4a, 0x05,0x02,0x02,0x02,0x00,0x4a,0x05,0x02,0x01,0x02,0x00,0x4a,0x1c,0x7e,0x01,0x04, 0x01,0x01,0x02,0x00,0x07,0x00,0x44,0x28,0x01,0x02,0x00,0x28,0x02,0x04,0x07,0x02, 0x07,0x01,0x18,0x1d,0x27,0x00,0x05,0x24,0xfd,0x07,0x02,0x07,0x00,0x07,0x02,0x45, 0x30,0x07,0x02,0x02,0x01,0x09,0x28,0x02,0x1c,0x0a,0x00,0x05,0x02,0x00,0x01,0x02, 0x00,0x00,0x07,0x00,0x24,0xfd,0x48,0x1b,0x1d,0x0e,0x00,0x02,0x00,0x1c,0x2e,0x00, 0x07,0x01,0x24,0xfd,0x07,0x00,0x23,0x16,0x1d,0x24,0x00,0x24,0xfd,0x07,0x00,0x02, 0x01,0x09,0x23,0x1c,0x2e,0x00,0x07,0x00,0x02,0x01,0x09,0x07,0x01,0x02,0xb5,0x00, 0x01,0x01,0x00,0x00,0x02,0x00,0x07,0x00,0x02,0xb5,0x00,0x01,0x01,0x07,0x00,0x07, 0x00,0x04,0x17,0x1d,0x67,0x00,0x07,0x00,0x2d,0x06,0x22,0x00,0x28,0x01,0x06,0x22, 0x01,0x28,0x02,0x06,0x22,0x02,0x28,0x03,0x06,0x22,0x03,0x28,0x04,0x06,0x22,0x04, 0x28,0x05,0x06,0x22,0x05,0x28,0x06,0x06,0x22,0x06,0x28,0x07,0x05,0x07,0x01,0x03, 0x11,0x01,0x00,0x00,0x25,0x07,0x02,0x07,0x03,0x07,0x04,0x02,0x1c,0x00,0x07,0x05, 0x02,0x1c,0x00,0x07,0x06,0x02,0x1c,0x00,0x07,0x07,0x02,0x1c,0x00,0x07,0x00,0x2e, 0x02,0xb7,0x00,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20, 0x02,0x20,0x02,0x1c,0x68,0x00,0x04,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x04,0x00, 0x02,0x1c,0x00,0x07,0x00,0x02,0xb7,0x00,0x20,0x02,0x01,0x02,0x00,0x00,0x07,0x01, 0x07,0x00,0x44,0x1b,0x1d,0x0e,0x00,0x07,0x01,0x1c,0x26,0x00,0x07,0x00,0x07,0x01, 0x45,0x15,0x1d,0x1c,0x00,0x07,0x01,0x1c,0x26,0x00,0x07,0x00,0x07,0x01,0x02,0x01, 0x09,0x02,0xb9,0x00,0x01,0x03,0x02,0x00,0x07,0x01,0x02,0x00,0x19,0x1d,0x75,0x00, 0x07,0x00,0x07,0x02,0x02,0xb9,0x00,0x28,0x03,0x07,0x03,0x02,0x01,0x09,0x28,0x04, 0x07,0x00,0x07,0x02,0x07,0x03,0x07,0x02,0x0a,0x46,0x07,0x00,0x07,0x04,0x02,0x06, 0x46,0x07,0x00,0x07,0x04,0x02,0x06,0x09,0x02,0x06,0x46,0x07,0x00,0x07,0x04,0x02, 0x0c,0x09,0x02,0x08,0x46,0x76,0x07,0x00,0x07,0x04,0x02,0x14,0x09,0x02,0x08,0x46, 0x76,0x07,0x00,0x07,0x04,0x02,0x1c,0x09,0x02,0x08,0x46,0x76,0x07,0x00,0x07,0x04, 0x02,0x24,0x09,0x02,0x08,0x46,0x76,0x20,0x07,0x07,0x00,0x07,0x01,0x02,0x01,0x0a, 0x07,0x04,0x02,0x2c,0x09,0x02,0xba,0x00,0x20,0x02,0x1c,0x76,0x00,0x04,0x01,0x00, 0x00,0x00,0x24,0x09,0x24,0x0a,0x24,0x0b,0x24,0x0c,0x24,0x15,0x02,0xb8,0x00,0x20, 0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x01,0x01,0x00,0x07,0x00,0x04,0x17, 0x1d,0x4f,0x00,0x02,0x09,0x07,0x00,0x02,0x00,0x02,0x04,0x46,0x2a,0x05,0x02,0x0a, 0x07,0x00,0x02,0x04,0x02,0x04,0x46,0x2a,0x05,0x02,0x0b,0x07,0x00,0x02,0x08,0x02, 0x04,0x46,0x2a,0x05,0x02,0x0c,0x07,0x00,0x02,0x0c,0x02,0x04,0x46,0x2a,0x05,0x07, 0x00,0x02,0x10,0x02,0x08,0x46,0x76,0x28,0x01,0x02,0x15,0x07,0x00,0x07,0x01,0x02, 0x18,0x02,0xba,0x00,0x2a,0x05,0x02,0x00,0x1c,0x50,0x00,0x04,0x01,0x02,0x02,0x00, 0x07,0x00,0x06,0x22,0x00,0x28,0x02,0x05,0x07,0x01,0x06,0x22,0x00,0x28,0x03,0x05, 0x07,0x02,0x07,0x03,0x89,0x01,0x01,0x01,0x00,0x03,0x10,0x01,0x00,0x00,0x04,0x2a, 0x05,0x62,0x28,0x01,0x07,0x01,0x04,0x16,0x1d,0x7f,0x00,0x03,0xff,0x00,0xff,0x00, 0x02,0x18,0x00,0x05,0x02,0x08,0x02,0x00,0x20,0x01,0x2a,0x05,0x07,0x00,0x1d,0x2f, 0x00,0x02,0x15,0x04,0x2a,0x1c,0x30,0x00,0x04,0x05,0x24,0x10,0x1d,0x4d,0x00,0x02, 0x09,0x24,0x12,0x2a,0x05,0x02,0x0a,0x24,0x13,0x2a,0x05,0x02,0x0b,0x24,0x14,0x2a, 0x05,0x02,0x00,0x1c,0x79,0x00,0x02,0x2d,0x00,0x1d,0x5b,0x00,0x02,0x09,0x24,0x11, 0x2a,0x1c,0x76,0x00,0x02,0x0a,0x02,0x2f,0x00,0x2a,0x05,0x02,0x0b,0x02,0x30,0x00, 0x2a,0x05,0x02,0x0c,0x02,0x31,0x00,0x2a,0x05,0x02,0x09,0x02,0x2e,0x00,0x2a,0x05, 0x02,0x00,0x05,0x02,0x00,0x1c,0x9f,0x00,0x03,0x00,0xff,0x00,0x00,0x02,0x18,0x00, 0x05,0x02,0x0d,0x6a,0x2a,0x05,0x02,0x08,0x02,0x05,0x20,0x01,0x2a,0x05,0x07,0x01, 0x02,0xbc,0x00,0x05,0x04,0x63,0x05,0x04,0x05,0x02,0x00,0x01,0x02,0x01,0x00,0x07, 0x00,0x06,0x22,0x00,0x28,0x02,0x05,0x07,0x02,0x04,0x17,0x06,0x1d,0x17,0x00,0x05, 0x07,0x01,0x07,0x02,0x89,0x15,0x01,0x03,0x00,0x00,0x07,0x01,0x07,0x02,0x18,0x1d, 0x21,0x00,0x07,0x00,0x07,0x01,0x02,0x02,0x46,0x76,0x07,0x00,0x07,0x01,0x02,0x02, 0x09,0x07,0x02,0x02,0xc0,0x00,0x20,0x02,0x1c,0x22,0x00,0x04,0x01,0x01,0x03,0x00, 0x07,0x00,0x44,0x28,0x01,0x07,0x01,0x02,0x05,0x16,0x06,0x15,0x1d,0x15,0x00,0x05, 0x07,0x01,0x02,0x0d,0x16,0x1d,0x1d,0x00,0x07,0x00,0x1c,0x5d,0x00,0x07,0x00,0x03, 0x14,0x01,0x00,0x00,0x25,0x03,0x15,0x01,0x00,0x00,0x25,0x02,0x0c,0x00,0x28,0x02, 0x07,0x01,0x02,0x0a,0x18,0x1d,0x3d,0x00,0x02,0x00,0x1c,0x4c,0x00,0x07,0x01,0x02, 0x1a,0x18,0x1d,0x4a,0x00,0x02,0x05,0x1c,0x4c,0x00,0x02,0x0d,0x28,0x03,0x07,0x02, 0x02,0x00,0x07,0x03,0x02,0x01,0x11,0x02,0xc0,0x00,0x02,0x08,0x00,0x01,0x02,0x00, 0x00,0x07,0x00,0x02,0x01,0x16,0x1d,0x1b,0x00,0x02,0x05,0x07,0x01,0x44,0x16,0x1d, 0x16,0x00,0x24,0x17,0x1c,0x18,0x00,0x24,0x18,0x1c,0x2a,0x00,0x07,0x00,0x02,0x02, 0x16,0x1d,0x28,0x00,0x24,0x19,0x1c,0x2a,0x00,0x24,0x16,0x01,0x00,0x03,0x00,0x03, 0x00,0x80,0xff,0x00,0x02,0x18,0x00,0x05,0x24,0x15,0x04,0x16,0x1d,0x15,0x00,0x02, 0x00,0x1c,0x64,0x00,0x02,0x29,0x00,0x5f,0x28,0x00,0x02,0x2b,0x00,0x28,0x01,0x07, 0x00,0x02,0x01,0x16,0x1d,0x31,0x00,0x02,0x2a,0x00,0x02,0xc1,0x00,0x1c,0x40,0x00, 0x07,0x00,0x02,0x02,0x16,0x1d,0x3f,0x00,0x02,0x2c,0x00,0x1c,0x40,0x00,0x04,0x28, 0x02,0x07,0x02,0x02,0x1d,0x00,0x05,0x03,0x10,0x01,0x00,0x00,0x3d,0x2a,0x05,0x24, 0x15,0x2d,0x07,0x01,0x5f,0x07,0x00,0x07,0x02,0x02,0xc2,0x00,0x5f,0x07,0x02,0x6e, 0x05,0x02,0x01,0x01,0x00,0x06,0x00,0x69,0x28,0x00,0x07,0x00,0x03,0x12,0x01,0x00, 0x00,0x25,0x17,0x1d,0x1d,0x00,0x03,0x16,0x01,0x00,0x00,0x25,0x26,0x05,0x07,0x00, 0x5f,0x1c,0x1e,0x00,0x04,0x05,0x24,0x08,0x34,0x02,0x05,0x16,0x1d,0x2d,0x00,0x05, 0x04,0x1c,0x0f,0x02,0x34,0x02,0x00,0x16,0x1d,0x02,0x01,0x05,0x07,0x00,0x03,0x09, 0x01,0x00,0x00,0x25,0x16,0x1d,0xfe,0x00,0x02,0x0d,0x6a,0x02,0x00,0x02,0x01,0x02, 0x19,0x00,0x2a,0x05,0x03,0x00,0x80,0xff,0x00,0x02,0x18,0x00,0x05,0x24,0x10,0x1d, 0x8f,0x00,0x02,0x15,0x04,0x6d,0x02,0xbd,0x02,0x10,0x00,0x2a,0x02,0x1e,0x00,0x05, 0x03,0x0f,0x01,0x00,0x00,0x25,0x03,0x17,0x01,0x00,0x00,0x25,0x24,0x0d,0x02,0x05, 0x45,0x7a,0x47,0x02,0x01,0x6c,0x05,0x03,0x18,0x01,0x00,0x00,0x25,0x60,0x05,0x02, 0x01,0x20,0x01,0x1c,0xfb,0x00,0x24,0x15,0x04,0x16,0x1d,0xd9,0x00,0x02,0x28,0x00, 0x28,0x01,0x07,0x01,0x44,0x1d,0xa6,0x00,0x07,0x01,0x1c,0xa7,0x00,0x04,0x28,0x02, 0x07,0x02,0x6d,0x28,0x03,0x07,0x03,0x02,0xbd,0x02,0x10,0x00,0x28,0x04,0x07,0x02, 0x04,0x16,0x1d,0xc3,0x00,0x07,0x04,0x1c,0xcc,0x00,0x07,0x04,0x07,0x02,0x02,0xbf, 0x02,0x11,0x00,0x28,0x05,0x02,0x15,0x07,0x05,0x2a,0x02,0x1e,0x00,0x1c,0xda,0x00, 0x04,0x05,0x02,0xc3,0x00,0x1d,0xfa,0x00,0x02,0x28,0x00,0x26,0x05,0x03,0x19,0x01, 0x00,0x00,0x25,0x60,0x05,0x02,0x03,0x02,0x00,0x3d,0x20,0x02,0x20,0x02,0x1c,0xfb, 0x00,0x04,0x1c,0xff,0x00,0x04,0x1c,0x0f,0x02,0x34,0x02,0x01,0x16,0x1d,0x33,0x01, 0x05,0x07,0x00,0x03,0x0d,0x01,0x00,0x00,0x25,0x16,0x1d,0x2f,0x01,0x02,0xff,0x02, 0x18,0x00,0x05,0x03,0x1a,0x01,0x00,0x00,0x25,0x60,0x05,0x02,0x67,0x00,0x05,0x02, 0x02,0x20,0x01,0x1c,0x30,0x01,0x04,0x1c,0x0f,0x02,0x34,0x02,0x02,0x16,0x1d,0x5e, 0x01,0x05,0x24,0x10,0x15,0x1d,0x5a,0x01,0x02,0x01,0x02,0xbe,0x00,0x05,0x02,0x4a, 0x00,0x05,0x03,0x0e,0x01,0x00,0x00,0x25,0x04,0x02,0x0b,0x6c,0x05,0x04,0x1c,0x5b, 0x01,0x04,0x1c,0x0f,0x02,0x34,0x02,0x03,0x16,0x1d,0x9b,0x01,0x22,0x01,0x28,0x01, 0x07,0x00,0x03,0x0c,0x01,0x00,0x00,0x25,0x16,0x1d,0x97,0x01,0x03,0x1b,0x01,0x00, 0x00,0x25,0x60,0x05,0x02,0x2d,0x00,0x1d,0x89,0x01,0x02,0x66,0x00,0x1c,0x8a,0x01, 0x04,0x05,0x02,0x77,0x00,0x05,0x02,0x04,0x3d,0x20,0x02,0x1c,0x98,0x01,0x04,0x1c, 0x0f,0x02,0x34,0x02,0x04,0x16,0x1d,0xd7,0x01,0x22,0x01,0x28,0x01,0x24,0x09,0x24, 0x11,0x17,0x1d,0xbd,0x01,0x03,0x1c,0x01,0x00,0x00,0x25,0x60,0x05,0x02,0x05,0x20, 0x01,0x1c,0xd4,0x01,0x3d,0x07,0x01,0x0a,0x02,0x03,0x19,0x1d,0xd3,0x01,0x02,0x66, 0x00,0x05,0x02,0x04,0x3d,0x20,0x02,0x1c,0xd4,0x01,0x04,0x1c,0x0f,0x02,0x34,0x02, 0x06,0x16,0x1d,0x0d,0x02,0x05,0x03,0x0e,0x01,0x00,0x00,0x25,0x04,0x02,0x0b,0x6c, 0x05,0x02,0xc3,0x00,0x1d,0x09,0x02,0x02,0x28,0x00,0x26,0x05,0x03,0x1d,0x01,0x00, 0x00,0x25,0x60,0x05,0x02,0x03,0x02,0x00,0x3d,0x20,0x02,0x20,0x02,0x1c,0x0a,0x02, 0x04,0x1c,0x0f,0x02,0x05,0x04,0x28,0x01,0x07,0x01,0x04,0x17,0x1d,0x20,0x02,0x02, 0x08,0x07,0x01,0x2a,0x1c,0x21,0x02,0x04,0x05,0x03,0x12,0x01,0x00,0x00,0x07,0x00, 0x2a,0x05,0x03,0x13,0x01,0x00,0x00,0x25,0x3d,0x17,0x1d,0x4b,0x02,0x03,0x13,0x01, 0x00,0x00,0x3d,0x2a,0x05,0x02,0x6a,0x00,0x05,0x02,0x76,0x00,0x05,0x02,0x00,0x1c, 0x4c,0x02,0x04,0x01,0x00,0x00,0x00,0x24,0x08,0x34,0x02,0x05,0x16,0x1d,0x0f,0x00, 0x05,0x02,0x01,0x1c,0x12,0x00,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x24,0x08,0x34, 0x02,0x05,0x16,0x1d,0x0f,0x00,0x05,0x02,0x01,0x1c,0x12,0x00,0x05,0x02,0x00,0x01, 0x01,0x02,0x00,0x07,0x00,0x02,0x06,0x12,0x02,0x03,0x0e,0x28,0x01,0x07,0x00,0x02, 0xff,0x0e,0x28,0x02,0x07,0x01,0x02,0x00,0x16,0x1d,0x25,0x00,0x03,0x1f,0x01,0x00, 0x00,0x25,0x07,0x02,0x23,0x1c,0x65,0x00,0x07,0x01,0x02,0x01,0x16,0x1d,0x3f,0x00, 0x02,0xff,0x03,0x1f,0x01,0x00,0x00,0x25,0x02,0x7f,0x07,0x02,0x0a,0x23,0x0a,0x1c, 0x65,0x00,0x07,0x01,0x02,0x02,0x16,0x1d,0x59,0x00,0x02,0xff,0x03,0x1f,0x01,0x00, 0x00,0x25,0x07,0x02,0x02,0x80,0x0a,0x23,0x0a,0x1c,0x65,0x00,0x03,0x1f,0x01,0x00, 0x00,0x25,0x02,0xff,0x07,0x02,0x0a,0x23,0x01,0x02,0x07,0x00,0x03,0xc7,0x01,0x00, 0x00,0x25,0x60,0x05,0x24,0xc1,0x15,0x1d,0xae,0x01,0x04,0x28,0x02,0x07,0x01,0x02, 0x84,0x00,0x02,0x1d,0x00,0x02,0xdf,0x00,0x28,0x03,0x07,0x03,0x04,0x17,0x1d,0x30, 0x00,0x03,0x24,0x01,0x00,0x00,0x02,0x00,0x2a,0x1c,0x31,0x00,0x04,0x05,0x07,0x03, 0x28,0x04,0x04,0x07,0x04,0x04,0x17,0x1d,0x34,0x01,0x1c,0x49,0x00,0x07,0x04,0x2e, 0x28,0x04,0x1c,0x37,0x00,0x05,0x07,0x04,0x2d,0x06,0x22,0x00,0x28,0x05,0x06,0x22, 0x01,0x28,0x06,0x05,0x07,0x05,0x27,0x05,0x03,0xc8,0x01,0x00,0x00,0x25,0x26,0x05, 0x07,0x05,0x02,0x03,0x16,0x1d,0x7e,0x00,0x03,0x26,0x01,0x00,0x00,0x07,0x06,0x02, 0x00,0x45,0x02,0x01,0x0b,0x5f,0x2a,0x1c,0x7f,0x00,0x04,0x05,0x07,0x05,0x02,0x04, 0x16,0x1d,0xea,0x00,0x07,0x06,0x02,0x04,0x04,0x46,0x02,0xb4,0x00,0x05,0x07,0x06, 0x02,0x14,0x45,0x28,0x07,0x07,0x06,0x02,0x15,0x45,0x28,0x08,0x03,0x29,0x01,0x00, 0x00,0x25,0x04,0x17,0x06,0x1d,0xc5,0x00,0x05,0x07,0x07,0x03,0x29,0x01,0x00,0x00, 0x25,0x17,0x06,0x15,0x1d,0xc5,0x00,0x05,0x07,0x08,0x03,0x2a,0x01,0x00,0x00,0x25, 0x17,0x1d,0xd4,0x00,0x03,0x44,0x01,0x00,0x00,0x25,0x02,0xca,0x00,0x1c,0xd5,0x00, 0x04,0x05,0x03,0x29,0x01,0x00,0x00,0x07,0x07,0x2a,0x05,0x03,0x2a,0x01,0x00,0x00, 0x07,0x08,0x2a,0x1c,0xeb,0x00,0x04,0x05,0x07,0x05,0x02,0x0a,0x16,0x1d,0x12,0x01, 0x07,0x06,0x02,0x01,0x04,0x02,0x47,0x02,0x2f,0x91,0x05,0x02,0x02,0x07,0x06,0x02, 0x01,0x02,0xd8,0x00,0x02,0xd9,0x00,0x2f,0x05,0x02,0x00,0x1c,0x13,0x01,0x04,0x05, 0x07,0x05,0x02,0x09,0x16,0x1d,0x2d,0x01,0x03,0x58,0xfe,0x07,0x04,0x03,0x54,0x67, 0xfb,0x13,0x88,0x05,0x02,0x00,0x1c,0x2e,0x01,0x04,0x05,0x02,0x00,0x1c,0x41,0x00, 0x05,0x07,0x02,0x04,0x16,0x1d,0xa0,0x01,0x03,0x25,0x01,0x00,0x00,0x25,0x03,0x32, 0x01,0x00,0x00,0x25,0x16,0x1d,0x8b,0x01,0x02,0x00,0x03,0x29,0x01,0x00,0x00,0x25, 0x02,0x00,0x02,0xad,0x00,0x05,0x02,0x01,0x03,0x2a,0x01,0x00,0x00,0x25,0x02,0x00, 0x02,0xad,0x00,0x05,0x02,0xfd,0x00,0x1d,0x76,0x01,0x02,0xf3,0x00,0x05,0x04,0x1c, 0x88,0x01,0x03,0x21,0x01,0x00,0x00,0x02,0x0b,0x3d,0x03,0x26,0x01,0x00,0x00,0x25, 0x09,0x20,0x02,0x2a,0x1c,0x9d,0x01,0x03,0x21,0x01,0x00,0x00,0x02,0x0b,0x3d,0x03, 0x26,0x01,0x00,0x00,0x25,0x09,0x20,0x02,0x2a,0x1c,0xab,0x01,0x03,0x21,0x01,0x00, 0x00,0x07,0x02,0x02,0xe3,0x00,0x2a,0x1c,0xaf,0x01,0x04,0x05,0x02,0x00,0x01,0x00, 0x00,0x00,0x03,0x64,0x01,0x00,0x00,0x25,0x04,0x16,0x1d,0xa6,0x00,0x03,0x64,0x01, 0x00,0x00,0x03,0x48,0x01,0x00,0x00,0x25,0x03,0x49,0x01,0x00,0x00,0x25,0x03,0x4a, 0x01,0x00,0x00,0x25,0x03,0x4b,0x01,0x00,0x00,0x25,0x03,0x4c,0x01,0x00,0x00,0x25, 0x03,0x4d,0x01,0x00,0x00,0x25,0x03,0x4e,0x01,0x00,0x00,0x25,0x03,0x4f,0x01,0x00, 0x00,0x25,0x03,0x50,0x01,0x00,0x00,0x25,0x03,0x51,0x01,0x00,0x00,0x25,0x03,0x52, 0x01,0x00,0x00,0x25,0x03,0x53,0x01,0x00,0x00,0x25,0x03,0x54,0x01,0x00,0x00,0x25, 0x03,0x55,0x01,0x00,0x00,0x25,0x03,0x56,0x01,0x00,0x00,0x25,0x03,0x57,0x01,0x00, 0x00,0x25,0x03,0x58,0x01,0x00,0x00,0x25,0x03,0x59,0x01,0x00,0x00,0x25,0x03,0x5a, 0x01,0x00,0x00,0x25,0x03,0x5b,0x01,0x00,0x00,0x25,0x03,0x5c,0x01,0x00,0x00,0x25, 0x03,0x5d,0x01,0x00,0x00,0x25,0x03,0x5e,0x01,0x00,0x00,0x25,0x03,0x5f,0x01,0x00, 0x00,0x25,0x20,0x18,0x2a,0x1c,0xa7,0x00,0x04,0x05,0x03,0x64,0x01,0x00,0x00,0x25, 0x01,0x01,0x00,0x00,0x07,0x00,0x04,0x20,0x02,0x02,0x98,0x00,0x05,0x02,0x00,0x01, 0x00,0x01,0x00,0x4d,0x28,0x00,0x07,0x00,0x03,0x65,0x01,0x00,0x00,0x25,0x17,0x1d, 0x6e,0x00,0x03,0x65,0x01,0x00,0x00,0x07,0x00,0x2a,0x05,0x07,0x00,0x1d,0x55,0x00, 0x03,0x66,0x01,0x00,0x00,0x25,0x04,0x16,0x1d,0x3b,0x00,0x03,0x68,0x01,0x00,0x00, 0x02,0x01,0x2a,0x05,0x03,0x66,0x01,0x00,0x00,0x35,0x2a,0x1c,0x52,0x00,0x03,0x68, 0x01,0x00,0x00,0x03,0x68,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x2a,0x05,0x03,0x66, 0x01,0x00,0x00,0x35,0x2a,0x1c,0x6b,0x00,0x03,0x66,0x01,0x00,0x00,0x25,0x04,0x17, 0x1d,0x6a,0x00,0x03,0x66,0x01,0x00,0x00,0x35,0x2a,0x1c,0x6b,0x00,0x04,0x1c,0x13, 0x01,0x03,0x66,0x01,0x00,0x00,0x25,0x04,0x17,0x1d,0x12,0x01,0x35,0x03,0x66,0x01, 0x00,0x00,0x25,0x0a,0x03,0x6e,0x01,0x00,0x00,0x25,0x1b,0x1d,0xc4,0x00,0x03,0x65, 0x01,0x00,0x00,0x25,0x1d,0xb8,0x00,0x03,0x67,0x01,0x00,0x00,0x03,0x68,0x01,0x00, 0x00,0x25,0x02,0x01,0x16,0x1d,0xae,0x00,0x03,0x6b,0x01,0x00,0x00,0x25,0x1c,0xb4, 0x00,0x03,0x6c,0x01,0x00,0x00,0x25,0x2a,0x1c,0xb9,0x00,0x04,0x05,0x03,0x66,0x01, 0x00,0x00,0x04,0x2a,0x1c,0x0f,0x01,0x35,0x03,0x66,0x01,0x00,0x00,0x25,0x0a,0x03, 0x6d,0x01,0x00,0x00,0x25,0x1b,0x06,0x1d,0xdf,0x00,0x05,0x03,0x65,0x01,0x00,0x00, 0x25,0x15,0x1d,0x0e,0x01,0x03,0x67,0x01,0x00,0x00,0x03,0x68,0x01,0x00,0x00,0x25, 0x02,0x01,0x16,0x1d,0xfc,0x00,0x03,0x69,0x01,0x00,0x00,0x25,0x1c,0x02,0x01,0x03, 0x6a,0x01,0x00,0x00,0x25,0x2a,0x05,0x03,0x66,0x01,0x00,0x00,0x04,0x2a,0x1c,0x0f, 0x01,0x04,0x1c,0x13,0x01,0x04,0x01,0x00,0x01,0x00,0x03,0x67,0x01,0x00,0x00,0x25, 0x28,0x00,0x03,0x67,0x01,0x00,0x00,0x04,0x2a,0x05,0x07,0x00,0x01,0x00,0x01,0x00, 0x02,0xc4,0x00,0x05,0x69,0x03,0x09,0x01,0x00,0x00,0x25,0x16,0x1d,0x33,0x00,0x24, 0x08,0x34,0x02,0x00,0x16,0x1d,0x1d,0x00,0x05,0x04,0x1c,0x30,0x00,0x05,0x03,0xd1, 0x01,0x00,0x00,0x25,0x60,0x05,0x02,0x08,0x02,0x06,0x20,0x01,0x2a,0x05,0x02,0x00, 0x1c,0x34,0x00,0x04,0x05,0x02,0xcb,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x25,0x34, 0x02,0x00,0x16,0x1d,0x5b,0x00,0x05,0x02,0xa5,0x00,0x05,0x03,0x02,0x01,0x00,0x00, 0x00,0x05,0x02,0xdb,0x00,0x05,0x02,0x00,0x1c,0x80,0x02,0x34,0x02,0x01,0x16,0x1d, 0x7c,0x00,0x22,0x01,0x28,0x00,0x02,0xa5,0x00,0x05,0x03,0x02,0x01,0x00,0x00,0x00, 0x05,0x07,0x00,0x02,0xdc,0x00,0x05,0x02,0x00,0x1c,0x80,0x02,0x34,0x02,0x02,0x16, 0x1d,0xac,0x00,0x05,0x02,0xa5,0x00,0x05,0x03,0x25,0x01,0x00,0x00,0x25,0x03,0x33, 0x01,0x00,0x00,0x25,0x17,0x1d,0xa1,0x00,0x03,0x02,0x01,0x00,0x00,0x00,0x1c,0xa2, 0x00,0x04,0x05,0x02,0xfe,0x00,0x05,0x02,0x00,0x1c,0x80,0x02,0x34,0x02,0x03,0x16, 0x1d,0xfd,0x00,0x22,0x01,0x28,0x00,0x02,0xa5,0x00,0x05,0x03,0x25,0x01,0x00,0x00, 0x25,0x03,0x33,0x01,0x00,0x00,0x25,0x17,0x1d,0xd8,0x00,0x02,0xb3,0x00,0x05,0x03, 0x02,0x01,0x00,0x00,0x00,0x1c,0xd9,0x00,0x04,0x05,0x07,0x00,0x02,0xff,0x00,0x05, 0x03,0x25,0x01,0x00,0x00,0x25,0x03,0x33,0x01,0x00,0x00,0x25,0x17,0x1d,0xf9,0x00, 0x03,0xcf,0x01,0x00,0x00,0x25,0x1c,0xfa,0x00,0x04,0x1c,0x80,0x02,0x34,0x02,0x0b, 0x16,0x1d,0x51,0x01,0x22,0x01,0x28,0x00,0x02,0xa5,0x00,0x05,0x03,0x25,0x01,0x00, 0x00,0x25,0x03,0x33,0x01,0x00,0x00,0x25,0x17,0x1d,0x29,0x01,0x02,0xb3,0x00,0x05, 0x03,0x02,0x01,0x00,0x00,0x00,0x1c,0x2a,0x01,0x04,0x05,0x07,0x00,0x03,0x00,0x01, 0x00,0x00,0x00,0x05,0x03,0x25,0x01,0x00,0x00,0x25,0x03,0x33,0x01,0x00,0x00,0x25, 0x17,0x1d,0x4d,0x01,0x03,0xcf,0x01,0x00,0x00,0x25,0x1c,0x4e,0x01,0x04,0x1c,0x80, 0x02,0x34,0x02,0x04,0x16,0x1d,0x75,0x01,0x05,0x02,0xa5,0x00,0x05,0x02,0xb3,0x00, 0x05,0x03,0x02,0x01,0x00,0x00,0x00,0x05,0x02,0xe6,0x00,0x05,0x03,0xcf,0x01,0x00, 0x00,0x25,0x1c,0x80,0x02,0x34,0x02,0x05,0x16,0x1d,0x9e,0x01,0x22,0x01,0x28,0x00, 0x02,0xa5,0x00,0x05,0x02,0xb3,0x00,0x05,0x03,0x02,0x01,0x00,0x00,0x00,0x05,0x07, 0x00,0x02,0xe7,0x00,0x05,0x03,0xcf,0x01,0x00,0x00,0x25,0x1c,0x80,0x02,0x34,0x02, 0x06,0x16,0x1d,0xb7,0x01,0x05,0x02,0xa5,0x00,0x05,0x02,0xe8,0x00,0x05,0x03,0xd0, 0x01,0x00,0x00,0x25,0x1c,0x80,0x02,0x34,0x02,0x09,0x16,0x1d,0xd5,0x01,0x22,0x01, 0x28,0x00,0x02,0xa5,0x00,0x05,0x07,0x00,0x02,0xfb,0x00,0x05,0x03,0xd0,0x01,0x00, 0x00,0x25,0x1c,0x80,0x02,0x34,0x02,0x07,0x16,0x1d,0xf3,0x01,0x22,0x01,0x28,0x00, 0x02,0xa5,0x00,0x05,0x07,0x00,0x02,0xf7,0x00,0x05,0x03,0xd0,0x01,0x00,0x00,0x25, 0x1c,0x80,0x02,0x34,0x02,0x08,0x16,0x1d,0x0d,0x02,0x22,0x01,0x28,0x00,0x07,0x00, 0x02,0xfa,0x00,0x05,0x03,0xd0,0x01,0x00,0x00,0x25,0x1c,0x80,0x02,0x34,0x02,0x0a, 0x16,0x1d,0x29,0x02,0x05,0x02,0xa5,0x00,0x05,0x03,0x01,0x01,0x00,0x00,0x00,0x05, 0x03,0xcf,0x01,0x00,0x00,0x25,0x1c,0x80,0x02,0x34,0x02,0x0c,0x16,0x1d,0x46,0x02, 0x22,0x01,0x28,0x00,0x03,0x02,0x01,0x00,0x00,0x00,0x05,0x07,0x00,0x02,0xea,0x00, 0x05,0x02,0x00,0x1c,0x80,0x02,0x34,0x02,0x0d,0x16,0x1d,0x57,0x02,0x05,0x02,0xf1, 0x00,0x05,0x02,0x00,0x1c,0x80,0x02,0x34,0x02,0x0e,0x16,0x1d,0x6c,0x02,0x05,0x02, 0xa5,0x00,0x05,0x02,0xfc,0x00,0x05,0x02,0x00,0x1c,0x80,0x02,0x34,0x02,0x0f,0x16, 0x1d,0x7d,0x02,0x05,0x02,0xed,0x00,0x05,0x02,0x00,0x1c,0x80,0x02,0x05,0x02,0x00, 0x28,0x00,0x07,0x00,0x03,0xcf,0x01,0x00,0x00,0x25,0x16,0x1d,0x97,0x02,0x03,0x07, 0x01,0x00,0x00,0x00,0x1c,0xaf,0x02,0x07,0x00,0x03,0xd0,0x01,0x00,0x00,0x25,0x16, 0x1d,0xac,0x02,0x03,0x06,0x01,0x00,0x00,0x00,0x1c,0xaf,0x02,0x02,0xcc,0x00,0x05, 0x02,0xf0,0x00,0x05,0x02,0x9b,0x00,0x05,0x02,0x8f,0x00,0x05,0x02,0x00,0x01,0x02, 0x00,0x00,0x07,0x01,0x07,0x00,0x44,0x18,0x1d,0x1e,0x00,0x07,0x00,0x07,0x01,0x45, 0x7a,0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x02,0xce,0x00,0x20,0x02,0x1c,0x1f,0x00, 0x04,0x01,0x01,0x00,0x00,0x07,0x00,0x02,0x00,0x02,0xce,0x00,0x49,0x01,0x00,0x00, 0x00,0x02,0x32,0x00,0x03,0x6f,0x01,0x00,0x00,0x25,0x6a,0x02,0xcf,0x00,0x03,0x70, 0x01,0x00,0x00,0x25,0x24,0x06,0x77,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02, 0x20,0x02,0x49,0x01,0x01,0x00,0x00,0x07,0x00,0x03,0x32,0x01,0x00,0x00,0x25,0x16, 0x1d,0x15,0x00,0x03,0x71,0x01,0x00,0x00,0x25,0x1c,0x2d,0x00,0x07,0x00,0x03,0x33, 0x01,0x00,0x00,0x25,0x16,0x1d,0x2a,0x00,0x03,0x72,0x01,0x00,0x00,0x25,0x1c,0x2d, 0x00,0x07,0x00,0x79,0x01,0x00,0x00,0x00,0x03,0x22,0x01,0x00,0x00,0x25,0x03,0x73, 0x01,0x00,0x00,0x25,0x6a,0x02,0xcf,0x00,0x03,0x74,0x01,0x00,0x00,0x25,0x24,0x1d, 0x77,0x03,0x75,0x01,0x00,0x00,0x25,0x03,0x24,0x01,0x00,0x00,0x25,0x79,0x03,0x76, 0x01,0x00,0x00,0x25,0x03,0x25,0x01,0x00,0x00,0x25,0x02,0xd1,0x00,0x03,0x77,0x01, 0x00,0x00,0x25,0x24,0x06,0x77,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20, 0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x01, 0x00,0x00,0x03,0x22,0x01,0x00,0x00,0x25,0x03,0x78,0x01,0x00,0x00,0x25,0x6a,0x02, 0xcf,0x00,0x03,0x79,0x01,0x00,0x00,0x25,0x24,0x1d,0x77,0x03,0x7a,0x01,0x00,0x00, 0x25,0x24,0x06,0x77,0x03,0x7b,0x01,0x00,0x00,0x25,0x07,0x00,0x77,0x04,0x20,0x02, 0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02, 0x49,0x01,0x01,0x00,0x00,0x03,0x22,0x01,0x00,0x00,0x25,0x03,0x7c,0x01,0x00,0x00, 0x25,0x6a,0x02,0xcf,0x00,0x03,0x7d,0x01,0x00,0x00,0x25,0x24,0x1d,0x77,0x03,0x7e, 0x01,0x00,0x00,0x25,0x24,0x06,0x77,0x03,0x7f,0x01,0x00,0x00,0x25,0x07,0x00,0x02, 0xcf,0x00,0x04,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20, 0x02,0x20,0x02,0x20,0x02,0x49,0x01,0x00,0x00,0x00,0x03,0x21,0x01,0x00,0x00,0x02, 0x00,0x20,0x01,0x2a,0x01,0x01,0x01,0x00,0x07,0x00,0x03,0x80,0x01,0x00,0x00,0x25, 0x02,0x00,0x02,0x02,0x00,0x28,0x01,0x07,0x01,0x04,0x17,0x1d,0x2b,0x00,0x07,0x00, 0x02,0x00,0x07,0x01,0x46,0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x04,0x46,0x20,0x02, 0x1c,0x30,0x00,0x07,0x00,0x04,0x20,0x02,0x01,0x02,0x01,0x00,0x07,0x00,0x03,0x81, 0x01,0x00,0x00,0x25,0x07,0x01,0x02,0x02,0x00,0x28,0x02,0x07,0x02,0x04,0x17,0x1d, 0x32,0x00,0x07,0x00,0x07,0x01,0x07,0x02,0x07,0x01,0x0a,0x46,0x02,0xd6,0x00,0x07, 0x00,0x07,0x02,0x02,0x01,0x09,0x02,0xd7,0x00,0x20,0x02,0x1c,0x4b,0x00,0x07,0x01, 0x07,0x00,0x44,0x18,0x1d,0x4a,0x00,0x07,0x00,0x07,0x01,0x04,0x46,0x02,0xd6,0x00, 0x04,0x20,0x02,0x1c,0x4b,0x00,0x04,0x01,0x02,0x01,0x00,0x07,0x00,0x03,0x82,0x01, 0x00,0x00,0x25,0x03,0x83,0x01,0x00,0x00,0x25,0x02,0x0c,0x00,0x28,0x02,0x07,0x02, 0x07,0x01,0x02,0xd7,0x00,0x01,0x01,0x03,0x00,0x03,0x84,0x01,0x00,0x00,0x25,0x60, 0x05,0x07,0x00,0x28,0x01,0x04,0x07,0x01,0x04,0x17,0x1d,0x40,0x00,0x1c,0x1f,0x00, 0x07,0x01,0x2e,0x28,0x01,0x1c,0x0d,0x00,0x05,0x07,0x01,0x2d,0x06,0x22,0x00,0x28, 0x02,0x06,0x22,0x01,0x28,0x03,0x05,0x07,0x02,0x26,0x05,0x03,0x85,0x01,0x00,0x00, 0x25,0x26,0x05,0x07,0x03,0x60,0x1c,0x17,0x00,0x05,0x07,0x00,0x01,0x02,0x01,0x00, 0x03,0x86,0x01,0x00,0x00,0x25,0x60,0x05,0x07,0x01,0x02,0x84,0x00,0x60,0x02,0x00, 0x02,0xd8,0x00,0x28,0x02,0x03,0x22,0x01,0x00,0x00,0x07,0x02,0x03,0x87,0x01,0x00, 0x00,0x25,0x7d,0x2a,0x05,0x03,0x23,0x01,0x00,0x00,0x07,0x02,0x03,0x88,0x01,0x00, 0x00,0x25,0x7d,0x2a,0x05,0x03,0x22,0x01,0x00,0x00,0x25,0x04,0x17,0x06,0x1d,0x4a, 0x00,0x05,0x03,0x23,0x01,0x00,0x00,0x25,0x04,0x17,0x1d,0x5a,0x00,0x03,0x21,0x01, 0x00,0x00,0x02,0x02,0x20,0x01,0x2a,0x1c,0x5b,0x00,0x04,0x05,0x02,0x00,0x01,0x00, 0x00,0x00,0x69,0x03,0x0c,0x01,0x00,0x00,0x25,0x16,0x06,0x1d,0x13,0x00,0x05,0x02, 0x94,0x00,0x02,0x00,0x16,0x1d,0x35,0x00,0x03,0x21,0x01,0x00,0x00,0x02,0x01,0x03, 0x89,0x01,0x00,0x00,0x25,0x02,0xd0,0x00,0x60,0x04,0x02,0xda,0x24,0xaa,0x02,0x7e, 0x00,0x20,0x02,0x2a,0x1c,0x36,0x00,0x04,0x05,0x02,0x00,0x01,0x01,0x00,0x00,0x07, 0x00,0x02,0x82,0x00,0x03,0x10,0x27,0x00,0x00,0x19,0x1d,0x29,0x00,0x03,0x8a,0x01, 0x00,0x00,0x25,0x60,0x05,0x07,0x00,0x02,0x7f,0x00,0x05,0x03,0x21,0x01,0x00,0x00, 0x02,0x00,0x20,0x01,0x2a,0x1c,0x2a,0x00,0x04,0x05,0x02,0x00,0x01,0x02,0x00,0x00, 0x07,0x00,0x07,0x01,0x45,0x02,0x10,0x11,0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x45, 0x02,0x08,0x11,0x09,0x07,0x00,0x07,0x01,0x02,0x02,0x09,0x45,0x09,0x01,0x03,0x02, 0x00,0x07,0x01,0x07,0x00,0x44,0x18,0x1d,0x6d,0x00,0x07,0x00,0x07,0x01,0x45,0x28, 0x03,0x07,0x03,0x02,0xff,0x16,0x1d,0x1d,0x00,0x07,0x02,0x1c,0x6a,0x00,0x07,0x03, 0x02,0x00,0x1b,0x06,0x1d,0x2c,0x00,0x05,0x07,0x03,0x02,0x0a,0x1a,0x1d,0x69,0x00, 0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x02,0xdd,0x00,0x28,0x04,0x07,0x04,0x02,0x00, 0x1b,0x1d,0x65,0x00,0x07,0x00,0x07,0x01,0x02,0x04,0x09,0x07,0x04,0x09,0x07,0x03, 0x07,0x00,0x07,0x01,0x02,0x04,0x09,0x07,0x04,0x46,0x20,0x02,0x07,0x02,0x20,0x02, 0x02,0xde,0x00,0x1c,0x66,0x00,0x04,0x1c,0x6a,0x00,0x04,0x1c,0x6e,0x00,0x04,0x01, 0x01,0x00,0x00,0x07,0x00,0x02,0x00,0x45,0x02,0x7f,0x16,0x1d,0x16,0x00,0x07,0x00, 0x02,0x01,0x04,0x02,0xde,0x00,0x1c,0x17,0x00,0x04,0x01,0x02,0x00,0x00,0x07,0x00, 0x04,0x17,0x06,0x1d,0x0f,0x00,0x05,0x07,0x01,0x07,0x00,0x44,0x18,0x1d,0x30,0x00, 0x07,0x00,0x07,0x01,0x45,0x07,0x00,0x07,0x01,0x02,0x01,0x09,0x45,0x20,0x02,0x07, 0x00,0x07,0x01,0x02,0x02,0x09,0x02,0xe0,0x00,0x20,0x02,0x1c,0x31,0x00,0x04,0x01, 0x01,0x00,0x00,0x02,0x00,0x07,0x00,0x03,0x30,0x01,0x00,0x00,0x25,0x02,0x00,0x02, 0x02,0x00,0x16,0x1d,0x28,0x00,0x03,0x23,0x01,0x00,0x00,0x25,0x07,0x00,0x03,0x30, 0x01,0x00,0x00,0x25,0x44,0x04,0x46,0x47,0x1c,0x2a,0x00,0x07,0x00,0x01,0x01,0x02, 0x00,0x07,0x00,0x04,0x17,0x1d,0x71,0x00,0x07,0x00,0x2d,0x06,0x22,0x00,0x28,0x01, 0x06,0x22,0x01,0x28,0x02,0x05,0x07,0x01,0x03,0x8b,0x01,0x00,0x00,0x25,0x89,0x15, 0x06,0x15,0x1d,0x2f,0x00,0x05,0x07,0x01,0x03,0x8c,0x01,0x00,0x00,0x25,0x89,0x15, 0x1d,0x46,0x00,0x07,0x02,0x03,0xe0,0x93,0x04,0x00,0x20,0x02,0x07,0x00,0x2e,0x02, 0xe2,0x00,0x20,0x02,0x1c,0x6e,0x00,0x07,0x01,0x03,0x8d,0x01,0x00,0x00,0x25,0x89, 0x15,0x1d,0x68,0x00,0x07,0x02,0x03,0x31,0x01,0x00,0x00,0x25,0x20,0x02,0x07,0x00, 0x2e,0x02,0xe2,0x00,0x20,0x02,0x1c,0x6e,0x00,0x07,0x00,0x2e,0x02,0xe2,0x00,0x1c, 0x72,0x00,0x04,0x01,0x01,0x01,0x00,0x03,0x8e,0x01,0x00,0x00,0x25,0x60,0x05,0x07, 0x00,0x03,0x8f,0x01,0x00,0x00,0x25,0x7d,0x75,0x28,0x01,0x07,0x01,0x79,0x60,0x05, 0x07,0x01,0x03,0x32,0x01,0x00,0x00,0x25,0x16,0x1d,0x85,0x00,0x03,0x25,0x01,0x00, 0x00,0x25,0x03,0x32,0x01,0x00,0x00,0x25,0x16,0x1d,0x60,0x00,0x02,0x00,0x03,0x29, 0x01,0x00,0x00,0x25,0x02,0x00,0x02,0xad,0x00,0x05,0x02,0x01,0x03,0x2a,0x01,0x00, 0x00,0x25,0x02,0x00,0x02,0xad,0x00,0x05,0x02,0x0b,0x3d,0x03,0x26,0x01,0x00,0x00, 0x25,0x09,0x20,0x02,0x1c,0x82,0x00,0x03,0x25,0x01,0x00,0x00,0x07,0x01,0x2a,0x05, 0x03,0x90,0x01,0x00,0x00,0x25,0x60,0x05,0x03,0xff,0x00,0xff,0x00,0x02,0x18,0x00, 0x05,0x02,0x9f,0x00,0x05,0x02,0x0a,0x20,0x01,0x1c,0xd7,0x00,0x07,0x01,0x03,0x33, 0x01,0x00,0x00,0x25,0x16,0x1d,0xb6,0x00,0x03,0x25,0x01,0x00,0x00,0x07,0x01,0x2a, 0x05,0x03,0x91,0x01,0x00,0x00,0x25,0x60,0x05,0x03,0xff,0x00,0xff,0x00,0x02,0x18, 0x00,0x05,0x02,0x9f,0x00,0x05,0x02,0x0e,0x20,0x01,0x1c,0xd7,0x00,0x03,0x2b,0x01, 0x00,0x00,0x07,0x00,0x2a,0x05,0x03,0x2d,0x01,0x00,0x00,0x07,0x00,0x02,0xe2,0x00, 0x2a,0x05,0x03,0x2e,0x01,0x00,0x00,0x04,0x2a,0x05,0x02,0x04,0x20,0x01,0x01,0x03, 0x01,0x00,0x24,0xc1,0x1d,0x0f,0x00,0x07,0x00,0x02,0x7f,0x00,0x05,0x04,0x1c,0x9c, 0x00,0x07,0x01,0x04,0x17,0x1d,0x56,0x00,0x03,0x2f,0x01,0x00,0x00,0x07,0x01,0x03, 0x2f,0x01,0x00,0x00,0x25,0x20,0x02,0x2a,0x05,0x07,0x02,0x04,0x17,0x06,0x1d,0x3c, 0x00,0x05,0x03,0x2f,0x01,0x00,0x00,0x25,0x02,0x06,0x00,0x07,0x02,0x19,0x1d,0x4f, 0x00,0x07,0x00,0x02,0x7f,0x00,0x05,0x07,0x00,0x04,0x04,0x02,0xe4,0x00,0x1c,0x50, 0x00,0x04,0x05,0x02,0x00,0x1c,0x9c,0x00,0x03,0x2d,0x01,0x00,0x00,0x25,0x2d,0x06, 0x22,0x00,0x28,0x03,0x05,0x03,0x2e,0x01,0x00,0x00,0x07,0x03,0x03,0x2f,0x01,0x00, 0x00,0x25,0x04,0x02,0x0d,0x00,0x2e,0x20,0x02,0x03,0x2e,0x01,0x00,0x00,0x25,0x20, 0x02,0x2a,0x05,0x03,0x2d,0x01,0x00,0x00,0x03,0x2d,0x01,0x00,0x00,0x25,0x2e,0x2a, 0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x04,0x20,0x01,0x2a,0x05,0x02,0x00,0x01,0x00, 0x00,0x00,0x03,0x00,0x00,0xff,0x00,0x02,0x18,0x00,0x05,0x02,0x9f,0x00,0x05,0x03, 0x3f,0x01,0x00,0x00,0x02,0x08,0x02,0xff,0x36,0x2a,0x05,0x03,0x21,0x01,0x00,0x00, 0x02,0x06,0x20,0x01,0x2a,0x05,0x03,0x25,0x01,0x00,0x00,0x03,0x2b,0x01,0x00,0x00, 0x25,0x03,0x92,0x01,0x00,0x00,0x25,0x7d,0x75,0x2a,0x05,0x02,0x00,0x01,0x00,0x02, 0x00,0x03,0x2d,0x01,0x00,0x00,0x25,0x2d,0x06,0x22,0x00,0x28,0x00,0x06,0x22,0x01, 0x28,0x01,0x05,0x07,0x00,0x04,0x16,0x1d,0x2a,0x00,0x03,0x93,0x01,0x00,0x00,0x25, 0x60,0x05,0x02,0xe5,0x00,0x05,0x02,0x00,0x1c,0x78,0x00,0x04,0x03,0x2e,0x01,0x00, 0x00,0x25,0x07,0x00,0x7d,0x17,0x1d,0x4c,0x00,0x03,0x2d,0x01,0x00,0x00,0x03,0x2d, 0x01,0x00,0x00,0x25,0x2e,0x2a,0x05,0x02,0xe6,0x00,0x1c,0x78,0x00,0x03,0x2f,0x01, 0x00,0x00,0x04,0x2a,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x05,0x03,0x94,0x01,0x00, 0x00,0x25,0x07,0x00,0x02,0xe1,0x00,0x60,0x04,0x02,0xe4,0x07,0x01,0x37,0x24,0xab, 0x02,0x7e,0x00,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x02, 0x82,0x00,0x03,0x10,0x27,0x00,0x00,0x19,0x1d,0x29,0x00,0x03,0x95,0x01,0x00,0x00, 0x25,0x60,0x05,0x07,0x00,0x02,0x7f,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x04, 0x20,0x01,0x2a,0x1c,0x2a,0x00,0x04,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0xa6, 0x00,0x1d,0x23,0x00,0x02,0x00,0x02,0x18,0x00,0x05,0x03,0x2c,0x01,0x00,0x00,0x3d, 0x2a,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x09,0x02,0x00,0x20,0x02,0x2a,0x1c,0x24, 0x00,0x04,0x05,0x02,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x04,0x17,0x1d,0x12,0x00, 0x03,0x24,0x01,0x00,0x00,0x07,0x00,0x2a,0x1c,0x13,0x00,0x04,0x05,0x03,0x21,0x01, 0x00,0x00,0x02,0x0c,0x03,0x96,0x01,0x00,0x00,0x25,0x02,0xd2,0x00,0x60,0x04,0x02, 0xc8,0x24,0xaa,0x02,0x7e,0x00,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x01,0x02,0x00, 0x02,0x01,0x28,0x01,0x04,0x07,0x01,0x02,0x04,0x18,0x1d,0x2f,0x00,0x05,0x35,0x07, 0x01,0x02,0x32,0x0b,0x0a,0x02,0xc7,0x00,0x28,0x02,0x07,0x01,0x07,0x02,0x03,0x01, 0x01,0x00,0x00,0x0b,0x4a,0x07,0x01,0x02,0x01,0x09,0x28,0x01,0x1c,0x05,0x00,0x05, 0x07,0x00,0x02,0x82,0x00,0x03,0x10,0x27,0x00,0x00,0x19,0x1d,0x53,0x00,0x03,0x97, 0x01,0x00,0x00,0x25,0x60,0x05,0x07,0x00,0x02,0x7f,0x00,0x05,0x04,0x02,0xe9,0x00, 0x1c,0x54,0x00,0x04,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0x02,0x02,0xe9,0x00, 0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x03,0x9b,0x01,0x00,0x00,0x25,0x04,0x17,0x01, 0x00,0x00,0x00,0x02,0x94,0x00,0x15,0x1d,0x2d,0x00,0x02,0x00,0x03,0x00,0x00,0xff, 0x00,0x4a,0x05,0x02,0x91,0x00,0x05,0x02,0x8b,0x00,0x05,0x03,0x98,0x01,0x00,0x00, 0x35,0x2a,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x0d,0x20,0x01,0x2a,0x1c,0x2e,0x00, 0x04,0x01,0x01,0x00,0x00,0x02,0x00,0x02,0x18,0x00,0x05,0x02,0x93,0x00,0x05,0x02, 0x00,0x02,0x00,0x4b,0x05,0x02,0x01,0x02,0x00,0x4b,0x05,0x02,0x40,0x02,0x90,0x00, 0x05,0x03,0x62,0x01,0x00,0x00,0x25,0x04,0x20,0x02,0x02,0x64,0x02,0x97,0x00,0x05, 0x03,0x99,0x01,0x00,0x00,0x07,0x00,0x2a,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x0f, 0x20,0x01,0x2a,0x05,0x02,0x00,0x01,0x02,0x00,0x00,0x03,0x9a,0x01,0x00,0x00,0x04, 0x2a,0x05,0x03,0x9b,0x01,0x00,0x00,0x04,0x2a,0x05,0x07,0x01,0x60,0x05,0x02,0x00, 0x02,0x18,0x00,0x05,0x03,0x9d,0x01,0x00,0x00,0x25,0x04,0x17,0x1d,0x3c,0x00,0x03, 0x9d,0x01,0x00,0x00,0x04,0x2a,0x05,0x03,0x61,0x01,0x00,0x00,0x25,0x04,0x20,0x02, 0x02,0x98,0x00,0x1c,0x3d,0x00,0x04,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x0b,0x3d, 0x03,0x27,0x01,0x00,0x00,0x25,0x09,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x00,0x00, 0x00,0x02,0xec,0x00,0x1d,0xc7,0x00,0x03,0x9d,0x01,0x00,0x00,0x25,0x04,0x17,0x06, 0x1d,0x1e,0x00,0x05,0x03,0x9d,0x01,0x00,0x00,0x25,0x35,0x0a,0x02,0x00,0x18,0x1d, 0x38,0x00,0x03,0x9d,0x01,0x00,0x00,0x04,0x2a,0x05,0x03,0x61,0x01,0x00,0x00,0x25, 0x04,0x20,0x02,0x02,0x98,0x00,0x1c,0x39,0x00,0x04,0x05,0x03,0x9b,0x01,0x00,0x00, 0x25,0x02,0x82,0x00,0x03,0x10,0x27,0x00,0x00,0x19,0x1d,0xc3,0x00,0x03,0x9e,0x01, 0x00,0x00,0x25,0x60,0x05,0x03,0x9b,0x01,0x00,0x00,0x25,0x02,0x7f,0x00,0x05,0x03, 0x9b,0x01,0x00,0x00,0x04,0x2a,0x05,0x03,0x9c,0x01,0x00,0x00,0x25,0x02,0x00,0x19, 0x1d,0xaa,0x00,0x03,0x9c,0x01,0x00,0x00,0x03,0x9c,0x01,0x00,0x00,0x25,0x02,0x01, 0x0a,0x2a,0x05,0x03,0x9b,0x01,0x00,0x00,0x03,0x9f,0x01,0x00,0x00,0x25,0x03,0x99, 0x01,0x00,0x00,0x25,0x02,0xd3,0x00,0x60,0x03,0x9a,0x01,0x00,0x00,0x25,0x02,0xef, 0x24,0xaa,0x02,0x7e,0x00,0x2a,0x05,0x04,0x1c,0xc0,0x00,0x03,0x9a,0x01,0x00,0x00, 0x04,0x2a,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x0b,0x3d,0x02,0x01,0x09,0x20,0x02, 0x2a,0x1c,0xc4,0x00,0x04,0x1c,0xc8,0x00,0x04,0x01,0x00,0x01,0x00,0x4d,0x15,0x06, 0x15,0x1d,0x16,0x00,0x05,0x35,0x03,0x98,0x01,0x00,0x00,0x25,0x0a,0x03,0x40,0x1f, 0x00,0x00,0x19,0x1d,0x82,0x00,0x02,0x8c,0x00,0x05,0x02,0x00,0x02,0x18,0x00,0x05, 0x02,0x8d,0x00,0x28,0x00,0x03,0x9a,0x01,0x00,0x00,0x07,0x00,0x49,0x2a,0x05,0x03, 0x9c,0x01,0x00,0x00,0x02,0x03,0x2a,0x05,0x03,0x9d,0x01,0x00,0x00,0x35,0x03,0x90, 0x01,0x00,0x00,0x09,0x2a,0x05,0x03,0x9b,0x01,0x00,0x00,0x03,0xa0,0x01,0x00,0x00, 0x25,0x03,0x99,0x01,0x00,0x00,0x25,0x02,0xd3,0x00,0x60,0x03,0x9a,0x01,0x00,0x00, 0x25,0x02,0xef,0x24,0xaa,0x02,0x7e,0x00,0x2a,0x05,0x03,0x21,0x01,0x00,0x00,0x02, 0x0b,0x3d,0x03,0x27,0x01,0x00,0x00,0x25,0x09,0x20,0x02,0x2a,0x1c,0x83,0x00,0x04, 0x01,0x02,0x00,0x00,0x03,0xa1,0x01,0x00,0x00,0x07,0x00,0x49,0x2a,0x05,0x03,0xa2, 0x01,0x00,0x00,0x02,0x04,0x02,0x01,0x09,0x2a,0x05,0x03,0xa3,0x01,0x00,0x00,0x02, 0x00,0x2a,0x05,0x03,0xa4,0x01,0x00,0x00,0x35,0x2a,0x05,0x03,0x21,0x01,0x00,0x00, 0x02,0x07,0x07,0x01,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x03,0xa7, 0x01,0x00,0x00,0x25,0x26,0x05,0x03,0xa5,0x01,0x00,0x00,0x3b,0x02,0xff,0x0e,0x5f, 0x02,0x06,0x0b,0x02,0x08,0x12,0x2a,0x05,0x03,0xa6,0x01,0x00,0x00,0x3b,0x02,0x01, 0x0e,0x3b,0x02,0x01,0x0e,0x20,0x02,0x2a,0x05,0x02,0xaa,0x00,0x05,0x03,0x46,0x01, 0x00,0x00,0x25,0x04,0x20,0x02,0x04,0x02,0xf2,0x00,0x05,0x02,0x00,0x01,0x01,0x00, 0x00,0x03,0xa4,0x01,0x00,0x00,0x04,0x2a,0x05,0x07,0x00,0x04,0x16,0x1d,0x28,0x00, 0x02,0xa9,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x0b,0x3d,0x03,0x26,0x01,0x00, 0x00,0x25,0x09,0x20,0x02,0x2a,0x1c,0x37,0x00,0x03,0x21,0x01,0x00,0x00,0x02,0x09, 0x07,0x00,0x02,0x01,0x09,0x20,0x02,0x2a,0x05,0x02,0x00,0x01,0x01,0x03,0x00,0x03, 0xa8,0x01,0x00,0x00,0x25,0x26,0x05,0x07,0x00,0x02,0x07,0x0e,0x5f,0x05,0x03,0x40, 0x01,0x00,0x00,0x25,0x07,0x00,0x02,0x07,0x0e,0x23,0x28,0x01,0x02,0x00,0x28,0x02, 0x04,0x07,0x02,0x02,0x08,0x18,0x1d,0x62,0x00,0x05,0x07,0x02,0x02,0x03,0x0b,0x28, 0x03,0x03,0x3f,0x01,0x00,0x00,0x25,0x07,0x02,0x07,0x01,0x07,0x03,0x23,0x02,0x10, 0x11,0x07,0x01,0x07,0x03,0x02,0x01,0x09,0x23,0x02,0x08,0x11,0x09,0x07,0x01,0x07, 0x03,0x02,0x02,0x09,0x23,0x09,0x30,0x07,0x02,0x02,0x01,0x09,0x28,0x02,0x1c,0x22, 0x00,0x01,0x02,0x00,0x00,0x03,0xa9,0x01,0x00,0x00,0x25,0x26,0x05,0x07,0x00,0x27, 0x05,0x03,0xaa,0x01,0x00,0x00,0x25,0x26,0x05,0x07,0x01,0x79,0x60,0x05,0x03,0x3f, 0x01,0x00,0x00,0x25,0x07,0x00,0x07,0x01,0x30,0x01,0x01,0x04,0x00,0x03,0xa4,0x01, 0x00,0x00,0x25,0x35,0x0a,0x02,0x00,0x1a,0x1d,0xdf,0x02,0x03,0xa2,0x01,0x00,0x00, 0x25,0x03,0xa1,0x01,0x00,0x00,0x25,0x44,0x1b,0x1d,0x27,0x00,0x07,0x00,0x02,0xf4, 0x00,0x1c,0xa2,0x02,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25, 0x45,0x28,0x01,0x03,0xa2,0x01,0x00,0x00,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x02, 0x09,0x07,0x01,0x03,0x37,0x01,0x00,0x00,0x25,0x16,0x1d,0x6f,0x00,0x03,0xa3,0x01, 0x00,0x00,0x02,0x0a,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25, 0x02,0x01,0x09,0x45,0x0b,0x2a,0x05,0x02,0x01,0x1c,0xa0,0x02,0x07,0x01,0x03,0x39, 0x01,0x00,0x00,0x25,0x16,0x1d,0xb4,0x00,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2, 0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x45,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2, 0x01,0x00,0x00,0x25,0x02,0x02,0x09,0x45,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2, 0x01,0x00,0x00,0x25,0x02,0x03,0x09,0x45,0x02,0xad,0x00,0x05,0x02,0x03,0x1c,0xa0, 0x02,0x07,0x01,0x03,0x38,0x01,0x00,0x00,0x25,0x16,0x1d,0x12,0x01,0x02,0x04,0x03, 0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x45,0x0a, 0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x02,0x09,0x45, 0x02,0x10,0x11,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02, 0x03,0x09,0x45,0x02,0x08,0x11,0x09,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01, 0x00,0x00,0x25,0x02,0x04,0x09,0x45,0x09,0x4a,0x05,0x02,0x06,0x1c,0xa0,0x02,0x07, 0x01,0x03,0x3a,0x01,0x00,0x00,0x25,0x16,0x1d,0x52,0x01,0x02,0x04,0x03,0xa1,0x01, 0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x45,0x0a,0x03,0x3f, 0x01,0x00,0x00,0x25,0x02,0x07,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00, 0x00,0x25,0x02,0x02,0x09,0x45,0x0e,0x23,0x4a,0x05,0x02,0x02,0x1c,0xa0,0x02,0x07, 0x01,0x03,0x3b,0x01,0x00,0x00,0x25,0x16,0x1d,0x9a,0x01,0x03,0xab,0x01,0x00,0x00, 0x25,0x60,0x05,0x02,0xc9,0x00,0x28,0x02,0x07,0x02,0x48,0x28,0x03,0x07,0x03,0x02, 0x00,0x19,0x1d,0x93,0x01,0x07,0x02,0x3b,0x02,0xff,0x0e,0x07,0x03,0x0b,0x02,0x08, 0x12,0x5f,0x23,0x28,0x04,0x07,0x04,0x04,0x20,0x02,0x02,0x98,0x00,0x1c,0x94,0x01, 0x04,0x05,0x02,0x00,0x1c,0xa0,0x02,0x07,0x01,0x03,0x3c,0x01,0x00,0x00,0x25,0x16, 0x1d,0x00,0x02,0x03,0xac,0x01,0x00,0x00,0x25,0x60,0x05,0x03,0xa1,0x01,0x00,0x00, 0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x45,0x28,0x02,0x03,0xa1,0x01, 0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x02,0x09,0x45,0x28,0x03,0x07, 0x02,0x07,0x02,0x02,0xac,0x00,0x03,0xa6,0x01,0x00,0x00,0x25,0x07,0x02,0x23,0x1d, 0xeb,0x01,0x07,0x03,0x13,0x1c,0xed,0x01,0x07,0x03,0x09,0x03,0xa6,0x01,0x00,0x00, 0x25,0x07,0x02,0x23,0x02,0xad,0x00,0x05,0x02,0x02,0x1c,0xa0,0x02,0x07,0x01,0x03, 0x3d,0x01,0x00,0x00,0x25,0x16,0x1d,0x66,0x02,0x03,0xad,0x01,0x00,0x00,0x25,0x26, 0x05,0x03,0xa5,0x01,0x00,0x00,0x25,0x5f,0x05,0x03,0xa5,0x01,0x00,0x00,0x25,0x03, 0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x45,0x5f, 0x16,0x1d,0x3c,0x02,0x02,0x03,0x1c,0x63,0x02,0x02,0x03,0x03,0xa1,0x01,0x00,0x00, 0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x02,0x09,0x45,0x02,0x08,0x11,0x09,0x03, 0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00,0x00,0x25,0x02,0x03,0x09,0x45,0x09, 0x1c,0xa0,0x02,0x07,0x01,0x03,0x3e,0x01,0x00,0x00,0x25,0x16,0x1d,0x98,0x02,0x03, 0xae,0x01,0x00,0x00,0x25,0x60,0x05,0x02,0xa8,0x00,0x06,0x1d,0x88,0x02,0x05,0x02, 0x94,0x00,0x02,0x00,0x16,0x1d,0x90,0x02,0x02,0x00,0x1c,0x95,0x02,0x03,0xfe,0xff, 0xff,0xff,0x1c,0xa0,0x02,0x07,0x00,0x02,0xf4,0x00,0x05,0x02,0x00,0x09,0x2a,0x05, 0x03,0xa4,0x01,0x00,0x00,0x25,0x04,0x17,0x1d,0xdb,0x02,0x03,0xa4,0x01,0x00,0x00, 0x03,0xa4,0x01,0x00,0x00,0x25,0x03,0xa1,0x01,0x00,0x00,0x25,0x03,0xa2,0x01,0x00, 0x00,0x25,0x02,0x01,0x0a,0x45,0x03,0xa3,0x01,0x00,0x00,0x25,0x0b,0x09,0x2a,0x05, 0x07,0x00,0x02,0xf7,0x00,0x1c,0xdc,0x02,0x04,0x1c,0xe0,0x02,0x04,0x01,0x03,0x05, 0x00,0x03,0xaf,0x01,0x00,0x00,0x25,0x60,0x05,0x24,0xc1,0x15,0x1d,0xad,0x00,0x04, 0x28,0x03,0x07,0x01,0x02,0x84,0x00,0x02,0xdf,0x00,0x28,0x04,0x07,0x04,0x28,0x05, 0x04,0x07,0x05,0x04,0x17,0x1d,0x6e,0x00,0x1c,0x32,0x00,0x07,0x05,0x2e,0x28,0x05, 0x1c,0x20,0x00,0x05,0x07,0x05,0x2d,0x06,0x22,0x00,0x28,0x06,0x06,0x22,0x01,0x28, 0x07,0x05,0x07,0x06,0x02,0x0a,0x16,0x1d,0x67,0x00,0x07,0x07,0x02,0x01,0x04,0x02, 0x47,0x02,0x2f,0x91,0x05,0x02,0x03,0x07,0x07,0x02,0x01,0x02,0xd8,0x00,0x02,0xd9, 0x00,0x2f,0x05,0x02,0x00,0x1c,0x68,0x00,0x04,0x05,0x02,0x00,0x1c,0x2a,0x00,0x05, 0x07,0x03,0x04,0x17,0x1d,0xa9,0x00,0x07,0x03,0x03,0xb0,0x01,0x00,0x00,0x25,0x7d, 0x75,0x28,0x04,0x07,0x04,0x03,0x25,0x01,0x00,0x00,0x25,0x17,0x06,0x1d,0x99,0x00, 0x05,0x03,0x25,0x01,0x00,0x00,0x25,0x07,0x02,0x16,0x1d,0xa5,0x00,0x02,0x93,0x00, 0x05,0x02,0x00,0x1c,0xa6,0x00,0x04,0x1c,0xaa,0x00,0x04,0x1c,0xae,0x00,0x04,0x05, 0x02,0x00,0x01,0x00,0x01,0x00,0x03,0xb1,0x01,0x00,0x00,0x25,0x04,0x16,0x06,0x15, 0x1d,0x2a,0x00,0x05,0x03,0xb2,0x01,0x00,0x00,0x25,0x03,0xb1,0x01,0x00,0x00,0x25, 0x44,0x1b,0x06,0x1d,0x2a,0x00,0x05,0x03,0xb4,0x01,0x00,0x00,0x25,0x02,0x01,0x18, 0x1d,0x97,0x00,0x03,0xb6,0x01,0x00,0x00,0x25,0x26,0x05,0x03,0xb1,0x01,0x00,0x00, 0x03,0x47,0x01,0x00,0x00,0x25,0x3b,0x02,0x03,0x0e,0x5f,0x02,0x07,0x00,0x2a,0x05, 0x03,0xb2,0x01,0x00,0x00,0x02,0x01,0x2a,0x05,0x03,0xb7,0x01,0x00,0x00,0x25,0x26, 0x05,0x03,0xb3,0x01,0x00,0x00,0x02,0xa0,0x3b,0x02,0xff,0x0e,0x02,0x5a,0x0b,0x02, 0x08,0x12,0x09,0x2a,0x5f,0x05,0x03,0xb8,0x01,0x00,0x00,0x25,0x26,0x05,0x03,0xb4, 0x01,0x00,0x00,0x02,0x03,0x3b,0x02,0xff,0x0e,0x02,0x12,0x0b,0x02,0x08,0x12,0x09, 0x2a,0x5f,0x05,0x03,0xb5,0x01,0x00,0x00,0x35,0x2a,0x1c,0x98,0x00,0x04,0x05,0x04, 0x03,0xb2,0x01,0x00,0x00,0x25,0x03,0xb1,0x01,0x00,0x00,0x25,0x44,0x18,0x06,0x1d, 0xb8,0x00,0x05,0x35,0x03,0xb5,0x01,0x00,0x00,0x25,0x0a,0x02,0x00,0x19,0x1d,0x49, 0x01,0x05,0x03,0xb1,0x01,0x00,0x00,0x25,0x03,0xb2,0x01,0x00,0x00,0x25,0x45,0x03, 0xb1,0x01,0x00,0x00,0x25,0x03,0xb2,0x01,0x00,0x00,0x25,0x02,0x01,0x09,0x45,0x02, 0x10,0x11,0x03,0xb1,0x01,0x00,0x00,0x25,0x03,0xb2,0x01,0x00,0x00,0x25,0x02,0x02, 0x09,0x45,0x02,0x08,0x11,0x09,0x03,0xb1,0x01,0x00,0x00,0x25,0x03,0xb2,0x01,0x00, 0x00,0x25,0x02,0x03,0x09,0x45,0x09,0x4a,0x05,0x03,0xb2,0x01,0x00,0x00,0x03,0xb2, 0x01,0x00,0x00,0x25,0x02,0x05,0x09,0x2a,0x05,0x03,0xb1,0x01,0x00,0x00,0x25,0x03, 0xb2,0x01,0x00,0x00,0x25,0x02,0x01,0x0a,0x45,0x28,0x00,0x07,0x00,0x04,0x17,0x1d, 0x45,0x01,0x03,0xb5,0x01,0x00,0x00,0x03,0xb5,0x01,0x00,0x00,0x25,0x07,0x00,0x03, 0xb3,0x01,0x00,0x00,0x25,0x0b,0x09,0x2a,0x1c,0x46,0x01,0x04,0x1c,0x9a,0x00,0x05, 0x03,0xb2,0x01,0x00,0x00,0x25,0x03,0xb1,0x01,0x00,0x00,0x25,0x44,0x1b,0x1d,0x87, 0x01,0x03,0xb2,0x01,0x00,0x00,0x02,0x01,0x2a,0x05,0x03,0xb9,0x01,0x00,0x00,0x25, 0x26,0x05,0x03,0xb4,0x01,0x00,0x00,0x03,0xb4,0x01,0x00,0x00,0x25,0x02,0x01,0x0a, 0x2a,0x5f,0x05,0x03,0xb5,0x01,0x00,0x00,0x35,0x2a,0x1c,0x88,0x01,0x04,0x05,0x02, 0x00,0x01,0x01,0x04,0x00,0x07,0x00,0x06,0x22,0x00,0x28,0x01,0x06,0x22,0x01,0x28, 0x02,0x06,0x22,0x02,0x28,0x03,0x05,0x02,0x94,0x00,0x02,0x00,0x16,0x1d,0x3b,0x00, 0x02,0x00,0x02,0x00,0x4b,0x05,0x02,0x01,0x02,0x00,0x4b,0x05,0x03,0x21,0x01,0x00, 0x00,0x02,0x09,0x07,0x01,0x02,0x01,0x09,0x20,0x02,0x2a,0x05,0x04,0x1c,0x19,0x01, 0x24,0xd7,0x1d,0x5a,0x00,0x02,0x00,0x35,0x03,0x00,0x01,0x00,0x00,0x0e,0x1d,0x54, 0x00,0x03,0xff,0x00,0xff,0x00,0x1c,0x56,0x00,0x02,0x00,0x4a,0x1c,0x5d,0x00,0x02, 0xf9,0x00,0x05,0x3d,0x03,0x2c,0x01,0x00,0x00,0x25,0x0a,0x03,0x34,0x01,0x00,0x00, 0x25,0x19,0x1d,0x81,0x00,0x02,0x00,0x02,0x00,0x4b,0x05,0x02,0x01,0x02,0x00,0x4b, 0x05,0x02,0x00,0x1c,0xe4,0x00,0x35,0x02,0x03,0x0b,0x02,0x08,0x12,0x02,0xc7,0x00, 0x02,0x06,0x12,0x28,0x04,0x02,0x00,0x07,0x04,0x02,0x03,0x16,0x1d,0x9f,0x00,0x02, 0x01,0x1c,0xb1,0x00,0x07,0x04,0x02,0x01,0x16,0x1d,0xaf,0x00,0x03,0xff,0xff,0xff, 0xff,0x1c,0xb1,0x00,0x02,0x00,0x4b,0x05,0x35,0x02,0x05,0x0b,0x02,0x08,0x12,0x02, 0xc7,0x00,0x02,0x06,0x12,0x28,0x04,0x02,0x01,0x07,0x04,0x02,0x03,0x16,0x1d,0xd1, 0x00,0x02,0x01,0x1c,0xe3,0x00,0x07,0x04,0x02,0x01,0x16,0x1d,0xe1,0x00,0x03,0xff, 0xff,0xff,0xff,0x1c,0xe3,0x00,0x02,0x00,0x4b,0x05,0x3d,0x07,0x03,0x0a,0x03,0x35, 0x01,0x00,0x00,0x25,0x19,0x1d,0x15,0x01,0x07,0x00,0x3d,0x2b,0x02,0x05,0x03,0xba, 0x01,0x00,0x00,0x25,0x02,0xd2,0x00,0x60,0x04,0x02,0xf8,0x03,0x25,0x01,0x00,0x00, 0x25,0x37,0x24,0xaa,0x02,0x7e,0x00,0x1c,0x16,0x01,0x04,0x05,0x02,0x00,0x01,0x01, 0x03,0x00,0x03,0x2b,0x01,0x00,0x00,0x25,0x07,0x00,0x02,0x07,0x00,0x06,0x22,0x00, 0x28,0x01,0x06,0x22,0x01,0x28,0x02,0x05,0x07,0x01,0x60,0x04,0x16,0x1d,0x27,0x00, 0x02,0xeb,0x00,0x05,0x02,0x00,0x1c,0x74,0x01,0x07,0x01,0x03,0xbb,0x01,0x00,0x00, 0x25,0x89,0x15,0x06,0x15,0x1d,0x41,0x00,0x05,0x07,0x01,0x03,0xbc,0x01,0x00,0x00, 0x25,0x89,0x15,0x1d,0x8d,0x00,0x03,0xbd,0x01,0x00,0x00,0x25,0x60,0x05,0x03,0x2e, 0x01,0x00,0x00,0x25,0x07,0x02,0x60,0x7d,0x28,0x03,0x07,0x03,0x04,0x16,0x1d,0x69, 0x00,0x03,0xbe,0x01,0x00,0x00,0x25,0x60,0x1c,0x6a,0x00,0x04,0x05,0x03,0x2e,0x01, 0x00,0x00,0x25,0x07,0x02,0x7d,0x02,0x98,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x02, 0x09,0x07,0x00,0x02,0x01,0x09,0x20,0x02,0x2a,0x05,0x02,0x00,0x1c,0x74,0x01,0x07, 0x01,0x03,0xbf,0x01,0x00,0x00,0x25,0x89,0x15,0x1d,0xcd,0x00,0x03,0xc0,0x01,0x00, 0x00,0x25,0x60,0x05,0x03,0xb1,0x01,0x00,0x00,0x04,0x2a,0x05,0x07,0x02,0x02,0xe1, 0x00,0x28,0x03,0x07,0x03,0x02,0x9a,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x08, 0x07,0x00,0x3d,0x3d,0x20,0x03,0x20,0x02,0x2a,0x05,0x02,0x00,0x1c,0x74,0x01,0x07, 0x01,0x03,0xc1,0x01,0x00,0x00,0x25,0x89,0x15,0x1d,0xfc,0x00,0x02,0x94,0x00,0x02, 0x00,0x16,0x1d,0xf5,0x00,0x03,0x21,0x01,0x00,0x00,0x02,0x09,0x07,0x00,0x02,0x01, 0x09,0x20,0x02,0x2a,0x1c,0xf6,0x00,0x04,0x05,0x02,0x00,0x1c,0x74,0x01,0x07,0x01, 0x03,0xc2,0x01,0x00,0x00,0x25,0x89,0x15,0x1d,0x1d,0x01,0x03,0x2e,0x01,0x00,0x00, 0x25,0x07,0x02,0x7d,0x07,0x00,0x02,0xf2,0x00,0x05,0x02,0x00,0x1c,0x74,0x01,0x07, 0x01,0x03,0xc3,0x01,0x00,0x00,0x25,0x89,0x15,0x1d,0x33,0x01,0x07,0x02,0x75,0x02, 0xf5,0x00,0x1c,0x34,0x01,0x04,0x05,0x07,0x01,0x03,0xc4,0x01,0x00,0x00,0x25,0x89, 0x15,0x1d,0x5a,0x01,0x07,0x02,0x75,0x28,0x03,0x07,0x03,0x02,0x18,0x12,0x07,0x03, 0x03,0xff,0xff,0xff,0x00,0x0e,0x02,0xf6,0x00,0x1c,0x5b,0x01,0x04,0x05,0x03,0x21, 0x01,0x00,0x00,0x02,0x09,0x07,0x00,0x02,0x01,0x09,0x20,0x02,0x2a,0x05,0x07,0x00, 0x02,0x01,0x09,0x02,0xfb,0x00,0x01,0x00,0x00,0x00,0x02,0xa6,0x00,0x1d,0x38,0x00, 0x02,0x00,0x02,0x18,0x00,0x05,0x02,0x00,0x02,0x08,0x02,0x00,0x02,0xad,0x00,0x05, 0x02,0x01,0x02,0x08,0x02,0x00,0x02,0xad,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x02, 0x0b,0x3d,0x03,0x26,0x01,0x00,0x00,0x25,0x09,0x20,0x02,0x2a,0x05,0x02,0x00,0x1c, 0x39,0x00,0x04,0x01,0x00,0x02,0x00,0x03,0xc6,0x01,0x00,0x00,0x25,0x26,0x05,0x03, 0x1e,0x01,0x00,0x00,0x25,0x02,0xb6,0x00,0x5f,0x28,0x00,0x07,0x00,0x1d,0x6b,0x00, 0x03,0xc5,0x01,0x00,0x00,0x25,0x04,0x17,0x1d,0x32,0x00,0x3d,0x03,0xc5,0x01,0x00, 0x00,0x25,0x0a,0x02,0x00,0x19,0x1c,0x34,0x00,0x02,0x00,0x28,0x01,0x07,0x01,0x06, 0x15,0x1d,0x46,0x00,0x05,0x03,0xc5,0x01,0x00,0x00,0x25,0x04,0x16,0x1d,0x64,0x00, 0x03,0xc5,0x01,0x00,0x00,0x3d,0x07,0x00,0x02,0x3c,0x0b,0x3b,0x02,0x7f,0x0e,0x02, 0x40,0x09,0x0b,0x02,0x07,0x12,0x09,0x2a,0x1c,0x65,0x00,0x04,0x05,0x07,0x01,0x1c, 0x75,0x00,0x03,0xc5,0x01,0x00,0x00,0x04,0x2a,0x05,0x02,0x00,0x01,0x00,0x00,0x00, 0x69,0x03,0x0c,0x01,0x00,0x00,0x25,0x16,0x1d,0x2a,0x00,0x03,0x21,0x01,0x00,0x00, 0x02,0x03,0x03,0xc9,0x01,0x00,0x00,0x25,0x02,0xd2,0x00,0x60,0x04,0x02,0xc8,0x24, 0xaa,0x02,0x7e,0x00,0x20,0x02,0x2a,0x1c,0x2b,0x00,0x04,0x05,0x02,0x00,0x01,0x01, 0x00,0x00,0x07,0x00,0x02,0x82,0x00,0x03,0x10,0x27,0x00,0x00,0x19,0x1d,0x31,0x00, 0x03,0xca,0x01,0x00,0x00,0x25,0x60,0x05,0x07,0x00,0x02,0x7f,0x00,0x05,0x03,0x21, 0x01,0x00,0x00,0x02,0x0b,0x3d,0x03,0x26,0x01,0x00,0x00,0x25,0x09,0x20,0x02,0x2a, 0x1c,0x32,0x00,0x04,0x05,0x02,0x00,0x01,0x01,0x00,0x00,0x07,0x00,0x3d,0x0a,0x02, 0x00,0x18,0x1d,0x17,0x00,0x03,0x21,0x01,0x00,0x00,0x02,0x02,0x20,0x01,0x2a,0x1c, 0x18,0x00,0x04,0x05,0x02,0x00,0x01,0x00,0x00,0x00,0x02,0xa6,0x00,0x1d,0x41,0x00, 0x02,0xa9,0x00,0x05,0x02,0x00,0x02,0x18,0x00,0x05,0x02,0x00,0x03,0x29,0x01,0x00, 0x00,0x25,0x02,0x00,0x02,0xad,0x00,0x05,0x02,0x01,0x03,0x2a,0x01,0x00,0x00,0x25, 0x02,0x00,0x02,0xad,0x00,0x05,0x03,0x21,0x01,0x00,0x00,0x02,0x0b,0x3d,0x03,0x26, 0x01,0x00,0x00,0x25,0x09,0x20,0x02,0x2a,0x1c,0x42,0x00,0x04,0x05,0x02,0x00,0x01, 0x00,0x03,0x00,0x02,0xa7,0x00,0x15,0x1d,0x5a,0x00,0x3d,0x24,0xb0,0x0a,0x03,0x36, 0x01,0x00,0x00,0x25,0x19,0x28,0x00,0x02,0xec,0x00,0x03,0x21,0x01,0x00,0x00,0x25, 0x34,0x02,0x05,0x16,0x1d,0x2c,0x00,0x22,0x01,0x05,0x02,0x02,0x1c,0x2f,0x00,0x05, 0x02,0x00,0x0f,0x28,0x01,0x35,0x02,0x04,0x07,0x01,0x0a,0x12,0x02,0xc7,0x00,0x28, 0x02,0x02,0x04,0x07,0x00,0x15,0x1d,0x51,0x00,0x07,0x02,0x03,0x01,0x00,0x01,0x00, 0x0b,0x1c,0x56,0x00,0x03,0xff,0x00,0xff,0x00,0x4a,0x1c,0x5b,0x00,0x04,0x05,0x02, 0x00,0x01,0x02,0x00,0x00,0x07,0x01,0x60,0x05,0x02,0x00,0x01,0x01,0x02,0x00,0x07, 0x00,0x28,0x01,0x04,0x07,0x01,0x04,0x17,0x1d,0x26,0x00,0x1c,0x17,0x00,0x07,0x01, 0x2e,0x28,0x01,0x1c,0x05,0x00,0x05,0x07,0x01,0x2d,0x28,0x02,0x07,0x02,0x02,0xcf, 0x00,0x60,0x1c,0x0f,0x00,0x05,0x07,0x00,0x01,0x00,0x01,0x00,0x65,0x28,0x00,0x07, 0x00,0x03,0xcb,0x01,0x00,0x00,0x25,0x89,0x1d,0x46,0x00,0x03,0xcb,0x01,0x00,0x00, 0x07,0x00,0x2a,0x05,0x07,0x00,0x04,0x17,0x1d,0x42,0x00,0x03,0x63,0x01,0x00,0x00, 0x25,0x02,0xca,0x00,0x05,0x03,0xcc,0x01,0x00,0x00,0x25,0x07,0x00,0x02,0xd4,0x00, 0x04,0x03,0x03,0x01,0x00,0x00,0x24,0xaa,0x02,0x7e,0x00,0x1c,0x43,0x00,0x04,0x1c, 0x47,0x00,0x04,0x05,0x02,0x00,0x01,0x00,0x01,0x00,0x02,0xcc,0x00,0x28,0x00,0x07, 0x00,0x04,0x17,0x1d,0x70,0x00,0x03,0xcd,0x01,0x00,0x00,0x25,0x60,0x05,0x02,0x93, 0x00,0x05,0x02,0xab,0x00,0x05,0x07,0x00,0x03,0x69,0x01,0x00,0x00,0x25,0x16,0x1d, 0x3a,0x00,0x03,0x42,0x01,0x00,0x00,0x25,0x02,0xca,0x00,0x05,0x02,0x05,0x02,0xe9, 0x00,0x1c,0x6d,0x00,0x07,0x00,0x03,0x6a,0x01,0x00,0x00,0x25,0x16,0x1d,0x58,0x00, 0x03,0x45,0x01,0x00,0x00,0x25,0x02,0xca,0x00,0x05,0x02,0x01,0x02,0xe9,0x00,0x1c, 0x6d,0x00,0x07,0x00,0x03,0x6b,0x01,0x00,0x00,0x25,0x16,0x1d,0x6c,0x00,0x02,0x05, 0x02,0xe9,0x00,0x1c,0x6d,0x00,0x04,0x1c,0x71,0x00,0x04,0x01,0x00,0x02,0x00,0x02, 0xcc,0x00,0x28,0x00,0x07,0x00,0x04,0x16,0x1d,0x12,0x00,0x02,0x9c,0x00,0x1c,0x14, 0x00,0x07,0x00,0x28,0x01,0x07,0x01,0x04,0x17,0x1d,0xa8,0x00,0x03,0xce,0x01,0x00, 0x00,0x25,0x60,0x05,0x02,0x93,0x00,0x05,0x02,0xab,0x00,0x05,0x07,0x01,0x03,0x69, 0x01,0x00,0x00,0x25,0x16,0x1d,0x41,0x00,0x02,0x03,0x02,0xe9,0x00,0x1c,0xa5,0x00, 0x07,0x01,0x03,0x6a,0x01,0x00,0x00,0x25,0x16,0x1d,0x5f,0x00,0x03,0x45,0x01,0x00, 0x00,0x25,0x02,0xca,0x00,0x05,0x02,0x01,0x02,0xe9,0x00,0x1c,0xa5,0x00,0x07,0x01, 0x03,0x6b,0x01,0x00,0x00,0x25,0x16,0x1d,0x73,0x00,0x02,0x00,0x02,0xee,0x00,0x1c, 0xa5,0x00,0x07,0x01,0x03,0x6c,0x01,0x00,0x00,0x25,0x16,0x1d,0x87,0x00,0x02,0x01, 0x02,0xee,0x00,0x1c,0xa5,0x00,0x07,0x01,0x03,0x00,0x80,0x00,0x00,0x0e,0x1d,0xa4, 0x00,0x03,0x41,0x01,0x00,0x00,0x25,0x02,0xca,0x00,0x05,0x07,0x01,0x02,0xe9,0x00, 0x1c,0xa5,0x00,0x04,0x1c,0xa9,0x00,0x04,0x05,0x03,0x05,0x01,0x00,0x00,0x00,0x01, 0x08,0x01,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x71,0x00,0x00,0x00,0x7f,0x00, 0x00,0x00,0x94,0x00,0x00,0x00,0xad,0x00,0x00,0x00,0xd8,0x00,0x00,0x00,0xf3,0x00, 0x00,0x00,0x1a,0x01,0x00,0x00,0x59,0x01,0x00,0x00,0x61,0x01,0x00,0x00,0x8c,0x01, 0x00,0x00,0x01,0x02,0x00,0x00,0x3e,0x02,0x00,0x00,0x5b,0x02,0x00,0x00,0x86,0x02, 0x00,0x00,0xd9,0x02,0x00,0x00,0xf8,0x02,0x00,0x00,0x32,0x03,0x00,0x00,0x4f,0x03, 0x00,0x00,0xa4,0x03,0x00,0x00,0xbb,0x03,0x00,0x00,0xed,0x03,0x00,0x00,0x2d,0x04, 0x00,0x00,0x39,0x04,0x00,0x00,0x5a,0x04,0x00,0x00,0x94,0x04,0x00,0x00,0xce,0x04, 0x00,0x00,0x07,0x05,0x00,0x00,0x2a,0x05,0x00,0x00,0xd9,0x05,0x00,0x00,0x69,0x06, 0x00,0x00,0x82,0x06,0x00,0x00,0x9e,0x06,0x00,0x00,0xa9,0x06,0x00,0x00,0xb4,0x06, 0x00,0x00,0xdc,0x06,0x00,0x00,0xeb,0x06,0x00,0x00,0xfa,0x06,0x00,0x00,0x1f,0x07, 0x00,0x00,0x31,0x07,0x00,0x00,0x3c,0x07,0x00,0x00,0x4a,0x07,0x00,0x00,0x55,0x07, 0x00,0x00,0x63,0x07,0x00,0x00,0x6e,0x07,0x00,0x00,0x7c,0x07,0x00,0x00,0x87,0x07, 0x00,0x00,0x92,0x07,0x00,0x00,0x9d,0x07,0x00,0x00,0xa8,0x07,0x00,0x00,0xb3,0x07, 0x00,0x00,0xbe,0x07,0x00,0x00,0xc9,0x07,0x00,0x00,0xd7,0x07,0x00,0x00,0xe2,0x07, 0x00,0x00,0xf0,0x07,0x00,0x00,0x0e,0x08,0x00,0x00,0x2d,0x08,0x00,0x00,0x46,0x08, 0x00,0x00,0x88,0x08,0x00,0x00,0xf2,0x08,0x00,0x00,0x65,0x09,0x00,0x00,0x99,0x09, 0x00,0x00,0xb3,0x09,0x00,0x00,0xfd,0x09,0x00,0x00,0x42,0x0a,0x00,0x00,0x50,0x0a, 0x00,0x00,0x60,0x0a,0x00,0x00,0xfb,0x0a,0x00,0x00,0x16,0x0b,0x00,0x00,0x48,0x0b, 0x00,0x00,0x80,0x0b,0x00,0x00,0x96,0x0b,0x00,0x00,0xa4,0x0b,0x00,0x00,0xac,0x0b, 0x00,0x00,0xe2,0x0b,0x00,0x00,0xc4,0x0c,0x00,0x00,0xe7,0x0c,0x00,0x00,0x05,0x0d, 0x00,0x00,0x17,0x0d,0x00,0x00,0x29,0x0d,0x00,0x00,0x6b,0x0d,0x00,0x00,0x85,0x0d, 0x00,0x00,0x98,0x0d,0x00,0x00,0xae,0x0d,0x00,0x00,0x2f,0x0e,0x00,0x00,0x50,0x0e, 0x00,0x00,0xd2,0x0e,0x00,0x00,0xf5,0x0e,0x00,0x00,0x05,0x12,0x00,0x00,0x68,0x12, 0x00,0x00,0x99,0x12,0x00,0x00,0xa4,0x12,0x00,0x00,0xaf,0x12,0x00,0x00,0x28,0x13, 0x00,0x00,0x33,0x13,0x00,0x00,0xfb,0x13,0x00,0x00,0x9f,0x14,0x00,0x00,0xda,0x15, 0x00,0x00,0x02,0x16,0x00,0x00,0x16,0x17,0x00,0x00,0xc7,0x17,0x00,0x00,0xec,0x17, 0x00,0x00,0xfa,0x17,0x00,0x00,0x5d,0x18,0x00,0x00,0x73,0x18,0x00,0x00,0x81,0x18, 0x00,0x00,0x96,0x18,0x00,0x00,0xb8,0x18,0x00,0x00,0xe9,0x18,0x00,0x00,0x66,0x19, 0x00,0x00,0xa6,0x19,0x00,0x00,0xdf,0x19,0x00,0x00,0xf9,0x19,0x00,0x00,0x67,0x1a, 0x00,0x00,0x72,0x1a,0x00,0x00,0xcc,0x1a,0x00,0x00,0xfd,0x1a,0x00,0x00,0x4b,0x1b, 0x00,0x00,0x63,0x1b,0x00,0x00,0x56,0x1c,0x00,0x00,0xc4,0x1c,0x00,0x00,0x09,0x1d, 0x00,0x00,0xa4,0x1d,0x00,0x00,0xd9,0x1d,0x00,0x00,0x2b,0x1e,0x00,0x00,0x0e,0x1f, 0x00,0x00,0x19,0x1f,0x00,0x00,0x26,0x1f,0x00,0x00,0x2e,0x1f,0x00,0x00,0x38,0x1f, 0x00,0x00,0x5e,0x1f,0x00,0x00,0x84,0x1f,0x00,0x00,0xbf,0x1f,0x00,0x00,0xcf,0x1f, 0x00,0x00,0x1c,0x20,0x00,0x00,0x50,0x20,0x00,0x00,0x6d,0x20,0x00,0x00,0xb6,0x20, 0x00,0x00,0xd5,0x20,0x00,0x00,0xe0,0x20,0x00,0x00,0xf6,0x20,0x00,0x00,0x0c,0x21, 0x00,0x00,0x50,0x21,0x00,0x00,0x68,0x21,0x00,0x00,0x79,0x21,0x00,0x00,0xb7,0x21, 0x00,0x00,0xe8,0x21,0x00,0x00,0x34,0x22,0x00,0x00,0xfa,0x22,0x00,0x00,0x12,0x23, 0x00,0x00,0x42,0x23,0x00,0x00,0x4d,0x23,0x00,0x00,0xfc,0x23,0x00,0x00,0x39,0x24, 0x00,0x00,0x84,0x24,0x00,0x00,0x93,0x24,0x00,0x00,0xbf,0x24,0x00,0x00,0xd2,0x24, 0x00,0x00,0x2c,0x25,0x00,0x00,0x5f,0x25,0x00,0x00,0x81,0x25,0x00,0x00,0x2a,0x27, 0x00,0x00,0x7e,0x28,0x00,0x00,0x37,0x29,0x00,0x00,0x5d,0x29,0x00,0x00,0x66,0x29, 0x00,0x00,0x6f,0x29,0x00,0x00,0x90,0x29,0x00,0x00,0xa5,0x29,0x00,0x00,0xba,0x29, 0x00,0x00,0xf3,0x29,0x00,0x00,0xfe,0x29,0x00,0x00,0x95,0x2a,0x00,0x00,0x6c,0x2f, 0x00,0x00,0x75,0x2f,0x00,0x00,0xa1,0x2f,0x00,0x00,0x20,0x30,0x00,0x00,0x52,0x30, 0x00,0x00,0xd4,0x31,0x00,0x00,0x02,0x32,0x00,0x00,0x34,0x32,0x00,0x00,0x3f,0x32, 0x00,0x00,0xab,0x32,0x00,0x00,0xbe,0x32,0x00,0x00,0xe8,0x32,0x00,0x00,0x62,0x33, 0x00,0x00,0x7c,0x33,0x00,0x00,0xd0,0x33,0x00,0x00,0xe9,0x33,0x00,0x00,0x8f,0x34, 0x00,0x00,0xaa,0x34,0x00,0x00,0xd0,0x34,0x00,0x00,0x31,0x35,0x00,0x00,0x5f,0x35, 0x00,0x00,0xc7,0x35,0x00,0x00,0x17,0x38,0x00,0x00,0x2d,0x38,0x00,0x00,0x43,0x38, 0x00,0x00,0xac,0x38,0x00,0x00,0x62,0x3a,0x00,0x00,0x14,0x3b,0x00,0x00,0x23,0x3b, 0x00,0x00,0x3a,0x3c,0x00,0x00,0x50,0x3c,0x00,0x00,0x12,0x3f,0x00,0x00,0x35,0x3f, 0x00,0x00,0x41,0x3f,0x00,0x00,0x67,0x3f,0x00,0x00,0x98,0x3f,0x00,0x00,0xf2,0x3f, 0x00,0x00,0x35,0x40,0x00,0x00,0x7a,0x40,0x00,0x00,0x88,0x40,0x00,0x00,0xbc,0x40, 0x00,0x00,0x0b,0x41,0x00,0x00,0x29,0x41,0x00,0x00,0x70,0x41,0x00,0x00,0xd2,0x41, 0x00,0x00,0x0f,0x42,0x00,0x00,0x40,0x42,0x00,0x00,0x61,0x42,0x00,0x00,0xd3,0x42, 0x00,0x00,0xee,0x42,0x00,0x00,0x23,0x43,0x00,0x00,0x51,0x43,0x00,0x00,0xc7,0x43, 0x00,0x00,0xa2,0x44,0x00,0x00,0x42,0x45,0x00,0x00,0x81,0x45,0x00,0x00,0xfd,0x45, 0x00,0x00,0x2e,0x46,0x00,0x00,0x59,0x46,0x00,0x00,0x90,0x46,0x00,0x00,0xeb,0x46, 0x00,0x00,0xf7,0x46,0x00,0x00,0x03,0x47,0x00,0x00,0x35,0x47,0x00,0x00,0x7a,0x47, 0x00,0x00,0xd1,0x47,0x00,0x00,0x9d,0x48,0x00,0x00,0x24,0x49,0x00,0x00,0x5e,0x49, 0x00,0x00,0xa1,0x49,0x00,0x00,0xdf,0x49,0x00,0x00,0x45,0x4a,0x00,0x00,0x6d,0x4a, 0x00,0x00,0x51,0x4d,0x00,0x00,0x06,0x4e,0x00,0x00,0x95,0x4f,0x00,0x00,0xb2,0x50, 0x00,0x00,0x2a,0x52,0x00,0x00,0x67,0x52,0x00,0x00,0xe0,0x52,0x00,0x00,0x12,0x53, 0x00,0x00,0x4b,0x53,0x00,0x00,0x6a,0x53,0x00,0x00,0xb3,0x53,0x00,0x00,0x15,0x54, 0x00,0x00,0x1f,0x54,0x00,0x00,0x4c,0x54,0x00,0x00,0x9a,0x54,0x00,0x00,0x0f,0x55, 0x00,0x00 };
idem2lyon/OpenJabNab
bootcode/compiler/mtl_linux/dumpbc.c
C
gpl-2.0
207,652
/*************************************************************************** qgslayoutitemshape.cpp ----------------------- begin : July 2017 copyright : (C) 2017 by Nyall Dawson email : nyall dot dawson at gmail dot com ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "qgslayoutitemshape.h" #include "qgslayout.h" #include "qgslayoututils.h" #include "qgssymbollayerutils.h" #include "qgslayoutmodel.h" #include "qgsstyleentityvisitor.h" #include <QPainter> QgsLayoutItemShape::QgsLayoutItemShape( QgsLayout *layout ) : QgsLayoutItem( layout ) , mCornerRadius( 0 ) { setBackgroundEnabled( false ); setFrameEnabled( false ); QgsStringMap properties; properties.insert( QStringLiteral( "color" ), QStringLiteral( "white" ) ); properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) ); properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "solid" ) ); properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "black" ) ); properties.insert( QStringLiteral( "width_border" ), QStringLiteral( "0.3" ) ); properties.insert( QStringLiteral( "joinstyle" ), QStringLiteral( "miter" ) ); mShapeStyleSymbol.reset( QgsFillSymbol::createSimple( properties ) ); refreshSymbol(); connect( this, &QgsLayoutItemShape::sizePositionChanged, this, [ = ] { updateBoundingRect(); update(); } ); } QgsLayoutItemShape *QgsLayoutItemShape::create( QgsLayout *layout ) { return new QgsLayoutItemShape( layout ); } int QgsLayoutItemShape::type() const { return QgsLayoutItemRegistry::LayoutShape; } QIcon QgsLayoutItemShape::icon() const { switch ( mShape ) { case Ellipse: return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemShapeEllipse.svg" ) ); case Rectangle: return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemShapeRectangle.svg" ) ); case Triangle: return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemShapeTriangle.svg" ) ); } return QIcon(); } QString QgsLayoutItemShape::displayName() const { if ( !id().isEmpty() ) { return id(); } switch ( mShape ) { case Ellipse: return tr( "<Ellipse>" ); case Rectangle: return tr( "<Rectangle>" ); case Triangle: return tr( "<Triangle>" ); } return tr( "<Shape>" ); } void QgsLayoutItemShape::setShapeType( QgsLayoutItemShape::Shape type ) { if ( type == mShape ) { return; } mShape = type; if ( mLayout && id().isEmpty() ) { //notify the model that the display name has changed mLayout->itemsModel()->updateItemDisplayName( this ); } } void QgsLayoutItemShape::refreshSymbol() { if ( layout() ) { QgsRenderContext rc = QgsLayoutUtils::createRenderContextForLayout( layout(), nullptr, layout()->renderContext().dpi() ); mMaxSymbolBleed = ( 25.4 / layout()->renderContext().dpi() ) * QgsSymbolLayerUtils::estimateMaxSymbolBleed( mShapeStyleSymbol.get(), rc ); } updateBoundingRect(); update(); emit frameChanged(); } void QgsLayoutItemShape::updateBoundingRect() { QRectF rectangle = rect(); rectangle.adjust( -mMaxSymbolBleed, -mMaxSymbolBleed, mMaxSymbolBleed, mMaxSymbolBleed ); if ( rectangle != mCurrentRectangle ) { prepareGeometryChange(); mCurrentRectangle = rectangle; } } void QgsLayoutItemShape::setSymbol( QgsFillSymbol *symbol ) { if ( !symbol ) return; mShapeStyleSymbol.reset( symbol->clone() ); refreshSymbol(); } QRectF QgsLayoutItemShape::boundingRect() const { return mCurrentRectangle; } double QgsLayoutItemShape::estimatedFrameBleed() const { return mMaxSymbolBleed; } bool QgsLayoutItemShape::accept( QgsStyleEntityVisitorInterface *visitor ) const { if ( mShapeStyleSymbol ) { QgsStyleSymbolEntity entity( mShapeStyleSymbol.get() ); if ( !visitor->visit( QgsStyleEntityVisitorInterface::StyleLeaf( &entity, uuid(), displayName() ) ) ) return false; } return true; } void QgsLayoutItemShape::draw( QgsLayoutItemRenderContext &context ) { QPainter *painter = context.renderContext().painter(); painter->setPen( Qt::NoPen ); painter->setBrush( Qt::NoBrush ); double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters ); QPolygonF shapePolygon; //shapes with curves must be enlarged before conversion to QPolygonF, or //the curves are approximated too much and appear jaggy QTransform t = QTransform::fromScale( 100, 100 ); //inverse transform used to scale created polygons back to expected size QTransform ti = t.inverted(); switch ( mShape ) { case Ellipse: { //create an ellipse QPainterPath ellipsePath; ellipsePath.addEllipse( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) ); QPolygonF ellipsePoly = ellipsePath.toFillPolygon( t ); shapePolygon = ti.map( ellipsePoly ); break; } case Rectangle: { //if corner radius set, then draw a rounded rectangle if ( mCornerRadius.length() > 0 ) { QPainterPath roundedRectPath; double radius = mLayout->convertToLayoutUnits( mCornerRadius ) * scale; roundedRectPath.addRoundedRect( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ), radius, radius ); QPolygonF roundedPoly = roundedRectPath.toFillPolygon( t ); shapePolygon = ti.map( roundedPoly ); } else { shapePolygon = QPolygonF( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) ); } break; } case Triangle: { shapePolygon << QPointF( 0, rect().height() * scale ); shapePolygon << QPointF( rect().width() * scale, rect().height() * scale ); shapePolygon << QPointF( rect().width() / 2.0 * scale, 0 ); shapePolygon << QPointF( 0, rect().height() * scale ); break; } } QList<QPolygonF> rings; //empty list symbol()->startRender( context.renderContext() ); symbol()->renderPolygon( shapePolygon, &rings, nullptr, context.renderContext() ); symbol()->stopRender( context.renderContext() ); } bool QgsLayoutItemShape::writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const { element.setAttribute( QStringLiteral( "shapeType" ), mShape ); element.setAttribute( QStringLiteral( "cornerRadiusMeasure" ), mCornerRadius.encodeMeasurement() ); QDomElement shapeStyleElem = QgsSymbolLayerUtils::saveSymbol( QString(), mShapeStyleSymbol.get(), document, context ); element.appendChild( shapeStyleElem ); return true; } bool QgsLayoutItemShape::readPropertiesFromElement( const QDomElement &element, const QDomDocument &, const QgsReadWriteContext &context ) { mShape = static_cast< Shape >( element.attribute( QStringLiteral( "shapeType" ), QStringLiteral( "0" ) ).toInt() ); if ( element.hasAttribute( QStringLiteral( "cornerRadiusMeasure" ) ) ) mCornerRadius = QgsLayoutMeasurement::decodeMeasurement( element.attribute( QStringLiteral( "cornerRadiusMeasure" ), QStringLiteral( "0" ) ) ); else mCornerRadius = QgsLayoutMeasurement( element.attribute( QStringLiteral( "cornerRadius" ), QStringLiteral( "0" ) ).toDouble() ); QDomElement shapeStyleSymbolElem = element.firstChildElement( QStringLiteral( "symbol" ) ); if ( !shapeStyleSymbolElem.isNull() ) { mShapeStyleSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( shapeStyleSymbolElem, context ) ); } return true; }
mj10777/QGIS
src/core/layout/qgslayoutitemshape.cpp
C++
gpl-2.0
8,247
<?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: nobody <nobody@localhost> | // +----------------------------------------------------------------------+ // // Plugin API provides support for < ? = $this->plugin(".....",.....); ? > // or {this.plugin(#xxxxx#,#xxxx#):h} // // BASICALLY THIS IS SAVANT'S PLUGIN PROVIDER. // @author Paul M. Jones <pmjones@ciaweb.net> class HTML_Template_Flexy_Plugin { /** * reference to main engine.. * * @var object HTML_Template_Flexy * @access public */ var $flexy; // reference to flexy. var $pluginCache = array(); // store of instanced plugins.. /** * Call a Plugin method. * * Look up in all the plugins to see if the method exists, if it does, call it. * * * @param array name of method, arguments. * * * @return string hopefully * @access public */ function call($args) { $method = $args[0]; // attempt to load the plugin on-the-fly $class = $this->_loadPlugins($method); if (is_a($class,'PEAR_Error')) { //echo $class->toString(); return $class->toString(); } // first argument is always the plugin name; shift the first // argument off the front of the array and reduce the number of // array elements. array_shift($args); return call_user_func_array(array(&$this->plugins[$class],$method), $args); } /** * Load the plugins, and lookup which one provides the required method * * * @param string Name * * @return string|PEAR_Error the class that provides it. * @access private */ function _loadPlugins($name) { // name can be: // ahref = maps to {class_prefix}_ahref::ahref $this->plugins = array(); if (empty($this->plugins)) { foreach ($this->flexy->options['plugins'] as $cname=>$file) { if (!is_int($cname)) { include_once $file; $this->plugins[$cname] = new $cname; $this->plugins[$cname]->flexy = &$this->flexy; continue; } $cname = $file; require_once 'HTML/Template/Flexy/Plugin/'. $cname . '.php'; $class = "HTML_Template_Flexy_Plugin_{$cname}"; $this->plugins[$class] = new $class; $this->plugins[$class]->flexy = &$this->flexy; } } foreach ($this->plugins as $class=>$o) { //echo "checking :". get_class($o). ":: $name\n"; if (method_exists($o,$name)) { return $class; } } return HTML_Template_Flexy::raiseError("could not find plugin with method: '$name'"); } }
sgreiner/revive-adserver
lib/pear/HTML/Template/Flexy/Plugin.php
PHP
gpl-2.0
3,890
#!/bin/sh # $1: package name, $2: yes or no, $3: 0 (if don't need to restart or stop). # $1: package name. # return value. 1: have package. 0: no package. _check_package(){ package_ready=`ipkg list_installed | grep "$1 "` package_ready2=`app_get_field.sh $1 Enabled 1` if [ -z "$package_ready" ] && [ -z "$package_ready2" ]; then return 0 else return 1 fi } nvram set apps_state_enable=0 # INITIALIZING if [ -z "$1" ] || [ -z "$2" ]; then echo "Usage: app_set_enabled.sh <Package name> <yes|no>" nvram set apps_state_error=1 exit 1 fi if [ "$2" != "yes" ] && [ "$2" != "no" ]; then echo "Usage: app_set_enabled.sh <Package name> <yes|no>" nvram set apps_state_error=1 exit 1 fi pkg_control_file= _check_package $1 if [ "$?" == "0" ]; then echo "The \"$1\" is not installed yet!" nvram set apps_state_error=8 exit 1 else pkg_control_file=/opt/lib/ipkg/info/$1.control fi nvram set apps_state_enable=1 # SETTING orig_value=`app_get_field.sh $1 Enabled 1` if [ "$orig_value" == "$2" ]; then echo "The field(Enabled) was set \"$2\" already." else Field_enabled=`grep "Enabled: " "$pkg_control_file"` if [ -z "$Field_enabled" ]; then sed -i '$a Enabled: '$2 $pkg_control_file else sed -i 's/Enabled: .*$/Enabled: '$2'/g' $pkg_control_file fi fi if [ "$3" != "0" ]; then if [ "$2" == "yes" ]; then echo "Restarting the package..." app_init_run.sh $1 restart else echo "Stop the package..." app_init_run.sh $1 stop fi else if [ "$2" == "yes" ]; then echo "Skip to restart the package!" else echo "Skip to stop the package!" fi fi nvram set apps_state_enable=2 # FINISHED
hajuuk/asuswrt
release/src/router/rom/apps_scripts/app_set_enabled.sh
Shell
gpl-2.0
1,623
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_71) on Tue Feb 16 15:23:08 EST 2016 --> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"> <title>Uses of Class org.apache.solr.store.blockcache.BlockCacheLocation (Solr 5.5.0 API)</title> <meta name="date" content="2016-02-16"> <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.apache.solr.store.blockcache.BlockCacheLocation (Solr 5.5.0 API)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../org/apache/solr/store/blockcache/BlockCacheLocation.html" title="class in org.apache.solr.store.blockcache">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/solr/store/blockcache/class-use/BlockCacheLocation.html" target="_top">Frames</a></li> <li><a href="BlockCacheLocation.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h2 title="Uses of Class org.apache.solr.store.blockcache.BlockCacheLocation" class="title">Uses of Class<br>org.apache.solr.store.blockcache.BlockCacheLocation</h2> </div> <div class="classUseContainer">No usage of org.apache.solr.store.blockcache.BlockCacheLocation</div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../org/apache/solr/store/blockcache/BlockCacheLocation.html" title="class in org.apache.solr.store.blockcache">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/solr/store/blockcache/class-use/BlockCacheLocation.html" target="_top">Frames</a></li> <li><a href="BlockCacheLocation.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small> <i>Copyright &copy; 2000-2016 Apache Software Foundation. All Rights Reserved.</i> <script src='../../../../../../prettify.js' type='text/javascript'></script> <script type='text/javascript'> (function(){ var oldonload = window.onload; if (typeof oldonload != 'function') { window.onload = prettyPrint; } else { window.onload = function() { oldonload(); prettyPrint(); } } })(); </script> </small></p> </body> </html>
olli-gold/vufind
solr/vendor/docs/solr-core/org/apache/solr/store/blockcache/class-use/BlockCacheLocation.html
HTML
gpl-2.0
4,954
// Copyright 2009 Dolphin Emulator Project // Licensed under GPLv2+ // Refer to the license.txt file included. #include <algorithm> #include <atomic> #include <mutex> #include <string> #include "Common/CommonTypes.h" #include "Common/StringUtil.h" #include "Core/Core.h" #include "VideoBackends/Software/SWCommandProcessor.h" #include "VideoBackends/Software/SWOGLWindow.h" #include "VideoBackends/Software/SWRenderer.h" #include "VideoBackends/Software/SWStatistics.h" #include "VideoCommon/ImageWrite.h" #include "VideoCommon/OnScreenDisplay.h" static u8 *s_xfbColorTexture[2]; static int s_currentColorTexture = 0; static std::atomic<bool> s_bScreenshot; static std::mutex s_criticalScreenshot; static std::string s_sScreenshotName; void SWRenderer::Init() { s_bScreenshot.store(false); } void SWRenderer::Shutdown() { delete[] s_xfbColorTexture[0]; delete[] s_xfbColorTexture[1]; } void SWRenderer::Prepare() { s_xfbColorTexture[0] = new u8[MAX_XFB_WIDTH * MAX_XFB_HEIGHT * 4]; s_xfbColorTexture[1] = new u8[MAX_XFB_WIDTH * MAX_XFB_HEIGHT * 4]; s_currentColorTexture = 0; } void SWRenderer::SetScreenshot(const char *_szFilename) { std::lock_guard<std::mutex> lk(s_criticalScreenshot); s_sScreenshotName = _szFilename; s_bScreenshot.store(true); } void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color) { SWOGLWindow::s_instance->PrintText(pstr, left, top, color); } void SWRenderer::DrawDebugText() { std::string debugtext; if (g_SWVideoConfig.bShowStats) { debugtext += StringFromFormat("Objects: %i\n", swstats.thisFrame.numDrawnObjects); debugtext += StringFromFormat("Primitives: %i\n", swstats.thisFrame.numPrimatives); debugtext += StringFromFormat("Vertices Loaded: %i\n", swstats.thisFrame.numVerticesLoaded); debugtext += StringFromFormat("Triangles Input: %i\n", swstats.thisFrame.numTrianglesIn); debugtext += StringFromFormat("Triangles Rejected: %i\n", swstats.thisFrame.numTrianglesRejected); debugtext += StringFromFormat("Triangles Culled: %i\n", swstats.thisFrame.numTrianglesCulled); debugtext += StringFromFormat("Triangles Clipped: %i\n", swstats.thisFrame.numTrianglesClipped); debugtext += StringFromFormat("Triangles Drawn: %i\n", swstats.thisFrame.numTrianglesDrawn); debugtext += StringFromFormat("Rasterized Pix: %i\n", swstats.thisFrame.rasterizedPixels); debugtext += StringFromFormat("TEV Pix In: %i\n", swstats.thisFrame.tevPixelsIn); debugtext += StringFromFormat("TEV Pix Out: %i\n", swstats.thisFrame.tevPixelsOut); } // Render a shadow, and then the text. SWRenderer::RenderText(debugtext.c_str(), 21, 21, 0xDD000000); SWRenderer::RenderText(debugtext.c_str(), 20, 20, 0xFFFFFF00); } u8* SWRenderer::GetNextColorTexture() { return s_xfbColorTexture[!s_currentColorTexture]; } u8* SWRenderer::GetCurrentColorTexture() { return s_xfbColorTexture[s_currentColorTexture]; } void SWRenderer::SwapColorTexture() { s_currentColorTexture = !s_currentColorTexture; } void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidth, u32 fbHeight) { if (fbWidth * fbHeight > MAX_XFB_WIDTH * MAX_XFB_HEIGHT) { ERROR_LOG(VIDEO, "Framebuffer is too large: %ix%i", fbWidth, fbHeight); return; } u32 offset = 0; u8 *TexturePointer = GetNextColorTexture(); for (u16 y = 0; y < fbHeight; y++) { for (u16 x = 0; x < fbWidth; x+=2) { // We do this one color sample (aka 2 RGB pixles) at a time int Y1 = xfb[x].Y - 16; int Y2 = xfb[x + 1].Y - 16; int U = int(xfb[x].UV) - 128; int V = int(xfb[x + 1].UV) - 128; // We do the inverse BT.601 conversion for YCbCr to RGB // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y1 + 1.596f * V), 0, 255); TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y1 - 0.392f * U - 0.813f * V), 0, 255); TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y1 + 2.017f * U ), 0, 255); TexturePointer[offset++] = 255; TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y2 + 1.596f * V), 0, 255); TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y2 - 0.392f * U - 0.813f * V), 0, 255); TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y2 + 2.017f * U ), 0, 255); TexturePointer[offset++] = 255; } xfb += fbWidth; } SwapColorTexture(); } // Called on the GPU thread void SWRenderer::Swap(u32 fbWidth, u32 fbHeight) { // Save screenshot if (s_bScreenshot.load()) { std::lock_guard<std::mutex> lk(s_criticalScreenshot); TextureToPng(GetCurrentColorTexture(), fbWidth * 4, s_sScreenshotName, fbWidth, fbHeight, false); // Reset settings s_sScreenshotName.clear(); s_bScreenshot.store(false); } OSD::DoCallbacks(OSD::OSD_ONFRAME); DrawDebugText(); SWOGLWindow::s_instance->ShowImage(GetCurrentColorTexture(), fbWidth * 4, fbWidth, fbHeight, 1.0); swstats.frameCount++; swstats.ResetFrame(); Core::Callback_VideoCopiedToXFB(true); // FIXME: should this function be called FrameRendered? }
hdcmeta/dolphin
Source/Core/VideoBackends/Software/SWRenderer.cpp
C++
gpl-2.0
5,140
<?php /** * @package Joomla.Site * @subpackage com_privacy * * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Request model class. * * @since 3.9.0 */ class PrivacyModelRequest extends JModelAdmin { /** * Creates an information request. * * @param array $data The data expected for the form. * * @return mixed Exception | JException | boolean * * @since 3.9.0 */ public function createRequest($data) { // Creating requests requires the site's email sending be enabled if (!JFactory::getConfig()->get('mailonline', 1)) { $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED')); return false; } // Get the form. $form = $this->getForm(); $data['email'] = JStringPunycode::emailToPunycode($data['email']); // Check for an error. if ($form instanceof Exception) { return $form; } // Filter and validate the form data. $data = $form->filter($data); $return = $form->validate($data); // Check for an error. if ($return instanceof Exception) { return $return; } // Check the validation results. if ($return === false) { // Get the validation messages from the form. foreach ($form->getErrors() as $formError) { $this->setError($formError->getMessage()); } return false; } // Search for an open information request matching the email and type $db = $this->getDbo(); $query = $db->getQuery(true) ->select('COUNT(id)') ->from('#__privacy_requests') ->where('email = ' . $db->quote($data['email'])) ->where('request_type = ' . $db->quote($data['request_type'])) ->where('status IN (0, 1)'); try { $result = (int) $db->setQuery($query)->loadResult(); } catch (JDatabaseException $exception) { // Can't check for existing requests, so don't create a new one $this->setError(JText::_('COM_PRIVACY_ERROR_CHECKING_FOR_EXISTING_REQUESTS')); return false; } if ($result > 0) { $this->setError(JText::_('COM_PRIVACY_ERROR_PENDING_REQUEST_OPEN')); return false; } // Everything is good to go, create the request $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword()); $hashedToken = JUserHelper::hashPassword($token); $data['confirm_token'] = $hashedToken; $data['confirm_token_created_at'] = JFactory::getDate()->toSql(); if (!$this->save($data)) { // The save function will set the error message, so just return here return false; } // Push a notification to the site's super users, deliberately ignoring if this process fails so the below message goes out JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/models', 'MessagesModel'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/tables'); /** @var MessagesModelMessage $messageModel */ $messageModel = JModelLegacy::getInstance('Message', 'MessagesModel'); $messageModel->notifySuperUsers( JText::_('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CREATED_REQUEST_SUBJECT'), JText::sprintf('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CREATED_REQUEST_MESSAGE', $data['email']) ); // The mailer can be set to either throw Exceptions or return boolean false, account for both try { $app = JFactory::getApplication(); $linkMode = $app->get('force_ssl', 0) == 2 ? 1 : -1; $substitutions = array( '[SITENAME]' => $app->get('sitename'), '[URL]' => JUri::root(), '[TOKENURL]' => JRoute::link('site', 'index.php?option=com_privacy&view=confirm&confirm_token=' . $token, false, $linkMode), '[FORMURL]' => JRoute::link('site', 'index.php?option=com_privacy&view=confirm', false, $linkMode), '[TOKEN]' => $token, '\\n' => "\n", ); switch ($data['request_type']) { case 'export': $emailSubject = JText::_('COM_PRIVACY_EMAIL_REQUEST_SUBJECT_EXPORT_REQUEST'); $emailBody = JText::_('COM_PRIVACY_EMAIL_REQUEST_BODY_EXPORT_REQUEST'); break; case 'remove': $emailSubject = JText::_('COM_PRIVACY_EMAIL_REQUEST_SUBJECT_REMOVE_REQUEST'); $emailBody = JText::_('COM_PRIVACY_EMAIL_REQUEST_BODY_REMOVE_REQUEST'); break; default: $this->setError(JText::_('COM_PRIVACY_ERROR_UNKNOWN_REQUEST_TYPE')); return false; } foreach ($substitutions as $k => $v) { $emailSubject = str_replace($k, $v, $emailSubject); $emailBody = str_replace($k, $v, $emailBody); } $mailer = JFactory::getMailer(); $mailer->setSubject($emailSubject); $mailer->setBody($emailBody); $mailer->addRecipient($data['email']); $mailResult = $mailer->Send(); if ($mailResult instanceof JException) { // JError was already called so we just need to return now return false; } elseif ($mailResult === false) { $this->setError($mailer->ErrorInfo); return false; } /** @var PrivacyTableRequest $table */ $table = $this->getTable(); if (!$table->load($this->getState($this->getName() . '.id'))) { $this->setError($table->getError()); return false; } // Log the request's creation JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); $message = array( 'action' => 'request-created', 'requesttype' => $table->request_type, 'subjectemail' => $table->email, 'id' => $table->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $table->id, ); /** @var ActionlogsModelActionlog $model */ $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_CREATED_REQUEST', 'com_privacy.request'); // The email sent and the record is saved, everything is good to go from here return true; } catch (phpmailerException $exception) { $this->setError($exception->getMessage()); return false; } } /** * Method for getting the form from the model. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return JForm|boolean A JForm object on success, false on failure * * @since 3.9.0 */ public function getForm($data = array(), $loadData = true) { return $this->loadForm('com_privacy.request', 'request', array('control' => 'jform')); } /** * Method to get a table object, load it if necessary. * * @param string $name The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * * @return JTable A JTable object * * @since 3.9.0 * @throws \Exception */ public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = array()) { return parent::getTable($name, $prefix, $options); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 3.9.0 */ protected function populateState() { // Get the application object. $params = JFactory::getApplication()->getParams('com_privacy'); // Load the parameters. $this->setState('params', $params); } }
jatitoam/joomla-cms
components/com_privacy/models/request.php
PHP
gpl-2.0
7,443
/* * $Id$ * * Flatstore module connection identifier * * Copyright (C) 2004 FhG Fokus * * This file is part of Kamailio, a free SIP server. * * Kamailio 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 * * Kamailio 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <string.h> #include "../../dprint.h" #include "../../mem/mem.h" #include "km_flat_id.h" /* * Create a new connection identifier */ struct flat_id* new_flat_id(char* dir, char* table) { struct flat_id* ptr; char* t; int t_len; if (!dir || !table) { LM_ERR("invalid parameter(s)\n"); return 0; } ptr = (struct flat_id*)pkg_malloc(sizeof(struct flat_id)); if (!ptr) { LM_ERR("no pkg memory left\n"); return 0; } memset(ptr, 0, sizeof(struct flat_id)); /* alloc memory for the table name */ t_len = strlen(table); t = (char*)pkg_malloc(t_len+1); if (!t) { LM_ERR("no pkg memory left\n"); pkg_free(ptr); return 0; } memset(t, 0, t_len); ptr->dir.s = dir; ptr->dir.len = strlen(dir); memcpy(t, table, t_len); t[t_len] = '\0'; ptr->table.s = t; ptr->table.len = t_len; return ptr; } /* * Compare two connection identifiers */ unsigned char cmp_flat_id(struct flat_id* id1, struct flat_id* id2) { if (!id1 || !id2) return 0; if (id1->dir.len != id2->dir.len) return 0; if (id1->table.len != id2->table.len) return 0; if (memcmp(id1->dir.s, id2->dir.s, id1->dir.len)) return 0; if (memcmp(id1->table.s, id2->table.s, id1->table.len)) return 0; return 1; } /* * Free a connection identifier */ void free_flat_id(struct flat_id* id) { if (!id) return; if (id->table.s) pkg_free(id->table.s); pkg_free(id); }
axler00/kamailio
modules/db_flatstore/km_flat_id.c
C
gpl-2.0
2,239
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.math3.ode.nonstiff; import org.apache.commons.math3.ode.sampling.StepInterpolator; /** * This class implements a step interpolator for second order * Runge-Kutta integrator. * * <p>This interpolator computes dense output inside the last * step computed. The interpolation equation is consistent with the * integration scheme : * <ul> * <li>Using reference point at step start:<br> * y(t<sub>n</sub> + &theta; h) = y (t<sub>n</sub>) + &theta; h [(1 - &theta;) y'<sub>1</sub> + &theta; y'<sub>2</sub>] * </li> * <li>Using reference point at step end:<br> * y(t<sub>n</sub> + &theta; h) = y (t<sub>n</sub> + h) + (1-&theta;) h [&theta; y'<sub>1</sub> - (1+&theta;) y'<sub>2</sub>] * </li> * </ul> * </p> * * where &theta; belongs to [0 ; 1] and where y'<sub>1</sub> and y'<sub>2</sub> are the two * evaluations of the derivatives already computed during the * step.</p> * * @see MidpointIntegrator * @version $Id$ * @since 1.2 */ class MidpointStepInterpolator extends RungeKuttaStepInterpolator { /** Serializable version identifier */ private static final long serialVersionUID = 20111120L; /** Simple constructor. * This constructor builds an instance that is not usable yet, the * {@link * org.apache.commons.math3.ode.sampling.AbstractStepInterpolator#reinitialize} * method should be called before using the instance in order to * initialize the internal arrays. This constructor is used only * in order to delay the initialization in some cases. The {@link * RungeKuttaIntegrator} class uses the prototyping design pattern * to create the step interpolators by cloning an uninitialized model * and later initializing the copy. */ public MidpointStepInterpolator() { } /** Copy constructor. * @param interpolator interpolator to copy from. The copy is a deep * copy: its arrays are separated from the original arrays of the * instance */ public MidpointStepInterpolator(final MidpointStepInterpolator interpolator) { super(interpolator); } /** {@inheritDoc} */ @Override protected StepInterpolator doCopy() { return new MidpointStepInterpolator(this); } /** {@inheritDoc} */ @Override protected void computeInterpolatedStateAndDerivatives(final double theta, final double oneMinusThetaH) { final double coeffDot2 = 2 * theta; final double coeffDot1 = 1 - coeffDot2; if ((previousState != null) && (theta <= 0.5)) { final double coeff1 = theta * oneMinusThetaH; final double coeff2 = theta * theta * h; for (int i = 0; i < interpolatedState.length; ++i) { final double yDot1 = yDotK[0][i]; final double yDot2 = yDotK[1][i]; interpolatedState[i] = previousState[i] + coeff1 * yDot1 + coeff2 * yDot2; interpolatedDerivatives[i] = coeffDot1 * yDot1 + coeffDot2 * yDot2; } } else { final double coeff1 = oneMinusThetaH * theta; final double coeff2 = oneMinusThetaH * (1.0 + theta); for (int i = 0; i < interpolatedState.length; ++i) { final double yDot1 = yDotK[0][i]; final double yDot2 = yDotK[1][i]; interpolatedState[i] = currentState[i] + coeff1 * yDot1 - coeff2 * yDot2; interpolatedDerivatives[i] = coeffDot1 * yDot1 + coeffDot2 * yDot2; } } } }
SpoonLabs/astor
examples/math_32/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointStepInterpolator.java
Java
gpl-2.0
4,249
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_71) on Tue Feb 16 15:22:59 EST 2016 --> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"> <title>org.apache.solr.client.solrj.impl Class Hierarchy (Solr 5.5.0 API)</title> <meta name="date" content="2016-02-16"> <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="org.apache.solr.client.solrj.impl Class Hierarchy (Solr 5.5.0 API)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li class="navBarCell1Rev">Tree</li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../org/apache/solr/client/solrj/beans/package-tree.html">Prev</a></li> <li><a href="../../../../../../org/apache/solr/client/solrj/io/package-tree.html">Next</a></li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/solr/client/solrj/impl/package-tree.html" target="_top">Frames</a></li> <li><a href="package-tree.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 class="title">Hierarchy For Package org.apache.solr.client.solrj.impl</h1> <span class="strong">Package Hierarchies:</span> <ul class="horizontal"> <li><a href="../../../../../../overview-tree.html">All Packages</a></li> </ul> </div> <div class="contentContainer"> <h2 title="Class Hierarchy">Class Hierarchy</h2> <ul> <li type="circle">java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang"><span class="strong">Object</span></a> <ul> <li type="circle">org.apache.http.impl.cookie.AbstractCookieSpec (implements org.apache.http.cookie.CookieSpec) <ul> <li type="circle">org.apache.http.impl.cookie.CookieSpecBase <ul> <li type="circle">org.apache.http.impl.cookie.NetscapeDraftSpec <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/SolrPortAwareCookieSpecFactory.PortAwareCookieSpec.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">SolrPortAwareCookieSpecFactory.PortAwareCookieSpec</span></a></li> </ul> </li> </ul> </li> </ul> </li> <li type="circle">org.apache.http.impl.cookie.BasicDomainHandler (implements org.apache.http.cookie.CommonCookieAttributeHandler) <ul> <li type="circle">org.apache.http.impl.cookie.NetscapeDomainHandler <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/SolrPortAwareCookieSpecFactory.PortAwareDomainHandler.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">SolrPortAwareCookieSpecFactory.PortAwareDomainHandler</span></a></li> </ul> </li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpClientConfigurer.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpClientConfigurer</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/Krb5HttpClientConfigurer.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">Krb5HttpClientConfigurer</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpClientUtil.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpClientUtil</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpClientUtil.HttpClientFactory.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpClientUtil.HttpClientFactory</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpSolrClient.HttpUriRequestResponse.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpSolrClient.HttpUriRequestResponse</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/LBHttpSolrClient.Req.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">LBHttpSolrClient.Req</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/LBHttpSolrClient.Rsp.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">LBHttpSolrClient.Rsp</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/LBHttpSolrClient.ServerWrapper.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">LBHttpSolrClient.ServerWrapper</span></a></li> <li type="circle">org.apache.solr.common.util.<a href="../../../../../../org/apache/solr/common/util/NamedList.html" title="class in org.apache.solr.common.util"><span class="strong">NamedList</span></a>&lt;T&gt; (implements java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Cloneable.html?is-external=true" title="class or interface in java.lang">Cloneable</a>, java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</a>&lt;T&gt;, java.io.<a href="http://download.oracle.com/javase/7/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>) <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/CloudSolrClient.RouteResponse.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">CloudSolrClient.RouteResponse</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.request.<a href="../../../../../../org/apache/solr/client/solrj/request/RequestWriter.html" title="class in org.apache.solr.client.solrj.request"><span class="strong">RequestWriter</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/BinaryRequestWriter.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">BinaryRequestWriter</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.<a href="../../../../../../org/apache/solr/client/solrj/ResponseParser.html" title="class in org.apache.solr.client.solrj"><span class="strong">ResponseParser</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/BinaryResponseParser.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">BinaryResponseParser</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">StreamingBinaryResponseParser</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/InputStreamResponseParser.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">InputStreamResponseParser</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/NoOpResponseParser.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">NoOpResponseParser</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/XMLResponseParser.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">XMLResponseParser</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.<a href="../../../../../../org/apache/solr/client/solrj/SolrClient.html" title="class in org.apache.solr.client.solrj"><span class="strong">SolrClient</span></a> (implements java.io.<a href="http://download.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a>, java.io.<a href="http://download.oracle.com/javase/7/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>) <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/CloudSolrClient.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">CloudSolrClient</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/CloudSolrServer.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">CloudSolrServer</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">ConcurrentUpdateSolrClient</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">ConcurrentUpdateSolrServer</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpSolrClient.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpSolrClient</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpSolrServer.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpSolrServer</span></a></li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/LBHttpSolrClient.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">LBHttpSolrClient</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/LBHttpSolrServer.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">LBHttpSolrServer</span></a></li> </ul> </li> </ul> </li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/SolrHttpRequestRetryHandler.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">SolrHttpRequestRetryHandler</span></a> (implements org.apache.http.client.HttpRequestRetryHandler)</li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/SolrPortAwareCookieSpecFactory.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">SolrPortAwareCookieSpecFactory</span></a> (implements org.apache.http.cookie.CookieSpecFactory, org.apache.http.cookie.CookieSpecProvider)</li> <li type="circle">java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang"><span class="strong">Throwable</span></a> (implements java.io.<a href="http://download.oracle.com/javase/7/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>) <ul> <li type="circle">java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang"><span class="strong">Exception</span></a> <ul> <li type="circle">java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/RuntimeException.html?is-external=true" title="class or interface in java.lang"><span class="strong">RuntimeException</span></a> <ul> <li type="circle">org.apache.solr.common.<a href="../../../../../../org/apache/solr/common/SolrException.html" title="class in org.apache.solr.common"><span class="strong">SolrException</span></a> <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/CloudSolrClient.RouteException.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">CloudSolrClient.RouteException</span></a></li> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/HttpSolrClient.RemoteSolrException.html" title="class in org.apache.solr.client.solrj.impl"><span class="strong">HttpSolrClient.RemoteSolrException</span></a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ul> <h2 title="Enum Hierarchy">Enum Hierarchy</h2> <ul> <li type="circle">java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang"><span class="strong">Object</span></a> <ul> <li type="circle">java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Enum.html?is-external=true" title="class or interface in java.lang"><span class="strong">Enum</span></a>&lt;E&gt; (implements java.lang.<a href="http://download.oracle.com/javase/7/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a>&lt;T&gt;, java.io.<a href="http://download.oracle.com/javase/7/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>) <ul> <li type="circle">org.apache.solr.client.solrj.impl.<a href="../../../../../../org/apache/solr/client/solrj/impl/XMLResponseParser.KnownType.html" title="enum in org.apache.solr.client.solrj.impl"><span class="strong">XMLResponseParser.KnownType</span></a></li> </ul> </li> </ul> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li class="navBarCell1Rev">Tree</li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../org/apache/solr/client/solrj/beans/package-tree.html">Prev</a></li> <li><a href="../../../../../../org/apache/solr/client/solrj/io/package-tree.html">Next</a></li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/solr/client/solrj/impl/package-tree.html" target="_top">Frames</a></li> <li><a href="package-tree.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small> <i>Copyright &copy; 2000-2016 Apache Software Foundation. All Rights Reserved.</i> <script src='../../../../../../prettify.js' type='text/javascript'></script> <script type='text/javascript'> (function(){ var oldonload = window.onload; if (typeof oldonload != 'function') { window.onload = prettyPrint; } else { window.onload = function() { oldonload(); prettyPrint(); } } })(); </script> </small></p> </body> </html>
JamieDenman/FXPlusVuFind
solr/vendor/docs/solr-solrj/org/apache/solr/client/solrj/impl/package-tree.html
HTML
gpl-2.0
17,353
/* * Gadget Driver for Android * * Copyright (C) 2008 Google, Inc. * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. * Author: Mike Lockwood <lockwood@android.com> * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. * */ /* #define DEBUG */ /* #define VERBOSE_DEBUG */ #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/delay.h> #include <linux/kernel.h> #include <linux/utsname.h> #include <linux/platform_device.h> #include <linux/usb/ch9.h> #include <linux/usb/composite.h> #include <linux/usb/gadget.h> #include <linux/usb/android_composite.h> #include "gadget_chips.h" #include <linux/wakelock.h> #ifdef CONFIG_PERFLOCK #include <mach/perflock.h> #endif /* * Kbuild is not very cooperative with respect to linking separately * compiled library objects into one module. So for now we won't use * separate compilation ... ensuring init/exit sections work to shrink * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "composite.c" #include "f_diag.c" #if defined(CONFIG_USB_ANDROID_RMNET_SMD) #include "f_rmnet_smd.c" #elif defined(CONFIG_USB_ANDROID_RMNET_SDIO) #include "f_rmnet_sdio.c" #elif defined(CONFIG_USB_ANDROID_RMNET_SMD_SDIO) #include "f_rmnet_smd_sdio.c" #elif defined(CONFIG_USB_ANDROID_RMNET_BAM) #include "f_rmnet.c" #endif #include "f_mass_storage.c" #include "u_serial.c" #include "u_sdio.c" #include "u_smd.c" #include "u_bam.c" #include "u_rmnet_ctrl_smd.c" #include "u_ctrl_hsic.c" #include "u_data_hsic.c" #include "f_serial.c" #ifdef CONFIG_USB_ANDROID_ACM #include "f_acm.c" #endif #include "f_adb.c" #if 0 #include "f_ccid.c" #endif #ifdef CONFIG_USB_ANDROID_MTP #include "f_mtp.c" #endif #include "f_accessory.c" #define USB_ETH_RNDIS y #ifdef CONFIG_USB_ANDROID_RNDIS #include "f_rndis.c" #include "rndis.c" #endif #ifdef CONFIG_USB_ANDROID_ECM #include "f_ecm.c" #endif #ifdef CONFIG_USB_ETH_PASS_FW #include "passthru.c" #endif #include "u_ether.c" #ifdef CONFIG_USB_ANDROID_USBNET #include "f_usbnet.c" #endif #include <linux/usb/htc_info.h> #ifdef pr_debug #undef pr_debug #endif #define pr_debug(fmt, args...) \ printk(KERN_DEBUG "[USB] " pr_fmt(fmt), ## args) #ifdef pr_err #undef pr_err #endif #define pr_err(fmt, args...) \ printk(KERN_ERR "[USB] " pr_fmt(fmt), ## args) #ifdef pr_warning #undef pr_warning #endif #define pr_warning(fmt, args...) \ printk(KERN_WARNING "[USB] " pr_fmt(fmt), ## args) #ifdef pr_info #undef pr_info #endif #define pr_info(fmt, args...) \ printk(KERN_INFO "[USB] " pr_fmt(fmt), ## args) MODULE_AUTHOR("Mike Lockwood"); MODULE_DESCRIPTION("Android Composite USB Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION("1.0"); static const char longname[] = "Gadget Android"; /* Default vendor and product IDs, overridden by userspace */ #define VENDOR_ID 0x18D1 #define PRODUCT_ID 0x0001 static bool connect2pc; struct android_usb_function { char *name; void *config; struct device *dev; char *dev_name; struct device_attribute **attributes; /* for android_dev.enabled_functions */ struct list_head enabled_list; /* Optional: initialization during gadget bind */ int (*init)(struct android_usb_function *, struct usb_composite_dev *); /* Optional: cleanup during gadget unbind */ void (*cleanup)(struct android_usb_function *); int (*bind_config)(struct android_usb_function *, struct usb_configuration *); /* Optional: called when the configuration is removed */ void (*unbind_config)(struct android_usb_function *, struct usb_configuration *); /* Optional: handle ctrl requests before the device is configured * and/or before the function is enabled */ int (*ctrlrequest)(struct android_usb_function *, struct usb_composite_dev *, const struct usb_ctrlrequest *); /* for performance requirement */ int performance_lock; }; struct android_dev { struct android_usb_function **functions; struct list_head enabled_functions; struct usb_composite_dev *cdev; struct device *dev; struct android_usb_platform_data *pdata; bool enabled; bool connected; bool sw_connected; struct work_struct work; struct delayed_work init_work; /* waiting for enabling functions */ struct list_head function_list; int num_products; struct android_usb_product *products; int num_functions; char **in_house_functions; int product_id; void (*enable_fast_charge)(bool enable); bool RndisDisableMPDecision; int (*match)(int product_id, int intrsharing); bool bEnablePerfLock; int autobot_mode; }; static struct class *android_class; static struct android_dev *_android_dev; #ifdef CONFIG_USB_ANDROID_PROJECTOR #include "f_projector.c" #endif static struct wake_lock android_usb_idle_wake_lock; #ifdef CONFIG_PERFLOCK static struct perf_lock android_usb_perf_lock; #endif static int android_bind_config(struct usb_configuration *c); static void android_unbind_config(struct usb_configuration *c); /* string IDs are assigned dynamically */ #define STRING_MANUFACTURER_IDX 0 #define STRING_PRODUCT_IDX 1 #define STRING_SERIAL_IDX 2 static char manufacturer_string[256]; static char product_string[256]; static char serial_string[256]; /* String Table */ static struct usb_string strings_dev[] = { [STRING_MANUFACTURER_IDX].s = manufacturer_string, [STRING_PRODUCT_IDX].s = product_string, [STRING_SERIAL_IDX].s = serial_string, { } /* end of list */ }; static struct usb_gadget_strings stringtab_dev = { .language = 0x0409, /* en-us */ .strings = strings_dev, }; static struct usb_gadget_strings *dev_strings[] = { &stringtab_dev, NULL, }; static struct usb_device_descriptor device_desc = { .bLength = sizeof(device_desc), .bDescriptorType = USB_DT_DEVICE, .bcdUSB = __constant_cpu_to_le16(0x0200), .bDeviceClass = USB_CLASS_PER_INTERFACE, .idVendor = __constant_cpu_to_le16(VENDOR_ID), .idProduct = __constant_cpu_to_le16(PRODUCT_ID), .bcdDevice = __constant_cpu_to_le16(0xffff), .bNumConfigurations = 1, }; static struct usb_configuration android_config_driver = { .label = "android", .unbind = android_unbind_config, .bConfigurationValue = 1, .bmAttributes = USB_CONFIG_ATT_ONE /* | USB_CONFIG_ATT_SELFPOWER */, .bMaxPower = 0xFA, /* 500ma */ }; static void android_work(struct work_struct *data) { struct android_dev *dev = container_of(data, struct android_dev, work); struct usb_composite_dev *cdev = dev->cdev; char *disconnected[2] = { "USB_STATE=DISCONNECTED", NULL }; char *connected[2] = { "USB_STATE=CONNECTED", NULL }; char *configured[2] = { "USB_STATE=CONFIGURED", NULL }; unsigned long flags; struct android_usb_function *f; int count = 0; /* release performance related locks first */ if (dev->pdata->sfab_lock) dev->pdata->sfab_lock(0); if (wake_lock_active(&android_usb_idle_wake_lock)) wake_unlock(&android_usb_idle_wake_lock); #ifdef CONFIG_PERFLOCK if (is_perf_lock_active(&android_usb_perf_lock)) perf_unlock(&android_usb_perf_lock); #endif spin_lock_irqsave(&cdev->lock, flags); if (cdev->config) { spin_unlock_irqrestore(&cdev->lock, flags); kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, configured); pr_info("USB_STATE=CONFIGURED"); /* hold perflock, wakelock for performance consideration */ list_for_each_entry(f, &dev->enabled_functions, enabled_list) { if (f->performance_lock && dev->bEnablePerfLock) { pr_info("Performance lock for '%s'\n", f->name); count++; } } if (count) { if (!wake_lock_active(&android_usb_idle_wake_lock)) wake_lock(&android_usb_idle_wake_lock); #ifdef CONFIG_PERFLOCK if (!is_perf_lock_active(&android_usb_perf_lock)) perf_lock(&android_usb_perf_lock); #endif if (dev->pdata->sfab_lock) dev->pdata->sfab_lock(1); } if (!connect2pc && dev->connected && !is_mtp_enabled) { connect2pc = true; switch_set_state(&cdev->sw_connect2pc, 1); pr_info("set usb_connect2pc = 1\n"); } return; } if (dev->connected != dev->sw_connected) { dev->sw_connected = dev->connected; spin_unlock_irqrestore(&cdev->lock, flags); kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, dev->sw_connected ? connected : disconnected); pr_info("%s\n", dev->connected ? connected[0] : disconnected[0]); } else { spin_unlock_irqrestore(&cdev->lock, flags); if (is_mtp_enabled) { kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, dev->connected ? connected : disconnected); pr_info("%s\n", dev->connected ? connected[0] : disconnected[0]); } } if (connect2pc && !dev->connected && !is_mtp_enabled) { connect2pc = false; switch_set_state(&cdev->sw_connect2pc, 0); pr_info("set usb_connect2pc = 0\n"); } } /*-------------------------------------------------------------------------*/ /* Supported functions initialization */ static ssize_t func_en_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *func = dev_get_drvdata(dev); struct android_usb_function *f; int ebl = 0; list_for_each_entry(f, &_android_dev->enabled_functions, enabled_list) { if (!strcmp(func->name, f->name)) { ebl = 1; break; } } return sprintf(buf, "%d", ebl); } static ssize_t func_en_store( struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *func = dev_get_drvdata(dev); struct android_usb_function *f; int ebl = 0; int value; sscanf(buf, "%d", &value); list_for_each_entry(f, &_android_dev->enabled_functions, enabled_list) { if (!strcmp(func->name, f->name)) { ebl = 1; break; } } if (!!value == ebl) { pr_info("%s function is already %s\n", func->name , ebl ? "enable" : "disable"); return size; } if (value) htc_usb_enable_function(func->name, 1); else htc_usb_enable_function(func->name, 0); return size; } static DEVICE_ATTR(on, S_IRUGO | S_IWUSR | S_IWGRP, func_en_show, func_en_store); /* For QCT modem transport interface design */ #define XPORT_STR_LEN 10 char *xport_to_str(enum transport_type t) { switch (t) { case USB_GADGET_XPORT_TTY: return "TTY"; case USB_GADGET_XPORT_SDIO: return "SDIO"; case USB_GADGET_XPORT_SMD: return "SMD"; case USB_GADGET_XPORT_BAM: return "BAM"; case USB_GADGET_XPORT_HSIC: return "HSIC"; case USB_GADGET_XPORT_NONE: return "NONE"; default: return "UNDEFINED"; } } enum transport_type str_to_xport(const char *name) { if (!strncasecmp("TTY", name, XPORT_STR_LEN)) return USB_GADGET_XPORT_TTY; if (!strncasecmp("SDIO", name, XPORT_STR_LEN)) return USB_GADGET_XPORT_SDIO; if (!strncasecmp("SMD", name, XPORT_STR_LEN)) return USB_GADGET_XPORT_SMD; if (!strncasecmp("BAM", name, XPORT_STR_LEN)) return USB_GADGET_XPORT_BAM; if (!strncasecmp("", name, XPORT_STR_LEN)) return USB_GADGET_XPORT_NONE; return USB_GADGET_XPORT_UNDEF; } #if defined(CONFIG_USB_ANDROID_RMNET_SMD) /* RMNET_SMD */ static int rmnet_smd_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return rmnet_smd_bind_config(c); } static struct android_usb_function rmnet_smd_function = { .name = "rmnet", .bind_config = rmnet_smd_function_bind_config, .performance_lock = 1, }; #elif defined(CONFIG_USB_ANDROID_RMNET_SDIO) /* RMNET_SDIO */ static int rmnet_sdio_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return rmnet_sdio_function_add(c); } static struct android_usb_function rmnet_sdio_function = { .name = "rmnet", .bind_config = rmnet_sdio_function_bind_config, .performance_lock = 1, }; #elif defined(CONFIG_USB_ANDROID_RMNET_SMD_SDIO) /* RMNET_SMD_SDIO */ static int rmnet_smd_sdio_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return rmnet_smd_sdio_init(); } static void rmnet_smd_sdio_function_cleanup(struct android_usb_function *f) { rmnet_smd_sdio_cleanup(); } static int rmnet_smd_sdio_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return rmnet_smd_sdio_function_add(c); } static struct device_attribute *rmnet_smd_sdio_attributes[] = { &dev_attr_transport, NULL }; static struct android_usb_function rmnet_smd_sdio_function = { .name = "rmnet", .init = rmnet_smd_sdio_function_init, .cleanup = rmnet_smd_sdio_function_cleanup, .bind_config = rmnet_smd_sdio_bind_config, .attributes = rmnet_smd_sdio_attributes, .performance_lock = 1, }; #elif defined(CONFIG_USB_ANDROID_RMNET_BAM) /*rmnet transport string format(per port):"ctrl0,data0,ctrl1,data1..." */ #define MAX_XPORT_STR_LEN 50 static char rmnet_transports[MAX_XPORT_STR_LEN]; static int rmnet_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; if (dev->pdata->usb_rmnet_interface) strlcpy(rmnet_transports, dev->pdata->usb_rmnet_interface, sizeof(rmnet_transports) - 1); return 0; } static void rmnet_function_cleanup(struct android_usb_function *f) { frmnet_cleanup(); } static int rmnet_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int i; int err = 0; char *ctrl_name; char *data_name; char buf[MAX_XPORT_STR_LEN], *b; static int rmnet_initialized, ports; if (!rmnet_initialized) { rmnet_initialized = 1; strlcpy(buf, rmnet_transports, sizeof(buf)); b = strim(buf); while (b) { ctrl_name = strsep(&b, ","); data_name = strsep(&b, ","); if (ctrl_name && data_name) { err = frmnet_init_port(ctrl_name, data_name); if (err) { pr_err("rmnet: Cannot open ctrl port:" "'%s' data port:'%s'\n", ctrl_name, data_name); goto out; } ports++; } } err = rmnet_gport_setup(); if (err) { pr_err("rmnet: Cannot setup transports"); goto out; } } for (i = 0; i < ports; i++) { err = frmnet_bind_config(c, i); if (err) { pr_err("Could not bind rmnet%u config\n", i); break; } } out: return err; } static ssize_t rmnet_transports_show(struct device *dev, struct device_attribute *attr, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", rmnet_transports); } static ssize_t rmnet_transports_store( struct device *device, struct device_attribute *attr, const char *buff, size_t size) { strlcpy(rmnet_transports, buff, sizeof(rmnet_transports)); return size; } static struct device_attribute dev_attr_rmnet_transports = __ATTR(transports, S_IRUGO | S_IWUSR, rmnet_transports_show, rmnet_transports_store); static struct device_attribute *rmnet_function_attributes[] = { &dev_attr_rmnet_transports, NULL }; static struct android_usb_function rmnet_function = { .name = "rmnet", .init = rmnet_function_init, .cleanup = rmnet_function_cleanup, .bind_config = rmnet_function_bind_config, .attributes = rmnet_function_attributes, .performance_lock = 1, }; #endif /* DIAG */ static char diag_clients[32]; /*enabled DIAG clients- "diag[,diag_mdm]" */ static ssize_t clients_store( struct device *device, struct device_attribute *attr, const char *buff, size_t size) { pr_info("%s, buff: %s\n", __func__, buff); strlcpy(diag_clients, buff, sizeof(diag_clients)); return size; } static DEVICE_ATTR(clients, S_IWUSR, NULL, clients_store); static struct device_attribute *diag_function_attributes[] = { &dev_attr_clients, NULL }; static int diag_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return diag_setup(); } static void diag_function_cleanup(struct android_usb_function *f) { diag_cleanup(); } static int diag_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { #if 1 int err; int (*notify)(uint32_t, const char *); notify = _android_dev->pdata->update_pid_and_serial_num; err = diag_function_add(c, "diag", notify); if (err) pr_err("diag: Cannot open channel 'diag'"); #else char *name; char buf[32], *b; int once = 0, err = -1; int (*notify)(uint32_t, const char *); strlcpy(buf, diag_clients, sizeof(buf)); b = strim(buf); while (b) { notify = NULL; name = strsep(&b, ","); /* Allow only first diag channel to update pid and serial no */ if (_android_dev->pdata && !once++) notify = _android_dev->pdata->update_pid_and_serial_num; if (name) { err = diag_function_add(c, name, notify); if (err) pr_err("diag: Cannot open channel '%s'", name); } } #endif return err; } static struct android_usb_function diag_function = { .name = "diag", .init = diag_function_init, .cleanup = diag_function_cleanup, .bind_config = diag_function_bind_config, .attributes = diag_function_attributes, }; #if defined(CONFIG_USB_ANDROID_MDM9K_DIAG) static int diag_mdm_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int err; int (*notify)(uint32_t, const char *); notify = NULL; err = diag_function_add(c, "diag_mdm", notify); if (err) pr_err("diag: Cannot open channel 'diag_mdm'"); return 0; } static struct android_usb_function diag_mdm_function = { .name = "diag_mdm", .bind_config = diag_mdm_function_bind_config, }; #endif /* Serial, Modem */ static int serial_driver_initial(struct usb_configuration *c) { char *name, *str[2]; char buf[80], *b; int err = -1; static int serial_initialized = 0, ports = 0; char *init_string; if (serial_initialized) { pr_info("%s: already initial\n", __func__); return ports; } serial_initialized = 1; init_string = _android_dev->pdata->fserial_init_string ? _android_dev->pdata->fserial_init_string : "smd:modem,tty,tty,tty:serial"; strncpy(buf, init_string, sizeof(buf)); buf[79] = 0; pr_info("%s: init string: %s\n", __func__, buf); b = strim(buf); while (b) { str[0] = str[1] = 0; name = strsep(&b, ","); if (name) { str[0] = strsep(&name, ":"); if (str[0]) str[1] = strsep(&name, ":"); } err = gserial_init_port(ports, str[0], str[1]); if (err) { pr_err("serial: Cannot open port '%s'\n", str[0]); goto out; } ports++; } err = gport_setup(c); if (err) { pr_err("serial: Cannot setup transports"); goto out; } return ports; out: return err; } /* Modem */ static void modem_function_cleanup(struct android_usb_function *f) { struct android_dev *dev = _android_dev; /* ToDo: need to cleanup by different channel */ gsmd_cleanup(dev->cdev->gadget, 1); } static int modem_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int err = -1; int i, ports; ports = serial_driver_initial(c); if (ports < 0) goto out; for (i = 0; i < ports; i++) { if (gserial_ports[i].func_type == USB_FSER_FUNC_MODEM) { err = gser_bind_config(c, i); if (err) { pr_err("serial: bind_config failed for port %d", i); goto out; } } } out: return err; } static struct android_usb_function modem_function = { .name = "modem", .cleanup = modem_function_cleanup, .bind_config = modem_function_bind_config, .performance_lock = 1, }; #ifdef CONFIG_USB_ANDROID_MDM9K_MODEM /* Modem_Mdm */ static void modem_mdm_function_cleanup(struct android_usb_function *f) { struct android_dev *dev = _android_dev; /* ToDo: need to cleanup by different channel */ gsmd_cleanup(dev->cdev->gadget, 1); } static int modem_mdm_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int err = -1; int i, ports; ports = serial_driver_initial(c); if (ports < 0) goto out; for (i = 0; i < ports; i++) { if (gserial_ports[i].func_type == USB_FSER_FUNC_MODEM_MDM) { err = gser_bind_config(c, i); if (err) { pr_err("serial: bind_config failed for port %d", i); goto out; } } } out: return err; } static struct android_usb_function modem_mdm_function = { .name = "modem_mdm", .cleanup = modem_mdm_function_cleanup, .bind_config = modem_mdm_function_bind_config, .performance_lock = 1, }; #endif /* SERIAL */ static char serial_transports[32]; /*enabled FSERIAL ports - "tty[,sdio]"*/ static ssize_t serial_transports_store( struct device *device, struct device_attribute *attr, const char *buff, size_t size) { pr_info("%s: %s\n", __func__, buff); strlcpy(serial_transports, buff, sizeof(serial_transports)); return size; } static DEVICE_ATTR(transports, S_IWUSR, NULL, serial_transports_store); static struct device_attribute *serial_function_attributes[] = { &dev_attr_transports, NULL }; static void serial_function_cleanup(struct android_usb_function *f) { gserial_cleanup(); } static int serial_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { #if 1 int err = -1; int i, ports, car_mode = _android_dev->autobot_mode; ports = serial_driver_initial(c); if (ports < 0) goto out; for (i = 0; i < ports; i++) { if ((gserial_ports[i].func_type == USB_FSER_FUNC_SERIAL) || (car_mode && gserial_ports[i].func_type == USB_FSER_FUNC_AUTOBOT)) { err = gser_bind_config(c, i); if (err) { pr_err("serial: bind_config failed for port %d", i); goto out; } } } #else char *name; char buf[32], *b; int err = -1, i; static int serial_initialized = 0, ports = 0; if (serial_initialized) goto bind_config; serial_initialized = 1; strlcpy(buf, serial_transports, sizeof(buf)); b = strim(buf); while (b) { name = strsep(&b, ","); if (name) { err = gserial_init_port(ports, name); if (err) { pr_err("serial: Cannot open port '%s'", name); goto out; } ports++; } } err = gport_setup(c); if (err) { pr_err("serial: Cannot setup transports"); goto out; } bind_config: for (i = 0; i < ports; i++) { err = gser_bind_config(c, i); if (err) { pr_err("serial: bind_config failed for port %d", i); goto out; } } #endif out: return err; } static struct android_usb_function serial_function = { .name = "serial", .cleanup = serial_function_cleanup, .bind_config = serial_function_bind_config, .attributes = serial_function_attributes, }; /* ADB */ static int adb_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return adb_setup(); } static void adb_function_cleanup(struct android_usb_function *f) { adb_cleanup(); } static int adb_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return adb_bind_config(c); } static struct android_usb_function adb_function = { .name = "adb", .init = adb_function_init, .cleanup = adb_function_cleanup, .bind_config = adb_function_bind_config, }; /* CCID */ #if 0 static int ccid_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return ccid_setup(); } static void ccid_function_cleanup(struct android_usb_function *f) { ccid_cleanup(); } static int ccid_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return ccid_bind_config(c); } static struct android_usb_function ccid_function = { .name = "ccid", .init = ccid_function_init, .cleanup = ccid_function_cleanup, .bind_config = ccid_function_bind_config, }; #endif #ifdef CONFIG_USB_ANDROID_ACM #define MAX_ACM_INSTANCES 4 struct acm_function_config { int instances; }; static int acm_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { struct acm_function_config *config; f->config = kzalloc(sizeof(struct acm_function_config), GFP_KERNEL); if (!f->config) return -ENOMEM; config = f->config; config->instances = 1; return gserial_setup(cdev->gadget, MAX_ACM_INSTANCES); } static void acm_function_cleanup(struct android_usb_function *f) { gserial_cleanup(); kfree(f->config); f->config = NULL; } static int acm_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int i; int ret = 0; struct acm_function_config *config = f->config; for (i = 0; i < config->instances; i++) { ret = acm_bind_config(c, i); if (ret) { pr_err("Could not bind acm%u config\n", i); break; } } return ret; } static ssize_t acm_instances_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct acm_function_config *config = f->config; return sprintf(buf, "%d\n", config->instances); } static ssize_t acm_instances_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct acm_function_config *config = f->config; int value; sscanf(buf, "%d", &value); if (value > MAX_ACM_INSTANCES) value = MAX_ACM_INSTANCES; config->instances = value; return size; } static DEVICE_ATTR(instances, S_IRUGO | S_IWUSR, acm_instances_show, acm_instances_store); static struct device_attribute *acm_function_attributes[] = { &dev_attr_instances, NULL }; static struct android_usb_function acm_function = { .name = "acm", .init = acm_function_init, .cleanup = acm_function_cleanup, .bind_config = acm_function_bind_config, .attributes = acm_function_attributes, }; #endif #ifdef CONFIG_USB_ANDROID_MTP static int mtp_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return mtp_setup(); } static void mtp_function_cleanup(struct android_usb_function *f) { mtp_cleanup(); } static int mtp_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return mtp_bind_config(c, false); } static int ptp_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { /* nothing to do - initialization is handled by mtp_function_init */ return 0; } static void ptp_function_cleanup(struct android_usb_function *f) { /* nothing to do - cleanup is handled by mtp_function_cleanup */ } static int ptp_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return mtp_bind_config(c, true); } static int mtp_function_ctrlrequest(struct android_usb_function *f, struct usb_composite_dev *cdev, const struct usb_ctrlrequest *c) { return mtp_ctrlrequest(cdev, c); } static struct android_usb_function mtp_function = { .name = "mtp", .init = mtp_function_init, .cleanup = mtp_function_cleanup, .bind_config = mtp_function_bind_config, .ctrlrequest = mtp_function_ctrlrequest, }; /* PTP function is same as MTP with slightly different interface descriptor */ static struct android_usb_function ptp_function = { .name = "ptp", .init = ptp_function_init, .cleanup = ptp_function_cleanup, .bind_config = ptp_function_bind_config, }; #endif #ifdef CONFIG_USB_ANDROID_ECM /* ECM */ struct ecm_function_config { u8 ethaddr[ETH_ALEN]; }; static int ecm_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { struct ecm_function_config *ecm; f->config = kzalloc(sizeof(struct ecm_function_config), GFP_KERNEL); if (!f->config) return -ENOMEM; ecm = f->config; return 0; } static void ecm_function_cleanup(struct android_usb_function *f) { kfree(f->config); f->config = NULL; } static int ecm_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int ret; struct ecm_function_config *ecm = f->config; if (!ecm) { pr_err("%s: ecm_pdata\n", __func__); return -1; } pr_info("%s MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", __func__, ecm->ethaddr[0], ecm->ethaddr[1], ecm->ethaddr[2], ecm->ethaddr[3], ecm->ethaddr[4], ecm->ethaddr[5]); ret = gether_setup_name(c->cdev->gadget, ecm->ethaddr, "usb"); if (ret) { pr_err("%s: gether_setup failed\n", __func__); return ret; } return ecm_bind_config(c, ecm->ethaddr); } static void ecm_function_unbind_config(struct android_usb_function *f, struct usb_configuration *c) { gether_cleanup(); } static ssize_t ecm_ethaddr_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct ecm_function_config *ecm = f->config; return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", ecm->ethaddr[0], ecm->ethaddr[1], ecm->ethaddr[2], ecm->ethaddr[3], ecm->ethaddr[4], ecm->ethaddr[5]); } static ssize_t ecm_ethaddr_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct ecm_function_config *ecm = f->config; if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", (int *)&ecm->ethaddr[0], (int *)&ecm->ethaddr[1], (int *)&ecm->ethaddr[2], (int *)&ecm->ethaddr[3], (int *)&ecm->ethaddr[4], (int *)&ecm->ethaddr[5]) == 6) return size; return -EINVAL; } static DEVICE_ATTR(ecm_ethaddr, S_IRUGO | S_IWUSR, ecm_ethaddr_show, ecm_ethaddr_store); static struct device_attribute *ecm_function_attributes[] = { &dev_attr_ecm_ethaddr, NULL }; static struct android_usb_function ecm_function = { .name = "cdc_ethernet", .init = ecm_function_init, .cleanup = ecm_function_cleanup, .bind_config = ecm_function_bind_config, .unbind_config = ecm_function_unbind_config, .attributes = ecm_function_attributes, .performance_lock = 1, }; #endif #ifdef CONFIG_USB_ANDROID_RNDIS /* RNDIS */ struct rndis_function_config { u8 ethaddr[ETH_ALEN]; u32 vendorID; char manufacturer[256]; bool wceis; }; static int rndis_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { struct rndis_function_config *rndis; struct android_dev *dev = _android_dev; f->config = kzalloc(sizeof(struct rndis_function_config), GFP_KERNEL); if (!f->config) return -ENOMEM; rndis = f->config; strncpy(rndis->manufacturer, dev->pdata->manufacturer_name, sizeof(rndis->manufacturer)); rndis->vendorID = dev->pdata->vendor_id; return 0; } static void rndis_function_cleanup(struct android_usb_function *f) { kfree(f->config); f->config = NULL; } static int rndis_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { int ret; struct rndis_function_config *rndis = f->config; if (!rndis) { pr_err("%s: rndis_pdata\n", __func__); return -1; } pr_info("%s MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", __func__, rndis->ethaddr[0], rndis->ethaddr[1], rndis->ethaddr[2], rndis->ethaddr[3], rndis->ethaddr[4], rndis->ethaddr[5]); ret = gether_setup_name(c->cdev->gadget, rndis->ethaddr, "usb"); if (ret) { pr_err("%s: gether_setup failed\n", __func__); return ret; } if (rndis->wceis) { /* "Wireless" RNDIS; auto-detected by Windows */ rndis_iad_descriptor.bFunctionClass = USB_CLASS_WIRELESS_CONTROLLER; rndis_iad_descriptor.bFunctionSubClass = 0x01; rndis_iad_descriptor.bFunctionProtocol = 0x03; rndis_control_intf.bInterfaceClass = USB_CLASS_WIRELESS_CONTROLLER; rndis_control_intf.bInterfaceSubClass = 0x01; rndis_control_intf.bInterfaceProtocol = 0x03; } return rndis_bind_config(c, rndis->ethaddr, rndis->vendorID, rndis->manufacturer); } static void rndis_function_unbind_config(struct android_usb_function *f, struct usb_configuration *c) { gether_cleanup(); } static ssize_t rndis_manufacturer_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; return snprintf(buf, PAGE_SIZE, "%s\n", config->manufacturer); } static ssize_t rndis_manufacturer_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; if (size >= sizeof(config->manufacturer)) return -EINVAL; if (sscanf(buf, "%255s", config->manufacturer) == 1) return size; return -1; } static DEVICE_ATTR(manufacturer, S_IRUGO | S_IWUSR, rndis_manufacturer_show, rndis_manufacturer_store); static ssize_t rndis_wceis_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; return snprintf(buf, PAGE_SIZE, "%d\n", config->wceis); } static ssize_t rndis_wceis_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; int value; if (sscanf(buf, "%d", &value) == 1) { config->wceis = value; return size; } return -EINVAL; } static DEVICE_ATTR(wceis, S_IRUGO | S_IWUSR, rndis_wceis_show, rndis_wceis_store); static ssize_t rndis_ethaddr_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *rndis = f->config; return snprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n", rndis->ethaddr[0], rndis->ethaddr[1], rndis->ethaddr[2], rndis->ethaddr[3], rndis->ethaddr[4], rndis->ethaddr[5]); } static ssize_t rndis_ethaddr_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *rndis = f->config; if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", (int *)&rndis->ethaddr[0], (int *)&rndis->ethaddr[1], (int *)&rndis->ethaddr[2], (int *)&rndis->ethaddr[3], (int *)&rndis->ethaddr[4], (int *)&rndis->ethaddr[5]) == 6) return size; return -EINVAL; } static DEVICE_ATTR(ethaddr, S_IRUGO | S_IWUSR, rndis_ethaddr_show, rndis_ethaddr_store); static ssize_t rndis_vendorID_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; return snprintf(buf, PAGE_SIZE, "%04x\n", config->vendorID); } static ssize_t rndis_vendorID_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct rndis_function_config *config = f->config; int value; if (sscanf(buf, "%04x", &value) == 1) { config->vendorID = value; return size; } return -EINVAL; } static DEVICE_ATTR(vendorID, S_IRUGO | S_IWUSR, rndis_vendorID_show, rndis_vendorID_store); static struct device_attribute *rndis_function_attributes[] = { &dev_attr_manufacturer, &dev_attr_wceis, &dev_attr_ethaddr, &dev_attr_vendorID, NULL }; static struct android_usb_function rndis_function = { .name = "rndis", .init = rndis_function_init, .cleanup = rndis_function_cleanup, .bind_config = rndis_function_bind_config, .unbind_config = rndis_function_unbind_config, .attributes = rndis_function_attributes, .performance_lock = 1, }; #endif struct mass_storage_function_config { struct fsg_config fsg; struct fsg_common *common; }; static int mass_storage_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { struct mass_storage_function_config *config; struct fsg_common *common; int err; struct android_dev *dev = _android_dev; int i; config = kzalloc(sizeof(struct mass_storage_function_config), GFP_KERNEL); if (!config) return -ENOMEM; if (dev->pdata->nluns) { config->fsg.nluns = dev->pdata->nluns; if (config->fsg.nluns > FSG_MAX_LUNS) config->fsg.nluns = FSG_MAX_LUNS; for (i = 0; i < config->fsg.nluns; i++) { if (dev->pdata->cdrom_lun & (1 << i)) { config->fsg.luns[i].cdrom = 1; config->fsg.luns[i].removable = 1; config->fsg.luns[i].ro = 1; } else { config->fsg.luns[i].cdrom = 0; config->fsg.luns[i].removable = 1; config->fsg.luns[i].ro = 0; } } } else { /* default value */ config->fsg.nluns = 1; config->fsg.luns[0].removable = 1; } config->fsg.vendor_name = dev->pdata->manufacturer_name; config->fsg.product_name= dev->pdata->product_name; common = fsg_common_init(NULL, cdev, &config->fsg); if (IS_ERR(common)) { kfree(config); return PTR_ERR(common); } for (i = 0; i < config->fsg.nluns; i++) { err = sysfs_create_link(&f->dev->kobj, &common->luns[i].dev.kobj, common->luns[i].dev.kobj.name); if (err) { fsg_common_release(&common->ref); kfree(config); return err; } } config->common = common; f->config = config; return 0; } static void mass_storage_function_cleanup(struct android_usb_function *f) { kfree(f->config); f->config = NULL; } static int mass_storage_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { struct mass_storage_function_config *config = f->config; return fsg_bind_config(c->cdev, c, config->common); } static ssize_t mass_storage_inquiry_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; return snprintf(buf, PAGE_SIZE, "%s\n", config->common->inquiry_string); } static ssize_t mass_storage_inquiry_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct android_usb_function *f = dev_get_drvdata(dev); struct mass_storage_function_config *config = f->config; if (size >= sizeof(config->common->inquiry_string)) return -EINVAL; if (sscanf(buf, "%28s", config->common->inquiry_string) != 1) return -EINVAL; return size; } static DEVICE_ATTR(inquiry_string, S_IRUGO | S_IWUSR, mass_storage_inquiry_show, mass_storage_inquiry_store); static struct device_attribute *mass_storage_function_attributes[] = { &dev_attr_inquiry_string, NULL }; static struct android_usb_function mass_storage_function = { .name = "mass_storage", .init = mass_storage_function_init, .cleanup = mass_storage_function_cleanup, .bind_config = mass_storage_function_bind_config, .attributes = mass_storage_function_attributes, }; static int accessory_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return acc_setup(); } static void accessory_function_cleanup(struct android_usb_function *f) { acc_cleanup(); } static int accessory_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return acc_bind_config(c); } static int accessory_function_ctrlrequest(struct android_usb_function *f, struct usb_composite_dev *cdev, const struct usb_ctrlrequest *c) { return acc_ctrlrequest(cdev, c); } static struct android_usb_function accessory_function = { .name = "accessory", .init = accessory_function_init, .cleanup = accessory_function_cleanup, .bind_config = accessory_function_bind_config, .ctrlrequest = accessory_function_ctrlrequest, }; #ifdef CONFIG_USB_ANDROID_PROJECTOR static int projector_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { f->config = kzalloc(sizeof(struct htcmode_protocol), GFP_KERNEL); if (!f->config) return -ENOMEM; return projector_setup(); } static void projector_function_cleanup(struct android_usb_function *f) { projector_cleanup(); if (f->config) { kfree(f->config); f->config = NULL; } } static int projector_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return projector_bind_config(c, f->config); } static ssize_t projector_product_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct htcmode_protocol *config = f->config; return snprintf(buf, PRODUCT_NAME_MAX, "%s\n", config->product_name); } static DEVICE_ATTR(product, S_IRUGO | S_IWUSR, projector_product_show, NULL); static ssize_t projector_car_model_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct htcmode_protocol *config = f->config; return snprintf(buf, CAR_MODEL_NAME_MAX, "%s\n", config->car_model); } static DEVICE_ATTR(car_model, S_IRUGO | S_IWUSR, projector_car_model_show, NULL); static ssize_t projector_width_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct htcmode_protocol *config = f->config; return snprintf(buf, PAGE_SIZE, "%d\n", config->server_info.width); } static DEVICE_ATTR(width, S_IRUGO | S_IWUSR, projector_width_show, NULL); static ssize_t projector_height_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct htcmode_protocol *config = f->config; return snprintf(buf, PAGE_SIZE, "%d\n", config->server_info.height); } static DEVICE_ATTR(height, S_IRUGO | S_IWUSR, projector_height_show, NULL); static ssize_t projector_rotation_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct htcmode_protocol *config = f->config; return snprintf(buf, PAGE_SIZE, "%d\n", (config->client_info.display_conf & CLIENT_INFO_SERVER_ROTATE_USED)); } static DEVICE_ATTR(rotation, S_IRUGO | S_IWUSR, projector_rotation_show, NULL); static ssize_t projector_version_show(struct device *dev, struct device_attribute *attr, char *buf) { struct android_usb_function *f = dev_get_drvdata(dev); struct htcmode_protocol *config = f->config; return snprintf(buf, PAGE_SIZE, "%d\n", config->version); } static DEVICE_ATTR(version, S_IRUGO | S_IWUSR, projector_version_show, NULL); static struct device_attribute *projector_function_attributes[] = { &dev_attr_product, &dev_attr_car_model, &dev_attr_width, &dev_attr_height, &dev_attr_rotation, &dev_attr_version, NULL }; struct android_usb_function projector_function = { .name = "projector", .init = projector_function_init, .cleanup = projector_function_cleanup, .bind_config = projector_function_bind_config, .attributes = projector_function_attributes }; #endif #ifdef CONFIG_USB_ANDROID_USBNET static int usbnet_function_init(struct android_usb_function *f, struct usb_composite_dev *cdev) { return usbnet_setup(); } static int usbnet_function_bind_config(struct android_usb_function *f, struct usb_configuration *c) { return usbnet_bind_config(c); } static int usbnet_function_ctrlrequest(struct android_usb_function *f, struct usb_composite_dev *cdev, const struct usb_ctrlrequest *c) { return usbnet_ctrlrequest(cdev, c); } struct android_usb_function usbnet_function = { .name = "usbnet", .init = usbnet_function_init, .bind_config = usbnet_function_bind_config, .ctrlrequest = usbnet_function_ctrlrequest, }; #endif static struct android_usb_function *supported_functions[] = { #if 1 #ifdef CONFIG_USB_ANDROID_RNDIS &rndis_function, #endif &accessory_function, #ifdef CONFIG_USB_ANDROID_MTP &mtp_function, &ptp_function, #endif &mass_storage_function, &adb_function, #ifdef CONFIG_USB_ANDROID_ECM &ecm_function, #endif &diag_function, &modem_function, #ifdef CONFIG_USB_ANDROID_MDM9K_MODEM &modem_mdm_function, #endif &serial_function, #ifdef CONFIG_USB_ANDROID_PROJECTOR &projector_function, #endif #ifdef CONFIG_USB_ANDROID_ACM &acm_function, #endif #if defined(CONFIG_USB_ANDROID_MDM9K_DIAG) &diag_mdm_function, #endif #if defined(CONFIG_USB_ANDROID_RMNET_SMD) &rmnet_smd_function, #elif defined(CONFIG_USB_ANDROID_RMNET_SDIO) &rmnet_sdio_function, #elif defined(CONFIG_USB_ANDROID_RMNET_SMD_SDIO) &rmnet_smd_sdio_function, #elif defined(CONFIG_USB_ANDROID_RMNET_BAM) &rmnet_function, #endif #if 0 &ccid_function, #endif #ifdef CONFIG_USB_ANDROID_USBNET &usbnet_function, #endif NULL #endif }; static int android_init_functions(struct android_usb_function **functions, struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; struct android_usb_function *f; struct device_attribute **attrs; struct device_attribute *attr; int err = 0; int index = 0; for (; (f = *functions++); index++) { f->dev_name = kasprintf(GFP_KERNEL, "f_%s", f->name); f->dev = device_create(android_class, dev->dev, MKDEV(0, index), f, f->dev_name); if (IS_ERR(f->dev)) { pr_err("%s: Failed to create dev %s", __func__, f->dev_name); err = PTR_ERR(f->dev); goto err_create; } if (device_create_file(f->dev, &dev_attr_on) < 0) { pr_err("%s: Failed to create dev file %s", __func__, f->dev_name); goto err_create; } if (f->init) { err = f->init(f, cdev); if (err) { pr_err("%s: Failed to init %s", __func__, f->name); goto err_out; } } attrs = f->attributes; if (attrs) { while ((attr = *attrs++) && !err) err = device_create_file(f->dev, attr); } if (err) { pr_err("%s: Failed to create function %s attributes", __func__, f->name); goto err_out; } pr_info("%s %s init\n", __func__, f->name); } return 0; err_out: device_destroy(android_class, f->dev->devt); err_create: kfree(f->dev_name); return err; } static void android_cleanup_functions(struct android_usb_function **functions) { struct android_usb_function *f; while (*functions) { f = *functions++; if (f->dev) { device_destroy(android_class, f->dev->devt); kfree(f->dev_name); } if (f->cleanup) f->cleanup(f); } } static int android_bind_enabled_functions(struct android_dev *dev, struct usb_configuration *c) { struct android_usb_function *f; int ret; list_for_each_entry(f, &dev->enabled_functions, enabled_list) { pr_info("%s bind name: %s\n", __func__, f->name); ret = f->bind_config(f, c); if (ret) { pr_err("%s: %s failed", __func__, f->name); return ret; } } return 0; } static void android_unbind_enabled_functions(struct android_dev *dev, struct usb_configuration *c) { struct android_usb_function *f; list_for_each_entry(f, &dev->enabled_functions, enabled_list) { if (f->unbind_config) f->unbind_config(f, c); } } static int android_enable_function(struct android_dev *dev, char *name) { struct android_usb_function **functions = dev->functions; struct android_usb_function *f; while ((f = *functions++)) { if (!strcmp(name, f->name)) { pr_info("%s: %s enabled\n", __func__, name); list_add_tail(&f->enabled_list, &dev->enabled_functions); return 0; } } pr_info("%s: %s failed\n", __func__, name); return -EINVAL; } /*-------------------------------------------------------------------------*/ /* /sys/class/android_usb/android%d/ interface */ static ssize_t remote_wakeup_show(struct device *pdev, struct device_attribute *attr, char *buf) { return snprintf(buf, PAGE_SIZE, "%d\n", !!(android_config_driver.bmAttributes & USB_CONFIG_ATT_WAKEUP)); } static ssize_t remote_wakeup_store(struct device *pdev, struct device_attribute *attr, const char *buff, size_t size) { int enable = 0; sscanf(buff, "%d", &enable); pr_debug("android_usb: %s remote wakeup\n", enable ? "enabling" : "disabling"); if (enable) android_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; else android_config_driver.bmAttributes &= ~USB_CONFIG_ATT_WAKEUP; return size; } static ssize_t functions_show(struct device *pdev, struct device_attribute *attr, char *buf) { struct android_dev *dev = dev_get_drvdata(pdev); struct android_usb_function *f; char *buff = buf; list_for_each_entry(f, &dev->enabled_functions, enabled_list) buff += snprintf(buff, PAGE_SIZE, "%s,", f->name); if (buff != buf) *(buff-1) = '\n'; return buff - buf; } /* TODO: replace by switch function and enable function */ static ssize_t functions_store(struct device *pdev, struct device_attribute *attr, const char *buff, size_t size) { struct android_dev *dev = dev_get_drvdata(pdev); char *name; char buf[256], *b; int err; pr_info("%s: buff: %s\n", __func__, buff); return size; INIT_LIST_HEAD(&dev->enabled_functions); strlcpy(buf, buff, sizeof(buf)); b = strim(buf); while (b) { name = strsep(&b, ","); if (name) { err = android_enable_function(dev, name); if (err) pr_err("android_usb: Cannot enable '%s'", name); } } return size; } static ssize_t enable_show(struct device *pdev, struct device_attribute *attr, char *buf) { struct android_dev *dev = dev_get_drvdata(pdev); return snprintf(buf, PAGE_SIZE, "%d\n", dev->enabled); } static ssize_t enable_store(struct device *pdev, struct device_attribute *attr, const char *buff, size_t size) { struct android_dev *dev = dev_get_drvdata(pdev); struct usb_composite_dev *cdev = dev->cdev; int enabled = 0; sscanf(buff, "%d", &enabled); if (enabled) htc_usb_enable_function("adb", 1); pr_info("%s, buff: %s\n", __func__, buff); /* temporaily return immediately to prevent framework change usb behavior */ return size; if (enabled && !dev->enabled) { /* update values in composite driver's copy of device descriptor */ cdev->desc.idVendor = device_desc.idVendor; cdev->desc.idProduct = device_desc.idProduct; cdev->desc.bcdDevice = device_desc.bcdDevice; cdev->desc.bDeviceClass = device_desc.bDeviceClass; cdev->desc.bDeviceSubClass = device_desc.bDeviceSubClass; cdev->desc.bDeviceProtocol = device_desc.bDeviceProtocol; if (usb_add_config(cdev, &android_config_driver, android_bind_config)) return size; usb_gadget_connect(cdev->gadget); dev->enabled = true; } else if (!enabled && dev->enabled) { usb_gadget_disconnect(cdev->gadget); usb_remove_config(cdev, &android_config_driver); dev->enabled = false; } else { pr_err("android_usb: already %s\n", dev->enabled ? "enabled" : "disabled"); } return size; } static ssize_t state_show(struct device *pdev, struct device_attribute *attr, char *buf) { struct android_dev *dev = dev_get_drvdata(pdev); struct usb_composite_dev *cdev = dev->cdev; char *state = "DISCONNECTED"; unsigned long flags; if (!cdev) goto out; spin_lock_irqsave(&cdev->lock, flags); if (cdev->config) state = "CONFIGURED"; else if (dev->connected) state = "CONNECTED"; spin_unlock_irqrestore(&cdev->lock, flags); out: return snprintf(buf, PAGE_SIZE, "%s\n", state); } #define DESCRIPTOR_ATTR(field, format_string) \ static ssize_t \ field ## _show(struct device *dev, struct device_attribute *attr, \ char *buf) \ { \ return snprintf(buf, PAGE_SIZE, \ format_string, device_desc.field); \ } \ static ssize_t \ field ## _store(struct device *dev, struct device_attribute *attr, \ const char *buf, size_t size) \ { \ int value; \ pr_info("%s: %s\n", __func__, buf); \ if (sscanf(buf, format_string, &value) == 1) { \ device_desc.field = value; \ return size; \ } \ return -1; \ } \ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, field ## _show, field ## _store); #define DESCRIPTOR_STRING_ATTR(field, buffer) \ static ssize_t \ field ## _show(struct device *dev, struct device_attribute *attr, \ char *buf) \ { \ return snprintf(buf, PAGE_SIZE, "%s", buffer); \ } \ static ssize_t \ field ## _store(struct device *dev, struct device_attribute *attr, \ const char *buf, size_t size) \ { \ pr_info("%s: %s\n", __func__, buf); \ if (size >= sizeof(buffer)) return -EINVAL; \ if (sscanf(buf, "%255s", buffer) == 1) { \ return size; \ } \ return -1; \ } \ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, field ## _show, field ## _store); DESCRIPTOR_ATTR(idVendor, "%04x\n") DESCRIPTOR_ATTR(idProduct, "%04x\n") DESCRIPTOR_ATTR(bcdDevice, "%04x\n") DESCRIPTOR_ATTR(bDeviceClass, "%d\n") DESCRIPTOR_ATTR(bDeviceSubClass, "%d\n") DESCRIPTOR_ATTR(bDeviceProtocol, "%d\n") DESCRIPTOR_STRING_ATTR(iManufacturer, manufacturer_string) DESCRIPTOR_STRING_ATTR(iProduct, product_string) DESCRIPTOR_STRING_ATTR(iSerial, serial_string) static DEVICE_ATTR(functions, S_IRUGO | S_IWUSR, functions_show, functions_store); static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store); static DEVICE_ATTR(state, S_IRUGO, state_show, NULL); static DEVICE_ATTR(remote_wakeup, S_IRUGO | S_IWUSR, remote_wakeup_show, remote_wakeup_store); static struct device_attribute *android_usb_attributes[] = { &dev_attr_idVendor, &dev_attr_idProduct, &dev_attr_bcdDevice, &dev_attr_bDeviceClass, &dev_attr_bDeviceSubClass, &dev_attr_bDeviceProtocol, &dev_attr_iManufacturer, &dev_attr_iProduct, &dev_attr_iSerial, &dev_attr_functions, &dev_attr_enable, &dev_attr_state, &dev_attr_remote_wakeup, NULL }; #include "htc_attr.c" /*-------------------------------------------------------------------------*/ /* Composite driver */ static int android_bind_config(struct usb_configuration *c) { struct android_dev *dev = _android_dev; int ret = 0; ret = android_bind_enabled_functions(dev, c); if (ret) return ret; return 0; } static void android_unbind_config(struct usb_configuration *c) { struct android_dev *dev = _android_dev; android_unbind_enabled_functions(dev, c); } static int android_bind(struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; struct android_usb_platform_data *pdata = _android_dev->pdata; struct usb_gadget *gadget = cdev->gadget; int gcnum, id, ret; usb_gadget_disconnect(gadget); ret = android_init_functions(dev->functions, cdev); if (ret) return ret; /* Allocate string descriptor numbers ... note that string * contents can be overridden by the composite_dev glue. */ id = usb_string_id(cdev); if (id < 0) return id; strings_dev[STRING_MANUFACTURER_IDX].id = id; device_desc.iManufacturer = id; id = usb_string_id(cdev); if (id < 0) return id; strings_dev[STRING_PRODUCT_IDX].id = id; device_desc.iProduct = id; dev->products = pdata->products; dev->num_products = pdata->num_products; dev->in_house_functions = pdata->functions; dev->num_functions = pdata->num_functions; dev->match = pdata->match; /* default String */ if (pdata->product_name) strlcpy(product_string, pdata->product_name, sizeof(product_string) - 1); if (pdata->manufacturer_name) strlcpy(manufacturer_string, pdata->manufacturer_name, sizeof(manufacturer_string) - 1); if (pdata->serial_number) strlcpy(serial_string, pdata->serial_number, sizeof(serial_string) - 1); id = usb_string_id(cdev); if (id < 0) return id; strings_dev[STRING_SERIAL_IDX].id = id; device_desc.iSerialNumber = id; gcnum = usb_gadget_controller_number(gadget); if (gcnum >= 0) device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); else { /* gadget zero is so simple (for now, no altsettings) that * it SHOULD NOT have problems with bulk-capable hardware. * so just warn about unrcognized controllers -- don't panic. * * things like configuration and altsetting numbering * can need hardware-specific attention though. */ pr_warning("%s: controller '%s' not recognized\n", longname, gadget->name); device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); } usb_gadget_set_selfpowered(gadget); dev->cdev = cdev; cdev->sw_connect2pc.name = "usb_connect2pc"; ret = switch_dev_register(&cdev->sw_connect2pc); if (ret < 0) pr_err("switch_dev_register fail:usb_connect2pc\n"); schedule_delayed_work(&dev->init_work, HZ); return 0; } static int android_usb_unbind(struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; cancel_work_sync(&dev->work); android_cleanup_functions(dev->functions); switch_dev_unregister(&cdev->sw_connect2pc); return 0; } static struct usb_composite_driver android_usb_driver = { .name = "android_usb", .dev = &device_desc, .strings = dev_strings, .unbind = android_usb_unbind, }; #ifdef CONFIG_USB_ANDROID_USBNET static struct work_struct reenumeration_work; static void do_reenumeration_work(struct work_struct *w) { struct android_dev *dev = _android_dev; int err, funcs, product_id; if (dev->enabled != true) { pr_info("%s: USB driver is not initialize\n", __func__); return; } mutex_lock(&function_bind_sem); funcs = htc_usb_get_func_combine_value(); usb_gadget_disconnect(dev->cdev->gadget); usb_remove_config(dev->cdev, &android_config_driver); INIT_LIST_HEAD(&dev->enabled_functions); if (funcs & (1 << USB_FUNCTION_ADB)) { err = android_enable_function(dev, "adb"); if (err) pr_err("android_usb: Cannot enable '%s'", "adb"); } err = android_enable_function(dev, "usbnet"); if (err) pr_err("android_usb: Cannot enable '%s'", "usbnet"); product_id = get_product_id(dev, &dev->enabled_functions); device_desc.idProduct = __constant_cpu_to_le16(product_id); dev->cdev->desc.idProduct = device_desc.idProduct; printk(KERN_INFO "%s:product_id = 0x%04x\n", __func__, product_id); usb_add_config(dev->cdev, &android_config_driver, android_bind_config); mdelay(100); usb_gadget_connect(dev->cdev->gadget); dev->enabled = true; mutex_unlock(&function_bind_sem); } static int handle_mode_switch(u16 switchIndex, struct usb_composite_dev *cdev) { switch (switchIndex) { case 0x1F: /* Enable the USBNet function and disable all others but adb */ printk(KERN_INFO "[USBNET] %s: 0x%02x\n", __func__, switchIndex); cdev->desc.bDeviceClass = USB_CLASS_COMM; break; /* Add other switch functions */ default: return -EOPNOTSUPP; } return 0; } static int android_switch_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) { int value = -EOPNOTSUPP; u16 wIndex = le16_to_cpu(c->wIndex); u16 wValue = le16_to_cpu(c->wValue); u16 wLength = le16_to_cpu(c->wLength); struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_request *req = cdev->req; /* struct android_dev *dev = _android_dev; */ switch (c->bRequestType & USB_TYPE_MASK) { case USB_TYPE_VENDOR: /* If the request is a mode switch , handle it */ if ((c->bRequest == 1) && (wValue == 0) && (wLength == 0)) { value = handle_mode_switch(wIndex, cdev); if (value != 0) return value; req->zero = 0; req->length = value; if (usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC)) printk(KERN_ERR "ep0 in queue failed\n"); /* force reenumeration */ schedule_work(&reenumeration_work); } break; /* Add Other type of requests here */ default: break; } return value; } #endif static int android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) { struct android_dev *dev = _android_dev; struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_request *req = cdev->req; struct android_usb_function *f; int value = -EOPNOTSUPP; unsigned long flags; req->zero = 0; req->complete = composite_setup_complete; req->length = 0; gadget->ep0->driver_data = cdev; #ifdef CONFIG_USB_ANDROID_USBNET value = android_switch_setup(gadget, c); if (value >= 0) return value; #endif list_for_each_entry(f, &dev->enabled_functions, enabled_list) { if (f->ctrlrequest) { value = f->ctrlrequest(f, cdev, c); if (value >= 0) break; } } /* Special case the accessory function. * It needs to handle control requests before it is enabled. */ if (value < 0) value = acc_ctrlrequest(cdev, c); #ifdef CONFIG_USB_ANDROID_PROJECTOR_HTC_MODE /* * The projector needs to handle control requests before it's enabled. */ if (value < 0) value = projector_ctrlrequest(cdev, c); #endif if (value < 0) value = composite_setup(gadget, c); spin_lock_irqsave(&cdev->lock, flags); if (!dev->connected) { dev->connected = 1; schedule_work(&dev->work); } else if (c->bRequest == USB_REQ_SET_CONFIGURATION && cdev->config) { schedule_work(&dev->work); } spin_unlock_irqrestore(&cdev->lock, flags); return value; } static void android_disconnect(struct usb_gadget *gadget) { struct android_dev *dev = _android_dev; struct usb_composite_dev *cdev = get_gadget_data(gadget); unsigned long flags; composite_disconnect(gadget); spin_lock_irqsave(&cdev->lock, flags); dev->connected = 0; schedule_work(&dev->work); spin_unlock_irqrestore(&cdev->lock, flags); /*android_switch_function is not called if removing usb cable. Without it, connect2pc may be blocked by is_mtp_enabled*/ is_mtp_enabled = false; } static void android_mute_disconnect(struct usb_gadget *gadget) { struct android_dev *dev = _android_dev; struct usb_composite_dev *cdev = get_gadget_data(gadget); unsigned long flags; composite_disconnect(gadget); /*changes USB_STATE only for MTP*/ if (is_mtp_enabled) { spin_lock_irqsave(&cdev->lock, flags); dev->connected = 0; schedule_work(&dev->work); spin_unlock_irqrestore(&cdev->lock, flags); } } static int android_create_device(struct android_dev *dev) { struct device_attribute **attrs = android_usb_attributes; struct device_attribute *attr; int err; dev->dev = device_create(android_class, NULL, MKDEV(0, 0), NULL, "android0"); if (IS_ERR(dev->dev)) return PTR_ERR(dev->dev); dev_set_drvdata(dev->dev, dev); while ((attr = *attrs++)) { err = device_create_file(dev->dev, attr); if (err) { device_destroy(android_class, dev->dev->devt); return err; } } return 0; } static void android_destroy_device(struct android_dev *dev) { struct device_attribute **attrs = android_usb_attributes; struct device_attribute *attr; while ((attr = *attrs++)) device_remove_file(dev->dev, attr); device_destroy(android_class, dev->dev->devt); } static int __devinit android_probe(struct platform_device *pdev) { struct android_usb_platform_data *pdata = pdev->dev.platform_data; struct android_dev *dev = _android_dev; dev->pdata = pdata; init_mfg_serialno(); if (sysfs_create_group(&pdev->dev.kobj, &android_usb_attr_group)) pr_err("%s: fail to create sysfs\n", __func__); return 0; } static struct platform_driver android_platform_driver = { .driver = { .name = "android_usb"}, }; static void android_usb_init_work(struct work_struct *data) { struct android_dev *dev = _android_dev; struct android_usb_platform_data *pdata = dev->pdata; struct usb_composite_dev *cdev = dev->cdev; int ret = 0; __u16 product_id; /* initial ums+adb by default */ ret = android_enable_function(dev, "mass_storage"); if (ret) pr_err("android_usb: Cannot enable '%s'", "mass_storage"); #if 0 ret = android_enable_function(dev, "adb"); if (ret) pr_err("android_usb: Cannot enable '%s'", "adb"); #endif /* initial function depends on radio flag */ if (pdata->diag_init) { ret = android_enable_function(dev, "diag"); if (ret) pr_err("android_usb: Cannot enable '%s'", "diag"); } if (pdata->modem_init) { ret = android_enable_function(dev, "modem"); if (ret) pr_err("android_usb: Cannot enable '%s'", "modem"); #if defined(CONFIG_USB_ANDROID_MDM9K_MODEM) ret = android_enable_function(dev, "modem_mdm"); if (ret) pr_err("android_usb: Cannot enable '%s'", "modem_mdm"); #endif } #if defined(CONFIG_USB_ANDROID_MDM9K_DIAG) if (pdata->diag_init) { ret = android_enable_function(dev, "diag_mdm"); if (ret) pr_err("android_usb: Cannot enable '%s'", "diag_mdm"); } #endif if (pdata->rmnet_init) { ret = android_enable_function(dev, "rmnet"); if (ret) pr_err("android_usb: Cannot enable '%s'", "rmnet"); } cdev->desc.idVendor = __constant_cpu_to_le16(pdata->vendor_id), product_id = get_product_id(dev, &dev->enabled_functions); if (dev->match) product_id = dev->match(product_id, intrsharing); cdev->desc.idProduct = __constant_cpu_to_le16(product_id), cdev->desc.bcdDevice = device_desc.bcdDevice; cdev->desc.bDeviceClass = device_desc.bDeviceClass; cdev->desc.bDeviceSubClass = device_desc.bDeviceSubClass; cdev->desc.bDeviceProtocol = device_desc.bDeviceProtocol; device_desc.idVendor = cdev->desc.idVendor; device_desc.idProduct = cdev->desc.idProduct; ret = usb_add_config(cdev, &android_config_driver, android_bind_config); usb_gadget_connect(cdev->gadget); dev->enabled = true; pr_info("%s: ret: %d\n", __func__, ret); } static int __init init(void) { struct android_dev *dev; int ret; connect2pc = false; android_class = class_create(THIS_MODULE, "android_usb"); if (IS_ERR(android_class)) return PTR_ERR(android_class); dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { pr_err("%s(): Failed to alloc memory for android_dev\n", __func__); class_destroy(android_class); return -ENOMEM; } dev->functions = supported_functions; dev->autobot_mode = 0; INIT_LIST_HEAD(&dev->enabled_functions); INIT_WORK(&dev->work, android_work); INIT_DELAYED_WORK(&dev->init_work, android_usb_init_work); #ifdef CONFIG_USB_ANDROID_USBNET INIT_WORK(&reenumeration_work, do_reenumeration_work); #endif ret = android_create_device(dev); if (ret) { pr_err("%s(): android_create_device failed\n", __func__); goto err_dev; } /* hold a performance lock if gadget driver need */ dev->bEnablePerfLock = 1; _android_dev = dev; wake_lock_init(&android_usb_idle_wake_lock, WAKE_LOCK_IDLE, "android_usb_idle"); #ifdef CONFIG_PERFLOCK perf_lock_init(&android_usb_perf_lock, PERF_LOCK_LOW, "android_usb"); #endif /* Override composite driver functions */ composite_driver.setup = android_setup; composite_driver.disconnect = android_disconnect; composite_driver.mute_disconnect = android_mute_disconnect; ret = platform_driver_probe(&android_platform_driver, android_probe); if (ret) { pr_err("%s(): Failed to register android" "platform driver\n", __func__); goto err_probe; } ret = usb_composite_probe(&android_usb_driver, android_bind); if (ret) { pr_err("%s(): Failed to register android" "composite driver\n", __func__); platform_driver_unregister(&android_platform_driver); goto err_probe; } return ret; err_probe: android_destroy_device(dev); err_dev: kfree(dev); class_destroy(android_class); return ret; } module_init(init); static void __exit cleanup(void) { wake_lock_destroy(&android_usb_idle_wake_lock); usb_composite_unregister(&android_usb_driver); class_destroy(android_class); kfree(_android_dev); _android_dev = NULL; } module_exit(cleanup);
zarboz/Ville-Test
drivers/usb/gadget/android.c
C
gpl-2.0
66,517
#include <stdlib.h> #include <gmodule.h> #include <clutter/clutter.h> #define PATH_DESCRIPTION \ "M 0, 0 " \ "L 0, 300 " \ "L 300, 300 " \ "L 300, 0 " \ "L 0, 0" static gboolean toggled = FALSE; static gboolean on_button_press (ClutterActor *actor, const ClutterEvent *event, gpointer dummy G_GNUC_UNUSED) { if (!toggled) clutter_actor_animate (actor, CLUTTER_EASE_OUT_CUBIC, 500, "@constraints.path.offset", 1.0, NULL); else clutter_actor_animate (actor, CLUTTER_EASE_OUT_CUBIC, 500, "@constraints.path.offset", 0.0, NULL); toggled = !toggled; return TRUE; } static gchar * node_to_string (const ClutterPathNode *node) { GString *buffer = g_string_sized_new (256); gsize len = 0, i; switch (node->type) { case CLUTTER_PATH_MOVE_TO: g_string_append (buffer, "move-to "); len = 1; break; case CLUTTER_PATH_LINE_TO: g_string_append (buffer, "line-to "); len = 1; break; case CLUTTER_PATH_CURVE_TO: g_string_append (buffer, "curve-to "); len = 3; break; case CLUTTER_PATH_CLOSE: g_string_append (buffer, "close"); len = 0; break; default: break; } for (i = 0; i < len; i++) { if (i == 0) g_string_append (buffer, "[ "); g_string_append_printf (buffer, "[ %d, %d ]", node->points[i].x, node->points[i].y); if (i == len - 1) g_string_append (buffer, " ]"); } return g_string_free (buffer, FALSE); } static void on_node_reached (ClutterPathConstraint *constraint, ClutterActor *actor, guint index_) { ClutterPath *path = clutter_path_constraint_get_path (constraint); ClutterPathNode node; gchar *str; clutter_path_get_node (path, index_, &node); str = node_to_string (&node); g_print ("Node %d reached: %s\n", index_, str); g_free (str); } G_MODULE_EXPORT int test_path_constraint_main (int argc, char *argv[]) { ClutterActor *stage, *rect; ClutterPath *path; ClutterColor rect_color = { 0xcc, 0x00, 0x00, 0xff }; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Path Constraint"); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); path = clutter_path_new (); clutter_path_set_description (path, PATH_DESCRIPTION); rect = clutter_rectangle_new (); clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &rect_color); clutter_actor_set_size (rect, 128, 128); clutter_actor_set_reactive (rect, TRUE); clutter_actor_add_constraint_with_name (rect, "path", clutter_path_constraint_new (path, 0.0)); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); g_signal_connect (rect, "button-press-event", G_CALLBACK (on_button_press), NULL); g_signal_connect (clutter_actor_get_constraint (rect, "path"), "node-reached", G_CALLBACK (on_node_reached), NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
halfline/mutter
clutter/tests/interactive/test-path-constraint.c
C
gpl-2.0
3,427
<!DOCTYPE html> <!-- Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or http://ckeditor.com/license --> <html> <head> <title>UI Color Picker &mdash; CKEditor Sample</title> <meta charset="utf-8"> <script src="../ckeditor.js"></script> <link rel="stylesheet" href="sample.css"> </head> <body> <h1 class="samples"> <a href="index.html">CKEditor Samples</a> &raquo; UI Color </h1> <div class="description"> <p> This sample shows how to automatically replace <code>&lt;textarea&gt;</code> elements with a CKEditor instance with an option to change the color of its user interface.<br> <strong>Note:</strong>The UI skin color feature depends on the CKEditor skin compatibility. The Moono and Kama skins are examples of skins that work with it. </p> </div> <form action="sample_posteddata.php" method="post"> <p> This editor instance has a UI color value defined in configuration to change the skin color, To specify the color of the user interface, set the <code>uiColor</code> property: </p> <pre class="samples"> CKEDITOR.replace( '<em>textarea_id</em>', { <strong>uiColor: '#14B8C4'</strong> });</pre> <p> Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of the <code>&lt;textarea&gt;</code> element to be replaced. </p> <p> <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea> <script> // Replace the <textarea id="editor"> with an CKEditor // instance, using default configurations. CKEDITOR.replace( 'editor1', { uiColor: '#14B8C4', toolbar: [ [ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ], [ 'FontSize', 'TextColor', 'BGColor' ] ] }); </script> </p> <p> <input type="submit" value="Submit"> </p> </form> <div id="footer"> <hr> <p> CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> </p> <p id="copy"> Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved. </p> </div> </body> </html>
RUSL-Sayuri/sayuri-info
web/assests/js/plugin/ckeditor/samples/uicolor.html
HTML
gpl-2.0
2,338
/* * drivers/mb862xx/mb862xxfb.c * * Fujitsu Carmine/Coral-P(A)/Lime framebuffer driver * * (C) 2008 Anatolij Gustschin <agust@denx.de> * DENX Software Engineering * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #undef DEBUG #include <linux/fb.h> #include <linux/delay.h> #include <linux/uaccess.h> #include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/pci.h> #if defined(CONFIG_OF) #include <linux/of_platform.h> #endif #include "mb862xxfb.h" #include "mb862xx_reg.h" #define NR_PALETTE 256 #define MB862XX_MEM_SIZE 0x1000000 #define CORALP_MEM_SIZE 0x2000000 #define CARMINE_MEM_SIZE 0x8000000 #define DRV_NAME "mb862xxfb" #if defined(CONFIG_SOCRATES) static struct mb862xx_gc_mode socrates_gc_mode = { /* Mode for Prime View PM070WL4 TFT LCD Panel */ { "800x480", 45, 800, 480, 40000, 86, 42, 33, 10, 128, 2, 0, 0, 0 }, /* 16 bits/pixel, 16MB, 133MHz, SDRAM memory mode value */ 16, 0x1000000, GC_CCF_COT_133, 0x4157ba63 }; #endif /* Helpers */ static inline int h_total(struct fb_var_screeninfo *var) { return var->xres + var->left_margin + var->right_margin + var->hsync_len; } static inline int v_total(struct fb_var_screeninfo *var) { return var->yres + var->upper_margin + var->lower_margin + var->vsync_len; } static inline int hsp(struct fb_var_screeninfo *var) { return var->xres + var->right_margin - 1; } static inline int vsp(struct fb_var_screeninfo *var) { return var->yres + var->lower_margin - 1; } static inline int d_pitch(struct fb_var_screeninfo *var) { return var->xres * var->bits_per_pixel / 8; } static inline unsigned int chan_to_field(unsigned int chan, struct fb_bitfield *bf) { chan &= 0xffff; chan >>= 16 - bf->length; return chan << bf->offset; } static int mb862xxfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { struct mb862xxfb_par *par = info->par; unsigned int val; switch (info->fix.visual) { case FB_VISUAL_TRUECOLOR: if (regno < 16) { val = chan_to_field(red, &info->var.red); val |= chan_to_field(green, &info->var.green); val |= chan_to_field(blue, &info->var.blue); par->pseudo_palette[regno] = val; } break; case FB_VISUAL_PSEUDOCOLOR: if (regno < 256) { val = (red >> 8) << 16; val |= (green >> 8) << 8; val |= blue >> 8; outreg(disp, GC_L0PAL0 + (regno * 4), val); } break; default: return 1; /* unsupported type */ } return 0; } static int mb862xxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fbi) { unsigned long tmp; if (fbi->dev) dev_dbg(fbi->dev, "%s\n", __func__); /* check if these values fit into the registers */ if (var->hsync_len > 255 || var->vsync_len > 255) return -EINVAL; if ((var->xres + var->right_margin) >= 4096) return -EINVAL; if ((var->yres + var->lower_margin) > 4096) return -EINVAL; if (h_total(var) > 4096 || v_total(var) > 4096) return -EINVAL; if (var->xres_virtual > 4096 || var->yres_virtual > 4096) return -EINVAL; if (var->bits_per_pixel <= 8) var->bits_per_pixel = 8; else if (var->bits_per_pixel <= 16) var->bits_per_pixel = 16; else if (var->bits_per_pixel <= 32) var->bits_per_pixel = 32; /* * can cope with 8,16 or 24/32bpp if resulting * pitch is divisible by 64 without remainder */ if (d_pitch(&fbi->var) % GC_L0M_L0W_UNIT) { int r; var->bits_per_pixel = 0; do { var->bits_per_pixel += 8; r = d_pitch(&fbi->var) % GC_L0M_L0W_UNIT; } while (r && var->bits_per_pixel <= 32); if (d_pitch(&fbi->var) % GC_L0M_L0W_UNIT) return -EINVAL; } /* line length is going to be 128 bit aligned */ tmp = (var->xres * var->bits_per_pixel) / 8; if ((tmp & 15) != 0) return -EINVAL; /* set r/g/b positions and validate bpp */ switch (var->bits_per_pixel) { case 8: var->red.length = var->bits_per_pixel; var->green.length = var->bits_per_pixel; var->blue.length = var->bits_per_pixel; var->red.offset = 0; var->green.offset = 0; var->blue.offset = 0; var->transp.length = 0; break; case 16: var->red.length = 5; var->green.length = 5; var->blue.length = 5; var->red.offset = 10; var->green.offset = 5; var->blue.offset = 0; var->transp.length = 0; break; case 24: case 32: var->transp.length = 8; var->red.length = 8; var->green.length = 8; var->blue.length = 8; var->transp.offset = 24; var->red.offset = 16; var->green.offset = 8; var->blue.offset = 0; break; default: return -EINVAL; } return 0; } /* * set display parameters */ static int mb862xxfb_set_par(struct fb_info *fbi) { struct mb862xxfb_par *par = fbi->par; unsigned long reg, sc; dev_dbg(par->dev, "%s\n", __func__); if (par->type == BT_CORALP) mb862xxfb_init_accel(fbi, fbi->var.xres); if (par->pre_init) return 0; /* disp off */ reg = inreg(disp, GC_DCM1); reg &= ~GC_DCM01_DEN; outreg(disp, GC_DCM1, reg); /* set display reference clock div. */ sc = par->refclk / (1000000 / fbi->var.pixclock) - 1; reg = inreg(disp, GC_DCM1); reg &= ~(GC_DCM01_CKS | GC_DCM01_RESV | GC_DCM01_SC); reg |= sc << 8; outreg(disp, GC_DCM1, reg); dev_dbg(par->dev, "SC 0x%lx\n", sc); /* disp dimension, format */ reg = pack(d_pitch(&fbi->var) / GC_L0M_L0W_UNIT, (fbi->var.yres - 1)); if (fbi->var.bits_per_pixel == 16) reg |= GC_L0M_L0C_16; outreg(disp, GC_L0M, reg); if (fbi->var.bits_per_pixel == 32) { reg = inreg(disp, GC_L0EM); outreg(disp, GC_L0EM, reg | GC_L0EM_L0EC_24); } outreg(disp, GC_WY_WX, 0); reg = pack(fbi->var.yres - 1, fbi->var.xres); outreg(disp, GC_WH_WW, reg); outreg(disp, GC_L0OA0, 0); outreg(disp, GC_L0DA0, 0); outreg(disp, GC_L0DY_L0DX, 0); outreg(disp, GC_L0WY_L0WX, 0); outreg(disp, GC_L0WH_L0WW, reg); /* both HW-cursors off */ reg = inreg(disp, GC_CPM_CUTC); reg &= ~(GC_CPM_CEN0 | GC_CPM_CEN1); outreg(disp, GC_CPM_CUTC, reg); /* timings */ reg = pack(fbi->var.xres - 1, fbi->var.xres - 1); outreg(disp, GC_HDB_HDP, reg); reg = pack((fbi->var.yres - 1), vsp(&fbi->var)); outreg(disp, GC_VDP_VSP, reg); reg = ((fbi->var.vsync_len - 1) << 24) | pack((fbi->var.hsync_len - 1), hsp(&fbi->var)); outreg(disp, GC_VSW_HSW_HSP, reg); outreg(disp, GC_HTP, pack(h_total(&fbi->var) - 1, 0)); outreg(disp, GC_VTR, pack(v_total(&fbi->var) - 1, 0)); /* display on */ reg = inreg(disp, GC_DCM1); reg |= GC_DCM01_DEN | GC_DCM01_L0E; reg &= ~GC_DCM01_ESY; outreg(disp, GC_DCM1, reg); return 0; } static int mb862xxfb_pan(struct fb_var_screeninfo *var, struct fb_info *info) { struct mb862xxfb_par *par = info->par; unsigned long reg; reg = pack(var->yoffset, var->xoffset); outreg(disp, GC_L0WY_L0WX, reg); reg = pack(info->var.yres_virtual, info->var.xres_virtual); outreg(disp, GC_L0WH_L0WW, reg); return 0; } static int mb862xxfb_blank(int mode, struct fb_info *fbi) { struct mb862xxfb_par *par = fbi->par; unsigned long reg; dev_dbg(fbi->dev, "blank mode=%d\n", mode); switch (mode) { case FB_BLANK_POWERDOWN: reg = inreg(disp, GC_DCM1); reg &= ~GC_DCM01_DEN; outreg(disp, GC_DCM1, reg); break; case FB_BLANK_UNBLANK: reg = inreg(disp, GC_DCM1); reg |= GC_DCM01_DEN; outreg(disp, GC_DCM1, reg); break; case FB_BLANK_NORMAL: case FB_BLANK_VSYNC_SUSPEND: case FB_BLANK_HSYNC_SUSPEND: default: return 1; } return 0; } static int mb862xxfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) { struct mb862xxfb_par *par = fbi->par; struct mb862xx_l1_cfg *l1_cfg = &par->l1_cfg; void __user *argp = (void __user *)arg; int *enable; u32 l1em = 0; switch (cmd) { case MB862XX_L1_GET_CFG: if (copy_to_user(argp, l1_cfg, sizeof(*l1_cfg))) return -EFAULT; break; case MB862XX_L1_SET_CFG: if (copy_from_user(l1_cfg, argp, sizeof(*l1_cfg))) return -EFAULT; if (l1_cfg->dh == 0 || l1_cfg->dw == 0) return -EINVAL; if ((l1_cfg->sw >= l1_cfg->dw) && (l1_cfg->sh >= l1_cfg->dh)) { /* downscaling */ outreg(cap, GC_CAP_CSC, pack((l1_cfg->sh << 11) / l1_cfg->dh, (l1_cfg->sw << 11) / l1_cfg->dw)); l1em = inreg(disp, GC_L1EM); l1em &= ~GC_L1EM_DM; } else if ((l1_cfg->sw <= l1_cfg->dw) && (l1_cfg->sh <= l1_cfg->dh)) { /* upscaling */ outreg(cap, GC_CAP_CSC, pack((l1_cfg->sh << 11) / l1_cfg->dh, (l1_cfg->sw << 11) / l1_cfg->dw)); outreg(cap, GC_CAP_CMSS, pack(l1_cfg->sw >> 1, l1_cfg->sh)); outreg(cap, GC_CAP_CMDS, pack(l1_cfg->dw >> 1, l1_cfg->dh)); l1em = inreg(disp, GC_L1EM); l1em |= GC_L1EM_DM; } if (l1_cfg->mirror) { outreg(cap, GC_CAP_CBM, inreg(cap, GC_CAP_CBM) | GC_CBM_HRV); l1em |= l1_cfg->dw * 2 - 8; } else { outreg(cap, GC_CAP_CBM, inreg(cap, GC_CAP_CBM) & ~GC_CBM_HRV); l1em &= 0xffff0000; } outreg(disp, GC_L1EM, l1em); break; case MB862XX_L1_ENABLE: enable = (int *)arg; if (*enable) { outreg(disp, GC_L1DA, par->cap_buf); outreg(cap, GC_CAP_IMG_START, pack(l1_cfg->sy >> 1, l1_cfg->sx)); outreg(cap, GC_CAP_IMG_END, pack(l1_cfg->sh, l1_cfg->sw)); outreg(disp, GC_L1M, GC_L1M_16 | GC_L1M_YC | GC_L1M_CS | (par->l1_stride << 16)); outreg(disp, GC_L1WY_L1WX, pack(l1_cfg->dy, l1_cfg->dx)); outreg(disp, GC_L1WH_L1WW, pack(l1_cfg->dh - 1, l1_cfg->dw)); outreg(disp, GC_DLS, 1); outreg(cap, GC_CAP_VCM, GC_VCM_VIE | GC_VCM_CM | GC_VCM_VS_PAL); outreg(disp, GC_DCM1, inreg(disp, GC_DCM1) | GC_DCM1_DEN | GC_DCM1_L1E); } else { outreg(cap, GC_CAP_VCM, inreg(cap, GC_CAP_VCM) & ~GC_VCM_VIE); outreg(disp, GC_DCM1, inreg(disp, GC_DCM1) & ~GC_DCM1_L1E); } break; case MB862XX_L1_CAP_CTL: enable = (int *)arg; if (*enable) { outreg(cap, GC_CAP_VCM, inreg(cap, GC_CAP_VCM) | GC_VCM_VIE); } else { outreg(cap, GC_CAP_VCM, inreg(cap, GC_CAP_VCM) & ~GC_VCM_VIE); } break; default: return -EINVAL; } return 0; } /* framebuffer ops */ static struct fb_ops mb862xxfb_ops = { .owner = THIS_MODULE, .fb_check_var = mb862xxfb_check_var, .fb_set_par = mb862xxfb_set_par, .fb_setcolreg = mb862xxfb_setcolreg, .fb_blank = mb862xxfb_blank, .fb_pan_display = mb862xxfb_pan, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_ioctl = mb862xxfb_ioctl, }; /* initialize fb_info data */ static int mb862xxfb_init_fbinfo(struct fb_info *fbi) { struct mb862xxfb_par *par = fbi->par; struct mb862xx_gc_mode *mode = par->gc_mode; unsigned long reg; int stride; fbi->fbops = &mb862xxfb_ops; fbi->pseudo_palette = par->pseudo_palette; fbi->screen_base = par->fb_base; fbi->screen_size = par->mapped_vram; strcpy(fbi->fix.id, DRV_NAME); fbi->fix.smem_start = (unsigned long)par->fb_base_phys; fbi->fix.mmio_start = (unsigned long)par->mmio_base_phys; fbi->fix.mmio_len = par->mmio_len; fbi->fix.accel = FB_ACCEL_NONE; fbi->fix.type = FB_TYPE_PACKED_PIXELS; fbi->fix.type_aux = 0; fbi->fix.xpanstep = 1; fbi->fix.ypanstep = 1; fbi->fix.ywrapstep = 0; reg = inreg(disp, GC_DCM1); if (reg & GC_DCM01_DEN && reg & GC_DCM01_L0E) { /* get the disp mode from active display cfg */ unsigned long sc = ((reg & GC_DCM01_SC) >> 8) + 1; unsigned long hsp, vsp, ht, vt; dev_dbg(par->dev, "using bootloader's disp. mode\n"); fbi->var.pixclock = (sc * 1000000) / par->refclk; fbi->var.xres = (inreg(disp, GC_HDB_HDP) & 0x0fff) + 1; reg = inreg(disp, GC_VDP_VSP); fbi->var.yres = ((reg >> 16) & 0x0fff) + 1; vsp = (reg & 0x0fff) + 1; fbi->var.xres_virtual = fbi->var.xres; fbi->var.yres_virtual = fbi->var.yres; reg = inreg(disp, GC_L0EM); if (reg & GC_L0EM_L0EC_24) { fbi->var.bits_per_pixel = 32; } else { reg = inreg(disp, GC_L0M); if (reg & GC_L0M_L0C_16) fbi->var.bits_per_pixel = 16; else fbi->var.bits_per_pixel = 8; } reg = inreg(disp, GC_VSW_HSW_HSP); fbi->var.hsync_len = ((reg & 0xff0000) >> 16) + 1; fbi->var.vsync_len = ((reg & 0x3f000000) >> 24) + 1; hsp = (reg & 0xffff) + 1; ht = ((inreg(disp, GC_HTP) & 0xfff0000) >> 16) + 1; fbi->var.right_margin = hsp - fbi->var.xres; fbi->var.left_margin = ht - hsp - fbi->var.hsync_len; vt = ((inreg(disp, GC_VTR) & 0xfff0000) >> 16) + 1; fbi->var.lower_margin = vsp - fbi->var.yres; fbi->var.upper_margin = vt - vsp - fbi->var.vsync_len; } else if (mode) { dev_dbg(par->dev, "using supplied mode\n"); fb_videomode_to_var(&fbi->var, (struct fb_videomode *)mode); fbi->var.bits_per_pixel = mode->def_bpp ? mode->def_bpp : 8; } else { int ret; ret = fb_find_mode(&fbi->var, fbi, "640x480-16@60", NULL, 0, NULL, 16); if (ret == 0 || ret == 4) { dev_err(par->dev, "failed to get initial mode\n"); return -EINVAL; } } fbi->var.xoffset = 0; fbi->var.yoffset = 0; fbi->var.grayscale = 0; fbi->var.nonstd = 0; fbi->var.height = -1; fbi->var.width = -1; fbi->var.accel_flags = 0; fbi->var.vmode = FB_VMODE_NONINTERLACED; fbi->var.activate = FB_ACTIVATE_NOW; fbi->flags = FBINFO_DEFAULT | #ifdef __BIG_ENDIAN FBINFO_FOREIGN_ENDIAN | #endif FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN; /* check and possibly fix bpp */ if ((fbi->fbops->fb_check_var)(&fbi->var, fbi)) dev_err(par->dev, "check_var() failed on initial setup?\n"); fbi->fix.visual = fbi->var.bits_per_pixel == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; fbi->fix.line_length = (fbi->var.xres_virtual * fbi->var.bits_per_pixel) / 8; fbi->fix.smem_len = fbi->fix.line_length * fbi->var.yres_virtual; /* * reserve space for capture buffers and two cursors * at the end of vram: 720x576 * 2 * 2.2 + 64x64 * 16. */ par->cap_buf = par->mapped_vram - 0x1bd800 - 0x10000; par->cap_len = 0x1bd800; par->l1_cfg.sx = 0; par->l1_cfg.sy = 0; par->l1_cfg.sw = 720; par->l1_cfg.sh = 576; par->l1_cfg.dx = 0; par->l1_cfg.dy = 0; par->l1_cfg.dw = 720; par->l1_cfg.dh = 576; stride = par->l1_cfg.sw * (fbi->var.bits_per_pixel / 8); par->l1_stride = stride / 64 + ((stride % 64) ? 1 : 0); outreg(cap, GC_CAP_CBM, GC_CBM_OO | GC_CBM_CBST | (par->l1_stride << 16)); outreg(cap, GC_CAP_CBOA, par->cap_buf); outreg(cap, GC_CAP_CBLA, par->cap_buf + par->cap_len); return 0; } /* * show some display controller and cursor registers */ static ssize_t mb862xxfb_show_dispregs(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *fbi = dev_get_drvdata(dev); struct mb862xxfb_par *par = fbi->par; char *ptr = buf; unsigned int reg; for (reg = GC_DCM0; reg <= GC_L0DY_L0DX; reg += 4) ptr += sprintf(ptr, "%08x = %08x\n", reg, inreg(disp, reg)); for (reg = GC_CPM_CUTC; reg <= GC_CUY1_CUX1; reg += 4) ptr += sprintf(ptr, "%08x = %08x\n", reg, inreg(disp, reg)); for (reg = GC_DCM1; reg <= GC_L0WH_L0WW; reg += 4) ptr += sprintf(ptr, "%08x = %08x\n", reg, inreg(disp, reg)); for (reg = 0x400; reg <= 0x410; reg += 4) ptr += sprintf(ptr, "geo %08x = %08x\n", reg, inreg(geo, reg)); for (reg = 0x400; reg <= 0x410; reg += 4) ptr += sprintf(ptr, "draw %08x = %08x\n", reg, inreg(draw, reg)); for (reg = 0x440; reg <= 0x450; reg += 4) ptr += sprintf(ptr, "draw %08x = %08x\n", reg, inreg(draw, reg)); return ptr - buf; } static DEVICE_ATTR(dispregs, 0444, mb862xxfb_show_dispregs, NULL); static irqreturn_t mb862xx_intr(int irq, void *dev_id) { struct mb862xxfb_par *par = (struct mb862xxfb_par *) dev_id; unsigned long reg_ist, mask; if (!par) return IRQ_NONE; if (par->type == BT_CARMINE) { /* Get Interrupt Status */ reg_ist = inreg(ctrl, GC_CTRL_STATUS); mask = inreg(ctrl, GC_CTRL_INT_MASK); if (reg_ist == 0) return IRQ_HANDLED; reg_ist &= mask; if (reg_ist == 0) return IRQ_HANDLED; /* Clear interrupt status */ outreg(ctrl, 0x0, reg_ist); } else { /* Get status */ reg_ist = inreg(host, GC_IST); mask = inreg(host, GC_IMASK); reg_ist &= mask; if (reg_ist == 0) return IRQ_HANDLED; /* Clear status */ outreg(host, GC_IST, ~reg_ist); } return IRQ_HANDLED; } #if defined(CONFIG_FB_MB862XX_LIME) /* * GDC (Lime, Coral(B/Q), Mint, ...) on host bus */ static int mb862xx_gdc_init(struct mb862xxfb_par *par) { unsigned long ccf, mmr; unsigned long ver, rev; if (!par) return -ENODEV; #if defined(CONFIG_FB_PRE_INIT_FB) par->pre_init = 1; #endif par->host = par->mmio_base; par->i2c = par->mmio_base + MB862XX_I2C_BASE; par->disp = par->mmio_base + MB862XX_DISP_BASE; par->cap = par->mmio_base + MB862XX_CAP_BASE; par->draw = par->mmio_base + MB862XX_DRAW_BASE; par->geo = par->mmio_base + MB862XX_GEO_BASE; par->pio = par->mmio_base + MB862XX_PIO_BASE; par->refclk = GC_DISP_REFCLK_400; ver = inreg(host, GC_CID); rev = inreg(pio, GC_REVISION); if ((ver == 0x303) && (rev & 0xffffff00) == 0x20050100) { dev_info(par->dev, "Fujitsu Lime v1.%d found\n", (int)rev & 0xff); par->type = BT_LIME; ccf = par->gc_mode ? par->gc_mode->ccf : GC_CCF_COT_100; mmr = par->gc_mode ? par->gc_mode->mmr : 0x414fb7f2; } else { dev_info(par->dev, "? GDC, CID/Rev.: 0x%lx/0x%lx \n", ver, rev); return -ENODEV; } if (!par->pre_init) { outreg(host, GC_CCF, ccf); udelay(200); outreg(host, GC_MMR, mmr); udelay(10); } /* interrupt status */ outreg(host, GC_IST, 0); outreg(host, GC_IMASK, GC_INT_EN); return 0; } static int of_platform_mb862xx_probe(struct platform_device *ofdev) { struct device_node *np = ofdev->dev.of_node; struct device *dev = &ofdev->dev; struct mb862xxfb_par *par; struct fb_info *info; struct resource res; resource_size_t res_size; unsigned long ret = -ENODEV; if (of_address_to_resource(np, 0, &res)) { dev_err(dev, "Invalid address\n"); return -ENXIO; } info = framebuffer_alloc(sizeof(struct mb862xxfb_par), dev); if (info == NULL) { dev_err(dev, "cannot allocate framebuffer\n"); return -ENOMEM; } par = info->par; par->info = info; par->dev = dev; par->irq = irq_of_parse_and_map(np, 0); if (par->irq == NO_IRQ) { dev_err(dev, "failed to map irq\n"); ret = -ENODEV; goto fbrel; } res_size = resource_size(&res); par->res = request_mem_region(res.start, res_size, DRV_NAME); if (par->res == NULL) { dev_err(dev, "Cannot claim framebuffer/mmio\n"); ret = -ENXIO; goto irqdisp; } #if defined(CONFIG_SOCRATES) par->gc_mode = &socrates_gc_mode; #endif par->fb_base_phys = res.start; par->mmio_base_phys = res.start + MB862XX_MMIO_BASE; par->mmio_len = MB862XX_MMIO_SIZE; if (par->gc_mode) par->mapped_vram = par->gc_mode->max_vram; else par->mapped_vram = MB862XX_MEM_SIZE; par->fb_base = ioremap(par->fb_base_phys, par->mapped_vram); if (par->fb_base == NULL) { dev_err(dev, "Cannot map framebuffer\n"); goto rel_reg; } par->mmio_base = ioremap(par->mmio_base_phys, par->mmio_len); if (par->mmio_base == NULL) { dev_err(dev, "Cannot map registers\n"); goto fb_unmap; } dev_dbg(dev, "fb phys 0x%llx 0x%lx\n", (u64)par->fb_base_phys, (ulong)par->mapped_vram); dev_dbg(dev, "mmio phys 0x%llx 0x%lx, (irq = %d)\n", (u64)par->mmio_base_phys, (ulong)par->mmio_len, par->irq); if (mb862xx_gdc_init(par)) goto io_unmap; if (request_irq(par->irq, mb862xx_intr, 0, DRV_NAME, (void *)par)) { dev_err(dev, "Cannot request irq\n"); goto io_unmap; } mb862xxfb_init_fbinfo(info); if (fb_alloc_cmap(&info->cmap, NR_PALETTE, 0) < 0) { dev_err(dev, "Could not allocate cmap for fb_info.\n"); goto free_irq; } if ((info->fbops->fb_set_par)(info)) dev_err(dev, "set_var() failed on initial setup?\n"); if (register_framebuffer(info)) { dev_err(dev, "failed to register framebuffer\n"); goto rel_cmap; } dev_set_drvdata(dev, info); if (device_create_file(dev, &dev_attr_dispregs)) dev_err(dev, "Can't create sysfs regdump file\n"); return 0; rel_cmap: fb_dealloc_cmap(&info->cmap); free_irq: outreg(host, GC_IMASK, 0); free_irq(par->irq, (void *)par); io_unmap: iounmap(par->mmio_base); fb_unmap: iounmap(par->fb_base); rel_reg: release_mem_region(res.start, res_size); irqdisp: irq_dispose_mapping(par->irq); fbrel: framebuffer_release(info); return ret; } static int of_platform_mb862xx_remove(struct platform_device *ofdev) { struct fb_info *fbi = dev_get_drvdata(&ofdev->dev); struct mb862xxfb_par *par = fbi->par; resource_size_t res_size = resource_size(par->res); unsigned long reg; dev_dbg(fbi->dev, "%s release\n", fbi->fix.id); /* display off */ reg = inreg(disp, GC_DCM1); reg &= ~(GC_DCM01_DEN | GC_DCM01_L0E); outreg(disp, GC_DCM1, reg); /* disable interrupts */ outreg(host, GC_IMASK, 0); free_irq(par->irq, (void *)par); irq_dispose_mapping(par->irq); device_remove_file(&ofdev->dev, &dev_attr_dispregs); unregister_framebuffer(fbi); fb_dealloc_cmap(&fbi->cmap); iounmap(par->mmio_base); iounmap(par->fb_base); release_mem_region(par->res->start, res_size); framebuffer_release(fbi); return 0; } /* * common types */ static struct of_device_id of_platform_mb862xx_tbl[] = { { .compatible = "fujitsu,MB86276", }, { .compatible = "fujitsu,lime", }, { .compatible = "fujitsu,MB86277", }, { .compatible = "fujitsu,mint", }, { .compatible = "fujitsu,MB86293", }, { .compatible = "fujitsu,MB86294", }, { .compatible = "fujitsu,coral", }, { /* end */ } }; static struct platform_driver of_platform_mb862xxfb_driver = { .driver = { .name = DRV_NAME, .of_match_table = of_platform_mb862xx_tbl, }, .probe = of_platform_mb862xx_probe, .remove = of_platform_mb862xx_remove, }; #endif #if defined(CONFIG_FB_MB862XX_PCI_GDC) static int coralp_init(struct mb862xxfb_par *par) { int cn, ver; par->host = par->mmio_base; par->i2c = par->mmio_base + MB862XX_I2C_BASE; par->disp = par->mmio_base + MB862XX_DISP_BASE; par->cap = par->mmio_base + MB862XX_CAP_BASE; par->draw = par->mmio_base + MB862XX_DRAW_BASE; par->geo = par->mmio_base + MB862XX_GEO_BASE; par->pio = par->mmio_base + MB862XX_PIO_BASE; par->refclk = GC_DISP_REFCLK_400; if (par->mapped_vram >= 0x2000000) { /* relocate gdc registers space */ writel(1, par->fb_base + MB862XX_MMIO_BASE + GC_RSW); udelay(1); /* wait at least 20 bus cycles */ } ver = inreg(host, GC_CID); cn = (ver & GC_CID_CNAME_MSK) >> 8; ver = ver & GC_CID_VERSION_MSK; if (cn == 3) { unsigned long reg; dev_info(par->dev, "Fujitsu Coral-%s GDC Rev.%d found\n",\ (ver == 6) ? "P" : (ver == 8) ? "PA" : "?", par->pdev->revision); reg = inreg(disp, GC_DCM1); if (reg & GC_DCM01_DEN && reg & GC_DCM01_L0E) par->pre_init = 1; if (!par->pre_init) { outreg(host, GC_CCF, GC_CCF_CGE_166 | GC_CCF_COT_133); udelay(200); outreg(host, GC_MMR, GC_MMR_CORALP_EVB_VAL); udelay(10); } /* Clear interrupt status */ outreg(host, GC_IST, 0); } else { return -ENODEV; } mb862xx_i2c_init(par); return 0; } static int init_dram_ctrl(struct mb862xxfb_par *par) { unsigned long i = 0; /* * Set io mode first! Spec. says IC may be destroyed * if not set to SSTL2/LVCMOS before init. */ outreg(dram_ctrl, GC_DCTL_IOCONT1_IOCONT0, GC_EVB_DCTL_IOCONT1_IOCONT0); /* DRAM init */ outreg(dram_ctrl, GC_DCTL_MODE_ADD, GC_EVB_DCTL_MODE_ADD); outreg(dram_ctrl, GC_DCTL_SETTIME1_EMODE, GC_EVB_DCTL_SETTIME1_EMODE); outreg(dram_ctrl, GC_DCTL_REFRESH_SETTIME2, GC_EVB_DCTL_REFRESH_SETTIME2); outreg(dram_ctrl, GC_DCTL_RSV2_RSV1, GC_EVB_DCTL_RSV2_RSV1); outreg(dram_ctrl, GC_DCTL_DDRIF2_DDRIF1, GC_EVB_DCTL_DDRIF2_DDRIF1); outreg(dram_ctrl, GC_DCTL_RSV0_STATES, GC_EVB_DCTL_RSV0_STATES); /* DLL reset done? */ while ((inreg(dram_ctrl, GC_DCTL_RSV0_STATES) & GC_DCTL_STATES_MSK)) { udelay(GC_DCTL_INIT_WAIT_INTERVAL); if (i++ > GC_DCTL_INIT_WAIT_CNT) { dev_err(par->dev, "VRAM init failed.\n"); return -EINVAL; } } outreg(dram_ctrl, GC_DCTL_MODE_ADD, GC_EVB_DCTL_MODE_ADD_AFT_RST); outreg(dram_ctrl, GC_DCTL_RSV0_STATES, GC_EVB_DCTL_RSV0_STATES_AFT_RST); return 0; } static int carmine_init(struct mb862xxfb_par *par) { unsigned long reg; par->ctrl = par->mmio_base + MB86297_CTRL_BASE; par->i2c = par->mmio_base + MB86297_I2C_BASE; par->disp = par->mmio_base + MB86297_DISP0_BASE; par->disp1 = par->mmio_base + MB86297_DISP1_BASE; par->cap = par->mmio_base + MB86297_CAP0_BASE; par->cap1 = par->mmio_base + MB86297_CAP1_BASE; par->draw = par->mmio_base + MB86297_DRAW_BASE; par->dram_ctrl = par->mmio_base + MB86297_DRAMCTRL_BASE; par->wrback = par->mmio_base + MB86297_WRBACK_BASE; par->refclk = GC_DISP_REFCLK_533; /* warm up */ reg = GC_CTRL_CLK_EN_DRAM | GC_CTRL_CLK_EN_2D3D | GC_CTRL_CLK_EN_DISP0; outreg(ctrl, GC_CTRL_CLK_ENABLE, reg); /* check for engine module revision */ if (inreg(draw, GC_2D3D_REV) == GC_RE_REVISION) dev_info(par->dev, "Fujitsu Carmine GDC Rev.%d found\n", par->pdev->revision); else goto err_init; reg &= ~GC_CTRL_CLK_EN_2D3D; outreg(ctrl, GC_CTRL_CLK_ENABLE, reg); /* set up vram */ if (init_dram_ctrl(par) < 0) goto err_init; outreg(ctrl, GC_CTRL_INT_MASK, 0); return 0; err_init: outreg(ctrl, GC_CTRL_CLK_ENABLE, 0); return -EINVAL; } static inline int mb862xx_pci_gdc_init(struct mb862xxfb_par *par) { switch (par->type) { case BT_CORALP: return coralp_init(par); case BT_CARMINE: return carmine_init(par); default: return -ENODEV; } } #define CHIP_ID(id) \ { PCI_DEVICE(PCI_VENDOR_ID_FUJITSU_LIMITED, id) } static struct pci_device_id mb862xx_pci_tbl[] = { /* MB86295/MB86296 */ CHIP_ID(PCI_DEVICE_ID_FUJITSU_CORALP), CHIP_ID(PCI_DEVICE_ID_FUJITSU_CORALPA), /* MB86297 */ CHIP_ID(PCI_DEVICE_ID_FUJITSU_CARMINE), { 0, } }; MODULE_DEVICE_TABLE(pci, mb862xx_pci_tbl); static int mb862xx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct mb862xxfb_par *par; struct fb_info *info; struct device *dev = &pdev->dev; int ret; ret = pci_enable_device(pdev); if (ret < 0) { dev_err(dev, "Cannot enable PCI device\n"); goto out; } info = framebuffer_alloc(sizeof(struct mb862xxfb_par), dev); if (!info) { dev_err(dev, "framebuffer alloc failed\n"); ret = -ENOMEM; goto dis_dev; } par = info->par; par->info = info; par->dev = dev; par->pdev = pdev; par->irq = pdev->irq; ret = pci_request_regions(pdev, DRV_NAME); if (ret < 0) { dev_err(dev, "Cannot reserve region(s) for PCI device\n"); goto rel_fb; } switch (pdev->device) { case PCI_DEVICE_ID_FUJITSU_CORALP: case PCI_DEVICE_ID_FUJITSU_CORALPA: par->fb_base_phys = pci_resource_start(par->pdev, 0); par->mapped_vram = CORALP_MEM_SIZE; if (par->mapped_vram >= 0x2000000) { par->mmio_base_phys = par->fb_base_phys + MB862XX_MMIO_HIGH_BASE; } else { par->mmio_base_phys = par->fb_base_phys + MB862XX_MMIO_BASE; } par->mmio_len = MB862XX_MMIO_SIZE; par->type = BT_CORALP; break; case PCI_DEVICE_ID_FUJITSU_CARMINE: par->fb_base_phys = pci_resource_start(par->pdev, 2); par->mmio_base_phys = pci_resource_start(par->pdev, 3); par->mmio_len = pci_resource_len(par->pdev, 3); par->mapped_vram = CARMINE_MEM_SIZE; par->type = BT_CARMINE; break; default: /* should never occur */ ret = -EIO; goto rel_reg; } par->fb_base = ioremap(par->fb_base_phys, par->mapped_vram); if (par->fb_base == NULL) { dev_err(dev, "Cannot map framebuffer\n"); ret = -EIO; goto rel_reg; } par->mmio_base = ioremap(par->mmio_base_phys, par->mmio_len); if (par->mmio_base == NULL) { dev_err(dev, "Cannot map registers\n"); ret = -EIO; goto fb_unmap; } dev_dbg(dev, "fb phys 0x%llx 0x%lx\n", (unsigned long long)par->fb_base_phys, (ulong)par->mapped_vram); dev_dbg(dev, "mmio phys 0x%llx 0x%lx\n", (unsigned long long)par->mmio_base_phys, (ulong)par->mmio_len); ret = mb862xx_pci_gdc_init(par); if (ret) goto io_unmap; ret = request_irq(par->irq, mb862xx_intr, IRQF_SHARED, DRV_NAME, (void *)par); if (ret) { dev_err(dev, "Cannot request irq\n"); goto io_unmap; } mb862xxfb_init_fbinfo(info); if (fb_alloc_cmap(&info->cmap, NR_PALETTE, 0) < 0) { dev_err(dev, "Could not allocate cmap for fb_info.\n"); ret = -ENOMEM; goto free_irq; } if ((info->fbops->fb_set_par)(info)) dev_err(dev, "set_var() failed on initial setup?\n"); ret = register_framebuffer(info); if (ret < 0) { dev_err(dev, "failed to register framebuffer\n"); goto rel_cmap; } pci_set_drvdata(pdev, info); if (device_create_file(dev, &dev_attr_dispregs)) dev_err(dev, "Can't create sysfs regdump file\n"); if (par->type == BT_CARMINE) outreg(ctrl, GC_CTRL_INT_MASK, GC_CARMINE_INT_EN); else outreg(host, GC_IMASK, GC_INT_EN); return 0; rel_cmap: fb_dealloc_cmap(&info->cmap); free_irq: free_irq(par->irq, (void *)par); io_unmap: iounmap(par->mmio_base); fb_unmap: iounmap(par->fb_base); rel_reg: pci_release_regions(pdev); rel_fb: framebuffer_release(info); dis_dev: pci_disable_device(pdev); out: return ret; } static void mb862xx_pci_remove(struct pci_dev *pdev) { struct fb_info *fbi = pci_get_drvdata(pdev); struct mb862xxfb_par *par = fbi->par; unsigned long reg; dev_dbg(fbi->dev, "%s release\n", fbi->fix.id); /* display off */ reg = inreg(disp, GC_DCM1); reg &= ~(GC_DCM01_DEN | GC_DCM01_L0E); outreg(disp, GC_DCM1, reg); if (par->type == BT_CARMINE) { outreg(ctrl, GC_CTRL_INT_MASK, 0); outreg(ctrl, GC_CTRL_CLK_ENABLE, 0); } else { outreg(host, GC_IMASK, 0); } mb862xx_i2c_exit(par); device_remove_file(&pdev->dev, &dev_attr_dispregs); unregister_framebuffer(fbi); fb_dealloc_cmap(&fbi->cmap); free_irq(par->irq, (void *)par); iounmap(par->mmio_base); iounmap(par->fb_base); pci_release_regions(pdev); framebuffer_release(fbi); pci_disable_device(pdev); } static struct pci_driver mb862xxfb_pci_driver = { .name = DRV_NAME, .id_table = mb862xx_pci_tbl, .probe = mb862xx_pci_probe, .remove = mb862xx_pci_remove, }; #endif static int mb862xxfb_init(void) { int ret = -ENODEV; #if defined(CONFIG_FB_MB862XX_LIME) ret = platform_driver_register(&of_platform_mb862xxfb_driver); #endif #if defined(CONFIG_FB_MB862XX_PCI_GDC) ret = pci_register_driver(&mb862xxfb_pci_driver); #endif return ret; } static void __exit mb862xxfb_exit(void) { #if defined(CONFIG_FB_MB862XX_LIME) platform_driver_unregister(&of_platform_mb862xxfb_driver); #endif #if defined(CONFIG_FB_MB862XX_PCI_GDC) pci_unregister_driver(&mb862xxfb_pci_driver); #endif } module_init(mb862xxfb_init); module_exit(mb862xxfb_exit); MODULE_DESCRIPTION("Fujitsu MB862xx Framebuffer driver"); MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); MODULE_LICENSE("GPL v2");
triplekill/linux
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
C
gpl-2.0
30,686
/** * eCryptfs: Linux filesystem encryption layer * This is where eCryptfs coordinates the symmetric encryption and * decryption of the file data as it passes between the lower * encrypted file and the upper decrypted file. * * Copyright (C) 1997-2003 Erez Zadok * Copyright (C) 2001-2003 Stony Brook University * Copyright (C) 2004-2007 International Business Machines Corp. * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> * * 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 <linux/pagemap.h> #include <linux/writeback.h> #include <linux/page-flags.h> #include <linux/mount.h> #include <linux/file.h> #include <linux/crypto.h> #include <linux/scatterlist.h> #include <linux/slab.h> #include <asm/unaligned.h> #include "ecryptfs_kernel.h" /** * ecryptfs_get_locked_page * * Get one page from cache or lower f/s, return error otherwise. * * Returns locked and up-to-date page (if ok), with increased * refcnt. */ struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index) { struct page *page = read_mapping_page(inode->i_mapping, index, NULL); if (!IS_ERR(page)) lock_page(page); return page; } /** * ecryptfs_writepage * @page: Page that is locked before this call is made * * Returns zero on success; non-zero otherwise * * This is where we encrypt the data and pass the encrypted data to * the lower filesystem. In OpenPGP-compatible mode, we operate on * entire underlying packets. */ static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc) { int rc; rc = ecryptfs_encrypt_page(page); if (rc) { ecryptfs_printk(KERN_WARNING, "Error encrypting " "page (upper index [0x%.16lx])\n", page->index); ClearPageUptodate(page); goto out; } SetPageUptodate(page); out: unlock_page(page); return rc; } static void strip_xattr_flag(char *page_virt, struct ecryptfs_crypt_stat *crypt_stat) { if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { size_t written; crypt_stat->flags &= ~ECRYPTFS_METADATA_IN_XATTR; ecryptfs_write_crypt_stat_flags(page_virt, crypt_stat, &written); crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR; } } /** * Header Extent: * Octets 0-7: Unencrypted file size (big-endian) * Octets 8-15: eCryptfs special marker * Octets 16-19: Flags * Octet 16: File format version number (between 0 and 255) * Octets 17-18: Reserved * Octet 19: Bit 1 (lsb): Reserved * Bit 2: Encrypted? * Bits 3-8: Reserved * Octets 20-23: Header extent size (big-endian) * Octets 24-25: Number of header extents at front of file * (big-endian) * Octet 26: Begin RFC 2440 authentication token packet set */ /** * ecryptfs_copy_up_encrypted_with_header * @page: Sort of a ``virtual'' representation of the encrypted lower * file. The actual lower file does not have the metadata in * the header. This is locked. * @crypt_stat: The eCryptfs inode's cryptographic context * * The ``view'' is the version of the file that userspace winds up * seeing, with the header information inserted. */ static int ecryptfs_copy_up_encrypted_with_header(struct page *page, struct ecryptfs_crypt_stat *crypt_stat) { loff_t extent_num_in_page = 0; loff_t num_extents_per_page = (PAGE_CACHE_SIZE / crypt_stat->extent_size); int rc = 0; while (extent_num_in_page < num_extents_per_page) { loff_t view_extent_num = ((((loff_t)page->index) * num_extents_per_page) + extent_num_in_page); size_t num_header_extents_at_front = (crypt_stat->metadata_size / crypt_stat->extent_size); if (view_extent_num < num_header_extents_at_front) { /* This is a header extent */ char *page_virt; page_virt = kmap_atomic(page); memset(page_virt, 0, PAGE_CACHE_SIZE); /* TODO: Support more than one header extent */ if (view_extent_num == 0) { size_t written; rc = ecryptfs_read_xattr_region( page_virt, page->mapping->host); strip_xattr_flag(page_virt + 16, crypt_stat); ecryptfs_write_header_metadata(page_virt + 20, crypt_stat, &written); } kunmap_atomic(page_virt); flush_dcache_page(page); if (rc) { printk(KERN_ERR "%s: Error reading xattr " "region; rc = [%d]\n", __func__, rc); goto out; } } else { /* This is an encrypted data extent */ loff_t lower_offset = ((view_extent_num * crypt_stat->extent_size) - crypt_stat->metadata_size); rc = ecryptfs_read_lower_page_segment( page, (lower_offset >> PAGE_CACHE_SHIFT), (lower_offset & ~PAGE_CACHE_MASK), crypt_stat->extent_size, page->mapping->host); if (rc) { printk(KERN_ERR "%s: Error attempting to read " "extent at offset [%lld] in the lower " "file; rc = [%d]\n", __func__, lower_offset, rc); goto out; } } extent_num_in_page++; } out: return rc; } /** * ecryptfs_readpage * @file: An eCryptfs file * @page: Page from eCryptfs inode mapping into which to stick the read data * * Read in a page, decrypting if necessary. * * Returns zero on success; non-zero on error. */ static int ecryptfs_readpage(struct file *file, struct page *page) { struct ecryptfs_crypt_stat *crypt_stat = &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat; int rc = 0; if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { rc = ecryptfs_read_lower_page_segment(page, page->index, 0, PAGE_CACHE_SIZE, page->mapping->host); } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) { if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { rc = ecryptfs_copy_up_encrypted_with_header(page, crypt_stat); if (rc) { printk(KERN_ERR "%s: Error attempting to copy " "the encrypted content from the lower " "file whilst inserting the metadata " "from the xattr into the header; rc = " "[%d]\n", __func__, rc); goto out; } } else { rc = ecryptfs_read_lower_page_segment( page, page->index, 0, PAGE_CACHE_SIZE, page->mapping->host); if (rc) { printk(KERN_ERR "Error reading page; rc = " "[%d]\n", rc); goto out; } } } else { rc = ecryptfs_decrypt_page(page); if (rc) { ecryptfs_printk(KERN_ERR, "Error decrypting page; " "rc = [%d]\n", rc); goto out; } } out: if (rc) ClearPageUptodate(page); else SetPageUptodate(page); ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16lx]\n", page->index); unlock_page(page); return rc; } /** * Called with lower inode mutex held. */ static int fill_zeros_to_end_of_page(struct page *page, unsigned int to) { struct inode *inode = page->mapping->host; int end_byte_in_page; if ((i_size_read(inode) / PAGE_CACHE_SIZE) != page->index) goto out; end_byte_in_page = i_size_read(inode) % PAGE_CACHE_SIZE; if (to > end_byte_in_page) end_byte_in_page = to; zero_user_segment(page, end_byte_in_page, PAGE_CACHE_SIZE); out: return 0; } /** * ecryptfs_write_begin * @file: The eCryptfs file * @mapping: The eCryptfs object * @pos: The file offset at which to start writing * @len: Length of the write * @flags: Various flags * @pagep: Pointer to return the page * @fsdata: Pointer to return fs data (unused) * * This function must zero any hole we create * * Returns zero on success; non-zero otherwise */ static int ecryptfs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) { pgoff_t index = pos >> PAGE_CACHE_SHIFT; struct page *page; loff_t prev_page_end_size; int rc = 0; page = grab_cache_page_write_begin(mapping, index, flags); if (!page) return -ENOMEM; *pagep = page; prev_page_end_size = ((loff_t)index << PAGE_CACHE_SHIFT); if (!PageUptodate(page)) { struct ecryptfs_crypt_stat *crypt_stat = &ecryptfs_inode_to_private(mapping->host)->crypt_stat; if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { rc = ecryptfs_read_lower_page_segment( page, index, 0, PAGE_CACHE_SIZE, mapping->host); if (rc) { printk(KERN_ERR "%s: Error attemping to read " "lower page segment; rc = [%d]\n", __func__, rc); ClearPageUptodate(page); goto out; } else SetPageUptodate(page); } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) { if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { rc = ecryptfs_copy_up_encrypted_with_header( page, crypt_stat); if (rc) { printk(KERN_ERR "%s: Error attempting " "to copy the encrypted content " "from the lower file whilst " "inserting the metadata from " "the xattr into the header; rc " "= [%d]\n", __func__, rc); ClearPageUptodate(page); goto out; } SetPageUptodate(page); } else { rc = ecryptfs_read_lower_page_segment( page, index, 0, PAGE_CACHE_SIZE, mapping->host); if (rc) { printk(KERN_ERR "%s: Error reading " "page; rc = [%d]\n", __func__, rc); ClearPageUptodate(page); goto out; } SetPageUptodate(page); } } else { if (prev_page_end_size >= i_size_read(page->mapping->host)) { zero_user(page, 0, PAGE_CACHE_SIZE); } else { rc = ecryptfs_decrypt_page(page); if (rc) { printk(KERN_ERR "%s: Error decrypting " "page at index [%ld]; " "rc = [%d]\n", __func__, page->index, rc); ClearPageUptodate(page); goto out; } } SetPageUptodate(page); } } /* If creating a page or more of holes, zero them out via truncate. * Note, this will increase i_size. */ if (index != 0) { if (prev_page_end_size > i_size_read(page->mapping->host)) { rc = ecryptfs_truncate(file->f_path.dentry, prev_page_end_size); if (rc) { printk(KERN_ERR "%s: Error on attempt to " "truncate to (higher) offset [%lld];" " rc = [%d]\n", __func__, prev_page_end_size, rc); goto out; } } } /* Writing to a new page, and creating a small hole from start * of page? Zero it out. */ if ((i_size_read(mapping->host) == prev_page_end_size) && (pos != 0)) zero_user(page, 0, PAGE_CACHE_SIZE); out: if (unlikely(rc)) { unlock_page(page); page_cache_release(page); *pagep = NULL; } return rc; } /** * ecryptfs_write_inode_size_to_header * * Writes the lower file size to the first 8 bytes of the header. * * Returns zero on success; non-zero on error. */ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) { char *file_size_virt; int rc; file_size_virt = kmalloc(sizeof(u64), GFP_KERNEL); if (!file_size_virt) { rc = -ENOMEM; goto out; } put_unaligned_be64(i_size_read(ecryptfs_inode), file_size_virt); rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0, sizeof(u64)); kfree(file_size_virt); if (rc < 0) printk(KERN_ERR "%s: Error writing file size to header; " "rc = [%d]\n", __func__, rc); else rc = 0; out: return rc; } struct kmem_cache *ecryptfs_xattr_cache; static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) { ssize_t size; void *xattr_virt; struct dentry *lower_dentry = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; struct inode *lower_inode = lower_dentry->d_inode; int rc; if (!lower_inode->i_op->getxattr || !lower_inode->i_op->setxattr) { printk(KERN_WARNING "No support for setting xattr in lower filesystem\n"); rc = -ENOSYS; goto out; } xattr_virt = kmem_cache_alloc(ecryptfs_xattr_cache, GFP_KERNEL); if (!xattr_virt) { printk(KERN_ERR "Out of memory whilst attempting to write " "inode size to xattr\n"); rc = -ENOMEM; goto out; } mutex_lock(&lower_inode->i_mutex); size = lower_inode->i_op->getxattr(lower_dentry, ECRYPTFS_XATTR_NAME, xattr_virt, PAGE_CACHE_SIZE); if (size < 0) size = 8; put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, xattr_virt, size, 0); mutex_unlock(&lower_inode->i_mutex); if (rc) printk(KERN_ERR "Error whilst attempting to write inode size " "to lower file xattr; rc = [%d]\n", rc); kmem_cache_free(ecryptfs_xattr_cache, xattr_virt); out: return rc; } int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode) { struct ecryptfs_crypt_stat *crypt_stat; crypt_stat = &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)); if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) return ecryptfs_write_inode_size_to_xattr(ecryptfs_inode); else return ecryptfs_write_inode_size_to_header(ecryptfs_inode); } /** * ecryptfs_write_end * @file: The eCryptfs file object * @mapping: The eCryptfs object * @pos: The file position * @len: The length of the data (unused) * @copied: The amount of data copied * @page: The eCryptfs page * @fsdata: The fsdata (unused) */ static int ecryptfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) { pgoff_t index = pos >> PAGE_CACHE_SHIFT; unsigned from = pos & (PAGE_CACHE_SIZE - 1); unsigned to = from + copied; struct inode *ecryptfs_inode = mapping->host; struct ecryptfs_crypt_stat *crypt_stat = &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; int rc; ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" "(page w/ index = [0x%.16lx], to = [%d])\n", index, to); if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0, to); if (!rc) { rc = copied; fsstack_copy_inode_size(ecryptfs_inode, ecryptfs_inode_to_lower(ecryptfs_inode)); } goto out; } /* Fills in zeros if 'to' goes beyond inode size */ rc = fill_zeros_to_end_of_page(page, to); if (rc) { ecryptfs_printk(KERN_WARNING, "Error attempting to fill " "zeros in page with index = [0x%.16lx]\n", index); goto out; } rc = ecryptfs_encrypt_page(page); if (rc) { ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper " "index [0x%.16lx])\n", index); goto out; } if (pos + copied > i_size_read(ecryptfs_inode)) { i_size_write(ecryptfs_inode, pos + copied); ecryptfs_printk(KERN_DEBUG, "Expanded file size to " "[0x%.16llx]\n", (unsigned long long)i_size_read(ecryptfs_inode)); } rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode); if (rc) printk(KERN_ERR "Error writing inode size to metadata; " "rc = [%d]\n", rc); else rc = copied; out: unlock_page(page); page_cache_release(page); return rc; } static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block) { int rc = 0; struct inode *inode; struct inode *lower_inode; inode = (struct inode *)mapping->host; lower_inode = ecryptfs_inode_to_lower(inode); if (lower_inode->i_mapping->a_ops->bmap) rc = lower_inode->i_mapping->a_ops->bmap(lower_inode->i_mapping, block); return rc; } const struct address_space_operations ecryptfs_aops = { .writepage = ecryptfs_writepage, .readpage = ecryptfs_readpage, .write_begin = ecryptfs_write_begin, .write_end = ecryptfs_write_end, .bmap = ecryptfs_bmap, };
ronasimi/aosp-kernel_lge_geeb
fs/ecryptfs/mmap.c
C
gpl-2.0
16,190
/* * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /* * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /** ------------------------------------------------------------------------- * ------------------------------------------------------------------------- * \file csrLinkList.c Implementation for the Common link list interfaces. Copyright (C) 2006 Airgo Networks, Incorporated ========================================================================== */ #include "palApi.h" #include "csrLinkList.h" #include "vos_lock.h" #include "vos_memory.h" #include "vos_trace.h" ANI_INLINE_FUNCTION void csrListInit(tListElem *pList) { pList->last = pList->next = pList; } ANI_INLINE_FUNCTION void csrListRemoveEntry(tListElem *pEntry) { tListElem *pLast; tListElem *pNext; pLast = pEntry->last; pNext = pEntry->next; pLast->next = pNext; pNext->last = pLast; } ANI_INLINE_FUNCTION tListElem * csrListRemoveHead(tListElem *pHead) { tListElem *pEntry; tListElem *pNext; pEntry = pHead->next; pNext = pEntry->next; pHead->next = pNext; pNext->last = pHead; return (pEntry); } ANI_INLINE_FUNCTION tListElem * csrListRemoveTail(tListElem *pHead) { tListElem *pEntry; tListElem *pLast; pEntry = pHead->last; pLast = pEntry->last; pHead->last = pLast; pLast->next = pHead; return (pEntry); } ANI_INLINE_FUNCTION void csrListInsertTail(tListElem *pHead, tListElem *pEntry) { tListElem *pLast; pLast = pHead->last; pEntry->last = pLast; pEntry->next = pHead; pLast->next = pEntry; pHead->last = pEntry; } ANI_INLINE_FUNCTION void csrListInsertHead(tListElem *pHead, tListElem *pEntry) { tListElem *pNext; pNext = pHead->next; pEntry->next = pNext; pEntry->last = pHead; pNext->last = pEntry; pHead->next = pEntry; } //Insert pNewEntry before pEntry void csrListInsertEntry(tListElem *pEntry, tListElem *pNewEntry) { tListElem *pLast; if( !pEntry) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pEntry is Null", __func__); return; } pLast = pEntry->last; pLast->next = pNewEntry; pEntry->last = pNewEntry; pNewEntry->next = pEntry; pNewEntry->last = pLast; } tANI_U32 csrLLCount( tDblLinkList *pList ) { tANI_U32 c = 0; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return c; } if ( pList && ( LIST_FLAG_OPEN == pList->Flag ) ) { c = pList->Count; } return( c ); } void csrLLLock( tDblLinkList *pList ) { if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return ; } if ( LIST_FLAG_OPEN == pList->Flag ) { vos_lock_acquire(&pList->Lock); } } void csrLLUnlock( tDblLinkList *pList ) { if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return ; } if ( LIST_FLAG_OPEN == pList->Flag ) { vos_lock_release(&pList->Lock); } } tANI_BOOLEAN csrLLIsListEmpty( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ) { tANI_BOOLEAN fEmpty = eANI_BOOLEAN_TRUE; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return fEmpty ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if(fInterlocked) { csrLLLock(pList); } fEmpty = csrIsListEmpty( &pList->ListHead ); if(fInterlocked) { csrLLUnlock(pList); } } return( fEmpty ); } tANI_BOOLEAN csrLLFindEntry( tDblLinkList *pList, tListElem *pEntryToFind ) { tANI_BOOLEAN fFound = eANI_BOOLEAN_FALSE; tListElem *pEntry; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return fFound ; } if ( LIST_FLAG_OPEN == pList->Flag ) { pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); // Have to make sure we don't loop back to the head of the list, which will // happen if the entry is NOT on the list... while( pEntry && ( pEntry != &pList->ListHead ) ) { if ( pEntry == pEntryToFind ) { fFound = eANI_BOOLEAN_TRUE; break; } pEntry = pEntry->next; } } return( fFound ); } eHalStatus csrLLOpen( tHddHandle hHdd, tDblLinkList *pList ) { eHalStatus status = eHAL_STATUS_SUCCESS; VOS_STATUS vosStatus; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return eHAL_STATUS_FAILURE ; } if ( LIST_FLAG_OPEN != pList->Flag ) { pList->Count = 0; vosStatus = vos_lock_init(&pList->Lock); if(VOS_IS_STATUS_SUCCESS(vosStatus)) { csrListInit( &pList->ListHead ); pList->Flag = LIST_FLAG_OPEN; pList->hHdd = hHdd; } else { status = eHAL_STATUS_FAILURE; } } return (status); } void csrLLClose( tDblLinkList *pList ) { if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return ; } if ( LIST_FLAG_OPEN == pList->Flag ) { // Make sure the list is empty... csrLLPurge( pList, LL_ACCESS_LOCK ); vos_lock_destroy( &pList->Lock ); pList->Flag = LIST_FLAG_CLOSE; } } void csrLLInsertTail( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ) { if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return; } if ( LIST_FLAG_OPEN == pList->Flag ) { if(fInterlocked) { csrLLLock(pList); } csrListInsertTail( &pList->ListHead, pEntry ); pList->Count++; if(fInterlocked) { csrLLUnlock(pList); } } } void csrLLInsertHead( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ) { if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return; } if ( LIST_FLAG_OPEN == pList->Flag ) { if(fInterlocked) { csrLLLock(pList); } csrListInsertHead( &pList->ListHead, pEntry ); pList->Count++; if(fInterlocked) { csrLLUnlock(pList); } } } void csrLLInsertEntry( tDblLinkList *pList, tListElem *pEntry, tListElem *pNewEntry, tANI_BOOLEAN fInterlocked ) { if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if(fInterlocked) { csrLLLock(pList); } csrListInsertEntry( pEntry, pNewEntry ); pList->Count++; if(fInterlocked) { csrLLUnlock(pList); } } } tListElem *csrLLRemoveTail( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ) { tListElem *pEntry = NULL; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return pEntry ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } if ( !csrIsListEmpty(&pList->ListHead) ) { pEntry = csrListRemoveTail( &pList->ListHead ); pList->Count--; } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( pEntry ); } tListElem *csrLLPeekTail( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ) { tListElem *pEntry = NULL; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return pEntry ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } if ( !csrIsListEmpty(&pList->ListHead) ) { pEntry = pList->ListHead.last; } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( pEntry ); } tListElem *csrLLRemoveHead( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ) { tListElem *pEntry = NULL; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return pEntry ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } if ( !csrIsListEmpty(&pList->ListHead) ) { pEntry = csrListRemoveHead( &pList->ListHead ); pList->Count--; } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( pEntry ); } tListElem *csrLLPeekHead( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ) { tListElem *pEntry = NULL; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return pEntry ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } if ( !csrIsListEmpty(&pList->ListHead) ) { pEntry = pList->ListHead.next; } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( pEntry ); } void csrLLPurge( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ) { tListElem *pEntry; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } while( (pEntry = csrLLRemoveHead( pList, LL_ACCESS_NOLOCK )) ) { // just remove everything from the list until // nothing left on the list. } if ( fInterlocked ) { csrLLUnlock( pList ); } } } tANI_BOOLEAN csrLLRemoveEntry( tDblLinkList *pList, tListElem *pEntryToRemove, tANI_BOOLEAN fInterlocked ) { tANI_BOOLEAN fFound = eANI_BOOLEAN_FALSE; tListElem *pEntry; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return fFound; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); // Have to make sure we don't loop back to the head of the list, which will // happen if the entry is NOT on the list... while( pEntry && ( pEntry != &pList->ListHead ) ) { if ( pEntry == pEntryToRemove ) { csrListRemoveEntry( pEntry ); pList->Count--; fFound = eANI_BOOLEAN_TRUE; break; } pEntry = pEntry->next; } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( fFound ); } tListElem *csrLLNext( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ) { tListElem *pNextEntry = NULL; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return pNextEntry ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } if ( !csrIsListEmpty(&pList->ListHead) && csrLLFindEntry( pList, pEntry ) ) { pNextEntry = pEntry->next; //Make sure we don't walk past the head if ( pNextEntry == &pList->ListHead ) { pNextEntry = NULL; } } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( pNextEntry ); } tListElem *csrLLPrevious( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ) { tListElem *pNextEntry = NULL; if( !pList) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,"%s: Error!! pList is Null", __func__); return pNextEntry ; } if ( LIST_FLAG_OPEN == pList->Flag ) { if ( fInterlocked ) { csrLLLock( pList ); } if ( !csrIsListEmpty(&pList->ListHead) && csrLLFindEntry( pList, pEntry ) ) { pNextEntry = pEntry->last; //Make sure we don't walk past the head if ( pNextEntry == &pList->ListHead ) { pNextEntry = NULL; } } if ( fInterlocked ) { csrLLUnlock( pList ); } } return( pNextEntry ); }
AlbertXingZhang/android_kernel_sony_msm8x60
drivers/staging/prima/CORE/SME/src/csr/csrLinkList.c
C
gpl-2.0
15,197
<?php /** * WordPress Roles and Capabilities. * * @package WordPress * @subpackage User */ /** * WordPress User Roles. * * The role option is simple, the structure is organized by role name that store * the name in value of the 'name' key. The capabilities are stored as an array * in the value of the 'capability' key. * * array ( * 'rolename' => array ( * 'name' => 'rolename', * 'capabilities' => array() * ) * ) * * @since 2.0.0 * @package WordPress * @subpackage User */ class WP_Roles { /** * List of roles and capabilities. * * @since 2.0.0 * @access public * @var array */ public $roles; /** * List of the role objects. * * @since 2.0.0 * @access public * @var array */ public $role_objects = array(); /** * List of role names. * * @since 2.0.0 * @access public * @var array */ public $role_names = array(); /** * Option name for storing role list. * * @since 2.0.0 * @access public * @var string */ public $role_key; /** * Whether to use the database for retrieval and storage. * * @since 2.1.0 * @access public * @var bool */ public $use_db = true; /** * Constructor * * @since 2.0.0 */ public function __construct() { $this->_init(); } /** * Make private/protected methods readable for backwards compatibility. * * @since 4.0.0 * @access public * * @param callable $name Method to call. * @param array $arguments Arguments to pass when calling. * @return mixed|bool Return value of the callback, false otherwise. */ public function __call( $name, $arguments ) { return call_user_func_array( array( $this, $name ), $arguments ); } /** * Set up the object properties. * * The role key is set to the current prefix for the $wpdb object with * 'user_roles' appended. If the $wp_user_roles global is set, then it will * be used and the role option will not be updated or used. * * @since 2.1.0 * @access protected * * @global wpdb $wpdb WordPress database abstraction object. * @global array $wp_user_roles Used to set the 'roles' property value. */ protected function _init() { global $wpdb, $wp_user_roles; $this->role_key = $wpdb->get_blog_prefix() . 'user_roles'; if ( ! empty( $wp_user_roles ) ) { $this->roles = $wp_user_roles; $this->use_db = false; } else { $this->roles = get_option( $this->role_key ); } if ( empty( $this->roles ) ) return; $this->role_objects = array(); $this->role_names = array(); foreach ( array_keys( $this->roles ) as $role ) { $this->role_objects[$role] = new WP_Role( $role, $this->roles[$role]['capabilities'] ); $this->role_names[$role] = $this->roles[$role]['name']; } } /** * Reinitialize the object * * Recreates the role objects. This is typically called only by switch_to_blog() * after switching wpdb to a new blog ID. * * @since 3.5.0 * @access public */ public function reinit() { // There is no need to reinit if using the wp_user_roles global. if ( ! $this->use_db ) return; global $wpdb; // Duplicated from _init() to avoid an extra function call. $this->role_key = $wpdb->get_blog_prefix() . 'user_roles'; $this->roles = get_option( $this->role_key ); if ( empty( $this->roles ) ) return; $this->role_objects = array(); $this->role_names = array(); foreach ( array_keys( $this->roles ) as $role ) { $this->role_objects[$role] = new WP_Role( $role, $this->roles[$role]['capabilities'] ); $this->role_names[$role] = $this->roles[$role]['name']; } } /** * Add role name with capabilities to list. * * Updates the list of roles, if the role doesn't already exist. * * The capabilities are defined in the following format `array( 'read' => true );` * To explicitly deny a role a capability you set the value for that capability to false. * * @since 2.0.0 * @access public * * @param string $role Role name. * @param string $display_name Role display name. * @param array $capabilities List of role capabilities in the above format. * @return WP_Role|null WP_Role object if role is added, null if already exists. */ public function add_role( $role, $display_name, $capabilities = array() ) { if ( isset( $this->roles[$role] ) ) return; $this->roles[$role] = array( 'name' => $display_name, 'capabilities' => $capabilities ); if ( $this->use_db ) update_option( $this->role_key, $this->roles ); $this->role_objects[$role] = new WP_Role( $role, $capabilities ); $this->role_names[$role] = $display_name; return $this->role_objects[$role]; } /** * Remove role by name. * * @since 2.0.0 * @access public * * @param string $role Role name. */ public function remove_role( $role ) { if ( ! isset( $this->role_objects[$role] ) ) return; unset( $this->role_objects[$role] ); unset( $this->role_names[$role] ); unset( $this->roles[$role] ); if ( $this->use_db ) update_option( $this->role_key, $this->roles ); if ( get_option( 'default_role' ) == $role ) update_option( 'default_role', 'subscriber' ); } /** * Add capability to role. * * @since 2.0.0 * @access public * * @param string $role Role name. * @param string $cap Capability name. * @param bool $grant Optional, default is true. Whether role is capable of performing capability. */ public function add_cap( $role, $cap, $grant = true ) { if ( ! isset( $this->roles[$role] ) ) return; $this->roles[$role]['capabilities'][$cap] = $grant; if ( $this->use_db ) update_option( $this->role_key, $this->roles ); } /** * Remove capability from role. * * @since 2.0.0 * @access public * * @param string $role Role name. * @param string $cap Capability name. */ public function remove_cap( $role, $cap ) { if ( ! isset( $this->roles[$role] ) ) return; unset( $this->roles[$role]['capabilities'][$cap] ); if ( $this->use_db ) update_option( $this->role_key, $this->roles ); } /** * Retrieve role object by name. * * @since 2.0.0 * @access public * * @param string $role Role name. * @return WP_Role|null WP_Role object if found, null if the role does not exist. */ public function get_role( $role ) { if ( isset( $this->role_objects[$role] ) ) return $this->role_objects[$role]; else return null; } /** * Retrieve list of role names. * * @since 2.0.0 * @access public * * @return array List of role names. */ public function get_names() { return $this->role_names; } /** * Whether role name is currently in the list of available roles. * * @since 2.0.0 * @access public * * @param string $role Role name to look up. * @return bool */ public function is_role( $role ) { return isset( $this->role_names[$role] ); } } /** * WordPress Role class. * * @since 2.0.0 * @package WordPress * @subpackage User */ class WP_Role { /** * Role name. * * @since 2.0.0 * @access public * @var string */ public $name; /** * List of capabilities the role contains. * * @since 2.0.0 * @access public * @var array */ public $capabilities; /** * Constructor - Set up object properties. * * The list of capabilities, must have the key as the name of the capability * and the value a boolean of whether it is granted to the role. * * @since 2.0.0 * @access public * * @param string $role Role name. * @param array $capabilities List of capabilities. */ public function __construct( $role, $capabilities ) { $this->name = $role; $this->capabilities = $capabilities; } /** * Assign role a capability. * * @see WP_Roles::add_cap() Method uses implementation for role. * @since 2.0.0 * @access public * * @param string $cap Capability name. * @param bool $grant Whether role has capability privilege. */ public function add_cap( $cap, $grant = true ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $this->capabilities[$cap] = $grant; $wp_roles->add_cap( $this->name, $cap, $grant ); } /** * Remove capability from role. * * This is a container for {@link WP_Roles::remove_cap()} to remove the * capability from the role. That is to say, that {@link * WP_Roles::remove_cap()} implements the functionality, but it also makes * sense to use this class, because you don't need to enter the role name. * * @since 2.0.0 * @access public * * @param string $cap Capability name. */ public function remove_cap( $cap ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); unset( $this->capabilities[$cap] ); $wp_roles->remove_cap( $this->name, $cap ); } /** * Whether role has capability. * * The capabilities is passed through the 'role_has_cap' filter. The first * parameter for the hook is the list of capabilities the class has * assigned. The second parameter is the capability name to look for. The * third and final parameter for the hook is the role name. * * @since 2.0.0 * @access public * * @param string $cap Capability name. * @return bool True, if user has capability. False, if doesn't have capability. */ public function has_cap( $cap ) { /** * Filter which capabilities a role has. * * @since 2.0.0 * * @param array $capabilities Array of role capabilities. * @param string $cap Capability name. * @param string $name Role name. */ $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name ); if ( !empty( $capabilities[$cap] ) ) return $capabilities[$cap]; else return false; } } /** * WordPress User class. * * @since 2.0.0 * @package WordPress * @subpackage User */ class WP_User { /** * User data container. * * @since 2.0.0 * @access private * @var array */ var $data; /** * The user's ID. * * @since 2.1.0 * @access public * @var int */ public $ID = 0; /** * The individual capabilities the user has been given. * * @since 2.0.0 * @access public * @var array */ public $caps = array(); /** * User metadata option name. * * @since 2.0.0 * @access public * @var string */ public $cap_key; /** * The roles the user is part of. * * @since 2.0.0 * @access public * @var array */ public $roles = array(); /** * All capabilities the user has, including individual and role based. * * @since 2.0.0 * @access public * @var array */ public $allcaps = array(); /** * The filter context applied to user data fields. * * @since 2.9.0 * @access private * @var string */ var $filter = null; private static $back_compat_keys; /** * Constructor * * Retrieves the userdata and passes it to {@link WP_User::init()}. * * @since 2.0.0 * @access public * * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. * @param string $name Optional. User's username * @param int $blog_id Optional Blog ID, defaults to current blog. * @return WP_User */ public function __construct( $id = 0, $name = '', $blog_id = '' ) { if ( ! isset( self::$back_compat_keys ) ) { $prefix = $GLOBALS['wpdb']->prefix; self::$back_compat_keys = array( 'user_firstname' => 'first_name', 'user_lastname' => 'last_name', 'user_description' => 'description', 'user_level' => $prefix . 'user_level', $prefix . 'usersettings' => $prefix . 'user-settings', $prefix . 'usersettingstime' => $prefix . 'user-settings-time', ); } if ( is_a( $id, 'WP_User' ) ) { $this->init( $id->data, $blog_id ); return; } elseif ( is_object( $id ) ) { $this->init( $id, $blog_id ); return; } if ( ! empty( $id ) && ! is_numeric( $id ) ) { $name = $id; $id = 0; } if ( $id ) $data = self::get_data_by( 'id', $id ); else $data = self::get_data_by( 'login', $name ); if ( $data ) $this->init( $data, $blog_id ); } /** * Sets up object properties, including capabilities. * * @param object $data User DB row object * @param int $blog_id Optional. The blog id to initialize for */ public function init( $data, $blog_id = '' ) { $this->data = $data; $this->ID = (int) $data->ID; $this->for_blog( $blog_id ); } /** * Return only the main user fields * * @since 3.3.0 * * @param string $field The field to query against: 'id', 'slug', 'email' or 'login' * @param string|int $value The field value * @return object Raw user object */ public static function get_data_by( $field, $value ) { global $wpdb; if ( 'id' == $field ) { // Make sure the value is numeric to avoid casting objects, for example, // to int 1. if ( ! is_numeric( $value ) ) return false; $value = intval( $value ); if ( $value < 1 ) return false; } else { $value = trim( $value ); } if ( !$value ) return false; switch ( $field ) { case 'id': $user_id = $value; $db_field = 'ID'; break; case 'slug': $user_id = wp_cache_get($value, 'userslugs'); $db_field = 'user_nicename'; break; case 'email': $user_id = wp_cache_get($value, 'useremail'); $db_field = 'user_email'; break; case 'login': $value = sanitize_user( $value ); $user_id = wp_cache_get($value, 'userlogins'); $db_field = 'user_login'; break; default: return false; } if ( false !== $user_id ) { if ( $user = wp_cache_get( $user_id, 'users' ) ) return $user; } if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value ) ) ) return false; update_user_caches( $user ); return $user; } /** * Magic method for checking the existence of a certain custom field * * @since 3.3.0 * @param string $key * @return bool */ public function __isset( $key ) { if ( 'id' == $key ) { _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) ); $key = 'ID'; } if ( isset( $this->data->$key ) ) return true; if ( isset( self::$back_compat_keys[ $key ] ) ) $key = self::$back_compat_keys[ $key ]; return metadata_exists( 'user', $this->ID, $key ); } /** * Magic method for accessing custom fields * * @since 3.3.0 * @param string $key * @return mixed */ public function __get( $key ) { if ( 'id' == $key ) { _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) ); return $this->ID; } if ( isset( $this->data->$key ) ) { $value = $this->data->$key; } else { if ( isset( self::$back_compat_keys[ $key ] ) ) $key = self::$back_compat_keys[ $key ]; $value = get_user_meta( $this->ID, $key, true ); } if ( $this->filter ) { $value = sanitize_user_field( $key, $value, $this->ID, $this->filter ); } return $value; } /** * Magic method for setting custom fields * * @since 3.3.0 */ public function __set( $key, $value ) { if ( 'id' == $key ) { _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) ); $this->ID = $value; return; } $this->data->$key = $value; } /** * Determine whether the user exists in the database. * * @since 3.4.0 * @access public * * @return bool True if user exists in the database, false if not. */ public function exists() { return ! empty( $this->ID ); } /** * Retrieve the value of a property or meta key. * * Retrieves from the users and usermeta table. * * @since 3.3.0 * * @param string $key Property */ public function get( $key ) { return $this->__get( $key ); } /** * Determine whether a property or meta key is set * * Consults the users and usermeta tables. * * @since 3.3.0 * * @param string $key Property */ public function has_prop( $key ) { return $this->__isset( $key ); } /** * Return an array representation. * * @since 3.5.0 * * @return array Array representation. */ public function to_array() { return get_object_vars( $this->data ); } /** * Set up capability object properties. * * Will set the value for the 'cap_key' property to current database table * prefix, followed by 'capabilities'. Will then check to see if the * property matching the 'cap_key' exists and is an array. If so, it will be * used. * * @access protected * @since 2.1.0 * * @param string $cap_key Optional capability key */ function _init_caps( $cap_key = '' ) { global $wpdb; if ( empty($cap_key) ) $this->cap_key = $wpdb->get_blog_prefix() . 'capabilities'; else $this->cap_key = $cap_key; $this->caps = get_user_meta( $this->ID, $this->cap_key, true ); if ( ! is_array( $this->caps ) ) $this->caps = array(); $this->get_role_caps(); } /** * Retrieve all of the role capabilities and merge with individual capabilities. * * All of the capabilities of the roles the user belongs to are merged with * the users individual roles. This also means that the user can be denied * specific roles that their role might have, but the specific user isn't * granted permission to. * * @since 2.0.0 * @uses $wp_roles * @access public * * @return array List of all capabilities for the user. */ public function get_role_caps() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); //Filter out caps that are not role names and assign to $this->roles if ( is_array( $this->caps ) ) $this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) ); //Build $allcaps from role caps, overlay user's $caps $this->allcaps = array(); foreach ( (array) $this->roles as $role ) { $the_role = $wp_roles->get_role( $role ); $this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities ); } $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps ); return $this->allcaps; } /** * Add role to user. * * Updates the user's meta data option with capabilities and roles. * * @since 2.0.0 * @access public * * @param string $role Role name. */ public function add_role( $role ) { $this->caps[$role] = true; update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); } /** * Remove role from user. * * @since 2.0.0 * @access public * * @param string $role Role name. */ public function remove_role( $role ) { if ( !in_array($role, $this->roles) ) return; unset( $this->caps[$role] ); update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); } /** * Set the role of the user. * * This will remove the previous roles of the user and assign the user the * new one. You can set the role to an empty string and it will remove all * of the roles from the user. * * @since 2.0.0 * @access public * * @param string $role Role name. */ public function set_role( $role ) { if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) return; foreach ( (array) $this->roles as $oldrole ) unset( $this->caps[$oldrole] ); $old_roles = $this->roles; if ( !empty( $role ) ) { $this->caps[$role] = true; $this->roles = array( $role => true ); } else { $this->roles = false; } update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); /** * Fires after the user's role has changed. * * @since 2.9.0 * @since 3.6.0 Added $old_roles to include an array of the user's previous roles. * * @param int $user_id The user ID. * @param string $role The new role. * @param array $old_roles An array of the user's previous roles. */ do_action( 'set_user_role', $this->ID, $role, $old_roles ); } /** * Choose the maximum level the user has. * * Will compare the level from the $item parameter against the $max * parameter. If the item is incorrect, then just the $max parameter value * will be returned. * * Used to get the max level based on the capabilities the user has. This * is also based on roles, so if the user is assigned the Administrator role * then the capability 'level_10' will exist and the user will get that * value. * * @since 2.0.0 * @access public * * @param int $max Max level of user. * @param string $item Level capability name. * @return int Max Level. */ public function level_reduction( $max, $item ) { if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) { $level = intval( $matches[1] ); return max( $max, $level ); } else { return $max; } } /** * Update the maximum user level for the user. * * Updates the 'user_level' user metadata (includes prefix that is the * database table prefix) with the maximum user level. Gets the value from * the all of the capabilities that the user has. * * @since 2.0.0 * @access public */ public function update_user_level_from_caps() { global $wpdb; $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 ); update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level ); } /** * Add capability and grant or deny access to capability. * * @since 2.0.0 * @access public * * @param string $cap Capability name. * @param bool $grant Whether to grant capability to user. */ public function add_cap( $cap, $grant = true ) { $this->caps[$cap] = $grant; update_user_meta( $this->ID, $this->cap_key, $this->caps ); } /** * Remove capability from user. * * @since 2.0.0 * @access public * * @param string $cap Capability name. */ public function remove_cap( $cap ) { if ( ! isset( $this->caps[$cap] ) ) return; unset( $this->caps[$cap] ); update_user_meta( $this->ID, $this->cap_key, $this->caps ); } /** * Remove all of the capabilities of the user. * * @since 2.1.0 * @access public */ public function remove_all_caps() { global $wpdb; $this->caps = array(); delete_user_meta( $this->ID, $this->cap_key ); delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' ); $this->get_role_caps(); } /** * Whether user has capability or role name. * * This is useful for looking up whether the user has a specific role * assigned to the user. The second optional parameter can also be used to * check for capabilities against a specific object, such as a post or user. * * @since 2.0.0 * @access public * * @param string|int $cap Capability or role name to search. * @return bool True, if user has capability; false, if user does not have capability. */ public function has_cap( $cap ) { if ( is_numeric( $cap ) ) { _deprecated_argument( __FUNCTION__, '2.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') ); $cap = $this->translate_level_to_cap( $cap ); } $args = array_slice( func_get_args(), 1 ); $args = array_merge( array( $cap, $this->ID ), $args ); $caps = call_user_func_array( 'map_meta_cap', $args ); // Multisite super admin has all caps by definition, Unless specifically denied. if ( is_multisite() && is_super_admin( $this->ID ) ) { if ( in_array('do_not_allow', $caps) ) return false; return true; } /** * Dynamically filter a user's capabilities. * * @since 2.0.0 * @since 3.7.0 Added the user object. * * @param array $allcaps An array of all the role's capabilities. * @param array $caps Actual capabilities for meta capability. * @param array $args Optional parameters passed to has_cap(), typically object ID. * @param WP_User $user The user object. */ // Must have ALL requested caps $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); $capabilities['exist'] = true; // Everyone is allowed to exist foreach ( (array) $caps as $cap ) { if ( empty( $capabilities[ $cap ] ) ) return false; } return true; } /** * Convert numeric level to level capability name. * * Prepends 'level_' to level number. * * @since 2.0.0 * @access public * * @param int $level Level number, 1 to 10. * @return string */ public function translate_level_to_cap( $level ) { return 'level_' . $level; } /** * Set the blog to operate on. Defaults to the current blog. * * @since 3.0.0 * * @param int $blog_id Optional Blog ID, defaults to current blog. */ public function for_blog( $blog_id = '' ) { global $wpdb; if ( ! empty( $blog_id ) ) $cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities'; else $cap_key = ''; $this->_init_caps( $cap_key ); } } /** * Map meta capabilities to primitive capabilities. * * This does not actually compare whether the user ID has the actual capability, * just what the capability or capabilities are. Meta capability list value can * be 'delete_user', 'edit_user', 'remove_user', 'promote_user', 'delete_post', * 'delete_page', 'edit_post', 'edit_page', 'read_post', or 'read_page'. * * @since 2.0.0 * * @param string $cap Capability name. * @param int $user_id User ID. * @return array Actual capabilities for meta capability. */ function map_meta_cap( $cap, $user_id ) { $args = array_slice( func_get_args(), 2 ); $caps = array(); switch ( $cap ) { case 'remove_user': $caps[] = 'remove_users'; break; case 'promote_user': $caps[] = 'promote_users'; break; case 'edit_user': case 'edit_users': // Allow user to edit itself if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) break; // If multisite these caps are allowed only for super admins. if ( is_multisite() && !is_super_admin( $user_id ) ) $caps[] = 'do_not_allow'; else $caps[] = 'edit_users'; // edit_user maps to edit_users. break; case 'delete_post': case 'delete_page': $post = get_post( $args[0] ); if ( 'revision' == $post->post_type ) { $post = get_post( $post->post_parent ); } $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type->map_meta_cap ) { $caps[] = $post_type->cap->$cap; // Prior to 3.1 we would re-call map_meta_cap here. if ( 'delete_post' == $cap ) $cap = $post_type->cap->$cap; break; } // If the post author is set and the user is the author... if ( $post->post_author && $user_id == $post->post_author ) { // If the post is published... if ( 'publish' == $post->post_status ) { $caps[] = $post_type->cap->delete_published_posts; } elseif ( 'trash' == $post->post_status ) { if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) { $caps[] = $post_type->cap->delete_published_posts; } } else { // If the post is draft... $caps[] = $post_type->cap->delete_posts; } } else { // The user is trying to edit someone else's post. $caps[] = $post_type->cap->delete_others_posts; // The post is published, extra cap required. if ( 'publish' == $post->post_status ) { $caps[] = $post_type->cap->delete_published_posts; } elseif ( 'private' == $post->post_status ) { $caps[] = $post_type->cap->delete_private_posts; } } break; // edit_post breaks down to edit_posts, edit_published_posts, or // edit_others_posts case 'edit_post': case 'edit_page': $post = get_post( $args[0] ); if ( empty( $post ) ) break; if ( 'revision' == $post->post_type ) { $post = get_post( $post->post_parent ); } $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type->map_meta_cap ) { $caps[] = $post_type->cap->$cap; // Prior to 3.1 we would re-call map_meta_cap here. if ( 'edit_post' == $cap ) $cap = $post_type->cap->$cap; break; } // If the post author is set and the user is the author... if ( $post->post_author && $user_id == $post->post_author ) { // If the post is published... if ( 'publish' == $post->post_status ) { $caps[] = $post_type->cap->edit_published_posts; } elseif ( 'trash' == $post->post_status ) { if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) { $caps[] = $post_type->cap->edit_published_posts; } } else { // If the post is draft... $caps[] = $post_type->cap->edit_posts; } } else { // The user is trying to edit someone else's post. $caps[] = $post_type->cap->edit_others_posts; // The post is published, extra cap required. if ( 'publish' == $post->post_status ) { $caps[] = $post_type->cap->edit_published_posts; } elseif ( 'private' == $post->post_status ) { $caps[] = $post_type->cap->edit_private_posts; } } break; case 'read_post': case 'read_page': $post = get_post( $args[0] ); if ( 'revision' == $post->post_type ) { $post = get_post( $post->post_parent ); } $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type->map_meta_cap ) { $caps[] = $post_type->cap->$cap; // Prior to 3.1 we would re-call map_meta_cap here. if ( 'read_post' == $cap ) $cap = $post_type->cap->$cap; break; } $status_obj = get_post_status_object( $post->post_status ); if ( $status_obj->public ) { $caps[] = $post_type->cap->read; break; } if ( $post->post_author && $user_id == $post->post_author ) { $caps[] = $post_type->cap->read; } elseif ( $status_obj->private ) { $caps[] = $post_type->cap->read_private_posts; } else { $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); } break; case 'publish_post': $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); $caps[] = $post_type->cap->publish_posts; break; case 'edit_post_meta': case 'delete_post_meta': case 'add_post_meta': $post = get_post( $args[0] ); $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); $meta_key = isset( $args[ 1 ] ) ? $args[ 1 ] : false; if ( $meta_key && has_filter( "auth_post_meta_{$meta_key}" ) ) { /** * Filter whether the user is allowed to add post meta to a post. * * The dynamic portion of the hook name, `$meta_key`, refers to the * meta key passed to {@see map_meta_cap()}. * * @since 3.3.0 * * @param bool $allowed Whether the user can add the post meta. Default false. * @param string $meta_key The meta key. * @param int $post_id Post ID. * @param int $user_id User ID. * @param string $cap Capability name. * @param array $caps User capabilities. */ $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps ); if ( ! $allowed ) $caps[] = $cap; } elseif ( $meta_key && is_protected_meta( $meta_key, 'post' ) ) { $caps[] = $cap; } break; case 'edit_comment': $comment = get_comment( $args[0] ); if ( empty( $comment ) ) break; $post = get_post( $comment->comment_post_ID ); $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); break; case 'unfiltered_upload': if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) ) $caps[] = $cap; else $caps[] = 'do_not_allow'; break; case 'unfiltered_html' : // Disallow unfiltered_html for all users, even admins and super admins. if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) $caps[] = 'do_not_allow'; elseif ( is_multisite() && ! is_super_admin( $user_id ) ) $caps[] = 'do_not_allow'; else $caps[] = $cap; break; case 'edit_files': case 'edit_plugins': case 'edit_themes': // Disallow the file editors. if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) $caps[] = 'do_not_allow'; elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) $caps[] = 'do_not_allow'; elseif ( is_multisite() && ! is_super_admin( $user_id ) ) $caps[] = 'do_not_allow'; else $caps[] = $cap; break; case 'update_plugins': case 'delete_plugins': case 'install_plugins': case 'upload_plugins': case 'update_themes': case 'delete_themes': case 'install_themes': case 'upload_themes': case 'update_core': // Disallow anything that creates, deletes, or updates core, plugin, or theme files. // Files in uploads are excepted. if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) { $caps[] = 'do_not_allow'; } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) { $caps[] = 'do_not_allow'; } elseif ( 'upload_themes' === $cap ) { $caps[] = 'install_themes'; } elseif ( 'upload_plugins' === $cap ) { $caps[] = 'install_plugins'; } else { $caps[] = $cap; } break; case 'activate_plugins': $caps[] = $cap; if ( is_multisite() ) { // update_, install_, and delete_ are handled above with is_super_admin(). $menu_perms = get_site_option( 'menu_items', array() ); if ( empty( $menu_perms['plugins'] ) ) $caps[] = 'manage_network_plugins'; } break; case 'delete_user': case 'delete_users': // If multisite only super admins can delete users. if ( is_multisite() && ! is_super_admin( $user_id ) ) $caps[] = 'do_not_allow'; else $caps[] = 'delete_users'; // delete_user maps to delete_users. break; case 'create_users': if ( !is_multisite() ) $caps[] = $cap; elseif ( is_super_admin() || get_site_option( 'add_new_users' ) ) $caps[] = $cap; else $caps[] = 'do_not_allow'; break; case 'manage_links' : if ( get_option( 'link_manager_enabled' ) ) $caps[] = $cap; else $caps[] = 'do_not_allow'; break; case 'customize' : $caps[] = 'edit_theme_options'; break; default: // Handle meta capabilities for custom post types. $post_type_meta_caps = _post_type_meta_capabilities(); if ( isset( $post_type_meta_caps[ $cap ] ) ) { $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); return call_user_func_array( 'map_meta_cap', $args ); } // If no meta caps match, return the original cap. $caps[] = $cap; } /** * Filter a user's capabilities depending on specific context and/or privilege. * * @since 2.8.0 * * @param array $caps Returns the user's actual capabilities. * @param string $cap Capability name. * @param int $user_id The user ID. * @param array $args Adds the context to the cap. Typically the object ID. */ return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args ); } /** * Whether current user has capability or role. * * @since 2.0.0 * * @param string $capability Capability or role name. * @return bool */ function current_user_can( $capability ) { $current_user = wp_get_current_user(); if ( empty( $current_user ) ) return false; $args = array_slice( func_get_args(), 1 ); $args = array_merge( array( $capability ), $args ); return call_user_func_array( array( $current_user, 'has_cap' ), $args ); } /** * Whether current user has a capability or role for a given blog. * * @since 3.0.0 * * @param int $blog_id Blog ID * @param string $capability Capability or role name. * @return bool */ function current_user_can_for_blog( $blog_id, $capability ) { if ( is_multisite() ) switch_to_blog( $blog_id ); $current_user = wp_get_current_user(); if ( empty( $current_user ) ) return false; $args = array_slice( func_get_args(), 2 ); $args = array_merge( array( $capability ), $args ); $can = call_user_func_array( array( $current_user, 'has_cap' ), $args ); if ( is_multisite() ) restore_current_blog(); return $can; } /** * Whether author of supplied post has capability or role. * * @since 2.9.0 * * @param int|object $post Post ID or post object. * @param string $capability Capability or role name. * @return bool */ function author_can( $post, $capability ) { if ( !$post = get_post($post) ) return false; $author = get_userdata( $post->post_author ); if ( ! $author ) return false; $args = array_slice( func_get_args(), 2 ); $args = array_merge( array( $capability ), $args ); return call_user_func_array( array( $author, 'has_cap' ), $args ); } /** * Whether a particular user has capability or role. * * @since 3.1.0 * * @param int|object $user User ID or object. * @param string $capability Capability or role name. * @return bool */ function user_can( $user, $capability ) { if ( ! is_object( $user ) ) $user = get_userdata( $user ); if ( ! $user || ! $user->exists() ) return false; $args = array_slice( func_get_args(), 2 ); $args = array_merge( array( $capability ), $args ); return call_user_func_array( array( $user, 'has_cap' ), $args ); } /** * Retrieve role object. * * @see WP_Roles::get_role() Uses method to retrieve role object. * @since 2.0.0 * * @param string $role Role name. * @return WP_Role|null WP_Role object if found, null if the role does not exist. */ function get_role( $role ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); return $wp_roles->get_role( $role ); } /** * Add role, if it does not exist. * * @see WP_Roles::add_role() Uses method to add role. * @since 2.0.0 * * @param string $role Role name. * @param string $display_name Display name for role. * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false ); * @return WP_Role|null WP_Role object if role is added, null if already exists. */ function add_role( $role, $display_name, $capabilities = array() ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); return $wp_roles->add_role( $role, $display_name, $capabilities ); } /** * Remove role, if it exists. * * @see WP_Roles::remove_role() Uses method to remove role. * @since 2.0.0 * * @param string $role Role name. */ function remove_role( $role ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $wp_roles->remove_role( $role ); } /** * Retrieve a list of super admins. * * @since 3.0.0 * * @uses $super_admins Super admins global variable, if set. * * @return array List of super admin logins */ function get_super_admins() { global $super_admins; if ( isset($super_admins) ) return $super_admins; else return get_site_option( 'site_admins', array('admin') ); } /** * Determine if user is a site admin. * * @since 3.0.0 * * @param int $user_id (Optional) The ID of a user. Defaults to the current user. * @return bool True if the user is a site admin. */ function is_super_admin( $user_id = false ) { if ( ! $user_id || $user_id == get_current_user_id() ) $user = wp_get_current_user(); else $user = get_userdata( $user_id ); if ( ! $user || ! $user->exists() ) return false; if ( is_multisite() ) { $super_admins = get_super_admins(); if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) return true; } else { if ( $user->has_cap('delete_users') ) return true; } return false; }
mark-toast/easyplantest
wp-includes/capabilities.php
PHP
gpl-2.0
39,186
/* * Copyright (C) Freescale Semicondutor, Inc. 2007, 2008. * Copyright (C) Semihalf 2009 * Copyright (C) Ilya Yanok, Emcraft Systems 2010 * * Written by Piotr Ziecik <kosmo@semihalf.com>. Hardware description * (defines, structures and comments) was taken from MPC5121 DMA driver * written by Hongjun Chen <hong-jun.chen@freescale.com>. * * Approved as OSADL project by a majority of OSADL members and funded * by OSADL membership fees in 2009; for details see www.osadl.org. * * 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. * * The full GNU General Public License is included in this distribution in the * file called COPYING. */ /* * This is initial version of MPC5121 DMA driver. Only memory to memory * transfers are supported (tested using dmatest module). */ #include <linux/module.h> #include <linux/dmaengine.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/slab.h> #include <linux/of_device.h> #include <linux/of_platform.h> #include <linux/random.h> #include "dmaengine.h" /* Number of DMA Transfer descriptors allocated per channel */ #define MPC_DMA_DESCRIPTORS 64 /* Macro definitions */ #define MPC_DMA_CHANNELS 64 #define MPC_DMA_TCD_OFFSET 0x1000 /* Arbitration mode of group and channel */ #define MPC_DMA_DMACR_EDCG (1 << 31) #define MPC_DMA_DMACR_ERGA (1 << 3) #define MPC_DMA_DMACR_ERCA (1 << 2) /* Error codes */ #define MPC_DMA_DMAES_VLD (1 << 31) #define MPC_DMA_DMAES_GPE (1 << 15) #define MPC_DMA_DMAES_CPE (1 << 14) #define MPC_DMA_DMAES_ERRCHN(err) \ (((err) >> 8) & 0x3f) #define MPC_DMA_DMAES_SAE (1 << 7) #define MPC_DMA_DMAES_SOE (1 << 6) #define MPC_DMA_DMAES_DAE (1 << 5) #define MPC_DMA_DMAES_DOE (1 << 4) #define MPC_DMA_DMAES_NCE (1 << 3) #define MPC_DMA_DMAES_SGE (1 << 2) #define MPC_DMA_DMAES_SBE (1 << 1) #define MPC_DMA_DMAES_DBE (1 << 0) #define MPC_DMA_DMAGPOR_SNOOP_ENABLE (1 << 6) #define MPC_DMA_TSIZE_1 0x00 #define MPC_DMA_TSIZE_2 0x01 #define MPC_DMA_TSIZE_4 0x02 #define MPC_DMA_TSIZE_16 0x04 #define MPC_DMA_TSIZE_32 0x05 /* MPC5121 DMA engine registers */ struct __attribute__ ((__packed__)) mpc_dma_regs { /* 0x00 */ u32 dmacr; /* DMA control register */ u32 dmaes; /* DMA error status */ /* 0x08 */ u32 dmaerqh; /* DMA enable request high(channels 63~32) */ u32 dmaerql; /* DMA enable request low(channels 31~0) */ u32 dmaeeih; /* DMA enable error interrupt high(ch63~32) */ u32 dmaeeil; /* DMA enable error interrupt low(ch31~0) */ /* 0x18 */ u8 dmaserq; /* DMA set enable request */ u8 dmacerq; /* DMA clear enable request */ u8 dmaseei; /* DMA set enable error interrupt */ u8 dmaceei; /* DMA clear enable error interrupt */ /* 0x1c */ u8 dmacint; /* DMA clear interrupt request */ u8 dmacerr; /* DMA clear error */ u8 dmassrt; /* DMA set start bit */ u8 dmacdne; /* DMA clear DONE status bit */ /* 0x20 */ u32 dmainth; /* DMA interrupt request high(ch63~32) */ u32 dmaintl; /* DMA interrupt request low(ch31~0) */ u32 dmaerrh; /* DMA error high(ch63~32) */ u32 dmaerrl; /* DMA error low(ch31~0) */ /* 0x30 */ u32 dmahrsh; /* DMA hw request status high(ch63~32) */ u32 dmahrsl; /* DMA hardware request status low(ch31~0) */ union { u32 dmaihsa; /* DMA interrupt high select AXE(ch63~32) */ u32 dmagpor; /* (General purpose register on MPC8308) */ }; u32 dmailsa; /* DMA interrupt low select AXE(ch31~0) */ /* 0x40 ~ 0xff */ u32 reserve0[48]; /* Reserved */ /* 0x100 */ u8 dchpri[MPC_DMA_CHANNELS]; /* DMA channels(0~63) priority */ }; struct __attribute__ ((__packed__)) mpc_dma_tcd { /* 0x00 */ u32 saddr; /* Source address */ u32 smod:5; /* Source address modulo */ u32 ssize:3; /* Source data transfer size */ u32 dmod:5; /* Destination address modulo */ u32 dsize:3; /* Destination data transfer size */ u32 soff:16; /* Signed source address offset */ /* 0x08 */ u32 nbytes; /* Inner "minor" byte count */ u32 slast; /* Last source address adjustment */ u32 daddr; /* Destination address */ /* 0x14 */ u32 citer_elink:1; /* Enable channel-to-channel linking on * minor loop complete */ u32 citer_linkch:6; /* Link channel for minor loop complete */ u32 citer:9; /* Current "major" iteration count */ u32 doff:16; /* Signed destination address offset */ /* 0x18 */ u32 dlast_sga; /* Last Destination address adjustment/scatter * gather address */ /* 0x1c */ u32 biter_elink:1; /* Enable channel-to-channel linking on major * loop complete */ u32 biter_linkch:6; u32 biter:9; /* Beginning "major" iteration count */ u32 bwc:2; /* Bandwidth control */ u32 major_linkch:6; /* Link channel number */ u32 done:1; /* Channel done */ u32 active:1; /* Channel active */ u32 major_elink:1; /* Enable channel-to-channel linking on major * loop complete */ u32 e_sg:1; /* Enable scatter/gather processing */ u32 d_req:1; /* Disable request */ u32 int_half:1; /* Enable an interrupt when major counter is * half complete */ u32 int_maj:1; /* Enable an interrupt when major iteration * count completes */ u32 start:1; /* Channel start */ }; struct mpc_dma_desc { struct dma_async_tx_descriptor desc; struct mpc_dma_tcd *tcd; dma_addr_t tcd_paddr; int error; struct list_head node; }; struct mpc_dma_chan { struct dma_chan chan; struct list_head free; struct list_head prepared; struct list_head queued; struct list_head active; struct list_head completed; struct mpc_dma_tcd *tcd; dma_addr_t tcd_paddr; /* Lock for this structure */ spinlock_t lock; }; struct mpc_dma { struct dma_device dma; struct tasklet_struct tasklet; struct mpc_dma_chan channels[MPC_DMA_CHANNELS]; struct mpc_dma_regs __iomem *regs; struct mpc_dma_tcd __iomem *tcd; int irq; int irq2; uint error_status; int is_mpc8308; /* Lock for error_status field in this structure */ spinlock_t error_status_lock; }; #define DRV_NAME "mpc512x_dma" /* Convert struct dma_chan to struct mpc_dma_chan */ static inline struct mpc_dma_chan *dma_chan_to_mpc_dma_chan(struct dma_chan *c) { return container_of(c, struct mpc_dma_chan, chan); } /* Convert struct dma_chan to struct mpc_dma */ static inline struct mpc_dma *dma_chan_to_mpc_dma(struct dma_chan *c) { struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(c); return container_of(mchan, struct mpc_dma, channels[c->chan_id]); } /* * Execute all queued DMA descriptors. * * Following requirements must be met while calling mpc_dma_execute(): * a) mchan->lock is acquired, * b) mchan->active list is empty, * c) mchan->queued list contains at least one entry. */ static void mpc_dma_execute(struct mpc_dma_chan *mchan) { struct mpc_dma *mdma = dma_chan_to_mpc_dma(&mchan->chan); struct mpc_dma_desc *first = NULL; struct mpc_dma_desc *prev = NULL; struct mpc_dma_desc *mdesc; int cid = mchan->chan.chan_id; /* Move all queued descriptors to active list */ list_splice_tail_init(&mchan->queued, &mchan->active); /* Chain descriptors into one transaction */ list_for_each_entry(mdesc, &mchan->active, node) { if (!first) first = mdesc; if (!prev) { prev = mdesc; continue; } prev->tcd->dlast_sga = mdesc->tcd_paddr; prev->tcd->e_sg = 1; mdesc->tcd->start = 1; prev = mdesc; } prev->tcd->int_maj = 1; /* Send first descriptor in chain into hardware */ memcpy_toio(&mdma->tcd[cid], first->tcd, sizeof(struct mpc_dma_tcd)); if (first != prev) mdma->tcd[cid].e_sg = 1; out_8(&mdma->regs->dmassrt, cid); } /* Handle interrupt on one half of DMA controller (32 channels) */ static void mpc_dma_irq_process(struct mpc_dma *mdma, u32 is, u32 es, int off) { struct mpc_dma_chan *mchan; struct mpc_dma_desc *mdesc; u32 status = is | es; int ch; while ((ch = fls(status) - 1) >= 0) { status &= ~(1 << ch); mchan = &mdma->channels[ch + off]; spin_lock(&mchan->lock); out_8(&mdma->regs->dmacint, ch + off); out_8(&mdma->regs->dmacerr, ch + off); /* Check error status */ if (es & (1 << ch)) list_for_each_entry(mdesc, &mchan->active, node) mdesc->error = -EIO; /* Execute queued descriptors */ list_splice_tail_init(&mchan->active, &mchan->completed); if (!list_empty(&mchan->queued)) mpc_dma_execute(mchan); spin_unlock(&mchan->lock); } } /* Interrupt handler */ static irqreturn_t mpc_dma_irq(int irq, void *data) { struct mpc_dma *mdma = data; uint es; /* Save error status register */ es = in_be32(&mdma->regs->dmaes); spin_lock(&mdma->error_status_lock); if ((es & MPC_DMA_DMAES_VLD) && mdma->error_status == 0) mdma->error_status = es; spin_unlock(&mdma->error_status_lock); /* Handle interrupt on each channel */ if (mdma->dma.chancnt > 32) { mpc_dma_irq_process(mdma, in_be32(&mdma->regs->dmainth), in_be32(&mdma->regs->dmaerrh), 32); } mpc_dma_irq_process(mdma, in_be32(&mdma->regs->dmaintl), in_be32(&mdma->regs->dmaerrl), 0); /* Schedule tasklet */ tasklet_schedule(&mdma->tasklet); return IRQ_HANDLED; } /* process completed descriptors */ static void mpc_dma_process_completed(struct mpc_dma *mdma) { dma_cookie_t last_cookie = 0; struct mpc_dma_chan *mchan; struct mpc_dma_desc *mdesc; struct dma_async_tx_descriptor *desc; unsigned long flags; LIST_HEAD(list); int i; for (i = 0; i < mdma->dma.chancnt; i++) { mchan = &mdma->channels[i]; /* Get all completed descriptors */ spin_lock_irqsave(&mchan->lock, flags); if (!list_empty(&mchan->completed)) list_splice_tail_init(&mchan->completed, &list); spin_unlock_irqrestore(&mchan->lock, flags); if (list_empty(&list)) continue; /* Execute callbacks and run dependencies */ list_for_each_entry(mdesc, &list, node) { desc = &mdesc->desc; if (desc->callback) desc->callback(desc->callback_param); last_cookie = desc->cookie; dma_run_dependencies(desc); } /* Free descriptors */ spin_lock_irqsave(&mchan->lock, flags); list_splice_tail_init(&list, &mchan->free); mchan->chan.completed_cookie = last_cookie; spin_unlock_irqrestore(&mchan->lock, flags); } } /* DMA Tasklet */ static void mpc_dma_tasklet(unsigned long data) { struct mpc_dma *mdma = (void *)data; unsigned long flags; uint es; spin_lock_irqsave(&mdma->error_status_lock, flags); es = mdma->error_status; mdma->error_status = 0; spin_unlock_irqrestore(&mdma->error_status_lock, flags); /* Print nice error report */ if (es) { dev_err(mdma->dma.dev, "Hardware reported following error(s) on channel %u:\n", MPC_DMA_DMAES_ERRCHN(es)); if (es & MPC_DMA_DMAES_GPE) dev_err(mdma->dma.dev, "- Group Priority Error\n"); if (es & MPC_DMA_DMAES_CPE) dev_err(mdma->dma.dev, "- Channel Priority Error\n"); if (es & MPC_DMA_DMAES_SAE) dev_err(mdma->dma.dev, "- Source Address Error\n"); if (es & MPC_DMA_DMAES_SOE) dev_err(mdma->dma.dev, "- Source Offset" " Configuration Error\n"); if (es & MPC_DMA_DMAES_DAE) dev_err(mdma->dma.dev, "- Destination Address" " Error\n"); if (es & MPC_DMA_DMAES_DOE) dev_err(mdma->dma.dev, "- Destination Offset" " Configuration Error\n"); if (es & MPC_DMA_DMAES_NCE) dev_err(mdma->dma.dev, "- NBytes/Citter" " Configuration Error\n"); if (es & MPC_DMA_DMAES_SGE) dev_err(mdma->dma.dev, "- Scatter/Gather" " Configuration Error\n"); if (es & MPC_DMA_DMAES_SBE) dev_err(mdma->dma.dev, "- Source Bus Error\n"); if (es & MPC_DMA_DMAES_DBE) dev_err(mdma->dma.dev, "- Destination Bus Error\n"); } mpc_dma_process_completed(mdma); } /* Submit descriptor to hardware */ static dma_cookie_t mpc_dma_tx_submit(struct dma_async_tx_descriptor *txd) { struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(txd->chan); struct mpc_dma_desc *mdesc; unsigned long flags; dma_cookie_t cookie; mdesc = container_of(txd, struct mpc_dma_desc, desc); spin_lock_irqsave(&mchan->lock, flags); /* Move descriptor to queue */ list_move_tail(&mdesc->node, &mchan->queued); /* If channel is idle, execute all queued descriptors */ if (list_empty(&mchan->active)) mpc_dma_execute(mchan); /* Update cookie */ cookie = dma_cookie_assign(txd); spin_unlock_irqrestore(&mchan->lock, flags); return cookie; } /* Alloc channel resources */ static int mpc_dma_alloc_chan_resources(struct dma_chan *chan) { struct mpc_dma *mdma = dma_chan_to_mpc_dma(chan); struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(chan); struct mpc_dma_desc *mdesc; struct mpc_dma_tcd *tcd; dma_addr_t tcd_paddr; unsigned long flags; LIST_HEAD(descs); int i; /* Alloc DMA memory for Transfer Control Descriptors */ tcd = dma_alloc_coherent(mdma->dma.dev, MPC_DMA_DESCRIPTORS * sizeof(struct mpc_dma_tcd), &tcd_paddr, GFP_KERNEL); if (!tcd) return -ENOMEM; /* Alloc descriptors for this channel */ for (i = 0; i < MPC_DMA_DESCRIPTORS; i++) { mdesc = kzalloc(sizeof(struct mpc_dma_desc), GFP_KERNEL); if (!mdesc) { dev_notice(mdma->dma.dev, "Memory allocation error. " "Allocated only %u descriptors\n", i); break; } dma_async_tx_descriptor_init(&mdesc->desc, chan); mdesc->desc.flags = DMA_CTRL_ACK; mdesc->desc.tx_submit = mpc_dma_tx_submit; mdesc->tcd = &tcd[i]; mdesc->tcd_paddr = tcd_paddr + (i * sizeof(struct mpc_dma_tcd)); list_add_tail(&mdesc->node, &descs); } /* Return error only if no descriptors were allocated */ if (i == 0) { dma_free_coherent(mdma->dma.dev, MPC_DMA_DESCRIPTORS * sizeof(struct mpc_dma_tcd), tcd, tcd_paddr); return -ENOMEM; } spin_lock_irqsave(&mchan->lock, flags); mchan->tcd = tcd; mchan->tcd_paddr = tcd_paddr; list_splice_tail_init(&descs, &mchan->free); spin_unlock_irqrestore(&mchan->lock, flags); /* Enable Error Interrupt */ out_8(&mdma->regs->dmaseei, chan->chan_id); return 0; } /* Free channel resources */ static void mpc_dma_free_chan_resources(struct dma_chan *chan) { struct mpc_dma *mdma = dma_chan_to_mpc_dma(chan); struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(chan); struct mpc_dma_desc *mdesc, *tmp; struct mpc_dma_tcd *tcd; dma_addr_t tcd_paddr; unsigned long flags; LIST_HEAD(descs); spin_lock_irqsave(&mchan->lock, flags); /* Channel must be idle */ BUG_ON(!list_empty(&mchan->prepared)); BUG_ON(!list_empty(&mchan->queued)); BUG_ON(!list_empty(&mchan->active)); BUG_ON(!list_empty(&mchan->completed)); /* Move data */ list_splice_tail_init(&mchan->free, &descs); tcd = mchan->tcd; tcd_paddr = mchan->tcd_paddr; spin_unlock_irqrestore(&mchan->lock, flags); /* Free DMA memory used by descriptors */ dma_free_coherent(mdma->dma.dev, MPC_DMA_DESCRIPTORS * sizeof(struct mpc_dma_tcd), tcd, tcd_paddr); /* Free descriptors */ list_for_each_entry_safe(mdesc, tmp, &descs, node) kfree(mdesc); /* Disable Error Interrupt */ out_8(&mdma->regs->dmaceei, chan->chan_id); } /* Send all pending descriptor to hardware */ static void mpc_dma_issue_pending(struct dma_chan *chan) { /* * We are posting descriptors to the hardware as soon as * they are ready, so this function does nothing. */ } /* Check request completion status */ static enum dma_status mpc_dma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) { struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(chan); enum dma_status ret; unsigned long flags; spin_lock_irqsave(&mchan->lock, flags); ret = dma_cookie_status(chan, cookie, txstate); spin_unlock_irqrestore(&mchan->lock, flags); return ret; } /* Prepare descriptor for memory to memory copy */ static struct dma_async_tx_descriptor * mpc_dma_prep_memcpy(struct dma_chan *chan, dma_addr_t dst, dma_addr_t src, size_t len, unsigned long flags) { struct mpc_dma *mdma = dma_chan_to_mpc_dma(chan); struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(chan); struct mpc_dma_desc *mdesc = NULL; struct mpc_dma_tcd *tcd; unsigned long iflags; /* Get free descriptor */ spin_lock_irqsave(&mchan->lock, iflags); if (!list_empty(&mchan->free)) { mdesc = list_first_entry(&mchan->free, struct mpc_dma_desc, node); list_del(&mdesc->node); } spin_unlock_irqrestore(&mchan->lock, iflags); if (!mdesc) { /* try to free completed descriptors */ mpc_dma_process_completed(mdma); return NULL; } mdesc->error = 0; tcd = mdesc->tcd; /* Prepare Transfer Control Descriptor for this transaction */ memset(tcd, 0, sizeof(struct mpc_dma_tcd)); if (IS_ALIGNED(src | dst | len, 32)) { tcd->ssize = MPC_DMA_TSIZE_32; tcd->dsize = MPC_DMA_TSIZE_32; tcd->soff = 32; tcd->doff = 32; } else if (!mdma->is_mpc8308 && IS_ALIGNED(src | dst | len, 16)) { /* MPC8308 doesn't support 16 byte transfers */ tcd->ssize = MPC_DMA_TSIZE_16; tcd->dsize = MPC_DMA_TSIZE_16; tcd->soff = 16; tcd->doff = 16; } else if (IS_ALIGNED(src | dst | len, 4)) { tcd->ssize = MPC_DMA_TSIZE_4; tcd->dsize = MPC_DMA_TSIZE_4; tcd->soff = 4; tcd->doff = 4; } else if (IS_ALIGNED(src | dst | len, 2)) { tcd->ssize = MPC_DMA_TSIZE_2; tcd->dsize = MPC_DMA_TSIZE_2; tcd->soff = 2; tcd->doff = 2; } else { tcd->ssize = MPC_DMA_TSIZE_1; tcd->dsize = MPC_DMA_TSIZE_1; tcd->soff = 1; tcd->doff = 1; } tcd->saddr = src; tcd->daddr = dst; tcd->nbytes = len; tcd->biter = 1; tcd->citer = 1; /* Place descriptor in prepared list */ spin_lock_irqsave(&mchan->lock, iflags); list_add_tail(&mdesc->node, &mchan->prepared); spin_unlock_irqrestore(&mchan->lock, iflags); return &mdesc->desc; } static int mpc_dma_probe(struct platform_device *op) { struct device_node *dn = op->dev.of_node; struct device *dev = &op->dev; struct dma_device *dma; struct mpc_dma *mdma; struct mpc_dma_chan *mchan; struct resource res; ulong regs_start, regs_size; int retval, i; mdma = devm_kzalloc(dev, sizeof(struct mpc_dma), GFP_KERNEL); if (!mdma) { dev_err(dev, "Memory exhausted!\n"); return -ENOMEM; } mdma->irq = irq_of_parse_and_map(dn, 0); if (mdma->irq == NO_IRQ) { dev_err(dev, "Error mapping IRQ!\n"); return -EINVAL; } if (of_device_is_compatible(dn, "fsl,mpc8308-dma")) { mdma->is_mpc8308 = 1; mdma->irq2 = irq_of_parse_and_map(dn, 1); if (mdma->irq2 == NO_IRQ) { dev_err(dev, "Error mapping IRQ!\n"); return -EINVAL; } } retval = of_address_to_resource(dn, 0, &res); if (retval) { dev_err(dev, "Error parsing memory region!\n"); return retval; } regs_start = res.start; regs_size = resource_size(&res); if (!devm_request_mem_region(dev, regs_start, regs_size, DRV_NAME)) { dev_err(dev, "Error requesting memory region!\n"); return -EBUSY; } mdma->regs = devm_ioremap(dev, regs_start, regs_size); if (!mdma->regs) { dev_err(dev, "Error mapping memory region!\n"); return -ENOMEM; } mdma->tcd = (struct mpc_dma_tcd *)((u8 *)(mdma->regs) + MPC_DMA_TCD_OFFSET); retval = devm_request_irq(dev, mdma->irq, &mpc_dma_irq, 0, DRV_NAME, mdma); if (retval) { dev_err(dev, "Error requesting IRQ!\n"); return -EINVAL; } if (mdma->is_mpc8308) { retval = devm_request_irq(dev, mdma->irq2, &mpc_dma_irq, 0, DRV_NAME, mdma); if (retval) { dev_err(dev, "Error requesting IRQ2!\n"); return -EINVAL; } } spin_lock_init(&mdma->error_status_lock); dma = &mdma->dma; dma->dev = dev; if (!mdma->is_mpc8308) dma->chancnt = MPC_DMA_CHANNELS; else dma->chancnt = 16; /* MPC8308 DMA has only 16 channels */ dma->device_alloc_chan_resources = mpc_dma_alloc_chan_resources; dma->device_free_chan_resources = mpc_dma_free_chan_resources; dma->device_issue_pending = mpc_dma_issue_pending; dma->device_tx_status = mpc_dma_tx_status; dma->device_prep_dma_memcpy = mpc_dma_prep_memcpy; INIT_LIST_HEAD(&dma->channels); dma_cap_set(DMA_MEMCPY, dma->cap_mask); for (i = 0; i < dma->chancnt; i++) { mchan = &mdma->channels[i]; mchan->chan.device = dma; dma_cookie_init(&mchan->chan); INIT_LIST_HEAD(&mchan->free); INIT_LIST_HEAD(&mchan->prepared); INIT_LIST_HEAD(&mchan->queued); INIT_LIST_HEAD(&mchan->active); INIT_LIST_HEAD(&mchan->completed); spin_lock_init(&mchan->lock); list_add_tail(&mchan->chan.device_node, &dma->channels); } tasklet_init(&mdma->tasklet, mpc_dma_tasklet, (unsigned long)mdma); /* * Configure DMA Engine: * - Dynamic clock, * - Round-robin group arbitration, * - Round-robin channel arbitration. */ if (!mdma->is_mpc8308) { out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_EDCG | MPC_DMA_DMACR_ERGA | MPC_DMA_DMACR_ERCA); /* Disable hardware DMA requests */ out_be32(&mdma->regs->dmaerqh, 0); out_be32(&mdma->regs->dmaerql, 0); /* Disable error interrupts */ out_be32(&mdma->regs->dmaeeih, 0); out_be32(&mdma->regs->dmaeeil, 0); /* Clear interrupts status */ out_be32(&mdma->regs->dmainth, 0xFFFFFFFF); out_be32(&mdma->regs->dmaintl, 0xFFFFFFFF); out_be32(&mdma->regs->dmaerrh, 0xFFFFFFFF); out_be32(&mdma->regs->dmaerrl, 0xFFFFFFFF); /* Route interrupts to IPIC */ out_be32(&mdma->regs->dmaihsa, 0); out_be32(&mdma->regs->dmailsa, 0); } else { /* MPC8308 has 16 channels and lacks some registers */ out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_ERCA); /* enable snooping */ out_be32(&mdma->regs->dmagpor, MPC_DMA_DMAGPOR_SNOOP_ENABLE); /* Disable error interrupts */ out_be32(&mdma->regs->dmaeeil, 0); /* Clear interrupts status */ out_be32(&mdma->regs->dmaintl, 0xFFFF); out_be32(&mdma->regs->dmaerrl, 0xFFFF); } /* Register DMA engine */ dev_set_drvdata(dev, mdma); retval = dma_async_device_register(dma); if (retval) { devm_free_irq(dev, mdma->irq, mdma); irq_dispose_mapping(mdma->irq); } return retval; } static int mpc_dma_remove(struct platform_device *op) { struct device *dev = &op->dev; struct mpc_dma *mdma = dev_get_drvdata(dev); dma_async_device_unregister(&mdma->dma); devm_free_irq(dev, mdma->irq, mdma); irq_dispose_mapping(mdma->irq); return 0; } static struct of_device_id mpc_dma_match[] = { { .compatible = "fsl,mpc5121-dma", }, {}, }; static struct platform_driver mpc_dma_driver = { .probe = mpc_dma_probe, .remove = mpc_dma_remove, .driver = { .name = DRV_NAME, .owner = THIS_MODULE, .of_match_table = mpc_dma_match, }, }; module_platform_driver(mpc_dma_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Piotr Ziecik <kosmo@semihalf.com>");
LEPT-Development/aura_kernel_lge_c50
drivers/dma/mpc512x_dma.c
C
gpl-2.0
22,994
/* ir-jvc-decoder.c - handle JVC IR Pulse/Space protocol * * Copyright (C) 2010 by David Härdeman <david@hardeman.nu> * * 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 version 2 of the License. * * 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. */ #include <linux/bitrev.h> #include <linux/module.h> #include "rc-core-priv.h" #define JVC_NBITS 16 /* dev(8) + func(8) */ #define JVC_UNIT 525000 /* ns */ #define JVC_HEADER_PULSE (16 * JVC_UNIT) /* lack of header -> repeat */ #define JVC_HEADER_SPACE (8 * JVC_UNIT) #define JVC_BIT_PULSE (1 * JVC_UNIT) #define JVC_BIT_0_SPACE (1 * JVC_UNIT) #define JVC_BIT_1_SPACE (3 * JVC_UNIT) #define JVC_TRAILER_PULSE (1 * JVC_UNIT) #define JVC_TRAILER_SPACE (35 * JVC_UNIT) enum jvc_state { STATE_INACTIVE, STATE_HEADER_SPACE, STATE_BIT_PULSE, STATE_BIT_SPACE, STATE_TRAILER_PULSE, STATE_TRAILER_SPACE, STATE_CHECK_REPEAT, }; /** * ir_jvc_decode() - Decode one JVC pulse or space * @dev: the struct rc_dev descriptor of the device * @duration: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev) { struct jvc_dec *data = &dev->raw->jvc; if (!(dev->enabled_protocols & RC_BIT_JVC)) return 0; if (!is_timing_event(ev)) { if (ev.reset) data->state = STATE_INACTIVE; return 0; } if (!geq_margin(ev.duration, JVC_UNIT, JVC_UNIT / 2)) goto out; IR_dprintk(2, "JVC decode started at state %d (%uus %s)\n", data->state, TO_US(ev.duration), TO_STR(ev.pulse)); again: switch (data->state) { case STATE_INACTIVE: if (!ev.pulse) break; if (!eq_margin(ev.duration, JVC_HEADER_PULSE, JVC_UNIT / 2)) break; data->count = 0; data->first = true; data->toggle = !data->toggle; data->state = STATE_HEADER_SPACE; return 0; case STATE_HEADER_SPACE: if (ev.pulse) break; if (!eq_margin(ev.duration, JVC_HEADER_SPACE, JVC_UNIT / 2)) break; data->state = STATE_BIT_PULSE; return 0; case STATE_BIT_PULSE: if (!ev.pulse) break; if (!eq_margin(ev.duration, JVC_BIT_PULSE, JVC_UNIT / 2)) break; data->state = STATE_BIT_SPACE; return 0; case STATE_BIT_SPACE: if (ev.pulse) break; data->bits <<= 1; if (eq_margin(ev.duration, JVC_BIT_1_SPACE, JVC_UNIT / 2)) { data->bits |= 1; decrease_duration(&ev, JVC_BIT_1_SPACE); } else if (eq_margin(ev.duration, JVC_BIT_0_SPACE, JVC_UNIT / 2)) decrease_duration(&ev, JVC_BIT_0_SPACE); else break; data->count++; if (data->count == JVC_NBITS) data->state = STATE_TRAILER_PULSE; else data->state = STATE_BIT_PULSE; return 0; case STATE_TRAILER_PULSE: if (!ev.pulse) break; if (!eq_margin(ev.duration, JVC_TRAILER_PULSE, JVC_UNIT / 2)) break; data->state = STATE_TRAILER_SPACE; return 0; case STATE_TRAILER_SPACE: if (ev.pulse) break; if (!geq_margin(ev.duration, JVC_TRAILER_SPACE, JVC_UNIT / 2)) break; if (data->first) { u32 scancode; scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | (bitrev8((data->bits >> 0) & 0xff) << 0); IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); rc_keydown(dev, scancode, data->toggle); data->first = false; data->old_bits = data->bits; } else if (data->bits == data->old_bits) { IR_dprintk(1, "JVC repeat\n"); rc_repeat(dev); } else { IR_dprintk(1, "JVC invalid repeat msg\n"); break; } data->count = 0; data->state = STATE_CHECK_REPEAT; return 0; case STATE_CHECK_REPEAT: if (!ev.pulse) break; if (eq_margin(ev.duration, JVC_HEADER_PULSE, JVC_UNIT / 2)) data->state = STATE_INACTIVE; else data->state = STATE_BIT_PULSE; goto again; } out: IR_dprintk(1, "JVC decode failed at state %d (%uus %s)\n", data->state, TO_US(ev.duration), TO_STR(ev.pulse)); data->state = STATE_INACTIVE; return -EINVAL; } static struct ir_raw_handler jvc_handler = { .protocols = RC_BIT_JVC, .decode = ir_jvc_decode, }; static int __init ir_jvc_decode_init(void) { ir_raw_handler_register(&jvc_handler); printk(KERN_INFO "IR JVC protocol handler initialized\n"); return 0; } static void __exit ir_jvc_decode_exit(void) { ir_raw_handler_unregister(&jvc_handler); } module_init(ir_jvc_decode_init); module_exit(ir_jvc_decode_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Härdeman <david@hardeman.nu>"); MODULE_DESCRIPTION("JVC IR protocol decoder");
ashwinr64/android_kernel_motorola_msm8952
drivers/media/rc/ir-jvc-decoder.c
C
gpl-2.0
4,784
/* ir-sony-decoder.c - handle Sony IR Pulse/Space protocol * * Copyright (C) 2010 by David Härdeman <david@hardeman.nu> * * 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 version 2 of the License. * * 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. */ #include <linux/bitrev.h> #include <linux/module.h> #include "rc-core-priv.h" #define SONY_UNIT 600000 /* ns */ #define SONY_HEADER_PULSE (4 * SONY_UNIT) #define SONY_HEADER_SPACE (1 * SONY_UNIT) #define SONY_BIT_0_PULSE (1 * SONY_UNIT) #define SONY_BIT_1_PULSE (2 * SONY_UNIT) #define SONY_BIT_SPACE (1 * SONY_UNIT) #define SONY_TRAILER_SPACE (10 * SONY_UNIT) /* minimum */ enum sony_state { STATE_INACTIVE, STATE_HEADER_SPACE, STATE_BIT_PULSE, STATE_BIT_SPACE, STATE_FINISHED, }; /** * ir_sony_decode() - Decode one Sony pulse or space * @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) { struct sony_dec *data = &dev->raw->sony; u32 scancode; u8 device, subdevice, function; if (!(dev->enabled_protocols & (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20))) return 0; if (!is_timing_event(ev)) { if (ev.reset) data->state = STATE_INACTIVE; return 0; } if (!geq_margin(ev.duration, SONY_UNIT, SONY_UNIT / 2)) goto out; IR_dprintk(2, "Sony decode started at state %d (%uus %s)\n", data->state, TO_US(ev.duration), TO_STR(ev.pulse)); switch (data->state) { case STATE_INACTIVE: if (!ev.pulse) break; if (!eq_margin(ev.duration, SONY_HEADER_PULSE, SONY_UNIT / 2)) break; data->count = 0; data->state = STATE_HEADER_SPACE; return 0; case STATE_HEADER_SPACE: if (ev.pulse) break; if (!eq_margin(ev.duration, SONY_HEADER_SPACE, SONY_UNIT / 2)) break; data->state = STATE_BIT_PULSE; return 0; case STATE_BIT_PULSE: if (!ev.pulse) break; data->bits <<= 1; if (eq_margin(ev.duration, SONY_BIT_1_PULSE, SONY_UNIT / 2)) data->bits |= 1; else if (!eq_margin(ev.duration, SONY_BIT_0_PULSE, SONY_UNIT / 2)) break; data->count++; data->state = STATE_BIT_SPACE; return 0; case STATE_BIT_SPACE: if (ev.pulse) break; if (!geq_margin(ev.duration, SONY_BIT_SPACE, SONY_UNIT / 2)) break; decrease_duration(&ev, SONY_BIT_SPACE); if (!geq_margin(ev.duration, SONY_UNIT, SONY_UNIT / 2)) { data->state = STATE_BIT_PULSE; return 0; } data->state = STATE_FINISHED; /* Fall through */ case STATE_FINISHED: if (ev.pulse) break; if (!geq_margin(ev.duration, SONY_TRAILER_SPACE, SONY_UNIT / 2)) break; switch (data->count) { case 12: if (!(dev->enabled_protocols & RC_BIT_SONY12)) { data->state = STATE_INACTIVE; return 0; } device = bitrev8((data->bits << 3) & 0xF8); subdevice = 0; function = bitrev8((data->bits >> 4) & 0xFE); break; case 15: if (!(dev->enabled_protocols & RC_BIT_SONY15)) { data->state = STATE_INACTIVE; return 0; } device = bitrev8((data->bits >> 0) & 0xFF); subdevice = 0; function = bitrev8((data->bits >> 7) & 0xFE); break; case 20: if (!(dev->enabled_protocols & RC_BIT_SONY20)) { data->state = STATE_INACTIVE; return 0; } device = bitrev8((data->bits >> 5) & 0xF8); subdevice = bitrev8((data->bits >> 0) & 0xFF); function = bitrev8((data->bits >> 12) & 0xFE); break; default: IR_dprintk(1, "Sony invalid bitcount %u\n", data->count); goto out; } scancode = device << 16 | subdevice << 8 | function; IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode); rc_keydown(dev, scancode, 0); data->state = STATE_INACTIVE; return 0; } out: IR_dprintk(1, "Sony decode failed at state %d (%uus %s)\n", data->state, TO_US(ev.duration), TO_STR(ev.pulse)); data->state = STATE_INACTIVE; return -EINVAL; } static struct ir_raw_handler sony_handler = { .protocols = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20, .decode = ir_sony_decode, }; static int __init ir_sony_decode_init(void) { ir_raw_handler_register(&sony_handler); printk(KERN_INFO "IR Sony protocol handler initialized\n"); return 0; } static void __exit ir_sony_decode_exit(void) { ir_raw_handler_unregister(&sony_handler); } module_init(ir_sony_decode_init); module_exit(ir_sony_decode_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Härdeman <david@hardeman.nu>"); MODULE_DESCRIPTION("Sony IR protocol decoder");
Astralix/mainline-dss11
drivers/media/rc/ir-sony-decoder.c
C
gpl-2.0
4,887
/* * NV-RAM memory access on autcpu12 * (C) 2002 Thomas Gleixner (gleixner@autronix.de) * * 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 <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/ioport.h> #include <linux/init.h> #include <asm/io.h> #include <asm/sizes.h> #include <mach/hardware.h> #include <mach/autcpu12.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> #include <linux/mtd/partitions.h> static struct mtd_info *sram_mtd; struct map_info autcpu12_sram_map = { .name = "SRAM", .size = 32768, .bankwidth = 4, .phys = 0x12000000, }; static int __init init_autcpu12_sram (void) { map_word tmp, save0, save1; int err; autcpu12_sram_map.virt = ioremap(0x12000000, SZ_128K); if (!autcpu12_sram_map.virt) { printk("Failed to ioremap autcpu12 NV-RAM space\n"); err = -EIO; goto out; } simple_map_init(&autcpu12_sram_map); /* * Check for 32K/128K * read ofs 0 * read ofs 0x10000 * Write complement to ofs 0x100000 * Read and check result on ofs 0x0 * Restore contents */ save0 = map_read(&autcpu12_sram_map, 0); save1 = map_read(&autcpu12_sram_map, 0x10000); tmp.x[0] = ~save0.x[0]; map_write(&autcpu12_sram_map, tmp, 0x10000); /* if we find this pattern on 0x0, we have 32K size * restore contents and exit */ tmp = map_read(&autcpu12_sram_map, 0); if (!map_word_equal(&autcpu12_sram_map, tmp, save0)) { map_write(&autcpu12_sram_map, save0, 0x0); goto map; } /* We have a 128K found, restore 0x10000 and set size * to 128K */ map_write(&autcpu12_sram_map, save1, 0x10000); autcpu12_sram_map.size = SZ_128K; map: sram_mtd = do_map_probe("map_ram", &autcpu12_sram_map); if (!sram_mtd) { printk("NV-RAM probe failed\n"); err = -ENXIO; goto out_ioremap; } sram_mtd->owner = THIS_MODULE; sram_mtd->erasesize = 16; if (mtd_device_register(sram_mtd, NULL, 0)) { printk("NV-RAM device addition failed\n"); err = -ENOMEM; goto out_probe; } printk("NV-RAM device size %ldKiB registered on AUTCPU12\n",autcpu12_sram_map.size/SZ_1K); return 0; out_probe: map_destroy(sram_mtd); sram_mtd = 0; out_ioremap: iounmap((void *)autcpu12_sram_map.virt); out: return err; } static void __exit cleanup_autcpu12_maps(void) { if (sram_mtd) { mtd_device_unregister(sram_mtd); map_destroy(sram_mtd); iounmap((void *)autcpu12_sram_map.virt); } } module_init(init_autcpu12_sram); module_exit(cleanup_autcpu12_maps); MODULE_AUTHOR("Thomas Gleixner"); MODULE_DESCRIPTION("autcpu12 NV-RAM map driver"); MODULE_LICENSE("GPL");
Fusion-Devices/android_kernel_samsung_jf
drivers/mtd/maps/autcpu12-nvram.c
C
gpl-2.0
3,227
/* * net/ipv4/sysfs_net_ipv4.c * * sysfs-based networking knobs (so we can, unlike with sysctl, control perms) * * Copyright (C) 2008 Google, Inc. * * Robert Love <rlove@google.com> * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. */ #include <linux/kobject.h> #include <linux/string.h> #include <linux/sysfs.h> #include <linux/init.h> #include <net/tcp.h> #define CREATE_IPV4_FILE(_name, _var) \ static ssize_t _name##_show(struct kobject *kobj, \ struct kobj_attribute *attr, char *buf) \ { \ return sprintf(buf, "%d\n", _var); \ } \ static ssize_t _name##_store(struct kobject *kobj, \ struct kobj_attribute *attr, \ const char *buf, size_t count) \ { \ int val, ret; \ ret = sscanf(buf, "%d", &val); \ if (ret != 1) \ return -EINVAL; \ if (val < 0) \ return -EINVAL; \ _var = val; \ return count; \ } \ static struct kobj_attribute _name##_attr = \ __ATTR(_name, 0644, _name##_show, _name##_store) CREATE_IPV4_FILE(tcp_wmem_min, sysctl_tcp_wmem[0]); CREATE_IPV4_FILE(tcp_wmem_def, sysctl_tcp_wmem[1]); CREATE_IPV4_FILE(tcp_wmem_max, sysctl_tcp_wmem[2]); CREATE_IPV4_FILE(tcp_rmem_min, sysctl_tcp_rmem[0]); CREATE_IPV4_FILE(tcp_rmem_def, sysctl_tcp_rmem[1]); CREATE_IPV4_FILE(tcp_rmem_max, sysctl_tcp_rmem[2]); CREATE_IPV4_FILE(tcp_delack_seg, sysctl_tcp_delack_seg); CREATE_IPV4_FILE(tcp_use_userconfig, sysctl_tcp_use_userconfig); static struct attribute *ipv4_attrs[] = { &tcp_wmem_min_attr.attr, &tcp_wmem_def_attr.attr, &tcp_wmem_max_attr.attr, &tcp_rmem_min_attr.attr, &tcp_rmem_def_attr.attr, &tcp_rmem_max_attr.attr, &tcp_delack_seg_attr.attr, &tcp_use_userconfig_attr.attr, NULL }; static struct attribute_group ipv4_attr_group = { .attrs = ipv4_attrs, }; static __init int sysfs_ipv4_init(void) { struct kobject *ipv4_kobject; int ret; ipv4_kobject = kobject_create_and_add("ipv4", kernel_kobj); if (!ipv4_kobject) return -ENOMEM; ret = sysfs_create_group(ipv4_kobject, &ipv4_attr_group); if (ret) { kobject_put(ipv4_kobject); return ret; } return 0; } subsys_initcall(sysfs_ipv4_init);
thicklizard/m9-patches
net/ipv4/sysfs_net_ipv4.c
C
gpl-2.0
2,488