block.cc (11793:ef606668d247) block.cc (14239:73109c2181d3)
1/*
2 * Copyright (c) 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 57 unchanged lines hidden (view full) ---

66
67 readConfigBlob(pkt, cfgOffset, (uint8_t *)&cfg_out);
68}
69
70VirtIOBlock::Status
71VirtIOBlock::read(const BlkRequest &req, VirtDescriptor *desc_chain,
72 size_t off_data, size_t size)
73{
1/*
2 * Copyright (c) 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 57 unchanged lines hidden (view full) ---

66
67 readConfigBlob(pkt, cfgOffset, (uint8_t *)&cfg_out);
68}
69
70VirtIOBlock::Status
71VirtIOBlock::read(const BlkRequest &req, VirtDescriptor *desc_chain,
72 size_t off_data, size_t size)
73{
74 uint8_t data[size];
74 std::vector<uint8_t> data(size);
75 uint64_t sector(req.sector);
76
77 DPRINTF(VIOBlock, "Read request starting @ sector %i (size: %i)\n",
78 sector, size);
79
80 if (size % SectorSize != 0)
81 panic("Unexpected request/sector size relationship\n");
82
83 for (Addr offset = 0; offset < size; offset += SectorSize) {
75 uint64_t sector(req.sector);
76
77 DPRINTF(VIOBlock, "Read request starting @ sector %i (size: %i)\n",
78 sector, size);
79
80 if (size % SectorSize != 0)
81 panic("Unexpected request/sector size relationship\n");
82
83 for (Addr offset = 0; offset < size; offset += SectorSize) {
84 if (image.read(data + offset, sector) != SectorSize) {
84 if (image.read(&data[offset], sector) != SectorSize) {
85 warn("Failed to read sector %i\n", sector);
86 return S_IOERR;
87 }
88 ++sector;
89 }
90
85 warn("Failed to read sector %i\n", sector);
86 return S_IOERR;
87 }
88 ++sector;
89 }
90
91 desc_chain->chainWrite(off_data, data, size);
91 desc_chain->chainWrite(off_data, &data[0], size);
92
93 return S_OK;
94}
95
96VirtIOBlock::Status
97VirtIOBlock::write(const BlkRequest &req, VirtDescriptor *desc_chain,
98 size_t off_data, size_t size)
99{
92
93 return S_OK;
94}
95
96VirtIOBlock::Status
97VirtIOBlock::write(const BlkRequest &req, VirtDescriptor *desc_chain,
98 size_t off_data, size_t size)
99{
100 uint8_t data[size];
100 std::vector<uint8_t> data(size);
101 uint64_t sector(req.sector);
102
103 DPRINTF(VIOBlock, "Write request starting @ sector %i (size: %i)\n",
104 sector, size);
105
106 if (size % SectorSize != 0)
107 panic("Unexpected request/sector size relationship\n");
108
109
101 uint64_t sector(req.sector);
102
103 DPRINTF(VIOBlock, "Write request starting @ sector %i (size: %i)\n",
104 sector, size);
105
106 if (size % SectorSize != 0)
107 panic("Unexpected request/sector size relationship\n");
108
109
110 desc_chain->chainRead(off_data, data, size);
110 desc_chain->chainRead(off_data, &data[0], size);
111
112 for (Addr offset = 0; offset < size; offset += SectorSize) {
111
112 for (Addr offset = 0; offset < size; offset += SectorSize) {
113 if (image.write(data + offset, sector) != SectorSize) {
113 if (image.write(&data[offset], sector) != SectorSize) {
114 warn("Failed to write sector %i\n", sector);
115 return S_IOERR;
116 }
117 ++sector;
118 }
119
120 return S_OK;
121

--- 52 unchanged lines hidden ---
114 warn("Failed to write sector %i\n", sector);
115 return S_IOERR;
116 }
117 ++sector;
118 }
119
120 return S_OK;
121

--- 52 unchanged lines hidden ---