void setup_PIC(){ _Cli(); _outb(0x21,0xFC); _outb(0xA1,0xFF); _Sti(); return; }
int Idle(int argc, char* argv[]) { _Sti(); while(1) ; return 0; }
int imprimeDos(int argc, char *argv){ _Sti(); while(1) { printf("2"); } return EXIT_SUCCESS; }
void logout(int argc, char * argv[]) { int i; usrLoged = 0; for(i = 0; i < 4; i++) kill(terminals[i].PID); logPID = CreateProcessAt("logUsr", (int(*)(int, char**))logUser, currentProcessTTY, 0, (char**)0, PAGE_SIZE, 4, 1); _Sti(); }
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(); }
void logUser(void) { int i, fd, usrNotFound, j; user * usr; current = superblock->root; currentUsr.group = ADMIN; fd = do_open("usersfile", 777, 777); usr = malloc(sizeof(user) * 100); do_read(fd, (char *)usr, sizeof(user) * 100); while(!usrLoged) { usrNotFound = 1; printf("username: "******"%s", buffcopy); for(i = 0; i < 100 && usr[i].usrID != 0 && usrNotFound; i++) { if(strcmp(usr[i].name, buffcopy)) { usrNotFound = 0; } } usrName = 0; printf("\n"); clearTerminalBuffer(currentTTY); for(j = 0; j < BUFFER_SIZE; j++) buffcopy[j] = 0; if(!usrNotFound) { printf("password: "******"%s", buffcopy); if(strcmp(usr[i - 1].password, buffcopy)) { usrLoged = 1; currentUsr.usrID = usr[i - 1].usrID; currentUsr.group = usr[i - 1].group; } else printf("\nIncorrect password. Please try again"); password = 0; printf("\n"); } else printf("User not found. Please try again\n"); clearTerminalBuffer(currentTTY); for(j = 0; j < BUFFER_SIZE; j++) buffcopy[j] = 0; } terminals[0].PID = CreateProcessAt("Shell0", (int(*)(int, char**))shell, 0, 0, (char**)0, PAGE_SIZE, 2, 1); //printf("terminals[0].PID \n"); terminals[1].PID = CreateProcessAt("Shell1", (int(*)(int, char**))shell, 1, 0, (char**)0, PAGE_SIZE, 2, 1); //printf("terminals[1].PID \n"); terminals[2].PID = CreateProcessAt("Shell2", (int(*)(int, char**))shell, 2, 0, (char**)0, PAGE_SIZE, 2, 1); //printf("terminals[2].PID \n"); terminals[3].PID = CreateProcessAt("Shell3", (int(*)(int, char**))shell, 3, 0, (char**)0, PAGE_SIZE, 2, 1); //printf("terminals[3].PID \n"); //do_close(fd); //free(usr); _Sti(); return; }