int kmain() { initializeBuffer(); cursor = 0; /* Borra la pantalla. */ clearScreen(); /* CARGA DE IDT */ setup_IDT_content(); /* Carga de IDTR */ setup_IDTR(); _Cli(); _mascaraPIC1(0xFC); /*Habilito timer tick, teclado*/ _mascaraPIC2(0xFF); /*Las interrupciones del segundo PIC quedan deshabilitadas*/ _Sti(); showSplashScreen(); shell(); _Cli(); goodbye(); _Sti(); return 0; }
kmain() { int i,num; /* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ0 */ 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[0x80], 0x08, (dword)&_int_80_hand, ACS_INT, 0); /* Carga de IDTR */ idtr.base = 0; idtr.base +=(dword) &idt; idtr.limit = sizeof(idt)-1; _lidt (&idtr); _Cli(); /* Habilito interrupcion de timer tick*/ //_mascaraPIC1(INT_08 & INT_09 & INT_80); _mascaraPIC1(0x00); _mascaraPIC2(NONE); _Sti(); initKeyBoard(); initVideo(); initShell(); doubleFlagsFix(1.1); while (1) { updateShell(); } }
void setup_PIC(){ _Cli(); _outb(0x21,0xFC); _outb(0xA1,0xFF); _Sti(); return; }
void kill_in_kernel(int pid) { PROCESS * proc; PROCESS * parent; processNode * aux; int i,j; _Cli(); for (j = 0; j < 4; j++){ if( pid == terminals[j].PID && usrLoged ){ return; } } if(pid == 0 || pid == logoutPID || pid == logPID) { _Sti(); return; } if(pid == CurrentPID) actualKilled = 1; proc = GetProcessByPID(pid); if(proc->foreground){ parent = GetProcessByPID(proc->parent); if(parent->waitingPid == proc->pid) { parent->waitingPid = 0; awake_process(parent->pid); } } aux = ((processNode*)ready); while(aux != NULL) { if(aux->process->parent == pid) kill(aux->process->pid); aux = ((processNode*)aux->next); } aux = ((processNode *)ready); if(aux->process->pid == pid) ready = aux->next; else { while(aux->next != NULL && ((processNode *)aux->next)->process->pid != pid) aux = ((processNode *)aux->next); if(aux->next != NULL) aux->next = ((processNode*)aux->next)->next; } for(i = 0; i < 100; i++) if(last100[i] == proc->pid) last100[i] = -1; clear_proc_ptable(pid); _Sti(); return ; }
static void b_write(int p, const void *buff, int size) { int i; _Cli(); for(i = 0; i < size; i++) { myout( p , ( (byte *) buff )[i] ); } _Sti(); }
void send_departing_buffer(int cursor) { while (is_transmit_empty() == 0) ; int i = 0; for (i = 0; i < cursor; i++) { _Cli(); _outb(SERIAL_PORT, departing_buffer[i]); //no quiero ser interrumpido mientras escribo en el P.S _Sti(); } }
/********************************************** Starting point of the whole OS *************************************************/ int kmain() { int i, h; char * buffer = calloc(512 , 1); _Cli(); k_clear_screen(); printf("screen clear\n"); //cache_initarray(); printf("array init\n"); //cache_sortarray(); printf("array sort\n"); initializeSemaphoreTable(); printf("semaphore init\n"); initializeIDT(); unmaskPICS(); initializePaging(); _StartCR3(); SetupScheduler(); //printf("after SetupScheduler\n"); for(h = 0; h < 200; h++){ write_disk(0,h,buffer,BLOCK_SIZE,0); } fd_table = (filedescriptor *)calloc(100,1); masterBootRecord * mbr = (masterBootRecord *)malloc(512); superblock = (masterBlock*)malloc(512); bitmap = (BM*)calloc(BITMAP_SIZE,1); inodemap = (IM*)calloc(INODEMAP_SIZE,1); read_disk(0,0,mbr,BLOCK_SIZE,0); if ( mbr->existFS == 0 ){ init_filesystem("Chinux", mbr); }else{ load_filesystem(); } ready = NULL; for(i = 0; i < 4; i++) startTerminal(i); //free(mbr); logPID = CreateProcessAt("Login", (int(*)(int, char**))logUser, 0, 0, (char**)0, PAGE_SIZE, 4, 1); _Sti(); while(TRUE) ; return 1; }
static void s_write(const void* buff, int size) { int i; char *video = (char *) 0xb8000; _Cli(); for(i = 0; i < size; i++) { video[screen_pos++]= *((char*)buff+i); video[screen_pos++]= WHITE_TXT; } _Sti(); }
static void k_read(char *buff, int size) { int i=0; _Cli(); while( !BufferIsEmpty() && i< size ) { buff[i] = GetFromBuffer() ; i++; } _Sti(); }
void k_shutdown(){ k_disable(); k_shutdownScreen(); // Just to appreciate the art _Sti(); sleep(30); if(ACPIinitialized()){ acpiPowerOff(); }else{ _Cli(); while(1){} } return; }
kmain() { int i, num; /* Borra la pantalla. */ /* 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); //TODO: CARGAR LA PAG DE TABLAS /* Carga de IDTR */ idtr.base = 0; idtr.base += (dword) & idt; idtr.limit = sizeof(idt) - 1; _lidt(&idtr); _Cli(); /* Habilito interrupcion de timer tick*/ _mascaraPIC1(0xFC); _mascaraPIC2(0xFF); _Sti(); startKeyboard(); initVideo(); shellStart(); /* KeepAlive loop */ while (1) { // Main del shell shellMain(); } }
static void s_read(char *buff, int size) { int i=0; char * video; video = (char *) 0xb8000; _Cli(); while( i< size ) { buff[i] = *(video + screen_pos + CANT_COLS *2); i++; } _Sti(); }
void end_process(void) { PROCESS * proc; PROCESS * parent; processNode * aux; int i; _Cli(); actualKilled = 1; proc = GetProcessByPID(CurrentPID); if(!proc->foreground) printf("[%d]\tDone\t%s\n", proc->pid, proc->name); else{ parent = GetProcessByPID(proc->parent); if(parent->waitingPid == proc->pid) { parent->waitingPid = 0; awake_process(parent->pid); } } aux = ((processNode *)ready); if(aux->process->pid == CurrentPID) ready = aux->next; else { while(aux->next != NULL && ((processNode *)aux->next)->process->pid != CurrentPID) aux = ((processNode *)aux->next); if(aux->next != NULL) aux->next = ((processNode*)aux->next)->next; } for(i = 0; i < 100; i++) if(last100[i] == proc->pid) last100[i] = -1; clear_proc_ptable(proc->pid); printf("Welcome\n"); _Sti(); return ; }
kmain() { int i,num; int flag = 0; int vendor = 0xffff; /* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ0 y IRQ1 */ // setup_IDT_entry (&idt[0x08], 0x08, (dword)&_int_08_hand, ACS_INT, 0); setup_IDT_entry (&idt[0x80], 0x08, (dword)&_int_80_hand, ACS_INT, 0); /* Por default el teclado esta en ingles */ setup_IDT_entry (&idt[0x09], 0x08, (dword)&_int_09_hand_US,ACS_INT, 0); /* Carga de IDTR */ idtr.base = 0; idtr.base +=(dword) &idt; idtr.limit = sizeof(idt)-1; _lidt (&idtr); _Cli(); /* Habilito interrupcion del teclado */ _mascaraPIC1(0xFD); _mascaraPIC2(0xFF); _Sti(); /* Se inicia el shell */ shell(); }