mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-10 10:11:31 +00:00
This commit is contained in:
parent
f4f90780da
commit
c7439856fb
5 changed files with 3 additions and 144 deletions
|
|
@ -19,6 +19,7 @@ namespace Cosmos.Debug.DebugStub {
|
|||
new Comment("-http:#wiki.osdev.org/Spinlock");
|
||||
new Comment("-Looks good and also allows testing intead of waiting");
|
||||
new Comment("-Wont require us to disable / enable IRQs");
|
||||
new Comment("Comment");
|
||||
new Label("DebugStub_TracerEntry");
|
||||
new Comment("This code is temporarily disabled as IRQs are not enabled right now.");
|
||||
new Comment("LockOrExit");
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
# -Looks good and also allows testing intead of waiting
|
||||
# -Wont require us to disable / enable IRQs
|
||||
|
||||
# Comment
|
||||
|
||||
Group DebugStub
|
||||
|
||||
InterruptHandler TracerEntry {
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Kernel.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Test.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Test.xs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Cosmos.Assembler.X86\Cosmos.Assembler.x86.csproj">
|
||||
|
|
@ -78,12 +73,6 @@
|
|||
<Name>Cosmos.Hardware</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Test.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>Test.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Cosmos.Assembler;
|
||||
using Cosmos.Assembler.x86;
|
||||
|
||||
namespace MatthijsPlayground
|
||||
{
|
||||
public class Test : Cosmos.Assembler.Code {
|
||||
public override void Assemble() {
|
||||
new Comment("From Entry.CS");
|
||||
new Comment("We need to make sure Int3 can never run more than one instance at a time.");
|
||||
new Comment("We are not threaded yet, when we are we have to change stuff to thread vars and a lot of other stuff.");
|
||||
new Comment("Two Int3 calls currently can never happen at the same time normally, but IRQs can happen while the DebugStub is");
|
||||
new Comment("running. We also need to make sure IRQs are allowed to run during DebugStub as DebugStub can wait for");
|
||||
new Comment("a long time on commands.");
|
||||
new Comment("So we need to disable interrupts immediately and set a flag, then reenable interrupts if they were enabled");
|
||||
new Comment("when we disabled them. Later this can be replaced by some kind of critical section / lock around this code.");
|
||||
new Comment("Currently IRQs are disabled - we need to fix DS before we can reenable them and add support for critical sections / locks here.");
|
||||
new Comment("-http:#www.codemaestro.com/reviews/8");
|
||||
new Comment("-http:#en.wikipedia.org/wiki/Spinlock - Uses a register which is a problem for us");
|
||||
new Comment("-http:#wiki.osdev.org/Spinlock");
|
||||
new Comment("-Looks good and also allows testing intead of waiting");
|
||||
new Comment("-Wont require us to disable / enable IRQs");
|
||||
new Label("TracerEntry");
|
||||
new Comment("This code is temporarily disabled as IRQs are not enabled right now.");
|
||||
new Comment("LockOrExit");
|
||||
new Comment("EBP is restored by PopAll, but SendFrame uses it. Could");
|
||||
new Comment("get it from the PushAll data, but this is easier.");
|
||||
new Mov { DestinationRef = Cosmos.Assembler.ElementReference.New("CallerEBP") , SourceReg = RegistersEnum.EBP };
|
||||
new Comment("Could get ESP from PushAll but this is easier.");
|
||||
new Comment("Also allows us to use the stack before PushAll if we ever need it.");
|
||||
new Comment("We cant modify any registers since we havent done PushAll yet");
|
||||
new Comment("Maybe we could do a sub(4) on memory direct..");
|
||||
new Comment("But for now we remove from ESP which the Int3 produces,");
|
||||
new Comment("store ESP, then restore ESP so we don't cause stack corruption.");
|
||||
new Comment("12 bytes for EFLAGS, CS, EIP");
|
||||
new Add { DestinationReg = RegistersEnum.ESP, SourceValue = 12 };
|
||||
new Mov { DestinationRef = Cosmos.Assembler.ElementReference.New("CallerESP") , SourceReg = RegistersEnum.ESP };
|
||||
new Sub { DestinationReg = RegistersEnum.ESP, SourceValue = 12 };
|
||||
new Pushad();
|
||||
new Comment("Save current ESP so we can look at the results of PushAll later");
|
||||
new Mov { DestinationRef = Cosmos.Assembler.ElementReference.New("PushAllPtr") , SourceReg = RegistersEnum.ESP };
|
||||
new Comment("Get current ESP and add 32. This will skip over the PushAll and point");
|
||||
new Comment("us at the call data from Int3.");
|
||||
new Mov{ DestinationReg = RegistersEnum.EBP, SourceReg = RegistersEnum.ESP };
|
||||
new Add { DestinationReg = RegistersEnum.EBP, SourceValue = 32 };
|
||||
new Comment("Caller EIP");
|
||||
new Mov { DestinationReg = RegistersEnum.EAX, SourceReg = RegistersEnum.EBP, SourceIsIndirect = true};
|
||||
new Comment("EIP is pointer to op after our call. Int3 is 1 byte so we subtract 1.");
|
||||
new Comment("Note - when we used call it was 5 (size of our call + address)");
|
||||
new Comment("so we get the EIP as IL2CPU records it. Its also useful for when we");
|
||||
new Comment("wil be changing ops that call this stub.");
|
||||
new Dec { DestinationReg = RegistersEnum.EAX };
|
||||
new Comment("Store it for later use.");
|
||||
new Mov { DestinationRef = Cosmos.Assembler.ElementReference.New("CallerEIP") , SourceReg = RegistersEnum.EAX };
|
||||
new Call { DestinationLabel = "Executing" };
|
||||
new Popad();
|
||||
new Comment("Temp disabled, see comment on LockOrExit above");
|
||||
new Comment("Unlock");
|
||||
new IRET();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
# From Entry.CS
|
||||
|
||||
# We need to make sure Int3 can never run more than one instance at a time.
|
||||
# We are not threaded yet, when we are we have to change stuff to thread vars and a lot of other stuff.
|
||||
# Two Int3 calls currently can never happen at the same time normally, but IRQs can happen while the DebugStub is
|
||||
# running. We also need to make sure IRQs are allowed to run during DebugStub as DebugStub can wait for
|
||||
# a long time on commands.
|
||||
# So we need to disable interrupts immediately and set a flag, then reenable interrupts if they were enabled
|
||||
# when we disabled them. Later this can be replaced by some kind of critical section / lock around this code.
|
||||
# Currently IRQs are disabled - we need to fix DS before we can reenable them and add support for critical sections / locks here.
|
||||
# -http:#www.codemaestro.com/reviews/8
|
||||
# -http:#en.wikipedia.org/wiki/Spinlock - Uses a register which is a problem for us
|
||||
# -http:#wiki.osdev.org/Spinlock
|
||||
# -Looks good and also allows testing intead of waiting
|
||||
# -Wont require us to disable / enable IRQs
|
||||
|
||||
Group DebugStub
|
||||
|
||||
InterruptHandler TracerEntry {
|
||||
# This code is temporarily disabled as IRQs are not enabled right now.
|
||||
# LockOrExit
|
||||
|
||||
# EBP is restored by PopAll, but SendFrame uses it. Could
|
||||
# get it from the PushAll data, but this is easier.
|
||||
CallerEBP = EBP
|
||||
|
||||
# Could get ESP from PushAll but this is easier.
|
||||
# Also allows us to use the stack before PushAll if we ever need it.
|
||||
|
||||
# We cant modify any registers since we havent done PushAll yet
|
||||
# Maybe we could do a sub(4) on memory direct..
|
||||
# But for now we remove from ESP which the Int3 produces,
|
||||
# store ESP, then restore ESP so we don't cause stack corruption.
|
||||
# 12 bytes for EFLAGS, CS, EIP
|
||||
ESP + 12
|
||||
CallerESP = ESP
|
||||
ESP - 12
|
||||
|
||||
PushAll
|
||||
|
||||
# Temp Test
|
||||
EAX = $FF
|
||||
|
||||
# Save current ESP so we can look at the results of PushAll later
|
||||
PushAllPtr = ESP
|
||||
|
||||
# Get current ESP and add 32. This will skip over the PushAll and point
|
||||
# us at the call data from Int3.
|
||||
EBP = ESP
|
||||
EBP + 32
|
||||
|
||||
# Caller EIP
|
||||
EAX = [EBP]
|
||||
|
||||
# EIP is pointer to op after our call. Int3 is 1 byte so we subtract 1.
|
||||
# Note - when we used call it was 5 (size of our call + address)
|
||||
# so we get the EIP as IL2CPU records it. Its also useful for when we
|
||||
# wil be changing ops that call this stub.
|
||||
EAX - 1
|
||||
|
||||
# Store it for later use.
|
||||
CallerEIP = EAX
|
||||
|
||||
Call Executing
|
||||
|
||||
PopAll
|
||||
|
||||
# Temp disabled, see comment on LockOrExit above
|
||||
# Unlock
|
||||
}
|
||||
Loading…
Reference in a new issue