sm.s /* * asm.s contains the low-level code for most hardware - TopicsExpress



          

sm.s /* * asm.s contains the low-level code for most hardware faults. * page_exception is handled by the mm, so that isnt here. This * file also handles (hopefully) fpu-exceptions due to TS-bit, as * the fpu must be properly saved/resored. This hasnt been tested. */ .globl _divide_error,_debug,_nmi,_int3,_overflow,_bounds,_invalid_op .globl _device_not_available,_double_fault,_coprocessor_segment_overrun .globl _invalid_TSS,_segment_not_present,_stack_segment .globl _general_protection,_coprocessor_error,_reserved _divide_error: pushl $_do_divide_error no_error_code: xchgl %eax,(%esp) pushl %ebx pushl %ecx pushl %edx pushl %edi pushl %esi pushl %ebp push %ds push %es push %fs pushl $0 # error code lea 44(%esp),%edx pushl %edx movl $0x10,%edx mov %dx,%ds mov %dx,%es mov %dx,%fs call *%eax addl $8,%esp pop %fs pop %es pop %ds popl %ebp popl %esi popl %edi popl %edx popl %ecx popl %ebx popl %eax iret _debug: pushl $_do_int3 # _do_debug jmp no_error_code _nmi: pushl $_do_nmi jmp no_error_code _int3: pushl $_do_int3 jmp no_error_code _overflow: pushl $_do_overflow jmp no_error_code _bounds: pushl $_do_bounds jmp no_error_code _invalid_op: pushl $_do_invalid_op jmp no_error_code math_emulate: popl %eax pushl $_do_device_not_available jmp no_error_code _device_not_available: pushl %eax movl %cr0,%eax bt $2,%eax # EM (math emulation bit) jc math_emulate clts # clear TS so that we can use math movl _current,%eax cmpl _last_task_used_math,%eax je 1f # shouldnt happen really ... pushl %ecx pushl %edx push %ds movl $0x10,%eax mov %ax,%ds call _math_state_restore pop %ds popl %edx popl %ecx 1: popl %eax iret _coprocessor_segment_overrun: pushl $_do_coprocessor_segment_overrun jmp no_error_code _reserved: pushl $_do_reserved jmp no_error_code _coprocessor_error: pushl $_do_coprocessor_error jmp no_error_code _double_fault: pushl $_do_double_fault error_code: xchgl %eax,4(%esp) # error code %eax xchgl %ebx,(%esp) # &function %ebx pushl %ecx pushl %edx pushl %edi pushl %esi pushl %ebp push %ds push %es push %fs pushl %eax # error code lea 44(%esp),%eax # offset pushl %eax movl $0x10,%eax mov %ax,%ds mov %ax,%es mov %ax,%fs call *%ebx addl $8,%esp pop %fs pop %es pop %ds popl %ebp popl %esi popl %edi popl %edx popl %ecx popl %ebx popl %eax iret _invalid_TSS: pushl $_do_invalid_TSS jmp error_code _segment_not_present: pushl $_do_segment_not_present jmp error_code _stack_segment: pushl $_do_stack_segment jmp error_code _general_protection: pushl $_do_general_protection jmp error_code console.c /* * console.c * * This module implements the console io functions * void con_init(void) * void con_write(struct tty_queue * queue) * Hopefully this will be a rather complete VT102 implementation. * */ /* * NOTE!!! We sometimes disable and enable interrupts for a short while * (to put a word in video IO), but this will work even for keyboard * interrupts. We know interrupts arent enabled when getting a keyboard * interrupt, as we use trap-gates. Hopefully all is well. */ #include #include #include #include #define SCREEN_START 0xb8000 #define SCREEN_END 0xc0000 #define LINES 25 #define COLUMNS 80 #define NPAR 16 extern void keyboard_interrupt(void); static unsigned long origin=SCREEN_START; static unsigned long scr_end=SCREEN_START+LINES*COLUMNS*2; static unsigned long pos; static unsigned long x,y; static unsigned long top=0,bottom=LINES; static unsigned long lines=LINES,columns=COLUMNS; static unsigned long state=0; static unsigned long npar,par[NPAR]; static unsigned long ques=0; static unsigned char attr=0x07; /* * this is what the terminal answers to a ESC-Z or csi0c * query (= vt100 response). */ #define RESPONSE 33[?1;2c static inline void gotoxy(unsigned int new_x,unsigned int new_y) { if (new_x>=columns || new_y>=lines) return; x=new_x; y=new_y; pos=origin+((y*columns+x)9),0x3d5); outb_p(13,0x3d4); outb_p(0xff&((origin-SCREEN_START)>>1),0x3d5); sti(); } static void scrup(void) { if (!top && bottom==lines) { origin += columnspid == pid) send_sig(sig,*p,priv); } else if (pid == -1) while (--p > &FIRST_TASK) send_sig(sig,*p,priv); else while (--p > &FIRST_TASK) if (*p && (*p)->pgrp == -pid) send_sig(sig,*p,priv); } int sys_kill(int pid,int sig) { do_kill(pid,sig,!(current->uid || current->euid)); return 0; } int do_exit(long code) { int i; free_page_tables(get_base(current->ldt[1]),get_limit(0x0f)); free_page_tables(get_base(current->ldt[2]),get_limit(0x17)); for (i=0 ; ifather == current->pid) task->father = 0; for (i=0 ; ifilp) sys_close(i); iput(current->pwd); current->pwd=NULL; iput(current->root); current->root=NULL; if (current->leader && current->tty >= 0) tty_table[current->tty].pgrp = 0; if (last_task_used_math == current) last_task_used_math = NULL; if (current->father) { current->state = TASK_ZOMBIE; do_kill(current->father,SIGCHLD,1); current->exit_code = code; } else release(current); schedule(); return (-1); /* just to suppress warnings */ } int sys_exit(int error_code) { return do_exit((error_code&0xff)pid==pid || (pid==0 && (*p)->pgrp==current->pgrp) || (pidpgrp==-pid))) if ((*p)->father == current->pid) { flag=1; if ((*p)->state==TASK_ZOMBIE) { put_fs_long((*p)->exit_code, (unsigned long *) stat_addr); current->cutime += (*p)->utime; current->cstime += (*p)->stime; flag = (*p)->pid; release(*p); return flag; } } if (flag) { if (options & WNOHANG) return 0; sys_pause(); if (!(current->signal &= ~(1
Posted on: Fri, 18 Oct 2013 21:19:30 +0000

Trending Topics



Recently Viewed Topics




© 2015