Example #1
0
/**
 * Gets a sorted string representation of the alleles of a variant.
 */
void bcf_alleles2string_sorted(bcf_hdr_t *h, bcf1_t *v, kstring_t *var)
{
    bcf_unpack(v, BCF_UN_STR);
    var->l = 0;
    
    if (v->n_allele==2)
    {
        kputs(bcf_get_alt(v, 0), var);
        kputc(',', var);
        kputs(bcf_get_alt(v, 1), var);
    }
    else
    {
        char** allele = bcf_get_allele(v);
        char** temp = (char**) malloc((bcf_get_n_allele(v)-1)*sizeof(char*));
        for (int32_t i=1; i<v->n_allele; ++i)
        {
            temp[i-1] = allele[i];
        }
        
        std::qsort(temp, bcf_get_n_allele(v)-1, sizeof(char*), cmpstr);
        
        kputs(bcf_get_alt(v, 0), var);
        for (int32_t i=0; i<v->n_allele-1; ++i)
        {
            kputc(',', var);
            kputs(temp[i], var);
        }
        
        free(temp);
    }
}
Example #2
0
/**
 * Reads header of a VCF file and returns the bcf header object.
 * This wraps around vcf_hdr_read from the original htslib to
 * allow for an alternative header file to be read in.
 *
 * this searches for the alternative header saved as <filename>.hdr
 */
bcf_hdr_t *bcf_alt_hdr_read(htsFile *fp)
{
    bcf_hdr_t *h = NULL;

    //check for existence of alternative header
    kstring_t alt_hdr_fn = {0, 0, 0};
    kputs(fp->fn, &alt_hdr_fn);
    kputs(".hdr", &alt_hdr_fn);
    FILE *file = fopen(alt_hdr_fn.s, "r");
    if (!file)
    {
        h = bcf_hdr_read(fp);
    }
    else
    {
        fprintf(stderr, "[I:%s:%d %s] read alternative header for %s\n", __FILE__, __LINE__, __FUNCTION__, fp->fn);
        fclose(file);
        htsFile *alt_hdr = hts_open(alt_hdr_fn.s, "r");
        h = bcf_hdr_read(alt_hdr);
        hts_close(alt_hdr);
    
        //helps move the pointer to the right place
        bcf_hdr_t *temp_h = bcf_hdr_read(fp);
        bcf_hdr_destroy(temp_h);
    }

    if (alt_hdr_fn.m) free(alt_hdr_fn.s);
    return h;
}
Example #3
0
// Expands a output filename format string
static char* expand_format_string(const char* format_string, const char* basename, const char* rg_id, const int rg_idx)
{
    kstring_t str = { 0, 0, NULL };
    const char* pointer = format_string;
    const char* next;
    while ((next = strchr(pointer, '%')) != NULL) {
        kputsn(pointer, next-pointer, &str);
        ++next;
        switch (*next) {
        case '%':
            kputc('%', &str);
            break;
        case '*':
            kputs(basename, &str);
            break;
        case '#':
            kputl(rg_idx, &str);
            break;
        case '!':
            kputs(rg_id, &str);
            break;
        case '\0':
            // Error is: fprintf(pysamerr, "bad format string, trailing %%\n");
            free(str.s);
            return NULL;
        default:
            // Error is: fprintf(pysamerr, "bad format string, unknown format specifier\n");
            free(str.s);
            return NULL;
        }
        pointer = next + 1;
    }
    kputs(pointer, &str);
    return ks_release(&str);
}
Example #4
0
File: variant.cpp Project: atks/vt
/**
 * Updates a bcf1_t object with VNTR information.
 */
void Variant::update_bcf_with_vntr_info(bcf_hdr_t *h, bcf1_t *v)
{
    bcf_update_info_flag(h, v, "FUZZY", NULL, 1);

    //VNTR position and sequences
    bcf_set_pos1(v, vntr.fuzzy_beg1);
    kstring_t s = {0,0,0};
    s.l = 0;
    kputs(vntr.fuzzy_repeat_tract.c_str(), &s);
    kputc(',', &s);
    kputs("<VNTR>", &s);
    bcf_update_alleles_str(h, v, s.s);

    //VNTR motif
    bcf_update_info_string(h, v, "MOTIF", vntr.motif.c_str());
    bcf_update_info_string(h, v, "RU", vntr.ru.c_str());

    //VNTR characteristics
    bcf_update_info_float(h, v, "FZ_CONCORDANCE", &vntr.fuzzy_score, 1);
    bcf_update_info_float(h, v, "FZ_RL", &vntr.fuzzy_rl, 1);
    bcf_update_info_float(h, v, "FZ_LL", &vntr.fuzzy_ll, 1);
    int32_t flank_pos1[2] = {vntr.exact_beg1-1, vntr.exact_end1+1};
    bcf_update_info_int32(h, v, "FLANKS", &flank_pos1, 2);

    //flank positions
    int32_t fuzzy_flank_pos1[2] = {vntr.fuzzy_beg1-1, vntr.fuzzy_end1+1};
    bcf_update_info_int32(h, v, "FZ_FLANKS", &fuzzy_flank_pos1, 2);
    int32_t ru_count[2] = {vntr.fuzzy_no_perfect_ru, vntr.fuzzy_no_ru};
    bcf_update_info_int32(h, v, "FZ_RU_COUNTS", &ru_count, 2);

    if (vntr.is_large_repeat_tract) bcf_update_info_flag(h, v, "LARGE_REPEAT_REGION", NULL, 1);

    if (s.m) free(s.s);
}
Example #5
0
ptptr getproc(void)
{
	ptptr p = udata.u_ptab;

#ifdef DEBUGREALLYHARD
	kputs("getproc(");
	if (udata.u_ininterrupt)
		kputs("[IRQ]");
#endif
	while (1) {
		switch (p->p_status) {
		case P_ZOMBIE:
			/* If we died go to our parent */
#ifdef DEBUGREALLYHARD
			kprintf("Zombie: move from %x to %x\n", p,
				p->p_pptr);
#endif
			p = p->p_pptr;
		case P_READY:
			/* If we are ready run us */
			p->p_status = P_RUNNING;
		case P_RUNNING:
			/* If we are running keep running */
#ifdef DEBUGREALLYHARD
			kprintf("%x:%s:%d)\n", p, p->p_name, p->p_page);
#endif
			return p;
		default:
			/* Wait for an I/O operation to let us run, don't run
			   other tasks */
			ei();
			platform_idle();
		}
	}
}
Example #6
0
void pagemap_init(void)
{
	int i;

	/* RC2014 512/512K has RAM in the top 512 KiB of physical memory
	 * corresponding pages are 32-63 (page size is 16 KiB)
	 * Pages 32-34 are used by the kernel
	 * Page 35 is the common area for init
	 * Page 36 is the disk cache
	 * Pages 37 amd 38 are the second kernel bank
	 */
	for (i = 32 + 7; i < 64; i++)
		pagemap_add(i);

	/* finally add the common area */
	pagemap_add(32 + 3);

	ds1302_init();

	if (acia_present)
		kputs("6850 ACIA detected at 0x80.\n");
	if (sio_present)
		kputs("Z80 SIO detected at 0x80.\n");
	if (sio1_present)
		kputs("Z80 SIO detected at 0x84.\n");
	if (ctc_present)
		kputs("Z80 CTC detected at 0x88.\n");
	if (ds1302_present)
		kputs("DS1302 detected at 0xC0.\n");
}
Example #7
0
File: kinit.c Project: Zeke-OS/zeke
/**
 * Run all kernel module initializers.
 */
void exec_init_array(void)
{
    extern void dyndebug_early_boot_init(void);
    extern void kmem_init(void);
    extern void dynmem_init(void);
    extern void vralloc_init(void);
    int n;

#ifdef configDYNDEBUG
    dyndebug_early_boot_init();
#endif

    kputs("\n\nZeKe PreInit\n");
    n = __hw_preinit_array_end - __hw_preinit_array_start;
    exec_array(__hw_preinit_array_start, n);

    /*
     * Memory allocator initializers.
     */
    kmem_init();
    dynmem_init();
    vralloc_init();

    kputs("SubsysInit\n");
    n  = __init_array_end - __init_array_start;
    exec_array(__init_array_start, n);

    kputs("PostInit\n");
    disable_interrupt();
    n = __hw_postinit_array_end - __hw_postinit_array_start;
    exec_array(__hw_postinit_array_start, n);
    enable_interrupt();
}
Example #8
0
static void initVCMem()
{
	VCPROPS props;
	if (!vcPropsAlloc(&props, 256))
	{
		kputs("Cannot allocate VCProps buffer!\n");
		return;
	}

	vu32* tag = vcPropsAddTag(&props, VCTag_GetVCMem, 0, 2*4);

	if (!vcPropsExecute(&props))
	{
		vcPropsFree(&props);
		kputs("Mailbox request error!\n");
		return;
	}

	u32 vcMemStart = tag[0];
	u32 vcMemSize = tag[1];
	vcPropsFree(&props);

	int startIdx = L1_INDEX(phys2virt(vcMemStart));
	int endIdx = startIdx + (vcMemSize>>20);
	u32 curPos = vcMemStart - BIT(20);
	int i;
	for (i = startIdx; i < endIdx; i ++)
		MASTER_PAGETABLE[i] = MMU_L1_SECT1MB | (curPos+=BIT(20)) | MMU_L1_RWNA | MMU_L1_UNCACHED;

	kprintf("VC memory @ addr %p (%u bytes)\n", vcMemStart, vcMemSize);
}
static int
cmd_head(int argc, char** argv)
{
	debugger_command_pipe_segment* segment
		= get_current_debugger_command_pipe_segment();
	if (segment == NULL) {
		kprintf_unfiltered("%s can only be run as part of a pipe!\n", argv[0]);
		return B_KDEBUG_ERROR;
	}

	struct user_data {
		uint64	max_lines;
		uint64	lines;
	};
	user_data* userData = (user_data*)segment->user_data;

	if (segment->invocations == 0) {
		if (argc != 3) {
			print_debugger_command_usage(argv[0]);
			return B_KDEBUG_ERROR;
		}

		if (!evaluate_debug_expression(argv[1], &userData->max_lines, false))
			return B_KDEBUG_ERROR;
		userData->lines = 0;
	}

	if (++userData->lines <= userData->max_lines) {
		kputs(argv[2]);
		kputs("\n");
	}

	return 0;
}
Example #10
0
bool ConsoleDrv::Init()
{
	m_fb = KFramebuffer::From(DevGet("fb"));
	if (!m_fb)
	{
		kputs("<ConsoleDrv> Cannot open framebuffer!\n");
		return false;
	}
	if (m_fb->GetInfo(m_fbInfo) < 0)
	{
		kputs("<ConsoleDrv> Cannot retrieve framebuffer properties!\n");
		return false;
	}

	size_t dummy;
	if (DevGetMem(m_fb, m_conFb, dummy) < 0)
	{
		kputs("<ConsoleDrv> Cannot obtain framebuffer memory!\n");
		return false;
	}

	m_conW = m_fbInfo.width / FONT_CHARW;
	m_conH = m_fbInfo.height / FONT_CHARH;
	kprintf("<ConsoleDrv> Setting up %dx%d console...\n", m_conW, m_conH);

	return true;
}
Example #11
0
static int set_sample_pairs(char **samples, int nsamples, kstring_t *hdr, int idx)
{
    int i, j, n;

    // Are these samples "old-name new-name" pairs?
    void *hash = khash_str2str_init();
    for (i=0; i<nsamples; i++)
    {
        char *key, *value;
        key = value = samples[i];
        while ( *value && !isspace(*value) ) value++;
        if ( !*value ) break;
        *value = 0; value++;
        while ( isspace(*value) ) value++;
        khash_str2str_set(hash,key,value);
    }
    if ( i!=nsamples )  // not "old-name new-name" pairs
    {
        khash_str2str_destroy(hash);
        return 0;
    }

    while ( hdr->l>0 && isspace(hdr->s[hdr->l-1]) ) hdr->l--;  // remove trailing newlines
    hdr->s[hdr->l] = 0;

    kstring_t tmp = {0,0,0};
    i = j = n = 0;
    while ( hdr->s[idx+i] && hdr->s[idx+i])
    {
        if ( hdr->s[idx+i]=='\t' )
        {
            hdr->s[idx+i] = 0;

            if ( ++n>9 )
            {
                char *ori = khash_str2str_get(hash,hdr->s+idx+j);
                kputs(ori ? ori : hdr->s+idx+j, &tmp);
            }
            else
                kputs(hdr->s+idx+j, &tmp);

            kputc('\t',&tmp);

            j = ++i;
            continue;
        }
        i++;
    }
    char *ori = khash_str2str_get(hash,hdr->s+idx+j);
    kputs(ori ? ori : hdr->s+idx+j, &tmp);

    if ( hash ) khash_str2str_destroy(hash);

    hdr->l = idx;
    kputs(tmp.s, hdr);
    kputc('\n', hdr);
    free(tmp.s);

    return 1;
}
Example #12
0
int main(void){
    trap_init();
    kputs("Hello kern MAIN!!\n");
    smp_startup();
    kputs("smp_startup end\n");
    RTC_MAIN();
    for(;;);
}
Example #13
0
meth_obs1_v *methbed_get_chrom1(methbed_t *in) {

  meth_obs1_v *obs=init_meth_obs1_v(10000);
  meth_obs1_t *ob = try_next_meth_obs1_v(obs);

  in->chrm = 0;
  if (in->nextchrom.l) {        /* get next object from last run */
    *ob = in->next;
    commit_next_meth_obs1_v(obs);
    ob = try_next_meth_obs1_v(obs);
    in->chrm = strdup(in->nextchrom.s); /* record current chrom once */
  }

  char ch[1000];
  kstring_t str;
  str.s = 0; str.l = str.m = 0;

  int i=0;
  while (1) {
    int c=gzgetc(in->FH);
    if (c=='\n' || c==EOF) {

      if (in->chrm && i%100000==0) {
        fprintf(stderr, "\r[%s:%d] %s\t%d\t%zu\033[K", __func__, __LINE__, in->chrm, i, obs->size);
        fflush(stderr);
      }
      ++i;

      if (str.l>2 && str.s[0] != '#' && strcount_char(str.s, '\t')>=3) {
        if (methbed_parse1(str.s, ob, ch)) {
          if (!in->nextchrom.l) { /* first time read */
            kputs(ch, &in->nextchrom);
            in->chrm = strdup(in->nextchrom.s); /* record current chrom once */
          } else if (strcmp(ch, in->nextchrom.s) != 0) { /* next chromosome encountered */
            in->next = *ob;
            in->nextchrom.l = 0;
            kputs(ch, &in->nextchrom);
            break;
          }
          commit_next_meth_obs1_v(obs);
          ob = try_next_meth_obs1_v(obs);
        }
      }
      str.l = 0;                /* clean line */
      if (c==EOF) {
        memset(&in->next, 0, sizeof(meth_obs1_t));
        in->nextchrom.l = 0;
        break;
      }
    } else {
      kputc(c, &str);
    }
  }

  free(str.s);

  return obs;
}
Example #14
0
char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of)
{
	uint8_t *s = bam1_seq(b), *t = bam1_qual(b);
	int i;
	const bam1_core_t *c = &b->core;
	kstring_t str;
	str.l = str.m = 0; str.s = 0;

	ksprintf(&str, "%s\t", bam1_qname(b));
	if (of == BAM_OFDEC) ksprintf(&str, "%d\t", c->flag);
	else if (of == BAM_OFHEX) ksprintf(&str, "0x%x\t", c->flag);
	else { // BAM_OFSTR
		for (i = 0; i < 16; ++i)
			if ((c->flag & 1<<i) && bam_flag2char_table[i])
				kputc(bam_flag2char_table[i], &str);
		kputc('\t', &str);
	}
	if (c->tid < 0) kputs("*\t", &str);
	else ksprintf(&str, "%s\t", header->target_name[c->tid]);
	ksprintf(&str, "%d\t%d\t", c->pos + 1, c->qual);
	if (c->n_cigar == 0) kputc('*', &str);
	else {
		for (i = 0; i < c->n_cigar; ++i)
			ksprintf(&str, "%d%c", bam1_cigar(b)[i]>>BAM_CIGAR_SHIFT, "MIDNSHP"[bam1_cigar(b)[i]&BAM_CIGAR_MASK]);
	}
	kputc('\t', &str);
	if (c->mtid < 0) kputs("*\t", &str);
	else if (c->mtid == c->tid) kputs("=\t", &str);
	else ksprintf(&str, "%s\t", header->target_name[c->mtid]);
	ksprintf(&str, "%d\t%d\t", c->mpos + 1, c->isize);
	if (c->l_qseq) {
		for (i = 0; i < c->l_qseq; ++i) kputc(bam_nt16_rev_table[bam1_seqi(s, i)], &str);
		kputc('\t', &str);
		if (t[0] == 0xff) kputc('*', &str);
		else for (i = 0; i < c->l_qseq; ++i) kputc(t[i] + 33, &str);
	} else ksprintf(&str, "*\t*");
	s = bam1_aux(b);
	while (s < b->data + b->data_len) {
		uint8_t type, key[2];
		key[0] = s[0]; key[1] = s[1];
		s += 2; type = *s; ++s;
		ksprintf(&str, "\t%c%c:", key[0], key[1]);
		if (type == 'A') { ksprintf(&str, "A:%c", *s); ++s; }
		else if (type == 'C') { ksprintf(&str, "i:%u", *s); ++s; }
		else if (type == 'c') { ksprintf(&str, "i:%d", *(int8_t*)s); ++s; }
		else if (type == 'S') { ksprintf(&str, "i:%u", *(uint16_t*)s); s += 2; }
		else if (type == 's') { ksprintf(&str, "i:%d", *(int16_t*)s); s += 2; }
		else if (type == 'I') { ksprintf(&str, "i:%u", *(uint32_t*)s); s += 4; }
		else if (type == 'i') { ksprintf(&str, "i:%d", *(int32_t*)s); s += 4; }
		else if (type == 'f') { ksprintf(&str, "f:%g", *(float*)s); s += 4; }
		else if (type == 'd') { ksprintf(&str, "d:%lg", *(double*)s); s += 8; }
		else if (type == 'Z' || type == 'H') { ksprintf(&str, "%c:", type); while (*s) kputc(*s++, &str); ++s; }
	}
	return str.s;
}
Example #15
0
static int
cmd_grep(int argc, char** argv)
{
	bool caseSensitive = true;
	bool inverseMatch = false;

	int argi = 1;
	for (; argi < argc; argi++) {
		const char* arg = argv[argi];
		if (arg[0] != '-')
			break;

		for (int32 i = 1; arg[i] != '\0'; i++) {
			if (arg[i] == 'i') {
				caseSensitive = false;
			} else if (arg[i] == 'v') {
				inverseMatch = true;
			} else {
				print_debugger_command_usage(argv[0]);
				return B_KDEBUG_ERROR;
			}
		}
	}

	if (argc - argi != 2) {
		print_debugger_command_usage(argv[0]);
		return B_KDEBUG_ERROR;
	}

	const char* pattern = argv[argi++];
	const char* line = argv[argi++];

	bool match;
	if (caseSensitive) {
		match = strstr(line, pattern) != NULL;
	} else {
		match = false;
		int32 lineLen = strlen(line);
		int32 patternLen = strlen(pattern);
		for (int32 i = 0; i <= lineLen - patternLen; i++) {
			// This is rather slow, but should be OK for our purposes.
			if (strncasecmp(line + i, pattern, patternLen) == 0) {
				match = true;
				break;
			}
		}
	}

	if (match != inverseMatch) {
		kputs(line);
		kputs("\n");
	}

	return 0;
}
Example #16
0
// Returns 'v' (valid value), 'i' (invalid; required GA4GH field missing),
// or upon encountering an unexpected token, that token's type.
// Explicit `return '?'` means a JSON parsing error, typically a member key
// that is not a string.  An unexpected token may be a valid token that was
// not the type expected for a particular GA4GH field, or it may be '?' or
// '\0' which should be propagated.
static char
parse_ga4gh_redirect_json(hFILE_multipart *fp, hFILE *json,
                          kstring_t *b, kstring_t *header)
{
    hts_json_token t;

    if (hts_json_fnext(json, &t, b) != '{') return t.type;
    while (hts_json_fnext(json, &t, b) != '}') {
        if (t.type != 's') return '?';

        if (strcmp(t.str, "urls") == 0) {
            if (hts_json_fnext(json, &t, b) != '[') return t.type;

            while (hts_json_fnext(json, &t, b) != ']') {
                hfile_part *part;
                size_t n = 0, max = 0;

                hts_expand(hfile_part, fp->nparts+1, fp->maxparts, fp->parts);
                part = &fp->parts[fp->nparts++];
                part->url = NULL;
                part->headers = NULL;

                if (t.type != '{') return t.type;
                while (hts_json_fnext(json, &t, b) != '}') {
                    if (t.type != 's') return '?';

                    if (strcmp(t.str, "url") == 0) {
                        if (hts_json_fnext(json, &t, b) != 's') return t.type;
                        part->url = ks_release(b);
                    }
                    else if (strcmp(t.str, "headers") == 0) {
                        if (hts_json_fnext(json, &t, b) != '{') return t.type;

                        while (hts_json_fnext(json, &t, header) != '}') {
                            if (t.type != 's') return '?';

                            if (hts_json_fnext(json, &t, b) != 's')
                                return t.type;

                            kputs(": ", header);
                            kputs(t.str, header);
                            n++;
                            hts_expand(char *, n+1, max, part->headers);
                            part->headers[n-1] = ks_release(header);
                            part->headers[n] = NULL;
                        }
                    }
                    else if (hts_json_fskip_value(json, '\0') != 'v')
                        return '?';
                }

                if (! part->url) return 'i';
            }
        }
        else if (strcmp(t.str, "format") == 0) {
Example #17
0
/* Call this to initialize SDC/blkdev interface */
void devsdc_init(void)
{
	kputs("SDC: ");
	if (devsdc_exist()) {
	    	/* turn on uber-secret SDC LBA mode*/
		sdc_reg_ctl = 0x43; 
		sdc_present = 1;
		kputs("Ok.\n");
	}
	else kprintf("Not found.\n");
}
Example #18
0
static int load_genmap(args_t *args, bcf1_t *line)
{
    if ( !args->genmap_fname ) { args->ngenmap = 0; return 0; }

    kstring_t str = {0,0,0};
    char *fname = strstr(args->genmap_fname,"{CHROM}");
    if ( fname )
    {
        kputsn(args->genmap_fname, fname - args->genmap_fname, &str);
        kputs(bcf_seqname(args->hdr,line), &str);
        kputs(fname+7,&str);
        fname = str.s;
    }
    else
        fname = args->genmap_fname;

    htsFile *fp = hts_open(fname, "rb");
    if ( !fp )
    {
        args->ngenmap = 0;
        return -1;
    }

    hts_getline(fp, KS_SEP_LINE, &str);
    if ( strcmp(str.s,"position COMBINED_rate(cM/Mb) Genetic_Map(cM)") )
        error("Unexpected header, found:\n\t[%s], but expected:\n\t[position COMBINED_rate(cM/Mb) Genetic_Map(cM)]\n", fname, str.s);

    args->ngenmap = args->igenmap = 0;
    while ( hts_getline(fp, KS_SEP_LINE, &str) > 0 )
    {
        args->ngenmap++;
        hts_expand(genmap_t,args->ngenmap,args->mgenmap,args->genmap);
        genmap_t *gm = &args->genmap[args->ngenmap-1];

        char *tmp, *end;
        gm->pos = strtol(str.s, &tmp, 10);
        if ( str.s==tmp ) error("Could not parse %s: %s\n", fname, str.s);

        // skip second column
        tmp++;
        while ( *tmp && !isspace(*tmp) ) tmp++;

        // read the genetic map in cM
        gm->rate = strtod(tmp+1, &end);
        if ( tmp+1==end ) error("Could not parse %s: %s\n", fname, str.s);
    }
    if ( !args->ngenmap ) error("Genetic map empty?\n");
    int i;
    for (i=0; i<args->ngenmap; i++) args->genmap[i].rate /= args->genmap[args->ngenmap-1].rate; // scale to 1
    if ( hts_close(fp) ) error("Close failed\n");
    free(str.s);
    return 0;
}
Example #19
0
static void timer_test_delay(void)
{
	int i;

	kputs("Delay test\n");
	for (i = 0; i < 1000; i += 100)
	{
		kprintf("delay %d...", i);
		timer_delay(i);
		kputs("done\n");
	}
}
Example #20
0
File: variant.cpp Project: atks/vt
/**
 * Gets a string representation of the underlying VNTR by fuzzy alignment.
 */
void Variant::get_fuzzy_vntr_string(kstring_t* s)
{
    s->l = 0;
    kputs(chrom.c_str(), s);
    kputc(':', s);
    kputw(vntr.fuzzy_beg1, s);
    kputc(':', s);
    kputs(vntr.fuzzy_repeat_tract.c_str(), s);
    kputc(':', s);
    kputs("<VNTR>", s);
    kputc(':', s);
    kputs(vntr.motif.c_str(), s);
};
Example #21
0
File: kinit.c Project: Zeke-OS/zeke
void exec_initfn(int (*fn)(void))
{
    int err;

    err = fn();

    if (err == 0) {
        kputs("\r\t\t\t\tOK\n");
    } else if (err != -EAGAIN) {
        kputs("\r\t\t\t\tFAILED\n");
        panic("Halt");
    }
}
Example #22
0
/* All of our Exception handling Interrupt Service Routines will
*  point to this function. This will tell us what exception has
*  happened! Right now, we simply halt the system by hitting an
*  endless loop.All ISRs disable interrupts while they are being
*  serviced as a 'locking' mechanism to prevent an IRQ from
*  happening and messing up kernel data structures */
void fault_handler(struct regs *r)
{
    if(r->err_code)
    {
        printf("ERROR!");
    }
    if (r->int_no < 32)
    {
        kputs((char *)exception_messages[r->int_no]);
        kputs("Exception. System Halted!\n");
        for (;;);
    }
}
Example #23
0
static int
cmd_tail(int argc, char** argv)
{
	debugger_command_pipe_segment* segment
		= get_current_debugger_command_pipe_segment();
	if (segment == NULL) {
		kprintf_unfiltered("%s can only be run as part of a pipe!\n", argv[0]);
		return B_KDEBUG_ERROR;
	}

	struct user_data {
		uint64	max_lines;
		int64	line_count;
		bool	restarted;
	};
	user_data* userData = (user_data*)segment->user_data;

	if (segment->invocations == 0) {
		if (argc > 3) {
			print_debugger_command_usage(argv[0]);
			return B_KDEBUG_ERROR;
		}

		userData->max_lines = 10;
		if (argc > 2 && !evaluate_debug_expression(argv[1],
				&userData->max_lines, false)) {
			return B_KDEBUG_ERROR;
		}

		userData->line_count = 1;
		userData->restarted = false;
	} else if (!userData->restarted) {
		if (argv[argc - 1] == NULL) {
			userData->restarted = true;
			userData->line_count -= userData->max_lines;
			return B_KDEBUG_RESTART_PIPE;
		}

		++userData->line_count;
	} else {
		if (argv[argc - 1] == NULL)
			return 0;

		if (--userData->line_count < 0) {
			kputs(argv[argc - 1]);
			kputs("\n");
		}
	}

	return 0;
}
Example #24
0
void eqraos_screen() {
	kclear(0x13);
	kgoto_xy(0,0);
	kset_color(0x3F);
	kputs("                                  eqraOS v0.1                                   ");
	//kgoto_xy(0,1);
	//kputs("                          Ahmad Essam [suda.nix@hotmail.com]                    ");
	
	kgoto_xy(0,24);
	kset_color(0x3F);
	kputs("                                                                                ");
	
	kgoto_xy(0,3);
}
Example #25
0
void map_init(void)
{
	if (acia_present)
		kputs("6850 ACIA detected at 0x80.\n");
	if (sio_present)
		kputs("Z80 SIO detected at 0x80.\n");
	if (sio1_present)
		kputs("Z80 SIO detected at 0x84.\n");
	if (ctc_present)
		kputs("Z80 CTC detected at 0x88.\n");
	ds1302_init();
	if (ds1302_present)
		kputs("DS1302 detected at 0xC0.\n");
}
Example #26
0
/**
 * Gets a string representation of a variant.
 */
void bcf_variant2string(bcf_hdr_t *h, bcf1_t *v, kstring_t *var)
{
    bcf_unpack(v, BCF_UN_STR);
    var->l = 0;
    kputs(bcf_get_chrom(h, v), var);
    kputc(':', var);
    kputw(bcf_get_pos1(v), var);
    kputc(':', var);
    for (int32_t i=0; i<v->n_allele; ++i)
    {
        if (i) kputc(',', var);
        kputs(bcf_get_alt(v, i), var);
    }
}
Example #27
0
void panic_text(char* str) {
	kputs("============= KERNEL PANIC =============");
	#ifdef DEBUG
	kprintf("[ Kernel debug enabled\r\n");
	#endif
	kprintf("[ Boot Ticks: %d\r\n[ Mills From boot: %d\r\n", tick, millis_from_boot);
	kputs(str);
	kputs("=============== INFO END ===============");
	kputs("System Halted due to fatal error");

	// 在遇到这种问题的时候我们需要使用jmp
	// 这个情况下栈可能是乱的,调用可能不工作
	__asm__ volatile ("jmp fatal_halt");
}
	void datalink_send_packet_to_host(uint8_t * packetbuf, uint16_t len) {
		int8_t resp;
		uint8_t txresp;
		uint8_t buf[1];
		xbee_tick();
		
		resp = xbee_AT_get("AI",buf);
		if ( resp < 0 ) {
			kputs("Radio not responding. (AI)\n");
			buf[0] = (xbee_get_status()!=XBEE_STATUS_ASSOC); // assume no change from before
		}
		
		redo_send:
		if (xbee_get_status() == XBEE_STATUS_ASSOC) {
			if ( buf[0] != 0 ) {
				printf_P(PSTR("Radio not ready, AI=%02X, correcting.\n"),buf[0]);
				xbee_set_status(XBEE_STATUS_DISASSOC);
				return;
			}
			if (dest_mode == BROADCAST) {
				xbee_send_packet_64(XBEE_BROADCAST_64b_ADDR,len,packetbuf,XBEE_TX_OPTION_BROADCAST_PAN);
				} else if ( dest_mode == SEND16 ){
				xbee_send_packet_16(dest16,len,packetbuf,0);
				} else if (dest_mode == SEND64) {
				xbee_send_packet_64(dest64,len,packetbuf,0);
				} else if (dest_mode == WIFI_SEND) {
				uint8_t ipbuf[4];
				resp = xbee_AT_get("MY",ipbuf);
				if ( resp < 0 ) {
					kputs("Radio not responding. (MY)\n");
					return;
				}
				printf_P(PSTR("My IP address=%d.%d.%d.%d\n"),ipbuf[0],ipbuf[1],ipbuf[2],ipbuf[3]);
				destipv4 = ((uint32_t)(ipbuf[0])<<24UL) | ((uint32_t)(ipbuf[1])<<16UL) | (((uint32_t)ipbuf[2])<<8UL) | 1;
				xbee_send_ipv4_packet(destipv4, len, packetbuf);
			}
			txresp = xbee_wait_for_send();
			//printf_P(PSTR("TX resp = %02X\n"),txresp);
			} else {
			if (buf[0] == 0) {
				printf_P(PSTR("Radio ready, but did not send status update, correcting.\n"));
				xbee_set_status(XBEE_STATUS_ASSOC);
				goto redo_send;
			}
			else printf_P(PSTR("Radio not ready to send packet AI=%02X\n"),buf[0]);
		}
		xbee_tick();
	}
Example #29
0
static int irods_init()
{
    kstring_t useragent = { 0, 0, NULL };
    struct sigaction pipehandler;
    rErrMsg_t err;
    int ret, pipehandler_ret;

    if (hts_verbose >= 5) rodsLogLevel(hts_verbose);

    ret = getRodsEnv(&irods.env);
    if (ret < 0) goto error;

    // Set iRODS User-Agent, if our caller hasn't already done so.
    kputs("htslib/", &useragent);
    kputs(hts_version(), &useragent);
    (void) setenv(SP_OPTION, useragent.s, 0);
    free(useragent.s);

    // Prior to iRODS 4.1, rcConnect() (even if it fails) installs its own
    // SIGPIPE handler, which just prints a message and otherwise ignores the
    // signal.  Most actual SIGPIPEs encountered will pertain to e.g. stdout
    // rather than iRODS's connection, so we save and restore the existing
    // state (by default, termination; or as already set by our caller).
    pipehandler_ret = sigaction(SIGPIPE, NULL, &pipehandler);

    irods.conn = rcConnect(irods.env.rodsHost, irods.env.rodsPort,
                           irods.env.rodsUserName, irods.env.rodsZone,
                           NO_RECONN, &err);
    if (pipehandler_ret == 0) sigaction(SIGPIPE, &pipehandler, NULL);
    if (irods.conn == NULL) { ret = err.status; goto error; }

    if (strcmp(irods.env.rodsUserName, PUBLIC_USER_NAME) != 0) {
#if defined IRODS_VERSION_INTEGER && IRODS_VERSION_INTEGER >= 4000000
        ret = clientLogin(irods.conn, NULL, NULL);
#else
        ret = clientLogin(irods.conn);
#endif
        if (ret != 0) goto error;
    }

    return 0;

error:
    if (irods.conn) { (void) rcDisconnect(irods.conn); }
    irods.conn = NULL;
    set_errno(ret);
    return -1;
}
void main(void)
{
    kputs("--DEBUG-- Hello world from BIOS in C!\n");
	char mbr[SECTOR_SIZE];
	readdisk(0,0,mbr,SECTOR_SIZE);
	(*((void (*)(void*,void*))(VTRC2VTRE(mbr))))(&readdisk,mbr);
}