Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
set dynamic size for the requested packet type
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKarvandi committed Apr 16, 2024
1 parent 0524080 commit 32dc4d7
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @copyright
* This project is released under the GNU Public License v3.
*/
package hwdbg.interpreter
package hwdbg.communication

import chisel3._
import chisel3.util.{switch, is}
Expand Down Expand Up @@ -67,7 +67,9 @@ class DebuggerPacketInterpreter(
//
val interpretationDone = Output(Bool()) // interpretation done or not?
val foundValidPacket = Output(Bool()) // packet was valid or not
val requestedActionOfThePacket = Output(UInt(32.W)) // the requested action
val requestedActionOfThePacket = Output(
UInt(new DebuggerRemotePacket().getWidth.W)
) // the requested action

})

Expand Down Expand Up @@ -301,7 +303,9 @@ object DebuggerPacketInterpreter {
val rdWrAddr = Wire(UInt(bramAddrWidth.W))
val interpretationDone = Wire(Bool())
val foundValidPacket = Wire(Bool())
val requestedActionOfThePacket = Wire(UInt(32.W))
val requestedActionOfThePacket = Wire(
UInt(new DebuggerRemotePacket().getWidth.W)
)

//
// Configure the input signals
Expand Down
77 changes: 77 additions & 0 deletions src/main/scala/hwdbg/communication/sender.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/** @file
* sender.scala
* @author
* Sina Karvandi ([email protected])
* @brief
* Remote debugger packet sender module
* @details
* @version 0.1
* @date
* 2024-04-16
*
* @copyright
* This project is released under the GNU Public License v3.
*/
package hwdbg.communication

import chisel3._
import chisel3.util.{switch, is}
import circt.stage.ChiselStage

import hwdbg.configs._
import hwdbg.types._
import hwdbg.utils._
import hwdbg.constants._

object DebuggerPacketSenderEnums {
object State extends ChiselEnum {
val sIdle, sInit, sDone = Value
}
}

class DebuggerPacketSender(
debug: Boolean = DebuggerConfigurations.ENABLE_DEBUG,
bramAddrWidth: Int = DebuggerConfigurations.BLOCK_RAM_ADDR_WIDTH,
bramDataWidth: Int = DebuggerConfigurations.BLOCK_RAM_DATA_WIDTH
) extends Module {

//
// Import state enum
//
import DebuggerPacketSenderEnums.State
import DebuggerPacketSenderEnums.State._

val io = IO(new Bundle {

//
// Chip signals
//
val en = Input(Bool()) // chip enable signal

//
// Interrupt signals (lines)
// Note: Only PS output signal is exported here,
// a separate module will control the PL signal
//
val psOutInterrupt = Output(Bool()) // PL to PS interrupt

//
// BRAM (Block RAM) ports
//
val rdWrAddr = Output(UInt(bramAddrWidth.W)) // read/write address
val wrEna = Output(Bool()) // enable writing
val wrData = Output(UInt(bramDataWidth.W)) // write data

//
// Sending signals
//
val sendingSignalDone = Output(Bool()) // sending signal done or not?
val foundValidPacket = Output(Bool()) // packet was valid or not
val requestedActionOfThePacket =
Output(
UInt(new DebuggerRemotePacket().getWidth.W)
) // the requested action

})

}
33 changes: 33 additions & 0 deletions src/main/scala/hwdbg/configs/constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,36 @@ object HyperDbgSharedConstants {
0x4859504552444247L // HYPERDBG = 0x4859504552444247

}

/** @brief
* Enumeration for different packet types in HyperDbg packets
* @warning
* Used in HyperDbg
*/
object DEBUGGER_REMOTE_PACKET_TYPE extends Enumeration {

//
// Debugger to debuggee (vmx-root)
//
val DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_VMX_ROOT = Value(1)

//
// Debugger to debuggee (user-mode)
//
val DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_USER_MODE = Value(2)

//
// Debuggee to debugger (user-mode and kernel-mode, vmx-root mode)
//
val DEBUGGEE_TO_DEBUGGER = Value(3)

//
// Debugger to debuggee (hardware), used in hwdbg
//
val DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL = Value(4)

//
// Debuggee to debugger (hardware), used in hwdbg
//
val DEBUGGEE_TO_DEBUGGER_HARDWARE_LEVEL = Value(5)
}
2 changes: 1 addition & 1 deletion src/main/scala/hwdbg/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import chisel3._
import circt.stage.ChiselStage

import hwdbg.configs._
import hwdbg.interpreter._
import hwdbg.communication._

class DebuggerMain(
debug: Boolean = DebuggerConfigurations.ENABLE_DEBUG,
Expand Down

0 comments on commit 32dc4d7

Please sign in to comment.