1 /* 2 * Copyright 2008, Marcus Overhagen. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SATA_REQUEST_H 6 #define _SATA_REQUEST_H 7 8 #include "ahci_defs.h" 9 10 class sata_request 11 { 12 public: 13 sata_request(); 14 sata_request(scsi_ccb *ccb); 15 ~sata_request(); 16 17 void set_data(void *data, size_t dataSize); 18 19 void set_ata_cmd(uint8 command); 20 void set_ata28_cmd(uint8 command, uint32 lba, uint8 sectorCount); 21 void set_ata48_cmd(uint8 command, uint64 lba, uint16 sectorCount); 22 23 void set_atapi_cmd(); 24 bool is_atapi(); 25 26 scsi_ccb * ccb(); 27 const void * fis(); 28 void * data(); 29 int size(); 30 void finish(int tfd, size_t bytesTransfered); 31 void abort(); 32 33 void wait_for_completition(); 34 int completition_status(); 35 36 private: 37 scsi_ccb * fCcb; 38 uint8 fFis[20]; 39 bool fIsATAPI; 40 sem_id fCompletionSem; 41 int fCompletionStatus; 42 void * fData; 43 size_t fDataSize; 44 }; 45 46 47 inline scsi_ccb * 48 sata_request::ccb() 49 { 50 return fCcb; 51 } 52 53 54 inline const void * 55 sata_request::fis() 56 { 57 return fFis; 58 } 59 60 61 inline bool 62 sata_request::is_atapi() 63 { 64 return fIsATAPI; 65 } 66 67 68 inline void * 69 sata_request::data() 70 { 71 return fData; 72 } 73 74 75 inline int 76 sata_request::size() 77 { 78 return fDataSize; 79 } 80 81 82 #endif 83