main.c

00001 /***************************************************************************
00002                           main.c  -  description
00003                              -------------------
00004     begin                : Sat Dec 13 2003
00005     copyright            : (C) 2003 by Dynacube Team
00006     email                : mdshah82@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #include "core/kmaster.h"
00020 #include "core/vm86.h"
00021 #include "core/ktask.h"
00022 
00023 #include "common/stdlib.h"
00024 #include "common/string.h"
00025 #include "common/ds/stack.h"
00026 #include "common/ds/queue.h"
00027 #include "common/ds/hashmap.h"
00028 
00029 #include "mm/mm.h"
00030 #include "proc/proc.h"
00031 #include "fs/fat12.h"
00032 
00033 #include "gui/zorder.h"
00034 #include "gui/svga.h"
00035 #include "gui/server/gui.h"
00036 
00037 #include "dev/core/kpic.h"
00038 #include "dev/floppy/floppy.h"
00039 
00040 
00041 // Exported Symbols
00042 extern void _Z6runGUIv();
00043 extern void _Z9list_initv();
00044 
00045 void callGUI();
00046 
00047 int main(void)
00048 {
00049  //Global Initialization
00050  //Perhaps I should replace it with some init()....
00051  DD i;
00052 
00053  cli();
00054  cls();
00055 
00056  kprint("Dynacube\t1.0\tLoading [dd/mm/yyyy]\n");
00057  kprint("------------------------------------------------------\n");
00058 
00059  printf("\n\n\n\t\tHELLO WORLD !!!\n\n");
00060  kdump();
00061 
00062 // BLOCK
00063  gdt_init();
00064 
00065  kprint("\nSystem Descriptors Loaded................ ");
00066 
00067  pic_init();
00068 
00069  kprint("\nPIC remapped................ \n");
00070 
00071  printf("\nkrnl_size %x val: %d",KERNEL_SIZE,(PHYS_MEM/_4MB));
00072 
00073  task_init();
00074  proc_init();
00075  
00076  memcpy((void *)(KERNEL_SIZE),(void *)null_proc,512);
00077 
00078  q_init(&ready_q);
00079  q_init(&message_q);
00080  q_init(&timer_q);
00081  q_init(&intr_q);
00082  q_init(&gui_q);
00083  q_init(&fs_q);
00084 
00085  for(i = 0 ; i < 3 ; i++)
00086    q_init(&device_q[i]);
00087 
00088  z_init();
00089  hash_init();
00090 
00091  _Z9list_initv();
00092 
00093  cls();
00094 
00095  // Retrieve stored VBE information
00096  vbe_mode = *((VBE_ModeInfo *) (0x91000));
00097  printf("\nPhys addr: %x xRes %d yRes %d bpp %d",vbe_mode.PhysBasePtr,vbe_mode.XResolution,vbe_mode.YResolution,vbe_mode.BitsPerPixel);
00098  printf("\nModeAttributes : %x",vbe_mode.ModeAttributes);
00099 
00100  mouse_init();
00101 
00102  mm_init();
00103  task_init();
00104  proc_init();
00105  fs_init();
00106 
00107  forkNULL();
00108  startGUI();
00109  startFloppy();
00110  startFS();
00111  create("\\editor");
00112 // create("\\calc");
00113 // create("\\run");
00114 // create("\\timeset");
00115 
00116  printQ(&ready_q);
00117 
00118  cls();
00119  pit0_init(1);
00120  pic_enable(TIMER);
00121  pic_enable(KEYBOARD);
00122  pic_enable(FLOPPY);
00123  pic_enable(PS2_MOUSE);
00124  
00125  // Let multi-tasking begin :)
00126  sti();
00127 
00128  while(1);
00129 
00130  return 0;
00131 }
00132 
00133 
00134 void startGUI()
00135 {
00136   _proc[GUI_PID].avl = _false;
00137 
00138   _proc[GUI_PID].cr3 = _system.cr3;
00139 
00140   _proc[GUI_PID].cs = _system.cs;
00141   _proc[GUI_PID].ds = _system.ds;
00142   _proc[GUI_PID].ss = GUI_STACK_SEL * 8; //_system.ss;//
00143   _proc[GUI_PID].es = _system.es;
00144   _proc[GUI_PID].fs = _system.fs;
00145   _proc[GUI_PID].gs = _system.gs;
00146 
00147   _proc[GUI_PID].eax = 0;
00148   _proc[GUI_PID].ebx = 0;
00149   _proc[GUI_PID].ecx = 0;
00150   _proc[GUI_PID].edx = 0;
00151   _proc[GUI_PID].esi = 0;
00152   _proc[GUI_PID].edi = 0;
00153   _proc[GUI_PID].ebp = 0;
00154 
00155   _proc[GUI_PID].esp = (KERNEL_SIZE - 2 *_4MB/4); //Set ESP
00156   _proc[GUI_PID].eip = _Z6runGUIv;
00157   _proc[GUI_PID].eflags = _system.eflags | (1<<9);
00158 
00159   _proc[GUI_PID].ss0 = _system.ss;
00160   _proc[GUI_PID].ss1 = NULL1_SEL;
00161   _proc[GUI_PID].ss2 = NULL1_SEL;   
00162   
00163   _proc[GUI_PID].ldt_sel = LDT_USR_SEL * 8; //_system.ldt_sel;
00164   
00165    enq(&ready_q,GUI_PID);    
00166 }
00167 
00168 void startFloppy()
00169 {
00170   _proc[FLOPPY_PID].avl = _false;
00171 
00172   _proc[FLOPPY_PID].cr3 = _system.cr3;
00173 
00174   _proc[FLOPPY_PID].cs = _system.cs;
00175   _proc[FLOPPY_PID].ds = _system.ds;
00176   _proc[FLOPPY_PID].ss = FLOPPY_STACK_SEL * 8; //_system.ss;//
00177   _proc[FLOPPY_PID].es = _system.es;
00178   _proc[FLOPPY_PID].fs = _system.fs;
00179   _proc[FLOPPY_PID].gs = _system.gs;
00180 
00181   _proc[FLOPPY_PID].eax = 0;
00182   _proc[FLOPPY_PID].ebx = 0;
00183   _proc[FLOPPY_PID].ecx = 0;
00184   _proc[FLOPPY_PID].edx = 0;
00185   _proc[FLOPPY_PID].esi = 0;
00186   _proc[FLOPPY_PID].edi = 0;
00187   _proc[FLOPPY_PID].ebp = 0;
00188 
00189   _proc[FLOPPY_PID].esp = (KERNEL_SIZE - _4MB/4); //Set ESP
00190   _proc[FLOPPY_PID].eip =  runFloppy; // callGUI; 
00191   _proc[FLOPPY_PID].eflags = _system.eflags | (1<<9);
00192 
00193   _proc[FLOPPY_PID].ss0 = _system.ss;
00194   _proc[FLOPPY_PID].ss1 = NULL1_SEL;
00195   _proc[FLOPPY_PID].ss2 = NULL1_SEL;
00196 
00197   _proc[FLOPPY_PID].ldt_sel = LDT_USR_SEL * 8; //_system.ldt_sel;
00198 
00199    enq(&ready_q,FLOPPY_PID);
00200 }
00201 
00202 void startFS()
00203 {
00204   _proc[FS_PID].avl = _false;
00205 
00206   _proc[FS_PID].cr3 = _system.cr3;
00207 
00208   _proc[FS_PID].cs = _system.cs;
00209   _proc[FS_PID].ds = _system.ds;
00210   _proc[FS_PID].ss = FS_STACK_SEL * 8; //_system.ss;//
00211   _proc[FS_PID].es = _system.es;
00212   _proc[FS_PID].fs = _system.fs;
00213   _proc[FS_PID].gs = _system.gs;
00214 
00215   _proc[FS_PID].eax = 0;
00216   _proc[FS_PID].ebx = 0;
00217   _proc[FS_PID].ecx = 0;
00218   _proc[FS_PID].edx = 0;
00219   _proc[FS_PID].esi = 0;
00220   _proc[FS_PID].edi = 0;
00221   _proc[FS_PID].ebp = 0;
00222 
00223   _proc[FS_PID].esp = (KERNEL_SIZE - _4MB); //Set ESP
00224   _proc[FS_PID].eip =  runFS;
00225   _proc[FS_PID].eflags = _system.eflags | (1<<9);
00226 
00227   _proc[FS_PID].ss0 = _system.ss;
00228   _proc[FS_PID].ss1 = NULL1_SEL;
00229   _proc[FS_PID].ss2 = NULL1_SEL;
00230 
00231   _proc[FS_PID].ldt_sel = LDT_USR_SEL * 8; //_system.ldt_sel;
00232 
00233    enq(&ready_q,FS_PID);
00234 }
00235 
00236 /* END OF FILE */

Generated on Thu Jul 27 23:52:27 2006 for Dynacube by  doxygen 1.4.7