/*****************************************************************************************
Copyright (c) 2002-2004 The UbixOS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions, the following disclaimer and the list of authors. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions, the following
disclaimer and the list of authors in the documentation and/or other materials provided
with the distribution. Neither the name of the UbixOS Project nor the names of its
contributors may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$Id$
*****************************************************************************************/
#include <ubixos/init.h>
#include <sys/gdt.h>
#include <sys/video.h>
#include <sys/tss.h>
#include <ubixos/exec.h>
#include <ubixos/kpanic.h>
#include <ubixos/systemtask.h>
#include <vfs/mount.h>
#include <lib/kprintf.h>
#include <lib/kmalloc.h>
#include <lib/bioscall.h>
#include <isa/mouse.h>
#include <pci/pci.h>
#include <pci/hd.h>
#include <sde/sde.h>
#include <ubixos/smp.h>
#include <ufs/ufs.h>
static char kernelStack[8192]; /* Stack Space For Our Kernel */
ubixDescriptorTable(ubixGDT,8) {
{dummy:0},
ubixStandardDescriptor(0x0, 0xFFFFF, (dCode + dRead + dBig + dBiglim)),
ubixStandardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim)),
ubixStandardDescriptor(0x0, 0xFFFFF, (dLdt)),
ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss)),
ubixStandardDescriptor(0x0, 0xFFFFF, (dCode + dWrite + dBig + dBiglim + dDpl3)),
ubixStandardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)),
ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss)),
};
struct {
unsigned short limit __attribute__ ((packed));
union descriptorTableUnion *gdt __attribute__ ((packed));
} loadGDT = { (8 * sizeof(union descriptorTableUnion) - 1), ubixGDT };
/*****************************************************************************************
Desc: This is the entry point into the os where all of the kernels sub systems are
started up.
Notes:
*****************************************************************************************/
int main() {
int i = 0x0;
clearScreen(); /* Do A Clear Screen Just To Make The TEXT Buffer Nice And Empty */
/* Modify src/sys/include/ubixos/init.h to add a startup routine */
for (i=0x0;i<init_tasksTotal;i++) {
if (init_tasks[i]() != 0x0) {
kpanic("Error: Initializing System.\n");
}
}
//smpInit();
//mouseInit();
//pciInit();
//initHardDisk();
if (mount(0x0,0x0,0x0,0x0,"sys","rw") != 0x0) {
kprintf("Problem Mounting sys Mount Point\n");
}
if (mount(0x0,0x0,0x1,0x0,"tmp","rw") != 0x0) {
kprintf("Problem Mounting tmp Mount Point\n");
}
/*
if (mount(0x1,0x1,0x0,0x0,"hd","rw") != 0x0) {
kprintf("Problem Mounting HD Mount Point\n");
}
*/
execThread(systemTask,(uInt32)(kmalloc(0x2000)+0x2000),0x0);
execFile("sys:/init",0x0,0x0,0x0);
//execFile("sys:/shell",0x0,0x0,0x0);
kprintf("Free Pages: [%i]\n",freePages);
kprintf("MemoryMap: [0x%X]\n",vmmMemoryMap);
kprintf("Starting Os\n");
//lookup("/COPYRIGHT");
irqEnable(0x0);
sched();
return(0x0);
}
/************************************************************************
Function: _start();
Description: This Is The Kernels Main Entry Point From Here We Must
Re-Setup Our GDT And Set All Registers To Their Default
Values So We Are Sure Of No Error When The OS Boots Up Also
We Have To Quickly Set Up Our Interrupt Table Because We Do
Not Have Any Fault Protection Yet
Notes:
02/17/03 - I'm Unhappy With The Infinite Loop I Decided To Do If The Call
To Main Returns I Think I Shall Change It To A Kernel Panic
At A Later Date Then Reboot The Machine
************************************************************************/
void _start() {
asm ("pushl $2; popf");
asm volatile(
"lgdtl (loadGDT) \n"
"movw $0x10,%%ax \n" /* Select Ring 0 Data Segment */
"movw %%ax,%%ds \n" /* Set Default Segment */
"movw %%ax,%%es \n" /* "" "" */
"movw %%ax,%%fs \n" /* "" "" */
"movw %%ax,%%gs \n" /* "" "" */
"movw %%ax,%%ss \n" /* "" "" */
"movl $0x2000,%%esp \n" /* Set Default Stack Pointer Its The End Of First Page */
"movl $0x2000,%%ebp \n"
"mov $0x18,%%ax \n" /* Set Up Dummy LDT */
"lldt %%ax \n" /* Load The Dummy LDT */
"mov $0x20,%%ax \n" /* Set Up Dummy TSS */
"ltr %%ax \n" /* Load The Dummy TSS */
"ljmp $0x08,$next \n"
"next: \n"
:
: "r" (ubixGDT), "p" (kernelStack+8192)
: "%eax"
);
main();
kpanic("Error: kernel main returned.\n");
}
/***
$Log$
Revision 1.52 2004/07/14 12:42:46 reddawg
fdc: fdcInit to fdc_init
Changed Startup Routines
Revision 1.49 2004/07/14 12:03:50 reddawg
ne2k: ne2kInit to ne2k_init
Changed Startup Routines
Revision 1.48 2004/07/14 02:25:40 reddawg
net: netInit to net_init
Changed startup routines
Revision 1.47 2004/07/09 13:37:30 reddawg
time: timeInit to time_init
Adjusted initialization routines
Revision 1.39 2004/07/09 12:31:15 reddawg
Updating Initialization Procedures
Revision 1.38 2004/07/09 12:18:19 reddawg
Updating Initialization Procedures
Revision 1.36 2004/07/08 02:47:36 reddawg
Tuuned afew things adding ufs support to ubixos
Revision 1.35 2004/06/28 23:12:58 reddawg
file format now container:/path/to/file
Revision 1.34 2004/06/25 17:25:52 reddawg
I am cleaning too
Revision 1.33 2004/06/25 13:16:23 reddawg
Made kernel stack static to prevent corruptions
Revision 1.32 2004/06/04 17:33:33 reddawg
Changed idle task to system task
Revision 1.31 2004/06/04 10:19:42 reddawg
notes: we compile again, thank g-d anyways i was about to cry
Revision 1.30 2004/05/25 18:38:55 reddawg
Removed sample code
Revision 1.29 2004/05/25 15:50:43 reddawg
mpiSpam() test
Revision 1.28 2004/05/23 01:10:35 reddawg
Fixes: Started to fix re-entrancy issues many more to look into
Revision 1.27 2004/05/21 21:15:04 reddawg
Fixed a few bugs which prevented the system from loadin
Revision 1.26 2004/05/20 22:54:02 reddawg
Cleaned Up Warrnings
Revision 1.25 2004/05/19 17:28:28 reddawg
Added the correct endTask Procedure
Revision 1.24 2004/05/19 04:07:42 reddawg
kmalloc(size,pid) no more it is no kmalloc(size); the way it should of been
Revision 1.23 2004/05/19 03:35:02 reddawg
Fixed A Few Ordering Issues In The Service Startup Routine
Revision 1.22 2004/05/19 01:21:29 reddawg
Tweaked
Revision 1.21 2004/05/18 10:45:41 reddawg
Bug Fix
Revision 1.20 2004/05/10 02:23:24 reddawg
Minor Changes To Source Code To Prepare It For Open Source Release
Revision 1.19 2004/05/08 19:06:24 reddawg
Going to impliment FSTAB
Revision 1.18 2004/05/04 23:38:24 reddawg
make clean all install
Revision 1.17 2004/05/04 23:31:01 reddawg
Ok Mark Cleaned Up Boot This
Revision 1.16 2004/05/02 14:34:21 reddawg
SMP Support Thanks To Some Help From Slowcoder now to make it interface
well with the rest of the kernel
Revision 1.15 2004/04/30 17:04:23 reddawg
Ok GUI is back on
Revision 1.14 2004/04/30 16:58:37 reddawg
Turned On PCI Detections
Revision 1.13 2004/04/30 16:29:34 reddawg
Turned Off Gui
Revision 1.12 2004/04/30 13:40:34 reddawg
Just doing spring cleaning for the new members
Revision 1.7 2004/04/26 22:27:36 reddawg
Now mounts our harddrive I need to either impliment fstab or do something similar
Revision 1.6 2004/04/25 04:35:50 reddawg
Minor bug fixes to set default partition information
Revision 1.107 2004/04/13 16:36:33 reddawg
Changed our copyright, it is all now under a BSD-Style license
END
***/