/* sections */ #include #include #include #include "archconst.h" #include "kernel/const.h" #include "sconst.h" /* * This file contains a number of assembly code utility routines needed by the * kernel. They are: */ .globl monitor /* exit Minix and return to the monitor */ .globl int86 /* let the monitor make an 8086 interrupt call */ .globl exit /* dummy for library routines */ .globl _exit /* dummy for library routines */ .globl __exit /* dummy for library routines */ .globl __main /* dummy for GCC */ .globl phys_insw /* transfer data from (disk controller) port to memory */ .globl phys_insb /* likewise byte by byte */ .globl phys_outsw /* transfer data from memory to (disk controller) port */ .globl phys_outsb /* likewise byte by byte */ .globl phys_copy /* copy data from anywhere to anywhere in memory */ .globl phys_copy_fault /* phys_copy pagefault */ .globl phys_copy_fault_in_kernel /* phys_copy pagefault in kernel */ .globl phys_memset /* write pattern anywhere in memory */ .globl mem_rdw /* copy one word from [segment:offset] */ .globl reset /* reset the system */ .globl halt_cpu/* halts the current cpu when idle */ .globl read_cpu_flags /* read the cpu flags */ .globl read_cr0 /* read cr0 */ .globl read_cr2 /* read cr2 */ .globl getcr3val .globl write_cr0 /* write a value in cr0 */ .globl read_cr3 .globl read_cr4 .globl write_cr4 .globl catch_pagefaults .globl read_ds .globl read_cs .globl read_ss .globl idt_reload /* reload idt when returning to monitor. */ .globl fninit /* non-waiting FPU initialization */ .globl fnstsw /* store status word (non-waiting) */ .globl fnstcw /* store control word (non-waiting) */ /* * The routines only guarantee to preserve the registers the C compiler * expects to be preserved (ebx, esi, edi, ebp, esp, segment registers, and * direction bit in the flags). */ .text /*===========================================================================*/ /* monitor */ /*===========================================================================*/ /* PUBLIC void monitor(); */ /* Return to the monitor. */ monitor: movl mon_sp, %esp /* restore monitor stack pointer */ movw $SS_SELECTOR, %dx /* monitor data segment */ mov %dx, %ds mov %dx, %es mov %dx, %fs mov %dx, %gs mov %dx, %ss pop %edi pop %esi pop %ebp lretw /* return to the monitor */ /*===========================================================================*/ /* int86 */ /*===========================================================================*/ /* PUBLIC void int86(); */ int86: cmpb $0, mon_return /* is the monitor there? */ jne 0f movb $0x01, %ah /* an int 13 error seems appropriate */ movb %ah, reg86+0 /* reg86.w.f = 1 (set carry flag) */ movb %ah, reg86+13 /* reg86.b.ah = 0x01 = "invalid command" */ ret 0: push %ebp /* save C registers */ push %esi push %edi push %ebx pushf /* save flags */ cli /* no interruptions */ inb $INT2_CTLMASK movb %al, %ah inb $INT_CTLMASK push %eax /* save interrupt masks */ movl irq_use, %eax /* map of in-use IRQ's */ and $~(1<