target
int64
0
1
func
stringlengths
7
484k
func_no_comments
stringlengths
7
484k
idx
int64
1
368k
1
static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size, uint64_t max_mem) { DeviceState *dev; SysBusDevice *s; RamDevice *d; /* allocate RAM */ if ((uint64_t)RAM_size > max_mem) { fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n", (unsigned int)(RAM_size / (1024 * 1024)), (unsigned int)(max_mem / (1024 * 1024))); exit(1); } dev = qdev_create(NULL, "memory"); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = RAM_size; qdev_init(dev); sysbus_mmio_map(s, 0, addr); }
static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size, uint64_t max_mem) { DeviceState *dev; SysBusDevice *s; RamDevice *d; if ((uint64_t)RAM_size > max_mem) { fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n", (unsigned int)(RAM_size / (1024 * 1024)), (unsigned int)(max_mem / (1024 * 1024))); exit(1); } dev = qdev_create(NULL, "memory"); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = RAM_size; qdev_init(dev); sysbus_mmio_map(s, 0, addr); }
265
1
compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct mpt_fw_xfer32 kfw32; struct mpt_fw_xfer kfw; MPT_ADAPTER *iocp = NULL; int iocnum, iocnumX; int nonblock = (filp->f_flags & O_NONBLOCK); int ret; if (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32))) return -EFAULT; /* Verify intended MPT adapter */ iocnumX = kfw32.iocnum & 0xFF; if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || (iocp == NULL)) { printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", __LINE__, iocnumX); return -ENODEV; } if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0) return ret; dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "compat_mptfwxfer_ioctl() called\n", iocp->name)); kfw.iocnum = iocnum; kfw.fwlen = kfw32.fwlen; kfw.bufp = compat_ptr(kfw32.bufp); ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen); mutex_unlock(&iocp->ioctl_cmds.mutex); return ret; }
compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct mpt_fw_xfer32 kfw32; struct mpt_fw_xfer kfw; MPT_ADAPTER *iocp = NULL; int iocnum, iocnumX; int nonblock = (filp->f_flags & O_NONBLOCK); int ret; if (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32))) return -EFAULT; iocnumX = kfw32.iocnum & 0xFF; if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || (iocp == NULL)) { printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", __LINE__, iocnumX); return -ENODEV; } if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0) return ret; dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "compat_mptfwxfer_ioctl() called\n", iocp->name)); kfw.iocnum = iocnum; kfw.fwlen = kfw32.fwlen; kfw.bufp = compat_ptr(kfw32.bufp); ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen); mutex_unlock(&iocp->ioctl_cmds.mutex); return ret; }
266
0
static int ogg_read_header ( AVFormatContext * s ) { struct ogg * ogg = s -> priv_data ; int ret , i ; ogg -> curidx = - 1 ; do { ret = ogg_packet ( s , NULL , NULL , NULL , NULL ) ; if ( ret < 0 ) { ogg_read_close ( s ) ; return ret ; } } while ( ! ogg -> headers ) ; av_log ( s , AV_LOG_TRACE , "found headers\n" ) ; for ( i = 0 ; i < ogg -> nstreams ; i ++ ) { struct ogg_stream * os = ogg -> streams + i ; if ( ogg -> streams [ i ] . header < 0 ) { av_log ( s , AV_LOG_ERROR , "Header parsing failed for stream %d\n" , i ) ; ogg -> streams [ i ] . codec = NULL ; av_freep ( & ogg -> streams [ i ] . private ) ; } else if ( os -> codec && os -> nb_header < os -> codec -> nb_header ) { av_log ( s , AV_LOG_WARNING , "Headers mismatch for stream %d: " "expected %d received %d.\n" , i , os -> codec -> nb_header , os -> nb_header ) ; if ( s -> error_recognition & AV_EF_EXPLODE ) return AVERROR_INVALIDDATA ; } if ( os -> start_granule != OGG_NOGRANULE_VALUE ) os -> lastpts = s -> streams [ i ] -> start_time = ogg_gptopts ( s , i , os -> start_granule , NULL ) ; } ret = ogg_get_length ( s ) ; if ( ret < 0 ) { ogg_read_close ( s ) ; return ret ; } return 0 ; }
static int ogg_read_header ( AVFormatContext * s ) { struct ogg * ogg = s -> priv_data ; int ret , i ; ogg -> curidx = - 1 ; do { ret = ogg_packet ( s , NULL , NULL , NULL , NULL ) ; if ( ret < 0 ) { ogg_read_close ( s ) ; return ret ; } } while ( ! ogg -> headers ) ; av_log ( s , AV_LOG_TRACE , "found headers\n" ) ; for ( i = 0 ; i < ogg -> nstreams ; i ++ ) { struct ogg_stream * os = ogg -> streams + i ; if ( ogg -> streams [ i ] . header < 0 ) { av_log ( s , AV_LOG_ERROR , "Header parsing failed for stream %d\n" , i ) ; ogg -> streams [ i ] . codec = NULL ; av_freep ( & ogg -> streams [ i ] . private ) ; } else if ( os -> codec && os -> nb_header < os -> codec -> nb_header ) { av_log ( s , AV_LOG_WARNING , "Headers mismatch for stream %d: " "expected %d received %d.\n" , i , os -> codec -> nb_header , os -> nb_header ) ; if ( s -> error_recognition & AV_EF_EXPLODE ) return AVERROR_INVALIDDATA ; } if ( os -> start_granule != OGG_NOGRANULE_VALUE ) os -> lastpts = s -> streams [ i ] -> start_time = ogg_gptopts ( s , i , os -> start_granule , NULL ) ; } ret = ogg_get_length ( s ) ; if ( ret < 0 ) { ogg_read_close ( s ) ; return ret ; } return 0 ; }
267
1
static u32 __peek_user_compat(struct task_struct *child, addr_t addr) { struct user32 *dummy32 = NULL; per_struct32 *dummy_per32 = NULL; addr_t offset; __u32 tmp; if (addr < (addr_t) &dummy32->regs.acrs) { /* * psw and gprs are stored on the stack */ if (addr == (addr_t) &dummy32->regs.psw.mask) { /* Fake a 31 bit psw mask. */ tmp = (__u32)(task_pt_regs(child)->psw.mask >> 32); tmp = PSW32_MASK_MERGE(psw32_user_bits, tmp); } else if (addr == (addr_t) &dummy32->regs.psw.addr) { /* Fake a 31 bit psw address. */ tmp = (__u32) task_pt_regs(child)->psw.addr | PSW32_ADDR_AMODE31; } else { /* gpr 0-15 */ tmp = *(__u32 *)((addr_t) &task_pt_regs(child)->psw + addr*2 + 4); } } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) { /* * access registers are stored in the thread structure */ offset = addr - (addr_t) &dummy32->regs.acrs; tmp = *(__u32*)((addr_t) &child->thread.acrs + offset); } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) { /* * orig_gpr2 is stored on the kernel stack */ tmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4); } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) { /* * floating point regs. are stored in the thread structure */ offset = addr - (addr_t) &dummy32->regs.fp_regs; tmp = *(__u32 *)((addr_t) &child->thread.fp_regs + offset); } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) { /* * per_info is found in the thread structure */ offset = addr - (addr_t) &dummy32->regs.per_info; /* This is magic. See per_struct and per_struct32. */ if ((offset >= (addr_t) &dummy_per32->control_regs && offset < (addr_t) (&dummy_per32->control_regs + 1)) || (offset >= (addr_t) &dummy_per32->starting_addr && offset <= (addr_t) &dummy_per32->ending_addr) || offset == (addr_t) &dummy_per32->lowcore.words.address) offset = offset*2 + 4; else offset = offset*2; tmp = *(__u32 *)((addr_t) &child->thread.per_info + offset); } else tmp = 0; return tmp; }
static u32 __peek_user_compat(struct task_struct *child, addr_t addr) { struct user32 *dummy32 = NULL; per_struct32 *dummy_per32 = NULL; addr_t offset; __u32 tmp; if (addr < (addr_t) &dummy32->regs.acrs) { if (addr == (addr_t) &dummy32->regs.psw.mask) { tmp = (__u32)(task_pt_regs(child)->psw.mask >> 32); tmp = PSW32_MASK_MERGE(psw32_user_bits, tmp); } else if (addr == (addr_t) &dummy32->regs.psw.addr) { tmp = (__u32) task_pt_regs(child)->psw.addr | PSW32_ADDR_AMODE31; } else { tmp = *(__u32 *)((addr_t) &task_pt_regs(child)->psw + addr*2 + 4); } } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) { offset = addr - (addr_t) &dummy32->regs.acrs; tmp = *(__u32*)((addr_t) &child->thread.acrs + offset); } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) { tmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4); } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) { offset = addr - (addr_t) &dummy32->regs.fp_regs; tmp = *(__u32 *)((addr_t) &child->thread.fp_regs + offset); } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) { offset = addr - (addr_t) &dummy32->regs.per_info; if ((offset >= (addr_t) &dummy_per32->control_regs && offset < (addr_t) (&dummy_per32->control_regs + 1)) || (offset >= (addr_t) &dummy_per32->starting_addr && offset <= (addr_t) &dummy_per32->ending_addr) || offset == (addr_t) &dummy_per32->lowcore.words.address) offset = offset*2 + 4; else offset = offset*2; tmp = *(__u32 *)((addr_t) &child->thread.per_info + offset); } else tmp = 0; return tmp; }
268
1
int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align) { int i, first = -1; ICSState *ics = &icp->ics[src]; assert(src == 0); /* * MSIMesage::data is used for storing VIRQ so * it has to be aligned to num to support multiple * MSI vectors. MSI-X is not affected by this. * The hint is used for the first IRQ, the rest should * be allocated continuously. */ if (align) { assert((num == 1) || (num == 2) || (num == 4) || (num == 8) || (num == 16) || (num == 32)); first = ics_find_free_block(ics, num, num); } else { first = ics_find_free_block(ics, num, 1); } if (first >= 0) { for (i = first; i < first + num; ++i) { ics_set_irq_type(ics, i, lsi); } } first += ics->offset; trace_xics_alloc_block(src, first, num, lsi, align); return first; }
int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align) { int i, first = -1; ICSState *ics = &icp->ics[src]; assert(src == 0); if (align) { assert((num == 1) || (num == 2) || (num == 4) || (num == 8) || (num == 16) || (num == 32)); first = ics_find_free_block(ics, num, num); } else { first = ics_find_free_block(ics, num, 1); } if (first >= 0) { for (i = first; i < first + num; ++i) { ics_set_irq_type(ics, i, lsi); } } first += ics->offset; trace_xics_alloc_block(src, first, num, lsi, align); return first; }
269
0
mptctl_do_fw_download(MPT_ADAPTER *iocp, char __user *ufwbuf, size_t fwlen) { FWDownload_t *dlmsg; MPT_FRAME_HDR *mf; FWDownloadTCSGE_t *ptsge; MptSge_t *sgl, *sgIn; char *sgOut; struct buflist *buflist; struct buflist *bl; dma_addr_t sgl_dma; int ret; int numfrags = 0; int maxfrags; int n = 0; u32 sgdir; u32 nib; int fw_bytes_copied = 0; int i; int sge_offset = 0; u16 iocstat; pFWDownloadReply_t ReplyMsg = NULL; unsigned long timeleft; /* Valid device. Get a message frame and construct the FW download message. */ if ((mf = mpt_get_msg_frame(mptctl_id, iocp)) == NULL) return -EAGAIN; dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_fwdl called. mptctl_id = %xh.\n", iocp->name, mptctl_id)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.bufp = %p\n", iocp->name, ufwbuf)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.fwlen = %d\n", iocp->name, (int)fwlen)); dlmsg = (FWDownload_t*) mf; ptsge = (FWDownloadTCSGE_t *) &dlmsg->SGL; sgOut = (char *) (ptsge + 1); /* * Construct f/w download request */ dlmsg->ImageType = MPI_FW_DOWNLOAD_ITYPE_FW; dlmsg->Reserved = 0; dlmsg->ChainOffset = 0; dlmsg->Function = MPI_FUNCTION_FW_DOWNLOAD; dlmsg->Reserved1[0] = dlmsg->Reserved1[1] = dlmsg->Reserved1[2] = 0; if (iocp->facts.MsgVersion >= MPI_VERSION_01_05) dlmsg->MsgFlags = MPI_FW_DOWNLOAD_MSGFLGS_LAST_SEGMENT; else dlmsg->MsgFlags = 0; /* Set up the Transaction SGE. */ ptsge->Reserved = 0; ptsge->ContextSize = 0; ptsge->DetailsLength = 12; ptsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; ptsge->Reserved_0100_Checksum = 0; ptsge->ImageOffset = 0; ptsge->ImageSize = cpu_to_le32(fwlen); /* Add the SGL */ /* * Need to kmalloc area(s) for holding firmware image bytes. * But we need to do it piece meal, using a proper * scatter gather list (with 128kB MAX hunks). * * A practical limit here might be # of sg hunks that fit into * a single IOC request frame; 12 or 8 (see below), so: * For FC9xx: 12 x 128kB == 1.5 mB (max) * For C1030: 8 x 128kB == 1 mB (max) * We could support chaining, but things get ugly(ier:) * * Set the sge_offset to the start of the sgl (bytes). */ sgdir = 0x04000000; /* IOC will READ from sys mem */ sge_offset = sizeof(MPIHeader_t) + sizeof(FWDownloadTCSGE_t); if ((sgl = kbuf_alloc_2_sgl(fwlen, sgdir, sge_offset, &numfrags, &buflist, &sgl_dma, iocp)) == NULL) return -ENOMEM; /* * We should only need SGL with 2 simple_32bit entries (up to 256 kB) * for FC9xx f/w image, but calculate max number of sge hunks * we can fit into a request frame, and limit ourselves to that. * (currently no chain support) * maxfrags = (Request Size - FWdownload Size ) / Size of 32 bit SGE * Request maxfrags * 128 12 * 96 8 * 64 4 */ maxfrags = (iocp->req_sz - sizeof(MPIHeader_t) - sizeof(FWDownloadTCSGE_t)) / iocp->SGE_size; if (numfrags > maxfrags) { ret = -EMLINK; goto fwdl_out; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: sgl buffer = %p, sgfrags = %d\n", iocp->name, sgl, numfrags)); /* * Parse SG list, copying sgl itself, * plus f/w image hunks from user space as we go... */ ret = -EFAULT; sgIn = sgl; bl = buflist; for (i=0; i < numfrags; i++) { /* Get the SGE type: 0 - TCSGE, 3 - Chain, 1 - Simple SGE * Skip everything but Simple. If simple, copy from * user space into kernel space. * Note: we should not have anything but Simple as * Chain SGE are illegal. */ nib = (sgIn->FlagsLength & 0x30000000) >> 28; if (nib == 0 || nib == 3) { ; } else if (sgIn->Address) { iocp->add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); n++; if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { printk(MYIOC_s_ERR_FMT "%s@%d::_ioctl_fwdl - " "Unable to copy f/w buffer hunk#%d @ %p\n", iocp->name, __FILE__, __LINE__, n, ufwbuf); goto fwdl_out; } fw_bytes_copied += bl->len; } sgIn++; bl++; sgOut += iocp->SGE_size; } DBG_DUMP_FW_DOWNLOAD(iocp, (u32 *)mf, numfrags); /* * Finally, perform firmware download. */ ReplyMsg = NULL; SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, dlmsg->MsgContext); INITIALIZE_MGMT_STATUS(iocp->ioctl_cmds.status) mpt_put_msg_frame(mptctl_id, iocp, mf); /* Now wait for the command to complete */ retry_wait: timeleft = wait_for_completion_timeout(&iocp->ioctl_cmds.done, HZ*60); if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { ret = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); if (iocp->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(iocp, mf); goto fwdl_out; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "FW download timeout, doorbell=0x%08x\n", iocp->name, mpt_GetIocState(iocp, 0)); mptctl_timeout_expired(iocp, mf); } else goto retry_wait; goto fwdl_out; } if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); mpt_free_msg_frame(iocp, mf); ret = -ENODATA; goto fwdl_out; } if (sgl) kfree_sgl(sgl, sgl_dma, buflist, iocp); ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; if (iocstat == MPI_IOCSTATUS_SUCCESS) { printk(MYIOC_s_INFO_FMT "F/W update successful!\n", iocp->name); return 0; } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(time to go bang on somebodies door)\n", iocp->name); return -EBADRQC; } else if (iocstat == MPI_IOCSTATUS_BUSY) { printk(MYIOC_s_WARN_FMT "IOC_BUSY!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(try again later?)\n", iocp->name); return -EBUSY; } else { printk(MYIOC_s_WARN_FMT "ioctl_fwdl() returned [bad] status = %04xh\n", iocp->name, iocstat); printk(MYIOC_s_WARN_FMT "(bad VooDoo)\n", iocp->name); return -ENOMSG; } return 0; fwdl_out: CLEAR_MGMT_STATUS(iocp->ioctl_cmds.status); SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, 0); kfree_sgl(sgl, sgl_dma, buflist, iocp); return ret; }
mptctl_do_fw_download(MPT_ADAPTER *iocp, char __user *ufwbuf, size_t fwlen) { FWDownload_t *dlmsg; MPT_FRAME_HDR *mf; FWDownloadTCSGE_t *ptsge; MptSge_t *sgl, *sgIn; char *sgOut; struct buflist *buflist; struct buflist *bl; dma_addr_t sgl_dma; int ret; int numfrags = 0; int maxfrags; int n = 0; u32 sgdir; u32 nib; int fw_bytes_copied = 0; int i; int sge_offset = 0; u16 iocstat; pFWDownloadReply_t ReplyMsg = NULL; unsigned long timeleft; if ((mf = mpt_get_msg_frame(mptctl_id, iocp)) == NULL) return -EAGAIN; dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_fwdl called. mptctl_id = %xh.\n", iocp->name, mptctl_id)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.bufp = %p\n", iocp->name, ufwbuf)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.fwlen = %d\n", iocp->name, (int)fwlen)); dlmsg = (FWDownload_t*) mf; ptsge = (FWDownloadTCSGE_t *) &dlmsg->SGL; sgOut = (char *) (ptsge + 1); dlmsg->ImageType = MPI_FW_DOWNLOAD_ITYPE_FW; dlmsg->Reserved = 0; dlmsg->ChainOffset = 0; dlmsg->Function = MPI_FUNCTION_FW_DOWNLOAD; dlmsg->Reserved1[0] = dlmsg->Reserved1[1] = dlmsg->Reserved1[2] = 0; if (iocp->facts.MsgVersion >= MPI_VERSION_01_05) dlmsg->MsgFlags = MPI_FW_DOWNLOAD_MSGFLGS_LAST_SEGMENT; else dlmsg->MsgFlags = 0; ptsge->Reserved = 0; ptsge->ContextSize = 0; ptsge->DetailsLength = 12; ptsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; ptsge->Reserved_0100_Checksum = 0; ptsge->ImageOffset = 0; ptsge->ImageSize = cpu_to_le32(fwlen); sgdir = 0x04000000; sge_offset = sizeof(MPIHeader_t) + sizeof(FWDownloadTCSGE_t); if ((sgl = kbuf_alloc_2_sgl(fwlen, sgdir, sge_offset, &numfrags, &buflist, &sgl_dma, iocp)) == NULL) return -ENOMEM; maxfrags = (iocp->req_sz - sizeof(MPIHeader_t) - sizeof(FWDownloadTCSGE_t)) / iocp->SGE_size; if (numfrags > maxfrags) { ret = -EMLINK; goto fwdl_out; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: sgl buffer = %p, sgfrags = %d\n", iocp->name, sgl, numfrags)); ret = -EFAULT; sgIn = sgl; bl = buflist; for (i=0; i < numfrags; i++) { nib = (sgIn->FlagsLength & 0x30000000) >> 28; if (nib == 0 || nib == 3) { ; } else if (sgIn->Address) { iocp->add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); n++; if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { printk(MYIOC_s_ERR_FMT "%s@%d::_ioctl_fwdl - " "Unable to copy f/w buffer hunk#%d @ %p\n", iocp->name, __FILE__, __LINE__, n, ufwbuf); goto fwdl_out; } fw_bytes_copied += bl->len; } sgIn++; bl++; sgOut += iocp->SGE_size; } DBG_DUMP_FW_DOWNLOAD(iocp, (u32 *)mf, numfrags); ReplyMsg = NULL; SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, dlmsg->MsgContext); INITIALIZE_MGMT_STATUS(iocp->ioctl_cmds.status) mpt_put_msg_frame(mptctl_id, iocp, mf); retry_wait: timeleft = wait_for_completion_timeout(&iocp->ioctl_cmds.done, HZ*60); if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { ret = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); if (iocp->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(iocp, mf); goto fwdl_out; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "FW download timeout, doorbell=0x%08x\n", iocp->name, mpt_GetIocState(iocp, 0)); mptctl_timeout_expired(iocp, mf); } else goto retry_wait; goto fwdl_out; } if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); mpt_free_msg_frame(iocp, mf); ret = -ENODATA; goto fwdl_out; } if (sgl) kfree_sgl(sgl, sgl_dma, buflist, iocp); ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; if (iocstat == MPI_IOCSTATUS_SUCCESS) { printk(MYIOC_s_INFO_FMT "F/W update successful!\n", iocp->name); return 0; } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(time to go bang on somebodies door)\n", iocp->name); return -EBADRQC; } else if (iocstat == MPI_IOCSTATUS_BUSY) { printk(MYIOC_s_WARN_FMT "IOC_BUSY!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(try again later?)\n", iocp->name); return -EBUSY; } else { printk(MYIOC_s_WARN_FMT "ioctl_fwdl() returned [bad] status = %04xh\n", iocp->name, iocstat); printk(MYIOC_s_WARN_FMT "(bad VooDoo)\n", iocp->name); return -ENOMSG; } return 0; fwdl_out: CLEAR_MGMT_STATUS(iocp->ioctl_cmds.status); SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, 0); kfree_sgl(sgl, sgl_dma, buflist, iocp); return ret; }
270
1
acc_ctx_hints(OM_uint32 *minor_status, gss_ctx_id_t *ctx, spnego_gss_cred_id_t spcred, gss_buffer_t *mechListMIC, OM_uint32 *negState, send_token_flag *return_token) { OM_uint32 tmpmin, ret; gss_OID_set supported_mechSet; spnego_gss_ctx_id_t sc = NULL; *mechListMIC = GSS_C_NO_BUFFER; supported_mechSet = GSS_C_NO_OID_SET; *return_token = NO_TOKEN_SEND; *negState = REJECT; *minor_status = 0; /* A hint request must be the first token received. */ if (*ctx != GSS_C_NO_CONTEXT) return GSS_S_DEFECTIVE_TOKEN; ret = get_negotiable_mechs(minor_status, spcred, GSS_C_ACCEPT, &supported_mechSet); if (ret != GSS_S_COMPLETE) goto cleanup; ret = make_NegHints(minor_status, mechListMIC); if (ret != GSS_S_COMPLETE) goto cleanup; sc = create_spnego_ctx(); if (sc == NULL) { ret = GSS_S_FAILURE; goto cleanup; } if (put_mech_set(supported_mechSet, &sc->DER_mechTypes) < 0) { ret = GSS_S_FAILURE; goto cleanup; } sc->internal_mech = GSS_C_NO_OID; *negState = ACCEPT_INCOMPLETE; *return_token = INIT_TOKEN_SEND; sc->firstpass = 1; *ctx = (gss_ctx_id_t)sc; sc = NULL; ret = GSS_S_COMPLETE; cleanup: release_spnego_ctx(&sc); gss_release_oid_set(&tmpmin, &supported_mechSet); return ret; }
acc_ctx_hints(OM_uint32 *minor_status, gss_ctx_id_t *ctx, spnego_gss_cred_id_t spcred, gss_buffer_t *mechListMIC, OM_uint32 *negState, send_token_flag *return_token) { OM_uint32 tmpmin, ret; gss_OID_set supported_mechSet; spnego_gss_ctx_id_t sc = NULL; *mechListMIC = GSS_C_NO_BUFFER; supported_mechSet = GSS_C_NO_OID_SET; *return_token = NO_TOKEN_SEND; *negState = REJECT; *minor_status = 0; if (*ctx != GSS_C_NO_CONTEXT) return GSS_S_DEFECTIVE_TOKEN; ret = get_negotiable_mechs(minor_status, spcred, GSS_C_ACCEPT, &supported_mechSet); if (ret != GSS_S_COMPLETE) goto cleanup; ret = make_NegHints(minor_status, mechListMIC); if (ret != GSS_S_COMPLETE) goto cleanup; sc = create_spnego_ctx(); if (sc == NULL) { ret = GSS_S_FAILURE; goto cleanup; } if (put_mech_set(supported_mechSet, &sc->DER_mechTypes) < 0) { ret = GSS_S_FAILURE; goto cleanup; } sc->internal_mech = GSS_C_NO_OID; *negState = ACCEPT_INCOMPLETE; *return_token = INIT_TOKEN_SEND; sc->firstpass = 1; *ctx = (gss_ctx_id_t)sc; sc = NULL; ret = GSS_S_COMPLETE; cleanup: release_spnego_ctx(&sc); gss_release_oid_set(&tmpmin, &supported_mechSet); return ret; }
271
1
int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) { struct dnotify_struct *dn; struct dnotify_struct *odn; struct dnotify_struct **prev; struct inode *inode; fl_owner_t id = current->files; int error = 0; if ((arg & ~DN_MULTISHOT) == 0) { dnotify_flush(filp, id); return 0; } if (!dir_notify_enable) return -EINVAL; inode = filp->f_path.dentry->d_inode; if (!S_ISDIR(inode->i_mode)) return -ENOTDIR; dn = kmem_cache_alloc(dn_cache, GFP_KERNEL); if (dn == NULL) return -ENOMEM; spin_lock(&inode->i_lock); prev = &inode->i_dnotify; while ((odn = *prev) != NULL) { if ((odn->dn_owner == id) && (odn->dn_filp == filp)) { odn->dn_fd = fd; odn->dn_mask |= arg; inode->i_dnotify_mask |= arg & ~DN_MULTISHOT; goto out_free; } prev = &odn->dn_next; } error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); if (error) goto out_free; dn->dn_mask = arg; dn->dn_fd = fd; dn->dn_filp = filp; dn->dn_owner = id; inode->i_dnotify_mask |= arg & ~DN_MULTISHOT; dn->dn_next = inode->i_dnotify; inode->i_dnotify = dn; spin_unlock(&inode->i_lock); if (filp->f_op && filp->f_op->dir_notify) return filp->f_op->dir_notify(filp, arg); return 0; out_free: spin_unlock(&inode->i_lock); kmem_cache_free(dn_cache, dn); return error; }
int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) { struct dnotify_struct *dn; struct dnotify_struct *odn; struct dnotify_struct **prev; struct inode *inode; fl_owner_t id = current->files; int error = 0; if ((arg & ~DN_MULTISHOT) == 0) { dnotify_flush(filp, id); return 0; } if (!dir_notify_enable) return -EINVAL; inode = filp->f_path.dentry->d_inode; if (!S_ISDIR(inode->i_mode)) return -ENOTDIR; dn = kmem_cache_alloc(dn_cache, GFP_KERNEL); if (dn == NULL) return -ENOMEM; spin_lock(&inode->i_lock); prev = &inode->i_dnotify; while ((odn = *prev) != NULL) { if ((odn->dn_owner == id) && (odn->dn_filp == filp)) { odn->dn_fd = fd; odn->dn_mask |= arg; inode->i_dnotify_mask |= arg & ~DN_MULTISHOT; goto out_free; } prev = &odn->dn_next; } error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); if (error) goto out_free; dn->dn_mask = arg; dn->dn_fd = fd; dn->dn_filp = filp; dn->dn_owner = id; inode->i_dnotify_mask |= arg & ~DN_MULTISHOT; dn->dn_next = inode->i_dnotify; inode->i_dnotify = dn; spin_unlock(&inode->i_lock); if (filp->f_op && filp->f_op->dir_notify) return filp->f_op->dir_notify(filp, arg); return 0; out_free: spin_unlock(&inode->i_lock); kmem_cache_free(dn_cache, dn); return error; }
273
1
mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) { FWDownload_t *dlmsg; MPT_FRAME_HDR *mf; MPT_ADAPTER *iocp; FWDownloadTCSGE_t *ptsge; MptSge_t *sgl, *sgIn; char *sgOut; struct buflist *buflist; struct buflist *bl; dma_addr_t sgl_dma; int ret; int numfrags = 0; int maxfrags; int n = 0; u32 sgdir; u32 nib; int fw_bytes_copied = 0; int i; int sge_offset = 0; u16 iocstat; pFWDownloadReply_t ReplyMsg = NULL; unsigned long timeleft; if (mpt_verify_adapter(ioc, &iocp) < 0) { printk(KERN_DEBUG MYNAM "ioctl_fwdl - ioc%d not found!\n", ioc); return -ENODEV; /* (-6) No such device or address */ } else { /* Valid device. Get a message frame and construct the FW download message. */ if ((mf = mpt_get_msg_frame(mptctl_id, iocp)) == NULL) return -EAGAIN; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_fwdl called. mptctl_id = %xh.\n", iocp->name, mptctl_id)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.bufp = %p\n", iocp->name, ufwbuf)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.fwlen = %d\n", iocp->name, (int)fwlen)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.ioc = %04xh\n", iocp->name, ioc)); dlmsg = (FWDownload_t*) mf; ptsge = (FWDownloadTCSGE_t *) &dlmsg->SGL; sgOut = (char *) (ptsge + 1); /* * Construct f/w download request */ dlmsg->ImageType = MPI_FW_DOWNLOAD_ITYPE_FW; dlmsg->Reserved = 0; dlmsg->ChainOffset = 0; dlmsg->Function = MPI_FUNCTION_FW_DOWNLOAD; dlmsg->Reserved1[0] = dlmsg->Reserved1[1] = dlmsg->Reserved1[2] = 0; if (iocp->facts.MsgVersion >= MPI_VERSION_01_05) dlmsg->MsgFlags = MPI_FW_DOWNLOAD_MSGFLGS_LAST_SEGMENT; else dlmsg->MsgFlags = 0; /* Set up the Transaction SGE. */ ptsge->Reserved = 0; ptsge->ContextSize = 0; ptsge->DetailsLength = 12; ptsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; ptsge->Reserved_0100_Checksum = 0; ptsge->ImageOffset = 0; ptsge->ImageSize = cpu_to_le32(fwlen); /* Add the SGL */ /* * Need to kmalloc area(s) for holding firmware image bytes. * But we need to do it piece meal, using a proper * scatter gather list (with 128kB MAX hunks). * * A practical limit here might be # of sg hunks that fit into * a single IOC request frame; 12 or 8 (see below), so: * For FC9xx: 12 x 128kB == 1.5 mB (max) * For C1030: 8 x 128kB == 1 mB (max) * We could support chaining, but things get ugly(ier:) * * Set the sge_offset to the start of the sgl (bytes). */ sgdir = 0x04000000; /* IOC will READ from sys mem */ sge_offset = sizeof(MPIHeader_t) + sizeof(FWDownloadTCSGE_t); if ((sgl = kbuf_alloc_2_sgl(fwlen, sgdir, sge_offset, &numfrags, &buflist, &sgl_dma, iocp)) == NULL) return -ENOMEM; /* * We should only need SGL with 2 simple_32bit entries (up to 256 kB) * for FC9xx f/w image, but calculate max number of sge hunks * we can fit into a request frame, and limit ourselves to that. * (currently no chain support) * maxfrags = (Request Size - FWdownload Size ) / Size of 32 bit SGE * Request maxfrags * 128 12 * 96 8 * 64 4 */ maxfrags = (iocp->req_sz - sizeof(MPIHeader_t) - sizeof(FWDownloadTCSGE_t)) / iocp->SGE_size; if (numfrags > maxfrags) { ret = -EMLINK; goto fwdl_out; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: sgl buffer = %p, sgfrags = %d\n", iocp->name, sgl, numfrags)); /* * Parse SG list, copying sgl itself, * plus f/w image hunks from user space as we go... */ ret = -EFAULT; sgIn = sgl; bl = buflist; for (i=0; i < numfrags; i++) { /* Get the SGE type: 0 - TCSGE, 3 - Chain, 1 - Simple SGE * Skip everything but Simple. If simple, copy from * user space into kernel space. * Note: we should not have anything but Simple as * Chain SGE are illegal. */ nib = (sgIn->FlagsLength & 0x30000000) >> 28; if (nib == 0 || nib == 3) { ; } else if (sgIn->Address) { iocp->add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); n++; if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { printk(MYIOC_s_ERR_FMT "%s@%d::_ioctl_fwdl - " "Unable to copy f/w buffer hunk#%d @ %p\n", iocp->name, __FILE__, __LINE__, n, ufwbuf); goto fwdl_out; } fw_bytes_copied += bl->len; } sgIn++; bl++; sgOut += iocp->SGE_size; } DBG_DUMP_FW_DOWNLOAD(iocp, (u32 *)mf, numfrags); /* * Finally, perform firmware download. */ ReplyMsg = NULL; SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, dlmsg->MsgContext); INITIALIZE_MGMT_STATUS(iocp->ioctl_cmds.status) mpt_put_msg_frame(mptctl_id, iocp, mf); /* Now wait for the command to complete */ retry_wait: timeleft = wait_for_completion_timeout(&iocp->ioctl_cmds.done, HZ*60); if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { ret = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); if (iocp->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(iocp, mf); goto fwdl_out; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "FW download timeout, doorbell=0x%08x\n", iocp->name, mpt_GetIocState(iocp, 0)); mptctl_timeout_expired(iocp, mf); } else goto retry_wait; goto fwdl_out; } if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); mpt_free_msg_frame(iocp, mf); ret = -ENODATA; goto fwdl_out; } if (sgl) kfree_sgl(sgl, sgl_dma, buflist, iocp); ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; if (iocstat == MPI_IOCSTATUS_SUCCESS) { printk(MYIOC_s_INFO_FMT "F/W update successful!\n", iocp->name); return 0; } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(time to go bang on somebodies door)\n", iocp->name); return -EBADRQC; } else if (iocstat == MPI_IOCSTATUS_BUSY) { printk(MYIOC_s_WARN_FMT "IOC_BUSY!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(try again later?)\n", iocp->name); return -EBUSY; } else { printk(MYIOC_s_WARN_FMT "ioctl_fwdl() returned [bad] status = %04xh\n", iocp->name, iocstat); printk(MYIOC_s_WARN_FMT "(bad VooDoo)\n", iocp->name); return -ENOMSG; } return 0; fwdl_out: CLEAR_MGMT_STATUS(iocp->ioctl_cmds.status); SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, 0); kfree_sgl(sgl, sgl_dma, buflist, iocp); return ret; }
mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) { FWDownload_t *dlmsg; MPT_FRAME_HDR *mf; MPT_ADAPTER *iocp; FWDownloadTCSGE_t *ptsge; MptSge_t *sgl, *sgIn; char *sgOut; struct buflist *buflist; struct buflist *bl; dma_addr_t sgl_dma; int ret; int numfrags = 0; int maxfrags; int n = 0; u32 sgdir; u32 nib; int fw_bytes_copied = 0; int i; int sge_offset = 0; u16 iocstat; pFWDownloadReply_t ReplyMsg = NULL; unsigned long timeleft; if (mpt_verify_adapter(ioc, &iocp) < 0) { printk(KERN_DEBUG MYNAM "ioctl_fwdl - ioc%d not found!\n", ioc); return -ENODEV; } else { if ((mf = mpt_get_msg_frame(mptctl_id, iocp)) == NULL) return -EAGAIN; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_fwdl called. mptctl_id = %xh.\n", iocp->name, mptctl_id)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.bufp = %p\n", iocp->name, ufwbuf)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.fwlen = %d\n", iocp->name, (int)fwlen)); dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.ioc = %04xh\n", iocp->name, ioc)); dlmsg = (FWDownload_t*) mf; ptsge = (FWDownloadTCSGE_t *) &dlmsg->SGL; sgOut = (char *) (ptsge + 1); dlmsg->ImageType = MPI_FW_DOWNLOAD_ITYPE_FW; dlmsg->Reserved = 0; dlmsg->ChainOffset = 0; dlmsg->Function = MPI_FUNCTION_FW_DOWNLOAD; dlmsg->Reserved1[0] = dlmsg->Reserved1[1] = dlmsg->Reserved1[2] = 0; if (iocp->facts.MsgVersion >= MPI_VERSION_01_05) dlmsg->MsgFlags = MPI_FW_DOWNLOAD_MSGFLGS_LAST_SEGMENT; else dlmsg->MsgFlags = 0; ptsge->Reserved = 0; ptsge->ContextSize = 0; ptsge->DetailsLength = 12; ptsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; ptsge->Reserved_0100_Checksum = 0; ptsge->ImageOffset = 0; ptsge->ImageSize = cpu_to_le32(fwlen); sgdir = 0x04000000; sge_offset = sizeof(MPIHeader_t) + sizeof(FWDownloadTCSGE_t); if ((sgl = kbuf_alloc_2_sgl(fwlen, sgdir, sge_offset, &numfrags, &buflist, &sgl_dma, iocp)) == NULL) return -ENOMEM; maxfrags = (iocp->req_sz - sizeof(MPIHeader_t) - sizeof(FWDownloadTCSGE_t)) / iocp->SGE_size; if (numfrags > maxfrags) { ret = -EMLINK; goto fwdl_out; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: sgl buffer = %p, sgfrags = %d\n", iocp->name, sgl, numfrags)); ret = -EFAULT; sgIn = sgl; bl = buflist; for (i=0; i < numfrags; i++) { nib = (sgIn->FlagsLength & 0x30000000) >> 28; if (nib == 0 || nib == 3) { ; } else if (sgIn->Address) { iocp->add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); n++; if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { printk(MYIOC_s_ERR_FMT "%s@%d::_ioctl_fwdl - " "Unable to copy f/w buffer hunk#%d @ %p\n", iocp->name, __FILE__, __LINE__, n, ufwbuf); goto fwdl_out; } fw_bytes_copied += bl->len; } sgIn++; bl++; sgOut += iocp->SGE_size; } DBG_DUMP_FW_DOWNLOAD(iocp, (u32 *)mf, numfrags); ReplyMsg = NULL; SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, dlmsg->MsgContext); INITIALIZE_MGMT_STATUS(iocp->ioctl_cmds.status) mpt_put_msg_frame(mptctl_id, iocp, mf); retry_wait: timeleft = wait_for_completion_timeout(&iocp->ioctl_cmds.done, HZ*60); if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { ret = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); if (iocp->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(iocp, mf); goto fwdl_out; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "FW download timeout, doorbell=0x%08x\n", iocp->name, mpt_GetIocState(iocp, 0)); mptctl_timeout_expired(iocp, mf); } else goto retry_wait; goto fwdl_out; } if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); mpt_free_msg_frame(iocp, mf); ret = -ENODATA; goto fwdl_out; } if (sgl) kfree_sgl(sgl, sgl_dma, buflist, iocp); ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; if (iocstat == MPI_IOCSTATUS_SUCCESS) { printk(MYIOC_s_INFO_FMT "F/W update successful!\n", iocp->name); return 0; } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(time to go bang on somebodies door)\n", iocp->name); return -EBADRQC; } else if (iocstat == MPI_IOCSTATUS_BUSY) { printk(MYIOC_s_WARN_FMT "IOC_BUSY!\n", iocp->name); printk(MYIOC_s_WARN_FMT "(try again later?)\n", iocp->name); return -EBUSY; } else { printk(MYIOC_s_WARN_FMT "ioctl_fwdl() returned [bad] status = %04xh\n", iocp->name, iocstat); printk(MYIOC_s_WARN_FMT "(bad VooDoo)\n", iocp->name); return -ENOMSG; } return 0; fwdl_out: CLEAR_MGMT_STATUS(iocp->ioctl_cmds.status); SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, 0); kfree_sgl(sgl, sgl_dma, buflist, iocp); return ret; }
274
0
static void generate_joint_tables ( HYuvContext * s ) { uint16_t symbols [ 1 << VLC_BITS ] ; uint16_t bits [ 1 << VLC_BITS ] ; uint8_t len [ 1 << VLC_BITS ] ; if ( s -> bitstream_bpp < 24 ) { int p , i , y , u ; for ( p = 0 ; p < 3 ; p ++ ) { for ( i = y = 0 ; y < 256 ; y ++ ) { int len0 = s -> len [ 0 ] [ y ] ; int limit = VLC_BITS - len0 ; if ( limit <= 0 ) continue ; for ( u = 0 ; u < 256 ; u ++ ) { int len1 = s -> len [ p ] [ u ] ; if ( len1 > limit ) continue ; len [ i ] = len0 + len1 ; bits [ i ] = ( s -> bits [ 0 ] [ y ] << len1 ) + s -> bits [ p ] [ u ] ; symbols [ i ] = ( y << 8 ) + u ; if ( symbols [ i ] != 0xffff ) i ++ ; } } ff_free_vlc ( & s -> vlc [ 3 + p ] ) ; ff_init_vlc_sparse ( & s -> vlc [ 3 + p ] , VLC_BITS , i , len , 1 , 1 , bits , 2 , 2 , symbols , 2 , 2 , 0 ) ; } } else { uint8_t ( * map ) [ 4 ] = ( uint8_t ( * ) [ 4 ] ) s -> pix_bgr_map ; int i , b , g , r , code ; int p0 = s -> decorrelate ; int p1 = ! s -> decorrelate ; for ( i = 0 , g = - 16 ; g < 16 ; g ++ ) { int len0 = s -> len [ p0 ] [ g & 255 ] ; int limit0 = VLC_BITS - len0 ; if ( limit0 < 2 ) continue ; for ( b = - 16 ; b < 16 ; b ++ ) { int len1 = s -> len [ p1 ] [ b & 255 ] ; int limit1 = limit0 - len1 ; if ( limit1 < 1 ) continue ; code = ( s -> bits [ p0 ] [ g & 255 ] << len1 ) + s -> bits [ p1 ] [ b & 255 ] ; for ( r = - 16 ; r < 16 ; r ++ ) { int len2 = s -> len [ 2 ] [ r & 255 ] ; if ( len2 > limit1 ) continue ; len [ i ] = len0 + len1 + len2 ; bits [ i ] = ( code << len2 ) + s -> bits [ 2 ] [ r & 255 ] ; if ( s -> decorrelate ) { map [ i ] [ G ] = g ; map [ i ] [ B ] = g + b ; map [ i ] [ R ] = g + r ; } else { map [ i ] [ B ] = g ; map [ i ] [ G ] = b ; map [ i ] [ R ] = r ; } i ++ ; } } } ff_free_vlc ( & s -> vlc [ 3 ] ) ; init_vlc ( & s -> vlc [ 3 ] , VLC_BITS , i , len , 1 , 1 , bits , 2 , 2 , 0 ) ; } }
static void generate_joint_tables ( HYuvContext * s ) { uint16_t symbols [ 1 << VLC_BITS ] ; uint16_t bits [ 1 << VLC_BITS ] ; uint8_t len [ 1 << VLC_BITS ] ; if ( s -> bitstream_bpp < 24 ) { int p , i , y , u ; for ( p = 0 ; p < 3 ; p ++ ) { for ( i = y = 0 ; y < 256 ; y ++ ) { int len0 = s -> len [ 0 ] [ y ] ; int limit = VLC_BITS - len0 ; if ( limit <= 0 ) continue ; for ( u = 0 ; u < 256 ; u ++ ) { int len1 = s -> len [ p ] [ u ] ; if ( len1 > limit ) continue ; len [ i ] = len0 + len1 ; bits [ i ] = ( s -> bits [ 0 ] [ y ] << len1 ) + s -> bits [ p ] [ u ] ; symbols [ i ] = ( y << 8 ) + u ; if ( symbols [ i ] != 0xffff ) i ++ ; } } ff_free_vlc ( & s -> vlc [ 3 + p ] ) ; ff_init_vlc_sparse ( & s -> vlc [ 3 + p ] , VLC_BITS , i , len , 1 , 1 , bits , 2 , 2 , symbols , 2 , 2 , 0 ) ; } } else { uint8_t ( * map ) [ 4 ] = ( uint8_t ( * ) [ 4 ] ) s -> pix_bgr_map ; int i , b , g , r , code ; int p0 = s -> decorrelate ; int p1 = ! s -> decorrelate ; for ( i = 0 , g = - 16 ; g < 16 ; g ++ ) { int len0 = s -> len [ p0 ] [ g & 255 ] ; int limit0 = VLC_BITS - len0 ; if ( limit0 < 2 ) continue ; for ( b = - 16 ; b < 16 ; b ++ ) { int len1 = s -> len [ p1 ] [ b & 255 ] ; int limit1 = limit0 - len1 ; if ( limit1 < 1 ) continue ; code = ( s -> bits [ p0 ] [ g & 255 ] << len1 ) + s -> bits [ p1 ] [ b & 255 ] ; for ( r = - 16 ; r < 16 ; r ++ ) { int len2 = s -> len [ 2 ] [ r & 255 ] ; if ( len2 > limit1 ) continue ; len [ i ] = len0 + len1 + len2 ; bits [ i ] = ( code << len2 ) + s -> bits [ 2 ] [ r & 255 ] ; if ( s -> decorrelate ) { map [ i ] [ G ] = g ; map [ i ] [ B ] = g + b ; map [ i ] [ R ] = g + r ; } else { map [ i ] [ B ] = g ; map [ i ] [ G ] = b ; map [ i ] [ R ] = r ; } i ++ ; } } } ff_free_vlc ( & s -> vlc [ 3 ] ) ; init_vlc ( & s -> vlc [ 3 ] , VLC_BITS , i , len , 1 , 1 , bits , 2 , 2 , 0 ) ; } }
275
1
void object_property_get_uint16List(Object *obj, const char *name, uint16List **list, Error **errp) { StringOutputVisitor *ov; StringInputVisitor *iv; ov = string_output_visitor_new(false); object_property_get(obj, string_output_get_visitor(ov), name, errp); iv = string_input_visitor_new(string_output_get_string(ov)); visit_type_uint16List(string_input_get_visitor(iv), list, NULL, errp); string_output_visitor_cleanup(ov); string_input_visitor_cleanup(iv); }
void object_property_get_uint16List(Object *obj, const char *name, uint16List **list, Error **errp) { StringOutputVisitor *ov; StringInputVisitor *iv; ov = string_output_visitor_new(false); object_property_get(obj, string_output_get_visitor(ov), name, errp); iv = string_input_visitor_new(string_output_get_string(ov)); visit_type_uint16List(string_input_get_visitor(iv), list, NULL, errp); string_output_visitor_cleanup(ov); string_input_visitor_cleanup(iv); }
276
1
hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) { unsigned long orun = 1; ktime_t delta; delta = ktime_sub(now, timer->expires); if (delta.tv64 < 0) return 0; if (interval.tv64 < timer->base->resolution.tv64) interval.tv64 = timer->base->resolution.tv64; if (unlikely(delta.tv64 >= interval.tv64)) { s64 incr = ktime_to_ns(interval); orun = ktime_divns(delta, incr); timer->expires = ktime_add_ns(timer->expires, incr * orun); if (timer->expires.tv64 > now.tv64) return orun; /* * This (and the ktime_add() below) is the * correction for exact: */ orun++; } timer->expires = ktime_add(timer->expires, interval); return orun; }
hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) { unsigned long orun = 1; ktime_t delta; delta = ktime_sub(now, timer->expires); if (delta.tv64 < 0) return 0; if (interval.tv64 < timer->base->resolution.tv64) interval.tv64 = timer->base->resolution.tv64; if (unlikely(delta.tv64 >= interval.tv64)) { s64 incr = ktime_to_ns(interval); orun = ktime_divns(delta, incr); timer->expires = ktime_add_ns(timer->expires, incr * orun); if (timer->expires.tv64 > now.tv64) return orun; orun++; } timer->expires = ktime_add(timer->expires, interval); return orun; }
277
1
acc_ctx_new(OM_uint32 *minor_status, gss_buffer_t buf, gss_ctx_id_t *ctx, spnego_gss_cred_id_t spcred, gss_buffer_t *mechToken, gss_buffer_t *mechListMIC, OM_uint32 *negState, send_token_flag *return_token) { OM_uint32 tmpmin, ret, req_flags; gss_OID_set supported_mechSet, mechTypes; gss_buffer_desc der_mechTypes; gss_OID mech_wanted; spnego_gss_ctx_id_t sc = NULL; ret = GSS_S_DEFECTIVE_TOKEN; der_mechTypes.length = 0; der_mechTypes.value = NULL; *mechToken = *mechListMIC = GSS_C_NO_BUFFER; supported_mechSet = mechTypes = GSS_C_NO_OID_SET; *return_token = ERROR_TOKEN_SEND; *negState = REJECT; *minor_status = 0; ret = get_negTokenInit(minor_status, buf, &der_mechTypes, &mechTypes, &req_flags, mechToken, mechListMIC); if (ret != GSS_S_COMPLETE) { goto cleanup; } ret = get_negotiable_mechs(minor_status, spcred, GSS_C_ACCEPT, &supported_mechSet); if (ret != GSS_S_COMPLETE) { *return_token = NO_TOKEN_SEND; goto cleanup; } /* * Select the best match between the list of mechs * that the initiator requested and the list that * the acceptor will support. */ mech_wanted = negotiate_mech(supported_mechSet, mechTypes, negState); if (*negState == REJECT) { ret = GSS_S_BAD_MECH; goto cleanup; } sc = (spnego_gss_ctx_id_t)*ctx; if (sc != NULL) { gss_release_buffer(&tmpmin, &sc->DER_mechTypes); assert(mech_wanted != GSS_C_NO_OID); } else sc = create_spnego_ctx(); if (sc == NULL) { ret = GSS_S_FAILURE; *return_token = NO_TOKEN_SEND; goto cleanup; } sc->mech_set = mechTypes; mechTypes = GSS_C_NO_OID_SET; sc->internal_mech = mech_wanted; sc->DER_mechTypes = der_mechTypes; der_mechTypes.length = 0; der_mechTypes.value = NULL; if (*negState == REQUEST_MIC) sc->mic_reqd = 1; *return_token = INIT_TOKEN_SEND; sc->firstpass = 1; *ctx = (gss_ctx_id_t)sc; ret = GSS_S_COMPLETE; cleanup: gss_release_oid_set(&tmpmin, &mechTypes); gss_release_oid_set(&tmpmin, &supported_mechSet); if (der_mechTypes.length != 0) gss_release_buffer(&tmpmin, &der_mechTypes); return ret; }
acc_ctx_new(OM_uint32 *minor_status, gss_buffer_t buf, gss_ctx_id_t *ctx, spnego_gss_cred_id_t spcred, gss_buffer_t *mechToken, gss_buffer_t *mechListMIC, OM_uint32 *negState, send_token_flag *return_token) { OM_uint32 tmpmin, ret, req_flags; gss_OID_set supported_mechSet, mechTypes; gss_buffer_desc der_mechTypes; gss_OID mech_wanted; spnego_gss_ctx_id_t sc = NULL; ret = GSS_S_DEFECTIVE_TOKEN; der_mechTypes.length = 0; der_mechTypes.value = NULL; *mechToken = *mechListMIC = GSS_C_NO_BUFFER; supported_mechSet = mechTypes = GSS_C_NO_OID_SET; *return_token = ERROR_TOKEN_SEND; *negState = REJECT; *minor_status = 0; ret = get_negTokenInit(minor_status, buf, &der_mechTypes, &mechTypes, &req_flags, mechToken, mechListMIC); if (ret != GSS_S_COMPLETE) { goto cleanup; } ret = get_negotiable_mechs(minor_status, spcred, GSS_C_ACCEPT, &supported_mechSet); if (ret != GSS_S_COMPLETE) { *return_token = NO_TOKEN_SEND; goto cleanup; } mech_wanted = negotiate_mech(supported_mechSet, mechTypes, negState); if (*negState == REJECT) { ret = GSS_S_BAD_MECH; goto cleanup; } sc = (spnego_gss_ctx_id_t)*ctx; if (sc != NULL) { gss_release_buffer(&tmpmin, &sc->DER_mechTypes); assert(mech_wanted != GSS_C_NO_OID); } else sc = create_spnego_ctx(); if (sc == NULL) { ret = GSS_S_FAILURE; *return_token = NO_TOKEN_SEND; goto cleanup; } sc->mech_set = mechTypes; mechTypes = GSS_C_NO_OID_SET; sc->internal_mech = mech_wanted; sc->DER_mechTypes = der_mechTypes; der_mechTypes.length = 0; der_mechTypes.value = NULL; if (*negState == REQUEST_MIC) sc->mic_reqd = 1; *return_token = INIT_TOKEN_SEND; sc->firstpass = 1; *ctx = (gss_ctx_id_t)sc; ret = GSS_S_COMPLETE; cleanup: gss_release_oid_set(&tmpmin, &mechTypes); gss_release_oid_set(&tmpmin, &supported_mechSet); if (der_mechTypes.length != 0) gss_release_buffer(&tmpmin, &der_mechTypes); return ret; }
280
0
mptctl_do_mpt_command (MPT_ADAPTER *ioc, struct mpt_ioctl_command karg, void __user *mfPtr) { MPT_FRAME_HDR *mf = NULL; MPIHeader_t *hdr; char *psge; struct buflist bufIn; /* data In buffer */ struct buflist bufOut; /* data Out buffer */ dma_addr_t dma_addr_in; dma_addr_t dma_addr_out; int sgSize = 0; /* Num SG elements */ int flagsLength; int sz, rc = 0; int msgContext; u16 req_idx; ulong timeout; unsigned long timeleft; struct scsi_device *sdev; unsigned long flags; u8 function; /* bufIn and bufOut are used for user to kernel space transfers */ bufIn.kptr = bufOut.kptr = NULL; bufIn.len = bufOut.len = 0; spin_lock_irqsave(&ioc->taskmgmt_lock, flags); if (ioc->ioc_reset_in_progress) { spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " "Busy with diagnostic reset\n", __FILE__, __LINE__); return -EBUSY; } spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); /* Basic sanity checks to prevent underflows or integer overflows */ if (karg.maxReplyBytes < 0 || karg.dataInSize < 0 || karg.dataOutSize < 0 || karg.dataSgeOffset < 0 || karg.maxSenseBytes < 0 || karg.dataSgeOffset > ioc->req_sz / 4) return -EINVAL; /* Verify that the final request frame will not be too large. */ sz = karg.dataSgeOffset * 4; if (karg.dataInSize > 0) sz += ioc->SGE_size; if (karg.dataOutSize > 0) sz += ioc->SGE_size; if (sz > ioc->req_sz) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Request frame too large (%d) maximum (%d)\n", ioc->name, __FILE__, __LINE__, sz, ioc->req_sz); return -EFAULT; } /* Get a free request frame and save the message context. */ if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) return -EAGAIN; hdr = (MPIHeader_t *) mf; msgContext = le32_to_cpu(hdr->MsgContext); req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); /* Copy the request frame * Reset the saved message context. * Request frame in user space */ if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to read MF from mpt_ioctl_command struct @ %p\n", ioc->name, __FILE__, __LINE__, mfPtr); function = -1; rc = -EFAULT; goto done_free_mem; } hdr->MsgContext = cpu_to_le32(msgContext); function = hdr->Function; /* Verify that this request is allowed. */ dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n", ioc->name, hdr->Function, mf)); switch (function) { case MPI_FUNCTION_IOC_FACTS: case MPI_FUNCTION_PORT_FACTS: karg.dataOutSize = karg.dataInSize = 0; break; case MPI_FUNCTION_CONFIG: { Config_t *config_frame; config_frame = (Config_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\ttype=0x%02x ext_type=0x%02x " "number=0x%02x action=0x%02x\n", ioc->name, config_frame->Header.PageType, config_frame->ExtPageType, config_frame->Header.PageNumber, config_frame->Action)); break; } case MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND: case MPI_FUNCTION_FC_EX_LINK_SRVC_SEND: case MPI_FUNCTION_FW_UPLOAD: case MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR: case MPI_FUNCTION_FW_DOWNLOAD: case MPI_FUNCTION_FC_PRIMITIVE_SEND: case MPI_FUNCTION_TOOLBOX: case MPI_FUNCTION_SAS_IO_UNIT_CONTROL: break; case MPI_FUNCTION_SCSI_IO_REQUEST: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; int scsidir = 0; int dataSize; u32 id; id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; if (pScsiReq->TargetID > id) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target ID out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } if (pScsiReq->Bus >= ioc->number_of_buses) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target Bus out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); /* verify that app has not requested * more sense data than driver * can provide, if so, reset this parameter * set the sense buffer pointer low address * update the control field to specify Q type */ if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); shost_for_each_device(sdev, ioc->sh) { struct scsi_target *starget = scsi_target(sdev); VirtTarget *vtarget = starget->hostdata; if (vtarget == NULL) continue; if ((pScsiReq->TargetID == vtarget->id) && (pScsiReq->Bus == vtarget->channel) && (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; } /* Have the IOCTL driver set the direction based * on the dataOutSize (ordering issue with Sparc). */ if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SMP_PASSTHROUGH: /* Check mf->PassthruFlags to determine if * transfer is ImmediateMode or not. * Immediate mode returns data in the ReplyFrame. * Else, we are sending request and response data * in two SGLs at the end of the mf. */ break; case MPI_FUNCTION_SATA_PASSTHROUGH: if (!ioc->sh) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_RAID_ACTION: /* Just add a SGE */ break; case MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; int scsidir = MPI_SCSIIO_CONTROL_READ; int dataSize; pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); /* verify that app has not requested * more sense data than driver * can provide, if so, reset this parameter * set the sense buffer pointer low address * update the control field to specify Q type */ if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); /* All commands to physical devices are tagged */ /* Have the IOCTL driver set the direction based * on the dataOutSize (ordering issue with Sparc). */ if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SCSI_TASK_MGMT: { SCSITaskMgmt_t *pScsiTm; pScsiTm = (SCSITaskMgmt_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tTaskType=0x%x MsgFlags=0x%x " "TaskMsgContext=0x%x id=%d channel=%d\n", ioc->name, pScsiTm->TaskType, le32_to_cpu (pScsiTm->TaskMsgContext), pScsiTm->MsgFlags, pScsiTm->TargetID, pScsiTm->Bus)); break; } case MPI_FUNCTION_IOC_INIT: { IOCInit_t *pInit = (IOCInit_t *) mf; u32 high_addr, sense_high; /* Verify that all entries in the IOC INIT match * existing setup (and in LE format). */ if (sizeof(dma_addr_t) == sizeof(u64)) { high_addr = cpu_to_le32((u32)((u64)ioc->req_frames_dma >> 32)); sense_high= cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); } else { high_addr = 0; sense_high= 0; } if ((pInit->Flags != 0) || (pInit->MaxDevices != ioc->facts.MaxDevices) || (pInit->MaxBuses != ioc->facts.MaxBuses) || (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || (pInit->HostMfaHighAddr != high_addr) || (pInit->SenseBufferHighAddr != sense_high)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } } break; default: /* * MPI_FUNCTION_PORT_ENABLE * MPI_FUNCTION_TARGET_CMD_BUFFER_POST * MPI_FUNCTION_TARGET_ASSIST * MPI_FUNCTION_TARGET_STATUS_SEND * MPI_FUNCTION_TARGET_MODE_ABORT * MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET * MPI_FUNCTION_IO_UNIT_RESET * MPI_FUNCTION_HANDSHAKE * MPI_FUNCTION_REPLY_FRAME_REMOVAL * MPI_FUNCTION_EVENT_NOTIFICATION * (driver handles event notification) * MPI_FUNCTION_EVENT_ACK */ /* What to do with these??? CHECK ME!!! MPI_FUNCTION_FC_LINK_SRVC_BUF_POST MPI_FUNCTION_FC_LINK_SRVC_RSP MPI_FUNCTION_FC_ABORT MPI_FUNCTION_LAN_SEND MPI_FUNCTION_LAN_RECEIVE MPI_FUNCTION_LAN_RESET */ printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Illegal request (function 0x%x) \n", ioc->name, __FILE__, __LINE__, hdr->Function); rc = -EFAULT; goto done_free_mem; } /* Add the SGL ( at most one data in SGE and one data out SGE ) * In the case of two SGE's - the data out (write) will always * preceede the data in (read) SGE. psgList is used to free the * allocated memory. */ psge = (char *) (((int *) mf) + karg.dataSgeOffset); flagsLength = 0; if (karg.dataOutSize > 0) sgSize ++; if (karg.dataInSize > 0) sgSize ++; if (sgSize > 0) { /* Set up the dataOut memory allocation */ if (karg.dataOutSize > 0) { if (karg.dataInSize > 0) { flagsLength = ( MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_DIRECTION) << MPI_SGE_FLAGS_SHIFT; } else { flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE; } flagsLength |= karg.dataOutSize; bufOut.len = karg.dataOutSize; bufOut.kptr = pci_alloc_consistent( ioc->pcidev, bufOut.len, &dma_addr_out); if (bufOut.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { /* Set up this SGE. * Copy to MF and to sglbuf */ ioc->add_sge(psge, flagsLength, dma_addr_out); psge += ioc->SGE_size; /* Copy user data to kernel space. */ if (copy_from_user(bufOut.kptr, karg.dataOutBufPtr, bufOut.len)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - Unable " "to read user data " "struct @ %p\n", ioc->name, __FILE__, __LINE__,karg.dataOutBufPtr); rc = -EFAULT; goto done_free_mem; } } } if (karg.dataInSize > 0) { flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ; flagsLength |= karg.dataInSize; bufIn.len = karg.dataInSize; bufIn.kptr = pci_alloc_consistent(ioc->pcidev, bufIn.len, &dma_addr_in); if (bufIn.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { /* Set up this SGE * Copy to MF and to sglbuf */ ioc->add_sge(psge, flagsLength, dma_addr_in); } } } else { /* Add a NULL SGE */ ioc->add_sge(psge, flagsLength, (dma_addr_t) -1); } SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, hdr->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { mutex_lock(&ioc->taskmgmt_cmds.mutex); if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) { mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) mpt_put_msg_frame_hi_pri(mptctl_id, ioc, mf); else { rc =mpt_send_handshake_request(mptctl_id, ioc, sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); if (rc != 0) { dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED! (ioc %p, mf %p)\n", ioc->name, ioc, mf)); mpt_clear_taskmgmt_in_progress_flag(ioc); rc = -ENODATA; mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } } } else mpt_put_msg_frame(mptctl_id, ioc, mf); /* Now wait for the command to complete */ timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT; retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*timeout); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { rc = -ETIME; dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "%s: TIMED OUT!\n", ioc->name, __func__)); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "mpt cmd timeout, doorbell=0x%08x" " function=0x%x\n", ioc->name, mpt_GetIocState(ioc, 0), function); if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mptctl_timeout_expired(ioc, mf); mf = NULL; } else goto retry_wait; goto done_free_mem; } if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mf = NULL; /* If a valid reply frame, copy to the user. * Offset 2: reply length in U32's */ if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) { if (karg.maxReplyBytes < ioc->reply_sz) { sz = min(karg.maxReplyBytes, 4*ioc->ioctl_cmds.reply[2]); } else { sz = min(ioc->reply_sz, 4*ioc->ioctl_cmds.reply[2]); } if (sz > 0) { if (copy_to_user(karg.replyFrameBufPtr, ioc->ioctl_cmds.reply, sz)){ printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write out reply frame %p\n", ioc->name, __FILE__, __LINE__, karg.replyFrameBufPtr); rc = -ENODATA; goto done_free_mem; } } } /* If valid sense data, copy to user. */ if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_SENSE_VALID) { sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); if (sz > 0) { if (copy_to_user(karg.senseDataPtr, ioc->ioctl_cmds.sense, sz)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write sense data to user %p\n", ioc->name, __FILE__, __LINE__, karg.senseDataPtr); rc = -ENODATA; goto done_free_mem; } } } /* If the overall status is _GOOD and data in, copy data * to user. */ if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD) && (karg.dataInSize > 0) && (bufIn.kptr)) { if (copy_to_user(karg.dataInBufPtr, bufIn.kptr, karg.dataInSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write data to user %p\n", ioc->name, __FILE__, __LINE__, karg.dataInBufPtr); rc = -ENODATA; } } done_free_mem: CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); /* Free the allocated memory. */ if (bufOut.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufOut.len, (void *) bufOut.kptr, dma_addr_out); } if (bufIn.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufIn.len, (void *) bufIn.kptr, dma_addr_in); } /* mf is null if command issued successfully * otherwise, failure occurred after mf acquired. */ if (mf) mpt_free_msg_frame(ioc, mf); return rc; }
mptctl_do_mpt_command (MPT_ADAPTER *ioc, struct mpt_ioctl_command karg, void __user *mfPtr) { MPT_FRAME_HDR *mf = NULL; MPIHeader_t *hdr; char *psge; struct buflist bufIn; struct buflist bufOut; dma_addr_t dma_addr_in; dma_addr_t dma_addr_out; int sgSize = 0; int flagsLength; int sz, rc = 0; int msgContext; u16 req_idx; ulong timeout; unsigned long timeleft; struct scsi_device *sdev; unsigned long flags; u8 function; bufIn.kptr = bufOut.kptr = NULL; bufIn.len = bufOut.len = 0; spin_lock_irqsave(&ioc->taskmgmt_lock, flags); if (ioc->ioc_reset_in_progress) { spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " "Busy with diagnostic reset\n", __FILE__, __LINE__); return -EBUSY; } spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); if (karg.maxReplyBytes < 0 || karg.dataInSize < 0 || karg.dataOutSize < 0 || karg.dataSgeOffset < 0 || karg.maxSenseBytes < 0 || karg.dataSgeOffset > ioc->req_sz / 4) return -EINVAL; sz = karg.dataSgeOffset * 4; if (karg.dataInSize > 0) sz += ioc->SGE_size; if (karg.dataOutSize > 0) sz += ioc->SGE_size; if (sz > ioc->req_sz) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Request frame too large (%d) maximum (%d)\n", ioc->name, __FILE__, __LINE__, sz, ioc->req_sz); return -EFAULT; } if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) return -EAGAIN; hdr = (MPIHeader_t *) mf; msgContext = le32_to_cpu(hdr->MsgContext); req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to read MF from mpt_ioctl_command struct @ %p\n", ioc->name, __FILE__, __LINE__, mfPtr); function = -1; rc = -EFAULT; goto done_free_mem; } hdr->MsgContext = cpu_to_le32(msgContext); function = hdr->Function; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n", ioc->name, hdr->Function, mf)); switch (function) { case MPI_FUNCTION_IOC_FACTS: case MPI_FUNCTION_PORT_FACTS: karg.dataOutSize = karg.dataInSize = 0; break; case MPI_FUNCTION_CONFIG: { Config_t *config_frame; config_frame = (Config_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\ttype=0x%02x ext_type=0x%02x " "number=0x%02x action=0x%02x\n", ioc->name, config_frame->Header.PageType, config_frame->ExtPageType, config_frame->Header.PageNumber, config_frame->Action)); break; } case MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND: case MPI_FUNCTION_FC_EX_LINK_SRVC_SEND: case MPI_FUNCTION_FW_UPLOAD: case MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR: case MPI_FUNCTION_FW_DOWNLOAD: case MPI_FUNCTION_FC_PRIMITIVE_SEND: case MPI_FUNCTION_TOOLBOX: case MPI_FUNCTION_SAS_IO_UNIT_CONTROL: break; case MPI_FUNCTION_SCSI_IO_REQUEST: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; int scsidir = 0; int dataSize; u32 id; id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; if (pScsiReq->TargetID > id) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target ID out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } if (pScsiReq->Bus >= ioc->number_of_buses) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target Bus out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); shost_for_each_device(sdev, ioc->sh) { struct scsi_target *starget = scsi_target(sdev); VirtTarget *vtarget = starget->hostdata; if (vtarget == NULL) continue; if ((pScsiReq->TargetID == vtarget->id) && (pScsiReq->Bus == vtarget->channel) && (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; } if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SMP_PASSTHROUGH: break; case MPI_FUNCTION_SATA_PASSTHROUGH: if (!ioc->sh) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_RAID_ACTION: break; case MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; int scsidir = MPI_SCSIIO_CONTROL_READ; int dataSize; pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SCSI_TASK_MGMT: { SCSITaskMgmt_t *pScsiTm; pScsiTm = (SCSITaskMgmt_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tTaskType=0x%x MsgFlags=0x%x " "TaskMsgContext=0x%x id=%d channel=%d\n", ioc->name, pScsiTm->TaskType, le32_to_cpu (pScsiTm->TaskMsgContext), pScsiTm->MsgFlags, pScsiTm->TargetID, pScsiTm->Bus)); break; } case MPI_FUNCTION_IOC_INIT: { IOCInit_t *pInit = (IOCInit_t *) mf; u32 high_addr, sense_high; if (sizeof(dma_addr_t) == sizeof(u64)) { high_addr = cpu_to_le32((u32)((u64)ioc->req_frames_dma >> 32)); sense_high= cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); } else { high_addr = 0; sense_high= 0; } if ((pInit->Flags != 0) || (pInit->MaxDevices != ioc->facts.MaxDevices) || (pInit->MaxBuses != ioc->facts.MaxBuses) || (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || (pInit->HostMfaHighAddr != high_addr) || (pInit->SenseBufferHighAddr != sense_high)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } } break; default: printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Illegal request (function 0x%x) \n", ioc->name, __FILE__, __LINE__, hdr->Function); rc = -EFAULT; goto done_free_mem; } psge = (char *) (((int *) mf) + karg.dataSgeOffset); flagsLength = 0; if (karg.dataOutSize > 0) sgSize ++; if (karg.dataInSize > 0) sgSize ++; if (sgSize > 0) { if (karg.dataOutSize > 0) { if (karg.dataInSize > 0) { flagsLength = ( MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_DIRECTION) << MPI_SGE_FLAGS_SHIFT; } else { flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE; } flagsLength |= karg.dataOutSize; bufOut.len = karg.dataOutSize; bufOut.kptr = pci_alloc_consistent( ioc->pcidev, bufOut.len, &dma_addr_out); if (bufOut.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { ioc->add_sge(psge, flagsLength, dma_addr_out); psge += ioc->SGE_size; if (copy_from_user(bufOut.kptr, karg.dataOutBufPtr, bufOut.len)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - Unable " "to read user data " "struct @ %p\n", ioc->name, __FILE__, __LINE__,karg.dataOutBufPtr); rc = -EFAULT; goto done_free_mem; } } } if (karg.dataInSize > 0) { flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ; flagsLength |= karg.dataInSize; bufIn.len = karg.dataInSize; bufIn.kptr = pci_alloc_consistent(ioc->pcidev, bufIn.len, &dma_addr_in); if (bufIn.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { ioc->add_sge(psge, flagsLength, dma_addr_in); } } } else { ioc->add_sge(psge, flagsLength, (dma_addr_t) -1); } SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, hdr->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { mutex_lock(&ioc->taskmgmt_cmds.mutex); if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) { mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) mpt_put_msg_frame_hi_pri(mptctl_id, ioc, mf); else { rc =mpt_send_handshake_request(mptctl_id, ioc, sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); if (rc != 0) { dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED! (ioc %p, mf %p)\n", ioc->name, ioc, mf)); mpt_clear_taskmgmt_in_progress_flag(ioc); rc = -ENODATA; mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } } } else mpt_put_msg_frame(mptctl_id, ioc, mf); timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT; retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*timeout); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { rc = -ETIME; dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "%s: TIMED OUT!\n", ioc->name, __func__)); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "mpt cmd timeout, doorbell=0x%08x" " function=0x%x\n", ioc->name, mpt_GetIocState(ioc, 0), function); if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mptctl_timeout_expired(ioc, mf); mf = NULL; } else goto retry_wait; goto done_free_mem; } if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mf = NULL; if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) { if (karg.maxReplyBytes < ioc->reply_sz) { sz = min(karg.maxReplyBytes, 4*ioc->ioctl_cmds.reply[2]); } else { sz = min(ioc->reply_sz, 4*ioc->ioctl_cmds.reply[2]); } if (sz > 0) { if (copy_to_user(karg.replyFrameBufPtr, ioc->ioctl_cmds.reply, sz)){ printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write out reply frame %p\n", ioc->name, __FILE__, __LINE__, karg.replyFrameBufPtr); rc = -ENODATA; goto done_free_mem; } } } if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_SENSE_VALID) { sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); if (sz > 0) { if (copy_to_user(karg.senseDataPtr, ioc->ioctl_cmds.sense, sz)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write sense data to user %p\n", ioc->name, __FILE__, __LINE__, karg.senseDataPtr); rc = -ENODATA; goto done_free_mem; } } } if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD) && (karg.dataInSize > 0) && (bufIn.kptr)) { if (copy_to_user(karg.dataInBufPtr, bufIn.kptr, karg.dataInSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write data to user %p\n", ioc->name, __FILE__, __LINE__, karg.dataInBufPtr); rc = -ENODATA; } } done_free_mem: CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); if (bufOut.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufOut.len, (void *) bufOut.kptr, dma_addr_out); } if (bufIn.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufIn.len, (void *) bufIn.kptr, dma_addr_in); } if (mf) mpt_free_msg_frame(ioc, mf); return rc; }
282
1
m4_mkstemp (struct obstack *obs, int argc, token_data **argv) { if (bad_argc (argv[0], argc, 2, 2)) return; mkstemp_helper (obs, ARG (1)); }
m4_mkstemp (struct obstack *obs, int argc, token_data **argv) { if (bad_argc (argv[0], argc, 2, 2)) return; mkstemp_helper (obs, ARG (1)); }
283
1
mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) { MPT_ADAPTER *ioc; MPT_FRAME_HDR *mf = NULL; MPIHeader_t *hdr; char *psge; struct buflist bufIn; /* data In buffer */ struct buflist bufOut; /* data Out buffer */ dma_addr_t dma_addr_in; dma_addr_t dma_addr_out; int sgSize = 0; /* Num SG elements */ int iocnum, flagsLength; int sz, rc = 0; int msgContext; u16 req_idx; ulong timeout; unsigned long timeleft; struct scsi_device *sdev; unsigned long flags; u8 function; /* bufIn and bufOut are used for user to kernel space transfers */ bufIn.kptr = bufOut.kptr = NULL; bufIn.len = bufOut.len = 0; if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } spin_lock_irqsave(&ioc->taskmgmt_lock, flags); if (ioc->ioc_reset_in_progress) { spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " "Busy with diagnostic reset\n", __FILE__, __LINE__); return -EBUSY; } spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); /* Basic sanity checks to prevent underflows or integer overflows */ if (karg.maxReplyBytes < 0 || karg.dataInSize < 0 || karg.dataOutSize < 0 || karg.dataSgeOffset < 0 || karg.maxSenseBytes < 0 || karg.dataSgeOffset > ioc->req_sz / 4) return -EINVAL; /* Verify that the final request frame will not be too large. */ sz = karg.dataSgeOffset * 4; if (karg.dataInSize > 0) sz += ioc->SGE_size; if (karg.dataOutSize > 0) sz += ioc->SGE_size; if (sz > ioc->req_sz) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Request frame too large (%d) maximum (%d)\n", ioc->name, __FILE__, __LINE__, sz, ioc->req_sz); return -EFAULT; } /* Get a free request frame and save the message context. */ if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) return -EAGAIN; hdr = (MPIHeader_t *) mf; msgContext = le32_to_cpu(hdr->MsgContext); req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); /* Copy the request frame * Reset the saved message context. * Request frame in user space */ if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to read MF from mpt_ioctl_command struct @ %p\n", ioc->name, __FILE__, __LINE__, mfPtr); function = -1; rc = -EFAULT; goto done_free_mem; } hdr->MsgContext = cpu_to_le32(msgContext); function = hdr->Function; /* Verify that this request is allowed. */ dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n", ioc->name, hdr->Function, mf)); switch (function) { case MPI_FUNCTION_IOC_FACTS: case MPI_FUNCTION_PORT_FACTS: karg.dataOutSize = karg.dataInSize = 0; break; case MPI_FUNCTION_CONFIG: { Config_t *config_frame; config_frame = (Config_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\ttype=0x%02x ext_type=0x%02x " "number=0x%02x action=0x%02x\n", ioc->name, config_frame->Header.PageType, config_frame->ExtPageType, config_frame->Header.PageNumber, config_frame->Action)); break; } case MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND: case MPI_FUNCTION_FC_EX_LINK_SRVC_SEND: case MPI_FUNCTION_FW_UPLOAD: case MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR: case MPI_FUNCTION_FW_DOWNLOAD: case MPI_FUNCTION_FC_PRIMITIVE_SEND: case MPI_FUNCTION_TOOLBOX: case MPI_FUNCTION_SAS_IO_UNIT_CONTROL: break; case MPI_FUNCTION_SCSI_IO_REQUEST: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; int scsidir = 0; int dataSize; u32 id; id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; if (pScsiReq->TargetID > id) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target ID out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } if (pScsiReq->Bus >= ioc->number_of_buses) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target Bus out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); /* verify that app has not requested * more sense data than driver * can provide, if so, reset this parameter * set the sense buffer pointer low address * update the control field to specify Q type */ if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); shost_for_each_device(sdev, ioc->sh) { struct scsi_target *starget = scsi_target(sdev); VirtTarget *vtarget = starget->hostdata; if (vtarget == NULL) continue; if ((pScsiReq->TargetID == vtarget->id) && (pScsiReq->Bus == vtarget->channel) && (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; } /* Have the IOCTL driver set the direction based * on the dataOutSize (ordering issue with Sparc). */ if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SMP_PASSTHROUGH: /* Check mf->PassthruFlags to determine if * transfer is ImmediateMode or not. * Immediate mode returns data in the ReplyFrame. * Else, we are sending request and response data * in two SGLs at the end of the mf. */ break; case MPI_FUNCTION_SATA_PASSTHROUGH: if (!ioc->sh) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_RAID_ACTION: /* Just add a SGE */ break; case MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; int scsidir = MPI_SCSIIO_CONTROL_READ; int dataSize; pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); /* verify that app has not requested * more sense data than driver * can provide, if so, reset this parameter * set the sense buffer pointer low address * update the control field to specify Q type */ if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); /* All commands to physical devices are tagged */ /* Have the IOCTL driver set the direction based * on the dataOutSize (ordering issue with Sparc). */ if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SCSI_TASK_MGMT: { SCSITaskMgmt_t *pScsiTm; pScsiTm = (SCSITaskMgmt_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tTaskType=0x%x MsgFlags=0x%x " "TaskMsgContext=0x%x id=%d channel=%d\n", ioc->name, pScsiTm->TaskType, le32_to_cpu (pScsiTm->TaskMsgContext), pScsiTm->MsgFlags, pScsiTm->TargetID, pScsiTm->Bus)); break; } case MPI_FUNCTION_IOC_INIT: { IOCInit_t *pInit = (IOCInit_t *) mf; u32 high_addr, sense_high; /* Verify that all entries in the IOC INIT match * existing setup (and in LE format). */ if (sizeof(dma_addr_t) == sizeof(u64)) { high_addr = cpu_to_le32((u32)((u64)ioc->req_frames_dma >> 32)); sense_high= cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); } else { high_addr = 0; sense_high= 0; } if ((pInit->Flags != 0) || (pInit->MaxDevices != ioc->facts.MaxDevices) || (pInit->MaxBuses != ioc->facts.MaxBuses) || (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || (pInit->HostMfaHighAddr != high_addr) || (pInit->SenseBufferHighAddr != sense_high)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } } break; default: /* * MPI_FUNCTION_PORT_ENABLE * MPI_FUNCTION_TARGET_CMD_BUFFER_POST * MPI_FUNCTION_TARGET_ASSIST * MPI_FUNCTION_TARGET_STATUS_SEND * MPI_FUNCTION_TARGET_MODE_ABORT * MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET * MPI_FUNCTION_IO_UNIT_RESET * MPI_FUNCTION_HANDSHAKE * MPI_FUNCTION_REPLY_FRAME_REMOVAL * MPI_FUNCTION_EVENT_NOTIFICATION * (driver handles event notification) * MPI_FUNCTION_EVENT_ACK */ /* What to do with these??? CHECK ME!!! MPI_FUNCTION_FC_LINK_SRVC_BUF_POST MPI_FUNCTION_FC_LINK_SRVC_RSP MPI_FUNCTION_FC_ABORT MPI_FUNCTION_LAN_SEND MPI_FUNCTION_LAN_RECEIVE MPI_FUNCTION_LAN_RESET */ printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Illegal request (function 0x%x) \n", ioc->name, __FILE__, __LINE__, hdr->Function); rc = -EFAULT; goto done_free_mem; } /* Add the SGL ( at most one data in SGE and one data out SGE ) * In the case of two SGE's - the data out (write) will always * preceede the data in (read) SGE. psgList is used to free the * allocated memory. */ psge = (char *) (((int *) mf) + karg.dataSgeOffset); flagsLength = 0; if (karg.dataOutSize > 0) sgSize ++; if (karg.dataInSize > 0) sgSize ++; if (sgSize > 0) { /* Set up the dataOut memory allocation */ if (karg.dataOutSize > 0) { if (karg.dataInSize > 0) { flagsLength = ( MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_DIRECTION) << MPI_SGE_FLAGS_SHIFT; } else { flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE; } flagsLength |= karg.dataOutSize; bufOut.len = karg.dataOutSize; bufOut.kptr = pci_alloc_consistent( ioc->pcidev, bufOut.len, &dma_addr_out); if (bufOut.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { /* Set up this SGE. * Copy to MF and to sglbuf */ ioc->add_sge(psge, flagsLength, dma_addr_out); psge += ioc->SGE_size; /* Copy user data to kernel space. */ if (copy_from_user(bufOut.kptr, karg.dataOutBufPtr, bufOut.len)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - Unable " "to read user data " "struct @ %p\n", ioc->name, __FILE__, __LINE__,karg.dataOutBufPtr); rc = -EFAULT; goto done_free_mem; } } } if (karg.dataInSize > 0) { flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ; flagsLength |= karg.dataInSize; bufIn.len = karg.dataInSize; bufIn.kptr = pci_alloc_consistent(ioc->pcidev, bufIn.len, &dma_addr_in); if (bufIn.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { /* Set up this SGE * Copy to MF and to sglbuf */ ioc->add_sge(psge, flagsLength, dma_addr_in); } } } else { /* Add a NULL SGE */ ioc->add_sge(psge, flagsLength, (dma_addr_t) -1); } SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, hdr->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { mutex_lock(&ioc->taskmgmt_cmds.mutex); if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) { mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) mpt_put_msg_frame_hi_pri(mptctl_id, ioc, mf); else { rc =mpt_send_handshake_request(mptctl_id, ioc, sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); if (rc != 0) { dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED! (ioc %p, mf %p)\n", ioc->name, ioc, mf)); mpt_clear_taskmgmt_in_progress_flag(ioc); rc = -ENODATA; mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } } } else mpt_put_msg_frame(mptctl_id, ioc, mf); /* Now wait for the command to complete */ timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT; retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*timeout); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { rc = -ETIME; dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "%s: TIMED OUT!\n", ioc->name, __func__)); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "mpt cmd timeout, doorbell=0x%08x" " function=0x%x\n", ioc->name, mpt_GetIocState(ioc, 0), function); if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mptctl_timeout_expired(ioc, mf); mf = NULL; } else goto retry_wait; goto done_free_mem; } if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mf = NULL; /* If a valid reply frame, copy to the user. * Offset 2: reply length in U32's */ if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) { if (karg.maxReplyBytes < ioc->reply_sz) { sz = min(karg.maxReplyBytes, 4*ioc->ioctl_cmds.reply[2]); } else { sz = min(ioc->reply_sz, 4*ioc->ioctl_cmds.reply[2]); } if (sz > 0) { if (copy_to_user(karg.replyFrameBufPtr, ioc->ioctl_cmds.reply, sz)){ printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write out reply frame %p\n", ioc->name, __FILE__, __LINE__, karg.replyFrameBufPtr); rc = -ENODATA; goto done_free_mem; } } } /* If valid sense data, copy to user. */ if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_SENSE_VALID) { sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); if (sz > 0) { if (copy_to_user(karg.senseDataPtr, ioc->ioctl_cmds.sense, sz)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write sense data to user %p\n", ioc->name, __FILE__, __LINE__, karg.senseDataPtr); rc = -ENODATA; goto done_free_mem; } } } /* If the overall status is _GOOD and data in, copy data * to user. */ if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD) && (karg.dataInSize > 0) && (bufIn.kptr)) { if (copy_to_user(karg.dataInBufPtr, bufIn.kptr, karg.dataInSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write data to user %p\n", ioc->name, __FILE__, __LINE__, karg.dataInBufPtr); rc = -ENODATA; } } done_free_mem: CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); /* Free the allocated memory. */ if (bufOut.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufOut.len, (void *) bufOut.kptr, dma_addr_out); } if (bufIn.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufIn.len, (void *) bufIn.kptr, dma_addr_in); } /* mf is null if command issued successfully * otherwise, failure occurred after mf acquired. */ if (mf) mpt_free_msg_frame(ioc, mf); return rc; }
mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) { MPT_ADAPTER *ioc; MPT_FRAME_HDR *mf = NULL; MPIHeader_t *hdr; char *psge; struct buflist bufIn; struct buflist bufOut; dma_addr_t dma_addr_in; dma_addr_t dma_addr_out; int sgSize = 0; int iocnum, flagsLength; int sz, rc = 0; int msgContext; u16 req_idx; ulong timeout; unsigned long timeleft; struct scsi_device *sdev; unsigned long flags; u8 function; bufIn.kptr = bufOut.kptr = NULL; bufIn.len = bufOut.len = 0; if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } spin_lock_irqsave(&ioc->taskmgmt_lock, flags); if (ioc->ioc_reset_in_progress) { spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " "Busy with diagnostic reset\n", __FILE__, __LINE__); return -EBUSY; } spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); if (karg.maxReplyBytes < 0 || karg.dataInSize < 0 || karg.dataOutSize < 0 || karg.dataSgeOffset < 0 || karg.maxSenseBytes < 0 || karg.dataSgeOffset > ioc->req_sz / 4) return -EINVAL; sz = karg.dataSgeOffset * 4; if (karg.dataInSize > 0) sz += ioc->SGE_size; if (karg.dataOutSize > 0) sz += ioc->SGE_size; if (sz > ioc->req_sz) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Request frame too large (%d) maximum (%d)\n", ioc->name, __FILE__, __LINE__, sz, ioc->req_sz); return -EFAULT; } if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) return -EAGAIN; hdr = (MPIHeader_t *) mf; msgContext = le32_to_cpu(hdr->MsgContext); req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to read MF from mpt_ioctl_command struct @ %p\n", ioc->name, __FILE__, __LINE__, mfPtr); function = -1; rc = -EFAULT; goto done_free_mem; } hdr->MsgContext = cpu_to_le32(msgContext); function = hdr->Function; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n", ioc->name, hdr->Function, mf)); switch (function) { case MPI_FUNCTION_IOC_FACTS: case MPI_FUNCTION_PORT_FACTS: karg.dataOutSize = karg.dataInSize = 0; break; case MPI_FUNCTION_CONFIG: { Config_t *config_frame; config_frame = (Config_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\ttype=0x%02x ext_type=0x%02x " "number=0x%02x action=0x%02x\n", ioc->name, config_frame->Header.PageType, config_frame->ExtPageType, config_frame->Header.PageNumber, config_frame->Action)); break; } case MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND: case MPI_FUNCTION_FC_EX_LINK_SRVC_SEND: case MPI_FUNCTION_FW_UPLOAD: case MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR: case MPI_FUNCTION_FW_DOWNLOAD: case MPI_FUNCTION_FC_PRIMITIVE_SEND: case MPI_FUNCTION_TOOLBOX: case MPI_FUNCTION_SAS_IO_UNIT_CONTROL: break; case MPI_FUNCTION_SCSI_IO_REQUEST: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; int scsidir = 0; int dataSize; u32 id; id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; if (pScsiReq->TargetID > id) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target ID out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } if (pScsiReq->Bus >= ioc->number_of_buses) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Target Bus out of bounds. \n", ioc->name, __FILE__, __LINE__); rc = -ENODEV; goto done_free_mem; } pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); shost_for_each_device(sdev, ioc->sh) { struct scsi_target *starget = scsi_target(sdev); VirtTarget *vtarget = starget->hostdata; if (vtarget == NULL) continue; if ((pScsiReq->TargetID == vtarget->id) && (pScsiReq->Bus == vtarget->channel) && (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; } if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SMP_PASSTHROUGH: break; case MPI_FUNCTION_SATA_PASSTHROUGH: if (!ioc->sh) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_RAID_ACTION: break; case MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; int qtag = MPI_SCSIIO_CONTROL_SIMPLEQ; int scsidir = MPI_SCSIIO_CONTROL_READ; int dataSize; pScsiReq->MsgFlags &= ~MPI_SCSIIO_MSGFLGS_SENSE_WIDTH; pScsiReq->MsgFlags |= mpt_msg_flags(ioc); if (karg.maxSenseBytes > MPT_SENSE_BUFFER_SIZE) pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; else pScsiReq->SenseBufferLength = karg.maxSenseBytes; pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma + (req_idx * MPT_SENSE_BUFFER_ALLOC)); if (karg.dataOutSize > 0) { scsidir = MPI_SCSIIO_CONTROL_WRITE; dataSize = karg.dataOutSize; } else { scsidir = MPI_SCSIIO_CONTROL_READ; dataSize = karg.dataInSize; } pScsiReq->Control = cpu_to_le32(scsidir | qtag); pScsiReq->DataLength = cpu_to_le32(dataSize); } else { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "SCSI driver is not loaded. \n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } break; case MPI_FUNCTION_SCSI_TASK_MGMT: { SCSITaskMgmt_t *pScsiTm; pScsiTm = (SCSITaskMgmt_t *)mf; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tTaskType=0x%x MsgFlags=0x%x " "TaskMsgContext=0x%x id=%d channel=%d\n", ioc->name, pScsiTm->TaskType, le32_to_cpu (pScsiTm->TaskMsgContext), pScsiTm->MsgFlags, pScsiTm->TargetID, pScsiTm->Bus)); break; } case MPI_FUNCTION_IOC_INIT: { IOCInit_t *pInit = (IOCInit_t *) mf; u32 high_addr, sense_high; if (sizeof(dma_addr_t) == sizeof(u64)) { high_addr = cpu_to_le32((u32)((u64)ioc->req_frames_dma >> 32)); sense_high= cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); } else { high_addr = 0; sense_high= 0; } if ((pInit->Flags != 0) || (pInit->MaxDevices != ioc->facts.MaxDevices) || (pInit->MaxBuses != ioc->facts.MaxBuses) || (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || (pInit->HostMfaHighAddr != high_addr) || (pInit->SenseBufferHighAddr != sense_high)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", ioc->name, __FILE__, __LINE__); rc = -EFAULT; goto done_free_mem; } } break; default: printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Illegal request (function 0x%x) \n", ioc->name, __FILE__, __LINE__, hdr->Function); rc = -EFAULT; goto done_free_mem; } psge = (char *) (((int *) mf) + karg.dataSgeOffset); flagsLength = 0; if (karg.dataOutSize > 0) sgSize ++; if (karg.dataInSize > 0) sgSize ++; if (sgSize > 0) { if (karg.dataOutSize > 0) { if (karg.dataInSize > 0) { flagsLength = ( MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_DIRECTION) << MPI_SGE_FLAGS_SHIFT; } else { flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE; } flagsLength |= karg.dataOutSize; bufOut.len = karg.dataOutSize; bufOut.kptr = pci_alloc_consistent( ioc->pcidev, bufOut.len, &dma_addr_out); if (bufOut.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { ioc->add_sge(psge, flagsLength, dma_addr_out); psge += ioc->SGE_size; if (copy_from_user(bufOut.kptr, karg.dataOutBufPtr, bufOut.len)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - Unable " "to read user data " "struct @ %p\n", ioc->name, __FILE__, __LINE__,karg.dataOutBufPtr); rc = -EFAULT; goto done_free_mem; } } } if (karg.dataInSize > 0) { flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ; flagsLength |= karg.dataInSize; bufIn.len = karg.dataInSize; bufIn.kptr = pci_alloc_consistent(ioc->pcidev, bufIn.len, &dma_addr_in); if (bufIn.kptr == NULL) { rc = -ENOMEM; goto done_free_mem; } else { ioc->add_sge(psge, flagsLength, dma_addr_in); } } } else { ioc->add_sge(psge, flagsLength, (dma_addr_t) -1); } SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, hdr->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { mutex_lock(&ioc->taskmgmt_cmds.mutex); if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) { mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) mpt_put_msg_frame_hi_pri(mptctl_id, ioc, mf); else { rc =mpt_send_handshake_request(mptctl_id, ioc, sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); if (rc != 0) { dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED! (ioc %p, mf %p)\n", ioc->name, ioc, mf)); mpt_clear_taskmgmt_in_progress_flag(ioc); rc = -ENODATA; mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } } } else mpt_put_msg_frame(mptctl_id, ioc, mf); timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT; retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*timeout); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { rc = -ETIME; dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "%s: TIMED OUT!\n", ioc->name, __func__)); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); goto done_free_mem; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "mpt cmd timeout, doorbell=0x%08x" " function=0x%x\n", ioc->name, mpt_GetIocState(ioc, 0), function); if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mptctl_timeout_expired(ioc, mf); mf = NULL; } else goto retry_wait; goto done_free_mem; } if (function == MPI_FUNCTION_SCSI_TASK_MGMT) mutex_unlock(&ioc->taskmgmt_cmds.mutex); mf = NULL; if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) { if (karg.maxReplyBytes < ioc->reply_sz) { sz = min(karg.maxReplyBytes, 4*ioc->ioctl_cmds.reply[2]); } else { sz = min(ioc->reply_sz, 4*ioc->ioctl_cmds.reply[2]); } if (sz > 0) { if (copy_to_user(karg.replyFrameBufPtr, ioc->ioctl_cmds.reply, sz)){ printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write out reply frame %p\n", ioc->name, __FILE__, __LINE__, karg.replyFrameBufPtr); rc = -ENODATA; goto done_free_mem; } } } if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_SENSE_VALID) { sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); if (sz > 0) { if (copy_to_user(karg.senseDataPtr, ioc->ioctl_cmds.sense, sz)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write sense data to user %p\n", ioc->name, __FILE__, __LINE__, karg.senseDataPtr); rc = -ENODATA; goto done_free_mem; } } } if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD) && (karg.dataInSize > 0) && (bufIn.kptr)) { if (copy_to_user(karg.dataInBufPtr, bufIn.kptr, karg.dataInSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " "Unable to write data to user %p\n", ioc->name, __FILE__, __LINE__, karg.dataInBufPtr); rc = -ENODATA; } } done_free_mem: CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); if (bufOut.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufOut.len, (void *) bufOut.kptr, dma_addr_out); } if (bufIn.kptr != NULL) { pci_free_consistent(ioc->pcidev, bufIn.len, (void *) bufIn.kptr, dma_addr_in); } if (mf) mpt_free_msg_frame(ioc, mf); return rc; }
284
0
xmlParserInputBufferCreateFilenameFunc xmlThrDefParserInputBufferCreateFilenameDefault ( xmlParserInputBufferCreateFilenameFunc func ) { xmlParserInputBufferCreateFilenameFunc old ; xmlMutexLock ( xmlThrDefMutex ) ; old = xmlParserInputBufferCreateFilenameValueThrDef ; if ( old == NULL ) { old = __xmlParserInputBufferCreateFilename ; } xmlParserInputBufferCreateFilenameValueThrDef = func ; xmlMutexUnlock ( xmlThrDefMutex ) ; return ( old ) ; }
xmlParserInputBufferCreateFilenameFunc xmlThrDefParserInputBufferCreateFilenameDefault ( xmlParserInputBufferCreateFilenameFunc func ) { xmlParserInputBufferCreateFilenameFunc old ; xmlMutexLock ( xmlThrDefMutex ) ; old = xmlParserInputBufferCreateFilenameValueThrDef ; if ( old == NULL ) { old = __xmlParserInputBufferCreateFilename ; } xmlParserInputBufferCreateFilenameValueThrDef = func ; xmlMutexUnlock ( xmlThrDefMutex ) ; return ( old ) ; }
287
1
uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t l2_offset, *l2_table, cluster_offset; int nb_clusters, i = 0; QCowL2Meta *old_alloc; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); if (ret == 0) return 0; nb_clusters = size_to_clusters(s, n_end << 9); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); cluster_offset = be64_to_cpu(l2_table[l2_index]); /* We keep all QCOW_OFLAG_COPIED clusters */ if (cluster_offset & QCOW_OFLAG_COPIED) { nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, 0); cluster_offset &= ~QCOW_OFLAG_COPIED; m->nb_clusters = 0; goto out; } /* for the moment, multiple compressed clusters are not managed */ if (cluster_offset & QCOW_OFLAG_COMPRESSED) nb_clusters = 1; /* how many available clusters ? */ while (i < nb_clusters) { i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index], i, 0); if(be64_to_cpu(l2_table[l2_index + i])) break; i += count_contiguous_free_clusters(nb_clusters - i, &l2_table[l2_index + i]); cluster_offset = be64_to_cpu(l2_table[l2_index + i]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; } nb_clusters = i; /* * Check if there already is an AIO write request in flight which allocates * the same cluster. In this case we need to wait until the previous * request has completed and updated the L2 table accordingly. */ QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t end_offset = offset + nb_clusters * s->cluster_size; uint64_t old_offset = old_alloc->offset; uint64_t old_end_offset = old_alloc->offset + old_alloc->nb_clusters * s->cluster_size; if (end_offset < old_offset || offset > old_end_offset) { /* No intersection */ } else { if (offset < old_offset) { /* Stop at the start of a running allocation */ nb_clusters = (old_offset - offset) >> s->cluster_bits; } else { nb_clusters = 0; } if (nb_clusters == 0) { /* Set dependency and wait for a callback */ m->depends_on = old_alloc; m->nb_clusters = 0; *num = 0; return 0; } } } if (!nb_clusters) { abort(); } QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); /* allocate a new cluster */ cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size); /* save info needed for meta data update */ m->offset = offset; m->n_start = n_start; m->nb_clusters = nb_clusters; out: m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end); *num = m->nb_available - n_start; return cluster_offset; }
uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t l2_offset, *l2_table, cluster_offset; int nb_clusters, i = 0; QCowL2Meta *old_alloc; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); if (ret == 0) return 0; nb_clusters = size_to_clusters(s, n_end << 9); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); cluster_offset = be64_to_cpu(l2_table[l2_index]); if (cluster_offset & QCOW_OFLAG_COPIED) { nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, 0); cluster_offset &= ~QCOW_OFLAG_COPIED; m->nb_clusters = 0; goto out; } if (cluster_offset & QCOW_OFLAG_COMPRESSED) nb_clusters = 1; while (i < nb_clusters) { i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index], i, 0); if(be64_to_cpu(l2_table[l2_index + i])) break; i += count_contiguous_free_clusters(nb_clusters - i, &l2_table[l2_index + i]); cluster_offset = be64_to_cpu(l2_table[l2_index + i]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; } nb_clusters = i; QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t end_offset = offset + nb_clusters * s->cluster_size; uint64_t old_offset = old_alloc->offset; uint64_t old_end_offset = old_alloc->offset + old_alloc->nb_clusters * s->cluster_size; if (end_offset < old_offset || offset > old_end_offset) { } else { if (offset < old_offset) { nb_clusters = (old_offset - offset) >> s->cluster_bits; } else { nb_clusters = 0; } if (nb_clusters == 0) { m->depends_on = old_alloc; m->nb_clusters = 0; *num = 0; return 0; } } } if (!nb_clusters) { abort(); } QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size); m->offset = offset; m->n_start = n_start; m->nb_clusters = nb_clusters; out: m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end); *num = m->nb_available - n_start; return cluster_offset; }
288
1
mkstemp_helper (struct obstack *obs, const char *name) { int fd; int len; int i; /* Guarantee that there are six trailing 'X' characters, even if the user forgot to supply them. */ len = strlen (name); obstack_grow (obs, name, len); for (i = 0; len > 0 && i < 6; i++) if (name[--len] != 'X') break; for (; i < 6; i++) obstack_1grow (obs, 'X'); obstack_1grow (obs, '\0'); errno = 0; fd = mkstemp ((char *) obstack_base (obs)); if (fd < 0) { M4ERROR ((0, errno, "cannot create tempfile `%s'", name)); obstack_free (obs, obstack_finish (obs)); } else close (fd); }
mkstemp_helper (struct obstack *obs, const char *name) { int fd; int len; int i; len = strlen (name); obstack_grow (obs, name, len); for (i = 0; len > 0 && i < 6; i++) if (name[--len] != 'X') break; for (; i < 6; i++) obstack_1grow (obs, 'X'); obstack_1grow (obs, '\0'); errno = 0; fd = mkstemp ((char *) obstack_base (obs)); if (fd < 0) { M4ERROR ((0, errno, "cannot create tempfile `%s'", name)); obstack_free (obs, obstack_finish (obs)); } else close (fd); }
289
1
static int mptctl_do_reset(unsigned long arg) { struct mpt_ioctl_diag_reset __user *urinfo = (void __user *) arg; struct mpt_ioctl_diag_reset krinfo; MPT_ADAPTER *iocp; if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_do_reset - " "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", __FILE__, __LINE__, urinfo); return -EFAULT; } if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { printk(KERN_DEBUG MYNAM "%s@%d::mptctl_do_reset - ioc%d not found!\n", __FILE__, __LINE__, krinfo.hdr.iocnum); return -ENODEV; /* (-6) No such device or address */ } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_reset called.\n", iocp->name)); if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { printk (MYIOC_s_ERR_FMT "%s@%d::mptctl_do_reset - reset failed.\n", iocp->name, __FILE__, __LINE__); return -1; } return 0; }
static int mptctl_do_reset(unsigned long arg) { struct mpt_ioctl_diag_reset __user *urinfo = (void __user *) arg; struct mpt_ioctl_diag_reset krinfo; MPT_ADAPTER *iocp; if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_do_reset - " "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", __FILE__, __LINE__, urinfo); return -EFAULT; } if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { printk(KERN_DEBUG MYNAM "%s@%d::mptctl_do_reset - ioc%d not found!\n", __FILE__, __LINE__, krinfo.hdr.iocnum); return -ENODEV; } dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_reset called.\n", iocp->name)); if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { printk (MYIOC_s_ERR_FMT "%s@%d::mptctl_do_reset - reset failed.\n", iocp->name, __FILE__, __LINE__); return -1; } return 0; }
290
1
void ff_xvmc_init_block(MpegEncContext *s) { struct xvmc_render_state *render = (struct xvmc_render_state*)s->current_picture.data[2]; assert(render); if (!render || render->magic != AV_XVMC_RENDER_MAGIC) { assert(0); return; // make sure that this is a render packet } s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64); }
void ff_xvmc_init_block(MpegEncContext *s) { struct xvmc_render_state *render = (struct xvmc_render_state*)s->current_picture.data[2]; assert(render); if (!render || render->magic != AV_XVMC_RENDER_MAGIC) { assert(0); return;
291
1
create_spnego_ctx(void) { spnego_gss_ctx_id_t spnego_ctx = NULL; spnego_ctx = (spnego_gss_ctx_id_t) malloc(sizeof (spnego_gss_ctx_id_rec)); if (spnego_ctx == NULL) { return (NULL); } spnego_ctx->magic_num = SPNEGO_MAGIC_ID; spnego_ctx->ctx_handle = GSS_C_NO_CONTEXT; spnego_ctx->mech_set = NULL; spnego_ctx->internal_mech = NULL; spnego_ctx->optionStr = NULL; spnego_ctx->DER_mechTypes.length = 0; spnego_ctx->DER_mechTypes.value = NULL; spnego_ctx->default_cred = GSS_C_NO_CREDENTIAL; spnego_ctx->mic_reqd = 0; spnego_ctx->mic_sent = 0; spnego_ctx->mic_rcvd = 0; spnego_ctx->mech_complete = 0; spnego_ctx->nego_done = 0; spnego_ctx->internal_name = GSS_C_NO_NAME; spnego_ctx->actual_mech = GSS_C_NO_OID; check_spnego_options(spnego_ctx); return (spnego_ctx); }
create_spnego_ctx(void) { spnego_gss_ctx_id_t spnego_ctx = NULL; spnego_ctx = (spnego_gss_ctx_id_t) malloc(sizeof (spnego_gss_ctx_id_rec)); if (spnego_ctx == NULL) { return (NULL); } spnego_ctx->magic_num = SPNEGO_MAGIC_ID; spnego_ctx->ctx_handle = GSS_C_NO_CONTEXT; spnego_ctx->mech_set = NULL; spnego_ctx->internal_mech = NULL; spnego_ctx->optionStr = NULL; spnego_ctx->DER_mechTypes.length = 0; spnego_ctx->DER_mechTypes.value = NULL; spnego_ctx->default_cred = GSS_C_NO_CREDENTIAL; spnego_ctx->mic_reqd = 0; spnego_ctx->mic_sent = 0; spnego_ctx->mic_rcvd = 0; spnego_ctx->mech_complete = 0; spnego_ctx->nego_done = 0; spnego_ctx->internal_name = GSS_C_NO_NAME; spnego_ctx->actual_mech = GSS_C_NO_OID; check_spnego_options(spnego_ctx); return (spnego_ctx); }
292
0
static int dissect_h245_CertSelectionCriteria ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) { offset = dissect_per_constrained_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h245_CertSelectionCriteria , CertSelectionCriteria_sequence_of , 1 , 16 , FALSE ) ; return offset ; }
static int dissect_h245_CertSelectionCriteria ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) { offset = dissect_per_constrained_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h245_CertSelectionCriteria , CertSelectionCriteria_sequence_of , 1 , 16 , FALSE ) ; return offset ; }
293
1
m4_maketemp (struct obstack *obs, int argc, token_data **argv) { if (bad_argc (argv[0], argc, 2, 2)) return; if (no_gnu_extensions) { /* POSIX states "any trailing 'X' characters [are] replaced with the current process ID as a string", without referencing the file system. Horribly insecure, but we have to do it when we are in traditional mode. For reference, Solaris m4 does: maketemp() -> `' maketemp(X) -> `X' maketemp(XX) -> `Xn', where n is last digit of pid maketemp(XXXXXXXX) -> `X00nnnnn', where nnnnn is 16-bit pid */ const char *str = ARG (1); int len = strlen (str); int i; int len2; M4ERROR ((warning_status, 0, "recommend using mkstemp instead")); for (i = len; i > 1; i--) if (str[i - 1] != 'X') break; obstack_grow (obs, str, i); str = ntoa ((int32_t) getpid (), 10); len2 = strlen (str); if (len2 > len - i) obstack_grow0 (obs, str + len2 - (len - i), len - i); else { while (i++ < len - len2) obstack_1grow (obs, '0'); obstack_grow0 (obs, str, len2); } } else mkstemp_helper (obs, ARG (1)); }
m4_maketemp (struct obstack *obs, int argc, token_data **argv) { if (bad_argc (argv[0], argc, 2, 2)) return; if (no_gnu_extensions) { const char *str = ARG (1); int len = strlen (str); int i; int len2; M4ERROR ((warning_status, 0, "recommend using mkstemp instead")); for (i = len; i > 1; i--) if (str[i - 1] != 'X') break; obstack_grow (obs, str, i); str = ntoa ((int32_t) getpid (), 10); len2 = strlen (str); if (len2 > len - i) obstack_grow0 (obs, str + len2 - (len - i), len - i); else { while (i++ < len - len2) obstack_1grow (obs, '0'); obstack_grow0 (obs, str, len2); } } else mkstemp_helper (obs, ARG (1)); }
294
0
mptctl_eventenable (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_eventenable __user *uarg = (void __user *) arg; struct mpt_ioctl_eventenable karg; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventenable - " "Unable to read in mpt_ioctl_eventenable struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventenable called.\n", ioc->name)); if (ioc->events == NULL) { /* Have not yet allocated memory - do so now. */ int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); ioc->events = kzalloc(sz, GFP_KERNEL); if (!ioc->events) { printk(MYIOC_s_ERR_FMT ": ERROR - Insufficient memory to add adapter!\n", ioc->name); return -ENOMEM; } ioc->alloc_total += sz; ioc->eventContext = 0; } /* Update the IOC event logging flag. */ ioc->eventTypes = karg.eventTypes; return 0; }
mptctl_eventenable (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_eventenable __user *uarg = (void __user *) arg; struct mpt_ioctl_eventenable karg; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventenable - " "Unable to read in mpt_ioctl_eventenable struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventenable called.\n", ioc->name)); if (ioc->events == NULL) { int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); ioc->events = kzalloc(sz, GFP_KERNEL); if (!ioc->events) { printk(MYIOC_s_ERR_FMT ": ERROR - Insufficient memory to add adapter!\n", ioc->name); return -ENOMEM; } ioc->alloc_total += sz; ioc->eventContext = 0; } ioc->eventTypes = karg.eventTypes; return 0; }
295
1
void do_adde (void) { T2 = T0; T0 += T1 + xer_ca; if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) { xer_ca = 0; } else { xer_ca = 1; } }
void do_adde (void) { T2 = T0; T0 += T1 + xer_ca; if (likely(!(T0 < T2 || (xer_ca == 1 && T0 == T2)))) { xer_ca = 0; } else { xer_ca = 1; } }
297
1
produce_frozen_state (const char *name) { FILE *file; int h; symbol *sym; const builtin *bp; if (file = fopen (name, O_BINARY ? "wb" : "w"), !file) { M4ERROR ((warning_status, errno, name)); return; } /* Write a recognizable header. */ xfprintf (file, "# This is a frozen state file generated by %s\n", PACKAGE_STRING); xfprintf (file, "V1\n"); /* Dump quote delimiters. */ if (strcmp (lquote.string, DEF_LQUOTE) || strcmp (rquote.string, DEF_RQUOTE)) { xfprintf (file, "Q%d,%d\n", (int) lquote.length, (int) rquote.length); fputs (lquote.string, file); fputs (rquote.string, file); fputc ('\n', file); } /* Dump comment delimiters. */ if (strcmp (bcomm.string, DEF_BCOMM) || strcmp (ecomm.string, DEF_ECOMM)) { xfprintf (file, "C%d,%d\n", (int) bcomm.length, (int) ecomm.length); fputs (bcomm.string, file); fputs (ecomm.string, file); fputc ('\n', file); } /* Dump all symbols. */ for (h = 0; h < hash_table_size; h++) { /* Process all entries in one bucket, from the last to the first. This order ensures that, at reload time, pushdef's will be executed with the oldest definitions first. */ symtab[h] = reverse_symbol_list (symtab[h]); for (sym = symtab[h]; sym; sym = SYMBOL_NEXT (sym)) { switch (SYMBOL_TYPE (sym)) { case TOKEN_TEXT: xfprintf (file, "T%d,%d\n", (int) strlen (SYMBOL_NAME (sym)), (int) strlen (SYMBOL_TEXT (sym))); fputs (SYMBOL_NAME (sym), file); fputs (SYMBOL_TEXT (sym), file); fputc ('\n', file); break; case TOKEN_FUNC: bp = find_builtin_by_addr (SYMBOL_FUNC (sym)); if (bp == NULL) { M4ERROR ((warning_status, 0, "\ INTERNAL ERROR: builtin not found in builtin table!")); abort (); } xfprintf (file, "F%d,%d\n", (int) strlen (SYMBOL_NAME (sym)), (int) strlen (bp->name)); fputs (SYMBOL_NAME (sym), file); fputs (bp->name, file); fputc ('\n', file); break; case TOKEN_VOID: /* Ignore placeholder tokens that exist due to traceon. */ break; default: M4ERROR ((warning_status, 0, "\ INTERNAL ERROR: bad token data type in freeze_one_symbol ()")); abort (); break; } } /* Reverse the bucket once more, putting it back as it was. */ symtab[h] = reverse_symbol_list (symtab[h]); } /* Let diversions be issued from output.c module, its cleaner to have this piece of code there. */ freeze_diversions (file); /* All done. */ fputs ("# End of frozen state file\n", file); if (close_stream (file) != 0) M4ERROR ((EXIT_FAILURE, errno, "unable to create frozen state")); }
produce_frozen_state (const char *name) { FILE *file; int h; symbol *sym; const builtin *bp; if (file = fopen (name, O_BINARY ? "wb" : "w"), !file) { M4ERROR ((warning_status, errno, name)); return; } xfprintf (file, "# This is a frozen state file generated by %s\n", PACKAGE_STRING); xfprintf (file, "V1\n"); if (strcmp (lquote.string, DEF_LQUOTE) || strcmp (rquote.string, DEF_RQUOTE)) { xfprintf (file, "Q%d,%d\n", (int) lquote.length, (int) rquote.length); fputs (lquote.string, file); fputs (rquote.string, file); fputc ('\n', file); } if (strcmp (bcomm.string, DEF_BCOMM) || strcmp (ecomm.string, DEF_ECOMM)) { xfprintf (file, "C%d,%d\n", (int) bcomm.length, (int) ecomm.length); fputs (bcomm.string, file); fputs (ecomm.string, file); fputc ('\n', file); } for (h = 0; h < hash_table_size; h++) { symtab[h] = reverse_symbol_list (symtab[h]); for (sym = symtab[h]; sym; sym = SYMBOL_NEXT (sym)) { switch (SYMBOL_TYPE (sym)) { case TOKEN_TEXT: xfprintf (file, "T%d,%d\n", (int) strlen (SYMBOL_NAME (sym)), (int) strlen (SYMBOL_TEXT (sym))); fputs (SYMBOL_NAME (sym), file); fputs (SYMBOL_TEXT (sym), file); fputc ('\n', file); break; case TOKEN_FUNC: bp = find_builtin_by_addr (SYMBOL_FUNC (sym)); if (bp == NULL) { M4ERROR ((warning_status, 0, "\ INTERNAL ERROR: builtin not found in builtin table!")); abort (); } xfprintf (file, "F%d,%d\n", (int) strlen (SYMBOL_NAME (sym)), (int) strlen (bp->name)); fputs (SYMBOL_NAME (sym), file); fputs (bp->name, file); fputc ('\n', file); break; case TOKEN_VOID: break; default: M4ERROR ((warning_status, 0, "\ INTERNAL ERROR: bad token data type in freeze_one_symbol ()")); abort (); break; } } symtab[h] = reverse_symbol_list (symtab[h]); } freeze_diversions (file); fputs ("# End of frozen state file\n", file); if (close_stream (file) != 0) M4ERROR ((EXIT_FAILURE, errno, "unable to create frozen state")); }
298
1
mptctl_eventenable (unsigned long arg) { struct mpt_ioctl_eventenable __user *uarg = (void __user *) arg; struct mpt_ioctl_eventenable karg; MPT_ADAPTER *ioc; int iocnum; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventenable - " "Unable to read in mpt_ioctl_eventenable struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventenable() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventenable called.\n", ioc->name)); if (ioc->events == NULL) { /* Have not yet allocated memory - do so now. */ int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); ioc->events = kzalloc(sz, GFP_KERNEL); if (!ioc->events) { printk(MYIOC_s_ERR_FMT ": ERROR - Insufficient memory to add adapter!\n", ioc->name); return -ENOMEM; } ioc->alloc_total += sz; ioc->eventContext = 0; } /* Update the IOC event logging flag. */ ioc->eventTypes = karg.eventTypes; return 0; }
mptctl_eventenable (unsigned long arg) { struct mpt_ioctl_eventenable __user *uarg = (void __user *) arg; struct mpt_ioctl_eventenable karg; MPT_ADAPTER *ioc; int iocnum; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventenable - " "Unable to read in mpt_ioctl_eventenable struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventenable() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventenable called.\n", ioc->name)); if (ioc->events == NULL) { int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); ioc->events = kzalloc(sz, GFP_KERNEL); if (!ioc->events) { printk(MYIOC_s_ERR_FMT ": ERROR - Insufficient memory to add adapter!\n", ioc->name); return -ENOMEM; } ioc->alloc_total += sz; ioc->eventContext = 0; } ioc->eventTypes = karg.eventTypes; return 0; }
301
1
static unsigned char asn1_oid_decode(struct asn1_ctx *ctx, unsigned char *eoc, unsigned long **oid, unsigned int *len) { unsigned long subid; unsigned int size; unsigned long *optr; size = eoc - ctx->pointer + 1; *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); if (*oid == NULL) { if (net_ratelimit()) printk("OOM in bsalg (%d)\n", __LINE__); return 0; } optr = *oid; if (!asn1_subid_decode(ctx, &subid)) { kfree(*oid); *oid = NULL; return 0; } if (subid < 40) { optr [0] = 0; optr [1] = subid; } else if (subid < 80) { optr [0] = 1; optr [1] = subid - 40; } else { optr [0] = 2; optr [1] = subid - 80; } *len = 2; optr += 2; while (ctx->pointer < eoc) { if (++(*len) > size) { ctx->error = ASN1_ERR_DEC_BADVALUE; kfree(*oid); *oid = NULL; return 0; } if (!asn1_subid_decode(ctx, optr++)) { kfree(*oid); *oid = NULL; return 0; } } return 1; }
static unsigned char asn1_oid_decode(struct asn1_ctx *ctx, unsigned char *eoc, unsigned long **oid, unsigned int *len) { unsigned long subid; unsigned int size; unsigned long *optr; size = eoc - ctx->pointer + 1; *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); if (*oid == NULL) { if (net_ratelimit()) printk("OOM in bsalg (%d)\n", __LINE__); return 0; } optr = *oid; if (!asn1_subid_decode(ctx, &subid)) { kfree(*oid); *oid = NULL; return 0; } if (subid < 40) { optr [0] = 0; optr [1] = subid; } else if (subid < 80) { optr [0] = 1; optr [1] = subid - 40; } else { optr [0] = 2; optr [1] = subid - 80; } *len = 2; optr += 2; while (ctx->pointer < eoc) { if (++(*len) > size) { ctx->error = ASN1_ERR_DEC_BADVALUE; kfree(*oid); *oid = NULL; return 0; } if (!asn1_subid_decode(ctx, optr++)) { kfree(*oid); *oid = NULL; return 0; } } return 1; }
303
1
spnego_gss_accept_sec_context( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_cred_id_t verifier_cred_handle, gss_buffer_t input_token, gss_channel_bindings_t input_chan_bindings, gss_name_t *src_name, gss_OID *mech_type, gss_buffer_t output_token, OM_uint32 *ret_flags, OM_uint32 *time_rec, gss_cred_id_t *delegated_cred_handle) { OM_uint32 ret, tmpmin, negState; send_token_flag return_token; gss_buffer_t mechtok_in, mic_in, mic_out; gss_buffer_desc mechtok_out = GSS_C_EMPTY_BUFFER; spnego_gss_ctx_id_t sc = NULL; spnego_gss_cred_id_t spcred = NULL; int sendTokenInit = 0, tmpret; mechtok_in = mic_in = mic_out = GSS_C_NO_BUFFER; /* * This function works in three steps: * * 1. Perform mechanism negotiation. * 2. Invoke the negotiated mech's gss_accept_sec_context function * and examine the results. * 3. Process or generate MICs if necessary. * * Step one determines whether the negotiation requires a MIC exchange, * while steps two and three share responsibility for determining when * the exchange is complete. If the selected mech completes in this * call and no MIC exchange is expected, then step 2 will decide. If a * MIC exchange is expected, then step 3 will decide. If an error * occurs in any step, the exchange will be aborted, possibly with an * error token. * * negState determines the state of the negotiation, and is * communicated to the acceptor if a continuing token is sent. * return_token is used to indicate what type of token, if any, should * be generated. */ /* Validate arguments. */ if (minor_status != NULL) *minor_status = 0; if (output_token != GSS_C_NO_BUFFER) { output_token->length = 0; output_token->value = NULL; } if (minor_status == NULL || output_token == GSS_C_NO_BUFFER || context_handle == NULL) return GSS_S_CALL_INACCESSIBLE_WRITE; if (input_token == GSS_C_NO_BUFFER) return GSS_S_CALL_INACCESSIBLE_READ; /* Step 1: Perform mechanism negotiation. */ sc = (spnego_gss_ctx_id_t)*context_handle; spcred = (spnego_gss_cred_id_t)verifier_cred_handle; if (sc == NULL || sc->internal_mech == GSS_C_NO_OID) { /* Process an initial token or request for NegHints. */ if (src_name != NULL) *src_name = GSS_C_NO_NAME; if (mech_type != NULL) *mech_type = GSS_C_NO_OID; if (time_rec != NULL) *time_rec = 0; if (ret_flags != NULL) *ret_flags = 0; if (delegated_cred_handle != NULL) *delegated_cred_handle = GSS_C_NO_CREDENTIAL; if (input_token->length == 0) { ret = acc_ctx_hints(minor_status, context_handle, spcred, &mic_out, &negState, &return_token); if (ret != GSS_S_COMPLETE) goto cleanup; sendTokenInit = 1; ret = GSS_S_CONTINUE_NEEDED; } else { /* Can set negState to REQUEST_MIC */ ret = acc_ctx_new(minor_status, input_token, context_handle, spcred, &mechtok_in, &mic_in, &negState, &return_token); if (ret != GSS_S_COMPLETE) goto cleanup; ret = GSS_S_CONTINUE_NEEDED; } } else { /* Process a response token. Can set negState to * ACCEPT_INCOMPLETE. */ ret = acc_ctx_cont(minor_status, input_token, context_handle, &mechtok_in, &mic_in, &negState, &return_token); if (ret != GSS_S_COMPLETE) goto cleanup; ret = GSS_S_CONTINUE_NEEDED; } /* Step 2: invoke the negotiated mechanism's gss_accept_sec_context * function. */ sc = (spnego_gss_ctx_id_t)*context_handle; /* * Handle mechtok_in and mic_in only if they are * present in input_token. If neither is present, whether * this is an error depends on whether this is the first * round-trip. RET is set to a default value according to * whether it is the first round-trip. */ if (negState != REQUEST_MIC && mechtok_in != GSS_C_NO_BUFFER) { ret = acc_ctx_call_acc(minor_status, sc, spcred, mechtok_in, mech_type, &mechtok_out, ret_flags, time_rec, delegated_cred_handle, &negState, &return_token); } /* Step 3: process or generate the MIC, if the negotiated mech is * complete and supports MICs. */ if (!HARD_ERROR(ret) && sc->mech_complete && (sc->ctx_flags & GSS_C_INTEG_FLAG)) { ret = handle_mic(minor_status, mic_in, (mechtok_out.length != 0), sc, &mic_out, &negState, &return_token); } cleanup: if (return_token == INIT_TOKEN_SEND && sendTokenInit) { assert(sc != NULL); tmpret = make_spnego_tokenInit_msg(sc, 1, mic_out, 0, GSS_C_NO_BUFFER, return_token, output_token); if (tmpret < 0) ret = GSS_S_FAILURE; } else if (return_token != NO_TOKEN_SEND && return_token != CHECK_MIC) { tmpret = make_spnego_tokenTarg_msg(negState, sc ? sc->internal_mech : GSS_C_NO_OID, &mechtok_out, mic_out, return_token, output_token); if (tmpret < 0) ret = GSS_S_FAILURE; } if (ret == GSS_S_COMPLETE) { *context_handle = (gss_ctx_id_t)sc->ctx_handle; if (sc->internal_name != GSS_C_NO_NAME && src_name != NULL) { *src_name = sc->internal_name; sc->internal_name = GSS_C_NO_NAME; } release_spnego_ctx(&sc); } else if (ret != GSS_S_CONTINUE_NEEDED) { if (sc != NULL) { gss_delete_sec_context(&tmpmin, &sc->ctx_handle, GSS_C_NO_BUFFER); release_spnego_ctx(&sc); } *context_handle = GSS_C_NO_CONTEXT; } gss_release_buffer(&tmpmin, &mechtok_out); if (mechtok_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechtok_in); free(mechtok_in); } if (mic_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mic_in); free(mic_in); } if (mic_out != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mic_out); free(mic_out); } return ret; }
spnego_gss_accept_sec_context( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_cred_id_t verifier_cred_handle, gss_buffer_t input_token, gss_channel_bindings_t input_chan_bindings, gss_name_t *src_name, gss_OID *mech_type, gss_buffer_t output_token, OM_uint32 *ret_flags, OM_uint32 *time_rec, gss_cred_id_t *delegated_cred_handle) { OM_uint32 ret, tmpmin, negState; send_token_flag return_token; gss_buffer_t mechtok_in, mic_in, mic_out; gss_buffer_desc mechtok_out = GSS_C_EMPTY_BUFFER; spnego_gss_ctx_id_t sc = NULL; spnego_gss_cred_id_t spcred = NULL; int sendTokenInit = 0, tmpret; mechtok_in = mic_in = mic_out = GSS_C_NO_BUFFER; if (minor_status != NULL) *minor_status = 0; if (output_token != GSS_C_NO_BUFFER) { output_token->length = 0; output_token->value = NULL; } if (minor_status == NULL || output_token == GSS_C_NO_BUFFER || context_handle == NULL) return GSS_S_CALL_INACCESSIBLE_WRITE; if (input_token == GSS_C_NO_BUFFER) return GSS_S_CALL_INACCESSIBLE_READ; sc = (spnego_gss_ctx_id_t)*context_handle; spcred = (spnego_gss_cred_id_t)verifier_cred_handle; if (sc == NULL || sc->internal_mech == GSS_C_NO_OID) { if (src_name != NULL) *src_name = GSS_C_NO_NAME; if (mech_type != NULL) *mech_type = GSS_C_NO_OID; if (time_rec != NULL) *time_rec = 0; if (ret_flags != NULL) *ret_flags = 0; if (delegated_cred_handle != NULL) *delegated_cred_handle = GSS_C_NO_CREDENTIAL; if (input_token->length == 0) { ret = acc_ctx_hints(minor_status, context_handle, spcred, &mic_out, &negState, &return_token); if (ret != GSS_S_COMPLETE) goto cleanup; sendTokenInit = 1; ret = GSS_S_CONTINUE_NEEDED; } else { ret = acc_ctx_new(minor_status, input_token, context_handle, spcred, &mechtok_in, &mic_in, &negState, &return_token); if (ret != GSS_S_COMPLETE) goto cleanup; ret = GSS_S_CONTINUE_NEEDED; } } else { ret = acc_ctx_cont(minor_status, input_token, context_handle, &mechtok_in, &mic_in, &negState, &return_token); if (ret != GSS_S_COMPLETE) goto cleanup; ret = GSS_S_CONTINUE_NEEDED; } sc = (spnego_gss_ctx_id_t)*context_handle; if (negState != REQUEST_MIC && mechtok_in != GSS_C_NO_BUFFER) { ret = acc_ctx_call_acc(minor_status, sc, spcred, mechtok_in, mech_type, &mechtok_out, ret_flags, time_rec, delegated_cred_handle, &negState, &return_token); } if (!HARD_ERROR(ret) && sc->mech_complete && (sc->ctx_flags & GSS_C_INTEG_FLAG)) { ret = handle_mic(minor_status, mic_in, (mechtok_out.length != 0), sc, &mic_out, &negState, &return_token); } cleanup: if (return_token == INIT_TOKEN_SEND && sendTokenInit) { assert(sc != NULL); tmpret = make_spnego_tokenInit_msg(sc, 1, mic_out, 0, GSS_C_NO_BUFFER, return_token, output_token); if (tmpret < 0) ret = GSS_S_FAILURE; } else if (return_token != NO_TOKEN_SEND && return_token != CHECK_MIC) { tmpret = make_spnego_tokenTarg_msg(negState, sc ? sc->internal_mech : GSS_C_NO_OID, &mechtok_out, mic_out, return_token, output_token); if (tmpret < 0) ret = GSS_S_FAILURE; } if (ret == GSS_S_COMPLETE) { *context_handle = (gss_ctx_id_t)sc->ctx_handle; if (sc->internal_name != GSS_C_NO_NAME && src_name != NULL) { *src_name = sc->internal_name; sc->internal_name = GSS_C_NO_NAME; } release_spnego_ctx(&sc); } else if (ret != GSS_S_CONTINUE_NEEDED) { if (sc != NULL) { gss_delete_sec_context(&tmpmin, &sc->ctx_handle, GSS_C_NO_BUFFER); release_spnego_ctx(&sc); } *context_handle = GSS_C_NO_CONTEXT; } gss_release_buffer(&tmpmin, &mechtok_out); if (mechtok_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechtok_in); free(mechtok_in); } if (mic_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mic_in); free(mic_in); } if (mic_out != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mic_out); free(mic_out); } return ret; }
304
1
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { int i, ret = 0; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); if (!avctx->codec) return AVERROR(EINVAL); if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n"); return AVERROR(EINVAL); *got_sub_ptr = 0; avcodec_get_subtitle_defaults(sub); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); //apply_param_change(avctx, &tmp); pkt_recoded = tmp; ret = recode_subtitle(avctx, &pkt_recoded, &tmp); if (ret < 0) { *got_sub_ptr = 0; } else { avctx->internal->pkt = &pkt_recoded; if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded); av_assert1((ret >= 0) >= !!*got_sub_ptr && !!*got_sub_ptr >= !!sub->num_rects); if (sub->num_rects && !sub->end_display_time && avpkt->duration && avctx->pkt_timebase.num) { AVRational ms = { 1, 1000 }; sub->end_display_time = av_rescale_q(avpkt->duration, avctx->pkt_timebase, ms); for (i = 0; i < sub->num_rects; i++) { if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) { av_log(avctx, AV_LOG_ERROR, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); avsubtitle_free(sub); return AVERROR_INVALIDDATA; if (tmp.data != pkt_recoded.data) { // did we recode? /* prevent from destroying side data from original packet */ pkt_recoded.side_data = NULL; pkt_recoded.side_data_elems = 0; av_free_packet(&pkt_recoded); if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) sub->format = 0; else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) sub->format = 1; avctx->internal->pkt = NULL; av_packet_free_side_data(&tmp); if(ret == tmp.size) ret = avpkt->size; if (*got_sub_ptr) avctx->frame_number++; return ret;
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { int i, ret = 0; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); if (!avctx->codec) return AVERROR(EINVAL); if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n"); return AVERROR(EINVAL); *got_sub_ptr = 0; avcodec_get_subtitle_defaults(sub); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp);
306
0
static int sapi_uwsgi_read_post ( char * buffer , uint count_bytes TSRMLS_DC ) # endif { uint read_bytes = 0 ; struct wsgi_request * wsgi_req = ( struct wsgi_request * ) SG ( server_context ) ; count_bytes = MIN ( count_bytes , wsgi_req -> post_cl - SG ( read_post_bytes ) ) ; while ( read_bytes < count_bytes ) { ssize_t rlen = 0 ; char * buf = uwsgi_request_body_read ( wsgi_req , count_bytes - read_bytes , & rlen ) ; if ( buf == uwsgi . empty ) break ; if ( buf ) { memcpy ( buffer , buf , rlen ) ; read_bytes += rlen ; continue ; } break ; } return read_bytes ; }
static int sapi_uwsgi_read_post ( char * buffer , uint count_bytes TSRMLS_DC ) # endif { uint read_bytes = 0 ; struct wsgi_request * wsgi_req = ( struct wsgi_request * ) SG ( server_context ) ; count_bytes = MIN ( count_bytes , wsgi_req -> post_cl - SG ( read_post_bytes ) ) ; while ( read_bytes < count_bytes ) { ssize_t rlen = 0 ; char * buf = uwsgi_request_body_read ( wsgi_req , count_bytes - read_bytes , & rlen ) ; if ( buf == uwsgi . empty ) break ; if ( buf ) { memcpy ( buffer , buf , rlen ) ; read_bytes += rlen ; continue ; } break ; } return read_bytes ; }
308
1
mptctl_eventquery (unsigned long arg) { struct mpt_ioctl_eventquery __user *uarg = (void __user *) arg; struct mpt_ioctl_eventquery karg; MPT_ADAPTER *ioc; int iocnum; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventquery - " "Unable to read in mpt_ioctl_eventquery struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventquery() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventquery called.\n", ioc->name)); karg.eventEntries = MPTCTL_EVENT_LOG_SIZE; karg.eventTypes = ioc->eventTypes; /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventquery - " "Unable to write out mpt_ioctl_eventquery struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
mptctl_eventquery (unsigned long arg) { struct mpt_ioctl_eventquery __user *uarg = (void __user *) arg; struct mpt_ioctl_eventquery karg; MPT_ADAPTER *ioc; int iocnum; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventquery - " "Unable to read in mpt_ioctl_eventquery struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventquery() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventquery called.\n", ioc->name)); karg.eventEntries = MPTCTL_EVENT_LOG_SIZE; karg.eventTypes = ioc->eventTypes; if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventquery - " "Unable to write out mpt_ioctl_eventquery struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
309
1
asn1_header_decode(struct asn1_ctx *ctx, unsigned char **eoc, unsigned int *cls, unsigned int *con, unsigned int *tag) { unsigned int def = 0; unsigned int len = 0; if (!asn1_id_decode(ctx, cls, con, tag)) return 0; if (!asn1_length_decode(ctx, &def, &len)) return 0; if (def) *eoc = ctx->pointer + len; else *eoc = NULL; return 1; }
asn1_header_decode(struct asn1_ctx *ctx, unsigned char **eoc, unsigned int *cls, unsigned int *con, unsigned int *tag) { unsigned int def = 0; unsigned int len = 0; if (!asn1_id_decode(ctx, cls, con, tag)) return 0; if (!asn1_length_decode(ctx, &def, &len)) return 0; if (def) *eoc = ctx->pointer + len; else *eoc = NULL; return 1; }
310
0
static int mp_decode_frame(MPADecodeContext *s, short *samples) { int i, nb_frames, ch; short *samples_ptr; init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, s->inbuf_ptr - s->inbuf - HEADER_SIZE); /* skip error protection field */ if (s->error_protection) get_bits(&s->gb, 16); dprintf("frame %d:\n", s->frame_count); switch(s->layer) { case 1: nb_frames = mp_decode_layer1(s); break; case 2: nb_frames = mp_decode_layer2(s); break; case 3: default: nb_frames = mp_decode_layer3(s); break; } #if defined(DEBUG) for(i=0;i<nb_frames;i++) { for(ch=0;ch<s->nb_channels;ch++) { int j; printf("%d-%d:", i, ch); for(j=0;j<SBLIMIT;j++) printf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); printf("\n"); } } #endif /* apply the synthesis filter */ for(ch=0;ch<s->nb_channels;ch++) { samples_ptr = samples + ch; for(i=0;i<nb_frames;i++) { synth_filter(s, ch, samples_ptr, s->nb_channels, s->sb_samples[ch][i]); samples_ptr += 32 * s->nb_channels; } } #ifdef DEBUG s->frame_count++; #endif return nb_frames * 32 * sizeof(short) * s->nb_channels; }
static int mp_decode_frame(MPADecodeContext *s, short *samples) { int i, nb_frames, ch; short *samples_ptr; init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, s->inbuf_ptr - s->inbuf - HEADER_SIZE); if (s->error_protection) get_bits(&s->gb, 16); dprintf("frame %d:\n", s->frame_count); switch(s->layer) { case 1: nb_frames = mp_decode_layer1(s); break; case 2: nb_frames = mp_decode_layer2(s); break; case 3: default: nb_frames = mp_decode_layer3(s); break; } #if defined(DEBUG) for(i=0;i<nb_frames;i++) { for(ch=0;ch<s->nb_channels;ch++) { int j; printf("%d-%d:", i, ch); for(j=0;j<SBLIMIT;j++) printf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); printf("\n"); } } #endif for(ch=0;ch<s->nb_channels;ch++) { samples_ptr = samples + ch; for(i=0;i<nb_frames;i++) { synth_filter(s, ch, samples_ptr, s->nb_channels, s->sb_samples[ch][i]); samples_ptr += 32 * s->nb_channels; } } #ifdef DEBUG s->frame_count++; #endif return nb_frames * 32 * sizeof(short) * s->nb_channels; }
311
0
void dissect_zcl_power_config_attr_data ( proto_tree * tree , tvbuff_t * tvb , guint * offset , guint16 attr_id , guint data_type ) { proto_item * it ; static const int * mains_alarm_mask [ ] = { & hf_zbee_zcl_power_config_mains_alarm_mask_low , & hf_zbee_zcl_power_config_mains_alarm_mask_high , & hf_zbee_zcl_power_config_mains_alarm_mask_reserved , NULL } ; static const int * batt_alarm_mask [ ] = { & hf_zbee_zcl_power_config_batt_alarm_mask_low , & hf_zbee_zcl_power_config_batt_alarm_mask_reserved , NULL } ; switch ( attr_id ) { case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_FREQUENCY : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_frequency , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_ALARM_MASK : proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_power_config_mains_alarm_mask , ett_zbee_zcl_power_config_mains_alarm_mask , mains_alarm_mask , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE_MIN_THR : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage_min_thr , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE_MAX_THR : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage_max_thr , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE_DWELL_TP : it = proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage_dwell_tp , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; proto_item_append_text ( it , " [s]" ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_SIZE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_type , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_VOLTAGE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_voltage , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_AH_RATING : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_ah_rating , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_RATED_VOLTAGE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_rated_voltage , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_ALARM_MASK : proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_power_config_batt_alarm_mask , ett_zbee_zcl_power_config_batt_alarm_mask , batt_alarm_mask , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_VOLTAGE_MIN_THR : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_voltage_min_thr , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_MANUFACTURER : case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_QUANTITY : default : dissect_zcl_attr_data ( tvb , tree , offset , data_type ) ; break ; } }
void dissect_zcl_power_config_attr_data ( proto_tree * tree , tvbuff_t * tvb , guint * offset , guint16 attr_id , guint data_type ) { proto_item * it ; static const int * mains_alarm_mask [ ] = { & hf_zbee_zcl_power_config_mains_alarm_mask_low , & hf_zbee_zcl_power_config_mains_alarm_mask_high , & hf_zbee_zcl_power_config_mains_alarm_mask_reserved , NULL } ; static const int * batt_alarm_mask [ ] = { & hf_zbee_zcl_power_config_batt_alarm_mask_low , & hf_zbee_zcl_power_config_batt_alarm_mask_reserved , NULL } ; switch ( attr_id ) { case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_FREQUENCY : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_frequency , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_ALARM_MASK : proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_power_config_mains_alarm_mask , ett_zbee_zcl_power_config_mains_alarm_mask , mains_alarm_mask , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE_MIN_THR : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage_min_thr , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE_MAX_THR : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage_max_thr , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_MAINS_VOLTAGE_DWELL_TP : it = proto_tree_add_item ( tree , hf_zbee_zcl_power_config_mains_voltage_dwell_tp , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; proto_item_append_text ( it , " [s]" ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_SIZE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_type , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_VOLTAGE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_voltage , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_AH_RATING : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_ah_rating , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ; * offset += 2 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_RATED_VOLTAGE : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_rated_voltage , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_ALARM_MASK : proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_power_config_batt_alarm_mask , ett_zbee_zcl_power_config_batt_alarm_mask , batt_alarm_mask , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_VOLTAGE_MIN_THR : proto_tree_add_item ( tree , hf_zbee_zcl_power_config_batt_voltage_min_thr , tvb , * offset , 1 , ENC_LITTLE_ENDIAN ) ; * offset += 1 ; break ; case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_MANUFACTURER : case ZBEE_ZCL_ATTR_ID_POWER_CONF_BATTERY_QUANTITY : default : dissect_zcl_attr_data ( tvb , tree , offset , data_type ) ; break ; } }
312
0
static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { PCMDecode *s = avctx->priv_data; int sample_size, c, n; short *samples; const uint8_t *src, *src8, *src2[MAX_CHANNELS]; uint8_t *dstu8; int16_t *dst_int16_t; int32_t *dst_int32_t; int64_t *dst_int64_t; uint16_t *dst_uint16_t; uint32_t *dst_uint32_t; samples = data; src = buf; if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); return -1; } if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); return -1; } sample_size = av_get_bits_per_sample(avctx->codec_id)/8; /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ if (CODEC_ID_PCM_DVD == avctx->codec_id) /* 2 samples are interleaved per block in PCM_DVD */ sample_size = avctx->bits_per_coded_sample * 2 / 8; n = avctx->channels * sample_size; if(n && buf_size % n){ av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; } buf_size= FFMIN(buf_size, *data_size/2); *data_size=0; n = buf_size/sample_size; switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: DECODE(int32_t, le24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_S24BE: DECODE(int32_t, be24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_U24LE: DECODE(uint32_t, le24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: DECODE(uint32_t, be24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4; // sync flags are here *samples++ = ff_reverse[(v >> 8) & 0xff] + (ff_reverse[v & 0xff] << 8); } break; case CODEC_ID_PCM_S16LE_PLANAR: n /= avctx->channels; for(c=0;c<avctx->channels;c++) src2[c] = &src[c*n*2]; for(;n>0;n--) for(c=0;c<avctx->channels;c++) *samples++ = bytestream_get_le16(&src2[c]); src = src2[avctx->channels-1]; break; case CODEC_ID_PCM_U16LE: DECODE(uint16_t, le16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: DECODE(uint16_t, be16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: dstu8= (uint8_t*)samples; for(;n>0;n--) { *dstu8++ = *src++ + 128; } samples= (short*)dstu8; break; #if WORDS_BIGENDIAN case CODEC_ID_PCM_F64LE: DECODE(int64_t, le64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: DECODE(int32_t, le32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16LE: DECODE(int16_t, le16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: DECODE(int64_t, be64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: DECODE(int32_t, be32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16BE: DECODE(int16_t, be16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S16LE: #endif /* WORDS_BIGENDIAN */ case CODEC_ID_PCM_U8: memcpy(samples, src, n*sample_size); src += n*sample_size; samples = (short*)((uint8_t*)data + n*sample_size); break; case CODEC_ID_PCM_ZORK: for(;n>0;n--) { int x= *src++; if(x&128) x-= 128; else x = -x; *samples++ = x << 8; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: for(;n>0;n--) { *samples++ = s->table[*src++]; } break; case CODEC_ID_PCM_DVD: dst_int32_t = data; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12); } src = src8; } break; case 24: while (n--) { c = avctx->channels; src8 = src + 4*c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); } src = src8; } break; default: av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); return -1; break; } samples = (short *) dst_int32_t; break; default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }
static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { PCMDecode *s = avctx->priv_data; int sample_size, c, n; short *samples; const uint8_t *src, *src8, *src2[MAX_CHANNELS]; uint8_t *dstu8; int16_t *dst_int16_t; int32_t *dst_int32_t; int64_t *dst_int64_t; uint16_t *dst_uint16_t; uint32_t *dst_uint32_t; samples = data; src = buf; if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); return -1; } if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); return -1; } sample_size = av_get_bits_per_sample(avctx->codec_id)/8; if (CODEC_ID_PCM_DVD == avctx->codec_id) sample_size = avctx->bits_per_coded_sample * 2 / 8; n = avctx->channels * sample_size; if(n && buf_size % n){ av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; } buf_size= FFMIN(buf_size, *data_size/2); *data_size=0; n = buf_size/sample_size; switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: DECODE(int32_t, le24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_S24BE: DECODE(int32_t, be24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_U24LE: DECODE(uint32_t, le24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: DECODE(uint32_t, be24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4;
313
1
spnego_gss_complete_auth_token( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, gss_buffer_t input_message_buffer) { OM_uint32 ret; ret = gss_complete_auth_token(minor_status, context_handle, input_message_buffer); return (ret); }
spnego_gss_complete_auth_token( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, gss_buffer_t input_message_buffer) { OM_uint32 ret; ret = gss_complete_auth_token(minor_status, context_handle, input_message_buffer); return (ret); }
314
1
static unsigned char asn1_header_decode(struct asn1_ctx *ctx, unsigned char **eoc, unsigned int *cls, unsigned int *con, unsigned int *tag) { unsigned int def, len; if (!asn1_id_decode(ctx, cls, con, tag)) return 0; def = len = 0; if (!asn1_length_decode(ctx, &def, &len)) return 0; if (def) *eoc = ctx->pointer + len; else *eoc = NULL; return 1; }
static unsigned char asn1_header_decode(struct asn1_ctx *ctx, unsigned char **eoc, unsigned int *cls, unsigned int *con, unsigned int *tag) { unsigned int def, len; if (!asn1_id_decode(ctx, cls, con, tag)) return 0; def = len = 0; if (!asn1_length_decode(ctx, &def, &len)) return 0; if (def) *eoc = ctx->pointer + len; else *eoc = NULL; return 1; }
315
0
mptctl_eventreport (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_eventreport __user *uarg = (void __user *) arg; struct mpt_ioctl_eventreport karg; int numBytes, maxEvents, max; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventreport - " "Unable to read in mpt_ioctl_eventreport struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventreport called.\n", ioc->name)); numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); maxEvents = numBytes/sizeof(MPT_IOCTL_EVENTS); max = MPTCTL_EVENT_LOG_SIZE < maxEvents ? MPTCTL_EVENT_LOG_SIZE : maxEvents; /* If fewer than 1 event is requested, there must have * been some type of error. */ if ((max < 1) || !ioc->events) return -ENODATA; /* reset this flag so SIGIO can restart */ ioc->aen_event_read_flag=0; /* Copy the data from kernel memory to user memory */ numBytes = max * sizeof(MPT_IOCTL_EVENTS); if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventreport - " "Unable to write out mpt_ioctl_eventreport struct @ %p\n", ioc->name, __FILE__, __LINE__, ioc->events); return -EFAULT; } return 0; }
mptctl_eventreport (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_eventreport __user *uarg = (void __user *) arg; struct mpt_ioctl_eventreport karg; int numBytes, maxEvents, max; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventreport - " "Unable to read in mpt_ioctl_eventreport struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventreport called.\n", ioc->name)); numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); maxEvents = numBytes/sizeof(MPT_IOCTL_EVENTS); max = MPTCTL_EVENT_LOG_SIZE < maxEvents ? MPTCTL_EVENT_LOG_SIZE : maxEvents; if ((max < 1) || !ioc->events) return -ENODATA; ioc->aen_event_read_flag=0; numBytes = max * sizeof(MPT_IOCTL_EVENTS); if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventreport - " "Unable to write out mpt_ioctl_eventreport struct @ %p\n", ioc->name, __FILE__, __LINE__, ioc->events); return -EFAULT; } return 0; }
316
0
IN_PROC_BROWSER_TEST_F ( FramebustBlockBrowserTest , AllowRadioButtonSelected ) { const GURL url = embedded_test_server ( ) -> GetURL ( "/iframe.html" ) ; ui_test_utils : : NavigateToURL ( browser ( ) , url ) ; auto * helper = GetFramebustTabHelper ( ) ; helper -> AddBlockedUrl ( url , base : : BindOnce ( & FramebustBlockBrowserTest : : OnClick , base : : Unretained ( this ) ) ) ; EXPECT_TRUE ( helper -> HasBlockedUrls ( ) ) ; HostContentSettingsMap * settings_map = HostContentSettingsMapFactory : : GetForProfile ( browser ( ) -> profile ( ) ) ; EXPECT_EQ ( CONTENT_SETTING_BLOCK , settings_map -> GetContentSetting ( url , GURL ( ) , CONTENT_SETTINGS_TYPE_POPUPS , std : : string ( ) ) ) ; { ContentSettingFramebustBlockBubbleModel framebust_block_bubble_model ( browser ( ) -> content_setting_bubble_model_delegate ( ) , GetWebContents ( ) , browser ( ) -> profile ( ) ) ; framebust_block_bubble_model . OnRadioClicked ( kAllowRadioButtonIndex ) ; } EXPECT_EQ ( CONTENT_SETTING_ALLOW , settings_map -> GetContentSetting ( url , GURL ( ) , CONTENT_SETTINGS_TYPE_POPUPS , std : : string ( ) ) ) ; }
IN_PROC_BROWSER_TEST_F ( FramebustBlockBrowserTest , AllowRadioButtonSelected ) { const GURL url = embedded_test_server ( ) -> GetURL ( "/iframe.html" ) ; ui_test_utils : : NavigateToURL ( browser ( ) , url ) ; auto * helper = GetFramebustTabHelper ( ) ; helper -> AddBlockedUrl ( url , base : : BindOnce ( & FramebustBlockBrowserTest : : OnClick , base : : Unretained ( this ) ) ) ; EXPECT_TRUE ( helper -> HasBlockedUrls ( ) ) ; HostContentSettingsMap * settings_map = HostContentSettingsMapFactory : : GetForProfile ( browser ( ) -> profile ( ) ) ; EXPECT_EQ ( CONTENT_SETTING_BLOCK , settings_map -> GetContentSetting ( url , GURL ( ) , CONTENT_SETTINGS_TYPE_POPUPS , std : : string ( ) ) ) ; { ContentSettingFramebustBlockBubbleModel framebust_block_bubble_model ( browser ( ) -> content_setting_bubble_model_delegate ( ) , GetWebContents ( ) , browser ( ) -> profile ( ) ) ; framebust_block_bubble_model . OnRadioClicked ( kAllowRadioButtonIndex ) ; } EXPECT_EQ ( CONTENT_SETTING_ALLOW , settings_map -> GetContentSetting ( url , GURL ( ) , CONTENT_SETTINGS_TYPE_POPUPS , std : : string ( ) ) ) ; }
317
1
mptctl_eventreport (unsigned long arg) { struct mpt_ioctl_eventreport __user *uarg = (void __user *) arg; struct mpt_ioctl_eventreport karg; MPT_ADAPTER *ioc; int iocnum; int numBytes, maxEvents, max; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventreport - " "Unable to read in mpt_ioctl_eventreport struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventreport() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventreport called.\n", ioc->name)); numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); maxEvents = numBytes/sizeof(MPT_IOCTL_EVENTS); max = MPTCTL_EVENT_LOG_SIZE < maxEvents ? MPTCTL_EVENT_LOG_SIZE : maxEvents; /* If fewer than 1 event is requested, there must have * been some type of error. */ if ((max < 1) || !ioc->events) return -ENODATA; /* reset this flag so SIGIO can restart */ ioc->aen_event_read_flag=0; /* Copy the data from kernel memory to user memory */ numBytes = max * sizeof(MPT_IOCTL_EVENTS); if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventreport - " "Unable to write out mpt_ioctl_eventreport struct @ %p\n", ioc->name, __FILE__, __LINE__, ioc->events); return -EFAULT; } return 0; }
mptctl_eventreport (unsigned long arg) { struct mpt_ioctl_eventreport __user *uarg = (void __user *) arg; struct mpt_ioctl_eventreport karg; MPT_ADAPTER *ioc; int iocnum; int numBytes, maxEvents, max; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventreport - " "Unable to read in mpt_ioctl_eventreport struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventreport() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventreport called.\n", ioc->name)); numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); maxEvents = numBytes/sizeof(MPT_IOCTL_EVENTS); max = MPTCTL_EVENT_LOG_SIZE < maxEvents ? MPTCTL_EVENT_LOG_SIZE : maxEvents; if ((max < 1) || !ioc->events) return -ENODATA; ioc->aen_event_read_flag=0; numBytes = max * sizeof(MPT_IOCTL_EVENTS); if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventreport - " "Unable to write out mpt_ioctl_eventreport struct @ %p\n", ioc->name, __FILE__, __LINE__, ioc->events); return -EFAULT; } return 0; }
318
0
static int write_trailer(AVFormatContext *s) { WVMuxContext *wc = s->priv_data; AVIOContext *pb = s->pb; ff_ape_write(s); if (pb->seekable) { avio_seek(pb, 12, SEEK_SET); avio_wl32(pb, wc->duration); avio_flush(pb); } return 0; }
static int write_trailer(AVFormatContext *s) { WVMuxContext *wc = s->priv_data; AVIOContext *pb = s->pb; ff_ape_write(s); if (pb->seekable) { avio_seek(pb, 12, SEEK_SET); avio_wl32(pb, wc->duration); avio_flush(pb); } return 0; }
319
1
static unsigned char asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len) { unsigned char ch, cnt; if (!asn1_octet_decode(ctx, &ch)) return 0; if (ch == 0x80) *def = 0; else { *def = 1; if (ch < 0x80) *len = ch; else { cnt = ch & 0x7F; *len = 0; while (cnt > 0) { if (!asn1_octet_decode(ctx, &ch)) return 0; *len <<= 8; *len |= ch; cnt--; } } } return 1; }
static unsigned char asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len) { unsigned char ch, cnt; if (!asn1_octet_decode(ctx, &ch)) return 0; if (ch == 0x80) *def = 0; else { *def = 1; if (ch < 0x80) *len = ch; else { cnt = ch & 0x7F; *len = 0; while (cnt > 0) { if (!asn1_octet_decode(ctx, &ch)) return 0; *len <<= 8; *len |= ch; cnt--; } } } return 1; }
321
1
spnego_gss_context_time( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, OM_uint32 *time_rec) { OM_uint32 ret; ret = gss_context_time(minor_status, context_handle, time_rec); return (ret); }
spnego_gss_context_time( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, OM_uint32 *time_rec) { OM_uint32 ret; ret = gss_context_time(minor_status, context_handle, time_rec); return (ret); }
322
0
mptctl_fw_download(MPT_ADAPTER *iocp, unsigned long arg) { struct mpt_fw_xfer __user *ufwdl = (void __user *) arg; struct mpt_fw_xfer kfwdl; if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " "Unable to copy mpt_fw_xfer struct @ %p\n", __FILE__, __LINE__, ufwdl); return -EFAULT; } return mptctl_do_fw_download(iocp, kfwdl.bufp, kfwdl.fwlen); }
mptctl_fw_download(MPT_ADAPTER *iocp, unsigned long arg) { struct mpt_fw_xfer __user *ufwdl = (void __user *) arg; struct mpt_fw_xfer kfwdl; if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " "Unable to copy mpt_fw_xfer struct @ %p\n", __FILE__, __LINE__, ufwdl); return -EFAULT; } return mptctl_do_fw_download(iocp, kfwdl.bufp, kfwdl.fwlen); }
323
1
asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len) { unsigned char ch, cnt; if (!asn1_octet_decode(ctx, &ch)) return 0; if (ch == 0x80) *def = 0; else { *def = 1; if (ch < 0x80) *len = ch; else { cnt = (unsigned char) (ch & 0x7F); *len = 0; while (cnt > 0) { if (!asn1_octet_decode(ctx, &ch)) return 0; *len <<= 8; *len |= ch; cnt--; } } } return 1; }
asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len) { unsigned char ch, cnt; if (!asn1_octet_decode(ctx, &ch)) return 0; if (ch == 0x80) *def = 0; else { *def = 1; if (ch < 0x80) *len = ch; else { cnt = (unsigned char) (ch & 0x7F); *len = 0; while (cnt > 0) { if (!asn1_octet_decode(ctx, &ch)) return 0; *len <<= 8; *len |= ch; cnt--; } } } return 1; }
324
0
static void decStatus ( decNumber * dn , uInt status , decContext * set ) { if ( status & DEC_NaNs ) { if ( status & DEC_sNaN ) status &= ~ DEC_sNaN ; else { uprv_decNumberZero ( dn ) ; dn -> bits = DECNAN ; } } uprv_decContextSetStatus ( set , status ) ; return ; }
static void decStatus ( decNumber * dn , uInt status , decContext * set ) { if ( status & DEC_NaNs ) { if ( status & DEC_sNaN ) status &= ~ DEC_sNaN ; else { uprv_decNumberZero ( dn ) ; dn -> bits = DECNAN ; } } uprv_decContextSetStatus ( set , status ) ; return ; }
325
0
void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); /* virtio-1 compliant devices cannot change the alignment */ if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } /* Check that the transport told us it was going to do this * (so a buggy transport will immediately assert rather than * silently failing to migrate this state) */ assert(k->has_variable_vring_alignment); vdev->vq[n].vring.align = align; virtio_queue_update_rings(vdev, n); }
void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } assert(k->has_variable_vring_alignment); vdev->vq[n].vring.align = align; virtio_queue_update_rings(vdev, n); }
326
1
static int ipip6_rcv(struct sk_buff *skb) { struct iphdr *iph; struct ip_tunnel *tunnel; if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) goto out; iph = ip_hdr(skb); read_lock(&ipip6_lock); if ((tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), iph->saddr, iph->daddr)) != NULL) { secpath_reset(skb); skb->mac_header = skb->network_header; skb_reset_network_header(skb); IPCB(skb)->flags = 0; skb->protocol = htons(ETH_P_IPV6); skb->pkt_type = PACKET_HOST; if ((tunnel->dev->priv_flags & IFF_ISATAP) && !isatap_chksrc(skb, iph, tunnel)) { tunnel->stat.rx_errors++; read_unlock(&ipip6_lock); kfree_skb(skb); return 0; } tunnel->stat.rx_packets++; tunnel->stat.rx_bytes += skb->len; skb->dev = tunnel->dev; dst_release(skb->dst); skb->dst = NULL; nf_reset(skb); ipip6_ecn_decapsulate(iph, skb); netif_rx(skb); read_unlock(&ipip6_lock); return 0; } icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); kfree_skb(skb); read_unlock(&ipip6_lock); out: return 0; }
static int ipip6_rcv(struct sk_buff *skb) { struct iphdr *iph; struct ip_tunnel *tunnel; if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) goto out; iph = ip_hdr(skb); read_lock(&ipip6_lock); if ((tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), iph->saddr, iph->daddr)) != NULL) { secpath_reset(skb); skb->mac_header = skb->network_header; skb_reset_network_header(skb); IPCB(skb)->flags = 0; skb->protocol = htons(ETH_P_IPV6); skb->pkt_type = PACKET_HOST; if ((tunnel->dev->priv_flags & IFF_ISATAP) && !isatap_chksrc(skb, iph, tunnel)) { tunnel->stat.rx_errors++; read_unlock(&ipip6_lock); kfree_skb(skb); return 0; } tunnel->stat.rx_packets++; tunnel->stat.rx_bytes += skb->len; skb->dev = tunnel->dev; dst_release(skb->dst); skb->dst = NULL; nf_reset(skb); ipip6_ecn_decapsulate(iph, skb); netif_rx(skb); read_unlock(&ipip6_lock); return 0; } icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); kfree_skb(skb); read_unlock(&ipip6_lock); out: return 0; }
328
1
mptctl_fw_download(unsigned long arg) { struct mpt_fw_xfer __user *ufwdl = (void __user *) arg; struct mpt_fw_xfer kfwdl; if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " "Unable to copy mpt_fw_xfer struct @ %p\n", __FILE__, __LINE__, ufwdl); return -EFAULT; } return mptctl_do_fw_download(kfwdl.iocnum, kfwdl.bufp, kfwdl.fwlen); }
mptctl_fw_download(unsigned long arg) { struct mpt_fw_xfer __user *ufwdl = (void __user *) arg; struct mpt_fw_xfer kfwdl; if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " "Unable to copy mpt_fw_xfer struct @ %p\n", __FILE__, __LINE__, ufwdl); return -EFAULT; } return mptctl_do_fw_download(kfwdl.iocnum, kfwdl.bufp, kfwdl.fwlen); }
330
0
static void dumpcffcidset ( struct alltabs * at ) { int gid , start ; putc ( 2 , at -> charset ) ; start = - 1 ; for ( gid = 1 ; gid < at -> gi . gcnt ; ++ gid ) { if ( start == - 1 ) start = gid ; else if ( at -> gi . bygid [ gid ] - at -> gi . bygid [ start ] != gid - start ) { putshort ( at -> charset , at -> gi . bygid [ start ] ) ; putshort ( at -> charset , at -> gi . bygid [ gid - 1 ] - at -> gi . bygid [ start ] ) ; start = gid ; } } if ( start != - 1 ) { putshort ( at -> charset , at -> gi . bygid [ start ] ) ; putshort ( at -> charset , at -> gi . bygid [ gid - 1 ] - at -> gi . bygid [ start ] ) ; } }
static void dumpcffcidset ( struct alltabs * at ) { int gid , start ; putc ( 2 , at -> charset ) ; start = - 1 ; for ( gid = 1 ; gid < at -> gi . gcnt ; ++ gid ) { if ( start == - 1 ) start = gid ; else if ( at -> gi . bygid [ gid ] - at -> gi . bygid [ start ] != gid - start ) { putshort ( at -> charset , at -> gi . bygid [ start ] ) ; putshort ( at -> charset , at -> gi . bygid [ gid - 1 ] - at -> gi . bygid [ start ] ) ; start = gid ; } } if ( start != - 1 ) { putshort ( at -> charset , at -> gi . bygid [ start ] ) ; putshort ( at -> charset , at -> gi . bygid [ gid - 1 ] - at -> gi . bygid [ start ] ) ; } }
331
0
mptctl_getiocinfo (MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) { struct mpt_ioctl_iocinfo __user *uarg = (void __user *) arg; struct mpt_ioctl_iocinfo *karg; struct pci_dev *pdev; unsigned int port; int cim_rev; struct scsi_device *sdev; VirtDevice *vdevice; /* Add of PCI INFO results in unaligned access for * IA64 and Sparc. Reset long to int. Return no PCI * data for obsolete format. */ if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev0)) cim_rev = 0; else if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev1)) cim_rev = 1; else if (data_size == sizeof(struct mpt_ioctl_iocinfo)) cim_rev = 2; else if (data_size == (sizeof(struct mpt_ioctl_iocinfo_rev0)+12)) cim_rev = 0; /* obsolete */ else return -EFAULT; karg = memdup_user(uarg, data_size); if (IS_ERR(karg)) { printk(KERN_ERR MYNAM "%s@%d::mpt_ioctl_iocinfo() - memdup_user returned error [%ld]\n", __FILE__, __LINE__, PTR_ERR(karg)); return PTR_ERR(karg); } /* Verify the data transfer size is correct. */ if (karg->hdr.maxDataSize != data_size) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Structure size mismatch. Command not completed.\n", ioc->name, __FILE__, __LINE__); kfree(karg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_getiocinfo called.\n", ioc->name)); /* Fill in the data and return the structure to the calling * program */ if (ioc->bus_type == SAS) karg->adapterType = MPT_IOCTL_INTERFACE_SAS; else if (ioc->bus_type == FC) karg->adapterType = MPT_IOCTL_INTERFACE_FC; else karg->adapterType = MPT_IOCTL_INTERFACE_SCSI; if (karg->hdr.port > 1) { kfree(karg); return -EINVAL; } port = karg->hdr.port; karg->port = port; pdev = (struct pci_dev *) ioc->pcidev; karg->pciId = pdev->device; karg->hwRev = pdev->revision; karg->subSystemDevice = pdev->subsystem_device; karg->subSystemVendor = pdev->subsystem_vendor; if (cim_rev == 1) { /* Get the PCI bus, device, and function numbers for the IOC */ karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); } else if (cim_rev == 2) { /* Get the PCI bus, device, function and segment ID numbers for the IOC */ karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); karg->pciInfo.segmentID = pci_domain_nr(pdev->bus); } /* Get number of devices */ karg->numDevices = 0; if (ioc->sh) { shost_for_each_device(sdev, ioc->sh) { vdevice = sdev->hostdata; if (vdevice == NULL || vdevice->vtarget == NULL) continue; if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) continue; karg->numDevices++; } } /* Set the BIOS and FW Version */ karg->FWVersion = ioc->facts.FWVersion.Word; karg->BIOSVersion = ioc->biosVersion; /* Set the Version Strings. */ strncpy (karg->driverVersion, MPT_LINUX_PACKAGE_NAME, MPT_IOCTL_VERSION_LENGTH); karg->driverVersion[MPT_IOCTL_VERSION_LENGTH-1]='\0'; karg->busChangeEvent = 0; karg->hostId = ioc->pfacts[port].PortSCSIID; karg->rsvd[0] = karg->rsvd[1] = 0; /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, karg, data_size)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); kfree(karg); return -EFAULT; } kfree(karg); return 0; }
mptctl_getiocinfo (MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) { struct mpt_ioctl_iocinfo __user *uarg = (void __user *) arg; struct mpt_ioctl_iocinfo *karg; struct pci_dev *pdev; unsigned int port; int cim_rev; struct scsi_device *sdev; VirtDevice *vdevice; if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev0)) cim_rev = 0; else if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev1)) cim_rev = 1; else if (data_size == sizeof(struct mpt_ioctl_iocinfo)) cim_rev = 2; else if (data_size == (sizeof(struct mpt_ioctl_iocinfo_rev0)+12)) cim_rev = 0; else return -EFAULT; karg = memdup_user(uarg, data_size); if (IS_ERR(karg)) { printk(KERN_ERR MYNAM "%s@%d::mpt_ioctl_iocinfo() - memdup_user returned error [%ld]\n", __FILE__, __LINE__, PTR_ERR(karg)); return PTR_ERR(karg); } if (karg->hdr.maxDataSize != data_size) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Structure size mismatch. Command not completed.\n", ioc->name, __FILE__, __LINE__); kfree(karg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_getiocinfo called.\n", ioc->name)); if (ioc->bus_type == SAS) karg->adapterType = MPT_IOCTL_INTERFACE_SAS; else if (ioc->bus_type == FC) karg->adapterType = MPT_IOCTL_INTERFACE_FC; else karg->adapterType = MPT_IOCTL_INTERFACE_SCSI; if (karg->hdr.port > 1) { kfree(karg); return -EINVAL; } port = karg->hdr.port; karg->port = port; pdev = (struct pci_dev *) ioc->pcidev; karg->pciId = pdev->device; karg->hwRev = pdev->revision; karg->subSystemDevice = pdev->subsystem_device; karg->subSystemVendor = pdev->subsystem_vendor; if (cim_rev == 1) { karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); } else if (cim_rev == 2) { karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); karg->pciInfo.segmentID = pci_domain_nr(pdev->bus); } karg->numDevices = 0; if (ioc->sh) { shost_for_each_device(sdev, ioc->sh) { vdevice = sdev->hostdata; if (vdevice == NULL || vdevice->vtarget == NULL) continue; if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) continue; karg->numDevices++; } } karg->FWVersion = ioc->facts.FWVersion.Word; karg->BIOSVersion = ioc->biosVersion; strncpy (karg->driverVersion, MPT_LINUX_PACKAGE_NAME, MPT_IOCTL_VERSION_LENGTH); karg->driverVersion[MPT_IOCTL_VERSION_LENGTH-1]='\0'; karg->busChangeEvent = 0; karg->hostId = ioc->pfacts[port].PortSCSIID; karg->rsvd[0] = karg->rsvd[1] = 0; if (copy_to_user((char __user *)arg, karg, data_size)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); kfree(karg); return -EFAULT; } kfree(karg); return 0; }
332
1
static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) { u64 slice = __sched_period(cfs_rq->nr_running); slice *= se->load.weight; do_div(slice, cfs_rq->load.weight); return slice; }
static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) { u64 slice = __sched_period(cfs_rq->nr_running); slice *= se->load.weight; do_div(slice, cfs_rq->load.weight); return slice; }
333
0
int qcrypto_init(Error **errp) { int ret; ret = gnutls_global_init(); if (ret < 0) { error_setg(errp, "Unable to initialize GNUTLS library: %s", gnutls_strerror(ret)); return -1; } #ifdef DEBUG_GNUTLS gnutls_global_set_log_level(10); gnutls_global_set_log_function(qcrypto_gnutls_log); #endif #ifdef CONFIG_GNUTLS_GCRYPT if (!gcry_check_version(GCRYPT_VERSION)) { error_setg(errp, "Unable to initialize gcrypt"); return -1; } #ifdef QCRYPTO_INIT_GCRYPT_THREADS gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl); #endif /* QCRYPTO_INIT_GCRYPT_THREADS */ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif return 0; }
int qcrypto_init(Error **errp) { int ret; ret = gnutls_global_init(); if (ret < 0) { error_setg(errp, "Unable to initialize GNUTLS library: %s", gnutls_strerror(ret)); return -1; } #ifdef DEBUG_GNUTLS gnutls_global_set_log_level(10); gnutls_global_set_log_function(qcrypto_gnutls_log); #endif #ifdef CONFIG_GNUTLS_GCRYPT if (!gcry_check_version(GCRYPT_VERSION)) { error_setg(errp, "Unable to initialize gcrypt"); return -1; } #ifdef QCRYPTO_INIT_GCRYPT_THREADS gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl); #endif gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif return 0; }
334
1
spnego_gss_delete_sec_context( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t output_token) { OM_uint32 ret = GSS_S_COMPLETE; spnego_gss_ctx_id_t *ctx = (spnego_gss_ctx_id_t *)context_handle; *minor_status = 0; if (context_handle == NULL) return (GSS_S_FAILURE); if (*ctx == NULL) return (GSS_S_COMPLETE); /* * If this is still an SPNEGO mech, release it locally. */ if ((*ctx)->magic_num == SPNEGO_MAGIC_ID) { (void) gss_delete_sec_context(minor_status, &(*ctx)->ctx_handle, output_token); (void) release_spnego_ctx(ctx); } else { ret = gss_delete_sec_context(minor_status, context_handle, output_token); } return (ret); }
spnego_gss_delete_sec_context( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t output_token) { OM_uint32 ret = GSS_S_COMPLETE; spnego_gss_ctx_id_t *ctx = (spnego_gss_ctx_id_t *)context_handle; *minor_status = 0; if (context_handle == NULL) return (GSS_S_FAILURE); if (*ctx == NULL) return (GSS_S_COMPLETE); if ((*ctx)->magic_num == SPNEGO_MAGIC_ID) { (void) gss_delete_sec_context(minor_status, &(*ctx)->ctx_handle, output_token); (void) release_spnego_ctx(ctx); } else { ret = gss_delete_sec_context(minor_status, context_handle, output_token); } return (ret); }
336
1
mptctl_getiocinfo (unsigned long arg, unsigned int data_size) { struct mpt_ioctl_iocinfo __user *uarg = (void __user *) arg; struct mpt_ioctl_iocinfo *karg; MPT_ADAPTER *ioc; struct pci_dev *pdev; int iocnum; unsigned int port; int cim_rev; struct scsi_device *sdev; VirtDevice *vdevice; /* Add of PCI INFO results in unaligned access for * IA64 and Sparc. Reset long to int. Return no PCI * data for obsolete format. */ if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev0)) cim_rev = 0; else if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev1)) cim_rev = 1; else if (data_size == sizeof(struct mpt_ioctl_iocinfo)) cim_rev = 2; else if (data_size == (sizeof(struct mpt_ioctl_iocinfo_rev0)+12)) cim_rev = 0; /* obsolete */ else return -EFAULT; karg = memdup_user(uarg, data_size); if (IS_ERR(karg)) { printk(KERN_ERR MYNAM "%s@%d::mpt_ioctl_iocinfo() - memdup_user returned error [%ld]\n", __FILE__, __LINE__, PTR_ERR(karg)); return PTR_ERR(karg); } if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); kfree(karg); return -ENODEV; } /* Verify the data transfer size is correct. */ if (karg->hdr.maxDataSize != data_size) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Structure size mismatch. Command not completed.\n", ioc->name, __FILE__, __LINE__); kfree(karg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_getiocinfo called.\n", ioc->name)); /* Fill in the data and return the structure to the calling * program */ if (ioc->bus_type == SAS) karg->adapterType = MPT_IOCTL_INTERFACE_SAS; else if (ioc->bus_type == FC) karg->adapterType = MPT_IOCTL_INTERFACE_FC; else karg->adapterType = MPT_IOCTL_INTERFACE_SCSI; if (karg->hdr.port > 1) { kfree(karg); return -EINVAL; } port = karg->hdr.port; karg->port = port; pdev = (struct pci_dev *) ioc->pcidev; karg->pciId = pdev->device; karg->hwRev = pdev->revision; karg->subSystemDevice = pdev->subsystem_device; karg->subSystemVendor = pdev->subsystem_vendor; if (cim_rev == 1) { /* Get the PCI bus, device, and function numbers for the IOC */ karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); } else if (cim_rev == 2) { /* Get the PCI bus, device, function and segment ID numbers for the IOC */ karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); karg->pciInfo.segmentID = pci_domain_nr(pdev->bus); } /* Get number of devices */ karg->numDevices = 0; if (ioc->sh) { shost_for_each_device(sdev, ioc->sh) { vdevice = sdev->hostdata; if (vdevice == NULL || vdevice->vtarget == NULL) continue; if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) continue; karg->numDevices++; } } /* Set the BIOS and FW Version */ karg->FWVersion = ioc->facts.FWVersion.Word; karg->BIOSVersion = ioc->biosVersion; /* Set the Version Strings. */ strncpy (karg->driverVersion, MPT_LINUX_PACKAGE_NAME, MPT_IOCTL_VERSION_LENGTH); karg->driverVersion[MPT_IOCTL_VERSION_LENGTH-1]='\0'; karg->busChangeEvent = 0; karg->hostId = ioc->pfacts[port].PortSCSIID; karg->rsvd[0] = karg->rsvd[1] = 0; /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, karg, data_size)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); kfree(karg); return -EFAULT; } kfree(karg); return 0; }
mptctl_getiocinfo (unsigned long arg, unsigned int data_size) { struct mpt_ioctl_iocinfo __user *uarg = (void __user *) arg; struct mpt_ioctl_iocinfo *karg; MPT_ADAPTER *ioc; struct pci_dev *pdev; int iocnum; unsigned int port; int cim_rev; struct scsi_device *sdev; VirtDevice *vdevice; if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev0)) cim_rev = 0; else if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev1)) cim_rev = 1; else if (data_size == sizeof(struct mpt_ioctl_iocinfo)) cim_rev = 2; else if (data_size == (sizeof(struct mpt_ioctl_iocinfo_rev0)+12)) cim_rev = 0; else return -EFAULT; karg = memdup_user(uarg, data_size); if (IS_ERR(karg)) { printk(KERN_ERR MYNAM "%s@%d::mpt_ioctl_iocinfo() - memdup_user returned error [%ld]\n", __FILE__, __LINE__, PTR_ERR(karg)); return PTR_ERR(karg); } if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); kfree(karg); return -ENODEV; } if (karg->hdr.maxDataSize != data_size) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Structure size mismatch. Command not completed.\n", ioc->name, __FILE__, __LINE__); kfree(karg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_getiocinfo called.\n", ioc->name)); if (ioc->bus_type == SAS) karg->adapterType = MPT_IOCTL_INTERFACE_SAS; else if (ioc->bus_type == FC) karg->adapterType = MPT_IOCTL_INTERFACE_FC; else karg->adapterType = MPT_IOCTL_INTERFACE_SCSI; if (karg->hdr.port > 1) { kfree(karg); return -EINVAL; } port = karg->hdr.port; karg->port = port; pdev = (struct pci_dev *) ioc->pcidev; karg->pciId = pdev->device; karg->hwRev = pdev->revision; karg->subSystemDevice = pdev->subsystem_device; karg->subSystemVendor = pdev->subsystem_vendor; if (cim_rev == 1) { karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); } else if (cim_rev == 2) { karg->pciInfo.u.bits.busNumber = pdev->bus->number; karg->pciInfo.u.bits.deviceNumber = PCI_SLOT( pdev->devfn ); karg->pciInfo.u.bits.functionNumber = PCI_FUNC( pdev->devfn ); karg->pciInfo.segmentID = pci_domain_nr(pdev->bus); } karg->numDevices = 0; if (ioc->sh) { shost_for_each_device(sdev, ioc->sh) { vdevice = sdev->hostdata; if (vdevice == NULL || vdevice->vtarget == NULL) continue; if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) continue; karg->numDevices++; } } karg->FWVersion = ioc->facts.FWVersion.Word; karg->BIOSVersion = ioc->biosVersion; strncpy (karg->driverVersion, MPT_LINUX_PACKAGE_NAME, MPT_IOCTL_VERSION_LENGTH); karg->driverVersion[MPT_IOCTL_VERSION_LENGTH-1]='\0'; karg->busChangeEvent = 0; karg->hostId = ioc->pfacts[port].PortSCSIID; karg->rsvd[0] = karg->rsvd[1] = 0; if (copy_to_user((char __user *)arg, karg, data_size)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); kfree(karg); return -EFAULT; } kfree(karg); return 0; }
339
0
static void vring_desc_read(VirtIODevice *vdev, VRingDesc *desc, hwaddr desc_pa, int i) { address_space_read(&address_space_memory, desc_pa + i * sizeof(VRingDesc), MEMTXATTRS_UNSPECIFIED, (void *)desc, sizeof(VRingDesc)); virtio_tswap64s(vdev, &desc->addr); virtio_tswap32s(vdev, &desc->len); virtio_tswap16s(vdev, &desc->flags); virtio_tswap16s(vdev, &desc->next); }
static void vring_desc_read(VirtIODevice *vdev, VRingDesc *desc, hwaddr desc_pa, int i) { address_space_read(&address_space_memory, desc_pa + i * sizeof(VRingDesc), MEMTXATTRS_UNSPECIFIED, (void *)desc, sizeof(VRingDesc)); virtio_tswap64s(vdev, &desc->addr); virtio_tswap32s(vdev, &desc->len); virtio_tswap16s(vdev, &desc->flags); virtio_tswap16s(vdev, &desc->next); }
340
1
spnego_gss_export_sec_context( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t interprocess_token) { OM_uint32 ret; ret = gss_export_sec_context(minor_status, context_handle, interprocess_token); return (ret); }
spnego_gss_export_sec_context( OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t interprocess_token) { OM_uint32 ret; ret = gss_export_sec_context(minor_status, context_handle, interprocess_token); return (ret); }
342
0
mptctl_gettargetinfo (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg; struct mpt_ioctl_targetinfo karg; VirtDevice *vdevice; char *pmem; int *pdata; int numDevices = 0; int lun; int maxWordsLeft; int numBytes; u8 port; struct scsi_device *sdev; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_gettargetinfo - " "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_gettargetinfo called.\n", ioc->name)); /* Get the port number and set the maximum number of bytes * in the returned structure. * Ignore the port setting. */ numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); maxWordsLeft = numBytes/sizeof(int); port = karg.hdr.port; if (maxWordsLeft <= 0) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", ioc->name, __FILE__, __LINE__); return -ENOMEM; } /* Fill in the data and return the structure to the calling * program */ /* struct mpt_ioctl_targetinfo does not contain sufficient space * for the target structures so when the IOCTL is called, there is * not sufficient stack space for the structure. Allocate memory, * populate the memory, copy back to the user, then free memory. * targetInfo format: * bits 31-24: reserved * 23-16: LUN * 15- 8: Bus Number * 7- 0: Target ID */ pmem = kzalloc(numBytes, GFP_KERNEL); if (!pmem) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", ioc->name, __FILE__, __LINE__); return -ENOMEM; } pdata = (int *) pmem; /* Get number of devices */ if (ioc->sh){ shost_for_each_device(sdev, ioc->sh) { if (!maxWordsLeft) continue; vdevice = sdev->hostdata; if (vdevice == NULL || vdevice->vtarget == NULL) continue; if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) continue; lun = (vdevice->vtarget->raidVolume) ? 0x80 : vdevice->lun; *pdata = (((u8)lun << 16) + (vdevice->vtarget->channel << 8) + (vdevice->vtarget->id )); pdata++; numDevices++; --maxWordsLeft; } } karg.numDevices = numDevices; /* Copy part of the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_targetinfo))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); kfree(pmem); return -EFAULT; } /* Copy the remaining data from kernel memory to user memory */ if (copy_to_user(uarg->targetInfo, pmem, numBytes)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, pdata); kfree(pmem); return -EFAULT; } kfree(pmem); return 0; }
mptctl_gettargetinfo (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg; struct mpt_ioctl_targetinfo karg; VirtDevice *vdevice; char *pmem; int *pdata; int numDevices = 0; int lun; int maxWordsLeft; int numBytes; u8 port; struct scsi_device *sdev; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_gettargetinfo - " "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_gettargetinfo called.\n", ioc->name)); numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); maxWordsLeft = numBytes/sizeof(int); port = karg.hdr.port; if (maxWordsLeft <= 0) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", ioc->name, __FILE__, __LINE__); return -ENOMEM; } pmem = kzalloc(numBytes, GFP_KERNEL); if (!pmem) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", ioc->name, __FILE__, __LINE__); return -ENOMEM; } pdata = (int *) pmem; if (ioc->sh){ shost_for_each_device(sdev, ioc->sh) { if (!maxWordsLeft) continue; vdevice = sdev->hostdata; if (vdevice == NULL || vdevice->vtarget == NULL) continue; if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) continue; lun = (vdevice->vtarget->raidVolume) ? 0x80 : vdevice->lun; *pdata = (((u8)lun << 16) + (vdevice->vtarget->channel << 8) + (vdevice->vtarget->id )); pdata++; numDevices++; --maxWordsLeft; } } karg.numDevices = numDevices; if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_targetinfo))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); kfree(pmem); return -EFAULT; } if (copy_to_user(uarg->targetInfo, pmem, numBytes)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, pdata); kfree(pmem); return -EFAULT; } kfree(pmem); return 0; }
343
1
static u64 __sched_vslice(unsigned long rq_weight, unsigned long nr_running) { u64 vslice = __sched_period(nr_running); vslice *= NICE_0_LOAD; do_div(vslice, rq_weight); return vslice; }
static u64 __sched_vslice(unsigned long rq_weight, unsigned long nr_running) { u64 vslice = __sched_period(nr_running); vslice *= NICE_0_LOAD; do_div(vslice, rq_weight); return vslice; }
344
1
static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) { return calc_delta_mine(__sched_period(cfs_rq->nr_running), se->load.weight, &cfs_rq->load); }
static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) { return calc_delta_mine(__sched_period(cfs_rq->nr_running), se->load.weight, &cfs_rq->load); }
345
0
EVP_PKEY * d2i_PrivateKey_fp ( FILE * fp , EVP_PKEY * * a ) { return ASN1_d2i_fp_of ( EVP_PKEY , EVP_PKEY_new , d2i_AutoPrivateKey , fp , a ) ; }
EVP_PKEY * d2i_PrivateKey_fp ( FILE * fp , EVP_PKEY * * a ) { return ASN1_d2i_fp_of ( EVP_PKEY , EVP_PKEY_new , d2i_AutoPrivateKey , fp , a ) ; }
347
0
static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { IntelIOMMUState *s = opaque; VTDAddressSpace **pvtd_as; int bus_num = pci_bus_num(bus); assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX); assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX); pvtd_as = s->address_spaces[bus_num]; if (!pvtd_as) { /* No corresponding free() */ pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); s->address_spaces[bus_num] = pvtd_as; } if (!pvtd_as[devfn]) { pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace)); pvtd_as[devfn]->bus_num = (uint8_t)bus_num; pvtd_as[devfn]->devfn = (uint8_t)devfn; pvtd_as[devfn]->iommu_state = s; pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0; memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s), &s->iommu_ops, "intel_iommu", UINT64_MAX); address_space_init(&pvtd_as[devfn]->as, &pvtd_as[devfn]->iommu, "intel_iommu"); } return &pvtd_as[devfn]->as; }
static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { IntelIOMMUState *s = opaque; VTDAddressSpace **pvtd_as; int bus_num = pci_bus_num(bus); assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX); assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX); pvtd_as = s->address_spaces[bus_num]; if (!pvtd_as) { pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX); s->address_spaces[bus_num] = pvtd_as; } if (!pvtd_as[devfn]) { pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace)); pvtd_as[devfn]->bus_num = (uint8_t)bus_num; pvtd_as[devfn]->devfn = (uint8_t)devfn; pvtd_as[devfn]->iommu_state = s; pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0; memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s), &s->iommu_ops, "intel_iommu", UINT64_MAX); address_space_init(&pvtd_as[devfn]->as, &pvtd_as[devfn]->iommu, "intel_iommu"); } return &pvtd_as[devfn]->as; }
348
1
static u64 sched_vslice_add(struct cfs_rq *cfs_rq, struct sched_entity *se) { unsigned long nr_running = cfs_rq->nr_running; unsigned long weight; u64 vslice; if (!se->on_rq) nr_running++; vslice = __sched_period(nr_running); for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); weight = cfs_rq->load.weight; if (!se->on_rq) weight += se->load.weight; vslice *= NICE_0_LOAD; do_div(vslice, weight); } return vslice; }
static u64 sched_vslice_add(struct cfs_rq *cfs_rq, struct sched_entity *se) { unsigned long nr_running = cfs_rq->nr_running; unsigned long weight; u64 vslice; if (!se->on_rq) nr_running++; vslice = __sched_period(nr_running); for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); weight = cfs_rq->load.weight; if (!se->on_rq) weight += se->load.weight; vslice *= NICE_0_LOAD; do_div(vslice, weight); } return vslice; }
351
1
spnego_gss_get_mic( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, gss_qop_t qop_req, const gss_buffer_t message_buffer, gss_buffer_t message_token) { OM_uint32 ret; ret = gss_get_mic(minor_status, context_handle, qop_req, message_buffer, message_token); return (ret); }
spnego_gss_get_mic( OM_uint32 *minor_status, const gss_ctx_id_t context_handle, gss_qop_t qop_req, const gss_buffer_t message_buffer, gss_buffer_t message_token) { OM_uint32 ret; ret = gss_get_mic(minor_status, context_handle, qop_req, message_buffer, message_token); return (ret); }
352
0
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, int64_t offset) { uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; extent_begin_offset = (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; extent_relative_offset = offset - extent_begin_offset; offset_in_cluster = extent_relative_offset % cluster_size; return offset_in_cluster; }
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, int64_t offset) { uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; extent_begin_offset = (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; extent_relative_offset = offset - extent_begin_offset; offset_in_cluster = extent_relative_offset % cluster_size; return offset_in_cluster; }
353
1
mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) { hp_host_info_t __user *uarg = (void __user *) arg; MPT_ADAPTER *ioc; struct pci_dev *pdev; char *pbuf=NULL; dma_addr_t buf_dma; hp_host_info_t karg; CONFIGPARMS cfg; ConfigPageHeader_t hdr; int iocnum; int rc, cim_rev; ToolboxIstwiReadWriteRequest_t *IstwiRWRequest; MPT_FRAME_HDR *mf = NULL; unsigned long timeleft; int retval; u32 msgcontext; /* Reset long to int. Should affect IA64 and SPARC only */ if (data_size == sizeof(hp_host_info_t)) cim_rev = 1; else if (data_size == sizeof(hp_host_info_rev0_t)) cim_rev = 0; /* obsolete */ else return -EFAULT; if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_host_info - " "Unable to read in hp_host_info struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": mptctl_hp_hostinfo called.\n", ioc->name)); /* Fill in the data and return the structure to the calling * program */ pdev = (struct pci_dev *) ioc->pcidev; karg.vendor = pdev->vendor; karg.device = pdev->device; karg.subsystem_id = pdev->subsystem_device; karg.subsystem_vendor = pdev->subsystem_vendor; karg.devfn = pdev->devfn; karg.bus = pdev->bus->number; /* Save the SCSI host no. if * SCSI driver loaded */ if (ioc->sh != NULL) karg.host_no = ioc->sh->host_no; else karg.host_no = -1; /* Reformat the fw_version into a string */ snprintf(karg.fw_version, sizeof(karg.fw_version), "%.2hhu.%.2hhu.%.2hhu.%.2hhu", ioc->facts.FWVersion.Struct.Major, ioc->facts.FWVersion.Struct.Minor, ioc->facts.FWVersion.Struct.Unit, ioc->facts.FWVersion.Struct.Dev); /* Issue a config request to get the device serial number */ hdr.PageVersion = 0; hdr.PageLength = 0; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING; cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; /* read */ cfg.timeout = 10; strncpy(karg.serial_number, " ", 24); if (mpt_config(ioc, &cfg) == 0) { if (cfg.cfghdr.hdr->PageLength > 0) { /* Issue the second config page request */ cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma); if (pbuf) { cfg.physAddr = buf_dma; if (mpt_config(ioc, &cfg) == 0) { ManufacturingPage0_t *pdata = (ManufacturingPage0_t *) pbuf; if (strlen(pdata->BoardTracerNumber) > 1) { strlcpy(karg.serial_number, pdata->BoardTracerNumber, 24); } } pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, pbuf, buf_dma); pbuf = NULL; } } } rc = mpt_GetIocState(ioc, 1); switch (rc) { case MPI_IOC_STATE_OPERATIONAL: karg.ioc_status = HP_STATUS_OK; break; case MPI_IOC_STATE_FAULT: karg.ioc_status = HP_STATUS_FAILED; break; case MPI_IOC_STATE_RESET: case MPI_IOC_STATE_READY: default: karg.ioc_status = HP_STATUS_OTHER; break; } karg.base_io_addr = pci_resource_start(pdev, 0); if ((ioc->bus_type == SAS) || (ioc->bus_type == FC)) karg.bus_phys_width = HP_BUS_WIDTH_UNK; else karg.bus_phys_width = HP_BUS_WIDTH_16; karg.hard_resets = 0; karg.soft_resets = 0; karg.timeouts = 0; if (ioc->sh != NULL) { MPT_SCSI_HOST *hd = shost_priv(ioc->sh); if (hd && (cim_rev == 1)) { karg.hard_resets = ioc->hard_resets; karg.soft_resets = ioc->soft_resets; karg.timeouts = ioc->timeouts; } } /* * Gather ISTWI(Industry Standard Two Wire Interface) Data */ if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) { dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n", ioc->name, __func__)); goto out; } IstwiRWRequest = (ToolboxIstwiReadWriteRequest_t *)mf; msgcontext = IstwiRWRequest->MsgContext; memset(IstwiRWRequest,0,sizeof(ToolboxIstwiReadWriteRequest_t)); IstwiRWRequest->MsgContext = msgcontext; IstwiRWRequest->Function = MPI_FUNCTION_TOOLBOX; IstwiRWRequest->Tool = MPI_TOOLBOX_ISTWI_READ_WRITE_TOOL; IstwiRWRequest->Flags = MPI_TB_ISTWI_FLAGS_READ; IstwiRWRequest->NumAddressBytes = 0x01; IstwiRWRequest->DataLength = cpu_to_le16(0x04); if (pdev->devfn & 1) IstwiRWRequest->DeviceAddr = 0xB2; else IstwiRWRequest->DeviceAddr = 0xB0; pbuf = pci_alloc_consistent(ioc->pcidev, 4, &buf_dma); if (!pbuf) goto out; ioc->add_sge((char *)&IstwiRWRequest->SGL, (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma); retval = 0; SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, IstwiRWRequest->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) mpt_put_msg_frame(mptctl_id, ioc, mf); retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*MPT_IOCTL_DEFAULT_TIMEOUT); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { retval = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(ioc, mf); goto out; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "HOST INFO command timeout, doorbell=0x%08x\n", ioc->name, mpt_GetIocState(ioc, 0)); mptctl_timeout_expired(ioc, mf); } else goto retry_wait; goto out; } /* *ISTWI Data Definition * pbuf[0] = FW_VERSION = 0x4 * pbuf[1] = Bay Count = 6 or 4 or 2, depending on * the config, you should be seeing one out of these three values * pbuf[2] = Drive Installed Map = bit pattern depend on which * bays have drives in them * pbuf[3] = Checksum (0x100 = (byte0 + byte2 + byte3) */ if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) karg.rsvd = *(u32 *)pbuf; out: CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); if (pbuf) pci_free_consistent(ioc->pcidev, 4, pbuf, buf_dma); /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hpgethostinfo - " "Unable to write out hp_host_info @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) { hp_host_info_t __user *uarg = (void __user *) arg; MPT_ADAPTER *ioc; struct pci_dev *pdev; char *pbuf=NULL; dma_addr_t buf_dma; hp_host_info_t karg; CONFIGPARMS cfg; ConfigPageHeader_t hdr; int iocnum; int rc, cim_rev; ToolboxIstwiReadWriteRequest_t *IstwiRWRequest; MPT_FRAME_HDR *mf = NULL; unsigned long timeleft; int retval; u32 msgcontext; if (data_size == sizeof(hp_host_info_t)) cim_rev = 1; else if (data_size == sizeof(hp_host_info_rev0_t)) cim_rev = 0; else return -EFAULT; if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_host_info - " "Unable to read in hp_host_info struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": mptctl_hp_hostinfo called.\n", ioc->name)); pdev = (struct pci_dev *) ioc->pcidev; karg.vendor = pdev->vendor; karg.device = pdev->device; karg.subsystem_id = pdev->subsystem_device; karg.subsystem_vendor = pdev->subsystem_vendor; karg.devfn = pdev->devfn; karg.bus = pdev->bus->number; if (ioc->sh != NULL) karg.host_no = ioc->sh->host_no; else karg.host_no = -1; snprintf(karg.fw_version, sizeof(karg.fw_version), "%.2hhu.%.2hhu.%.2hhu.%.2hhu", ioc->facts.FWVersion.Struct.Major, ioc->facts.FWVersion.Struct.Minor, ioc->facts.FWVersion.Struct.Unit, ioc->facts.FWVersion.Struct.Dev); hdr.PageVersion = 0; hdr.PageLength = 0; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING; cfg.cfghdr.hdr = &hdr; cfg.physAddr = -1; cfg.pageAddr = 0; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; cfg.timeout = 10; strncpy(karg.serial_number, " ", 24); if (mpt_config(ioc, &cfg) == 0) { if (cfg.cfghdr.hdr->PageLength > 0) { cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma); if (pbuf) { cfg.physAddr = buf_dma; if (mpt_config(ioc, &cfg) == 0) { ManufacturingPage0_t *pdata = (ManufacturingPage0_t *) pbuf; if (strlen(pdata->BoardTracerNumber) > 1) { strlcpy(karg.serial_number, pdata->BoardTracerNumber, 24); } } pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, pbuf, buf_dma); pbuf = NULL; } } } rc = mpt_GetIocState(ioc, 1); switch (rc) { case MPI_IOC_STATE_OPERATIONAL: karg.ioc_status = HP_STATUS_OK; break; case MPI_IOC_STATE_FAULT: karg.ioc_status = HP_STATUS_FAILED; break; case MPI_IOC_STATE_RESET: case MPI_IOC_STATE_READY: default: karg.ioc_status = HP_STATUS_OTHER; break; } karg.base_io_addr = pci_resource_start(pdev, 0); if ((ioc->bus_type == SAS) || (ioc->bus_type == FC)) karg.bus_phys_width = HP_BUS_WIDTH_UNK; else karg.bus_phys_width = HP_BUS_WIDTH_16; karg.hard_resets = 0; karg.soft_resets = 0; karg.timeouts = 0; if (ioc->sh != NULL) { MPT_SCSI_HOST *hd = shost_priv(ioc->sh); if (hd && (cim_rev == 1)) { karg.hard_resets = ioc->hard_resets; karg.soft_resets = ioc->soft_resets; karg.timeouts = ioc->timeouts; } } if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) { dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n", ioc->name, __func__)); goto out; } IstwiRWRequest = (ToolboxIstwiReadWriteRequest_t *)mf; msgcontext = IstwiRWRequest->MsgContext; memset(IstwiRWRequest,0,sizeof(ToolboxIstwiReadWriteRequest_t)); IstwiRWRequest->MsgContext = msgcontext; IstwiRWRequest->Function = MPI_FUNCTION_TOOLBOX; IstwiRWRequest->Tool = MPI_TOOLBOX_ISTWI_READ_WRITE_TOOL; IstwiRWRequest->Flags = MPI_TB_ISTWI_FLAGS_READ; IstwiRWRequest->NumAddressBytes = 0x01; IstwiRWRequest->DataLength = cpu_to_le16(0x04); if (pdev->devfn & 1) IstwiRWRequest->DeviceAddr = 0xB2; else IstwiRWRequest->DeviceAddr = 0xB0; pbuf = pci_alloc_consistent(ioc->pcidev, 4, &buf_dma); if (!pbuf) goto out; ioc->add_sge((char *)&IstwiRWRequest->SGL, (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma); retval = 0; SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, IstwiRWRequest->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) mpt_put_msg_frame(mptctl_id, ioc, mf); retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*MPT_IOCTL_DEFAULT_TIMEOUT); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { retval = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(ioc, mf); goto out; } if (!timeleft) { printk(MYIOC_s_WARN_FMT "HOST INFO command timeout, doorbell=0x%08x\n", ioc->name, mpt_GetIocState(ioc, 0)); mptctl_timeout_expired(ioc, mf); } else goto retry_wait; goto out; } if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) karg.rsvd = *(u32 *)pbuf; out: CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); if (pbuf) pci_free_consistent(ioc->pcidev, 4, pbuf, buf_dma); if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hpgethostinfo - " "Unable to write out hp_host_info @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
354
0
static int test_streaming ( xd3_stream * in_stream , uint8_t * encbuf , uint8_t * decbuf , uint8_t * delbuf , usize_t megs ) { xd3_stream estream , dstream ; int ret ; usize_t i , delsize , decsize ; xd3_config cfg ; xd3_init_config ( & cfg , in_stream -> flags ) ; cfg . flags |= XD3_COMPLEVEL_6 ; if ( ( ret = xd3_config_stream ( & estream , & cfg ) ) || ( ret = xd3_config_stream ( & dstream , & cfg ) ) ) { goto fail ; } for ( i = 0 ; i < megs ; i += 1 ) { ( ( usize_t * ) encbuf ) [ 0 ] = i ; if ( ( i % 200 ) == 199 ) { DOT ( ) ; } if ( ( ret = xd3_process_stream ( 1 , & estream , xd3_encode_input , 0 , encbuf , 1 << 20 , delbuf , & delsize , 1 << 20 ) ) ) { in_stream -> msg = estream . msg ; goto fail ; } if ( ( ret = xd3_process_stream ( 0 , & dstream , xd3_decode_input , 0 , delbuf , delsize , decbuf , & decsize , 1 << 20 ) ) ) { in_stream -> msg = dstream . msg ; goto fail ; } if ( decsize != 1 << 20 || memcmp ( encbuf , decbuf , 1 << 20 ) != 0 ) { in_stream -> msg = "wrong result" ; ret = XD3_INTERNAL ; goto fail ; } } if ( ( ret = xd3_close_stream ( & estream ) ) || ( ret = xd3_close_stream ( & dstream ) ) ) { goto fail ; } fail : xd3_free_stream ( & estream ) ; xd3_free_stream ( & dstream ) ; return ret ; }
static int test_streaming ( xd3_stream * in_stream , uint8_t * encbuf , uint8_t * decbuf , uint8_t * delbuf , usize_t megs ) { xd3_stream estream , dstream ; int ret ; usize_t i , delsize , decsize ; xd3_config cfg ; xd3_init_config ( & cfg , in_stream -> flags ) ; cfg . flags |= XD3_COMPLEVEL_6 ; if ( ( ret = xd3_config_stream ( & estream , & cfg ) ) || ( ret = xd3_config_stream ( & dstream , & cfg ) ) ) { goto fail ; } for ( i = 0 ; i < megs ; i += 1 ) { ( ( usize_t * ) encbuf ) [ 0 ] = i ; if ( ( i % 200 ) == 199 ) { DOT ( ) ; } if ( ( ret = xd3_process_stream ( 1 , & estream , xd3_encode_input , 0 , encbuf , 1 << 20 , delbuf , & delsize , 1 << 20 ) ) ) { in_stream -> msg = estream . msg ; goto fail ; } if ( ( ret = xd3_process_stream ( 0 , & dstream , xd3_decode_input , 0 , delbuf , delsize , decbuf , & decsize , 1 << 20 ) ) ) { in_stream -> msg = dstream . msg ; goto fail ; } if ( decsize != 1 << 20 || memcmp ( encbuf , decbuf , 1 << 20 ) != 0 ) { in_stream -> msg = "wrong result" ; ret = XD3_INTERNAL ; goto fail ; } } if ( ( ret = xd3_close_stream ( & estream ) ) || ( ret = xd3_close_stream ( & dstream ) ) ) { goto fail ; } fail : xd3_free_stream ( & estream ) ; xd3_free_stream ( & dstream ) ; return ret ; }
355
0
static unsigned int dec_move_pr(DisasContext *dc) { TCGv t0; DIS(fprintf (logfile, "move $p%u, $r%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, 0); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op1], cpu_R[dc->op1], t0, preg_sizes[dc->op2]); tcg_temp_free(t0); return 2; }
static unsigned int dec_move_pr(DisasContext *dc) { TCGv t0; DIS(fprintf (logfile, "move $p%u, $r%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, 0); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op1], cpu_R[dc->op1], t0, preg_sizes[dc->op2]); tcg_temp_free(t0); return 2; }
356
1
static unsigned long wakeup_gran(struct sched_entity *se) { unsigned long gran = sysctl_sched_wakeup_granularity; /* * More easily preempt - nice tasks, while not making * it harder for + nice tasks. */ if (unlikely(se->load.weight > NICE_0_LOAD)) gran = calc_delta_fair(gran, &se->load); return gran; }
static unsigned long wakeup_gran(struct sched_entity *se) { unsigned long gran = sysctl_sched_wakeup_granularity; if (unlikely(se->load.weight > NICE_0_LOAD)) gran = calc_delta_fair(gran, &se->load); return gran; }
357
1
spnego_gss_get_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_qop_t qop_req, gss_iov_buffer_desc *iov, int iov_count) { return gss_get_mic_iov(minor_status, context_handle, qop_req, iov, iov_count); }
spnego_gss_get_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_qop_t qop_req, gss_iov_buffer_desc *iov, int iov_count) { return gss_get_mic_iov(minor_status, context_handle, qop_req, iov, iov_count); }
358
0
static void U_CALLCONV _LMBCSOpen ## n ( UConverter * _this , UConverterLoadArgs * pArgs , UErrorCode * err ) \ { _LMBCSOpenWorker ( _this , pArgs , err , n ) ; } static void _LMBCSOpenWorker ( UConverter * _this , UConverterLoadArgs * pArgs , UErrorCode * err , ulmbcs_byte_t OptGroup ) { UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) uprv_malloc ( sizeof ( UConverterDataLMBCS ) ) ; _this -> extraInfo = extraInfo ; if ( extraInfo != NULL ) { UConverterNamePieces stackPieces ; UConverterLoadArgs stackArgs = UCNV_LOAD_ARGS_INITIALIZER ; ulmbcs_byte_t i ; uprv_memset ( extraInfo , 0 , sizeof ( UConverterDataLMBCS ) ) ; stackArgs . onlyTestIsLoadable = pArgs -> onlyTestIsLoadable ; for ( i = 0 ; i <= ULMBCS_GRP_LAST && U_SUCCESS ( * err ) ; i ++ ) { if ( OptGroupByteToCPName [ i ] != NULL ) { extraInfo -> OptGrpConverter [ i ] = ucnv_loadSharedData ( OptGroupByteToCPName [ i ] , & stackPieces , & stackArgs , err ) ; } } if ( U_FAILURE ( * err ) || pArgs -> onlyTestIsLoadable ) { _LMBCSClose ( _this ) ; return ; } extraInfo -> OptGroup = OptGroup ; extraInfo -> localeConverterIndex = FindLMBCSLocale ( pArgs -> locale ) ; } else { * err = U_MEMORY_ALLOCATION_ERROR ; } } U_CDECL_BEGIN static void U_CALLCONV _LMBCSClose ( UConverter * _this ) { if ( _this -> extraInfo != NULL ) { ulmbcs_byte_t Ix ; UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) _this -> extraInfo ; for ( Ix = 0 ; Ix <= ULMBCS_GRP_LAST ; Ix ++ ) { if ( extraInfo -> OptGrpConverter [ Ix ] != NULL ) ucnv_unloadSharedDataIfReady ( extraInfo -> OptGrpConverter [ Ix ] ) ; } if ( ! _this -> isExtraLocal ) { uprv_free ( _this -> extraInfo ) ; _this -> extraInfo = NULL ; } } } typedef struct LMBCSClone { UConverter cnv ; UConverterDataLMBCS lmbcs ; } LMBCSClone ; static UConverter * U_CALLCONV _LMBCSSafeClone ( const UConverter * cnv , void * stackBuffer , int32_t * pBufferSize , UErrorCode * status ) { ( void ) status ; LMBCSClone * newLMBCS ; UConverterDataLMBCS * extraInfo ; int32_t i ; if ( * pBufferSize <= 0 ) { * pBufferSize = ( int32_t ) sizeof ( LMBCSClone ) ; return NULL ; } extraInfo = ( UConverterDataLMBCS * ) cnv -> extraInfo ; newLMBCS = ( LMBCSClone * ) stackBuffer ; uprv_memcpy ( & newLMBCS -> lmbcs , extraInfo , sizeof ( UConverterDataLMBCS ) ) ; for ( i = 0 ; i <= ULMBCS_GRP_LAST ; ++ i ) { if ( extraInfo -> OptGrpConverter [ i ] != NULL ) { ucnv_incrementRefCount ( extraInfo -> OptGrpConverter [ i ] ) ; } } newLMBCS -> cnv . extraInfo = & newLMBCS -> lmbcs ; newLMBCS -> cnv . isExtraLocal = TRUE ; return & newLMBCS -> cnv ; } static size_t LMBCSConversionWorker ( UConverterDataLMBCS * extraInfo , ulmbcs_byte_t group , ulmbcs_byte_t * pStartLMBCS , UChar * pUniChar , ulmbcs_byte_t * lastConverterIndex , UBool * groups_tried ) { ulmbcs_byte_t * pLMBCS = pStartLMBCS ; UConverterSharedData * xcnv = extraInfo -> OptGrpConverter [ group ] ; int bytesConverted ; uint32_t value ; ulmbcs_byte_t firstByte ; U_ASSERT ( xcnv ) ; U_ASSERT ( group < ULMBCS_GRP_UNICODE ) ; bytesConverted = ucnv_MBCSFromUChar32 ( xcnv , * pUniChar , & value , FALSE ) ; if ( bytesConverted > 0 ) { firstByte = ( ulmbcs_byte_t ) ( value >> ( ( bytesConverted - 1 ) * 8 ) ) ; } else { groups_tried [ group ] = TRUE ; return 0 ; } * lastConverterIndex = group ; U_ASSERT ( ( firstByte <= ULMBCS_C0END ) || ( firstByte >= ULMBCS_C1START ) || ( group == ULMBCS_GRP_EXCEPT ) ) ; if ( group != ULMBCS_GRP_EXCEPT && extraInfo -> OptGroup != group ) { * pLMBCS ++ = group ; if ( bytesConverted == 1 && group >= ULMBCS_DOUBLEOPTGROUP_START ) { * pLMBCS ++ = group ; } } if ( bytesConverted == 1 && firstByte < 0x20 ) return 0 ; switch ( bytesConverted ) { case 4 : * pLMBCS ++ = ( ulmbcs_byte_t ) ( value >> 24 ) ; U_FALLTHROUGH ; case 3 : * pLMBCS ++ = ( ulmbcs_byte_t ) ( value >> 16 ) ; U_FALLTHROUGH ; case 2 : * pLMBCS ++ = ( ulmbcs_byte_t ) ( value >> 8 ) ; U_FALLTHROUGH ; case 1 : * pLMBCS ++ = ( ulmbcs_byte_t ) value ; U_FALLTHROUGH ; default : break ; } return ( pLMBCS - pStartLMBCS ) ; } static size_t LMBCSConvertUni ( ulmbcs_byte_t * pLMBCS , UChar uniChar ) { uint8_t LowCh = ( uint8_t ) ( uniChar & 0x00FF ) ; uint8_t HighCh = ( uint8_t ) ( uniChar >> 8 ) ; * pLMBCS ++ = ULMBCS_GRP_UNICODE ; if ( LowCh == 0 ) { * pLMBCS ++ = ULMBCS_UNICOMPATZERO ; * pLMBCS ++ = HighCh ; } else { * pLMBCS ++ = HighCh ; * pLMBCS ++ = LowCh ; } return ULMBCS_UNICODE_SIZE ; } static void U_CALLCONV _LMBCSFromUnicode ( UConverterFromUnicodeArgs * args , UErrorCode * err ) { ulmbcs_byte_t lastConverterIndex = 0 ; UChar uniChar ; ulmbcs_byte_t LMBCS [ ULMBCS_CHARSIZE_MAX ] ; ulmbcs_byte_t * pLMBCS ; int32_t bytes_written ; UBool groups_tried [ ULMBCS_GRP_LAST + 1 ] ; UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; int sourceIndex = 0 ; ulmbcs_byte_t OldConverterIndex = 0 ; while ( args -> source < args -> sourceLimit && ! U_FAILURE ( * err ) ) { OldConverterIndex = extraInfo -> localeConverterIndex ; if ( args -> target >= args -> targetLimit ) { * err = U_BUFFER_OVERFLOW_ERROR ; break ; } uniChar = * ( args -> source ) ; bytes_written = 0 ; pLMBCS = LMBCS ; if ( ( uniChar >= 0x80 ) && ( uniChar <= 0xff ) && ( uniChar != 0xB1 ) && ( uniChar != 0xD7 ) && ( uniChar != 0xF7 ) && ( uniChar != 0xB0 ) && ( uniChar != 0xB4 ) && ( uniChar != 0xB6 ) && ( uniChar != 0xA7 ) && ( uniChar != 0xA8 ) ) { extraInfo -> localeConverterIndex = ULMBCS_GRP_L1 ; } if ( ( ( uniChar > ULMBCS_C0END ) && ( uniChar < ULMBCS_C1START ) ) || uniChar == 0 || uniChar == ULMBCS_HT || uniChar == ULMBCS_CR || uniChar == ULMBCS_LF || uniChar == ULMBCS_123SYSTEMRANGE ) { * pLMBCS ++ = ( ulmbcs_byte_t ) uniChar ; bytes_written = 1 ; } if ( ! bytes_written ) { ulmbcs_byte_t group = FindLMBCSUniRange ( uniChar ) ; if ( group == ULMBCS_GRP_UNICODE ) { pLMBCS += LMBCSConvertUni ( pLMBCS , uniChar ) ; bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ; } else if ( group == ULMBCS_GRP_CTRL ) { if ( uniChar <= ULMBCS_C0END ) { * pLMBCS ++ = ULMBCS_GRP_CTRL ; * pLMBCS ++ = ( ulmbcs_byte_t ) ( ULMBCS_CTRLOFFSET + uniChar ) ; } else if ( uniChar >= ULMBCS_C1START && uniChar <= ULMBCS_C1START + ULMBCS_CTRLOFFSET ) { * pLMBCS ++ = ULMBCS_GRP_CTRL ; * pLMBCS ++ = ( ulmbcs_byte_t ) ( uniChar & 0x00FF ) ; } bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ; } else if ( group < ULMBCS_GRP_UNICODE ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , group , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written ) { uprv_memset ( groups_tried , 0 , sizeof ( groups_tried ) ) ; if ( ( extraInfo -> OptGroup != 1 ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , extraInfo -> OptGroup ) ) ) { if ( extraInfo -> localeConverterIndex < ULMBCS_DOUBLEOPTGROUP_START ) { bytes_written = LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_L1 , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; if ( ! bytes_written ) { bytes_written = LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_EXCEPT , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written ) { bytes_written = LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } else { bytes_written = LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } if ( ! bytes_written && ( extraInfo -> localeConverterIndex ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , extraInfo -> localeConverterIndex ) ) ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written && ( lastConverterIndex ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , lastConverterIndex ) ) ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , lastConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written ) { ulmbcs_byte_t grp_start ; ulmbcs_byte_t grp_end ; ulmbcs_byte_t grp_ix ; grp_start = ( ulmbcs_byte_t ) ( ( group == ULMBCS_AMBIGUOUS_MBCS ) ? ULMBCS_DOUBLEOPTGROUP_START : ULMBCS_GRP_L1 ) ; grp_end = ( ulmbcs_byte_t ) ( ( group == ULMBCS_AMBIGUOUS_MBCS ) ? ULMBCS_GRP_LAST : ULMBCS_GRP_TH ) ; if ( group == ULMBCS_AMBIGUOUS_ALL ) { grp_start = ULMBCS_GRP_L1 ; grp_end = ULMBCS_GRP_LAST ; } for ( grp_ix = grp_start ; grp_ix <= grp_end && ! bytes_written ; grp_ix ++ ) { if ( extraInfo -> OptGrpConverter [ grp_ix ] && ! groups_tried [ grp_ix ] ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , grp_ix , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } if ( ! bytes_written && grp_start == ULMBCS_GRP_L1 ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_EXCEPT , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } if ( ! bytes_written ) { pLMBCS += LMBCSConvertUni ( pLMBCS , uniChar ) ; bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ; } } } args -> source ++ ; pLMBCS = LMBCS ; while ( args -> target < args -> targetLimit && bytes_written -- ) { * ( args -> target ) ++ = * pLMBCS ++ ; if ( args -> offsets ) { * ( args -> offsets ) ++ = sourceIndex ; } } sourceIndex ++ ; if ( bytes_written > 0 ) { uint8_t * pErrorBuffer = args -> converter -> charErrorBuffer ; * err = U_BUFFER_OVERFLOW_ERROR ; args -> converter -> charErrorBufferLength = ( int8_t ) bytes_written ; while ( bytes_written -- ) { * pErrorBuffer ++ = * pLMBCS ++ ; } } extraInfo -> localeConverterIndex = OldConverterIndex ; } } static UChar GetUniFromLMBCSUni ( char const * * ppLMBCSin ) { uint8_t HighCh = * ( * ppLMBCSin ) ++ ; uint8_t LowCh = * ( * ppLMBCSin ) ++ ; if ( HighCh == ULMBCS_UNICOMPATZERO ) { HighCh = LowCh ; LowCh = 0 ; } return ( UChar ) ( ( HighCh << 8 ) | LowCh ) ; } # define CHECK_SOURCE_LIMIT ( index ) if ( args -> source + index > args -> sourceLimit ) { * err = U_TRUNCATED_CHAR_FOUND ; args -> source = args -> sourceLimit ; return 0xffff ; } static UChar32 U_CALLCONV _LMBCSGetNextUCharWorker ( UConverterToUnicodeArgs * args , UErrorCode * err ) { UChar32 uniChar = 0 ; ulmbcs_byte_t CurByte ; if ( args -> source >= args -> sourceLimit ) { * err = U_ILLEGAL_ARGUMENT_ERROR ; return 0xffff ; } CurByte = * ( ( ulmbcs_byte_t * ) ( args -> source ++ ) ) ; if ( ( ( CurByte > ULMBCS_C0END ) && ( CurByte < ULMBCS_C1START ) ) || ( CurByte == 0 ) || CurByte == ULMBCS_HT || CurByte == ULMBCS_CR || CurByte == ULMBCS_LF || CurByte == ULMBCS_123SYSTEMRANGE ) { uniChar = CurByte ; } else { UConverterDataLMBCS * extraInfo ; ulmbcs_byte_t group ; UConverterSharedData * cnv ; if ( CurByte == ULMBCS_GRP_CTRL ) { ulmbcs_byte_t C0C1byte ; CHECK_SOURCE_LIMIT ( 1 ) ; C0C1byte = * ( args -> source ) ++ ; uniChar = ( C0C1byte < ULMBCS_C1START ) ? C0C1byte - ULMBCS_CTRLOFFSET : C0C1byte ; } else if ( CurByte == ULMBCS_GRP_UNICODE ) { CHECK_SOURCE_LIMIT ( 2 ) ; return GetUniFromLMBCSUni ( & ( args -> source ) ) ; } else if ( CurByte <= ULMBCS_CTRLOFFSET ) { group = CurByte ; extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; if ( group > ULMBCS_GRP_LAST || ( cnv = extraInfo -> OptGrpConverter [ group ] ) == NULL ) { * err = U_INVALID_CHAR_FOUND ; } else if ( group >= ULMBCS_DOUBLEOPTGROUP_START ) { CHECK_SOURCE_LIMIT ( 2 ) ; if ( * args -> source == group ) { ++ args -> source ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source , 1 , FALSE ) ; ++ args -> source ; } else { uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source , 2 , FALSE ) ; args -> source += 2 ; } } else { CHECK_SOURCE_LIMIT ( 1 ) ; CurByte = * ( args -> source ) ++ ; if ( CurByte >= ULMBCS_C1START ) { uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP ( cnv , CurByte ) ; } else { char bytes [ 2 ] ; extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; cnv = extraInfo -> OptGrpConverter [ ULMBCS_GRP_EXCEPT ] ; bytes [ 0 ] = group ; bytes [ 1 ] = CurByte ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , bytes , 2 , FALSE ) ; } } } else if ( CurByte >= ULMBCS_C1START ) { extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; group = extraInfo -> OptGroup ; cnv = extraInfo -> OptGrpConverter [ group ] ; if ( group >= ULMBCS_DOUBLEOPTGROUP_START ) { if ( ! ucnv_MBCSIsLeadByte ( cnv , CurByte ) ) { CHECK_SOURCE_LIMIT ( 0 ) ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source - 1 , 1 , FALSE ) ; } else { CHECK_SOURCE_LIMIT ( 1 ) ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source - 1 , 2 , FALSE ) ; ++ args -> source ; } } else { uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP ( cnv , CurByte ) ; } } } return uniChar ; } static void U_CALLCONV _LMBCSToUnicodeWithOffsets ( UConverterToUnicodeArgs * args , UErrorCode * err ) { char LMBCS [ ULMBCS_CHARSIZE_MAX ] ; UChar uniChar ; const char * saveSource ; const char * pStartLMBCS = args -> source ; const char * errSource = NULL ; int8_t savebytes = 0 ; while ( U_SUCCESS ( * err ) && args -> sourceLimit > args -> source && args -> targetLimit > args -> target ) { saveSource = args -> source ; if ( args -> converter -> toULength ) { const char * saveSourceLimit ; size_t size_old = args -> converter -> toULength ; size_t size_new_maybe_1 = sizeof ( LMBCS ) - size_old ; size_t size_new_maybe_2 = args -> sourceLimit - args -> source ; size_t size_new = ( size_new_maybe_1 < size_new_maybe_2 ) ? size_new_maybe_1 : size_new_maybe_2 ; uprv_memcpy ( LMBCS , args -> converter -> toUBytes , size_old ) ; uprv_memcpy ( LMBCS + size_old , args -> source , size_new ) ; saveSourceLimit = args -> sourceLimit ; args -> source = errSource = LMBCS ; args -> sourceLimit = LMBCS + size_old + size_new ; savebytes = ( int8_t ) ( size_old + size_new ) ; uniChar = ( UChar ) _LMBCSGetNextUCharWorker ( args , err ) ; args -> source = saveSource + ( ( args -> source - LMBCS ) - size_old ) ; args -> sourceLimit = saveSourceLimit ; if ( * err == U_TRUNCATED_CHAR_FOUND ) { args -> converter -> toULength = savebytes ; uprv_memcpy ( args -> converter -> toUBytes , LMBCS , savebytes ) ; args -> source = args -> sourceLimit ; * err = U_ZERO_ERROR ; return ; } else { args -> converter -> toULength = 0 ; } } else { errSource = saveSource ; uniChar = ( UChar ) _LMBCSGetNextUCharWorker ( args , err ) ; savebytes = ( int8_t ) ( args -> source - saveSource ) ; } if ( U_SUCCESS ( * err ) ) { if ( uniChar < 0xfffe ) { * ( args -> target ) ++ = uniChar ; if ( args -> offsets ) { * ( args -> offsets ) ++ = ( int32_t ) ( saveSource - pStartLMBCS ) ; } } else if ( uniChar == 0xfffe ) { * err = U_INVALID_CHAR_FOUND ; } else { * err = U_ILLEGAL_CHAR_FOUND ; } } } if ( U_SUCCESS ( * err ) && args -> sourceLimit > args -> source && args -> targetLimit <= args -> target ) { * err = U_BUFFER_OVERFLOW_ERROR ; } else if ( U_FAILURE ( * err ) ) { args -> converter -> toULength = savebytes ; if ( savebytes > 0 ) { uprv_memcpy ( args -> converter -> toUBytes , errSource , savebytes ) ; } if ( * err == U_TRUNCATED_CHAR_FOUND ) { * err = U_ZERO_ERROR ; } } } DEFINE_LMBCS_OPEN ( 1 ) DEFINE_LMBCS_OPEN ( 2 )
static void U_CALLCONV _LMBCSOpen ## n ( UConverter * _this , UConverterLoadArgs * pArgs , UErrorCode * err ) \ { _LMBCSOpenWorker ( _this , pArgs , err , n ) ; } static void _LMBCSOpenWorker ( UConverter * _this , UConverterLoadArgs * pArgs , UErrorCode * err , ulmbcs_byte_t OptGroup ) { UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) uprv_malloc ( sizeof ( UConverterDataLMBCS ) ) ; _this -> extraInfo = extraInfo ; if ( extraInfo != NULL ) { UConverterNamePieces stackPieces ; UConverterLoadArgs stackArgs = UCNV_LOAD_ARGS_INITIALIZER ; ulmbcs_byte_t i ; uprv_memset ( extraInfo , 0 , sizeof ( UConverterDataLMBCS ) ) ; stackArgs . onlyTestIsLoadable = pArgs -> onlyTestIsLoadable ; for ( i = 0 ; i <= ULMBCS_GRP_LAST && U_SUCCESS ( * err ) ; i ++ ) { if ( OptGroupByteToCPName [ i ] != NULL ) { extraInfo -> OptGrpConverter [ i ] = ucnv_loadSharedData ( OptGroupByteToCPName [ i ] , & stackPieces , & stackArgs , err ) ; } } if ( U_FAILURE ( * err ) || pArgs -> onlyTestIsLoadable ) { _LMBCSClose ( _this ) ; return ; } extraInfo -> OptGroup = OptGroup ; extraInfo -> localeConverterIndex = FindLMBCSLocale ( pArgs -> locale ) ; } else { * err = U_MEMORY_ALLOCATION_ERROR ; } } U_CDECL_BEGIN static void U_CALLCONV _LMBCSClose ( UConverter * _this ) { if ( _this -> extraInfo != NULL ) { ulmbcs_byte_t Ix ; UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) _this -> extraInfo ; for ( Ix = 0 ; Ix <= ULMBCS_GRP_LAST ; Ix ++ ) { if ( extraInfo -> OptGrpConverter [ Ix ] != NULL ) ucnv_unloadSharedDataIfReady ( extraInfo -> OptGrpConverter [ Ix ] ) ; } if ( ! _this -> isExtraLocal ) { uprv_free ( _this -> extraInfo ) ; _this -> extraInfo = NULL ; } } } typedef struct LMBCSClone { UConverter cnv ; UConverterDataLMBCS lmbcs ; } LMBCSClone ; static UConverter * U_CALLCONV _LMBCSSafeClone ( const UConverter * cnv , void * stackBuffer , int32_t * pBufferSize , UErrorCode * status ) { ( void ) status ; LMBCSClone * newLMBCS ; UConverterDataLMBCS * extraInfo ; int32_t i ; if ( * pBufferSize <= 0 ) { * pBufferSize = ( int32_t ) sizeof ( LMBCSClone ) ; return NULL ; } extraInfo = ( UConverterDataLMBCS * ) cnv -> extraInfo ; newLMBCS = ( LMBCSClone * ) stackBuffer ; uprv_memcpy ( & newLMBCS -> lmbcs , extraInfo , sizeof ( UConverterDataLMBCS ) ) ; for ( i = 0 ; i <= ULMBCS_GRP_LAST ; ++ i ) { if ( extraInfo -> OptGrpConverter [ i ] != NULL ) { ucnv_incrementRefCount ( extraInfo -> OptGrpConverter [ i ] ) ; } } newLMBCS -> cnv . extraInfo = & newLMBCS -> lmbcs ; newLMBCS -> cnv . isExtraLocal = TRUE ; return & newLMBCS -> cnv ; } static size_t LMBCSConversionWorker ( UConverterDataLMBCS * extraInfo , ulmbcs_byte_t group , ulmbcs_byte_t * pStartLMBCS , UChar * pUniChar , ulmbcs_byte_t * lastConverterIndex , UBool * groups_tried ) { ulmbcs_byte_t * pLMBCS = pStartLMBCS ; UConverterSharedData * xcnv = extraInfo -> OptGrpConverter [ group ] ; int bytesConverted ; uint32_t value ; ulmbcs_byte_t firstByte ; U_ASSERT ( xcnv ) ; U_ASSERT ( group < ULMBCS_GRP_UNICODE ) ; bytesConverted = ucnv_MBCSFromUChar32 ( xcnv , * pUniChar , & value , FALSE ) ; if ( bytesConverted > 0 ) { firstByte = ( ulmbcs_byte_t ) ( value >> ( ( bytesConverted - 1 ) * 8 ) ) ; } else { groups_tried [ group ] = TRUE ; return 0 ; } * lastConverterIndex = group ; U_ASSERT ( ( firstByte <= ULMBCS_C0END ) || ( firstByte >= ULMBCS_C1START ) || ( group == ULMBCS_GRP_EXCEPT ) ) ; if ( group != ULMBCS_GRP_EXCEPT && extraInfo -> OptGroup != group ) { * pLMBCS ++ = group ; if ( bytesConverted == 1 && group >= ULMBCS_DOUBLEOPTGROUP_START ) { * pLMBCS ++ = group ; } } if ( bytesConverted == 1 && firstByte < 0x20 ) return 0 ; switch ( bytesConverted ) { case 4 : * pLMBCS ++ = ( ulmbcs_byte_t ) ( value >> 24 ) ; U_FALLTHROUGH ; case 3 : * pLMBCS ++ = ( ulmbcs_byte_t ) ( value >> 16 ) ; U_FALLTHROUGH ; case 2 : * pLMBCS ++ = ( ulmbcs_byte_t ) ( value >> 8 ) ; U_FALLTHROUGH ; case 1 : * pLMBCS ++ = ( ulmbcs_byte_t ) value ; U_FALLTHROUGH ; default : break ; } return ( pLMBCS - pStartLMBCS ) ; } static size_t LMBCSConvertUni ( ulmbcs_byte_t * pLMBCS , UChar uniChar ) { uint8_t LowCh = ( uint8_t ) ( uniChar & 0x00FF ) ; uint8_t HighCh = ( uint8_t ) ( uniChar >> 8 ) ; * pLMBCS ++ = ULMBCS_GRP_UNICODE ; if ( LowCh == 0 ) { * pLMBCS ++ = ULMBCS_UNICOMPATZERO ; * pLMBCS ++ = HighCh ; } else { * pLMBCS ++ = HighCh ; * pLMBCS ++ = LowCh ; } return ULMBCS_UNICODE_SIZE ; } static void U_CALLCONV _LMBCSFromUnicode ( UConverterFromUnicodeArgs * args , UErrorCode * err ) { ulmbcs_byte_t lastConverterIndex = 0 ; UChar uniChar ; ulmbcs_byte_t LMBCS [ ULMBCS_CHARSIZE_MAX ] ; ulmbcs_byte_t * pLMBCS ; int32_t bytes_written ; UBool groups_tried [ ULMBCS_GRP_LAST + 1 ] ; UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; int sourceIndex = 0 ; ulmbcs_byte_t OldConverterIndex = 0 ; while ( args -> source < args -> sourceLimit && ! U_FAILURE ( * err ) ) { OldConverterIndex = extraInfo -> localeConverterIndex ; if ( args -> target >= args -> targetLimit ) { * err = U_BUFFER_OVERFLOW_ERROR ; break ; } uniChar = * ( args -> source ) ; bytes_written = 0 ; pLMBCS = LMBCS ; if ( ( uniChar >= 0x80 ) && ( uniChar <= 0xff ) && ( uniChar != 0xB1 ) && ( uniChar != 0xD7 ) && ( uniChar != 0xF7 ) && ( uniChar != 0xB0 ) && ( uniChar != 0xB4 ) && ( uniChar != 0xB6 ) && ( uniChar != 0xA7 ) && ( uniChar != 0xA8 ) ) { extraInfo -> localeConverterIndex = ULMBCS_GRP_L1 ; } if ( ( ( uniChar > ULMBCS_C0END ) && ( uniChar < ULMBCS_C1START ) ) || uniChar == 0 || uniChar == ULMBCS_HT || uniChar == ULMBCS_CR || uniChar == ULMBCS_LF || uniChar == ULMBCS_123SYSTEMRANGE ) { * pLMBCS ++ = ( ulmbcs_byte_t ) uniChar ; bytes_written = 1 ; } if ( ! bytes_written ) { ulmbcs_byte_t group = FindLMBCSUniRange ( uniChar ) ; if ( group == ULMBCS_GRP_UNICODE ) { pLMBCS += LMBCSConvertUni ( pLMBCS , uniChar ) ; bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ; } else if ( group == ULMBCS_GRP_CTRL ) { if ( uniChar <= ULMBCS_C0END ) { * pLMBCS ++ = ULMBCS_GRP_CTRL ; * pLMBCS ++ = ( ulmbcs_byte_t ) ( ULMBCS_CTRLOFFSET + uniChar ) ; } else if ( uniChar >= ULMBCS_C1START && uniChar <= ULMBCS_C1START + ULMBCS_CTRLOFFSET ) { * pLMBCS ++ = ULMBCS_GRP_CTRL ; * pLMBCS ++ = ( ulmbcs_byte_t ) ( uniChar & 0x00FF ) ; } bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ; } else if ( group < ULMBCS_GRP_UNICODE ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , group , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written ) { uprv_memset ( groups_tried , 0 , sizeof ( groups_tried ) ) ; if ( ( extraInfo -> OptGroup != 1 ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , extraInfo -> OptGroup ) ) ) { if ( extraInfo -> localeConverterIndex < ULMBCS_DOUBLEOPTGROUP_START ) { bytes_written = LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_L1 , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; if ( ! bytes_written ) { bytes_written = LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_EXCEPT , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written ) { bytes_written = LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } else { bytes_written = LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } if ( ! bytes_written && ( extraInfo -> localeConverterIndex ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , extraInfo -> localeConverterIndex ) ) ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written && ( lastConverterIndex ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , lastConverterIndex ) ) ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , lastConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } if ( ! bytes_written ) { ulmbcs_byte_t grp_start ; ulmbcs_byte_t grp_end ; ulmbcs_byte_t grp_ix ; grp_start = ( ulmbcs_byte_t ) ( ( group == ULMBCS_AMBIGUOUS_MBCS ) ? ULMBCS_DOUBLEOPTGROUP_START : ULMBCS_GRP_L1 ) ; grp_end = ( ulmbcs_byte_t ) ( ( group == ULMBCS_AMBIGUOUS_MBCS ) ? ULMBCS_GRP_LAST : ULMBCS_GRP_TH ) ; if ( group == ULMBCS_AMBIGUOUS_ALL ) { grp_start = ULMBCS_GRP_L1 ; grp_end = ULMBCS_GRP_LAST ; } for ( grp_ix = grp_start ; grp_ix <= grp_end && ! bytes_written ; grp_ix ++ ) { if ( extraInfo -> OptGrpConverter [ grp_ix ] && ! groups_tried [ grp_ix ] ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , grp_ix , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } if ( ! bytes_written && grp_start == ULMBCS_GRP_L1 ) { bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_EXCEPT , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ; } } if ( ! bytes_written ) { pLMBCS += LMBCSConvertUni ( pLMBCS , uniChar ) ; bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ; } } } args -> source ++ ; pLMBCS = LMBCS ; while ( args -> target < args -> targetLimit && bytes_written -- ) { * ( args -> target ) ++ = * pLMBCS ++ ; if ( args -> offsets ) { * ( args -> offsets ) ++ = sourceIndex ; } } sourceIndex ++ ; if ( bytes_written > 0 ) { uint8_t * pErrorBuffer = args -> converter -> charErrorBuffer ; * err = U_BUFFER_OVERFLOW_ERROR ; args -> converter -> charErrorBufferLength = ( int8_t ) bytes_written ; while ( bytes_written -- ) { * pErrorBuffer ++ = * pLMBCS ++ ; } } extraInfo -> localeConverterIndex = OldConverterIndex ; } } static UChar GetUniFromLMBCSUni ( char const * * ppLMBCSin ) { uint8_t HighCh = * ( * ppLMBCSin ) ++ ; uint8_t LowCh = * ( * ppLMBCSin ) ++ ; if ( HighCh == ULMBCS_UNICOMPATZERO ) { HighCh = LowCh ; LowCh = 0 ; } return ( UChar ) ( ( HighCh << 8 ) | LowCh ) ; } # define CHECK_SOURCE_LIMIT ( index ) if ( args -> source + index > args -> sourceLimit ) { * err = U_TRUNCATED_CHAR_FOUND ; args -> source = args -> sourceLimit ; return 0xffff ; } static UChar32 U_CALLCONV _LMBCSGetNextUCharWorker ( UConverterToUnicodeArgs * args , UErrorCode * err ) { UChar32 uniChar = 0 ; ulmbcs_byte_t CurByte ; if ( args -> source >= args -> sourceLimit ) { * err = U_ILLEGAL_ARGUMENT_ERROR ; return 0xffff ; } CurByte = * ( ( ulmbcs_byte_t * ) ( args -> source ++ ) ) ; if ( ( ( CurByte > ULMBCS_C0END ) && ( CurByte < ULMBCS_C1START ) ) || ( CurByte == 0 ) || CurByte == ULMBCS_HT || CurByte == ULMBCS_CR || CurByte == ULMBCS_LF || CurByte == ULMBCS_123SYSTEMRANGE ) { uniChar = CurByte ; } else { UConverterDataLMBCS * extraInfo ; ulmbcs_byte_t group ; UConverterSharedData * cnv ; if ( CurByte == ULMBCS_GRP_CTRL ) { ulmbcs_byte_t C0C1byte ; CHECK_SOURCE_LIMIT ( 1 ) ; C0C1byte = * ( args -> source ) ++ ; uniChar = ( C0C1byte < ULMBCS_C1START ) ? C0C1byte - ULMBCS_CTRLOFFSET : C0C1byte ; } else if ( CurByte == ULMBCS_GRP_UNICODE ) { CHECK_SOURCE_LIMIT ( 2 ) ; return GetUniFromLMBCSUni ( & ( args -> source ) ) ; } else if ( CurByte <= ULMBCS_CTRLOFFSET ) { group = CurByte ; extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; if ( group > ULMBCS_GRP_LAST || ( cnv = extraInfo -> OptGrpConverter [ group ] ) == NULL ) { * err = U_INVALID_CHAR_FOUND ; } else if ( group >= ULMBCS_DOUBLEOPTGROUP_START ) { CHECK_SOURCE_LIMIT ( 2 ) ; if ( * args -> source == group ) { ++ args -> source ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source , 1 , FALSE ) ; ++ args -> source ; } else { uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source , 2 , FALSE ) ; args -> source += 2 ; } } else { CHECK_SOURCE_LIMIT ( 1 ) ; CurByte = * ( args -> source ) ++ ; if ( CurByte >= ULMBCS_C1START ) { uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP ( cnv , CurByte ) ; } else { char bytes [ 2 ] ; extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; cnv = extraInfo -> OptGrpConverter [ ULMBCS_GRP_EXCEPT ] ; bytes [ 0 ] = group ; bytes [ 1 ] = CurByte ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , bytes , 2 , FALSE ) ; } } } else if ( CurByte >= ULMBCS_C1START ) { extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ; group = extraInfo -> OptGroup ; cnv = extraInfo -> OptGrpConverter [ group ] ; if ( group >= ULMBCS_DOUBLEOPTGROUP_START ) { if ( ! ucnv_MBCSIsLeadByte ( cnv , CurByte ) ) { CHECK_SOURCE_LIMIT ( 0 ) ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source - 1 , 1 , FALSE ) ; } else { CHECK_SOURCE_LIMIT ( 1 ) ; uniChar = ucnv_MBCSSimpleGetNextUChar ( cnv , args -> source - 1 , 2 , FALSE ) ; ++ args -> source ; } } else { uniChar = _MBCS_SINGLE_SIMPLE_GET_NEXT_BMP ( cnv , CurByte ) ; } } } return uniChar ; } static void U_CALLCONV _LMBCSToUnicodeWithOffsets ( UConverterToUnicodeArgs * args , UErrorCode * err ) { char LMBCS [ ULMBCS_CHARSIZE_MAX ] ; UChar uniChar ; const char * saveSource ; const char * pStartLMBCS = args -> source ; const char * errSource = NULL ; int8_t savebytes = 0 ; while ( U_SUCCESS ( * err ) && args -> sourceLimit > args -> source && args -> targetLimit > args -> target ) { saveSource = args -> source ; if ( args -> converter -> toULength ) { const char * saveSourceLimit ; size_t size_old = args -> converter -> toULength ; size_t size_new_maybe_1 = sizeof ( LMBCS ) - size_old ; size_t size_new_maybe_2 = args -> sourceLimit - args -> source ; size_t size_new = ( size_new_maybe_1 < size_new_maybe_2 ) ? size_new_maybe_1 : size_new_maybe_2 ; uprv_memcpy ( LMBCS , args -> converter -> toUBytes , size_old ) ; uprv_memcpy ( LMBCS + size_old , args -> source , size_new ) ; saveSourceLimit = args -> sourceLimit ; args -> source = errSource = LMBCS ; args -> sourceLimit = LMBCS + size_old + size_new ; savebytes = ( int8_t ) ( size_old + size_new ) ; uniChar = ( UChar ) _LMBCSGetNextUCharWorker ( args , err ) ; args -> source = saveSource + ( ( args -> source - LMBCS ) - size_old ) ; args -> sourceLimit = saveSourceLimit ; if ( * err == U_TRUNCATED_CHAR_FOUND ) { args -> converter -> toULength = savebytes ; uprv_memcpy ( args -> converter -> toUBytes , LMBCS , savebytes ) ; args -> source = args -> sourceLimit ; * err = U_ZERO_ERROR ; return ; } else { args -> converter -> toULength = 0 ; } } else { errSource = saveSource ; uniChar = ( UChar ) _LMBCSGetNextUCharWorker ( args , err ) ; savebytes = ( int8_t ) ( args -> source - saveSource ) ; } if ( U_SUCCESS ( * err ) ) { if ( uniChar < 0xfffe ) { * ( args -> target ) ++ = uniChar ; if ( args -> offsets ) { * ( args -> offsets ) ++ = ( int32_t ) ( saveSource - pStartLMBCS ) ; } } else if ( uniChar == 0xfffe ) { * err = U_INVALID_CHAR_FOUND ; } else { * err = U_ILLEGAL_CHAR_FOUND ; } } } if ( U_SUCCESS ( * err ) && args -> sourceLimit > args -> source && args -> targetLimit <= args -> target ) { * err = U_BUFFER_OVERFLOW_ERROR ; } else if ( U_FAILURE ( * err ) ) { args -> converter -> toULength = savebytes ; if ( savebytes > 0 ) { uprv_memcpy ( args -> converter -> toUBytes , errSource , savebytes ) ; } if ( * err == U_TRUNCATED_CHAR_FOUND ) { * err = U_ZERO_ERROR ; } } } DEFINE_LMBCS_OPEN ( 1 ) DEFINE_LMBCS_OPEN ( 2 )
359
0
static void virtio_balloon_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = virtio_balloon_init_pci; k->exit = virtio_balloon_exit_pci; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_MEMORY_RAM; dc->alias = "virtio-balloon"; dc->reset = virtio_pci_reset; dc->props = virtio_balloon_properties; }
static void virtio_balloon_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = virtio_balloon_init_pci; k->exit = virtio_balloon_exit_pci; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_MEMORY_RAM; dc->alias = "virtio-balloon"; dc->reset = virtio_pci_reset; dc->props = virtio_balloon_properties; }
360
0
mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg) { hp_target_info_t __user *uarg = (void __user *) arg; SCSIDevicePage0_t *pg0_alloc; SCSIDevicePage3_t *pg3_alloc; MPT_SCSI_HOST *hd = NULL; hp_target_info_t karg; int data_sz; dma_addr_t page_dma; CONFIGPARMS cfg; ConfigPageHeader_t hdr; int tmp, np, rc = 0; if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_targetinfo - " "Unable to read in hp_host_targetinfo struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (karg.hdr.id >= MPT_MAX_FC_DEVICES) return -EINVAL; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", ioc->name)); /* There is nothing to do for FCP parts. */ if ((ioc->bus_type == SAS) || (ioc->bus_type == FC)) return 0; if ((ioc->spi_data.sdp0length == 0) || (ioc->sh == NULL)) return 0; if (ioc->sh->host_no != karg.hdr.host) return -ENODEV; /* Get the data transfer speeds */ data_sz = ioc->spi_data.sdp0length * 4; pg0_alloc = (SCSIDevicePage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma); if (pg0_alloc) { hdr.PageVersion = ioc->spi_data.sdp0version; hdr.PageLength = data_sz; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; cfg.cfghdr.hdr = &hdr; cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; cfg.dir = 0; cfg.timeout = 0; cfg.physAddr = page_dma; cfg.pageAddr = (karg.hdr.channel << 8) | karg.hdr.id; if ((rc = mpt_config(ioc, &cfg)) == 0) { np = le32_to_cpu(pg0_alloc->NegotiatedParameters); karg.negotiated_width = np & MPI_SCSIDEVPAGE0_NP_WIDE ? HP_BUS_WIDTH_16 : HP_BUS_WIDTH_8; if (np & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK) { tmp = (np & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_PERIOD_MASK) >> 8; if (tmp < 0x09) karg.negotiated_speed = HP_DEV_SPEED_ULTRA320; else if (tmp <= 0x09) karg.negotiated_speed = HP_DEV_SPEED_ULTRA160; else if (tmp <= 0x0A) karg.negotiated_speed = HP_DEV_SPEED_ULTRA2; else if (tmp <= 0x0C) karg.negotiated_speed = HP_DEV_SPEED_ULTRA; else if (tmp <= 0x25) karg.negotiated_speed = HP_DEV_SPEED_FAST; else karg.negotiated_speed = HP_DEV_SPEED_ASYNC; } else karg.negotiated_speed = HP_DEV_SPEED_ASYNC; } pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg0_alloc, page_dma); } /* Set defaults */ karg.message_rejects = -1; karg.phase_errors = -1; karg.parity_errors = -1; karg.select_timeouts = -1; /* Get the target error parameters */ hdr.PageVersion = 0; hdr.PageLength = 0; hdr.PageNumber = 3; hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; cfg.cfghdr.hdr = &hdr; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; cfg.timeout = 0; cfg.physAddr = -1; if ((mpt_config(ioc, &cfg) == 0) && (cfg.cfghdr.hdr->PageLength > 0)) { /* Issue the second config page request */ cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; data_sz = (int) cfg.cfghdr.hdr->PageLength * 4; pg3_alloc = (SCSIDevicePage3_t *) pci_alloc_consistent( ioc->pcidev, data_sz, &page_dma); if (pg3_alloc) { cfg.physAddr = page_dma; cfg.pageAddr = (karg.hdr.channel << 8) | karg.hdr.id; if ((rc = mpt_config(ioc, &cfg)) == 0) { karg.message_rejects = (u32) le16_to_cpu(pg3_alloc->MsgRejectCount); karg.phase_errors = (u32) le16_to_cpu(pg3_alloc->PhaseErrorCount); karg.parity_errors = (u32) le16_to_cpu(pg3_alloc->ParityErrorCount); } pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); } } hd = shost_priv(ioc->sh); if (hd != NULL) karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hp_target_info - " "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg) { hp_target_info_t __user *uarg = (void __user *) arg; SCSIDevicePage0_t *pg0_alloc; SCSIDevicePage3_t *pg3_alloc; MPT_SCSI_HOST *hd = NULL; hp_target_info_t karg; int data_sz; dma_addr_t page_dma; CONFIGPARMS cfg; ConfigPageHeader_t hdr; int tmp, np, rc = 0; if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_targetinfo - " "Unable to read in hp_host_targetinfo struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (karg.hdr.id >= MPT_MAX_FC_DEVICES) return -EINVAL; dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", ioc->name)); if ((ioc->bus_type == SAS) || (ioc->bus_type == FC)) return 0; if ((ioc->spi_data.sdp0length == 0) || (ioc->sh == NULL)) return 0; if (ioc->sh->host_no != karg.hdr.host) return -ENODEV; data_sz = ioc->spi_data.sdp0length * 4; pg0_alloc = (SCSIDevicePage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma); if (pg0_alloc) { hdr.PageVersion = ioc->spi_data.sdp0version; hdr.PageLength = data_sz; hdr.PageNumber = 0; hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; cfg.cfghdr.hdr = &hdr; cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; cfg.dir = 0; cfg.timeout = 0; cfg.physAddr = page_dma; cfg.pageAddr = (karg.hdr.channel << 8) | karg.hdr.id; if ((rc = mpt_config(ioc, &cfg)) == 0) { np = le32_to_cpu(pg0_alloc->NegotiatedParameters); karg.negotiated_width = np & MPI_SCSIDEVPAGE0_NP_WIDE ? HP_BUS_WIDTH_16 : HP_BUS_WIDTH_8; if (np & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK) { tmp = (np & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_PERIOD_MASK) >> 8; if (tmp < 0x09) karg.negotiated_speed = HP_DEV_SPEED_ULTRA320; else if (tmp <= 0x09) karg.negotiated_speed = HP_DEV_SPEED_ULTRA160; else if (tmp <= 0x0A) karg.negotiated_speed = HP_DEV_SPEED_ULTRA2; else if (tmp <= 0x0C) karg.negotiated_speed = HP_DEV_SPEED_ULTRA; else if (tmp <= 0x25) karg.negotiated_speed = HP_DEV_SPEED_FAST; else karg.negotiated_speed = HP_DEV_SPEED_ASYNC; } else karg.negotiated_speed = HP_DEV_SPEED_ASYNC; } pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg0_alloc, page_dma); } karg.message_rejects = -1; karg.phase_errors = -1; karg.parity_errors = -1; karg.select_timeouts = -1; hdr.PageVersion = 0; hdr.PageLength = 0; hdr.PageNumber = 3; hdr.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; cfg.cfghdr.hdr = &hdr; cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; cfg.dir = 0; cfg.timeout = 0; cfg.physAddr = -1; if ((mpt_config(ioc, &cfg) == 0) && (cfg.cfghdr.hdr->PageLength > 0)) { cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; data_sz = (int) cfg.cfghdr.hdr->PageLength * 4; pg3_alloc = (SCSIDevicePage3_t *) pci_alloc_consistent( ioc->pcidev, data_sz, &page_dma); if (pg3_alloc) { cfg.physAddr = page_dma; cfg.pageAddr = (karg.hdr.channel << 8) | karg.hdr.id; if ((rc = mpt_config(ioc, &cfg)) == 0) { karg.message_rejects = (u32) le16_to_cpu(pg3_alloc->MsgRejectCount); karg.phase_errors = (u32) le16_to_cpu(pg3_alloc->PhaseErrorCount); karg.parity_errors = (u32) le16_to_cpu(pg3_alloc->ParityErrorCount); } pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); } } hd = shost_priv(ioc->sh); if (hd != NULL) karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hp_target_info - " "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
362
0
static bool checkprotoprefix ( struct Curl_easy * data , struct connectdata * conn , const char * s ) { # ifndef CURL_DISABLE_RTSP if ( conn -> handler -> protocol & CURLPROTO_RTSP ) return checkrtspprefix ( data , s ) ; # else ( void ) conn ; # endif return checkhttpprefix ( data , s ) ; }
static bool checkprotoprefix ( struct Curl_easy * data , struct connectdata * conn , const char * s ) { # ifndef CURL_DISABLE_RTSP if ( conn -> handler -> protocol & CURLPROTO_RTSP ) return checkrtspprefix ( data , s ) ; # else ( void ) conn ; # endif return checkhttpprefix ( data , s ) ; }
364
0
static int fetch_active_ports_list(QEMUFile *f, VirtIOSerial *s, uint32_t nr_active_ports) { uint32_t i; s->post_load = g_malloc0(sizeof(*s->post_load)); s->post_load->nr_active_ports = nr_active_ports; s->post_load->connected = g_malloc0(sizeof(*s->post_load->connected) * nr_active_ports); s->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_serial_post_load_timer_cb, s); /* Items in struct VirtIOSerialPort */ for (i = 0; i < nr_active_ports; i++) { VirtIOSerialPort *port; uint32_t elem_popped; uint32_t id; id = qemu_get_be32(f); port = find_port_by_id(s, id); if (!port) { return -EINVAL; } port->guest_connected = qemu_get_byte(f); s->post_load->connected[i].port = port; s->post_load->connected[i].host_connected = qemu_get_byte(f); qemu_get_be32s(f, &elem_popped); if (elem_popped) { qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); port->elem = qemu_get_virtqueue_element(f, sizeof(VirtQueueElement)); /* * Port was throttled on source machine. Let's * unthrottle it here so data starts flowing again. */ virtio_serial_throttle_port(port, false); } } timer_mod(s->post_load->timer, 1); return 0; }
static int fetch_active_ports_list(QEMUFile *f, VirtIOSerial *s, uint32_t nr_active_ports) { uint32_t i; s->post_load = g_malloc0(sizeof(*s->post_load)); s->post_load->nr_active_ports = nr_active_ports; s->post_load->connected = g_malloc0(sizeof(*s->post_load->connected) * nr_active_ports); s->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_serial_post_load_timer_cb, s); for (i = 0; i < nr_active_ports; i++) { VirtIOSerialPort *port; uint32_t elem_popped; uint32_t id; id = qemu_get_be32(f); port = find_port_by_id(s, id); if (!port) { return -EINVAL; } port->guest_connected = qemu_get_byte(f); s->post_load->connected[i].port = port; s->post_load->connected[i].host_connected = qemu_get_byte(f); qemu_get_be32s(f, &elem_popped); if (elem_popped) { qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); port->elem = qemu_get_virtqueue_element(f, sizeof(VirtQueueElement)); virtio_serial_throttle_port(port, false); } } timer_mod(s->post_load->timer, 1); return 0; }
365
0
mptctl_mpt_command (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_command __user *uarg = (void __user *) arg; struct mpt_ioctl_command karg; int rc; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_mpt_command - " "Unable to read in mpt_ioctl_command struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } rc = mptctl_do_mpt_command (ioc, karg, &uarg->MF); return rc; }
mptctl_mpt_command (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_command __user *uarg = (void __user *) arg; struct mpt_ioctl_command karg; int rc; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_mpt_command - " "Unable to read in mpt_ioctl_command struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } rc = mptctl_do_mpt_command (ioc, karg, &uarg->MF); return rc; }
367
1
place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) { u64 vruntime; if (first_fair(cfs_rq)) { vruntime = min_vruntime(cfs_rq->min_vruntime, __pick_next_entity(cfs_rq)->vruntime); } else vruntime = cfs_rq->min_vruntime; /* * The 'current' period is already promised to the current tasks, * however the extra weight of the new task will slow them down a * little, place the new task so that it fits in the slot that * stays open at the end. */ if (initial && sched_feat(START_DEBIT)) vruntime += sched_vslice_add(cfs_rq, se); if (!initial) { /* sleeps upto a single latency don't count. */ if (sched_feat(NEW_FAIR_SLEEPERS)) { if (sched_feat(NORMALIZED_SLEEPER)) vruntime -= calc_delta_fair(sysctl_sched_latency, &cfs_rq->load); else vruntime -= sysctl_sched_latency; } /* ensure we never gain time by being placed backwards. */ vruntime = max_vruntime(se->vruntime, vruntime); } se->vruntime = vruntime; }
place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) { u64 vruntime; if (first_fair(cfs_rq)) { vruntime = min_vruntime(cfs_rq->min_vruntime, __pick_next_entity(cfs_rq)->vruntime); } else vruntime = cfs_rq->min_vruntime; if (initial && sched_feat(START_DEBIT)) vruntime += sched_vslice_add(cfs_rq, se); if (!initial) { if (sched_feat(NEW_FAIR_SLEEPERS)) { if (sched_feat(NORMALIZED_SLEEPER)) vruntime -= calc_delta_fair(sysctl_sched_latency, &cfs_rq->load); else vruntime -= sysctl_sched_latency; } vruntime = max_vruntime(se->vruntime, vruntime); } se->vruntime = vruntime; }
368
0
static void snoop_urb_data ( struct urb * urb , unsigned len ) { int i , size ; len = min ( len , usbfs_snoop_max ) ; if ( ! usbfs_snoop || len == 0 ) return ; if ( urb -> num_sgs == 0 ) { print_hex_dump ( KERN_DEBUG , "data: " , DUMP_PREFIX_NONE , 32 , 1 , urb -> transfer_buffer , len , 1 ) ; return ; } for ( i = 0 ; i < urb -> num_sgs && len ; i ++ ) { size = ( len > USB_SG_SIZE ) ? USB_SG_SIZE : len ; print_hex_dump ( KERN_DEBUG , "data: " , DUMP_PREFIX_NONE , 32 , 1 , sg_virt ( & urb -> sg [ i ] ) , size , 1 ) ; len -= size ; } }
static void snoop_urb_data ( struct urb * urb , unsigned len ) { int i , size ; len = min ( len , usbfs_snoop_max ) ; if ( ! usbfs_snoop || len == 0 ) return ; if ( urb -> num_sgs == 0 ) { print_hex_dump ( KERN_DEBUG , "data: " , DUMP_PREFIX_NONE , 32 , 1 , urb -> transfer_buffer , len , 1 ) ; return ; } for ( i = 0 ; i < urb -> num_sgs && len ; i ++ ) { size = ( len > USB_SG_SIZE ) ? USB_SG_SIZE : len ; print_hex_dump ( KERN_DEBUG , "data: " , DUMP_PREFIX_NONE , 32 , 1 , sg_virt ( & urb -> sg [ i ] ) , size , 1 ) ; len -= size ; } }
369
1
spnego_gss_get_mic_iov_length(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_qop_t qop_req, gss_iov_buffer_desc *iov, int iov_count) { return gss_get_mic_iov_length(minor_status, context_handle, qop_req, iov, iov_count); }
spnego_gss_get_mic_iov_length(OM_uint32 *minor_status, gss_ctx_id_t context_handle, gss_qop_t qop_req, gss_iov_buffer_desc *iov, int iov_count) { return gss_get_mic_iov_length(minor_status, context_handle, qop_req, iov, iov_count); }
370
0
void HELPER(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUUniCore32State *env) { int flag; flag = float32_compare_quiet(a, b, &env->ucf64.fp_status); env->CF = 0; switch (c & 0x7) { case 0: /* F */ break; case 1: /* UN */ if (flag == 2) { env->CF = 1; } break; case 2: /* EQ */ if (flag == 0) { env->CF = 1; } break; case 3: /* UEQ */ if ((flag == 0) || (flag == 2)) { env->CF = 1; } break; case 4: /* OLT */ if (flag == -1) { env->CF = 1; } break; case 5: /* ULT */ if ((flag == -1) || (flag == 2)) { env->CF = 1; } break; case 6: /* OLE */ if ((flag == -1) || (flag == 0)) { env->CF = 1; } break; case 7: /* ULE */ if (flag != 1) { env->CF = 1; } break; } env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29) | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff); }
void HELPER(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUUniCore32State *env) { int flag; flag = float32_compare_quiet(a, b, &env->ucf64.fp_status); env->CF = 0; switch (c & 0x7) { case 0: break; case 1: if (flag == 2) { env->CF = 1; } break; case 2: if (flag == 0) { env->CF = 1; } break; case 3: if ((flag == 0) || (flag == 2)) { env->CF = 1; } break; case 4: if (flag == -1) { env->CF = 1; } break; case 5: if ((flag == -1) || (flag == 2)) { env->CF = 1; } break; case 6: if ((flag == -1) || (flag == 0)) { env->CF = 1; } break; case 7: if (flag != 1) { env->CF = 1; } break; } env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29) | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff); }
371
1
mptctl_mpt_command (unsigned long arg) { struct mpt_ioctl_command __user *uarg = (void __user *) arg; struct mpt_ioctl_command karg; MPT_ADAPTER *ioc; int iocnum; int rc; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_mpt_command - " "Unable to read in mpt_ioctl_command struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } rc = mptctl_do_mpt_command (karg, &uarg->MF); return rc; }
mptctl_mpt_command (unsigned long arg) { struct mpt_ioctl_command __user *uarg = (void __user *) arg; struct mpt_ioctl_command karg; MPT_ADAPTER *ioc; int iocnum; int rc; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_mpt_command - " "Unable to read in mpt_ioctl_command struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } rc = mptctl_do_mpt_command (karg, &uarg->MF); return rc; }
373
0
gx_color_index mem_mapped_map_rgb_color ( gx_device * dev , const gx_color_value cv [ ] ) { gx_device_memory * const mdev = ( gx_device_memory * ) dev ; byte br = gx_color_value_to_byte ( cv [ 0 ] ) ; register const byte * pptr = mdev -> palette . data ; int cnt = mdev -> palette . size ; const byte * which = 0 ; int best = 256 * 3 ; if ( mdev -> color_info . num_components != 1 ) { byte bg = gx_color_value_to_byte ( cv [ 1 ] ) ; byte bb = gx_color_value_to_byte ( cv [ 2 ] ) ; while ( ( cnt -= 3 ) >= 0 ) { register int diff = * pptr - br ; if ( diff < 0 ) diff = - diff ; if ( diff < best ) { int dg = pptr [ 1 ] - bg ; if ( dg < 0 ) dg = - dg ; if ( ( diff += dg ) < best ) { int db = pptr [ 2 ] - bb ; if ( db < 0 ) db = - db ; if ( ( diff += db ) < best ) which = pptr , best = diff ; } } if ( diff == 0 ) break ; pptr += 3 ; } } else { while ( ( cnt -= 3 ) >= 0 ) { register int diff = * pptr - br ; if ( diff < 0 ) diff = - diff ; if ( diff < best ) { which = pptr , best = diff ; } if ( diff == 0 ) break ; pptr += 3 ; } } return ( gx_color_index ) ( ( which - mdev -> palette . data ) / 3 ) ; }
gx_color_index mem_mapped_map_rgb_color ( gx_device * dev , const gx_color_value cv [ ] ) { gx_device_memory * const mdev = ( gx_device_memory * ) dev ; byte br = gx_color_value_to_byte ( cv [ 0 ] ) ; register const byte * pptr = mdev -> palette . data ; int cnt = mdev -> palette . size ; const byte * which = 0 ; int best = 256 * 3 ; if ( mdev -> color_info . num_components != 1 ) { byte bg = gx_color_value_to_byte ( cv [ 1 ] ) ; byte bb = gx_color_value_to_byte ( cv [ 2 ] ) ; while ( ( cnt -= 3 ) >= 0 ) { register int diff = * pptr - br ; if ( diff < 0 ) diff = - diff ; if ( diff < best ) { int dg = pptr [ 1 ] - bg ; if ( dg < 0 ) dg = - dg ; if ( ( diff += dg ) < best ) { int db = pptr [ 2 ] - bb ; if ( db < 0 ) db = - db ; if ( ( diff += db ) < best ) which = pptr , best = diff ; } } if ( diff == 0 ) break ; pptr += 3 ; } } else { while ( ( cnt -= 3 ) >= 0 ) { register int diff = * pptr - br ; if ( diff < 0 ) diff = - diff ; if ( diff < best ) { which = pptr , best = diff ; } if ( diff == 0 ) break ; pptr += 3 ; } } return ( gx_color_index ) ( ( which - mdev -> palette . data ) / 3 ) ; }
374
0
static void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED(%%REGBP, %5) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); }
static void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) {
375
1
_gnutls_server_name_recv_params (gnutls_session_t session, const opaque * data, size_t _data_size) { int i; const unsigned char *p; uint16_t len, type; ssize_t data_size = _data_size; int server_names = 0; if (session->security_parameters.entity == GNUTLS_SERVER) { DECR_LENGTH_RET (data_size, 2, 0); len = _gnutls_read_uint16 (data); if (len != data_size) { /* This is unexpected packet length, but * just ignore it, for now. */ gnutls_assert (); return 0; } p = data + 2; /* Count all server_names in the packet. */ while (data_size > 0) { DECR_LENGTH_RET (data_size, 1, 0); p++; DECR_LEN (data_size, 2); len = _gnutls_read_uint16 (p); p += 2; DECR_LENGTH_RET (data_size, len, 0); server_names++; p += len; } session->security_parameters.extensions.server_names_size = server_names; if (server_names == 0) return 0; /* no names found */ /* we cannot accept more server names. */ if (server_names > MAX_SERVER_NAME_EXTENSIONS) server_names = MAX_SERVER_NAME_EXTENSIONS; p = data + 2; for (i = 0; i < server_names; i++) { type = *p; p++; len = _gnutls_read_uint16 (p); p += 2; switch (type) { case 0: /* NAME_DNS */ if (len <= MAX_SERVER_NAME_SIZE) { memcpy (session->security_parameters.extensions. server_names[i].name, p, len); session->security_parameters.extensions. server_names[i].name_length = len; session->security_parameters.extensions. server_names[i].type = GNUTLS_NAME_DNS; break; } } /* move to next record */ p += len; } } return 0; }
_gnutls_server_name_recv_params (gnutls_session_t session, const opaque * data, size_t _data_size) { int i; const unsigned char *p; uint16_t len, type; ssize_t data_size = _data_size; int server_names = 0; if (session->security_parameters.entity == GNUTLS_SERVER) { DECR_LENGTH_RET (data_size, 2, 0); len = _gnutls_read_uint16 (data); if (len != data_size) { gnutls_assert (); return 0; } p = data + 2; while (data_size > 0) { DECR_LENGTH_RET (data_size, 1, 0); p++; DECR_LEN (data_size, 2); len = _gnutls_read_uint16 (p); p += 2; DECR_LENGTH_RET (data_size, len, 0); server_names++; p += len; } session->security_parameters.extensions.server_names_size = server_names; if (server_names == 0) return 0; if (server_names > MAX_SERVER_NAME_EXTENSIONS) server_names = MAX_SERVER_NAME_EXTENSIONS; p = data + 2; for (i = 0; i < server_names; i++) { type = *p; p++; len = _gnutls_read_uint16 (p); p += 2; switch (type) { case 0: if (len <= MAX_SERVER_NAME_SIZE) { memcpy (session->security_parameters.extensions. server_names[i].name, p, len); session->security_parameters.extensions. server_names[i].name_length = len; session->security_parameters.extensions. server_names[i].type = GNUTLS_NAME_DNS; break; } } p += len; } } return 0; }
376
0
mptctl_readtest (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_test __user *uarg = (void __user *) arg; struct mpt_ioctl_test karg; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_readtest - " "Unable to read in mpt_ioctl_test struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_readtest called.\n", ioc->name)); /* Fill in the data and return the structure to the calling * program */ #ifdef MFCNT karg.chip_type = ioc->mfcnt; #else karg.chip_type = ioc->pcidev->device; #endif strncpy (karg.name, ioc->name, MPT_MAX_NAME); karg.name[MPT_MAX_NAME-1]='\0'; strncpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH); karg.product[MPT_PRODUCT_LENGTH-1]='\0'; /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_readtest - " "Unable to write out mpt_ioctl_test struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
mptctl_readtest (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_test __user *uarg = (void __user *) arg; struct mpt_ioctl_test karg; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_readtest - " "Unable to read in mpt_ioctl_test struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_readtest called.\n", ioc->name)); #ifdef MFCNT karg.chip_type = ioc->mfcnt; #else karg.chip_type = ioc->pcidev->device; #endif strncpy (karg.name, ioc->name, MPT_MAX_NAME); karg.name[MPT_MAX_NAME-1]='\0'; strncpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH); karg.product[MPT_PRODUCT_LENGTH-1]='\0'; if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_readtest - " "Unable to write out mpt_ioctl_test struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
377
0
static int scsi_disk_emulate_start_stop(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); bool start = req->cmd.buf[4] & 1; bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */ if (s->qdev.type == TYPE_ROM && loej) { if (!start && !s->tray_open && s->tray_locked) { scsi_check_condition(r, bdrv_is_inserted(s->qdev.conf.bs) ? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } if (s->tray_open != !start) { bdrv_eject(s->qdev.conf.bs, !start); s->tray_open = !start; } } return 0; }
static int scsi_disk_emulate_start_stop(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); bool start = req->cmd.buf[4] & 1; bool loej = req->cmd.buf[4] & 2; if (s->qdev.type == TYPE_ROM && loej) { if (!start && !s->tray_open && s->tray_locked) { scsi_check_condition(r, bdrv_is_inserted(s->qdev.conf.bs) ? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } if (s->tray_open != !start) { bdrv_eject(s->qdev.conf.bs, !start); s->tray_open = !start; } } return 0; }
378
1
spnego_gss_import_sec_context( OM_uint32 *minor_status, const gss_buffer_t interprocess_token, gss_ctx_id_t *context_handle) { OM_uint32 ret; ret = gss_import_sec_context(minor_status, interprocess_token, context_handle); return (ret); }
spnego_gss_import_sec_context( OM_uint32 *minor_status, const gss_buffer_t interprocess_token, gss_ctx_id_t *context_handle) { OM_uint32 ret; ret = gss_import_sec_context(minor_status, interprocess_token, context_handle); return (ret); }
381
0
static void ecc_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { printf("ECC: Unsupported write 0x" TARGET_FMT_plx " %04x\n", addr, val & 0xffff); }
static void ecc_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { printf("ECC: Unsupported write 0x" TARGET_FMT_plx " %04x\n", addr, val & 0xffff); }
382
1
_gnutls_ciphertext2compressed (gnutls_session_t session, opaque * compress_data, int compress_size, gnutls_datum_t ciphertext, uint8_t type) { uint8_t MAC[MAX_HASH_SIZE]; uint16_t c_length; uint8_t pad; int length; digest_hd_st td; uint16_t blocksize; int ret, i, pad_failed = 0; uint8_t major, minor; gnutls_protocol_t ver; int hash_size = _gnutls_hash_get_algo_len (session->security_parameters. read_mac_algorithm); ver = gnutls_protocol_get_version (session); minor = _gnutls_version_get_minor (ver); major = _gnutls_version_get_major (ver); blocksize = _gnutls_cipher_get_block_size (session->security_parameters. read_bulk_cipher_algorithm); /* initialize MAC */ ret = mac_init (&td, session->security_parameters.read_mac_algorithm, session->connection_state.read_mac_secret.data, session->connection_state.read_mac_secret.size, ver); if (ret < 0 && session->security_parameters.read_mac_algorithm != GNUTLS_MAC_NULL) { gnutls_assert (); return GNUTLS_E_INTERNAL_ERROR; } /* actual decryption (inplace) */ switch (_gnutls_cipher_is_block (session->security_parameters.read_bulk_cipher_algorithm)) { case CIPHER_STREAM: if ((ret = _gnutls_cipher_decrypt (&session->connection_state. read_cipher_state, ciphertext.data, ciphertext.size)) < 0) { gnutls_assert (); return ret; } length = ciphertext.size - hash_size; break; case CIPHER_BLOCK: if ((ciphertext.size < blocksize) || (ciphertext.size % blocksize != 0)) { gnutls_assert (); return GNUTLS_E_DECRYPTION_FAILED; } if ((ret = _gnutls_cipher_decrypt (&session->connection_state. read_cipher_state, ciphertext.data, ciphertext.size)) < 0) { gnutls_assert (); return ret; } /* ignore the IV in TLS 1.1. */ if (session->security_parameters.version >= GNUTLS_TLS1_1) { ciphertext.size -= blocksize; ciphertext.data += blocksize; if (ciphertext.size == 0) { gnutls_assert (); return GNUTLS_E_DECRYPTION_FAILED; } } pad = ciphertext.data[ciphertext.size - 1] + 1; /* pad */ length = ciphertext.size - hash_size - pad; if (pad > ciphertext.size - hash_size) { gnutls_assert (); /* We do not fail here. We check below for the * the pad_failed. If zero means success. */ pad_failed = GNUTLS_E_DECRYPTION_FAILED; } /* Check the pading bytes (TLS 1.x) */ if (ver >= GNUTLS_TLS1 && pad_failed == 0) for (i = 2; i < pad; i++) { if (ciphertext.data[ciphertext.size - i] != ciphertext.data[ciphertext.size - 1]) pad_failed = GNUTLS_E_DECRYPTION_FAILED; } break; default: gnutls_assert (); return GNUTLS_E_INTERNAL_ERROR; } if (length < 0) length = 0; c_length = _gnutls_conv_uint16 ((uint16_t) length); /* Pass the type, version, length and compressed through * MAC. */ if (session->security_parameters.read_mac_algorithm != GNUTLS_MAC_NULL) { _gnutls_hmac (&td, UINT64DATA (session->connection_state. read_sequence_number), 8); _gnutls_hmac (&td, &type, 1); if (ver >= GNUTLS_TLS1) { /* TLS 1.x */ _gnutls_hmac (&td, &major, 1); _gnutls_hmac (&td, &minor, 1); } _gnutls_hmac (&td, &c_length, 2); if (length > 0) _gnutls_hmac (&td, ciphertext.data, length); mac_deinit (&td, MAC, ver); } /* This one was introduced to avoid a timing attack against the TLS * 1.0 protocol. */ if (pad_failed != 0) return pad_failed; /* HMAC was not the same. */ if (memcmp (MAC, &ciphertext.data[length], hash_size) != 0) { gnutls_assert (); return GNUTLS_E_DECRYPTION_FAILED; } /* copy the decrypted stuff to compress_data. */ if (compress_size < length) { gnutls_assert (); return GNUTLS_E_DECOMPRESSION_FAILED; } memcpy (compress_data, ciphertext.data, length); return length; }
_gnutls_ciphertext2compressed (gnutls_session_t session, opaque * compress_data, int compress_size, gnutls_datum_t ciphertext, uint8_t type) { uint8_t MAC[MAX_HASH_SIZE]; uint16_t c_length; uint8_t pad; int length; digest_hd_st td; uint16_t blocksize; int ret, i, pad_failed = 0; uint8_t major, minor; gnutls_protocol_t ver; int hash_size = _gnutls_hash_get_algo_len (session->security_parameters. read_mac_algorithm); ver = gnutls_protocol_get_version (session); minor = _gnutls_version_get_minor (ver); major = _gnutls_version_get_major (ver); blocksize = _gnutls_cipher_get_block_size (session->security_parameters. read_bulk_cipher_algorithm); ret = mac_init (&td, session->security_parameters.read_mac_algorithm, session->connection_state.read_mac_secret.data, session->connection_state.read_mac_secret.size, ver); if (ret < 0 && session->security_parameters.read_mac_algorithm != GNUTLS_MAC_NULL) { gnutls_assert (); return GNUTLS_E_INTERNAL_ERROR; } switch (_gnutls_cipher_is_block (session->security_parameters.read_bulk_cipher_algorithm)) { case CIPHER_STREAM: if ((ret = _gnutls_cipher_decrypt (&session->connection_state. read_cipher_state, ciphertext.data, ciphertext.size)) < 0) { gnutls_assert (); return ret; } length = ciphertext.size - hash_size; break; case CIPHER_BLOCK: if ((ciphertext.size < blocksize) || (ciphertext.size % blocksize != 0)) { gnutls_assert (); return GNUTLS_E_DECRYPTION_FAILED; } if ((ret = _gnutls_cipher_decrypt (&session->connection_state. read_cipher_state, ciphertext.data, ciphertext.size)) < 0) { gnutls_assert (); return ret; } if (session->security_parameters.version >= GNUTLS_TLS1_1) { ciphertext.size -= blocksize; ciphertext.data += blocksize; if (ciphertext.size == 0) { gnutls_assert (); return GNUTLS_E_DECRYPTION_FAILED; } } pad = ciphertext.data[ciphertext.size - 1] + 1; length = ciphertext.size - hash_size - pad; if (pad > ciphertext.size - hash_size) { gnutls_assert (); pad_failed = GNUTLS_E_DECRYPTION_FAILED; } if (ver >= GNUTLS_TLS1 && pad_failed == 0) for (i = 2; i < pad; i++) { if (ciphertext.data[ciphertext.size - i] != ciphertext.data[ciphertext.size - 1]) pad_failed = GNUTLS_E_DECRYPTION_FAILED; } break; default: gnutls_assert (); return GNUTLS_E_INTERNAL_ERROR; } if (length < 0) length = 0; c_length = _gnutls_conv_uint16 ((uint16_t) length); if (session->security_parameters.read_mac_algorithm != GNUTLS_MAC_NULL) { _gnutls_hmac (&td, UINT64DATA (session->connection_state. read_sequence_number), 8); _gnutls_hmac (&td, &type, 1); if (ver >= GNUTLS_TLS1) { _gnutls_hmac (&td, &major, 1); _gnutls_hmac (&td, &minor, 1); } _gnutls_hmac (&td, &c_length, 2); if (length > 0) _gnutls_hmac (&td, ciphertext.data, length); mac_deinit (&td, MAC, ver); } if (pad_failed != 0) return pad_failed; if (memcmp (MAC, &ciphertext.data[length], hash_size) != 0) { gnutls_assert (); return GNUTLS_E_DECRYPTION_FAILED; } if (compress_size < length) { gnutls_assert (); return GNUTLS_E_DECOMPRESSION_FAILED; } memcpy (compress_data, ciphertext.data, length); return length; }
383
0
static inline void tswap32s ( uint32_t * s ) { }
static inline void tswap32s ( uint32_t * s ) { }
384
1
spnego_gss_init_sec_context( OM_uint32 *minor_status, gss_cred_id_t claimant_cred_handle, gss_ctx_id_t *context_handle, gss_name_t target_name, gss_OID mech_type, OM_uint32 req_flags, OM_uint32 time_req, gss_channel_bindings_t input_chan_bindings, gss_buffer_t input_token, gss_OID *actual_mech, gss_buffer_t output_token, OM_uint32 *ret_flags, OM_uint32 *time_rec) { send_token_flag send_token = NO_TOKEN_SEND; OM_uint32 tmpmin, ret, negState; gss_buffer_t mechtok_in, mechListMIC_in, mechListMIC_out; gss_buffer_desc mechtok_out = GSS_C_EMPTY_BUFFER; spnego_gss_cred_id_t spcred = NULL; spnego_gss_ctx_id_t spnego_ctx = NULL; dsyslog("Entering init_sec_context\n"); mechtok_in = mechListMIC_out = mechListMIC_in = GSS_C_NO_BUFFER; negState = REJECT; /* * This function works in three steps: * * 1. Perform mechanism negotiation. * 2. Invoke the negotiated or optimistic mech's gss_init_sec_context * function and examine the results. * 3. Process or generate MICs if necessary. * * The three steps share responsibility for determining when the * exchange is complete. If the selected mech completed in a previous * call and no MIC exchange is expected, then step 1 will decide. If * the selected mech completes in this call and no MIC exchange is * expected, then step 2 will decide. If a MIC exchange is expected, * then step 3 will decide. If an error occurs in any step, the * exchange will be aborted, possibly with an error token. * * negState determines the state of the negotiation, and is * communicated to the acceptor if a continuing token is sent. * send_token is used to indicate what type of token, if any, should be * generated. */ /* Validate arguments. */ if (minor_status != NULL) *minor_status = 0; if (output_token != GSS_C_NO_BUFFER) { output_token->length = 0; output_token->value = NULL; } if (minor_status == NULL || output_token == GSS_C_NO_BUFFER || context_handle == NULL) return GSS_S_CALL_INACCESSIBLE_WRITE; if (actual_mech != NULL) *actual_mech = GSS_C_NO_OID; /* Step 1: perform mechanism negotiation. */ spcred = (spnego_gss_cred_id_t)claimant_cred_handle; if (*context_handle == GSS_C_NO_CONTEXT) { ret = init_ctx_new(minor_status, spcred, context_handle, &send_token); if (ret != GSS_S_CONTINUE_NEEDED) { goto cleanup; } } else { ret = init_ctx_cont(minor_status, context_handle, input_token, &mechtok_in, &mechListMIC_in, &negState, &send_token); if (HARD_ERROR(ret)) { goto cleanup; } } /* Step 2: invoke the selected or optimistic mechanism's * gss_init_sec_context function, if it didn't complete previously. */ spnego_ctx = (spnego_gss_ctx_id_t)*context_handle; if (!spnego_ctx->mech_complete) { ret = init_ctx_call_init( minor_status, spnego_ctx, spcred, target_name, req_flags, time_req, mechtok_in, actual_mech, &mechtok_out, ret_flags, time_rec, &negState, &send_token); /* Give the mechanism a chance to force a mechlistMIC. */ if (!HARD_ERROR(ret) && mech_requires_mechlistMIC(spnego_ctx)) spnego_ctx->mic_reqd = 1; } /* Step 3: process or generate the MIC, if the negotiated mech is * complete and supports MICs. */ if (!HARD_ERROR(ret) && spnego_ctx->mech_complete && (spnego_ctx->ctx_flags & GSS_C_INTEG_FLAG)) { ret = handle_mic(minor_status, mechListMIC_in, (mechtok_out.length != 0), spnego_ctx, &mechListMIC_out, &negState, &send_token); } cleanup: if (send_token == INIT_TOKEN_SEND) { if (make_spnego_tokenInit_msg(spnego_ctx, 0, mechListMIC_out, req_flags, &mechtok_out, send_token, output_token) < 0) { ret = GSS_S_FAILURE; } } else if (send_token != NO_TOKEN_SEND) { if (make_spnego_tokenTarg_msg(negState, GSS_C_NO_OID, &mechtok_out, mechListMIC_out, send_token, output_token) < 0) { ret = GSS_S_FAILURE; } } gss_release_buffer(&tmpmin, &mechtok_out); if (ret == GSS_S_COMPLETE) { /* * Now, switch the output context to refer to the * negotiated mechanism's context. */ *context_handle = (gss_ctx_id_t)spnego_ctx->ctx_handle; if (actual_mech != NULL) *actual_mech = spnego_ctx->actual_mech; if (ret_flags != NULL) *ret_flags = spnego_ctx->ctx_flags; release_spnego_ctx(&spnego_ctx); } else if (ret != GSS_S_CONTINUE_NEEDED) { if (spnego_ctx != NULL) { gss_delete_sec_context(&tmpmin, &spnego_ctx->ctx_handle, GSS_C_NO_BUFFER); release_spnego_ctx(&spnego_ctx); } *context_handle = GSS_C_NO_CONTEXT; } if (mechtok_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechtok_in); free(mechtok_in); } if (mechListMIC_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechListMIC_in); free(mechListMIC_in); } if (mechListMIC_out != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechListMIC_out); free(mechListMIC_out); } return ret; } /* init_sec_context */
spnego_gss_init_sec_context( OM_uint32 *minor_status, gss_cred_id_t claimant_cred_handle, gss_ctx_id_t *context_handle, gss_name_t target_name, gss_OID mech_type, OM_uint32 req_flags, OM_uint32 time_req, gss_channel_bindings_t input_chan_bindings, gss_buffer_t input_token, gss_OID *actual_mech, gss_buffer_t output_token, OM_uint32 *ret_flags, OM_uint32 *time_rec) { send_token_flag send_token = NO_TOKEN_SEND; OM_uint32 tmpmin, ret, negState; gss_buffer_t mechtok_in, mechListMIC_in, mechListMIC_out; gss_buffer_desc mechtok_out = GSS_C_EMPTY_BUFFER; spnego_gss_cred_id_t spcred = NULL; spnego_gss_ctx_id_t spnego_ctx = NULL; dsyslog("Entering init_sec_context\n"); mechtok_in = mechListMIC_out = mechListMIC_in = GSS_C_NO_BUFFER; negState = REJECT; if (minor_status != NULL) *minor_status = 0; if (output_token != GSS_C_NO_BUFFER) { output_token->length = 0; output_token->value = NULL; } if (minor_status == NULL || output_token == GSS_C_NO_BUFFER || context_handle == NULL) return GSS_S_CALL_INACCESSIBLE_WRITE; if (actual_mech != NULL) *actual_mech = GSS_C_NO_OID; spcred = (spnego_gss_cred_id_t)claimant_cred_handle; if (*context_handle == GSS_C_NO_CONTEXT) { ret = init_ctx_new(minor_status, spcred, context_handle, &send_token); if (ret != GSS_S_CONTINUE_NEEDED) { goto cleanup; } } else { ret = init_ctx_cont(minor_status, context_handle, input_token, &mechtok_in, &mechListMIC_in, &negState, &send_token); if (HARD_ERROR(ret)) { goto cleanup; } } spnego_ctx = (spnego_gss_ctx_id_t)*context_handle; if (!spnego_ctx->mech_complete) { ret = init_ctx_call_init( minor_status, spnego_ctx, spcred, target_name, req_flags, time_req, mechtok_in, actual_mech, &mechtok_out, ret_flags, time_rec, &negState, &send_token); if (!HARD_ERROR(ret) && mech_requires_mechlistMIC(spnego_ctx)) spnego_ctx->mic_reqd = 1; } if (!HARD_ERROR(ret) && spnego_ctx->mech_complete && (spnego_ctx->ctx_flags & GSS_C_INTEG_FLAG)) { ret = handle_mic(minor_status, mechListMIC_in, (mechtok_out.length != 0), spnego_ctx, &mechListMIC_out, &negState, &send_token); } cleanup: if (send_token == INIT_TOKEN_SEND) { if (make_spnego_tokenInit_msg(spnego_ctx, 0, mechListMIC_out, req_flags, &mechtok_out, send_token, output_token) < 0) { ret = GSS_S_FAILURE; } } else if (send_token != NO_TOKEN_SEND) { if (make_spnego_tokenTarg_msg(negState, GSS_C_NO_OID, &mechtok_out, mechListMIC_out, send_token, output_token) < 0) { ret = GSS_S_FAILURE; } } gss_release_buffer(&tmpmin, &mechtok_out); if (ret == GSS_S_COMPLETE) { *context_handle = (gss_ctx_id_t)spnego_ctx->ctx_handle; if (actual_mech != NULL) *actual_mech = spnego_ctx->actual_mech; if (ret_flags != NULL) *ret_flags = spnego_ctx->ctx_flags; release_spnego_ctx(&spnego_ctx); } else if (ret != GSS_S_CONTINUE_NEEDED) { if (spnego_ctx != NULL) { gss_delete_sec_context(&tmpmin, &spnego_ctx->ctx_handle, GSS_C_NO_BUFFER); release_spnego_ctx(&spnego_ctx); } *context_handle = GSS_C_NO_CONTEXT; } if (mechtok_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechtok_in); free(mechtok_in); } if (mechListMIC_in != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechListMIC_in); free(mechListMIC_in); } if (mechListMIC_out != GSS_C_NO_BUFFER) { gss_release_buffer(&tmpmin, mechListMIC_out); free(mechListMIC_out); } return ret; }
385
0
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) { cpu_synchronize_state(cpu_single_env); assert(cpu_single_env->exception_injected == -1); cpu_single_env->exception_injected = arch_info->exception; cpu_single_env->has_error_code = 0; } return handle; }
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) { cpu_synchronize_state(cpu_single_env); assert(cpu_single_env->exception_injected == -1); cpu_single_env->exception_injected = arch_info->exception; cpu_single_env->has_error_code = 0; } return handle; }
386
0
static int unpack_superblocks ( Vp3DecodeContext * s , GetBitContext * gb ) { int superblock_starts [ 3 ] = { 0 , s -> u_superblock_start , s -> v_superblock_start } ; int bit = 0 ; int current_superblock = 0 ; int current_run = 0 ; int num_partial_superblocks = 0 ; int i , j ; int current_fragment ; int plane ; if ( s -> keyframe ) { memset ( s -> superblock_coding , SB_FULLY_CODED , s -> superblock_count ) ; } else { bit = get_bits1 ( gb ) ^ 1 ; current_run = 0 ; while ( current_superblock < s -> superblock_count && get_bits_left ( gb ) > 0 ) { if ( s -> theora && current_run == MAXIMUM_LONG_BIT_RUN ) bit = get_bits1 ( gb ) ; else bit ^= 1 ; current_run = get_vlc2 ( gb , s -> superblock_run_length_vlc . table , 6 , 2 ) + 1 ; if ( current_run == 34 ) current_run += get_bits ( gb , 12 ) ; if ( current_superblock + current_run > s -> superblock_count ) { av_log ( s -> avctx , AV_LOG_ERROR , "Invalid partially coded superblock run length\n" ) ; return - 1 ; } memset ( s -> superblock_coding + current_superblock , bit , current_run ) ; current_superblock += current_run ; if ( bit ) num_partial_superblocks += current_run ; } if ( num_partial_superblocks < s -> superblock_count ) { int superblocks_decoded = 0 ; current_superblock = 0 ; bit = get_bits1 ( gb ) ^ 1 ; current_run = 0 ; while ( superblocks_decoded < s -> superblock_count - num_partial_superblocks && get_bits_left ( gb ) > 0 ) { if ( s -> theora && current_run == MAXIMUM_LONG_BIT_RUN ) bit = get_bits1 ( gb ) ; else bit ^= 1 ; current_run = get_vlc2 ( gb , s -> superblock_run_length_vlc . table , 6 , 2 ) + 1 ; if ( current_run == 34 ) current_run += get_bits ( gb , 12 ) ; for ( j = 0 ; j < current_run ; current_superblock ++ ) { if ( current_superblock >= s -> superblock_count ) { av_log ( s -> avctx , AV_LOG_ERROR , "Invalid fully coded superblock run length\n" ) ; return - 1 ; } if ( s -> superblock_coding [ current_superblock ] == SB_NOT_CODED ) { s -> superblock_coding [ current_superblock ] = 2 * bit ; j ++ ; } } superblocks_decoded += current_run ; } } if ( num_partial_superblocks ) { current_run = 0 ; bit = get_bits1 ( gb ) ; bit ^= 1 ; } } s -> total_num_coded_frags = 0 ; memset ( s -> macroblock_coding , MODE_COPY , s -> macroblock_count ) ; for ( plane = 0 ; plane < 3 ; plane ++ ) { int sb_start = superblock_starts [ plane ] ; int sb_end = sb_start + ( plane ? s -> c_superblock_count : s -> y_superblock_count ) ; int num_coded_frags = 0 ; for ( i = sb_start ; i < sb_end && get_bits_left ( gb ) > 0 ; i ++ ) { for ( j = 0 ; j < 16 ; j ++ ) { current_fragment = s -> superblock_fragments [ i * 16 + j ] ; if ( current_fragment != - 1 ) { int coded = s -> superblock_coding [ i ] ; if ( s -> superblock_coding [ i ] == SB_PARTIALLY_CODED ) { if ( current_run -- == 0 ) { bit ^= 1 ; current_run = get_vlc2 ( gb , s -> fragment_run_length_vlc . table , 5 , 2 ) ; } coded = bit ; } if ( coded ) { s -> all_fragments [ current_fragment ] . coding_method = MODE_INTER_NO_MV ; s -> coded_fragment_list [ plane ] [ num_coded_frags ++ ] = current_fragment ; } else { s -> all_fragments [ current_fragment ] . coding_method = MODE_COPY ; } } } } s -> total_num_coded_frags += num_coded_frags ; for ( i = 0 ; i < 64 ; i ++ ) s -> num_coded_frags [ plane ] [ i ] = num_coded_frags ; if ( plane < 2 ) s -> coded_fragment_list [ plane + 1 ] = s -> coded_fragment_list [ plane ] + num_coded_frags ; } return 0 ; }
static int unpack_superblocks ( Vp3DecodeContext * s , GetBitContext * gb ) { int superblock_starts [ 3 ] = { 0 , s -> u_superblock_start , s -> v_superblock_start } ; int bit = 0 ; int current_superblock = 0 ; int current_run = 0 ; int num_partial_superblocks = 0 ; int i , j ; int current_fragment ; int plane ; if ( s -> keyframe ) { memset ( s -> superblock_coding , SB_FULLY_CODED , s -> superblock_count ) ; } else { bit = get_bits1 ( gb ) ^ 1 ; current_run = 0 ; while ( current_superblock < s -> superblock_count && get_bits_left ( gb ) > 0 ) { if ( s -> theora && current_run == MAXIMUM_LONG_BIT_RUN ) bit = get_bits1 ( gb ) ; else bit ^= 1 ; current_run = get_vlc2 ( gb , s -> superblock_run_length_vlc . table , 6 , 2 ) + 1 ; if ( current_run == 34 ) current_run += get_bits ( gb , 12 ) ; if ( current_superblock + current_run > s -> superblock_count ) { av_log ( s -> avctx , AV_LOG_ERROR , "Invalid partially coded superblock run length\n" ) ; return - 1 ; } memset ( s -> superblock_coding + current_superblock , bit , current_run ) ; current_superblock += current_run ; if ( bit ) num_partial_superblocks += current_run ; } if ( num_partial_superblocks < s -> superblock_count ) { int superblocks_decoded = 0 ; current_superblock = 0 ; bit = get_bits1 ( gb ) ^ 1 ; current_run = 0 ; while ( superblocks_decoded < s -> superblock_count - num_partial_superblocks && get_bits_left ( gb ) > 0 ) { if ( s -> theora && current_run == MAXIMUM_LONG_BIT_RUN ) bit = get_bits1 ( gb ) ; else bit ^= 1 ; current_run = get_vlc2 ( gb , s -> superblock_run_length_vlc . table , 6 , 2 ) + 1 ; if ( current_run == 34 ) current_run += get_bits ( gb , 12 ) ; for ( j = 0 ; j < current_run ; current_superblock ++ ) { if ( current_superblock >= s -> superblock_count ) { av_log ( s -> avctx , AV_LOG_ERROR , "Invalid fully coded superblock run length\n" ) ; return - 1 ; } if ( s -> superblock_coding [ current_superblock ] == SB_NOT_CODED ) { s -> superblock_coding [ current_superblock ] = 2 * bit ; j ++ ; } } superblocks_decoded += current_run ; } } if ( num_partial_superblocks ) { current_run = 0 ; bit = get_bits1 ( gb ) ; bit ^= 1 ; } } s -> total_num_coded_frags = 0 ; memset ( s -> macroblock_coding , MODE_COPY , s -> macroblock_count ) ; for ( plane = 0 ; plane < 3 ; plane ++ ) { int sb_start = superblock_starts [ plane ] ; int sb_end = sb_start + ( plane ? s -> c_superblock_count : s -> y_superblock_count ) ; int num_coded_frags = 0 ; for ( i = sb_start ; i < sb_end && get_bits_left ( gb ) > 0 ; i ++ ) { for ( j = 0 ; j < 16 ; j ++ ) { current_fragment = s -> superblock_fragments [ i * 16 + j ] ; if ( current_fragment != - 1 ) { int coded = s -> superblock_coding [ i ] ; if ( s -> superblock_coding [ i ] == SB_PARTIALLY_CODED ) { if ( current_run -- == 0 ) { bit ^= 1 ; current_run = get_vlc2 ( gb , s -> fragment_run_length_vlc . table , 5 , 2 ) ; } coded = bit ; } if ( coded ) { s -> all_fragments [ current_fragment ] . coding_method = MODE_INTER_NO_MV ; s -> coded_fragment_list [ plane ] [ num_coded_frags ++ ] = current_fragment ; } else { s -> all_fragments [ current_fragment ] . coding_method = MODE_COPY ; } } } } s -> total_num_coded_frags += num_coded_frags ; for ( i = 0 ; i < 64 ; i ++ ) s -> num_coded_frags [ plane ] [ i ] = num_coded_frags ; if ( plane < 2 ) s -> coded_fragment_list [ plane + 1 ] = s -> coded_fragment_list [ plane ] + num_coded_frags ; } return 0 ; }
387
1
_gnutls_recv_handshake_header (gnutls_session_t session, gnutls_handshake_description_t type, gnutls_handshake_description_t * recv_type) { int ret; uint32_t length32 = 0; uint8_t *dataptr = NULL; /* for realloc */ size_t handshake_header_size = HANDSHAKE_HEADER_SIZE; /* if we have data into the buffer then return them, do not read the next packet. * In order to return we need a full TLS handshake header, or in case of a version 2 * packet, then we return the first byte. */ if (session->internals.handshake_header_buffer.header_size == handshake_header_size || (session->internals.v2_hello != 0 && type == GNUTLS_HANDSHAKE_CLIENT_HELLO && session->internals. handshake_header_buffer.packet_length > 0)) { *recv_type = session->internals.handshake_header_buffer.recv_type; return session->internals.handshake_header_buffer.packet_length; } /* Note: SSL2_HEADERS == 1 */ dataptr = session->internals.handshake_header_buffer.header; /* If we haven't already read the handshake headers. */ if (session->internals.handshake_header_buffer.header_size < SSL2_HEADERS) { ret = _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, type, dataptr, SSL2_HEADERS); if (ret < 0) { gnutls_assert (); return ret; } /* The case ret==0 is caught here. */ if (ret != SSL2_HEADERS) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } session->internals.handshake_header_buffer.header_size = SSL2_HEADERS; } if (session->internals.v2_hello == 0 || type != GNUTLS_HANDSHAKE_CLIENT_HELLO) { ret = _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, type, &dataptr[session-> internals. handshake_header_buffer. header_size], HANDSHAKE_HEADER_SIZE - session->internals. handshake_header_buffer.header_size); if (ret <= 0) { gnutls_assert (); return (ret < 0) ? ret : GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } if ((size_t) ret != HANDSHAKE_HEADER_SIZE - session->internals.handshake_header_buffer.header_size) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } *recv_type = dataptr[0]; /* we do not use DECR_LEN because we know * that the packet has enough data. */ length32 = _gnutls_read_uint24 (&dataptr[1]); handshake_header_size = HANDSHAKE_HEADER_SIZE; _gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n", session, _gnutls_handshake2str (dataptr[0]), length32 + HANDSHAKE_HEADER_SIZE); } else { /* v2 hello */ length32 = session->internals.v2_hello - SSL2_HEADERS; /* we've read the first byte */ handshake_header_size = SSL2_HEADERS; /* we've already read one byte */ *recv_type = dataptr[0]; _gnutls_handshake_log ("HSK[%x]: %s(v2) was received [%ld bytes]\n", session, _gnutls_handshake2str (*recv_type), length32 + handshake_header_size); if (*recv_type != GNUTLS_HANDSHAKE_CLIENT_HELLO) { /* it should be one or nothing */ gnutls_assert (); return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; } } /* put the packet into the buffer */ session->internals.handshake_header_buffer.header_size = handshake_header_size; session->internals.handshake_header_buffer.packet_length = length32; session->internals.handshake_header_buffer.recv_type = *recv_type; if (*recv_type != type) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; } return length32; }
_gnutls_recv_handshake_header (gnutls_session_t session, gnutls_handshake_description_t type, gnutls_handshake_description_t * recv_type) { int ret; uint32_t length32 = 0; uint8_t *dataptr = NULL; size_t handshake_header_size = HANDSHAKE_HEADER_SIZE; if (session->internals.handshake_header_buffer.header_size == handshake_header_size || (session->internals.v2_hello != 0 && type == GNUTLS_HANDSHAKE_CLIENT_HELLO && session->internals. handshake_header_buffer.packet_length > 0)) { *recv_type = session->internals.handshake_header_buffer.recv_type; return session->internals.handshake_header_buffer.packet_length; } dataptr = session->internals.handshake_header_buffer.header; if (session->internals.handshake_header_buffer.header_size < SSL2_HEADERS) { ret = _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, type, dataptr, SSL2_HEADERS); if (ret < 0) { gnutls_assert (); return ret; } if (ret != SSL2_HEADERS) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } session->internals.handshake_header_buffer.header_size = SSL2_HEADERS; } if (session->internals.v2_hello == 0 || type != GNUTLS_HANDSHAKE_CLIENT_HELLO) { ret = _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, type, &dataptr[session-> internals. handshake_header_buffer. header_size], HANDSHAKE_HEADER_SIZE - session->internals. handshake_header_buffer.header_size); if (ret <= 0) { gnutls_assert (); return (ret < 0) ? ret : GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } if ((size_t) ret != HANDSHAKE_HEADER_SIZE - session->internals.handshake_header_buffer.header_size) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } *recv_type = dataptr[0]; length32 = _gnutls_read_uint24 (&dataptr[1]); handshake_header_size = HANDSHAKE_HEADER_SIZE; _gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n", session, _gnutls_handshake2str (dataptr[0]), length32 + HANDSHAKE_HEADER_SIZE); } else { length32 = session->internals.v2_hello - SSL2_HEADERS; handshake_header_size = SSL2_HEADERS; *recv_type = dataptr[0]; _gnutls_handshake_log ("HSK[%x]: %s(v2) was received [%ld bytes]\n", session, _gnutls_handshake2str (*recv_type), length32 + handshake_header_size); if (*recv_type != GNUTLS_HANDSHAKE_CLIENT_HELLO) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; } } session->internals.handshake_header_buffer.header_size = handshake_header_size; session->internals.handshake_header_buffer.packet_length = length32; session->internals.handshake_header_buffer.recv_type = *recv_type; if (*recv_type != type) { gnutls_assert (); return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; } return length32; }
388
0
mptctl_replace_fw (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg; struct mpt_ioctl_replace_fw karg; int newFwSize; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_replace_fw called.\n", ioc->name)); /* If caching FW, Free the old FW image */ if (ioc->cached_fw == NULL) return 0; mpt_free_fw_memory(ioc); /* Allocate memory for the new FW image */ newFwSize = ALIGN(karg.newImageSize, 4); mpt_alloc_fw_memory(ioc, newFwSize); if (ioc->cached_fw == NULL) return -ENOMEM; /* Copy the data from user memory to kernel space */ if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw image " "@ %p\n", ioc->name, __FILE__, __LINE__, uarg); mpt_free_fw_memory(ioc); return -EFAULT; } /* Update IOCFactsReply */ ioc->facts.FWImageSize = newFwSize; return 0; }
mptctl_replace_fw (MPT_ADAPTER *ioc, unsigned long arg) { struct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg; struct mpt_ioctl_replace_fw karg; int newFwSize; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_replace_fw called.\n", ioc->name)); if (ioc->cached_fw == NULL) return 0; mpt_free_fw_memory(ioc); newFwSize = ALIGN(karg.newImageSize, 4); mpt_alloc_fw_memory(ioc, newFwSize); if (ioc->cached_fw == NULL) return -ENOMEM; if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw image " "@ %p\n", ioc->name, __FILE__, __LINE__, uarg); mpt_free_fw_memory(ioc); return -EFAULT; } ioc->facts.FWImageSize = newFwSize; return 0; }
389
0
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, Error **errp) { ChardevStdio *stdio; stdio = backend->u.stdio = g_new0(ChardevStdio, 1); qemu_chr_parse_common(opts, qapi_ChardevStdio_base(stdio)); stdio->has_signal = true; stdio->signal = qemu_opt_get_bool(opts, "signal", true); }
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, Error **errp) { ChardevStdio *stdio; stdio = backend->u.stdio = g_new0(ChardevStdio, 1); qemu_chr_parse_common(opts, qapi_ChardevStdio_base(stdio)); stdio->has_signal = true; stdio->signal = qemu_opt_get_bool(opts, "signal", true); }
390
1
mptctl_replace_fw (unsigned long arg) { struct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg; struct mpt_ioctl_replace_fw karg; MPT_ADAPTER *ioc; int iocnum; int newFwSize; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_replace_fw called.\n", ioc->name)); /* If caching FW, Free the old FW image */ if (ioc->cached_fw == NULL) return 0; mpt_free_fw_memory(ioc); /* Allocate memory for the new FW image */ newFwSize = ALIGN(karg.newImageSize, 4); mpt_alloc_fw_memory(ioc, newFwSize); if (ioc->cached_fw == NULL) return -ENOMEM; /* Copy the data from user memory to kernel space */ if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw image " "@ %p\n", ioc->name, __FILE__, __LINE__, uarg); mpt_free_fw_memory(ioc); return -EFAULT; } /* Update IOCFactsReply */ ioc->facts.FWImageSize = newFwSize; return 0; }
mptctl_replace_fw (unsigned long arg) { struct mpt_ioctl_replace_fw __user *uarg = (void __user *) arg; struct mpt_ioctl_replace_fw karg; MPT_ADAPTER *ioc; int iocnum; int newFwSize; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_replace_fw called.\n", ioc->name)); if (ioc->cached_fw == NULL) return 0; mpt_free_fw_memory(ioc); newFwSize = ALIGN(karg.newImageSize, 4); mpt_alloc_fw_memory(ioc, newFwSize); if (ioc->cached_fw == NULL) return -ENOMEM; if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_replace_fw - " "Unable to read in mpt_ioctl_replace_fw image " "@ %p\n", ioc->name, __FILE__, __LINE__, uarg); mpt_free_fw_memory(ioc); return -EFAULT; } ioc->facts.FWImageSize = newFwSize; return 0; }
391
0
TEST_F ( TemplateURLTest , Suggestions ) { struct TestData { const int accepted_suggestion ; const base : : string16 original_query_for_suggestion ; const std : : string expected_result ; } test_data [ ] = { { TemplateURLRef : : NO_SUGGESTIONS_AVAILABLE , base : : string16 ( ) , "http://bar/foo?q=foobar" } , { TemplateURLRef : : NO_SUGGESTIONS_AVAILABLE , ASCIIToUTF16 ( "foo" ) , "http://bar/foo?q=foobar" } , { TemplateURLRef : : NO_SUGGESTION_CHOSEN , base : : string16 ( ) , "http://bar/foo?q=foobar" } , { TemplateURLRef : : NO_SUGGESTION_CHOSEN , ASCIIToUTF16 ( "foo" ) , "http://bar/foo?q=foobar" } , { 0 , base : : string16 ( ) , "http://bar/foo?oq=&q=foobar" } , { 1 , ASCIIToUTF16 ( "foo" ) , "http://bar/foo?oq=foo&q=foobar" } , } ; TemplateURLData data ; data . SetURL ( "http://bar/foo?{ google:originalQueryForSuggestion} " "q={ searchTerms} " ) ; data . input_encodings . push_back ( "UTF-8" ) ; TemplateURL url ( data ) ; EXPECT_TRUE ( url . url_ref ( ) . IsValid ( search_terms_data_ ) ) ; ASSERT_TRUE ( url . url_ref ( ) . SupportsReplacement ( search_terms_data_ ) ) ; for ( size_t i = 0 ; i < arraysize ( test_data ) ; ++ i ) { TemplateURLRef : : SearchTermsArgs search_terms_args ( ASCIIToUTF16 ( "foobar" ) ) ; search_terms_args . accepted_suggestion = test_data [ i ] . accepted_suggestion ; search_terms_args . original_query = test_data [ i ] . original_query_for_suggestion ; GURL result ( url . url_ref ( ) . ReplaceSearchTerms ( search_terms_args , search_terms_data_ ) ) ; ASSERT_TRUE ( result . is_valid ( ) ) ; EXPECT_EQ ( test_data [ i ] . expected_result , result . spec ( ) ) ; } }
TEST_F ( TemplateURLTest , Suggestions ) { struct TestData { const int accepted_suggestion ; const base : : string16 original_query_for_suggestion ; const std : : string expected_result ; } test_data [ ] = { { TemplateURLRef : : NO_SUGGESTIONS_AVAILABLE , base : : string16 ( ) , "http://bar/foo?q=foobar" } , { TemplateURLRef : : NO_SUGGESTIONS_AVAILABLE , ASCIIToUTF16 ( "foo" ) , "http://bar/foo?q=foobar" } , { TemplateURLRef : : NO_SUGGESTION_CHOSEN , base : : string16 ( ) , "http://bar/foo?q=foobar" } , { TemplateURLRef : : NO_SUGGESTION_CHOSEN , ASCIIToUTF16 ( "foo" ) , "http://bar/foo?q=foobar" } , { 0 , base : : string16 ( ) , "http://bar/foo?oq=&q=foobar" } , { 1 , ASCIIToUTF16 ( "foo" ) , "http://bar/foo?oq=foo&q=foobar" } , } ; TemplateURLData data ; data . SetURL ( "http://bar/foo?{ google:originalQueryForSuggestion} " "q={ searchTerms} " ) ; data . input_encodings . push_back ( "UTF-8" ) ; TemplateURL url ( data ) ; EXPECT_TRUE ( url . url_ref ( ) . IsValid ( search_terms_data_ ) ) ; ASSERT_TRUE ( url . url_ref ( ) . SupportsReplacement ( search_terms_data_ ) ) ; for ( size_t i = 0 ; i < arraysize ( test_data ) ; ++ i ) { TemplateURLRef : : SearchTermsArgs search_terms_args ( ASCIIToUTF16 ( "foobar" ) ) ; search_terms_args . accepted_suggestion = test_data [ i ] . accepted_suggestion ; search_terms_args . original_query = test_data [ i ] . original_query_for_suggestion ; GURL result ( url . url_ref ( ) . ReplaceSearchTerms ( search_terms_args , search_terms_data_ ) ) ; ASSERT_TRUE ( result . is_valid ( ) ) ; EXPECT_EQ ( test_data [ i ] . expected_result , result . spec ( ) ) ; } }
393