- Main Page
- Data Structures
- Files
- Directories

- Search for |

- File List
- Globals

# main.c

Go to the documentation of this file.

    00001 /*****************************************************************************************
    00002  Copyright (c) 2002-2004, 2005 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: main_8c-source.html 88 2016-01-12 00:11:29Z reddawg $
    00027
    00028 *****************************************************************************************/
    00029
    00030 #include <ubixos/init.h>
    00031 #include <sys/gdt.h>
    00032 #include <sys/video.h>
    00033 #include <sys/tss.h>
    00034 #include <ubixos/exec.h>
    00035 #include <ubixos/kpanic.h>
    00036 #include <ubixos/systemtask.h>
    00037 #include <vfs/mount.h>
    00038 #include <lib/kprintf.h>
    00039 #include <lib/kmalloc.h>
    00040
    00041 #define B_ADAPTORSHIFT          24
    00042 #define B_ADAPTORMASK           0x0f
    00043 #define B_ADAPTOR(val)          (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK)
    00044 #define B_CONTROLLERSHIFT       20
    00045 #define B_CONTROLLERMASK        0xf
    00046 #define B_CONTROLLER(val)       (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK)
    00047 #define B_SLICESHIFT            20
    00048 #define B_SLICEMASK             0xff
    00049 #define B_SLICE(val)            (((val)>>B_SLICESHIFT) & B_SLICEMASK)
    00050 #define B_UNITSHIFT             16
    00051 #define B_UNITMASK              0xf
    00052 #define B_UNIT(val)             (((val) >> B_UNITSHIFT) & B_UNITMASK)
    00053 #define B_PARTITIONSHIFT        8
    00054 #define B_PARTITIONMASK         0xff
    00055 #define B_PARTITION(val)        (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
    00056 #define B_TYPESHIFT             0
    00057 #define B_TYPEMASK              0xff
    00058 #define B_TYPE(val)             (((val) >> B_TYPESHIFT) & B_TYPEMASK)
    00059
    00060
    00061 /*****************************************************************************************
    00062  Desc: The Kernels Descriptor table:
    00063        0x00 - Dummy Entry
    00064        0x08 - Ring 0 CS
    00065        0x10 - Ring 0 DS
    00066        0x18 - Dummy LDT
    00067        0x20 - Scheduler TSS
    00068        0x28 - Ring 3 CS
    00069        0x30 - Ring 3 DS
    00070        0x38 - GPF TSS
    00071        0x40 - Stack Fault TSS
    00072
    00073  Notes:
    00074
    00075 *****************************************************************************************/
    00076 ubixDescriptorTable(ubixGDT,9) {
    00077   {dummy:0},
    00078   ubixStandardDescriptor(0x0000, 0xFFFFF, (dCode + dRead + dBig + dBiglim)),
    00079   ubixStandardDescriptor(0x0000, 0xFFFFF, (dData + dWrite + dBig + dBiglim)),
    00080   ubixStandardDescriptor(0x0000, 0xFFFFF, (dLdt)),
    00081   ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss + dDpl3)),
    00082   ubixStandardDescriptor(0x0000, 0xFFFFF, (dCode + dWrite + dBig + dBiglim + dDpl3)),
    00083   ubixStandardDescriptor(0x0000, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)),
    00084   ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss)),
    00085   ubixStandardDescriptor(0x6200, (sizeof(struct tssStruct)), (dTss)),
    00086   };
    00087 struct {
    00088   unsigned short limit __attribute__ ((packed));
    00089   union descriptorTableUnion *gdt __attribute__ ((packed));
    00090   } loadGDT = { (9 * sizeof(union descriptorTableUnion) - 1), ubixGDT };
    00091
    00097 int kmain(uInt32 rootdev) {
    00098   /* Set up counter for startup routine */
    00099   int i = 0x0;
    00100   uInt32 *sysTask = 0x0;
    00101
    00102   /* Do A Clear Screen Just To Make The TEXT Buffer Nice And Empty */
    00103   clearScreen();
    00104   kprint("AAA");
    00105   kprint("BBB");
    00106 kprintf("TEST");
    00107   /* Modify src/sys/include/ubixos/init.h to add a startup routine */
    00108   for (i=0x0;i<init_tasksTotal;i++) {
    00109     if (init_tasks[i]() != 0x0) {
    00110       kpanic("Error: Initializing System.\n");
    00111       }
    00112     }
    00113
    00114   /* New Root Mount Point */
    00115   //Old 2 new 10
    00116   kprintf("[0xX][0x%X:0x%X:0x%X:0x%X:0x%X:0x%X]\n",B_ADAPTOR(rootdev),B_CONTROLLER(rootdev),B_SLICE(rootdev),B_UNIT(rootdev),B_PARTITION(rootdev),B_TYPE(rootdev));
    00117   if (vfs_mount(0x1,B_PARTITION(rootdev)+2,0x0,0xAA,"sys","rw") != 0x0) {
    00118     kprintf("Problem Mounting sys Mount Point\n");
    00119     }
    00120
    00121   /* Do our mounting */
    00122  /*
    00123   if (vfs_mount(0x0,0x0,0x0,0x0,"sys","rw") != 0x0) {
    00124     kprintf("Problem Mounting sys Mount Point\n");
    00125     }
    00126   if (vfs_mount(0x0,0x0,0x1,0x0,"tmp","rw") != 0x0) {
    00127     kprintf("Problem Mounting tmp Mount Point\n");
    00128     }
    00129   */
    00130
    00131   /* Initialize the system */
    00132   kprintf("Free Pages: [%i]\n",systemVitals->freePages);
    00133
    00134   kprintf("MemoryMap:  [0x%X]\n",vmmMemoryMap);
    00135   kprintf("Starting OS\n");
    00136
    00137         sysTask = kmalloc(0x2000);
    00138         if(sysTask == NULL)
    00139                 kprintf("OS: Unable to allocate memory\n");
    00140
    00141         execThread(systemTask, (uInt32)sysTask+0x2000,0x0);
    00142
    00143         execFile("sys:/bin/init",0x0,0x0,0x0); /* OS Initializer    */
    00144
    00145         irqEnable(0x0);
    00146
    00147         while (0x1)
    00148                 asm("hlt"); /* Keep haulting until the scheduler reacts */
    00149
    00150         /* Return to start however we should never get this far */
    00151         return(0x0);
    00152 }
    00153
    00154 /***
    00155  END
    00156  ***/