static int iconv_xlat16_open(struct iconv_converter_class *dcp, struct iconv_cspair *csp, struct iconv_cspair *cspf, void **dpp) { struct iconv_xlat16 *dp; uint32_t *headp, **idxp; int i; dp = (struct iconv_xlat16 *)kobj_create((struct kobj_class*)dcp, M_ICONV, M_WAITOK); headp = (uint32_t *)((caddr_t)csp->cp_data + sizeof(dp->d_table)); idxp = (uint32_t **)csp->cp_data; for (i = 0 ; i < 0x200 ; i++) { if (*idxp) { dp->d_table[i] = headp; headp += 0x80; } else { dp->d_table[i] = NULL; } idxp++; } if (strcmp(csp->cp_to, KICONV_WCTYPE_NAME) != 0) { if (iconv_open(KICONV_WCTYPE_NAME, csp->cp_from, &dp->f_ctp) != 0) dp->f_ctp = NULL; if (iconv_open(KICONV_WCTYPE_NAME, csp->cp_to, &dp->t_ctp) != 0) dp->t_ctp = NULL; } else { dp->f_ctp = dp->t_ctp = dp; } dp->d_csp = csp; csp->cp_refcount++; *dpp = (void*)dp; return (0); }
static int iconv_xlat16_open(struct iconv_converter_class *dcp, struct iconv_cspair *csp, struct iconv_cspair *cspf, void **dpp) { struct iconv_xlat16 *dp; uint32_t *headp, *idxp, dist = 0; int i; dp = (struct iconv_xlat16 *)kobj_create((struct kobj_class*)dcp, M_ICONV, M_WAITOK); headp = idxp = (uint32_t *)csp->cp_data; dist = 0x200; for (i = 0 ; i < 0x200 ; i++) { if (*idxp) { dp->d_table[i] = headp + dist; dist += 0x80; } else { dp->d_table[i] = NULL; } idxp++; } dp->d_csp = csp; csp->cp_refcount++; *dpp = (void*)dp; return (0); }
static void eficlock_create(void *arg) { kobj_t clock; clock = (kobj_t) kobj_create(&eficlock_class, M_TEMP, M_NOWAIT); clockattach(clock); }
static int iconv_ucs_open(struct iconv_converter_class *dcp, struct iconv_cspair *csp, struct iconv_cspair *cspf, void **dpp) { struct iconv_ucs *dp; int i; const char *from, *to; dp = (struct iconv_ucs *)kobj_create((struct kobj_class*)dcp, M_ICONV, M_WAITOK); to = csp->cp_to; from = cspf ? cspf->cp_from : csp->cp_from; dp->convtype = 0; if (cspf) dp->convtype |= KICONV_UCS_COMBINE; for (i = 0; unicode_family[i].name; i++) { if (strcmp(from, unicode_family[i].name) == 0) dp->convtype |= unicode_family[i].from_flag; if (strcmp(to, unicode_family[i].name) == 0) dp->convtype |= unicode_family[i].to_flag; } if (strcmp(ENCODING_UNICODE, ENCODING_UTF16) == 0) dp->convtype |= KICONV_UCS_UCS4; else dp->convtype &= ~KICONV_UCS_UCS4; dp->f_ctp = dp->t_ctp = NULL; if (dp->convtype & KICONV_UCS_COMBINE) { if ((dp->convtype & KICONV_UCS_FROM_UTF8) == 0 && (dp->convtype & KICONV_UCS_FROM_LE) == 0) { iconv_open(ENCODING_UNICODE, from, &dp->f_ctp); } if ((dp->convtype & KICONV_UCS_TO_UTF8) == 0 && (dp->convtype & KICONV_UCS_TO_LE) == 0) { iconv_open(to, ENCODING_UNICODE, &dp->t_ctp); } } dp->ctype = NULL; if (dp->convtype & (KICONV_UCS_FROM_UTF8 | KICONV_UCS_TO_UTF8)) iconv_open(KICONV_WCTYPE_NAME, ENCODING_UTF8, &dp->ctype); dp->d_csp = csp; if (dp->convtype & (KICONV_UCS_FROM_UTF8 | KICONV_UCS_FROM_LE)) { if (cspf) { dp->d_cspf = cspf; cspf->cp_refcount++; } else csp->cp_refcount++; } if (dp->convtype & (KICONV_UCS_TO_UTF8 | KICONV_UCS_TO_LE)) csp->cp_refcount++; *dpp = (void*)dp; return 0; }
static int iconv_xlat_open(struct iconv_converter_class *dcp, struct iconv_cspair *csp, struct iconv_cspair *cspf, void **dpp) { struct iconv_xlat *dp; dp = (struct iconv_xlat *)kobj_create((struct kobj_class*)dcp, M_ICONV, M_WAITOK); dp->d_table = csp->cp_data; dp->d_csp = csp; csp->cp_refcount++; *dpp = (void*)dp; return 0; }
/** * Allocate and return a new device enumeration table parser. * * @param cls The parser class for which an instance will be * allocated. * @param parent The parent device from which EROM resources should * be allocated. * @param rid The resource ID to be used when allocating EROM * resources. * @param cid The device's chip identifier. * * @retval non-NULL success * @retval NULL if an error occured allocating or initializing the * EROM parser. */ bhnd_erom_t * bhnd_erom_alloc(bhnd_erom_class_t *cls, const struct bhnd_chipid *cid, device_t parent, int rid) { bhnd_erom_t *erom; int error; erom = (bhnd_erom_t *)kobj_create((kobj_class_t)cls, M_BHND, M_WAITOK|M_ZERO); if ((error = BHND_EROM_INIT(erom, cid, parent, rid))) { printf("error initializing %s parser at %#jx with " "rid %d: %d\n", cls->name, (uintmax_t)cid->enum_addr, rid, error); kobj_delete((kobj_t)erom, M_BHND); return (NULL); } return (erom); }