bfm: fix HDD read_dma_cmd, identify_dma_cmd and clean up

This commit is contained in:
Florent Kermarrec 2014-12-14 13:14:32 +01:00
parent 623a3883c6
commit f01a8934f2
1 changed files with 12 additions and 8 deletions

View File

@ -418,10 +418,14 @@ class HDD(Module):
return FIS_DMA_ACTIVATE_D2H()
def read_dma_cmd(self, fis):
return FIS_DATA(self.read_mem(fis.lba_lsb, fis.count*4))
packet = self.read_mem(fis.lba_lsb, fis.count*4)
packet.insert(0, 0)
return FIS_DATA(packet)
def identify_dma_cmd(self, fis):
return FIS_DATA([i for i in range(256)])
packet = [i for i in range(256)]
packet.insert(0, 0)
return FIS_DATA(packet)
def data_cmd(self, fis):
self.write_mem(self.wr_address, fis.packet[1:])
@ -431,13 +435,13 @@ class HDD(Module):
self.mem = HDDMemRegion(base, length)
def write_mem(self, adr, data):
# XXX test if adr allocate in one memory region
# XXX test if adr allocated in one memory region
current_adr = (adr-self.mem.base)//4
for i in range(len(data)):
self.mem.data[current_adr+i] = data[i]
def read_mem(self, adr, length=1):
# XXX test if adr allocate in one memory region
# XXX test if adr allocated in one memory region
current_adr = (adr-self.mem.base)//4
data = []
for i in range(length//4):