コード例 #1
0
ファイル: idt.c プロジェクト: StringsStar/sing
void exception_handler(int vec_no,int err_code,int eip,int cs,int eflags)
{
	char * err_msg[] = {"#DE Divide Error",
			    "#DB RESERVED",
			    "--  NMI Interrupt",
			    "#BP Breakpoint",
			    "#OF Overflow",
			    "#BR BOUND Range Exceeded",
			    "#UD Invalid Opcode (Undefined Opcode)",
			    "#NM Device Not Available (No Math Coprocessor)",
			    "#DF Double Fault",
			    "    Coprocessor Segment Overrun (reserved)",
			    "#TS Invalid TSS",
			    "#NP Segment Not Present",
			    "#SS Stack-Segment Fault",
			    "#GP General Protection",
			    "#PF Page Fault",
			    "--  (Intel reserved. Do not use.)",
			    "#MF x87 FPU Floating-Point Error (Math Fault)",
			    "#AC Alignment Check",
			    "#MC Machine Check",
			    "#XF SIMD Floating-Point Exception"
	};

	disp_str(err_msg[vec_no]);
	disp_str("vec_no: ");
	disp_int(vec_no);
	disp_str(" err_code: ");
	disp_int(err_code);
	disp_str(" eip: ");
	disp_int(eip);
	disp_str(" cs: ");
	disp_int(cs);
	disp_str("\n");
}
コード例 #2
0
ファイル: protect.c プロジェクト: zf369/Tinix
PUBLIC void exception_handler(int vec_no, int err_code, int eip, int cs, int eflags)
{
    int i;
    int text_color = 0x74; // 灰底红字

    /* 通过打印空格的方式清空屏幕的前五行,并把 disp_pos 清零 */
    disp_pos = 0;
    for (i = 0; i < 80 * 5; i++)
    {
    	disp_str(" ");
    }
    disp_pos = 0;

    disp_color_str("Exception! --> ", text_color);
    disp_color_str(err_description[vec_no], text_color);
    disp_color_str("\n\n", text_color);

    disp_color_str("EFLAGS:", text_color);
    disp_int(eflags);

	disp_color_str(" CS:", text_color);
    disp_int(cs);

    disp_color_str(" EIP:", text_color);
    disp_int(eip);

    if (err_code != 0xFFFFFFFF)
    {
    	disp_color_str(" Error code:", text_color);
	    disp_int(err_code);
    }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Tigrolik/git_workspace
void test_int() {
    std::cout << "Max Int value: " << Int::max_value() << '\n';
    std::cout << "Min Int value: " << Int::min_value() << '\n';
    long int li1 {-2147483649};
    disp_int(li1);
    long int li2 {2147483659};
    disp_int(li2);
    long int li3 {3659};
    disp_int(li3);
}
コード例 #4
0
ファイル: protect.c プロジェクト: ilikeshell/tinux
PUBLIC void exception_handler(u32 vec_no, u32 err_code, u32 eip, u32 cs, u32 eflags)
{
	int i;
	u8 text_color = 0x74;	/* 灰底红字 */
	char* err_msg[] = 
	{
		"#DE Divide Error",
		"#BD RESERVED",
		"-- NMI Interrupt",
		"#BP Breakpoint",
		"#OF Overflow",
		"#BR Bound Range Exceeded",
		"#UD Invalid Opcode (Undefined Opcode)",
		"#NM Device Not Available (No Math Coprocessor)",
		"#DF Double Fault",
		"   Coprocessor Segment Overrun (reserved)",
		"#TS Invalid TSS",
		"#NP Segment Not Present",
		"#SS Stack Segment Fault",
		"#GP General Protection",
		"#PF Page Fault",
		"-- (Intel Reserved. Do not use)",
		"#MF x87 FPU Floating Point Error (Math Fault)",
		"#AC Alignment Check",
		"#MC Machine Check",
		"#XF SIMD Floating Point Exception"
	};
		
		/* 屏幕前五行清零 */
		disp_pos = 0;
		for(i = 0; i < 5 * 80; i++)
			disp_str(" ");
		disp_pos = 0;
		
		disp_color_str("Exception! --> ", text_color);
		disp_color_str(err_msg[vec_no], text_color);
		disp_color_str("\n\n", text_color);
		disp_color_str("EFLAGS:", text_color);
		disp_int(eflags);
		disp_color_str("cs:", text_color);
		disp_int(cs);
		disp_color_str("EIP:",text_color);
		disp_int(eip);
		
		if(err_code != 0xFFFFFFFF)
		{
			disp_color_str("ERROR CODE:", text_color);
			disp_int(err_code);
		}
}
コード例 #5
0
ファイル: protect.c プロジェクト: douzh/mydisk
/*======================================================================*
                            exception_handler
 *----------------------------------------------------------------------*
 异常处理
 *======================================================================*/
PUBLIC void exception_handler(int vec_no, int err_code, int eip, int cs, int eflags)
{
	int i;
	int text_color = 0x74; /* 灰底红字 */
	char err_description[][64] = {	"#DE Divide Error",
					"#DB RESERVED",
					"—  NMI Interrupt",
					"#BP Breakpoint",
					"#OF Overflow",
					"#BR BOUND Range Exceeded",
					"#UD Invalid Opcode (Undefined Opcode)",
					"#NM Device Not Available (No Math Coprocessor)",
					"#DF Double Fault",
					"    Coprocessor Segment Overrun (reserved)",
					"#TS Invalid TSS",
					"#NP Segment Not Present",
					"#SS Stack-Segment Fault",
					"#GP General Protection",
					"#PF Page Fault",
					"—  (Intel reserved. Do not use.)",
					"#MF x87 FPU Floating-Point Error (Math Fault)",
					"#AC Alignment Check",
					"#MC Machine Check",
					"#XF SIMD Floating-Point Exception"
				};

	/* 通过打印空格的方式清空屏幕的前五行,并把 disp_pos 清零 */
	disp_pos = 0;
	for(i=0;i<80*5;i++){
		disp_str(" ");
	}
	disp_pos = 0;

	disp_color_str("Exception! --> ", text_color);
	disp_color_str(err_description[vec_no], text_color);
	disp_color_str("\n\n", text_color);
	disp_color_str("EFLAGS:", text_color);
	disp_int(eflags);
	disp_color_str("CS:", text_color);
	disp_int(cs);
	disp_color_str("EIP:", text_color);
	disp_int(eip);

	if(err_code != 0xFFFFFFFF){
		disp_color_str("Error code:", text_color);
		disp_int(err_code);
	}
}
コード例 #6
0
ファイル: i8259.c プロジェクト: chenghuaijun/Orange
/*======================================================================*
                           spurious_irq
 *======================================================================*/
PUBLIC void spurious_irq(int irq)
{
        disp_str("spurious_irq: ");
        disp_int(irq);
        disp_str("\n");
	while(1);       //自己添加
}
コード例 #7
0
ファイル: start.c プロジェクト: chnlkw/osmu
void cpuid(t_32 id)
{
	t_64 rax=0,rbx=0,rcx=0,rdx=0;
	rax=get_cpuid(id, &rbx, &rcx, &rdx);
	disp_str("cpuid");
	disp_int(id);
	disp_str(" EAX=");
	disp_int(rax);
	disp_str(" EBX=");
	disp_int(rbx);
	disp_str(" ECX=");
	disp_int(rcx);
	disp_str(" EDX=");
	disp_int(rdx);
	disp_str("\n");
}
コード例 #8
0
ファイル: i8259.c プロジェクト: chenghuaijun/Orange
/*======================================================================*
                           spurious_irq
 *======================================================================*/
PUBLIC void spurious_irq(int irq)
{
	disp_str("spurious_irq: ");
	disp_int(irq);
	disp_str("\n");
//	while(1); //add by myself
}
コード例 #9
0
ファイル: i8259.c プロジェクト: itlodge/mos
void
spurious_irq(int irq)
{
    disp_str("spurious_irq: ");
    disp_int(irq);
    disp_str("\n");
}
コード例 #10
0
ファイル: interupt.c プロジェクト: DuoHuo/season
void exception_handler(int vec_no, int err_code, int eip, int cs, int eflags)
{
	int i;

	char * err_msg[] = {"#DE Divide Error",
			    "#DB RESERVED",
			    "--  NMI Interrupt",
			    "#BP Breakpoint",
			    "#OF Overflow",
			    "#BR BOUND Range Exceeded",
			    "#UD Invalid Opcode (Undefined Opcode)",
			    "#NM Device Not Available (No Math Coprocessor)",
			    "#DF Double Fault",
			    "    Coprocessor Segment Overrun (reserved)",
			    "#TS Invalid TSS",
			    "#NP Segment Not Present",
			    "#SS Stack Segment Fault",
			    "#GP General Protection",
			    "#PF Page Fault",
			    "--  (Intel reserved. Do not use.)",
			    "#MF x87 FPU Floating Point Error (Math Fault)",
			    "#AC Aligment Check",
			    "#MC Machine Check",
			    "#XF SIMD Floating Point Exception"
	};

	disp_pos = 0;
	for (i=0; i<80*5; i++) {
		disp_str(" ");
	}
	disp_pos = 0;

	disp_str("Exception! --> ");
	disp_str(err_msg[vec_no]);
	disp_str("\n\n");
	disp_str("EFLAGS:");
	disp_int(eflags);
	disp_str("  CS:");
	disp_int(cs);
	disp_str("  EIP:");
	disp_int(eip);

	if (err_code != 0xffffffff) {
		disp_str("  Error code:");
		disp_int(err_code);
	}
}
コード例 #11
0
ファイル: tty.c プロジェクト: nmsoccer/micro_kernel
void tty_write_int(int data , TTY *p_tty){
	CONSOLE *p_console = p_tty -> p_console;

	p_console -> current_videoaddr = disp_int(data , (p_console -> start_vmem * 2 + p_console -> current_videoaddr))
														- p_console -> start_vmem * 2;

	set_cursor_console(p_console);

}
コード例 #12
0
ファイル: main.c プロジェクト: douzh/mydisk
/*======================================================================*
                               TestC
 *======================================================================*/
void TestC()
{
	int i = 0x2000;
	while(1){
		disp_str("C");
		disp_int(i++);
		disp_str(".");
		delay(1);
	}
}
コード例 #13
0
ファイル: main.c プロジェクト: douzh/mydisk
/*======================================================================*
                               TestB
 *======================================================================*/
void TestB()
{
	int i = 0x1000;
	while(1){
		disp_str("B");
		disp_int(i++);
		disp_str(".");
		delay(1);
	}
}
コード例 #14
0
ファイル: main.c プロジェクト: douzh/mydisk
/*======================================================================*
                               TestA
 *======================================================================*/
void TestA()
{
	int i = 0;
	while(1){
		disp_str("A");
		disp_int(i++);
		disp_str(".");
		delay(1);
	}
}
コード例 #15
0
ファイル: main.c プロジェクト: klose911/sinix
void testA(void) 
{
	int i = 0; 

	while(TRUE) {
		disp_str("A"); 
		disp_int(i++); 
		disp_str("."); 
		delay(1);
	}
}
コード例 #16
0
ファイル: main.c プロジェクト: klose911/sinix
void testC(void) 
{
	int i = 0x2000; 

	while(TRUE) {
		disp_str("C"); 
		disp_int(i++); 
		disp_str("."); 
		delay(1);
	}
}
コード例 #17
0
ファイル: main.c プロジェクト: klose911/sinix
void testB(void) 
{
	int i = 0x1000; 

	while(TRUE) {
		disp_str("B"); 
		disp_int(i++); 
		disp_str("."); 
		delay(1);
	}
}
コード例 #18
0
ファイル: start.c プロジェクト: chnlkw/osmu
void cstart()
{
	disp_str("cstart begin\n");
//	init_gdt();
//	init_8259A();
//	init_idt();
	cpu_info();
	cpuid(1);
	disp_int(rdmsr(0x1B));disp_str("\n");
	init_mp();
	disp_str("cstart finish\n");
	while(1);
}
コード例 #19
0
PRIVATE void analysis_identify_info(u16* hdinfo)
{
	disp_str("print hd info: \n");
	int i, k;
	char s[64];

	struct iden_info_ascii{
		int idx;
		int len;
		char* desc;
	}iinfo[] = {{10, 20, "HD SN"}, /* Serial number in ASCII */
		    {27, 40, "HD Model"} /* Model number in ASCII */};
	for(k = 0; k < sizeof(iinfo) / sizeof(iinfo[0]); k++){
		char* p = (char*)&hdinfo[iinfo[k].idx];

		for(i = 0; i < iinfo[k].len / 2; i++){
			s[ i * 2 + 1] = *p++;		//这里是按字为单位的,一个字两个字节,小端存储,虽易要把每个字中的两个字节调换顺序;
			s[ i * 2] = *p++;
		}
		s[i * 2] = 0;	//'/0'
		//printf("%s: %s\n", iinfo[k],descm s);
		disp_str(iinfo[k].desc);
		disp_str(": ");
		disp_str(s);
		disp_str("\n");
	}

	int capabilities = hdinfo[49];
	hd_info[0].lba_support = (capabilities & 0x0200);
	//printf("LBA48 supported: %s\n", 
	//	(capabilities & 0x0200) ? "YES" : "NO");
	disp_str("LBA supported: ");
	disp_str((capabilities & 0x0200) ? "YES" : "NO");
	disp_str("\n");

	int cmd_set_supported = hdinfo[83];
	hd_info[0].lba48_support = (cmd_set_supported & 0x0400);
	//printf("LBA48 supported: %s\n",
	//	(cmd_set_supported & 0x0400) ? "YES" : "NO");
	disp_str("LBA48 supported: ");
	disp_str((cmd_set_supported & 0x0400) ? "YES" : "NO");
	disp_str("\n");

	int sectors = ((int)hdinfo[61] << 16) + hdinfo[60];
	hd_info[0].hd_size = sectors * 512;
	//printf("HD size: %dMB\n", sectors * 512 / 1000000);
	disp_str("HD size: ");
	disp_int(sectors * 512 / 1024 / 1024);
	disp_str("MB\n");
}
コード例 #20
0
PUBLIC void init_hd()
{
	/* Get the number of drives from the BIOS data area */
	u8* pNrDrives = (u8*)(0x475);
	disp_str("NrDrives:");
	disp_int(*pNrDrives);
	disp_str("\n");

	put_irq_handler(AT_WINI_IRQ, hd_handler);
	enable_irq(CASCADE_IRQ);	//打开级联中断线
	enable_irq(AT_WINI_IRQ);	//打开硬盘中断线
	
	int i = 0;
	for(i = 0; i < (sizeof(hd_info) / sizeof(hd_info[0])); i++)
		memset(&hd_info[i], 0, sizeof(hd_info[0]));
	hd_info[0].open_cnt = 0;
}
コード例 #21
0
ファイル: main.c プロジェクト: mengpq/os
/*======================================================================*
                               TestB
 *======================================================================*/
void TestB()
{
	int temp=new_out(10);
	disp_int(temp); display_string(" ");
	/*
	int temp=0x500000,i;
	int delta=0x500000/1024;
	for (i=0; i<delta; i++){
		u8 ret=read_memory(temp);
		//disp_int(ret); display_string(" ");
		temp+=1024;
	}
	display_string("scan 5MB memory\n");
	*/
	while(1){
		//PROCESSB();
	}
}
コード例 #22
0
ファイル: start.c プロジェクト: wwssllabcd/myOS
PUBLIC void cstart()
{
    showMsg();//set gs first, or you will get error when you show msg
    disp_str("\ncstart-start");
    disp_str("\n");

    set_gdt(0, 0x0000, 0x0000, 0x0000, 0x0000);
    set_gdt(1, 0x0FFF, 0x0000, 0x9A00, 0x00C0);        // code
    set_gdt(2, 0x0FFF, 0x0000, 0x9200, 0x00C0);        // data segment
    set_gdt(3, 0xFFFF, 0x8000, 0x920B|0x6000, 0x00C0); // GS, SET DPL = 3

    disp_int(0x67AB);

    init_gptr();
    init_iptr();
    init_prot();

    disp_str("\ncse");
}
コード例 #23
0
ファイル: keyboard.c プロジェクト: douzh/mydisk
/*======================================================================*
                           get_byte_from_kb_buf
*======================================================================*/
PRIVATE t_8 get_byte_from_kb_buf()	/* 从键盘缓冲区中读取下一个字节 */
{
	t_8	scan_code;

	while (kb_in.count <= 0) {}	/* 等待下一个字节到来 */

	disable_int();
	scan_code = *(kb_in.p_tail);
	kb_in.p_tail++;
	if (kb_in.p_tail == kb_in.buf + KB_IN_BYTES) {
		kb_in.p_tail = kb_in.buf;
	}
	kb_in.count--;
	enable_int();

#ifdef __TINIX_DEBUG__
	disp_color_str("[", MAKE_COLOR(WHITE,BLUE));
	disp_int(scan_code);
	disp_color_str("]", MAKE_COLOR(WHITE,BLUE));
#endif

	return scan_code;
}
コード例 #24
0
/**
 * <Ring 1> Print disk info.
 * 
 * @param hdi  Ptr to struct hd_info.
 *****************************************************************************/
PRIVATE void print_hdinfo(struct hd_info* hdi)
{
	int i;
	for(i = 0; i < NR_PART_PER_DRIVE + 1; i++){
//		printl("%sPART_%d: base %d(0x%x), size %d(0x%x) (in sector)\n",
//			i == 0 ? " " : "     ",
//			i,
//			hdi->primary[i].base,
//			hdi->primary[i].base,
//			hdi->primary[i].size,
//			hdi->primary[i].size);

		disp_str(i == 0 ? " " : "     ");
		disp_str("PART_");
		disp_int(i);
		disp_str(": base ");
		disp_int(hdi->primary[i].base);
		disp_str(", size ");
		disp_int(hdi->primary[i].size);
		disp_str("\n");
	}
	for(i = 0; i < NR_SUB_PER_DRIVE; i++){
		if(hdi->logical[i].size == 0)
			continue;
//		printl("         "
//		       "%d: base %d(0x%x), size %d(0x%x) (in sector)\n",
//		       i,
//		       hdi->logical[i].base,
//		       hdi->logical[i].base,
//		       hdi->logical[i].size,
//		       hdi->logical[i].size);
		disp_str("         ");
		disp_int(i);
		disp_str(": base ");
		disp_int(hdi->logical[i].base);
		disp_str(", size ");
		disp_int(hdi->logical[i].size);
	}
}
コード例 #25
0
ファイル: i8259.c プロジェクト: uping/prettyos
//default irq handler
static void reserved_irq(int irq)
{
	disp_str("spurious_irq: ");
	disp_int(irq);
	disp_str("\n");
}
コード例 #26
0
ファイル: intcode.cpp プロジェクト: CarterTsai/hime
gboolean module_feedkey(int key, int kvstate)
{
  int i;
#if 0
  if (key <= XK_KP_9 && key >= XK_KP_0)
    key -= XK_KP_0 - '0';
#endif
  key=toupper(key);
  if (key==XK_BackSpace||key==XK_Delete) {
#if WIN32
    if (*gmf.mf_test_mode)
      return intcode_cin>0;
#endif
    if (intcode_cin)
      intcode_cin--;
    else
      return 0;

    goto dispIn;
  }
  else
  if ((key<'0'||key>'F'||(key>'9' && key<'A')) && (key!=' ')){
    return 0;
  }

  if (current_intcode==INTCODE_BIG5) {
    if (intcode_cin==0 && key<'8')
      return 1;
    if (intcode_cin==1 && inch[0]=='F' && key=='F')
      return 1;
    if (intcode_cin==2 && (key<'4' || (key>'7' && key<'A')))
      return 1;
    if (intcode_cin==3 && (inch[2]=='7'||inch[2]=='F') && key=='F')
      return 1;
  }

  if (!intcode_cin && key==' ')
    return 0;
#if WIN32
  if (*gmf.mf_test_mode)
    return 1;
#endif
  if ((intcode_cin<MAX_INTCODE-1 || (current_intcode!=INTCODE_BIG5 && intcode_cin < MAX_INTCODE)) && key!=' ')
    inch[intcode_cin++]=key;

dispIn:
  clear_int_code_all();

#if 1
  if (intcode_cin)
    module_show_win();
#endif

  for(i=0;i<intcode_cin;i++) {
    disp_int(i, _(dstr[h2i(inch[i])]));
  }

  if ((current_intcode==INTCODE_BIG5 && intcode_cin==4 ||
       current_intcode==INTCODE_UTF32 && intcode_cin==6) &&
      *gmf.mf_gtab_press_full_auto_send || key==' ') {
    u_char utf8[CH_SZ+1];

    if (current_intcode==INTCODE_BIG5) {
      u_char ttt[3];
      ttt[2]=ttt[3]=0;
      ttt[0]=(h2i(inch[0])<<4)+h2i(inch[1]);
      ttt[1]=(h2i(inch[2])<<4)+h2i(inch[3]);
      big5_utf8((char *)ttt, (char *)utf8);
    } else {
      int i;
      u_int v = 0;

      for(i=0; i < intcode_cin; i++) {
        v <<= 4;
        v |= h2i(inch[i]);
      }

      utf32to8((char *)utf8, (char *)&v);
    }

    gmf.mf_send_utf8_ch((char *)utf8);
    intcode_cin=0;

    clear_int_code_all();
  }

  return 1;
}
コード例 #27
0
ファイル: main.c プロジェクト: mengpq/os
void display_int(int value){
	disp_int(value);
	trace_cursor();
}