summaryrefslogtreecommitdiff
path: root/src/kernel/ata.h
blob: 28ef0de93ecc2eb38fe660f5b25149292457f9c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
enum {
  ATA_STATUS_BUSY        = 0x80,
  ATA_STATUS_DRIVE_READY = 0x40,
  ATA_STATUS_DRIVE_FAULT = 0x20,
  ATA_STATUS_SEEK_DONE   = 0x10,
  ATA_STATUS_DATA_READY  = 0x08,
  ATA_STATUS_CORRECTED   = 0x04,
  ATA_STATUS_INDEX       = 0x02,
  ATA_STATUS_ERROR       = 0x01
};

enum {
  ATA_ERROR_BAD_BLOCK      = 0x80,
  ATA_ERROR_UNCORRECTABLE  = 0x40,
  ATA_ERROR_MEDIA_SWAPPED  = 0x20,
  ATA_ERROR_NO_ID_MARK     = 0x10,
  ATA_ERROR_MEDIA_SWAPPING = 0x08,
  ATA_ERROR_ABORTED_CMD    = 0x04,
  ATA_ERROR_NO_TRACK_ZERO  = 0x02,
  ATA_ERROR_NO_ADDR_MARK   = 0x01
};

enum {
  ATA_CMD_READ      = 0x20,
  ATA_CMD_WRITE     = 0x30,
  ATA_CMD_WRITE_EXT = 0x34,
  ATA_CMD_READ_EXT  = 0x40,
  ATAPI_CMD         = 0xa0,
  ATAPI_CMD_ID      = 0xa1,
  ATA_CMD_FLUSH     = 0xe7,
  ATA_CMD_FLUSH_EXT = 0xea,
  ATA_CMD_ID        = 0xec,
};

enum {
  ATAPI_CMD_EJECT = 0x1b,
  ATAPI_CMD_READ  = 0xa8
};

enum {
  ATA_REG_DATA   = 0x0,
  ATA_REG_ERROR  = 0x1,
  ATA_REG_FEAT   = 0x1,
  ATA_REG_COUNT  = 0x2,
  ATA_REG_LBA0   = 0x3,
  ATA_REG_LBA1   = 0x4,
  ATA_REG_LBA2   = 0x5,
  ATA_REG_SELECT = 0x6,
  ATA_REG_CMD    = 0x7,
  ATA_REG_STATUS = 0x7,
};

enum {
  ATA_MASTER_SELECT = 0xa0,
  ATA_SLAVE_SELECT  = 0xb0
};

enum {
  ATA_SET_EXT = 0x04000000
};

enum {
  ATA_CAP_LBA = 0x00000200
};

enum {
  ATA_CONTROL_NO_IRQS = 0x02,
};

enum {
  PATA_TYPE_ID   = 0x0000,
  SATA_TYPE_ID   = 0xc33c,
  PATAPI_TYPE_ID = 0xeb14,
  SATAPI_TYPE_ID = 0x9669
};