void info() { printf("\n:==========: :System info: :==========:\n\n"); // Kernel info printf( "Version: '%s'\n" "Patchlevel: '%s'\n" "Extraversion: '%s'\n" "Name: '%s'\n" "Revision: '%s'\n",VERSION,PATCHLEVEL,EXTRAVERSION,NAME,REV_NUM); // CPU Info _kputs (LNG_CPU); _kcolor (4); _kgoto (61, _kgetline()); _kputs (cpu_vendor); _kcolor(7); printf("\n"); // Memory RAM Info printf("Memory RAM: "); _kgoto(60, _kgetline()); printf(" %d Kb\n", get_memsize()/1024); // Memory free RAM Info printf(LNG_FREERAM); _kgoto(60, _kgetline()); printf(" %d Kb\n", get_numpages()); printf("\n"); // Bitmap Info printf("Number bitmap's elements: "); _kgoto(60, _kgetline()); printf(" %d", get_bmpelements()); _kgoto(60, _kgetline()); // Mem_area Info printf("\nSize of mem_area: "); _kgoto(60, _kgetline()); printf(" %d\n", sizeof(mem_area)); // Page Dir Info printf("Page Dir Entry n.0 is: "); _kgoto(60, _kgetline()); printf(" %d\n", get_pagedir_entry(0)); // Page Table Info printf("Page Table Entry n.4 in Page dir 0 is: "); _kgoto(60, _kgetline()); printf(" %d\n", get_pagetable_entry(0,4)); printf("\n:==========: :===========: :==========:\n\n"); }
void credits(void) { _kcolor('\011'); _kputs("DreamOS Credits\n\n"); _kputs("Main Developers:\n"); _kcolor('\012'); printf("Shainer - Lisa\n" "Finarfin - Ivan\n\n\n" ); _kcolor('\011'); _kputs("Contributors:\n"); _kcolor('\012'); _kputs("vinc94\n" "tk0\n" "Osiris\n" "Celeron\n" "Hamcha\n" "m0nt0\n" "and many others (3 or 4 :P)\n\n"); _kcolor('\007'); }
void credits(void) { _kcolor('\011'); _kputs("DreamOS Credits\n\n"); _kputs("Main Developers:\n"); _kcolor('\012'); printf( "Finarfin - Ivan (Founder)\n\n"); _kcolor('\011'); _kputs("Developers:\n"); _kcolor('\012'); _kputs("Osiris - Diego Stamigni \n\n"); _kcolor('\011'); _kputs("Contributors:\n"); _kcolor('\012'); _kputs("vinc94\n" "tk0\n" "DT\n" "Celeron\n" "Hamcha\n" "m0nt0\n" "shainer\n" "and many others (3 or 4 :P)\n\n"); _kcolor('\007'); }
int main_loop(struct multiboot_info *boot_info) { _kclear(); syscall_init(); module_start = (char*) *((unsigned int*)boot_info->mods_addr); module_end = *((unsigned int*)(boot_info->mods_addr+4)); _kcolor(BRIGHT_GREEN); _kputs(DREAMOS_VER); _kcolor(WHITE); _kputs(LNG_SITE); _kcolor(BRIGHT_BLUE); _kputs(SITEURL); _kputs("\n"); _kcolor(WHITE); _kputs("\n"); _kputs(LNG_GDT); init_gdt(); _kprintOK(); outportb(0xFF, MASTER_PORT_1); outportb(0xFF, SLAVE_PORT_1); _kputs(LNG_IDT); asm("cli"); init_idt(); _kprintOK(); _kputs(LNG_PIC8259); init_IRQ(); _kprintOK(); printf(LNG_PIT8253); configure_PIT (); //_kprintOK(); set_memorysize((boot_info->mem_upper+boot_info->mem_lower)*1024); init_mem(); asm("sti"); _kprintOK(); init_paging(); _kprintOK(); printf("Memory (upper) amount-> %d kb \n", boot_info->mem_upper); printf("Memory (lower) amount-> %d kb \n", boot_info->mem_lower); /* Alloc and fill CPUID structure */ sinfo = kmalloc(sizeof(struct cpuinfo_generic)); get_cpuid (sinfo); vfs_init(); initfs_init(); if(boot_info->mods_count > 0) printf("Found n. %d Modules\n", boot_info->mods_count); //printf("Address of module: 0x%x - 0x%x\n", *((unsigned int*)boot_info->mods_addr),module_end-(unsigned int) module_start); printf("\n"); printf("----\n"); printf(LNG_SHELL); _kprintOK(); printf("[+] Address: 0x%x\n", &end); printf("\n"); #ifdef BOCHS_DEBUG dbg_bochs_print((const unsigned char*)"DreamOS Debug String for Bochs\n"); #endif shell(); return 0; }
void shell() { char cmd[256]; char string[256]; char *user = kmalloc(24); memset(user, 0, strlen(user)); printf(LNG_USER); scanf ("%23s",user); while (!strlen(user)) { printf(LNG_USER); scanf ("%s",user); printf(LNG_USER_R); } _kclear(); aalogo(); printf("\n\n\n\n"); shell_mess = strlen (user) + 3; argc=1; for (;;) { printf("%s~# ",user); scanf("%254s",cmd); options (cmd); if (strcmp(argv[0], "help") == 0) { printf("Available commands:\n"); help(); } else if (strcmp(argv[0], "echo") == 0) { int c; for (c=1; c<argc; c++) printf ("%s ", argv[c]); printf ("\n"); } else if (strcmp(argv[0], "poweroff") == 0) { printf("Poweroff..\n"); poweroff(); } else if (strcmp(argv[0], "clear") == 0) { _kclear(); } else if (strcmp (argv[0], "uname") == 0) { /*if (argv[2] != " ") { memmove(argv[2], argv[2]+6, strlen(argv[2])); }*/ if (!(_kstrncmp(argv[1], "-a", 2)) || !(_kstrncmp(argv[1], "--all", 5))) { printf("%s %s.%s%s #1 CEST 2009 %s\n",NAME,VERSION,PATCHLEVEL,EXTRAVERSION,cpu_vendor); } else if (!(_kstrncmp(argv[1], "-r", 2)) || !(_kstrncmp(argv[1], "--rev", 5))) { printf("%s.%s%s\n",VERSION,PATCHLEVEL,EXTRAVERSION); } else if (!(_kstrncmp(argv[1], "-h", 2) ) || !(_kstrncmp(argv[1], "--help", 6))) { uname_help(); } else if (!(_kstrncmp(argv[1], "-i", 2)) || !(_kstrncmp(argv[1], "--info", 6))) { info(); } if (!(_kstrncmp(argv[1], '\0', 1))) { printf("%s\n" "For more info about this tool, please do 'uname --help'\n",NAME); } } else if (strcmp(argv[0], "cpuid") == 0) { struct cpuinfo_generic *sinfo = get_cpuid(); printf ("----- CPUID Information -----\n"); printf ("Vendor: %s\n", sinfo->cpu_vendor); printf ("Type: %s\n", sinfo->cpu_type); free (sinfo); } else if (strcmp(argv[0], "answer") == 0) { printf("42\n"); outportb('4',0xe9); } else if (strcmp(argv[0], "sleep") == 0) { int s; if (argv[1]) { s = atoi(argv[1]); if (s != -1) sleep (s); } else printf ("Missing operand\n"); } else if (strcmp(argv[0], "kmalloc") == 0) { printf("kmalloc try: ...\n"); int *b; b = (int*) kmalloc(10*sizeof(int)); printf("Address obtained: %d\n", b); int i = 0; while(i<10){ b[i] = i*2; i++; } i=0; while(i<10) { printf("b[%d] = %d\n",i, b[i]); i++; } printf("Address of a: %d\n", b); printf("Navigating used list...\n"); print_heap_list (kheap->used_list); free (b); } else if (strcmp(argv[0], "do_fault") == 0) { printf ("Genero un pagefault scrivendo 10 nella locazione 0xa0000000...\n"); int *prova; prova = (int*)0xa0000000; *prova = 10; printf ("Contenuto della locazione 0xa0000000 dopo l'intervento dell'handler: %d\n", *prova); } /*else if (!(_kstrncmp(cmd,"try_heap",8))){ try_alloc(); } else if (!(_kstrncmp(cmd,"free",4))) { unsigned int ptr = 425548; free((unsigned int*)ptr); ptr = 437836; free((unsigned int*)ptr); ptr=446028; free((unsigned int*)ptr); printf("Navigating used list...\n"); print_heap_list (kheap->used_list); printf("Navigating free list...\n"); print_heap_list (kheap->free_list); printf("Navigating free nodes...\n"); print_heap_list (kheap->free_nodes); }*/ else if (strcmp(argv[0], "printmem") == 0) print_heap_list(kheap->used_list); else if (strcmp(argv[0], "date") == 0) date(); else if (strcmp(argv[0], "aalogo") == 0) aalogo(); else if (strcmp(argv[0], "credits") == 0) { _kcolor('\011'); _kputs("DreamOS Credits\n\n"); _kputs("Main Developers:\n"); _kcolor('\012'); printf("Shainer - Lisa\n" "Finarfin - Ivan\n\n\n" ); _kcolor('\011'); _kputs("Contributors:\n"); _kcolor('\012'); _kputs("Osiris\n" "Celeron\n" "Hamcha\n" "m0nt0\n" "and many others (3 or 4 :P)\n\n"); _kcolor('\007'); } else if (strlen(cmd)>0) { printf(LNG_UNKNOWN_CMD " %s\n", argv[0]); } memset(string+5, 0, strlen(string)); memset(cmd, 0, strlen(cmd)); for (--argc; argc>=0; argc--) { free (argv[argc]); } } }
/** * @author Ivan Gualandri * @version 1.0 * * Questa funzione gestira a livello centralizzato le varie eccezione */ void _globalException(int n, int error) { switch (n) { case DIVIDE_ERROR: _kputs("Divide Error\n"); break; case DEBUG_EXC: _kputs("Debug Exception\n"); break; case NMI_INTERRUPT: _kputs("NMI Exception\n"); break; case OVERFLOW: _kputs("OverFlow Exception\n"); break; case BOUND_RANGE_EXCEED: _kputs("Bound Exception\n"); break; case DEV_NOT_AVL: _kputs("Device Not Available Exception\n"); break; case COPROC_SEG_OVERRUN: _kputs("CoProcessor Segment Overrun\n"); break; case BREAKPOINT: _kputs("BreakPoint\n"); break; case INVALID_TSS: _kputs("Invalid TSS\n"); break; case SEGMENT_NOT_PRESENT: _kputs("Segment Not Present\n"); break; case STACK_SEGMENT_FAULT: _kputs("Stack Segment Fault Exception\n"); break; case GENERAL_PROTECTION: _kputs("General Protection Exception\n"); break; case INVALID_OPCODE: _kputs("Invalid Opcode Exception\n"); break; case PAGE_FAULT: page_fault_handler (error); break; case INT_RSV: _kputs("Intel Reserved\n"); break; case FLOATING_POINT_ERR: _kputs("Floating Point Exception\n"); break; case ALIGNMENT_CHECK: _kputs("Alignment Check Exception\n"); break; case MACHINE_CHECK: _kputs("Machine Check Exception\n"); break; case DOUBLE_FAULT: _kputs("Double Fault Exception\n"); break; case SIMD_FP_EXC: _kputs ("Simd Floating Point Exception\n"); break; default: _kputs ("Unknown exception\n"); break; } }
void _int_rsv(){ _kputs("Eccezione Riservata - PANIC\n"); while(1); }
/* * The keyboard handler */ void keyboard_isr (void) { sc = inportb (0x60); // take scancode from the port /* error handling */ if (sc == 0x00 || sc == 0xFF) { _kputs ("Keyboard error\n"); goto end; } /* The right map is selected */ if (is_shifted == 0 && is_tab_pressed == 0) curmap = key_it_map; else if (is_shifted == 0 && is_tab_pressed) curmap = shifted_it_map; else if (is_shifted == 1 && is_tab_pressed == 0) curmap = shifted_it_map; else if (is_shifted == 1 && is_tab_pressed) curmap = key_it_map; /* In case of useless break codes, switch controls...*/ if (sc > CODE_BREAK && sc != (KEY_LSHIFT|CODE_BREAK) && sc != (KEY_RSHIFT|CODE_BREAK)){ if (sc==KEY_ENTER+128) outportb(MASTER_PORT, EOI); goto end; } switch (sc) { case KEY_LSHIFT: is_shifted = 1; break; case KEY_PGDOWN: _kscrolldown (); break; case KEY_PGUP: _kscrollup (); break; case KEY_RSHIFT: is_shifted = 1; break; case KEY_LSHIFT|CODE_BREAK: case KEY_RSHIFT|CODE_BREAK: is_shifted = 0; break; case CAPS_LED: if (is_tab_pressed == 0) { _ksetleds (1,-1,-1); is_tab_pressed = 1; } else { is_tab_pressed = 0; _ksetleds (0,-1,-1); } break; case NUM_LED: if (is_num_pressed == 0) { _ksetleds (-1,1,-1); is_num_pressed = 1; } else { _ksetleds (-1,0,-1); is_num_pressed = 0; } break; case SCROLL_LED: if (is_scroll_pressed == 0) { _ksetleds (-1,-1,1); is_scroll_pressed = 1; } else { _ksetleds (-1,-1,0); is_scroll_pressed = 0; } break; case KEY_ESCAPE: break; case KEY_BACKSPACE: if (STEP(buf_w) == buf_r) buf_r = STEP(buf_r); circlebuf[buf_w] = '\b'; buf_w = STEP(buf_w); _kbackspace(); _ksetcursauto(); break; case KEY_ENTER: if (STEP(buf_w) == buf_r) buf_r = STEP(buf_r); circlebuf[buf_w] = '\n'; buf_w = STEP(buf_w); _knewline(); _ksetcursauto(); last_tab = 0; outportb(MASTER_PORT, EOI); break; case KEY_TAB: if (STEP(buf_w) == buf_r) buf_r = STEP(buf_r); circlebuf[buf_w] = '\t'; buf_w = STEP(buf_w); _ktab(); _ksetcursauto(); last_tab++; break; case KEY_UPARROW: history_start(); _ksetcursauto(); break; case KEY_DOWNARROW: history_start(); _ksetcursauto(); break; case KEY_LEFTARROW: //_ksetcursor((_kgetline()), (_kgetcolumn() - 1)); break; case KEY_RIGHTARROW: //_ksetcursor((_kgetline()), (_kgetcolumn() + 1)); break; // Presente un bug qui che non permette il fix dei relativi tasti // se si decommenta, il sistema all'avvio va in panic e si riavvia case KEY_ALT: //_kputs("Alt key pressed, nothing to be done\n"); break; /*case KEY_ALTGR: break;*/ case KEY_CTRL: break; default: if (isdigit(key_it_map[sc]) && is_tab_pressed == 1) curmap = key_it_map; //printf ("%d", sc); if(shadow==0) putchar (curmap[sc]); /* Update buffer */ if (STEP(buf_w) == buf_r) buf_r = STEP(buf_r); circlebuf[buf_w] = curmap[sc]; buf_w = STEP(buf_w); } end: /* Send acknowledge */ //printf ("Prego"); outportb (MASTER_PORT, EOI); return; }