Skip to content

Commit

Permalink
- Worked on debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Mar 19, 2018
1 parent fe15d6a commit c7fbea3
Show file tree
Hide file tree
Showing 53 changed files with 761 additions and 245 deletions.
15 changes: 8 additions & 7 deletions Source/Mosa.Kernel.x86/Scheduler.cs
Expand Up @@ -160,36 +160,37 @@ public static uint CreateThread(uint methodAddress, uint stackSize)
return threadID;
}

private static void CreateThread(uint methoAddress, uint stackSize, uint threadID)
private static void CreateThread(uint methodAddress, uint stackSize, uint threadID)
{
var thread = Threads[threadID];

var stack = VirtualPageAllocator.Reserve(stackSize);
uint stackStateSize = 52;
var stackTop = stack + stackSize;

// Setup stack state
Native.Set32(stackTop - 4, 0); // Zero Sentinel
Native.Set32(stackTop - 8, SignalThreadTerminationMethodAddress); // Address of method that will raise a interrupt signal to terminate thread

Native.Set32(stackTop - 4 - 8, 0); // EFLAG
Native.Set32(stackTop - 8 - 8, 0); // CS
Native.Set32(stackTop - 12 - 8, methoAddress); // EIP
Native.Set32(stackTop - 4 - 8, 0x00000202);// EFLAG
Native.Set32(stackTop - 8 - 8, 0x08); // CS
Native.Set32(stackTop - 12 - 8, methodAddress); // EIP

Native.Set32(stackTop - 16 - 8, 0); // ErrorCode - not used
Native.Set32(stackTop - 20 - 8, 0); // Interrupt Number - not used

Native.Set32(stackTop - 24 - 8, 0); // EAX
Native.Set32(stackTop - 28 - 8, 0); // ECX
Native.Set32(stackTop - 32 - 8, 0); // EDX
Native.Set32(stackTop - 36 - 8, 0); // EBX
Native.Set32(stackTop - 40 - 8, stackTop - 8); // ESP (original) - not used
Native.Set32(stackTop - 40 - 8, 0); // ESP (original) - not used
Native.Set32(stackTop - 44 - 8, stackTop - 8); // EBP
Native.Set32(stackTop - 48 - 8, 0); // ESI
Native.Set32(stackTop - 52 - 8, 0); // EDI

thread.Status = ThreadStatus.Running;
thread.StackBottom = stack;
thread.StackTop = stackTop;
thread.StackStatePointer = stackTop - stackStateSize;
thread.StackStatePointer = stackTop - 52;
}

private static void SaveThreadState(uint threadID, uint stackSate)
Expand Down
12 changes: 6 additions & 6 deletions Source/Mosa.Tool.GDBDebugger/ConnectWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Source/Mosa.Tool.GDBDebugger/DebugAppLocationsWindow.cs
@@ -0,0 +1,38 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using Mosa.Tool.GDBDebugger.GDB;
using Mosa.Utility.BootImage;
using Mosa.Utility.Launcher;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace Mosa.Tool.GDBDebugger
{
public partial class DebugAppLocationsWindow : Form
{
private readonly AppLocations AppLocations;

public DebugAppLocationsWindow(AppLocations apps)
{
InitializeComponent();

AppLocations = apps;
}

private void DebugQemuWindow_Load(object sender, EventArgs e)
{
tbQEMU.Text = AppLocations.QEMU;
tbBIOSDirectory.Text = AppLocations.QEMUBIOSDirectory;
}

private void btnDebug_Click(object sender, EventArgs e)
{
AppLocations.QEMU = tbQEMU.Text;
AppLocations.QEMUBIOSDirectory = tbBIOSDirectory.Text;

Close();
}
}
}

0 comments on commit c7fbea3

Please sign in to comment.