void fork() { struct Task* task = malloc(sizeof(struct Task)); if(!task) panic("Task alloc failed!"); memcpy(task, current_task, sizeof(struct Task)); task->segment = task_seg; task_seg += 0x1000; farmemcpy(0x0000, 0x0000, 0x8000, task->segment, current_task->segment); farmemcpy(0x8000, 0x8000, 0x8000, task->segment, current_task->segment); memsetw(task->stack, 0, KERNEL_STACK_WORDS); /* create a kernel stack for returning to userspace */ task->stack[KERNEL_STACK_WORDS - 1] = &kernel_exit; /* return address */ task->stack[KERNEL_STACK_WORDS - 2] = 0x0000; /* bp */ task->stack[KERNEL_STACK_WORDS - 3] = 0x0000; /* ax */ task->stack[KERNEL_STACK_WORDS - 4] = 0x0000; /* si */ task->stack[KERNEL_STACK_WORDS - 5] = 0x0000; /* di */ task->kernel_sp = &task->stack[KERNEL_STACK_WORDS - 5]; task->stack_top = &task->stack[KERNEL_STACK_WORDS - 1]; pokew(task->segment, task->user_sp + 18, task->segment); pokew(task->segment, task->user_sp + 12, 0); task->next = task_list; task_list = task; return; }
/* * Bios Keyboard Poll */ static void kbd_timer(int __data) { int dav; #if 0 static int clk[4] = {0x072D, 0x075C, 0x077C, 0x072F,}; static int c = 0; pokew(0xB800, (79+0*80)*2, clk[(c++)&0x03]); #endif #asm jmp nhp savekey: xor ah,ah int 0x16 push ax call _AddQueue pop ax nhp: mov ah, #0x01 int 0x16 xor ah,ah cmp al,#6 jge savekey #endasm restart_timer(); }
void VGASetTextMode(uint8_t high_res) { uint8_t font_height = 0; if(high_res) { VGAWriteRegisters(vga_text_90_60); vga_text_width = 90; vga_text_height = 60; font_height = 8; } else { VGAWriteRegisters(vga_text_80_25); vga_text_width = 80; vga_text_height = 25; font_height = 16; } /* Set font. */ if(font_height >= 16) { VGAWriteFont(vga_8x16_font, 16); } else { VGAWriteFont(vga_8x8_font, 8); } /* tell the BIOS what we've done, so BIOS text output works OK */ pokew(0x40, 0x4A, vga_text_width); /* columns on screen */ pokew(0x40, 0x4C, vga_text_width * vga_text_height * 2); /* framebuffer size */ pokew(0x40, 0x50, 0); /* cursor pos'n */ pokeb(0x40, 0x60, font_height - 1); /* cursor shape */ pokeb(0x40, 0x61, font_height - 2); pokeb(0x40, 0x84, vga_text_height - 1); /* rows on screen - 1 */ pokeb(0x40, 0x85, font_height); /* char height */ /* Set white-on-black for all text. */ for(size_t i = 0; i < vga_text_width * vga_text_height; i++) { pokeb(0xB800, i * 2 + 1, 7); } }
void env_delete(word segm) { DBG_ENTER("env_delete", Suppl_env) DBG_ARGUMENTS( ("env=%u", segm) ) chkMem unless_segm(segm) DBG_EXIT DBG_ARGUMENTS( ("effective env=%u", segm) ) pokew(SEG2MCB(segm), MCB_OFF_OWNER, _psp); freeBlk(segm); chkMem /* Make sure the deleted segment won't be referenced */ env_relocateSegment(segm, 0); DBG_EXIT }
int env_nullStrings(word segm) { word ofs; DBG_ENTER("env_nullStrings", Suppl_env) DBG_ARGUMENTS( ("env=%u", segm) ) chkMem unless_segm(segm) DBG_RETURN_I( ESUPPL_NOENV) DBG_ARGUMENTS( ("effective env=%u", segm) ) ofs = env_endOfVars(segm) + 1; /* offset of string counter word */ if(mcb_length(segm) - 2 <= ofs) DBG_RETURN_I( ESUPPL_NOMEM) pokew(segm, ofs, 0); chkMem DBG_RETURN_I( ESUPPL_OK) }
void task_set_register(struct Task* task, unsigned int reg, unsigned int value) { pokew(task->segment, task->user_sp + reg, value); }
void put_ustack(register struct task_struct *t,int off,int val) { pokew(t->t_regs.ss, t->t_regs.sp+off, (__u16) val); }