layout = [
("type", 8),
("pm_port", 4),
- ("a", 1),
("c", 1),
- ("d", 1),
- ("i", 1),
("command", 8),
("features", 16),
("lba", 48),
("count", 16),
("icc", 8),
("control", 8),
- ("dma_buffer_id", 64),
- ("dma_buffer_offset", 32),
- ("dma_transfer_count", 32),
("data", dw)
]
return EndpointDescription(layout, packetized=True)
layout = [
("type", 8),
("pm_port", 4),
- ("a", 1),
- ("d", 1),
("i", 1),
("status", 8),
("error", 8),
("lba", 48),
("device", 8),
("count", 16),
- ("e_status", 8),
- ("transfer_count", 16),
- ("dma_buffer_id", 64),
- ("dma_buffer_offset", 32),
- ("dma_transfer_count", 32),
+ ("data", dw)
+ ]
+ return EndpointDescription(layout, packetized=True)
+
+def command_tx_layout(dw):
+ layout = [
+ ("write", 1),
+ ("read", 1),
+ ("address", 32),
+ ("length", 32),
+ ("data", dw)
+ ]
+ return EndpointDescription(layout, packetized=True)
+
+def command_rx_layout(dw):
+ layout = [
+ ("write", 1),
+ ("read", 1),
+ ("success", 1),
+ ("failed", 1),
("data", dw)
]
return EndpointDescription(layout, packetized=True)
r += FIS.__repr__(self)
return r
-class FIS_DMA_SETUP(FIS):
- def __init__(self, packet=[0]*fis_dma_setup_cmd_len):
- FIS.__init__(self, packet,fis_dma_setup_layout)
-
- def __repr__(self):
- r = "FIS_DMA_SETUP\n"
- r += FIS.__repr__(self)
- return r
-
class FIS_DATA(FIS):
def __init__(self, packet=[0]):
FIS.__init__(self, packet,fis_data_layout)
r += "%08x\n" %data
return r
-class FIS_PIO_SETUP_D2H(FIS):
- def __init__(self, packet=[0]*fis_pio_setup_d2h_cmd_len):
- FIS.__init__(self, packet,fis_pio_setup_d2h_layout)
-
- def __repr__(self):
- r = "FIS_PIO_SETUP\n"
- r += FIS.__repr__(self)
- return r
-
class FIS_UNKNOWN(FIS):
def __init__(self, packet=[0]):
FIS.__init__(self, packet, {})
fis = FIS_REG_D2H(packet)
elif fis_type == fis_types["DMA_ACTIVATE_D2H"]:
fis = FIS_DMA_ACTIVATE_D2H(packet)
- elif fis_type == fis_types["DMA_SETUP"]:
- fis = FIS_DMA_SETUP(packet)
elif fis_type == fis_types["DATA"]:
fis = FIS_DATA(packet)
- elif fis_type == fis_types["PIO_SETUP_D2H"]:
- fis = FIS_PIO_SETUP_D2H(packet)
else:
fis = FIS_UNKNOWN(packet)
if self.debug:
selfp.transport.sink.type = fis_types["REG_H2D"]
selfp.transport.sink.lba = 0x0123456789
yield
- while selfp.transport.sink.ack == 0:
- yield
- selfp.transport.sink.stb = 1
- selfp.transport.sink.sop = 1
- selfp.transport.sink.eop = 1
- selfp.transport.sink.type = fis_types["DMA_SETUP"]
- selfp.transport.sink.dma_buffer_id = 0x0123456789ABCDEF
- yield
while selfp.transport.sink.ack == 0:
yield
###
- cmd_ndwords = max(fis_reg_h2d_cmd_len, fis_dma_setup_cmd_len, fis_data_cmd_len)
+ cmd_ndwords = max(fis_reg_h2d_cmd_len, fis_data_cmd_len)
encoded_cmd = Signal(cmd_ndwords*32)
cnt = Signal(max=cmd_ndwords+1)
If(sink.stb & sink.sop,
If(test_type("REG_H2D"),
NextState("SEND_REG_H2D_CMD")
- ).Elif(test_type("DMA_SETUP"),
- NextState("SEND_DMA_SETUP_CMD")
).Elif(test_type("DATA"),
NextState("SEND_DATA_CMD")
).Else(
NextState("IDLE")
)
)
- fsm.act("SEND_DMA_SETUP_CMD",
- _encode_cmd(sink, fis_dma_setup_layout, encoded_cmd),
- cmd_len.eq(fis_dma_setup_cmd_len),
- cmd_send.eq(1),
- If(cmd_done,
- sink.ack.eq(1),
- NextState("IDLE")
- )
- )
fsm.act("SEND_DATA_CMD",
_encode_cmd(sink, fis_data_layout, encoded_cmd),
cmd_len.eq(fis_data_cmd_len),
###
- cmd_ndwords = max(fis_reg_d2h_cmd_len, fis_dma_activate_d2h_cmd_len, fis_dma_setup_cmd_len,
- fis_data_cmd_len, fis_pio_setup_d2h_cmd_len)
+ cmd_ndwords = max(fis_reg_d2h_cmd_len, fis_dma_activate_d2h_cmd_len, fis_data_cmd_len)
encoded_cmd = Signal(cmd_ndwords*32)
cnt = Signal(max=cmd_ndwords+1)
NextState("RECEIVE_REG_D2H_CMD")
).Elif(test_type("DMA_ACTIVATE_D2H"),
NextState("RECEIVE_DMA_ACTIVATE_D2H_CMD")
- ).Elif(test_type("DMA_SETUP"),
- NextState("RECEIVE_DMA_SETUP_CMD"),
).Elif(test_type("DATA"),
NextState("RECEIVE_DATA_CMD"),
- ).Elif(test_type("PIO_SETUP_D2H"),
- NextState("RECEIVE_PIO_SETUP_D2H_CMD"),
).Else(
# XXX: Better to ack?
link.source.ack.eq(1)
NextState("IDLE")
)
)
- fsm.act("RECEIVE_DMA_SETUP_CMD",
- cmd_len.eq(fis_dma_setup_cmd_len),
- cmd_receive.eq(1),
- If(cmd_done,
- NextState("PRESENT_DMA_SETUP_CMD")
- )
- )
- fsm.act("PRESENT_DMA_SETUP_CMD",
- source.stb.eq(1),
- _decode_cmd(encoded_cmd, fis_pio_setup_d2h_layout, source),
- If(source.ack,
- NextState("IDLE")
- )
- )
fsm.act("RECEIVE_DATA_CMD",
cmd_len.eq(fis_data_cmd_len),
cmd_receive.eq(1),
_decode_cmd(encoded_cmd, fis_data_layout, source),
source.sop.eq(0), # XXX
source.eop.eq(link.source.eop),
- source.d.eq(link.source.d),
+ source.data.eq(link.source.d),
If(source.stb & source.eop & source.ack,
NextState("IDLE")
)
)
- fsm.act("RECEIVE_PIO_SETUP_D2H_CMD",
- cmd_len.eq(fis_pio_setup_d2h_cmd_len),
- cmd_receive.eq(1),
- If(cmd_done,
- NextState("PRESENT_PIO_SETUP_D2H_CMD")
- )
- )
- fsm.act("PRESENT_PIO_SETUP_D2H_CMD",
- source.stb.eq(1),
- _decode_cmd(encoded_cmd, fis_pio_setup_d2h_layout, source),
- If(source.ack,
- NextState("IDLE")
- )
- )
cmd_cases = {}
for i in range(cmd_ndwords):
"REG_H2D": 0x27,
"REG_D2H": 0x34,
"DMA_ACTIVATE_D2H": 0x39,
- "DMA_SETUP": 0x41,
- "DATA": 0x46,
- "PIO_SETUP_D2H": 0x5F
+ "DATA": 0x46
}
class FISField():
"pm_port": FISField(0, 8, 4)
}
-fis_dma_setup_cmd_len = 7
-fis_dma_setup_layout = {
- "type": FISField(0, 0, 8),
- "pm_port": FISField(0, 8, 4),
- "d": FISField(0, 13, 1),
- "i": FISField(0, 14, 1),
- "a": FISField(0, 15, 1),
-
- "dma_buffer_id_lsb": FISField(1, 0, 32),
-
- "dma_buffer_id_msb": FISField(2, 0, 32),
-
- "dma_buffer_offset": FISField(4, 0, 32),
-
- "dma_transfer_count": FISField(4, 0, 32)
-}
-
fis_data_cmd_len = 1
fis_data_layout = {
"type": FISField(0, 0, 8)
}
-
-fis_pio_setup_d2h_cmd_len = 5
-fis_pio_setup_d2h_layout = {
- "type": FISField(0, 0, 8),
- "pm_port": FISField(0, 8, 4),
- "d": FISField(0, 13, 1),
- "i": FISField(0, 14, 1),
- "status": FISField(0, 16, 8),
- "error": FISField(0, 24, 8),
-
- "lba_lsb": FISField(1, 0, 24),
- "device": FISField(1, 24, 8),
-
- "lba_msb": FISField(2, 0, 24),
-
- "count": FISField(3, 0, 16),
- "e_status": FISField(3, 24, 8),
-
- "transfer_count": FISField(4, 0, 16)
-}