mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Move FIS creation into make_command
This commit is contained in:
@@ -204,7 +204,7 @@ port::stop_commands()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
port::make_command(size_t length)
|
port::make_command(size_t length, fis_register_h2d **fis)
|
||||||
{
|
{
|
||||||
int slot = -1;
|
int slot = -1;
|
||||||
uint32_t used_slots =
|
uint32_t used_slots =
|
||||||
@@ -238,10 +238,11 @@ port::make_command(size_t length)
|
|||||||
|
|
||||||
ent.flags = cmd_list_fis_size(sizeof(fis_register_h2d));
|
ent.flags = cmd_list_fis_size(sizeof(fis_register_h2d));
|
||||||
|
|
||||||
fis_register_h2d *fis = reinterpret_cast<fis_register_h2d *>(&cmdt.cmd_fis);
|
fis_register_h2d *cfis = reinterpret_cast<fis_register_h2d *>(&cmdt.cmd_fis);
|
||||||
kutil::memset(fis, 0, sizeof(fis_register_h2d));
|
kutil::memset(cfis, 0, sizeof(fis_register_h2d));
|
||||||
fis->type = fis_type::register_h2d;
|
cfis->type = fis_type::register_h2d;
|
||||||
fis->pm_port = 0x80; // set command register flag
|
cfis->pm_port = 0x80; // set command register flag
|
||||||
|
*fis = cfis;
|
||||||
|
|
||||||
size_t remaining = length;
|
size_t remaining = length;
|
||||||
for (int i = 0; i < max_prd_count; ++i) {
|
for (int i = 0; i < max_prd_count; ++i) {
|
||||||
@@ -272,13 +273,13 @@ port::make_command(size_t length)
|
|||||||
int
|
int
|
||||||
port::read_async(uint64_t offset, size_t length, void *dest)
|
port::read_async(uint64_t offset, size_t length, void *dest)
|
||||||
{
|
{
|
||||||
int slot = make_command(length);
|
fis_register_h2d *fis;
|
||||||
|
int slot = make_command(length, &fis);
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cmd_table &cmdt = m_cmd_table[slot];
|
cmd_table &cmdt = m_cmd_table[slot];
|
||||||
|
|
||||||
fis_register_h2d *fis = reinterpret_cast<fis_register_h2d *>(&cmdt.cmd_fis);
|
|
||||||
fis->command = ata_cmd::read_dma_ext;
|
fis->command = ata_cmd::read_dma_ext;
|
||||||
fis->device = 0x40; // ATA8-ACS p.175
|
fis->device = 0x40; // ATA8-ACS p.175
|
||||||
|
|
||||||
@@ -336,22 +337,18 @@ port::read(uint64_t offset, size_t length, void *dest)
|
|||||||
int
|
int
|
||||||
port::identify_async()
|
port::identify_async()
|
||||||
{
|
{
|
||||||
int slot = make_command(512);
|
fis_register_h2d *fis;
|
||||||
|
int slot = make_command(512, &fis);
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cmd_table &cmdt = m_cmd_table[slot];
|
|
||||||
|
|
||||||
fis_register_h2d *fis = reinterpret_cast<fis_register_h2d *>(&cmdt.cmd_fis);
|
|
||||||
kutil::memset(fis, 0, sizeof(fis_register_h2d));
|
|
||||||
fis->type = fis_type::register_h2d;
|
|
||||||
fis->pm_port = 0x80; // set command register flag
|
|
||||||
fis->command = ata_cmd::identify;
|
fis->command = ata_cmd::identify;
|
||||||
|
|
||||||
m_pending[slot].type = command_type::identify;
|
m_pending[slot].type = command_type::identify;
|
||||||
m_pending[slot].offset = 0;
|
m_pending[slot].offset = 0;
|
||||||
m_pending[slot].count = 0;
|
m_pending[slot].count = 0;
|
||||||
m_pending[slot].data = 0;
|
m_pending[slot].data = 0;
|
||||||
|
|
||||||
if(issue_command(slot))
|
if(issue_command(slot))
|
||||||
return slot;
|
return slot;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace ahci {
|
|||||||
|
|
||||||
struct cmd_list_entry;
|
struct cmd_list_entry;
|
||||||
struct cmd_table;
|
struct cmd_table;
|
||||||
|
struct fis_register_h2d;
|
||||||
class hba;
|
class hba;
|
||||||
enum class sata_signature : uint32_t;
|
enum class sata_signature : uint32_t;
|
||||||
enum class port_cmd : uint32_t;
|
enum class port_cmd : uint32_t;
|
||||||
@@ -92,8 +93,9 @@ private:
|
|||||||
|
|
||||||
/// Initialize a command structure
|
/// Initialize a command structure
|
||||||
/// \arg length The number of bytes of data needed in the PRDs
|
/// \arg length The number of bytes of data needed in the PRDs
|
||||||
|
/// \arg fis [out] The FIS for this command
|
||||||
/// \returns The index of the command slot, or -1 if none available
|
/// \returns The index of the command slot, or -1 if none available
|
||||||
int make_command(size_t length);
|
int make_command(size_t length, fis_register_h2d **fis);
|
||||||
|
|
||||||
/// Send a constructed command to the hardware
|
/// Send a constructed command to the hardware
|
||||||
/// \arg slot The index of the command slot used
|
/// \arg slot The index of the command slot used
|
||||||
|
|||||||
Reference in New Issue
Block a user