コード例 #1
0
// sorted disk map
void printDisk(u32t disk) {
   dsk_mapblock *dm = dsk_getmap(disk);
   if (dm) {
      int ii = 0;
      do {
         printf("%016LX %016LX %02X (%d)\n", dm[ii].StartSector, dm[ii].Length,
            dm[ii].Type, dm[ii].Index);
      } while ((dm[ii++].Flags&DMAP_LEND)==0);
      free(dm);
      printf("press key to continue!\n");
      key_wait(10);
   }
   exit(0);
}
コード例 #2
0
ファイル: ft_select_function.c プロジェクト: bciss/projets_42
char				*do_select(t_select *list)
{
	t_select		*tmp;

	if ((tputs(tgetstr("vi", NULL), 1, t_puts)) == -1)
		ft_exit("Tputs error");
	tmp = list;
	while (42)
	{
		do_refresh(tmp);
		list = get_ptr_atm(list);
		key_wait(list);
		if (list->finish == 1)
			break ;
	}
	return (get_choosen_word(tmp));
}
コード例 #3
0
/** process exit callback.
    note, that callbacks are called in CALLER context! 
    To catch something in CALLEE context use mt_pexitcb() for tid 1.
    Function is not covered by MT lock, nor by ldr_mutex! */
s32t _std mod_exitcb(process_context *pq, s32t rc) {
   int errtype = 0;
   // !!!
   fcloseall_as(pq->pid);
   io_close_as(pq->pid, IOHT_FILE|IOHT_DIR|IOHT_MUTEX);

   if (pq->rtbuf[RTBUF_PUSHDST]) {
      pushd_free((void*)pq->rtbuf[RTBUF_PUSHDST]);
      pq->rtbuf[RTBUF_PUSHDST] = 0;
   }
   if (pq->rtbuf[RTBUF_ANSIBUF]) {
      free((void*)pq->rtbuf[RTBUF_ANSIBUF]);
      pq->rtbuf[RTBUF_ANSIBUF] = 0;
   }

   if (!mem_checkmgr()) errtype = 1; else
   if (!exi_checkstate()) errtype = 2;

   if (errtype) {
      char prnbuf[128];
      vio_clearscr();
      vio_setcolor(VIO_COLOR_LRED);
      // can`t use printf here, if was closed above ;)
      snprintf(prnbuf, 128, "\n Application \"%s\"\n made unrecoverable damage in"
        " system %s structures...\n\n", pq->self->name, errtype==1?
           "heap manager":"shared classes");
      vio_strout(prnbuf);
      snprintf(prnbuf, 128, " This will produce trap or deadlock in nearest time.\n"
         " Reboot or press any key to continue...\n");
      vio_strout(prnbuf);
      vio_setcolor(VIO_COLOR_RESET);
      key_wait(60);
   }
   log_printf("memory check done\n");
   mod_apiunchain((u32t)pq->self,0,0,0);
   mod_fnunchain((u32t)pq->self,0,0,0);
   return rc;
}
コード例 #4
0
int main(int argc,char *argv[]) {
   u32t   ii, modes, mh;
   time_t       now;
   dir_t         di;
   vio_mode_info *mi = vio_modeinfo(0, 0, 0), *mp;

   if (argc>1) {
      if (stricmp(argv[1],"fps")==0) {
         // screen clear fps counter (for virtual console)
         u32t start = tm_counter(),
                cnt = 0;
         do {
            vio_clearscr();
            cnt++;
         } while (tm_counter()-start < 182);
         printf("%d.%d frames per second\n", cnt/10,cnt%10);
         return 0;
      } else
      if (stricmp(argv[1],"t")==0) {
         // rdtsc cycles in 55 ms.
         do {
            printf("%LX\n", hlp_tscin55ms());
         } while (key_wait(2)==0);
         return 0;
      } else
      if (stricmp(argv[1],"k")==0) {
         u32t tid;
         // trying to kill self from the second thread
         if (!mt_active()) {
            qserr res = mt_initialize();
            if (res) {
               cmd_shellerr(EMSG_QS, res, "MT mode:");
               return 1;
            }
         }
         // turn on trace output for MTLIB
         cmd_shellcall(shl_trace, "on mtlib", 0);

         tid = mt_createthread(threadfunc, MTCT_SUSPENDED|MTCT_NOFPU, 0, 0);
         mod_dumptree();
         mt_resumethread(0, tid);
         mt_waitthread(tid);
         // this line should never been printed
         printf("Something going wrong!\n");
         return 0;
      } else
      if (stricmp(argv[1],"m")==0 && argc==4) {
         static const char *cstr[MTRRF_TYPEMASK+1] = { "UC", "WC", "??", "??",
            "WT", "WP", "WB", "Mixed" };
         // try to query cache type for memory range
         u64t addr = strtoull(argv[2],0,16),
               len = strtoull(argv[3],0,16);
          
         u32t   ct = hlp_mtrrsum(addr,len);

         printf("cache type for %09LX..%09LX is %s\n", addr, addr+len-1, cstr[ct]);
      } else
      if (stricmp(argv[1],"r")==0 && argc==4) {
         // mem hide test
         u64t addr = strtoull(argv[2],0,16),
               len = strtoull(argv[3],0,16);
         sys_markmem(addr, len>>PAGESHIFT, PCMEM_HIDE|PCMEM_USERAPP);
      } else
      if (stricmp(argv[1],"c")==0 && (argc==2 || argc==3)) {
コード例 #5
0
void func(void) {
   printf("3 secs before longjmp!\n");
   key_wait(3);
   longjmp(jmp,1);
}