/// <summary> /// Main /// </summary> public static void Main() { Mosa.Kernel.x86.Kernel.Setup(); IDT.SetInterruptHandler(ProcessInterrupt); Setup.Initialize(); Setup.Start(); var textDevice = (ITextDevice)Setup.DeviceManager.GetDevices(new FindDevice.IsTypeOf <ITextDevice>()).First.Value; console = new TextScreen(textDevice); Console.ClearScreen(); Console.SetCursor(0, 0); Console.SetColor(TextColor.Blue, TextColor.Green); Console.WriteLine(" MOSA OS Version 1.5 - Compiler Version 1.5 "); Console.SetColor(TextColor.Black, TextColor.White); Console.WriteLine("> System ready"); Console.SetCursor(0, 24); Console.Write(" Copyright (C) 2008-2015 [Managed Operating System Alliance] "); Process(); }
public override void MainMethod() { Ensure.Init(); CPU.DisableInts(); GDT.Init(); IDT.Init(); ISR.Init(); Console.Clear(); ACPI.Init(); ACPI.Enable(); PageManager.Init(); Heap.Init(); GC.Init(); Paging.Init(); PIT.Init(); RTC.Init(); Scheduler.Init(); CPU.EnableInts(); DiskDrive.Init(); //FatFileSystem.Init(); PCI.Init(); Driver.Init(); AudioMixer.Init(); new Thread(Event.Init, "Events").Start(); new Thread(new SCI().Main, "Shell").Start(); Scheduler.Idle(); }
public static void Setup() { Screen.Clear(); Screen.Color = 0x0E; Screen.SetCursor(24, 0); Screen.Write('1'); Multiboot.Setup(); Screen.SetCursor(24, 1); Screen.Write('2'); PIC.Setup(); Screen.SetCursor(24, 2); Screen.Write('3'); GDT.Setup(); Screen.SetCursor(24, 3); Screen.Write('4'); IDT.Setup(); Screen.SetCursor(24, 4); Screen.Write('5'); PageFrameAllocator.Setup(); Screen.SetCursor(24, 5); Screen.Write('6'); PageTable.Setup(); Screen.SetCursor(24, 6); Screen.Write('7'); VirtualPageAllocator.Setup(); Screen.SetCursor(24, 7); Screen.Write('8'); Screen.SetCursor(24, 8); ProcessManager.Setup(); Screen.Write('9'); Screen.SetCursor(24, 9); TaskManager.Setup(); Screen.Write('A'); Screen.SetCursor(24, 10); }
internal static void Setup() { Debug.Write("PS/2 Mouse Controller Setup\n"); MouseCycle = 0; MouseData = new byte[4]; MouseData[0] = MOUSE_MAGIC; MousePipe = new Pipe(4, 1024); IDT.RegisterInterrupt(HandleIRQ, 0x2C); Wait(true); PortIO.Out8(MOUSE_STATUS, 0xA8); Wait(true); PortIO.Out8(MOUSE_STATUS, 0x20); Wait(false); byte status = (byte)(PortIO.In8(MOUSE_PORT) | 2); Wait(true); PortIO.Out8(MOUSE_STATUS, 0x60); Wait(true); PortIO.Out8(MOUSE_PORT, status); Write(0xF6); Read(); Write(0xF4); Read(); Debug.Write("Mouse Done\n"); }
/// <summary> /// Main /// </summary> public static void Main() { Kernel.x86.Kernel.Setup(); Console = ConsoleManager.Controller.Boot; Console.Clear(); IDT.SetInterruptHandler(ProcessInterrupt); Serial.SetupPort(Serial.COM1); _hal = new Hardware(); if (VBE.InitVBE(_hal)) { Log("VBE setup OK!"); DoGraphics(); } else { Log("VBE setup ERROR!"); } ForeverLoop(); }
/// <summary> /// Initialize the Machine /// </summary> public static void Setup() { Multiboot.Setup(); PIC.Setup(); IDT.Setup(); PageFrameAllocator.Setup(); PageTable.Setup(); VirtualPageAllocator.Setup(); GC.Setup(); Scheduler.Setup(); Serial.SetupPort(Serial.COM1); var _hal = new Hardware(); if (VBEDisplay.InitVBE(_hal)) { ScreenManager.Setup(); ScreenManager.Add(new BootScreen()); ScreenManager.Add(new TestScreen()); ScreenManager.ChangeScreen(ScreenIds.Boot); } Native.Hlt(); }
public static void KernelMain(IntPtr modulesSeg, FrameBuffer fb, MemoryMap mmap) { Debug.Initialise(); for (int i = 0; i < mmap.Length; i++) { if (mmap[i].IsUsable) { Allocator.AddFreePages((IntPtr)mmap[i].PhysicalStart, (uint)mmap[i].NumberOfPages); } } Internal.Runtime.CompilerHelpers.StartupCodeHelpers.InitialiseRuntime(modulesSeg); FrameBuffer._instance = fb; Font.Initialise(); IDT.Disable(); GDT.Initialise(); IDT.Initialise(); IDT.Enable(); Console.Clear(); Console.WriteLine("Hello from the kernel!\nThis is a line feed without carriage return,\r\nand this is with."); Console.WriteLine("Let's test some ANSI escape sequences :)"); Console.WriteLine("\x1b[30;107m *** \x1b[31;49m *** \x1b[32m *** \x1b[33m *** \x1b[34m *** \x1b[35m *** \x1b[36m *** \x1b[37m *** "); Console.WriteLine("\x1b[90m *** \x1b[91m *** \x1b[92m *** \x1b[93m *** \x1b[94m *** \x1b[95m *** \x1b[96m *** \x1b[97m *** "); Console.WriteLine("\x1b[39;40m *** \x1b[30;41m *** \x1b[42m *** \x1b[43m *** \x1b[44m *** \x1b[45m *** \x1b[46m *** \x1b[47m *** "); Console.WriteLine("\x1b[100m *** \x1b[101m *** \x1b[102m *** \x1b[103m *** \x1b[104m *** \x1b[105m *** \x1b[106m *** \x1b[107m *** \x1b[0m"); Console.WriteLine(); for (; ;) { Console.Write("> "); var cmd = Console.ReadLine(); switch (cmd) { case "mem": Console.Write("Allocations: "); Console.Write(Allocator.Allocations); Console.WriteLine(); Console.Write("Total Memory: "); Console.Write(Allocator.TotalMemory); Console.WriteLine(" bytes"); Console.Write("Free Memory: "); Console.Write(Allocator.FreeMemory); Console.WriteLine(" bytes"); Console.Write("Used Memory: "); Console.Write(Allocator.UsedMemory); Console.Write(" bytes ("); Console.Write(Allocator.UsedMemory / 4096); Console.WriteLine(" pages)"); break; } cmd.Dispose(); } }
/// <summary> /// Setup All Neccessary Stuff /// </summary> public static void Main() { Kernel.Setup(); IDT.SetInterruptHandler(ProcessInterrupt); Program.Setup(); }
public static int Lock() { if (IDT.Initialised) { IDT.Disable(); } return(0); }
public static int Unlock() { if (IDT.Initialised) { IDT.Enable(); } return(0); }
public static void Setup() { GDT.Setup(); // Global Descriptor Table PIC.Setup(); // Programmable Interrupt Controller IDT.Setup(); // Interrupt Descriptor table PIT.Setup(); // Periodic Interrupt Timer // Disabled because it needs MemoryManager [cedrou] //Serial.Setup (); // Setup serial I/O }
public static void Mode0(uint frequency) { IDT.Remap(); IRQ.ClearMask(0); IRQ.ClearMask(15); uint divisor = 1193180 / frequency; AXP.Outb(0x43, 0x30); AXP.Outb(0x40, (byte)(divisor & 0xFF)); AXP.Outb(0x40, (byte)((divisor >> 8) & 0xFF)); }
/// <summary> /// Takes either Gaze Data that is processed further to compute fixations or exisiting Fixation Data /// </summary> /// <param name="gazeData"></param> /// <param name="fixationData"></param> public static void ProcessFixationData(FixationData fixationData = null, GazeData gazeData = null) { if (gazeData != null) { FixationData = IDT.Classify(gazeData); } if (fixationData != null) { FixationData = fixationData; } SendFixationData(); }
public static unsafe void Start(uint magic, uint address) { /* Setup Multiboot */ Multiboot.Setup(magic, address); /* Placement Address */ Heap.PlacementAddress = Native.EndOfKernel(); /* Clear Interrupts */ Native.ClearInterrupt(); /* Setup PIC */ PIC.Setup(); /* Setup GDT & Enter into protected mode */ GDT.Setup(); /* Setup IDT */ IDT.Setup(); /* Enable Interrupts */ Native.SetInterrupt(); /* Setup Paging */ Paging.Setup(Multiboot.RAM); /* Setup Multitasking */ Multitasking.CreateTask(0, true); //This is System Update thread Multitasking.Init(); //Start Multitasking /* Call our kernel instance now */ try { Caller.Start(); while (true) { Caller.Update(); } } catch (Exception e) { //Kernel PANIC !! Console.WriteLine(e.Message); } while (true) //Set CPU in Infinite loop DON'T REMOVE THIS ELSE I'll KILL YOU (^ . ^) { Native.ClearInterrupt(); Native.Halt(); } ; }
private static void Setup() { IDT.SetInterruptHandler(null); Panic.Setup(); Debugger.Setup(Serial.COM1); // Initialize interrupts PIC.Setup(); IDT.Setup(); GDT.Setup(); //Runtime.Internal.Setup(); }
/// <summary> /// Main /// </summary> unsafe public static void Main() { Mosa.Kernel.x86.Kernel.Setup(); Console = ConsoleManager.Controller.Boot; Console.Clear(); IDT.SetInterruptHandler(ProcessInterrupt); Console.Color = Colors.White; Console.BackgroundColor = Colors.Green; Console.Write(@" MOSA OS Version 1.4 - Compiler Version 1.4"); FillLine(); Console.Color = Colors.White; Console.BackgroundColor = Colors.Black; if (SmbiosManager.IsAvailable) { BiosInformationStructure biosInfo = new BiosInformationStructure(); CpuStructure cpuInfo = new CpuStructure(); Console.WriteLine("> Checking BIOS..."); BulletPoint(); Console.Write("Vendor "); InBrackets(biosInfo.BiosVendor, Colors.White, Colors.LightBlue); Console.WriteLine(); BulletPoint(); Console.Write("Version "); InBrackets(biosInfo.BiosVersion, Colors.White, Colors.LightBlue); Console.WriteLine(); Console.WriteLine("> Checking CPU..."); BulletPoint(); Console.Write("Vendor "); InBrackets(cpuInfo.Vendor, Colors.White, Colors.LightBlue); Console.WriteLine(); BulletPoint(); Console.Write("Version "); InBrackets(cpuInfo.Version, Colors.White, Colors.LightBlue); Console.WriteLine(); } else { Console.WriteLine("> No SMBIOS available!"); } Console.WriteLine("> Initializing hardware abstraction layer..."); Setup.Initialize(); Console.WriteLine("> Adding hardware devices..."); Setup.Start(); Console.WriteLine("> System ready"); Console.WriteLine(); Console.Goto(24, 0); Console.Color = Colors.White; Console.BackgroundColor = Colors.Green; Console.Write(" Copyright (C) 2008-2015 [Managed Operating System Alliance]"); FillLine(); Process(); }
private static void Setup() { Logger.Log("Initialize Kernel"); IDT.SetInterruptHandler(null); Panic.Setup(); Debugger.Setup(Serial.COM2); // Initialize interrupts PIC.Setup(); IDT.Setup(); GDT.Setup(); Logger.Log("Kernel initialized"); }
/// <summary> /// Main /// </summary> public static void Main() { IDT.SetInterruptHandler(null); Panic.Setup(); Debugger.Setup(Serial.COM1); // Initialize interrupts PIC.Setup(); IDT.Setup(); GDT.Setup(); Runtime.Internal.Setup(); IDT.SetInterruptHandler(ProcessInterrupt); EnterTestReadyLoop(); }
public static void Main() { Mosa.Kernel.x86.Kernel.Setup(); IDT.SetInterruptHandler(ProcessInterrupt); Screen.Clear(); Screen.Goto(0, 0); Screen.Color = ScreenColor.White; Program.Setup(); while (true) { Program.Loop(); } }
/// <summary> /// Main /// </summary> unsafe public static void Main() { Kernel.x86.Kernel.Setup(); Console = ConsoleManager.Controller.Boot; Debug = ConsoleManager.Controller.Boot; Console.Clear(); Console.ScrollRow = 23; IDT.SetInterruptHandler(ProcessInterrupt); Console.Color = Colors.White; Console.BackgroundColor = Colors.Green; Console.Write(@" MOSA OS Version 1.4 - Compiler Version 1.4"); FillLine(); Console.Color = Colors.White; Console.BackgroundColor = Colors.Black; Console.WriteLine("> Initializing hardware abstraction layer..."); Setup.Initialize(); Console.WriteLine("> Adding hardware devices..."); Setup.Start(); Console.Color = Colors.White; Console.WriteLine(); Debug = ConsoleManager.Controller.Debug; // setup keymap var keymap = new US(); // setup keyboard (state machine) var keyboard = new Mosa.DeviceSystem.Keyboard(Setup.StandardKeyboard, keymap); // setup app manager var manager = new AppManager(Console, keyboard); IDT.SetInterruptHandler(manager.ProcessInterrupt); manager.Start(); }
internal static IRQCallBack[] callBacks; //TODO: create list per IRQ (for shared IRQs) #region Constructor internal IRQHandler16bit(byte irq) { spinLock.Enter(); if (irqs == null) { irqs = new bool[16]; callBacks = new IRQCallBack[16]; } this.irq = irq; IDT.Interrupt interrupt = (IDT.Interrupt)(irq + 0x20); IDT.RegisterIRQ(interrupt, Stubs.GetFunctionPointer(INTERRUPT16BIT_HANDLER)); spinLock.Exit(); }
internal IDE(bool IsPrimary, bool IsMaster = true) { UInt16 xBAR0 = (UInt16)(IsPrimary ? 0x01F0 : 0x0170); UInt16 xBAR1 = (UInt16)(IsPrimary ? 0x03F6 : 0x0376); mChannel = IsPrimary ? Channel.PRIMARY : Channel.SECONDARY; mType = IsMaster ? Type.MASTER : Type.SLAVE; DataReg = (UInt16)(xBAR0 + (byte)Register.ATA_REG_DATA); FeatureReg = (UInt16)(xBAR0 + (byte)Register.ATA_REG_FEATURES); SectorCountReg = (UInt16)(xBAR0 + (byte)Register.ATA_REG_SECCOUNT0); CommandReg = (UInt16)(xBAR0 + (byte)Register.ATA_REG_COMMAND); StatusReg = (UInt16)(xBAR0 + (byte)Register.ATA_REG_STATUS); AltStatusReg = (UInt16)(xBAR1 + (byte)Register.ATA_REG_ALTSTATUS); ControlReg = (UInt16)(xBAR1 + (byte)Register.ATA_REG_CONTROL); LBA0 = (UInt16)(xBAR0 + (byte)Register.ATA_REG_LBA0); LBA1 = (UInt16)(xBAR0 + (byte)Register.ATA_REG_LBA1); LBA2 = (UInt16)(xBAR0 + (byte)Register.ATA_REG_LBA2); DeviceSelect = (UInt16)(xBAR0 + (byte)Register.ATA_REG_HDDEVSEL); // Disable IRQ PortIO.Out8(ControlReg, 0x2); // Discover what we have =P Discover(); if (mDevice != Device.IDE_None) { IRQInvoked = false; // Register Interrupt Handler :-) IDT.RegisterInterrupt( delegate(ref IRQContext xContext) { IRQInvoked = true; }, (uint)(IsPrimary ? 0x2E : 0x2F)); } }
/// <summary> /// Main /// </summary> public static void Main() { Kernel.x86.Kernel.Setup(); Console = ConsoleManager.Controller.Boot; Console.Clear(); Serial.SetupPort(Serial.COM1); IDT.SetInterruptHandler(ProcessInterrupt); hal = new Hardware(); // Create Service manager and basic services var serviceManager = new ServiceManager(); DeviceService = new DeviceService(); var diskDeviceService = new DiskDeviceService(); var partitionService = new PartitionService(); var pciControllerService = new PCIControllerService(); var pciDeviceService = new PCIDeviceService(); serviceManager.AddService(DeviceService); serviceManager.AddService(diskDeviceService); serviceManager.AddService(partitionService); serviceManager.AddService(pciControllerService); serviceManager.AddService(pciDeviceService); DeviceSystem.Setup.Initialize(hal, DeviceService.ProcessInterrupt); DeviceService.RegisterDeviceDriver(DeviceDriver.Setup.GetDeviceDriverRegistryEntries()); DeviceService.Initialize(new X86System(), null); partitionService.CreatePartitionDevices(); var partitions = DeviceService.GetDevices <IPartitionDevice>(); foreach (var partition in partitions) { var fat = new FatFileSystem(partition.DeviceDriver as IPartitionDevice); hasFS = fat.IsValid; if (hasFS) { var location = fat.FindEntry("WALLP.BMP"); if (location.IsValid) { var fatFileStream = new FatFileStream(fat, location); var _wall = new byte[(uint)fatFileStream.Length]; for (int k = 0; k < _wall.Length; k++) { _wall[k] = (byte)(char)fatFileStream.ReadByte(); } wallpaper = new Bitmap(_wall); } } } var standardMice = DeviceService.GetDevices("StandardMouse"); if (standardMice.Count == 0) { hal.Pause(); hal.Abort("Catastrophic failure, mouse and/or PIT not found."); } mouse = standardMice[0].DeviceDriver as StandardMouse; mouse.SetScreenResolution(VBE.ScreenWidth, VBE.ScreenHeight); if (VBEDisplay.InitVBE(hal)) { Log("VBE setup OK!"); DoGraphics(); } else { Log("VBE setup ERROR!"); } }
/// <summary> /// Main /// </summary> public static void Main() { Kernel.x86.Kernel.Setup(); Console = ConsoleManager.Controller.Boot; Console.Clear(); Console.Goto(0, 0); Console.ScrollRow = 23; Console.Color = ScreenColor.White; Console.BackgroundColor = ScreenColor.Green; Debug = ConsoleManager.Controller.Debug; Console.Write(" MOSA OS Version 2.2 - Compiler Version 2.2"); FillLine(); Console.Color = ScreenColor.White; Console.BackgroundColor = ScreenColor.Black; Console.WriteLine("> Initializing services..."); // Create Service manager and basic services var serviceManager = new ServiceManager(); DeviceService = new DeviceService(); var diskDeviceService = new DiskDeviceService(); var partitionService = new PartitionService(); var pciControllerService = new PCIControllerService(); var pciDeviceService = new PCIDeviceService(); var pcService = new PCService(); serviceManager.AddService(DeviceService); serviceManager.AddService(diskDeviceService); serviceManager.AddService(partitionService); serviceManager.AddService(pciControllerService); serviceManager.AddService(pciDeviceService); serviceManager.AddService(pcService); Console.WriteLine("> Initializing hardware abstraction layer..."); // Set device driver system with the hardware HAL var hardware = new HAL.Hardware(); DeviceSystem.Setup.Initialize(hardware, DeviceService.ProcessInterrupt); Console.WriteLine("> Registering device drivers..."); DeviceService.RegisterDeviceDriver(DeviceDriver.Setup.GetDeviceDriverRegistryEntries()); Console.WriteLine("> Starting devices..."); DeviceService.Initialize(new X86System(), null); var acpi = DeviceService.GetFirstDevice <IACPI>().DeviceDriver as IACPI; // Setup APIC var localApic = Mosa.DeviceSystem.HAL.GetPhysicalMemory((Pointer)acpi.LocalApicAddress, 0xFFFF).Address; var ioApic = Mosa.DeviceSystem.HAL.GetPhysicalMemory((Pointer)acpi.IOApicAddress, 0xFFFF).Address; APIC.Setup(localApic, ioApic); Console.Write("> Probing for ISA devices..."); var isaDevices = DeviceService.GetChildrenOf(DeviceService.GetFirstDevice <ISABus>()); Console.WriteLine("[Completed: " + isaDevices.Count.ToString() + " found]"); foreach (var device in isaDevices) { Console.Write(" "); Bullet(ScreenColor.Yellow); Console.Write(" "); InBrackets(device.Name, ScreenColor.White, ScreenColor.Green); Console.WriteLine(); } Console.Write("> Probing for PCI devices..."); var devices = DeviceService.GetDevices <PCIDevice>(); Console.WriteLine("[Completed: " + devices.Count.ToString() + " found]"); foreach (var device in devices) { Console.Write(" "); Bullet(ScreenColor.Yellow); Console.Write(" "); var pciDevice = device.DeviceDriver as PCIDevice; InBrackets(device.Name + ": " + pciDevice.VendorID.ToString("x") + ":" + pciDevice.DeviceID.ToString("x") + " " + pciDevice.SubSystemID.ToString("x") + ":" + pciDevice.SubSystemVendorID.ToString("x") + " (" + pciDevice.ClassCode.ToString("x") + ":" + pciDevice.SubClassCode.ToString("x") + ":" + pciDevice.ProgIF.ToString("x") + ":" + pciDevice.RevisionID.ToString("x") + ")", ScreenColor.White, ScreenColor.Green); var children = DeviceService.GetChildrenOf(device); if (children.Count != 0) { var child = children[0]; Console.WriteLine(); Console.Write(" "); var pciDevice2 = child.DeviceDriver as PCIDevice; InBrackets(child.Name, ScreenColor.White, ScreenColor.Green); } Console.WriteLine(); } Console.Write("> Probing for disk controllers..."); var diskcontrollers = DeviceService.GetDevices <IDiskControllerDevice>(); Console.WriteLine("[Completed: " + diskcontrollers.Count.ToString() + " found]"); foreach (var device in diskcontrollers) { Console.Write(" "); Bullet(ScreenColor.Yellow); Console.Write(" "); InBrackets(device.Name, ScreenColor.White, ScreenColor.Green); Console.WriteLine(); } Console.Write("> Probing for disks..."); var disks = DeviceService.GetDevices <IDiskDevice>(); Console.WriteLine("[Completed: " + disks.Count.ToString() + " found]"); foreach (var disk in disks) { Console.Write(" "); Bullet(ScreenColor.Yellow); Console.Write(" "); InBrackets(disk.Name, ScreenColor.White, ScreenColor.Green); Console.Write(" " + (disk.DeviceDriver as IDiskDevice).TotalBlocks.ToString() + " blocks"); Console.WriteLine(); } partitionService.CreatePartitionDevices(); Console.Write("> Finding partitions..."); var partitions = DeviceService.GetDevices <IPartitionDevice>(); Console.WriteLine("[Completed: " + partitions.Count.ToString() + " found]"); //foreach (var partition in partitions) //{ // Console.Write(" "); // Bullet(ScreenColor.Yellow); // Console.Write(" "); // InBrackets(partition.Name, ScreenColor.White, ScreenColor.Green); // Console.Write(" " + (partition.DeviceDriver as IPartitionDevice).BlockCount.ToString() + " blocks"); // Console.WriteLine(); //} Console.Write("> Finding file systems..."); foreach (var partition in partitions) { var fat = new FatFileSystem(partition.DeviceDriver as IPartitionDevice); if (fat.IsValid) { Console.WriteLine("Found a FAT file system!"); const string filename = "TEST.TXT"; var location = fat.FindEntry(filename); if (location.IsValid) { Console.Write("Found: " + filename); var fatFileStream = new FatFileStream(fat, location); uint len = (uint)fatFileStream.Length; Console.WriteLine(" - Length: " + len.ToString() + " bytes"); Console.Write("Reading File: "); for (; ;) { int i = fatFileStream.ReadByte(); if (i < 0) { break; } Console.Write((char)i); } Console.WriteLine(); } const string bmpname = "WALLP.BMP"; var bmploc = fat.FindEntry(bmpname); if (bmploc.IsValid) { Console.Write("Found: " + bmpname); var fatFileStream = new FatFileStream(fat, bmploc); uint len = (uint)fatFileStream.Length; Console.WriteLine(" - Length: " + len.ToString() + " bytes"); Console.WriteLine(); } } } // Get StandardKeyboard var keyboards = DeviceService.GetDevices("StandardKeyboard"); if (keyboards.Count == 0) { Console.WriteLine("No Keyboard!"); ForeverLoop(); } var stdKeyboard = keyboards[0].DeviceDriver as IKeyboardDevice; // setup keymap var keymap = new US(); // setup keyboard (state machine) var keyboard = new DeviceSystem.Keyboard(stdKeyboard, keymap); // setup app manager var manager = new AppManager(Console, keyboard, serviceManager); IDT.SetInterruptHandler(manager.ProcessInterrupt); Logger.Log("<SELFTEST:PASSED>"); manager.Start(); }
public static void Start() { Screen.Color = 0x0; Screen.Clear(); Screen.GotoTop(); Screen.Color = 0x0E; Screen.Write('M'); Screen.Write('O'); Screen.Write('S'); Screen.Write('A'); Screen.Write(' '); Screen.Write('O'); Screen.Write('S'); Screen.Write("!"); Screen.Write(" "); DebugClient.Setup(Serial.COM1); Screen.Write('0'); IDT.SetInterruptHandler(null); Screen.Write('1'); Multiboot.Setup(); Screen.Write('2'); PIC.Setup(); Screen.Write('3'); GDT.Setup(); Screen.Write('4'); IDT.Setup(); Screen.Write('5'); PageFrameAllocator.Setup(); Screen.Write('6'); PageTable.Setup(); Screen.Write('7'); VirtualPageAllocator.Setup(); Screen.Write('8'); ProcessManager.Setup(); Screen.Write('9'); GC.Setup(); Screen.Write('0'); //Runtime.Setup(); Screen.Write('A'); TaskManager.Setup(); Screen.Write('B'); IDT.SetInterruptHandler(ProcessInterrupt); Screen.Write('C'); ConsoleManager.Setup(); Screen.Write('D'); Console = ConsoleManager.Controller.Boot; Screen.Write('E'); Screen.Write('F'); Console.Color = 0x0E; Console.BackgroundColor = 1; Console.WriteLine(); Console.WriteLine(); Console.Write("!MOSA is alive!"); Console.WriteLine(); KernelTest.RunTests(); Console.WriteLine(); DumpStackTrace(); //System.Threading.SpinLock splk = new System.Threading.SpinLock(); //bool lockTaken = false; //splk.Enter(ref lockTaken); //if (splk.IsHeld) // Console.Write("Entered..."); //lockTaken = false; //splk.Enter(ref lockTaken); //Console.Write("Should have looped!!!"); Console.Goto(22, 0); Process(); }
public static void Main() { Screen.Clear(); Screen.BackgroundColor = ScreenColor.Blue; Screen.Color = ScreenColor.Yellow; Screen.Write('M'); Screen.Write('O'); Screen.Write('S'); Screen.Write('A'); Screen.Write(' '); Screen.Write('O'); Screen.Write('S'); Screen.Write("!"); Screen.Write(" "); Multiboot.Setup(); Screen.Write('0'); GDT.Setup(); Screen.Write('1'); IDT.SetInterruptHandler(null); Screen.Write('2'); Debugger.Setup(Serial.COM1); Screen.Write('3'); PIC.Setup(); Screen.Write('4'); IDT.Setup(); Screen.Write('5'); PageFrameAllocator.Setup(); Screen.Write('6'); PageTable.Setup(); Screen.Write('7'); VirtualPageAllocator.Setup(); Screen.Write('8'); GC.Setup(); Screen.Write('9'); Scheduler.Setup(); Screen.Write('B'); IDT.SetInterruptHandler(ProcessInterrupt); Screen.Write('C'); ConsoleManager.Setup(); Screen.Write('D'); Screen.Write('E'); Screen.WriteLine(); Screen.WriteLine(); KernelTest.RunTests(); StackTrace(); StartThreadTest(); // should never get here Screen.Write("!BAD!"); while (true) { Native.Hlt(); } }
internal static void Setup() { IDT.RegisterInterrupt(Handler, 0x7F); }
static unsafe void KeyboardHandler (IDT.ISRData data) { // Read from the keyboard's data buffer byte input; uint scancode; bool pressed; input = IO.ReadByte (IO.Port.KB_data_port); /* XXX: why is this commented out? if (input == KeyboardMessages.Too_Many_Keys || input == KeyboardMessages.Keyboard_Error) { // TODO: do something usefull here.. return; } */ if (input == 0xe0) { input = IO.ReadByte (IO.Port.KB_data_port); scancode = (uint) ((input & 0x7F) >> 8) | 0xe0; pressed = (input & 0x80) == 0; } else if (input == 0xe1) { input = IO.ReadByte (IO.Port.KB_data_port); scancode = (uint) (input & 0x7F); pressed = (input & 0x80) == 0; return; } else { scancode = (uint) (input & 0x7F); pressed = (input & 0x80) == 0; } if (scancode == (uint) Keys.CapsLock) { // CapsLock if (pressed) { if (capsLockReleased) capsLock = !capsLock; capsLockReleased = false; SetLEDs (); } else capsLockReleased = true; return; } else if (scancode == (uint) Keys.NumLock) { // NumLock if (pressed) { if (numLockReleased) numLock = !numLock; numLockReleased = false; SetLEDs (); } else numLockReleased = true; return; } else if (scancode == (uint) Keys.ScrollLock) { // ScrollLock if (pressed) { if (scrollLockReleased) scrollLock = !scrollLock; scrollLockReleased = false; SetLEDs (); } else scrollLockReleased = true; return; } else if (scancode == (uint) Keys.LeftControl) { // left control leftControl = pressed; return; } else if (scancode == (uint) Keys.LeftShift) { // left shift leftShift = pressed; return; } else if (scancode == (uint) Keys.LeftAlt) { // left alt leftAlt = pressed; return; } else if (scancode == (uint) Keys.RightAlt) { // right alt rightAlt = pressed; return; } else if (scancode == (uint) Keys.RightControl) { // right control rightControl = pressed; return; } else if (scancode == (uint) Keys.RightShift) { // right shift rightShift = pressed; return; } if (pressed) { for (int x = 0; x < EntryModule.MaxEventHandlers; ++x) { if (keyDownEvent [x] == 0) continue; MemoryUtil.Call (keyDownEvent [x], scancode); } } else { for (int x = 0; x < EntryModule.MaxEventHandlers; ++x) { if (keyUpEvent [x] == 0) continue; MemoryUtil.Call (keyUpEvent [x], scancode); } } }
/// <summary> /// Main /// </summary> public static void Main() { Mosa.Kernel.x86.Kernel.Setup(); Console = ConsoleManager.Controller.Boot; Console.Clear(); IDT.SetInterruptHandler(ProcessInterrupt); Console.Color = Colors.White; Console.Goto(0, 0); Console.Color = Colors.Yellow; Console.BackgroundColor = Colors.Black; Console.Write("MOSA OS Version 1.4 '"); Console.Color = Colors.Red; Console.Write("Neptune"); Console.Color = Colors.Yellow; Console.Write("' Copyright 2008-2015"); Console.Color = 0x0F; Console.Write(new String((char)205, 60)); Console.Write((char)203); Console.Write(new String((char)205, 19)); Console.WriteLine(); Console.Goto(2, 0); Console.Color = Colors.Green; Console.Write("Multibootaddress: "); Console.Color = Colors.Gray; unsafe { Console.Write((uint)Multiboot.MultiBootInfo, 16, 8); } Console.WriteLine(); Console.Color = Colors.Green; Console.Write("Multiboot-Flags: "); Console.Color = Colors.Gray; Console.Write(Multiboot.Flags, 2, 32); Console.WriteLine(); Console.WriteLine(); Console.Color = Colors.Green; Console.Write("Size of Memory: "); Console.Color = Colors.Gray; Console.Write((Multiboot.MemoryLower + Multiboot.MemoryUpper) / 1024, 10, -1); Console.Write(" MB ("); Console.Write(Multiboot.MemoryLower + Multiboot.MemoryUpper, 10, -1); Console.Write(" KB)"); Console.WriteLine(); Console.Color = Colors.White; for (uint index = 0; index < 60; index++) { Console.Write((char)205); } Console.WriteLine(); Console.Color = Colors.Green; Console.Write("Memory-Map:"); Console.WriteLine(); for (uint index = 0; index < Multiboot.MemoryMapCount; index++) { Console.Color = Colors.White; Console.Write(Multiboot.GetMemoryMapBase(index), 16, 10); Console.Write(" - "); Console.Write(Multiboot.GetMemoryMapBase(index) + Multiboot.GetMemoryMapLength(index) - 1, 16, 10); Console.Write(" ("); Console.Color = Colors.Gray; Console.Write(Multiboot.GetMemoryMapLength(index), 16, 10); Console.Color = Colors.White; Console.Write(") "); Console.Color = Colors.Gray; Console.Write("Type: "); Console.Write(Multiboot.GetMemoryMapType(index), 16, 1); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(); Console.Color = Colors.Green; Console.Write("Smbios Info: "); if (SmbiosManager.IsAvailable) { Console.Color = Colors.White; Console.Write("["); Console.Color = Colors.Gray; Console.Write("Version "); Console.Write(SmbiosManager.MajorVersion, 10, -1); Console.Write("."); Console.Write(SmbiosManager.MinorVersion, 10, -1); Console.Color = Colors.White; Console.Write("]"); Console.WriteLine(); Console.Color = Colors.Yellow; Console.Write("[Bios]"); Console.Color = Colors.White; Console.WriteLine(); BiosInformationStructure biosInformation = new BiosInformationStructure(); Console.Color = Colors.White; Console.Write("Vendor: "); Console.Color = Colors.Gray; Console.Write(biosInformation.BiosVendor); Console.WriteLine(); Console.Color = Colors.White; Console.Write("Version: "); Console.Color = Colors.Gray; Console.Write(biosInformation.BiosVersion); Console.WriteLine(); Console.Color = Colors.White; Console.Write("Date: "); Console.Color = Colors.Gray; Console.Write(biosInformation.BiosDate); Console.Color = Colors.Yellow; Console.Row = 8; Console.Column = 35; Console.Write("[Cpu]"); Console.Color = Colors.White; Console.WriteLine(); Console.Column = 35; CpuStructure cpuStructure = new CpuStructure(); Console.Color = Colors.White; Console.Write("Vendor: "); Console.Color = Colors.Gray; Console.Write(cpuStructure.Vendor); Console.WriteLine(); Console.Column = 35; Console.Color = Colors.White; Console.Write("Version: "); Console.Color = Colors.Gray; Console.Write(cpuStructure.Version); Console.WriteLine(); Console.Column = 35; Console.Color = Colors.White; Console.Write("Socket: "); Console.Color = Colors.Gray; Console.Write(cpuStructure.Socket); Console.Write(" MHz"); Console.WriteLine(); Console.Column = 35; Console.Color = Colors.White; Console.Write("Cur. Speed: "); Console.Color = Colors.Gray; Console.Write(cpuStructure.MaxSpeed, 10, -1); Console.Write(" MHz"); Console.WriteLine(); Console.Column = 35; } else { Console.Color = Colors.Red; Console.Write("No SMBIOS available on this system!"); } Console.Goto(14, 0); Console.Color = 0x0F; for (uint index = 0; index < 60; index++) { Console.Write((char)205); } Console.WriteLine(); //CpuInfo cpuInfo = new CpuInfo(); //#region Vendor //Console.Color = Colors.Green; //Console.Write("Vendor: "); //Console.Color = Colors.White; //cpuInfo.PrintVendorString(Console); //Console.WriteLine(); //#endregion Vendor //#region Brand //Console.Color = Colors.Green; //Console.Write("Brand: "); //Console.Color = Colors.White; //cpuInfo.PrintBrandString(Console); //Console.WriteLine(); //#endregion Brand //#region Stepping //Console.Color = Colors.Green; //Console.Write("Stepping: "); //Console.Color = Colors.White; //Console.Write(cpuInfo.Stepping, 16, 2); //#endregion Stepping //#region Model //Console.Color = Colors.Green; //Console.Write(" Model: "); //Console.Color = Colors.White; //Console.Write(cpuInfo.Model, 16, 2); //#endregion Model //#region Family //Console.Color = Colors.Green; //Console.Write(" Family: "); //Console.Color = Colors.White; //Console.Write(cpuInfo.Family, 16, 2); //#endregion Family //#region Type //Console.Color = Colors.Green; //Console.Write(" Type: "); //Console.Color = Colors.White; //Console.Write(cpuInfo.Type, 16, 2); //Console.WriteLine(); //Console.Color = Colors.Green; //Console.Write("Cores: "); //Console.Color = Colors.White; //Console.Write(cpuInfo.NumberOfCores, 16, 2); //#endregion Type Console.Row = 19; for (uint index = 0; index < 80; index++) { Console.Column = index; Console.Write((char)205); } Console.Row = 23; for (uint index = 0; index < 80; index++) { Console.Column = index; Console.Write((char)205); } for (uint index = 2; index < 20; index++) { Console.Column = 60; Console.Row = index; Console.Color = Colors.White; if (index == 6) { Console.Write((char)185); } else if (index == 14) { Console.Write((char)185); } else if (index == 19) { Console.Write((char)202); } else { Console.Write((char)186); } } Console.Goto(24, 29); Console.Color = Colors.Yellow; Console.Write("www.mosa-project.org"); Console.Goto(12, 0); byte last = 0; while (true) { DisplayCMOS(); DisplayTime(); byte second = CMOS.Second; if (second % 10 != 5 & last != second) { last = CMOS.Second; DebugClient.SendAlive(); } Native.Hlt(); } }
static unsafe void DivideByZeroHandler (IDT.ISRData data) { SharpOS.Korlib.Runtime.Runtime.Throw (new InternalSystem.DivideByZeroException (), 4); }
private static unsafe void TimerHandler (IDT.ISRData data) { ticks++; for (int x = 0; x < EntryModule.MaxEventHandlers; ++x) { if (timerEvent[x] == 0) continue; MemoryUtil.Call(timerEvent[x], ticks); } SharpOS.Kernel.ADC.Thread thread = Dispatcher.Dispatch((void*) data.Stack); if (thread != null) { IDT.Stack* newStack = (IDT.Stack*) thread.StackPointer; newStack->IrqIndex = data.Stack->IrqIndex; data.Stack = newStack; } }
public static void Main() { Screen.Clear(); Screen.BackgroundColor = ScreenColor.Blue; Screen.Color = ScreenColor.Yellow; Screen.Write('M'); Screen.Write('O'); Screen.Write('S'); Screen.Write('A'); Screen.Write(' '); Screen.Write('O'); Screen.Write('S'); Screen.Write("!"); Screen.Write(" "); Multiboot.Setup(); Screen.Write('0'); GDT.Setup(); Screen.Write('1'); IDT.SetInterruptHandler(null); Screen.Write('2'); Debugger.Setup(Serial.COM1); Screen.Write('3'); PIC.Setup(); Screen.Write('4'); IDT.Setup(); Screen.Write('5'); PageFrameAllocator.Setup(); Screen.Write('6'); PageTable.Setup(); Screen.Write('7'); VirtualPageAllocator.Setup(); Screen.Write('8'); GC.Setup(); Screen.Write('9'); Scheduler.Setup(); Screen.Write('B'); IDT.SetInterruptHandler(ProcessInterrupt); Screen.Write('C'); ConsoleManager.Setup(); Screen.Write('D'); Screen.Write('E'); Screen.WriteLine(); Screen.WriteLine(); //Screen.Write("CompilerBugTests: "); //bool value1 = Test1(); //if (value1) // Screen.WriteLine("Ok"); //else // Screen.WriteLine("Failed"); //Screen.Write("FindTypeOfTest: "); //bool value3 = Test3(); //if (value3) // Screen.WriteLine("Ok"); //else // Screen.WriteLine("Failed"); //UnitTest(); KernelTest.RunTests(); StackTrace(); TestHash(); int value2 = CallReturn10(); Screen.Write("Return10 Test: "); if (value2 == 10) { Screen.WriteLine("Ok"); } else { Screen.WriteLine("Failed"); } StartThreadTest(); // should never get here Screen.Write("!BAD!"); while (true) { Native.Hlt(); } }
internal static void Start(uint magic, uint address, uint KernelDirectory, uint InitialHeap) { /* Kernel Logger init */ Debug.Init(); /* Initalize Heap */ Heap.Init(InitialHeap); /* Multiboot Info Parsing */ Multiboot.Setup(magic, address); /* Setup Paging */ Paging.Setup(KernelDirectory); /* Setup GDT */ GDT.Setup(); /* Remap PIC */ PIC.Setup(); /* Setup IDT */ IDT.Setup(); /* Enable Interrupt */ Native.Sti(); /* Setup Scheduler */ Scheduler.Init(KernelDirectory); /* Setup System Timer */ Timer.Setup(); /* Install SHM */ SHM.Install(); /* Initialise VBE 2.0 Driver */ VBE.Init(); /* Initialise Virtual File system */ VirtualFileSystem.Setup(); /* Setup Syscall */ Syscall.Setup(); /* Initialise C library */ Libc.Init(); try { Boot.Init(); } catch (Exception e) { Debug.Write("[@SystemThread] => [EXIT]: %s\n", e.Message); } while (true) { ; } }