void SysinfoMain(Tab *tab) { Task *task = TaskSwitcher::getNowTask(); int count = 0, count0 = 0; Sheet *sht = tab->sheet; // タイマー作成 Timer *timer = new Timer(task->queue); // タブが閉じられた時消えるように tab->timer = timer; // タイマーセット (1s) timer->set(100); showSysInfo(sht, 0); for (;;) { ++count; Cli(); if (task->queue->isempty()) { //task->sleep(); ベンチマーク測定のため Sti(); } else { int data = task->queue->pop(); Sti(); if (data == timer->data) { showSysInfo(sht, count - count0); count0 = count; timer->set(100); } } } }
//Proceso Top int Tope(int argc, char* argv[]) { char* video= (char*)0xb8000; int proce[65]; char Mensaje [10]; int salto; int i; char a; k_clear_screen(); message("Top V1.0: Procesos y porcentaje de CPU utilizada",0,10); message("PID CPU% TTY NAME",2,0); Sti(); while(a!=68) { a=GetKey(); salto=3; for(i=0;i<65;i++) { proce[i]=0; } for(i=0;i<100;i++) { proce[last100[i]]++; } Cli(); for(i=0;i<65;i++) { PROCESS* p=GetProcessByPID(i); if(p->free==0) { itoa2(i,Mensaje); message(Mensaje,salto,0); itoa2(proce[i],Mensaje); message(Mensaje,salto,28); itoa2(p->tty,Mensaje); message(Mensaje,salto,56); message(p->name,salto,78); salto=salto+1; } message(" ",salto,0); } if (argc>1) i=atoi2(argv[1]); else i=0; Sti(); Sleep(i); } return 0; }
// Starts the kernel's idle process. This process has kernel permissions. int idle_main(int argc, char ** params) { int i = 0; char a[] = { ' ', 0x07 }; for(; i < 2000; ++i) { memcpy((char*)0xb8000 + i * 2, a, 2); } // The funny message, windows says starting windows... why shouldn't we? D: char start_msg[][2] = { { 'S', 0x07 }, { 't', 0x08 }, { 'a', 0x09 }, { 'r', 0x0a }, { 't', 0x0b }, { 'i', 0x0c }, { 'n', 0x0d }, { 'g', 0x0e }, { ' ', 0x0f }, { 'M', 0x02 }, { 'o', 0x03 }, { 'n', 0x04 }, { 'i', 0x05 }, { 'x', 0x06 }, { ' ', 0x0f }, { '\001', 0x5f }, }; i = 0; for(; i < 16; ++i) { memcpy((char*)0xb8000 + i * 2, start_msg[i], 2); _setCursor(i); } Cli(); make_atomic(); mount(); // Mount or start the FS tty_init(0); // Load up the TTY's tty_init(1); tty_init(2); tty_init(3); tty_init(4); tty_init(5); setready(); // Set the kernel as ready and the FS as loaded users_init(); // Init the users fs_finish(); release_atomic(); Sti(); while(1) { _Halt(); // Now set to idle. } }
//Funcion a donde van a parar las funciones que terminan. void Cleaner(void) { char Men[10]; Cli(); Destroy(CurrentPID); k_clear_screen(); mess("==>"); Sti(); while(1); }
int _dfill (int argc, char ** argv) { int j = 0; for(j = 0; j < 1000; ++j) { int count = 384; int bytes = 65536; int sector = 1 + j * 128; if(argc > 1) { int i; sector = atoi(argv[1]); for(i = 0; i < 65536; ++i) { ans[i] = '0' + (i / 512) % 10; } int offset = 0; int ata = ATA0; Cli(); _disk_write(ata, ans, count, sector); for(i = 0; i < 65536; ++i) { ans[i] = 0; } // _disk_read(ata, ans, count, sector); Sti(); printf("%d\n", j); // for(i = 0; i < count; ++i) { // if(ans[i * 512] != i % 10 + '0') { // printf("Err %d %d %d %d\n", i % 10 + '0', ans[i * 512], i, j); // getC(); // break; // } // } } } return 0; }
/********************************************** kmain() Punto de entrada de código C. *************************************************/ kmain() { int i, num; // Paging.start(0x200000); // init_malloc(); initialize_pics(0x20,0x70); setup_IDT_entry(&idt[0x70], 0x08, (dword) & _rtc, ACS_INT, 0); _cache_init(); hdd_init(); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ0 */ setup_IDT_entry (&idt[0x00], 0x08, (dword)&_int_00_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x01], 0x08, (dword)&_int_01_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x02], 0x08, (dword)&_int_02_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x03], 0x08, (dword)&_int_03_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x04], 0x08, (dword)&_int_04_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x05], 0x08, (dword)&_int_05_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x06], 0x08, (dword)&_int_06_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x07], 0x08, (dword)&_int_07_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x08], 0x08, (dword)&_int_08_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x09], 0x08, (dword)&_int_09_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x0A], 0x08, (dword)&_int_0A_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x0B], 0x08, (dword)&_int_0B_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x0C], 0x08, (dword)&_int_0C_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x0D], 0x08, (dword)&_int_0D_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x0E], 0x08, (dword)&_int_0E_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x0F], 0x08, (dword)&_int_0F_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x10], 0x08, (dword)&_int_10_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x11], 0x08, (dword)&_int_11_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x12], 0x08, (dword)&_int_12_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x13], 0x08, (dword)&_int_13_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x14], 0x08, (dword)&_int_14_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x15], 0x08, (dword)&_int_15_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x16], 0x08, (dword)&_int_16_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x17], 0x08, (dword)&_int_17_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x18], 0x08, (dword)&_int_18_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x19], 0x08, (dword)&_int_19_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x1A], 0x08, (dword)&_int_1A_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x1B], 0x08, (dword)&_int_1B_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x1C], 0x08, (dword)&_int_1C_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x1D], 0x08, (dword)&_int_1D_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x1E], 0x08, (dword)&_int_1E_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x1F], 0x08, (dword)&_int_1F_hand, ACS_INT, 0); // setup_IDT_entry (&idt[0x20], 0x08, (dword)&_int_20_hand, ACS_INT, 0); // setup_IDT_entry (&idt[0x21], 0x08, (dword)&_int_21_hand, ACS_INT, 0); setup_IDT_entry(&idt[0x20], 0x08, (dword) & _timer_tick_hand, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ1 */ setup_IDT_entry(&idt[0x21], 0x08, (dword) & _KB_hand, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE int80h */ setup_IDT_entry(&idt[0x80], 0x08, (dword) & _int_80_hand, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE int79h */ setup_IDT_entry(&idt[0x79], 0x08, (dword) & _int_79_hand, ACS_INT, 0); /* Carga de IDTR */ idtr.base = 0; idtr.base += (dword) & idt; idtr.limit = sizeof(idt) - 1; _lidt(&idtr); Cli(); int rate = 0x06; _outb(0x70, 0x0A); //set index to register A char prev=_inb(0x71); //get initial value of register A _outb(0x70, 0x0A); //reset index to A _outb(0x71, (prev & 0xF0) | rate); //write only our rate to A. Note, rate is the bottom 4 bits. init_paging(); scheduler_init(); /* Habilito interrupcion de timer tick*/ _mascaraPIC1(0xFC); _mascaraPIC2(0xFE); _outb(0x70, 0x0B); //set the index to register B prev= _inb(0x71); //read the current value of register B _outb(0x70, 0x0B); //set the index again(a read will reset the index to register D) _outb(0x71, prev | 0x40); //write the previous value or'd with 0x40. This turns on bit 6 of register B Sti(); idle = create_process("idle", idle_main, 0, 0, 0, 0, 0, 0, 0, NULL, 0); // We soon exit out of here :) while (1); }
/********************************************** kmain() Punto de entrada de código C. *************************************************/ kmain() { int i, num; setup_IDT_entry(&idt[0x70], 0x08, (dword) & _rtc, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ0 */ setup_IDT_entry(&idt[0x08], 0x08, (dword) & _int_08_hand, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ1 */ setup_IDT_entry(&idt[0x09], 0x08, (dword) & _int_09_hand, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE int80h */ setup_IDT_entry(&idt[0x80], 0x08, (dword) & _int_80_hand, ACS_INT, 0); /* CARGA DE IDT CON LA RUTINA DE ATENCION DE int79h */ setup_IDT_entry(&idt[0x79], 0x08, (dword) & _int_79_hand, ACS_INT, 0); /* Carga de IDTR */ idtr.base = 0; idtr.base += (dword) & idt; idtr.limit = sizeof(idt) - 1; _lidt(&idtr); Cli(); int rate = 0x06; _outb(0x70, 0x0A); //set index to register A char prev=_inb(0x71); //get initial value of register A _outb(0x70, 0x0A); //reset index to A _outb(0x71, (prev & 0xF0) | rate); //write only our rate to A. Note, rate is the bottom 4 bits. scheduler_init(); /* Habilito interrupcion de timer tick*/ _mascaraPIC1(0x00); _mascaraPIC2(0x00); _outb(0x70, 0x0B); //set the index to register B prev= _inb(0x71); //read the current value of register B _outb(0x70, 0x0B); //set the index again(a read will reset the index to register D) _outb(0x71, prev | 0x40); //write the previous value or'd with 0x40. This turns on bit 6 of register B Sti(); idle = create_process("idle", idle_main, 0, 0, 0, 0, 0, 0, 0, NULL, 0); // We soon exit out of here :) while (1); }