static int automount_serialize(Unit *u, FILE *f, FDSet *fds) { Automount *a = AUTOMOUNT(u); Iterator i; void *p; int r; assert(a); assert(f); assert(fds); unit_serialize_item(u, f, "state", automount_state_to_string(a->state)); unit_serialize_item(u, f, "result", automount_result_to_string(a->result)); unit_serialize_item_format(u, f, "dev-id", "%u", (unsigned) a->dev_id); SET_FOREACH(p, a->tokens, i) unit_serialize_item_format(u, f, "token", "%u", PTR_TO_UINT(p)); SET_FOREACH(p, a->expire_tokens, i) unit_serialize_item_format(u, f, "expire-token", "%u", PTR_TO_UINT(p)); r = unit_serialize_item_fd(u, f, fds, "pipe-fd", a->pipe_fd); if (r < 0) return r; return 0; }
static int automount_serialize(Unit *u, FILE *f, FDSet *fds) { Automount *a = AUTOMOUNT(u); void *p; Iterator i; assert(a); assert(f); assert(fds); unit_serialize_item(u, f, "state", automount_state_to_string(a->state)); unit_serialize_item(u, f, "result", automount_result_to_string(a->result)); unit_serialize_item_format(u, f, "dev-id", "%u", (unsigned) a->dev_id); SET_FOREACH(p, a->tokens, i) unit_serialize_item_format(u, f, "token", "%u", PTR_TO_UINT(p)); SET_FOREACH(p, a->expire_tokens, i) unit_serialize_item_format(u, f, "expire-token", "%u", PTR_TO_UINT(p)); if (a->pipe_fd >= 0) { int copy; copy = fdset_put_dup(fds, a->pipe_fd); if (copy < 0) return copy; unit_serialize_item_format(u, f, "pipe-fd", "%i", copy); } return 0; }
static bool match_notify_index(const void *a, const void *b) { const struct mgmt_notify *notify = a; uint16_t index = PTR_TO_UINT(b); return notify->index == index; }
static bool match_request_index(const void *a, const void *b) { const struct mgmt_request *request = a; uint16_t index = PTR_TO_UINT(b); return request->index == index; }
static bool find_pending(const void *a, const void *b) { const struct pending_read *p = a; unsigned int id = PTR_TO_UINT(b); return p->id == id; }
static bool match_service_handle(const void *a, const void *b) { const struct service *service = a; uint16_t start_handle = PTR_TO_UINT(b); return service->start_handle == start_handle; }
static bool match_evt_id(const void *a, const void *b) { const struct evt *evt = a; unsigned int id = PTR_TO_UINT(b); return evt->id == id; }
static bool match_cmd_id(const void *a, const void *b) { const struct cmd *cmd = a; unsigned int id = PTR_TO_UINT(b); return cmd->id == id; }
static bool match_cmd_opcode(const void *a, const void *b) { const struct cmd *cmd = a; uint16_t opcode = PTR_TO_UINT(b); return cmd->opcode == opcode; }
static void cancel_gatt_req(void *data, void *user_data) { unsigned int id = PTR_TO_UINT(data); struct bt_scpp *scan = user_data; g_attrib_cancel(scan->attrib, id); }
static bool find_with_org_id(const void *data, const void *user_data) { const struct id_pair *p = data; unsigned int orig_id = PTR_TO_UINT(user_data); return (p->org_id == orig_id); }
static void test_unsigned(void) { unsigned buffer[SET_SIZE], i; Prioq *q; srand(0); q = prioq_new(trivial_compare_func); assert_se(q); for (i = 0; i < ELEMENTSOF(buffer); i++) { unsigned u; u = (unsigned) rand(); buffer[i] = u; assert_se(prioq_put(q, UINT_TO_PTR(u), NULL) >= 0); } qsort(buffer, ELEMENTSOF(buffer), sizeof(buffer[0]), unsigned_compare); for (i = 0; i < ELEMENTSOF(buffer); i++) { unsigned u; assert_se(prioq_size(q) == ELEMENTSOF(buffer) - i); u = PTR_TO_UINT(prioq_pop(q)); assert_se(buffer[i] == u); } assert_se(prioq_isempty(q)); prioq_free(q); }
static bool match_request_id(const void *a, const void *b) { const struct mgmt_request *request = a; unsigned int id = PTR_TO_UINT(b); return request->id == id; }
static bool dev_match_index(const void *a, const void *b) { const struct hci_dev *dev = a; uint16_t index = PTR_TO_UINT(b); return dev->index == index; }
static void shutdown_complete(const void *data, uint8_t size, void *user_data) { unsigned int id = PTR_TO_UINT(user_data); timeout_remove(id); mainloop_quit(); }
static bool match_notify_id(const void *a, const void *b) { const struct notify *notify = a; unsigned int id = PTR_TO_UINT(b); return notify->id == id; }
static bool match_disconn_id(const void *a, const void *b) { const struct att_disconn *disconn = a; unsigned int id = PTR_TO_UINT(b); return disconn->id == id; }
static bool match_op_id(const void *a, const void *b) { const struct att_send_op *op = a; unsigned int id = PTR_TO_UINT(b); return op->id == id; }
static void mark_notify_removed(void *data , void *user_data) { struct mgmt_notify *notify = data; uint16_t index = PTR_TO_UINT(user_data); if (notify->index == index || index == MGMT_INDEX_NONE) notify->removed = true; }
static bool find_service_for_handle(const void *data, const void *user_data) { const struct gatt_db_service *service = data; uint16_t handle = PTR_TO_UINT(user_data); uint16_t start, end; gatt_db_service_get_handles(service, &start, &end); return (start <= handle) && (handle <= end); }
static size_t TABLE_CELL_TO_INDEX(TableCell *cell) { unsigned i; assert(cell); i = PTR_TO_UINT(cell); assert(i > 0); return i-1; }
static bool kill_one(pink_easy_process_t *proc, void *userdata) { pid_t pid = pink_easy_process_get_pid(proc); if (PTR_TO_UINT(userdata)) warning("killing process:%lu", (unsigned long)pid); else fprintf(stderr, "killing process:%lu\n", (unsigned long)pid); if (pink_easy_process_kill(proc, SIGKILL) < 0 && errno != ESRCH) { if (PTR_TO_UINT(userdata)) warning("failed to kill process:%lu (errno:%d %s)", (unsigned long)pid, errno, strerror(errno)); else fprintf(stderr, "failed to kill process:%lu (errno:%d %s)\n", (unsigned long)pid, errno, strerror(errno)); } return true; }
static bool cont_one(pink_easy_process_t *proc, void *userdata) { pid_t pid = pink_easy_process_get_pid(proc); if (PTR_TO_UINT(userdata)) warning("resuming process:%lu", (unsigned long)pid); else fprintf(stderr, "resuming process:%lu\n", (unsigned long)pid); if (!pink_easy_process_resume(proc, 0) && errno != ESRCH) { if (PTR_TO_UINT(userdata)) warning("failed to resume process:%lu (errno:%d %s)", (unsigned long)pid, errno, strerror(errno)); else fprintf(stderr, "failed to resume process:%lu (errno:%d %s)\n", (unsigned long)pid, errno, strerror(errno)); } return true; }
/******************************************************************************* ** ** Function hidh_proc_repage_timeout ** ** Description This function handles timeout (to page device). ** ** Returns void ** *******************************************************************************/ void hidh_proc_repage_timeout (TIMER_LIST_ENT *p_tle) { tHID_HOST_DEV_CTB *device; UINT8 dhandle = PTR_TO_UINT(p_tle->param); hidh_conn_initiate(dhandle); device = &hh_cb.devices[dhandle]; device->conn_tries++; hh_cb.callback(dhandle, device->addr, HID_HDEV_EVT_RETRYING, device->conn_tries, NULL ) ; }
/******************************************************************************* ** ** Function hidh_sec_check_complete_orig ** ** Description This function checks to see if security procedures are being ** carried out or not.. ** ** Returns void ** *******************************************************************************/ void hidh_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_data, UINT8 res) { tHID_HOST_DEV_CTB *p_dev = (tHID_HOST_DEV_CTB *) p_ref_data; UINT8 dhandle; UNUSED(bd_addr); UNUSED (transport); // TODO(armansito): This kind of math to determine a device handle is way // too dirty and unnecessary. Why can't |p_dev| store it's handle? dhandle = (PTR_TO_UINT(p_dev) - PTR_TO_UINT(&(hh_cb.devices[0])))/ sizeof(tHID_HOST_DEV_CTB); if( res == BTM_SUCCESS && p_dev->conn.conn_state == HID_CONN_STATE_SECURITY ) { HIDH_TRACE_EVENT ("HID-Host Originator security pass."); p_dev->conn.disc_reason = HID_SUCCESS; /* Authentication passed. Reset disc_reason (from HID_ERR_AUTH_FAILED) */ /* Transition to the next appropriate state, configuration */ p_dev->conn.conn_state = HID_CONN_STATE_CONFIG; L2CA_ConfigReq (p_dev->conn.ctrl_cid, &hh_cb.l2cap_cfg); HIDH_TRACE_EVENT ("HID-Host Got Control conn cnf, sent cfg req, CID: 0x%x", p_dev->conn.ctrl_cid); } if( res != BTM_SUCCESS && p_dev->conn.conn_state == HID_CONN_STATE_SECURITY ) { #if (HID_HOST_MAX_CONN_RETRY > 0) if( res == BTM_DEVICE_TIMEOUT ) { if( p_dev->conn_tries <= HID_HOST_MAX_CONN_RETRY ) { hidh_conn_retry (dhandle); return; } } #endif p_dev->conn.disc_reason = HID_ERR_AUTH_FAILED; /* Save reason for disconnecting */ hidh_conn_disconnect(dhandle); } }
static int value_handler(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { _cleanup_free_ char *s = NULL; const char *x; int r; assert_se(asprintf(&s, "object %p, path %s", userdata, path) >= 0); r = sd_bus_message_append(reply, "s", s); assert_se(r >= 0); assert_se(x = startswith(path, "/value/")); assert_se(PTR_TO_UINT(userdata) == 30); return 1; }
int automount_send_ready(Automount *a, int status) { int ioctl_fd, r; unsigned token; assert(a); assert(status <= 0); if (set_isempty(a->tokens)) return 0; ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id); if (ioctl_fd < 0) { r = ioctl_fd; goto fail; } if (status) log_debug_unit(UNIT(a)->id, "Sending failure: %s", strerror(-status)); else log_debug_unit(UNIT(a)->id, "Sending success."); r = 0; /* Autofs thankfully does not hand out 0 as a token */ while ((token = PTR_TO_UINT(set_steal_first(a->tokens)))) { int k; /* Autofs fun fact II: * * if you pass a positive status code here, the kernel will * freeze! Yay! */ k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd, ioctl_fd, token, status); if (k < 0) r = k; } fail: if (ioctl_fd >= 0) close_nointr_nofail(ioctl_fd); return r; }
static int automount_send_ready(Automount *a, Set *tokens, int status) { _cleanup_close_ int ioctl_fd = -1; unsigned token; int r; assert(a); assert(status <= 0); if (set_isempty(tokens)) return 0; ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id); if (ioctl_fd < 0) return ioctl_fd; if (status != 0) log_unit_debug_errno(UNIT(a), status, "Sending failure: %m"); else log_unit_debug(UNIT(a), "Sending success."); r = 0; /* Autofs thankfully does not hand out 0 as a token */ while ((token = PTR_TO_UINT(set_steal_first(tokens)))) { int k; /* Autofs fun fact II: * * if you pass a positive status code here, the kernel will * freeze! Yay! */ k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd, ioctl_fd, token, status); if (k < 0) r = k; } return r; }
t_Error PrsInit(t_FmPcd *p_FmPcd) { t_FmPcdDriverParam *p_Param = p_FmPcd->p_FmPcdDriverParam; t_FmPcdPrsRegs *p_Regs = p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs; uint32_t tmpReg; if(p_FmPcd->guestId != NCSW_MASTER_ID) return E_OK; ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID); #ifdef FM_PRS_MEM_ERRATA_FMAN_SW003 { uint32_t i; uint32_t regsToGlobalOffset = 0x840; uint32_t firstPortToGlobalOffset = 0x45800; uint64_t globalAddr = PTR_TO_UINT(p_Regs) - regsToGlobalOffset; uint32_t firstPortAddr = (uint32_t)(globalAddr - (uint64_t)firstPortToGlobalOffset); uint32_t portSize = 0x1000; t_FmRevisionInfo revInfo; FM_GetRevision(p_FmPcd->h_Fm, &revInfo); if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0)) { /* clear all parser memory */ IOMemSet32(UINT_TO_PTR(globalAddr), 0x00000000, 0x800); for(i = 0;i<16;i++) IOMemSet32(UINT_TO_PTR(firstPortAddr+i*portSize), (uint8_t)0x00000000, (uint32_t)0x80); } } #endif /* FM_PRS_MEM_ERRATA_FMAN_SW003 */ /**********************RPCLIM******************/ WRITE_UINT32(p_Regs->rpclim, (uint32_t)p_Param->prsMaxParseCycleLimit); /**********************FMPL_RPCLIM******************/ /* register even if no interrupts enabled, to allow future enablement */ FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_ERR, PcdPrsErrorException, p_FmPcd); /* register even if no interrupts enabled, to allow future enablement */ FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_NORMAL, PcdPrsException, p_FmPcd); /**********************PEVR******************/ WRITE_UINT32(p_Regs->pevr, (FM_PCD_PRS_SINGLE_ECC | FM_PCD_PRS_PORT_IDLE_STS) ); /**********************PEVR******************/ /**********************PEVER******************/ if(p_FmPcd->exceptions & FM_PCD_EX_PRS_SINGLE_ECC) { FmEnableRamsEcc(p_FmPcd->h_Fm); WRITE_UINT32(p_Regs->pever, FM_PCD_PRS_SINGLE_ECC); } else WRITE_UINT32(p_Regs->pever, 0); /**********************PEVER******************/ /**********************PERR******************/ WRITE_UINT32(p_Regs->perr, FM_PCD_PRS_DOUBLE_ECC); /**********************PERR******************/ /**********************PERER******************/ tmpReg = 0; if(p_FmPcd->exceptions & FM_PCD_EX_PRS_DOUBLE_ECC) { FmEnableRamsEcc(p_FmPcd->h_Fm); tmpReg |= FM_PCD_PRS_DOUBLE_ECC; } WRITE_UINT32(p_Regs->perer, tmpReg); /**********************PERER******************/ /**********************PPCS******************/ WRITE_UINT32(p_Regs->ppsc, p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics); /**********************PPCS******************/ #ifdef FM_PRS_L4_SHELL_ERRATA_FMANb { uint32_t i, j; t_FmRevisionInfo revInfo; uint8_t swPrsL4Patch[] = SW_PRS_L4_PATCH; FM_GetRevision(p_FmPcd->h_Fm, &revInfo); if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0)) { /* load sw parser L4 patch */ for(i=0;i<sizeof(swPrsL4Patch)/4;i++) { tmpReg = 0; for(j =0;j<4;j++) { tmpReg <<= 8; tmpReg |= swPrsL4Patch[i*4+j]; } WRITE_UINT32(*(p_FmPcd->p_FmPcdPrs->p_SwPrsCode+ FM_PCD_PRS_SW_OFFSET/4 + i), tmpReg); } p_FmPcd->p_FmPcdPrs->p_CurrSwPrs = FM_PCD_PRS_SW_OFFSET/4 + p_FmPcd->p_FmPcdPrs->p_SwPrsCode+sizeof(swPrsL4Patch)/4; } } #endif /* FM_PRS_L4_SHELL_ERRATA_FMANb */ return E_OK; }
static int handle_compare(void *key1, void *key2) { return PTR_TO_UINT(key1) != PTR_TO_UINT(key2); }