pinfo_init() { register int end, i; if (!is_magic()) { end = dpgline[0]; for (i = 1; i <= end; i++) pageptr[(hpgline[i])] = '\0'; end = dpgattr[0] >> 1; for (i = 0; i < end; i++) { pageptr[PGTLRG+i] = (char)FALSE; pageptr[PGTCNT+i] = (char)FALSE; } pageptr[HPNPBOT] = pageptr[HPNPCENT] = (char)TRUE; pageptr[HPNPTOP] = pageptr[HPNPALT] = pageptr[HPNPLEFT] = pageptr[HPNPRIGT] = (char)FALSE; ((int*)pageptr)[HPNOFF] = ((int*)pageptr)[HMNOFF] = 0; pageptr[HROUGH] = (char)FALSE; end = doptradio[0]; for (i = 2; i <= end; i += 2) { pageptr[(hoptradio[i])] = (char)FALSE; pageptr[(hoptradio[i+1])] = (char)TRUE; } size_systems(); pageptr[PSYSUSR] = (char)sysrec; set_magic(); }
static int mem_start_download(struct link_device *ld, struct io_device *iod) { struct mem_link_device *mld = to_mem_link_device(ld); reset_ipc_map(mld); #ifdef CONFIG_LINK_DEVICE_WITH_SBD_ARCH if (mld->attrs & LINK_ATTR(LINK_ATTR_MEM_BOOT)) sbd_deactivate(&mld->sbd_link_dev); #endif if (mld->attrs & LINK_ATTR(LINK_ATTR_BOOT_ALIGNED)) ld->aligned = true; else ld->aligned = false; if (mld->dpram_magic) { unsigned int magic; set_magic(mld, MEM_BOOT_MAGIC); magic = get_magic(mld); if (magic != MEM_BOOT_MAGIC) { mif_err("%s: ERR! magic 0x%08X != BOOT_MAGIC 0x%08X\n", ld->name, magic, MEM_BOOT_MAGIC); return -EFAULT; } mif_err("%s: magic == 0x%08X\n", ld->name, magic); } return 0; }
/** @brief function for the @b dump_start method in a link_device instance @param ld the pointer to a link_device instance @param iod the pointer to an io_device instance */ int mem_start_upload(struct link_device *ld, struct io_device *iod) { struct mem_link_device *mld = to_mem_link_device(ld); if (mld->attrs & LINK_ATTR(LINK_ATTR_MEM_DUMP)) sbd_deactivate(&mld->sbd_link_dev); reset_ipc_map(mld); if (mld->attrs & LINK_ATTR(LINK_ATTR_DUMP_ALIGNED)) ld->aligned = true; else ld->aligned = false; if (mld->dpram_magic) { unsigned int magic; set_magic(mld, MEM_DUMP_MAGIC); magic = get_magic(mld); if (magic != MEM_DUMP_MAGIC) { mif_err("%s: ERR! magic 0x%08X != DUMP_MAGIC 0x%08X\n", ld->name, magic, MEM_DUMP_MAGIC); return -EFAULT; } mif_info("%s: magic == 0x%08X\n", ld->name, magic); } return 0; }
/** @brief function for the @b dump_start method in a link_device instance @param ld the pointer to a link_device instance @param iod the pointer to an io_device instance */ static int mem_start_upload(struct link_device *ld, struct io_device *iod) { struct mem_link_device *mld = to_mem_link_device(ld); reset_ipc_map(mld); reset_ipc_devices(mld); mif_err("%s: magic = 0x%08X\n", ld->name, SHM_DUMP_MAGIC); set_magic(mld, SHM_DUMP_MAGIC); return 0; }
void *BT_kMalloc(BT_u32 ulSize) { void *p; if(!ulSize) { return NULL; } ulSize=(ulSize+3)&0xFFFFFFFC; BT_CACHE *pCache = BT_GetSuitableCache(ulSize+sizeof(struct MEM_TAG)+sizeof(struct MAGIC_TAG)); if(pCache) { p = BT_CacheAlloc(pCache); } else { bt_paddr_t phys = bt_page_alloc(ulSize+sizeof(struct MEM_TAG)+sizeof(struct MAGIC_TAG)); if(!phys) { return NULL; } p = (void *) bt_phys_to_virt(phys); } if(!p) { return NULL; } struct MEM_TAG *tag = (struct MEM_TAG *) p; tag->pCache = pCache; tag->size = ulSize; set_magic(&tag->tag_0); set_magic(&tag->tag_1); struct MAGIC_TAG *mempost = (struct MAGIC_TAG *) ((BT_u8 *) (tag+1) + ulSize); set_magic(mempost); /* * Before the allocated memory we place a pointer to the pCache. * This will be 0 in the case of a page allocation! */ return ((void *) (tag + 1)); }
int mem_reset_ipc_link(struct mem_link_device *mld) { struct link_device *ld = &mld->link_dev; unsigned int magic; unsigned int access; int i; set_access(mld, 0); set_magic(mld, 0); reset_ipc_map(mld); for (i = 0; i < MAX_SIPC5_DEVICES; i++) { struct mem_ipc_device *dev = mld->dev[i]; skb_queue_purge(dev->skb_txq); atomic_set(&dev->txq.busy, 0); dev->req_ack_cnt[TX] = 0; skb_queue_purge(dev->skb_rxq); atomic_set(&dev->rxq.busy, 0); dev->req_ack_cnt[RX] = 0; } atomic_set(&ld->netif_stopped, 0); set_magic(mld, MEM_IPC_MAGIC); set_access(mld, 1); magic = get_magic(mld); access = get_access(mld); if (magic != MEM_IPC_MAGIC || access != 1) return -EACCES; return 0; }
int mem_reset_ipc_link(struct mem_link_device *mld) { struct link_device *ld = &mld->link_dev; unsigned int magic; unsigned int access; set_access(mld, 0); set_magic(mld, 0); reset_ipc_map(mld); reset_ipc_devices(mld); atomic_set(&ld->netif_stopped, 0); set_magic(mld, MEM_IPC_MAGIC); set_access(mld, 1); magic = get_magic(mld); access = get_access(mld); if (magic != MEM_IPC_MAGIC || access != 1) return -EACCES; return 0; }
static int dpram_init_ipc(struct dpram_link_device *dpld) { struct link_device *ld = &dpld->ld; int i; if (ld->mode == LINK_MODE_IPC && get_magic(dpld) == DPRAM_MAGIC_CODE && get_access(dpld) == 1) mif_info("%s: IPC already initialized\n", ld->name); /* Clear pointers in every circular queue */ for (i = 0; i < dpld->max_ipc_dev; i++) { set_tx_head(dpld, i, 0); set_tx_tail(dpld, i, 0); set_rx_head(dpld, i, 0); set_rx_tail(dpld, i, 0); } /* Initialize variables for efficient TX/RX processing */ for (i = 0; i < dpld->max_ipc_dev; i++) dpld->iod[i] = link_get_iod_with_format(ld, i); dpld->iod[IPC_RAW] = link_get_iod_with_format(ld, IPC_MULTI_RAW); if (dpld->iod[IPC_RAW]->recv_skb) dpld->use_skb = true; for (i = 0; i < dpld->max_ipc_dev; i++) { spin_lock_init(&dpld->tx_lock[i]); atomic_set(&dpld->res_required[i], 0); skb_queue_purge(&dpld->skb_rxq[i]); } /* Enable IPC */ atomic_set(&dpld->accessing, 0); set_magic(dpld, DPRAM_MAGIC_CODE); set_access(dpld, 1); if (get_magic(dpld) != DPRAM_MAGIC_CODE || get_access(dpld) != 1) return -EACCES; ld->mode = LINK_MODE_IPC; if (wake_lock_active(&dpld->wlock)) wake_unlock(&dpld->wlock); return 0; }
/** @brief function for the @b dload_start method in a link_device instance Set all flags and environments for CP binary download @param ld the pointer to a link_device instance @param iod the pointer to an io_device instance */ static int mem_start_download(struct link_device *ld, struct io_device *iod) { struct mem_link_device *mld = to_mem_link_device(ld); unsigned int magic; atomic_set(&mld->cp_boot_done, 0); reset_ipc_map(mld); reset_ipc_devices(mld); set_magic(mld, SHM_BOOT_MAGIC); magic = get_magic(mld); if (magic != SHM_BOOT_MAGIC) { mif_err("%s: ERR! magic 0x%08X != SHM_BOOT_MAGIC 0x%08X\n", ld->name, magic, SHM_BOOT_MAGIC); return -EFAULT; } return 0; }
void mem_handle_cp_crash(struct mem_link_device *mld, enum modem_state state) { struct link_device *ld = &mld->link_dev; struct modem_ctl *mc = ld->mc; #ifdef CONFIG_LINK_POWER_MANAGEMENT if (mld->stop_pm) mld->stop_pm(mld); #endif /* Disable normal IPC */ set_magic(mld, MEM_CRASH_MAGIC); set_access(mld, 0); stop_tx(mld); purge_txq(mld); if (cp_online(mc)) set_modem_state(mld, state); atomic_set(&mc->forced_cp_crash, 0); }
static int dpram_init_ipc(struct dpram_link_device *dpld) { struct link_device *ld = &dpld->ld; int i; if (ld->mode == LINK_MODE_IPC && get_magic(dpld) == DPRAM_MAGIC_CODE && get_access(dpld) == 1) mif_info("%s: IPC already initialized\n", ld->name); /* Clear pointers in every circular queue */ for (i = 0; i < dpld->max_ipc_dev; i++) { set_tx_head(dpld, i, 0); set_tx_tail(dpld, i, 0); set_rx_head(dpld, i, 0); set_rx_tail(dpld, i, 0); } for (i = 0; i < dpld->max_ipc_dev; i++) { spin_lock_init(&dpld->tx_lock[i]); atomic_set(&dpld->res_required[i], 0); } atomic_set(&dpld->accessing, 0); /* Enable IPC */ set_magic(dpld, DPRAM_MAGIC_CODE); set_access(dpld, 1); if (get_magic(dpld) != DPRAM_MAGIC_CODE || get_access(dpld) != 1) return -EACCES; ld->mode = LINK_MODE_IPC; if (wake_lock_active(&dpld->wlock)) wake_unlock(&dpld->wlock); return 0; }
void mem_handle_cp_crash(struct mem_link_device *mld, enum modem_state state) { struct link_device *ld = &mld->link_dev; struct modem_ctl *mc = ld->mc; int i; /* Disable normal IPC */ set_magic(mld, MEM_CRASH_MAGIC); set_access(mld, 0); if (!wake_lock_active(&mld->dump_wlock)) wake_lock(&mld->dump_wlock); stop_net_ifaces(ld); /* Purge the skb_txq in every IPC device (IPC_FMT, IPC_RAW, etc.) */ for (i = 0; i < MAX_SIPC5_DEV; i++) skb_queue_purge(mld->dev[i]->skb_txq); if (cp_online(mc)) set_modem_state(mld, state); mld->forced_cp_crash = false; }
/** * \brief Adds some magic points to the player. * * If the maximum value is reached, no more magic points are added. * * \param magic_to_add Number of magic points to add. * Must be positive of zero. */ void Equipment::add_magic(int magic_to_add) { Debug::check_assertion(magic_to_add >= 0, "Invalid magic amount to add"); set_magic(get_magic() + magic_to_add); }
void __declspec(dllexport) WINAPI _set_magic(long code, long param) { set_magic(code, param); }
struct link_device *dpram_create_link_device(struct platform_device *pdev) { struct modem_data *mdm_data = NULL; struct dpram_link_device *dpld = NULL; struct link_device *ld = NULL; struct resource *res = NULL; resource_size_t res_size; struct modemlink_dpram_control *dpctl = NULL; unsigned long task_data; int ret = 0; int i = 0; int bsize; int qsize; /* Get the platform data */ mdm_data = (struct modem_data *)pdev->dev.platform_data; if (!mdm_data) { mif_info("ERR! mdm_data == NULL\n"); goto err; } mif_info("modem = %s\n", mdm_data->name); mif_info("link device = %s\n", mdm_data->link_name); if (!mdm_data->dpram_ctl) { mif_info("ERR! mdm_data->dpram_ctl == NULL\n"); goto err; } dpctl = mdm_data->dpram_ctl; /* Alloc DPRAM link device structure */ dpld = kzalloc(sizeof(struct dpram_link_device), GFP_KERNEL); if (!dpld) { mif_info("ERR! kzalloc dpld fail\n"); goto err; } ld = &dpld->ld; task_data = (unsigned long)dpld; /* Retrieve modem data and DPRAM control data from the modem data */ ld->mdm_data = mdm_data; ld->name = mdm_data->link_name; ld->ipc_version = mdm_data->ipc_version; /* Retrieve the most basic data for IPC from the modem data */ dpld->dpctl = dpctl; dpld->dp_type = dpctl->dp_type; if (mdm_data->ipc_version < SIPC_VER_50) { if (!dpctl->max_ipc_dev) { mif_info("ERR! no max_ipc_dev\n"); goto err; } ld->aligned = dpctl->aligned; dpld->max_ipc_dev = dpctl->max_ipc_dev; } else { ld->aligned = 1; dpld->max_ipc_dev = MAX_SIPC5_DEV; } /* Set attributes as a link device */ ld->init_comm = dpram_link_init; ld->terminate_comm = dpram_link_terminate; ld->send = dpram_send; ld->force_dump = dpram_force_dump; ld->dump_start = dpram_dump_start; ld->dump_update = dpram_dump_update; ld->ioctl = dpram_ioctl; INIT_LIST_HEAD(&ld->list); skb_queue_head_init(&ld->sk_fmt_tx_q); skb_queue_head_init(&ld->sk_raw_tx_q); skb_queue_head_init(&ld->sk_rfs_tx_q); ld->skb_txq[IPC_FMT] = &ld->sk_fmt_tx_q; ld->skb_txq[IPC_RAW] = &ld->sk_raw_tx_q; ld->skb_txq[IPC_RFS] = &ld->sk_rfs_tx_q; /* Set up function pointers */ dpram_setup_common_op(dpld); dpld->dpram_dump = dpram_dump_memory; dpld->ext_op = dpram_get_ext_op(mdm_data->modem_type); /* Retrieve DPRAM resource */ if (!dpctl->dp_base) { res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { mif_info("%s: ERR! platform_get_resource fail\n", ld->name); goto err; } res_size = resource_size(res); dpctl->dp_base = ioremap_nocache(res->start, res_size); dpctl->dp_size = res_size; } dpld->dp_base = dpctl->dp_base; dpld->dp_size = dpctl->dp_size; mif_info("%s: dp_type %d, aligned %d, dp_base 0x%08X, dp_size %d\n", ld->name, dpld->dp_type, ld->aligned, (int)dpld->dp_base, dpld->dp_size); /* Initialize DPRAM map (physical map -> logical map) */ ret = dpram_table_init(dpld); if (ret < 0) { mif_info("%s: ERR! dpram_table_init fail (err %d)\n", ld->name, ret); goto err; } /* Disable IPC */ set_magic(dpld, 0); set_access(dpld, 0); dpld->dpram_init_status = DPRAM_INIT_STATE_NONE; /* Initialize locks, completions, and bottom halves */ snprintf(dpld->wlock_name, DP_MAX_NAME_LEN, "%s_wlock", ld->name); wake_lock_init(&dpld->wlock, WAKE_LOCK_SUSPEND, dpld->wlock_name); init_completion(&dpld->dpram_init_cmd); init_completion(&dpld->modem_pif_init_done); init_completion(&dpld->udl_start_complete); init_completion(&dpld->udl_cmd_complete); init_completion(&dpld->crash_start_complete); init_completion(&dpld->dump_start_complete); init_completion(&dpld->dump_recv_done); tasklet_init(&dpld->rx_tsk, dpram_ipc_rx_task, task_data); if (dpld->ext_op && dpld->ext_op->dl_task) tasklet_init(&dpld->dl_tsk, dpld->ext_op->dl_task, task_data); /* Prepare RXB queue */ qsize = DPRAM_MAX_RXBQ_SIZE; for (i = 0; i < dpld->max_ipc_dev; i++) { bsize = rxbq_get_page_size(get_rx_buff_size(dpld, i)); dpld->rxbq[i].size = qsize; dpld->rxbq[i].in = 0; dpld->rxbq[i].out = 0; dpld->rxbq[i].rxb = rxbq_create_pool(bsize, qsize); if (!dpld->rxbq[i].rxb) { mif_info("%s: ERR! %s rxbq_create_pool fail\n", ld->name, get_dev_name(i)); goto err; } mif_info("%s: %s rxbq_pool created (bsize:%d, qsize:%d)\n", ld->name, get_dev_name(i), bsize, qsize); } /* Prepare a multi-purpose miscellaneous buffer */ dpld->buff = kzalloc(dpld->dp_size, GFP_KERNEL); if (!dpld->buff) { mif_info("%s: ERR! kzalloc dpld->buff fail\n", ld->name); goto err; } /* Retrieve DPRAM IRQ GPIO# */ dpld->gpio_dpram_int = mdm_data->gpio_dpram_int; /* Retrieve DPRAM IRQ# */ if (!dpctl->dpram_irq) { dpctl->dpram_irq = platform_get_irq_byname(pdev, "dpram_irq"); if (dpctl->dpram_irq < 0) { mif_info("%s: ERR! platform_get_irq_byname fail\n", ld->name); goto err; } } dpld->irq = dpctl->dpram_irq; /* Retrieve DPRAM IRQ flags */ if (!dpctl->dpram_irq_flags) dpctl->dpram_irq_flags = (IRQF_NO_SUSPEND | IRQF_TRIGGER_LOW); dpld->irq_flags = dpctl->dpram_irq_flags; /* Register DPRAM interrupt handler */ snprintf(dpld->irq_name, DP_MAX_NAME_LEN, "%s_irq", ld->name); ret = dpram_register_isr(dpld->irq, dpram_irq_handler, dpld->irq_flags, dpld->irq_name, dpld); if (ret) goto err; return ld; err: if (dpld) { if (dpld->buff) kfree(dpld->buff); kfree(dpld); } return NULL; }
/** * \brief Removes some magic points from the player. * * If the number of magic points reaches zero, no more magic points * are removed. * * \param magic_to_remove Number of magic poits to remove. * Must be positive of zero. */ void Equipment::remove_magic(int magic_to_remove) { Debug::check_assertion(magic_to_remove >= 0, "Invalid magic amount to remove"); set_magic(get_magic() - magic_to_remove); }
/** @brief trigger an enforced CP crash @param mld the pointer to a mem_link_device instance */ void mem_forced_cp_crash(struct mem_link_device *mld) { struct link_device *ld = &mld->link_dev; struct modem_ctl *mc = ld->mc; unsigned long flags; bool duplicated = false; #ifdef DEBUG_MODEM_IF struct utc_time t; #endif #ifdef DEBUG_MODEM_IF get_utc_time(&t); #endif /* Disable normal IPC */ set_magic(mld, MEM_CRASH_MAGIC); set_access(mld, 0); spin_lock_irqsave(&mld->lock, flags); if (mld->forced_cp_crash) duplicated = true; else mld->forced_cp_crash = true; spin_unlock_irqrestore(&mld->lock, flags); if (duplicated) { #ifdef DEBUG_MODEM_IF evt_log(HMSU_FMT " %s: %s: ALREADY in progress <%pf>\n", t.hour, t.min, t.sec, t.us, CALLEE, ld->name, CALLER); #endif return; } if (!cp_online(mc)) { #ifdef DEBUG_MODEM_IF evt_log(HMSU_FMT " %s: %s: %s.state %s != ONLINE <%pf>\n", t.hour, t.min, t.sec, t.us, CALLEE, ld->name, mc->name, mc_state(mc), CALLER); #endif return; } if (!wake_lock_active(&mld->dump_wlock)) wake_lock(&mld->dump_wlock); stop_net_ifaces(ld); /** * If there is no CRASH_ACK from a CP in FORCE_CRASH_ACK_TIMEOUT, * handle_no_cp_crash_ack() will be executed. */ mif_add_timer(&mld->crash_ack_timer, FORCE_CRASH_ACK_TIMEOUT, handle_no_cp_crash_ack, (unsigned long)mld); /* Send CRASH_EXIT command to a CP */ send_ipc_irq(mld, cmd2int(CMD_CRASH_EXIT)); #ifdef DEBUG_MODEM_IF evt_log(HMSU_FMT " CRASH_EXIT: %s->%s: CP_CRASH_REQ <by %pf>\n", t.hour, t.min, t.sec, t.us, ld->name, mc->name, CALLER); if (in_interrupt()) queue_work(system_nrt_wq, &mld->dump_work); else save_mem_dump(mld); #endif }
/** * \brief Removes some magic points from the player. * * If the number of magic points reaches zero, no more magic points * are removed. * * \param magic_to_remove number of magic poits to remove */ void Equipment::remove_magic(int magic_to_remove) { set_magic(get_magic() - magic_to_remove); }
void mem_forced_cp_crash(struct mem_link_device *mld) { struct link_device *ld = &mld->link_dev; struct modem_ctl *mc = ld->mc; bool duplicated = false; unsigned long flags; /* Disable normal IPC */ set_magic(mld, MEM_CRASH_MAGIC); set_access(mld, 0); spin_lock_irqsave(&mld->lock, flags); if (atomic_read(&mc->forced_cp_crash)) duplicated = true; else atomic_set(&mc->forced_cp_crash, 1); spin_unlock_irqrestore(&mld->lock, flags); if (duplicated) { evt_log(0, "%s: %s: ALREADY in progress <%pf>\n", FUNC, ld->name, CALLER); return; } if (!cp_online(mc)) { evt_log(0, "%s: %s: %s.state %s != ONLINE <%pf>\n", FUNC, ld->name, mc->name, mc_state(mc), CALLER); return; } if (mc->wake_lock) { if (!wake_lock_active(mc->wake_lock)) { wake_lock(mc->wake_lock); mif_err("%s->wake_lock locked\n", mc->name); } } if (mld->attrs & LINK_ATTR(LINK_ATTR_MEM_DUMP)) { stop_net_ifaces(ld); if (mld->debug_info) mld->debug_info(); /** * If there is no CRASH_ACK from CP in a timeout, * handle_no_cp_crash_ack() will be executed. */ mif_add_timer(&mc->crash_ack_timer, FORCE_CRASH_ACK_TIMEOUT, handle_no_cp_crash_ack, (unsigned long)mld); /* Send CRASH_EXIT command to a CP */ send_ipc_irq(mld, cmd2int(CMD_CRASH_EXIT)); } else { modemctl_notify_event(MDM_EVENT_CP_FORCE_CRASH); } evt_log(0, "%s->%s: CP_CRASH_REQ <%pf>\n", ld->name, mc->name, CALLER); #ifdef DEBUG_MODEM_IF if (in_interrupt()) queue_work(system_nrt_wq, &mld->dump_work); else save_mem_dump(mld); #endif }
/** * \brief Restores all magic points. */ void Equipment::restore_all_magic() { set_magic(get_max_magic()); }
/** * \brief Adds some magic points to the player. * * If the maximum value is reached, no more magic points are added. * * \param magic_to_add number of magic points to add */ void Equipment::add_magic(int magic_to_add) { set_magic(get_magic() + magic_to_add); }