Newer
Older
ubixos / src / sys / init / main.c
@reddawg reddawg on 11 May 2002 1 KB Woot
/**************************************************************************************
 Copyright (c) 2002
      The UbixOS Project

 $Id$
**************************************************************************************/

#include <ubixos/gdt.h>
#include <ubixos/schedule.h>
#include <ubixos/idt.h>
#include <ubixos/exec.h>
#include <drivers/video.h>
#include <drivers/8259.h>
#include <drivers/keyboard.h>
#include <version/version.h>
#include <vmm/paging.h>

int main();

int testVal=0;

descriptorTable(GDT,5) {
  {dummy:0},
  standardDescriptor(0, 0xFFFFF, (dCode + dRead + dBig + dBiglim)),
  standardDescriptor(0, 0xFFFFF, (dData + dWrite + dBig + dBiglim)),
  standardDescriptor(0, 0xFFFFF, (dLdt)),
  standardDescriptor(100000, (sizeof(struct tssStruct)-1), (dTss)),
  };

struct {
  unsigned short limit __attribute__ ((packed));
  union descriptorTableunion *gdt __attribute__ ((packed));
  } loadGdt = { (5 * sizeof(union descriptorTableunion) - 1), GDT };

void _start(void) {
  asm(
    "lgdtl (loadGdt)   \n"
    "movw $0x10,%ax    \n"
    "movw %ax,%ds      \n"
    "movw %ax,%es      \n"
    "movw %ax,%fs      \n"
    "movw %ax,%gs      \n"
    "movw %ax,%ss      \n"
    "movl $0xFFFF,%esp \n"
    "mov $0x18,%ax     \n" //Set up dummy LDT
    "lldt %ax          \n"
    "mov $0x20,%ax     \n" // Set up dummy TSS
    "ltr %ax           \n" // Loads dummy TSS
    );
  main(); //Start Of Kernel Functionality
  while(1);
  }

void test() {
  while(1) {
    //kprint("The");
    testVal++;
    }
  }

void test2() {
  while(1) {
    //kprint("Ubu");
    }
  }

int main() {
  initPaging();    //Initialize Paging System
  clearScreen();
  outputVersion(); //Display Version Info
  init8259();      //Initialize PIC
  initIdt();       //Initialize IDT
  initKeyboard();  //Initialize Keyboard
  initScheduler(); //Initialize Scheduler
  execThread(test,0xAFFF,"Test Thread");
  execThread(test2,0xBFFF,"Test Thread2");
  enableIrq(0);
  return(0);
  }