bioscall.c

Go to the documentation of this file.
00001 /*****************************************************************************************
00002  Copyright (c) 2002-2004 The UbixOS Project
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without modification, are
00006  permitted provided that the following conditions are met:
00007 
00008  Redistributions of source code must retain the above copyright notice, this list of
00009  conditions, the following disclaimer and the list of authors.  Redistributions in binary
00010  form must reproduce the above copyright notice, this list of conditions, the following
00011  disclaimer and the list of authors in the documentation and/or other materials provided
00012  with the distribution. Neither the name of the UbixOS Project nor the names of its
00013  contributors may be used to endorse or promote products derived from this software
00014  without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00017  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00018  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00019  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00021  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00023  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00024  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026  $Id: bioscall_8c-source.html 88 2016-01-12 00:11:29Z reddawg $
00027 
00028 *****************************************************************************************/
00029 
00030 #include <sys/tss.h>
00031 #include <ubixos/sched.h>
00032 #include <vmm/vmm.h>
00033 #include <lib/kmalloc.h>
00034 #include <lib/bioscall.h>
00035 #include <lib/string.h>
00036 #include <sys/video.h>
00037 #include <assert.h>
00038 
00039 
00040 asm(
00041   ".globl bios16Code\n"
00042   ".code16          \n"
00043   "bios16Code:      \n"
00044   "int $0x10        \n"
00045   "int $0x69        \n"
00046   ".code32          \n"
00047   );
00048 
00049   
00050 void biosCall(int biosInt,int eax,int ebx,int ecx,int edx,int esi,int edi,int es,int ds) {
00051   short segment = 0x0,offset = 0x0;
00052   uInt32 tmpAddr = (uInt32)&bios16Code;
00053   kTask_t *newProcess = 0x0;
00054 
00055   offset = tmpAddr & 0xF;  // lower 4 bits
00056   segment = tmpAddr >> 4;
00057   
00058   newProcess = schedNewTask();
00059   assert(newProcess);
00060 
00061 
00062   newProcess->tss.back_link    = 0x0;
00063   newProcess->tss.esp0         = (uInt32)kmalloc(0x2000)+0x2000;
00064   newProcess->tss.ss0          = 0x10;
00065   newProcess->tss.esp1         = 0x0;
00066   newProcess->tss.ss1          = 0x0;
00067   newProcess->tss.esp2         = 0x0;
00068   newProcess->tss.ss2          = 0x0;
00069   newProcess->tss.cr3          = (uInt32)_current->tss.cr3;//(uInt32)vmmCreateVirtualSpace(newProcess->id);
00070   newProcess->tss.eip          =  offset & 0xFFFF;
00071   newProcess->tss.eflags       = 2 | EFLAG_IF | EFLAG_VM;
00072   newProcess->tss.eax          =     eax & 0xFFFF;
00073   newProcess->tss.ebx          =     ebx & 0xFFFF;
00074   newProcess->tss.ecx          =     ecx & 0xFFFF;
00075   newProcess->tss.edx          =     edx & 0xFFFF;
00076   newProcess->tss.esp          =  0x1000 & 0xFFFF;
00077   newProcess->tss.ebp          =  0x1000 & 0xFFFF;
00078   newProcess->tss.esi          =     esi & 0xFFFF;
00079   newProcess->tss.edi          =     edi & 0xFFFF;
00080   newProcess->tss.es           =      es & 0xFFFF;
00081   newProcess->tss.cs           = segment & 0xFFFF;
00082   newProcess->tss.ss           =  0x1000 & 0xFFFF;
00083   newProcess->tss.ds           =      ds & 0xFFFF;
00084   newProcess->tss.fs           =     0x0 & 0xFFFF;
00085   newProcess->tss.gs           =     0x0 & 0xFFFF;
00086   newProcess->tss.ldt          =     0x0 & 0xFFFF;
00087   newProcess->tss.trace_bitmap =     0x0 & 0xFFFF;
00088   newProcess->tss.io_map       =     0x0 & 0xFFFF;
00089   newProcess->tss.io_map       = sizeof(struct tssStruct)-8192;
00090   newProcess->oInfo.v86Task    = 0x1;
00091 
00092   newProcess->state = READY;
00093 
00094   while (newProcess->state > 0);
00095 
00096   return;
00097   }    
00098 
00099 /***
00100  END
00101  ***/
00102 

Generated on Fri Dec 15 11:18:55 2006 for UbixOS V2 by  doxygen 1.4.7