git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: (ahci) support multiple AHCI controller
[lunaix-os.git]
/
lunaix-os
/
includes
/
hal
/
ahci
/
hba.h
diff --git
a/lunaix-os/includes/hal/ahci/hba.h
b/lunaix-os/includes/hal/ahci/hba.h
index e7f8d01f7cfe5f0d04d8c4ff63879f94ac31e682..287f868f4ae66e491f3168cd2b5127cfca233420 100644
(file)
--- a/
lunaix-os/includes/hal/ahci/hba.h
+++ b/
lunaix-os/includes/hal/ahci/hba.h
@@
-1,7
+1,9
@@
#ifndef __LUNAIX_HBA_H
#define __LUNAIX_HBA_H
#ifndef __LUNAIX_HBA_H
#define __LUNAIX_HBA_H
-#include <stdint.h>
+#include <lunaix/blkio.h>
+#include <lunaix/buffer.h>
+#include <lunaix/types.h>
#define HBA_RCAP 0
#define HBA_RGHC 1
#define HBA_RCAP 0
#define HBA_RGHC 1
@@
-31,7
+33,11
@@
#define HBA_PxCMD_FR (1 << 14)
#define HBA_PxCMD_ST (1)
#define HBA_PxINTR_DMA (1 << 2)
#define HBA_PxCMD_FR (1 << 14)
#define HBA_PxCMD_ST (1)
#define HBA_PxINTR_DMA (1 << 2)
-#define HBA_PxINTR_D2HR (1)
+#define HBA_PxINTR_DHR (1)
+#define HBA_PxINTR_DPS (1 << 5)
+#define HBA_PxINTR_TFEE (1 << 30)
+#define HBA_PxINTR_OFE (1 << 24)
+#define HBA_PxINTR_IFE (1 << 27)
#define HBA_PxTFD_ERR (1)
#define HBA_PxTFD_BSY (1 << 7)
#define HBA_PxTFD_DRQ (1 << 3)
#define HBA_PxTFD_ERR (1)
#define HBA_PxTFD_BSY (1 << 7)
#define HBA_PxTFD_DRQ (1 << 3)
@@
-44,6
+50,8
@@
#define HBA_RPxSSTS_IF(x) (((x) >> 4) & 0xf)
#define HBA_RPxSSTS_PHYSTATE(x) ((x)&0xf)
#define HBA_RPxSSTS_IF(x) (((x) >> 4) & 0xf)
#define HBA_RPxSSTS_PHYSTATE(x) ((x)&0xf)
+#define hba_clear_reg(reg) (reg) = -1
+
#define HBA_DEV_SIG_ATAPI 0xeb140101
#define HBA_DEV_SIG_ATA 0x00000101
#define HBA_DEV_SIG_ATAPI 0xeb140101
#define HBA_DEV_SIG_ATA 0x00000101
@@
-59,6
+67,8
@@
typedef unsigned int hba_reg_t;
#define HBA_CMDH_CLR_BUSY (1 << 10)
#define HBA_CMDH_PRDT_LEN(entries) (((entries)&0xffff) << 16)
#define HBA_CMDH_CLR_BUSY (1 << 10)
#define HBA_CMDH_PRDT_LEN(entries) (((entries)&0xffff) << 16)
+#define HBA_MAX_PRDTE 4
+
struct hba_cmdh
{
uint16_t options;
struct hba_cmdh
{
uint16_t options;
@@
-82,13
+92,14
@@
struct hba_cmdt
uint8_t command_fis[64];
uint8_t atapi_cmd[16];
uint8_t reserved[0x30];
uint8_t command_fis[64];
uint8_t atapi_cmd[16];
uint8_t reserved[0x30];
- struct hba_prdte entries[
3
];
+ struct hba_prdte entries[
HBA_MAX_PRDTE
];
} __HBA_PACKED__;
#define HBA_DEV_FEXTLBA 1
#define HBA_DEV_FATAPI (1 << 1)
struct hba_port;
} __HBA_PACKED__;
#define HBA_DEV_FEXTLBA 1
#define HBA_DEV_FATAPI (1 << 1)
struct hba_port;
+struct ahci_hba;
struct hba_device
{
struct hba_device
{
@@
-99,33
+110,47
@@
struct hba_device
uint32_t block_size;
uint64_t wwn;
uint8_t cbd_size;
uint32_t block_size;
uint64_t wwn;
uint8_t cbd_size;
- uint8_t last_error;
- uint8_t last_status;
+ struct
+ {
+ uint8_t sense_key;
+ uint8_t error;
+ uint8_t status;
+ uint8_t reserve;
+ } last_result;
uint32_t alignment_offset;
uint32_t block_per_sec;
uint32_t capabilities;
uint32_t alignment_offset;
uint32_t block_per_sec;
uint32_t capabilities;
+ struct hba_port* port;
+ struct ahci_hba* hba;
struct
{
struct
{
- int (*identify)(struct hba_port* port);
- int (*read_buffer)(struct hba_port* port,
- uint64_t lba,
- void* buffer,
- uint32_t size);
- int (*write_buffer)(struct hba_port* port,
- uint64_t lba,
- void* buffer,
- uint32_t size);
+ int (*identify)(struct hba_device* dev);
+ void (*submit)(struct hba_device* dev, struct blkio_req* io_req);
} ops;
};
} ops;
};
+struct hba_cmd_state
+{
+ struct hba_cmdt* cmd_table;
+ void* state_ctx;
+};
+
+struct hba_cmd_context
+{
+ struct hba_cmd_state* issued[32];
+ u32_t tracked_ci;
+};
+
struct hba_port
{
volatile hba_reg_t* regs;
unsigned int ssts;
struct hba_cmdh* cmdlst;
struct hba_port
{
volatile hba_reg_t* regs;
unsigned int ssts;
struct hba_cmdh* cmdlst;
+ struct hba_cmd_context cmdctx;
void* fis;
struct hba_device* device;
void* fis;
struct hba_device* device;
+ struct ahci_hba* hba;
};
struct ahci_hba
};
struct ahci_hba
@@
-141,8
+166,14
@@
struct ahci_hba
int
hba_prepare_cmd(struct hba_port* port,
struct hba_cmdt** cmdt,
int
hba_prepare_cmd(struct hba_port* port,
struct hba_cmdt** cmdt,
- struct hba_cmdh** cmdh,
- void* buffer,
- unsigned int size);
+ struct hba_cmdh** cmdh);
+
+int
+hba_bind_vbuf(struct hba_cmdh* cmdh,
+ struct hba_cmdt* cmdt,
+ struct vecbuf* vbuf);
+
+int
+hba_bind_sbuf(struct hba_cmdh* cmdh, struct hba_cmdt* cmdt, struct membuf mbuf);
#endif /* __LUNAIX_HBA_H */
#endif /* __LUNAIX_HBA_H */