/* 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 */ #ifdef __ACK__ .globl _exit /* dummy for library routines */ .globl __exit /* dummy for library routines */ .globl ___exit /* dummy for library routines */ #endif .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 _write_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) */ .globl _fxsave .globl _fnsave .globl _fxrstor .globl _frstor .globl _clts /* * 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<