void schedule(unsigned int *stack){ if(active == TRUE){ task_t* cur_task = dequeue_task(); if(cur_task != NULL){ cur_pid = cur_task->pid; dbg_bochs_print("@@@@@@@"); dbg_bochs_print(cur_task->name); if(cur_task->status!=NEW){ cur_task->esp=*stack; } else { cur_task->status=READY; ((task_register_t *)(cur_task->esp))->eip = cur_task->eip; } enqueue_task(cur_task->pid, cur_task); cur_task=get_task(); if(cur_task->status==NEW){ cur_task->status=READY; } dbg_bochs_print(" -- "); dbg_bochs_print(cur_task->name); dbg_bochs_print("\n"); //load_pdbr(cur_task->pdir); *stack = cur_task->esp; } else { enqueue_task(cur_task->pid, cur_task); } } active = FALSE; return; }
/** * Create a new task * @author Ivan Gualandri * @version 1.0 * @param task_name The name of the task * @param start_function the entry point of the task. */ pid_t new_task(char *task_name, void (*start_function)()){ asm("cli"); task_t *new_task; table_address_t local_table; unsigned int new_pid = request_pid(); new_task = (task_t*)kmalloc(sizeof(task_t)); strcpy(new_task->name, task_name); new_task->next = NULL; new_task->start_function = start_function; new_task->cur_quants=0; new_task->pid = new_pid; new_task->eip = (unsigned int)start_function; new_task->esp = (unsigned int)kmalloc(STACK_SIZE) + STACK_SIZE-100; new_task->tty = tty_get_current(); dbg_bochs_print(new_task->esp); new_task->status = NEW; new_task->registers = (task_register_t*)new_task->esp; new_tss(new_task->registers, start_function); local_table = map_kernel(); new_task->pdir = local_table.page_dir; new_task->ptable = local_table.page_table; //new_task->pdir = 0; //new_task->ptable = 0; enqueue_task(new_task->pid, new_task); //(task_list.current)->cur_quants = MAX_TICKS; asm("sti"); return new_pid; }
void suicide() { task_t* cur_task; cur_task = get_task(); cur_task->status = DEAD; dbg_bochs_print("suicide\n"); while(TRUE); }
void tasks_init(){ asm("cli"); printf("Init tasks"); dbg_bochs_print("Task array setup"); task_list.head = NULL; task_list.tail = NULL; task_list.size = 0; current_pid = 0; asm("sti"); }
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; }