Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
716 lvd 1
#pragma once
2
const int MAX_PHYS_HD_DRIVES = 8;
3
const int MAX_PHYS_CD_DRIVES = 8;
4
const int MAX_SENSE_LEN = 0x40;
5
 
6
enum DEVTYPE { ATA_NONE, ATA_FILEHDD, ATA_NTHDD, ATA_SPTI_CD, ATA_ASPI_CD, ATA_FILECD };
7
enum DEVUSAGE { ATA_OP_ENUM_ONLY, ATA_OP_USE };
8
 
9
struct PHYS_DEVICE
10
{
11
   DEVTYPE type;
12
   DEVUSAGE usage;
13
   unsigned hdd_size;
14
   unsigned spti_id;
15
   unsigned adapterid, targetid; // ASPI
16
   unsigned char idsector[512];
17
   char filename[512];
18
   char viewname[512];
19
};
20
 
21
struct ATA_PASSER
22
{
23
   HANDLE hDevice;
24
   PHYS_DEVICE *dev;
25
   HANDLE Vols[100];
26
 
27
   static unsigned identify(PHYS_DEVICE *outlist, int max);
28
   static unsigned get_hdd_count();
29
 
30
   DWORD open(PHYS_DEVICE *dev);
31
   void close();
32
   bool loaded() { return (hDevice != INVALID_HANDLE_VALUE); }
33
   BOOL flush() { return FlushFileBuffers(hDevice); }
34
   bool seek(u64 nsector);
35
   bool read_sector(unsigned char *dst);
36
   bool write_sector(unsigned char *src);
37
 
38
   ATA_PASSER() { hDevice = INVALID_HANDLE_VALUE; }
39
   ~ATA_PASSER() { close(); }
40
};
41
 
42
struct ATAPI_PASSER
43
{
44
   HANDLE hDevice;
45
   PHYS_DEVICE *dev;
46
 
47
   CDB cdb;
48
   unsigned passed_length;
49
   unsigned char sense[MAX_SENSE_LEN]; unsigned senselen;
50
 
51
   static unsigned identify(PHYS_DEVICE *outlist, int max);
52
 
53
   DWORD open(PHYS_DEVICE *dev);
54
   void close();
55
//   bool loaded() { return (hDevice != INVALID_HANDLE_VALUE) || (dev->type == ATA_ASPI_CD); } //SMT (crashes if no master or slave device)
56
//   bool loaded() { return ((hDevice == INVALID_HANDLE_VALUE)?0:(dev->type == ATA_ASPI_CD)); } //Alone Coder (CD doesn't work with ==, !=, 1)
57
//   bool loaded() { return (hDevice != INVALID_HANDLE_VALUE) || ((dev)?(dev->type == ATA_ASPI_CD):0); } //Alone Coder (CD doesn't work if another device isn't set) (and SPTI won't work?)
58
//   bool loaded() { return (hDevice != INVALID_HANDLE_VALUE); } //Alone Coder (CD doesn't work)
59
   bool loaded() { return ((hDevice != INVALID_HANDLE_VALUE) || (dev)); } //Alone Coder (CD doesn't initialize (although works) if another device isn't set)
60
 
61
   int pass_through(void *buf, int bufsize);
62
   int read_atapi_id(unsigned char *idsector, char prefix);
63
 
64
   int SEND_ASPI_CMD(void *buf, int buf_sz);
65
   int SEND_SPTI_CMD(void *buf, int buf_sz);
66
 
67
   bool seek(unsigned nsector);
68
   bool read_sector(unsigned char *dst);
69
 
70
   ATAPI_PASSER() { hDevice = INVALID_HANDLE_VALUE; dev = 0; }
71
   ~ATAPI_PASSER() { close(); }
72
};
73
 
74
void make_ata_string(unsigned char *dst, unsigned n_words, const char *src);
75
void swap_bytes(char *dst, BYTE *src, unsigned n_words);
76
void print_device_name(char *dst, PHYS_DEVICE *dev);
77
void init_aspi();
78
void done_aspi();
79
 
80
// #define DUMP_HDD_IO