public async Task <IActionResult> Post([FromBody] PanicViewModel panicViewModel) { try { var user = await GetUser(); var panic = new Panic { ApplicationUserId = user.Id, Id = panicViewModel.Id, DateCreated = DateTime.UtcNow }; await _panicRepository.CreatePanic(panic); await PanickingService.SendPanicAlarm(_locationActionEventsRepository, _messagingService, _locationRepository, user); return(Ok(panicViewModel)); } catch (Exception ex) { Logger.LogError(ex.Message); return(BadRequest(new ErrorResponse(ex))); } }
public CombatHelperBehavior() { //_arm = new Arm(); //_combat = new Combat(); //_drones = new Drones(); _panic = new Panic(); //_salvage = new Salvage(); //_slave = new Slave(); _unloadLoot = new UnloadLoot(); _watch = new Stopwatch(); // // this is combat mission specific and needs to be generalized // Settings.Instance.SettingsLoaded += SettingsLoaded; //Settings.Instance.UseFittingManager = false; // States.CurrentCombatHelperBehaviorState fixed on ExecuteMission _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.UnloadLoot; _States.CurrentArmState = ArmState.Idle; //_States.CurrentCombatState = CombatState.Idle; //_States.CurrentDroneState = DroneState.Idle; _States.CurrentUnloadLootState = UnloadLootState.Idle; _States.CurrentTravelerState = TravelerState.Idle; Interlocked.Increment(ref CombatHelperBehaviorInstances); }
private static void AssertError(string message, uint arg1 = 0, uint arg2 = 0, uint arg3 = 0) { var sb = new StringBuffer(); sb.Append(message, arg1, arg2, arg3); Panic.Error(sb.CreateString()); }
/// <summary> /// Adds an IRQ to the table /// </summary> /// <param name="slot">The slot</param> /// <param name="pin">The pin</param> /// <param name="irq">The IRQ</param> private static void addIRQ(uint slot, uint pin, uint irq, uint polarity, uint trigger) { if (slot >= PCI_BUS_DEV_MAX || pin > PCI_PINS) { Panic.DoPanic("[PCI] Invalid IRQ added"); } PciIRQEntry entry = new PciIRQEntry(); entry.Irq = irq; entry.Flags = 0; if (polarity == 0 || polarity == 3) { entry.Flags |= IOApic.IOAPIC_REDIR_POLARITY_LOW; } else { entry.Flags |= IOApic.IOAPIC_REDIR_POLARITY_HIGH; } if (trigger == 0 || trigger == 3) { entry.Flags |= IOApic.IOAPIC_REDIR_TRIGGER_LEVEL; } else { entry.Flags |= IOApic.IOAPIC_REDIR_TRIGGER_EDGE; } m_irqTable[(slot * PCI_PINS) + pin] = entry; }
/// <summary> /// Starts a new process based on the given path and arguments /// </summary> /// <param name="path">The path</param> /// <param name="argv">The arguments</param> /// <param name="flags">Spawn flags</param> /// <returns>Errorcode or PID</returns> public static int StartProcess(string path, string[] argv, Task.SpawnFlags flags) { if (argv == null) { Panic.DoPanic("argv == null"); } Node node = VFS.GetByAbsolutePath(path); if (node == null) { return(-(int)ErrorCode.ENOENT); } // Open and create buffer VFS.Open(node, (int)FileMode.O_RDONLY); byte[] buffer = new byte[node.Size]; if (buffer == null) { Heap.Free(node); VFS.Close(node); return(-(int)ErrorCode.ENOMEM); } // Fill buffer contents VFS.Read(node, 0, node.Size, buffer); VFS.Close(node); // Pass execution to ELF loader int status = ELFLoader.Execute(buffer, node.Size, argv, flags); Heap.Free(buffer); Heap.Free(node); return(status); }
public Questor() { _lastPulse = DateTime.MinValue; _random = new Random(); _salvage = new Salvage(); _defense = new Defense(); _combat = new Combat(); _traveler = new Traveler(); _unloadLoot = new UnloadLoot(); _agentInteraction = new AgentInteraction(); _arm = new Arm(); _missionController = new MissionController(); _drones = new Drones(); _panic = new Panic(); _storyline = new Storyline(); Settings.Instance.SettingsLoaded += SettingsLoaded; // State fixed on ExecuteMission State = QuestorState.Idle; _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; _directEve.OnFrame += OnFrame; }
public unsafe Page *AllocatePages(uint pages, AllocatePageOptions options = default) { if (pages > _FreePages) { Panic.Error("Out of Memory"); return(null); } Page *page; if (AddressSpaceKind == AddressSpaceKind.Virtual || options.Continuous) { page = AllocatePagesContinuous(pages, options); } else { page = AllocatePagesNormal(pages, options); } if (page == null) { KernelMessage.WriteLine("DebugName: {0}", DebugName); KernelMessage.WriteLine("Free pages: {0:X8}, Requested: {1:X8}", FreePages, pages); Panic.Error("Out of Memory"); } KernelMessage.Path(DebugName, "SimpleAlloc: Request {0} Pages, Addr {1:X8}", pages, GetAddress(page)); return(page); }
public Questor(frmMain form1) { m_Parent = form1; _lastPulse = DateTime.MinValue; _random = new Random(); _salvage = new Salvage(); _defense = new Defense(); _combat = new Combat(); _traveler = new Traveler(); _unloadLoot = new UnloadLoot(); _agentInteraction = new AgentInteraction(); _arm = new Arm(); _missionController = new MissionController(); _drones = new Drones(); _panic = new Panic(); _storyline = new Storyline(); Settings.Instance.SettingsLoaded += SettingsLoaded; // State fixed on ExecuteMission State = QuestorState.Idle; _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; Cache.Instance.StopTimeSpecified = Program.stopTimeSpecified; _directEve.OnFrame += OnFrame; }
/// <summary> /// Do identify and read needed shizzle /// </summary> private void DoIdentify() { void *adr = Heap.Alloc(0x1000); int status = Identify(0, 1, adr); int statusCode = (status >> COMP_STATUS_SC_SHIFT) & COMP_STATUS_SC_MASK; if (statusCode != COMP_STATUS_SC_SUC) { Panic.DoPanic("[NVMe] Couldn't identifiy"); } NVMe_ID_Ctrl *idCtrl = (NVMe_ID_Ctrl *)adr; mFirmwareRevision = new char[8]; mSerialNumber = new char[20]; mModel = new char[40]; nNumNamespaces = (int)idCtrl->Nn; Memory.Memcpy(Util.ObjectToVoidPtr(mFirmwareRevision), idCtrl->FirmwareRevision, 8); Memory.Memcpy(Util.ObjectToVoidPtr(mSerialNumber), idCtrl->SerialNumber, 20); Memory.Memcpy(Util.ObjectToVoidPtr(mModel), idCtrl->ModelNumber, 40); Heap.Free(adr); }
/// <summary> /// Temporary kernel memory allocation before a real heap is set up /// </summary> /// <param name="size">The size</param> /// <param name="align">If the block should be aligned</param> /// <returns>A block of memory</returns> public static unsafe void *KAlloc(int size, bool align) { #if HEAP_DEBUG if (useRealHeap) { Panic.DoPanic("[HEAP] KAlloc has been called after real heap started!"); } #endif if (PhysicalMemoryManager.IsInitialized) { return(PhysicalMemoryManager.AllocRange(size)); } else { uint address = (uint)CurrentEnd; if (align) { address = Paging.AlignUp(address); } // At least 4byte align if ((address & 3) != 0) { address &= 3; address += 4; } CurrentEnd = (void *)(address + size); return((void *)address); } }
/// <summary> /// Creates a new page directory using only physical memory (used in Init) /// </summary> /// <param name="flags">The flags</param> /// <returns>The page directory</returns> public static PageDirectory *CreateNewDirectoryPhysically(PageFlags flags) { // Allocate a new block of physical memory to store our physical page in PageDirectory *directory = (PageDirectory *)Heap.AlignedAlloc(0x1000, sizeof(PageDirectory)); directory->PhysicalDirectory = directory; if (directory == null) { Panic.DoPanic("directory == null"); } // Allocate the tables for (int i = 0; i < 1024; i++) { PageTable *table = (PageTable *)PhysicalMemoryManager.Alloc(); if (table == null) { Panic.DoPanic("table == null"); } Memory.Memclear(table, sizeof(PageTable)); // Note: At this point, virtual address == physical address due to identity mapping directory->PhysicalTables[i] = (int)table | (int)flags; directory->VirtualTables[i] = (int)table; } return(directory); }
/// <summary> /// Wait for drive to be finished /// </summary> /// <param name="port">Port IO base</param> private static void poll(uint port) { wait400ns(port); byte status; do { status = PortIO.In8((ushort)(port + ATA_REG_STATUS)); }while ((status & ATA_STATUS_BSY) > 0); while ((status & ATA_STATUS_DRQ) == 0) { status = PortIO.In8((ushort)(port + ATA_REG_STATUS)); if ((status & ATA_STATUS_DF) > 0) { Panic.DoPanic("Device fault!"); } if ((status & ATA_STATUS_ERR) > 0) { Panic.DoPanic("ERR IN ATA!!"); } } }
private async void OnPanic() { _canPanic = false; Panic.ChangeCanExecute(); await Task.Delay(1000); _canPanic = true; Panic.ChangeCanExecute(); }
/// <summary> /// Translate ISA IRQ to a redirection entry /// </summary> /// <param name="irq">The ISA IRQ number</param> /// <returns>The override</returns> public static ISAOverride GetISARedirection(uint irq) { if (irq >= 16) { Panic.DoPanic("Requested an ISA redirection for IRQ >= 16"); } return(m_intSourceOverrides[irq]); }
public static unsafe ElfSections FromSectionName(string name) { bool success; var elf = FromSectionName(name, out success); if (!success) { Panic.Error("Could not find section " + name); } return(elf); }
public async Task CreatePanic(Panic panic) { panic.Id = Guid.NewGuid(); using (DataContext = new SimplySecureDataContext()) { DataContext.Panics.Add(panic); await DataContext.SaveChangesAsync(); } }
/// <summary> /// Gets the block from the pointer /// </summary> /// <param name="ptr">The pointer</param> /// <returns>The block</returns> private static unsafe Block *getBlockFromPtr(void *ptr) { Block *block = (Block *)((int)ptr - sizeof(Block)); #if HEAP_USE_MAGIC if (block->Magic != HEAP_MAGIC) { Panic.DoPanic("[HEAP] block->Magic != HEAP_MAGIC"); } #endif return(block); }
/// <summary> /// Create queues (for now just 1..) /// </summary> private void CreateQueues() { var queue = CreateQueue(1); if (queue == null) { Panic.DoPanic("[NVMe] Couldn't make queue"); } mIOQueue = queue; }
/// <summary> /// Sets the IRQ routing /// </summary> private static void setIRQRouting() { m_irqTable = new PciIRQEntry[PCI_BUS_DEV_MAX * PCI_PINS]; // Find root PCI device and handle it int status = Acpica.AcpiGetDevices("PNP0A03", onRootDevice, null, null); if (status != Acpica.AE_OK) { Panic.DoPanic("[PCI] Couldn't get root device"); } }
private static void Setup() { IDT.SetInterruptHandler(null); Panic.Setup(); Debugger.Setup(Serial.COM1); // Initialize interrupts PIC.Setup(); IDT.Setup(); GDT.Setup(); //Runtime.Internal.Setup(); }
public void SavePanic(Panic panic) { this.SaveUser(panic.User); if (panic.Id == 0) { this.Panics.Add(panic); } else { this.Panics.Attach(panic); } this.SaveChanges(); }
protected async Task PanicExecute() { try { IsBusy = true; Panic panic = new Panic(cid, BackendAuthManager.Instance.User); await api.Backend.SavePanicAsync(panic); Status = "Sent Panic"; IsBusy = false; } catch (Exception ex) { Status = "Failed: " + ex.Message; } }
public MiningBehavior() { //_arm = new Arm(); _panic = new Panic(); //_combat = new Combat(); _unloadLoot = new UnloadLoot(); //_drones = new Drones(); _lastPulse = DateTime.MinValue; MiningToolGroupIDs.Add((int)Group.Miners); //miners MiningToolGroupIDs.Add((int)Group.StripMiners); //strip miners MiningToolGroupIDs.Add((int)Group.ModulatedStripMiners); //modulated strip miners }
/// <summary> /// Syscall interrupt handler. Dispatcher for every SysCall. /// </summary> private static void InterruptHandler(ref IDTStack stack, SysCallCallingType callingMethod) { var args = new SystemMessage { Target = (SysCallTarget)stack.EAX, Arg1 = stack.EBX, Arg2 = stack.ECX, Arg3 = stack.EDX, Arg4 = stack.ESI, Arg5 = stack.EDI, Arg6 = stack.EBP, }; var commandNum = GetCommandNum(args.Target); if (KConfig.Log.SysCall) { KernelMessage.WriteLine("Got SysCall cmd={0} arg1={1:X8} arg2={2:X8} arg3={3:X8} arg4={4:X8} arg5={5:X8} arg6={6:X8}", (uint)args.Target, args.Arg1, args.Arg2, args.Arg3, args.Arg4, args.Arg5, args.Arg6); } Scheduler.SaveThreadState(Scheduler.GetCurrentThread().ThreadID, ref stack); var info = Commands[commandNum]; if (info == null) { Panic.Error("Undefined SysCall"); } var ctx = new SysCallContext { CallingType = callingMethod, Debug = info.Debug, }; if (info.Debug) { KDebug.DumpStats(); Debug.Nop(); } var result = info.Handler(ref ctx, ref args); if (KConfig.Log.SysCall) { KernelMessage.WriteLine("Result of Syscall cmd={0}: {1:X8}", (uint)args.Target, result); } stack.EAX = result; }
public static unsafe void Start() { SetThreadID(0); Enabled = true; KernelMessage.WriteLine("Enable Scheduler"); IDTManager.SetPrivilegeLevel((uint)KnownInterrupt.TerminateCurrentThread, 0x03); GDT.Tss->ESP0 = Threads[0].KernelStackBottom; GDT.LoadTaskRegister(); TriggerScheduler(); // Normally, you should never get here Panic.Error("Main-Thread still alive"); }
public void TestSavePanic() { User u = User.GenerateNewUser(); Panic p = new Panic("testCourse", u); Panic p2 = new Panic("testCourse", u); using (var db = new TestSurveyContext()) { db.SaveUser(u); db.SavePanic(p); db.SavePanic(p2); db.SaveChanges(); } }
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> /// Creates a block descriptor with given minimal size /// </summary> /// <param name="size">The minimal size</param> /// <returns>The block descriptor</returns> private static unsafe BlockDescriptor *createBlockDescriptor(int size) { #if HEAP_DEBUG_DESCRIPTOR Console.WriteLine("[HEAP] Creating a new block descriptor"); #endif // Add size of Block and BlockDescriptor size += sizeof(Block) + sizeof(BlockDescriptor); // Allocate descriptor size = getRequiredPageCount(size) * 0x1000; BlockDescriptor *descriptor = (BlockDescriptor *)Paging.AllocateVirtual(size); #if HEAP_DEBUG_DESCRIPTOR Console.Write("[HEAP] New descriptor is at 0x"); Console.WriteHex((int)descriptor); Console.Write(", physical: 0x"); Console.WriteHex((int)Paging.GetPhysicalFromVirtual(descriptor)); Console.Write('\n'); #endif if (descriptor == null) { Panic.DoPanic("descriptor == null"); } // Setup block Block *first = (Block *)((int)descriptor + sizeof(BlockDescriptor)); first->Prev = null; first->Next = null; first->Size = size - sizeof(BlockDescriptor); first->Used = false; first->Descriptor = descriptor; #if HEAP_USE_MAGIC first->Magic = HEAP_MAGIC; #endif // Setup descriptor descriptor->FreeSpace = size - sizeof(BlockDescriptor); descriptor->First = first; descriptor->FirstFree = first; descriptor->Next = null; #if HEAP_USE_MAGIC descriptor->Magic = HEAP_MAGIC; #endif return(descriptor); }
/// <summary> /// Called as callback when a root device is found /// </summary> /// <param name="Object">The object</param> /// <param name="NestingLevel">Nesting level</param> /// <param name="Context">User context</param> /// <param name="ReturnValue">Return value if early returned</param> /// <returns>Status</returns> private static int onRootDevice(void *Object, uint NestingLevel, void *Context, void **ReturnValue) { // Get routing table AcpiObjects.Buffer buffer; buffer.Length = Acpica.ACPI_ALLOCATE_BUFFER; int status = Acpica.AcpiGetIrqRoutingTable(Object, &buffer); if (status != Acpica.AE_OK) { Panic.DoPanic("[PCI] Couldn't get ACPI IRQ Routing Table"); } // The last entry will have Length 0 Acpica.PCIRoutingTable *table = (Acpica.PCIRoutingTable *)buffer.Pointer; while (table->Length > 0) { // No reference source if (table->Source[0] == 0) { uint slot = (uint)(table->Address >> 16); addIRQ(slot, table->Pin, table->SourceIndex, 0, 0); } // Source is not null, that means we need to lookup the reference resource else { void *handle = null; status = Acpica.AcpiGetHandle(Object, Util.CharPtrToString(table->Source), &handle); if (status != Acpica.AE_OK) { Panic.DoPanic("[PCI] Couldn't load references handle"); } status = Acpica.AcpiWalkResources(handle, Acpica.METHOD_NAME__CRS, onIRQResource, table); if (status != Acpica.AE_OK) { Panic.DoPanic("[PCI] Couldn't process resources for IRQ"); } } // Next entry table = (Acpica.PCIRoutingTable *)((byte *)table + table->Length); } // The object returned should be freed by us Acpica.AcpiOsFree(buffer.Pointer); return(Acpica.AE_OK); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); return; } rand = new System.Random(); startPos = transform.position; GameManager.OnFailGame += StopPanic; }
/// <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 Questor(frmMain form1) { m_Parent = form1; _lastPulse = DateTime.MinValue; _random = new Random(); //_debugmodule = new DebugModule(); //_scoop = new Scoop(); _salvage = new Salvage(); _defense = new Defense(); _localwatch = new LocalWatch(); _scanInteraction = new ScanInteraction(); _combat = new Combat(); _traveler = new Traveler(); _unloadLoot = new UnloadLoot(); _agentInteraction = new AgentInteraction(); _arm = new Arm(); _courier = new CourierMission(); _switch = new SwitchShip(); _missionController = new MissionController(); _drones = new Drones(); _panic = new Panic(); _storyline = new Storyline(); Settings.Instance.SettingsLoaded += SettingsLoaded; // State fixed on ExecuteMission State = QuestorState.Idle; _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; Cache.Instance.StopTimeSpecified = Program.stopTimeSpecified; Cache.Instance.MaxRuntime = Program.maxRuntime; Cache.Instance.StopTime = Program._stopTime; _questorStarted = DateTime.Now; _directEve.OnFrame += OnFrame; }
private Hardware BuildHardware(Panic.Repository.Linq.Hardware aHardware) { Hardware hardware = new Hardware(aHardware.HardwareID) { Enabled = (bool)aHardware.Enabled, Description = aHardware.Description, Make = aHardware.Make, ModelNumber = aHardware.ModelNumber, RXCapacity = (double)aHardware.RXCapacity, TXCapacity = (double)aHardware.TXCapacity, Notes = aHardware.Notes }; return hardware; }
private Link BuildLink(Panic.Repository.Linq.Link aLink) { Link link = new Link(aLink.LinkID) { Enabled = (bool)aLink.Enabled, FromSiteID = aLink.FromSiteID, ToSiteID = aLink.ToSiteID, HardwareID = aLink.HardwareID, Notes = aLink.Notes, RXOverride = (double)aLink.RXOverride, TXOverride = (double)aLink.TXOverride }; return link; }