Backport more old code
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
struct ahci_registers;
|
||||
struct pci_device;
|
||||
|
||||
struct ahci_fis_reg_h2d {
|
||||
uint8_t type;
|
||||
uint8_t cmd_port;
|
||||
uint8_t cmd;
|
||||
uint8_t feature_low;
|
||||
uint8_t lba0;
|
||||
uint8_t lba1;
|
||||
uint8_t lba2;
|
||||
uint8_t device;
|
||||
|
||||
uint8_t lba3;
|
||||
uint8_t lba4;
|
||||
uint8_t lba5;
|
||||
uint8_t feature_high;
|
||||
|
||||
uint16_t count;
|
||||
uint8_t icc;
|
||||
uint8_t control;
|
||||
|
||||
uint32_t __res0;
|
||||
};
|
||||
|
||||
struct ahci_controller {
|
||||
struct pci_device *pci_dev;
|
||||
uintptr_t abar_phys;
|
||||
struct ahci_registers *regs;
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#define ATA_CMD_IDENTIFY 0xEC
|
||||
#define ATA_CMD_PACKET 0xA0
|
||||
#define ATA_CMD_READ_DMA_EX 0x25
|
||||
#define ATA_CMD_WRITE_DMA_EX 0x35
|
||||
|
||||
#define ATA_CMD_PACKET_IDENTIFY 0xA1
|
||||
#define ATAPI_CMD_READ_SECTORS 0xA8
|
||||
|
||||
#define ATA_SR_BUSY (1 << 7)
|
||||
#define ATA_SR_DRQ (1 << 3)
|
||||
|
||||
// Response to ATA_CMD_IDENTIFY
|
||||
#define ATA_IDENT_DEVICE_TYPE 0x00
|
||||
#define ATA_IDENT_SERIAL 0x14
|
||||
#define ATA_IDENT_MODEL 0x36
|
||||
#define ATA_IDENT_CAPS 0x62
|
||||
#define ATA_IDENT_MAX_LBA 0x78
|
||||
#define ATA_IDENT_CMD_SETS 0xA4
|
||||
#define ATA_IDENT_MAX_LBAEXT 0xC8
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "sys/amd64/hw/irq.h"
|
||||
#include "sys/types.h"
|
||||
|
||||
#define PCI_PORT_CONFIG_ADDR 0xCF8
|
||||
#define PCI_PORT_CONFIG_DATA 0xCFC
|
||||
|
||||
#define PCI_CONFIG_ID 0x00
|
||||
#define PCI_CONFIG_CMD 0x04
|
||||
#define PCI_CONFIG_CLASS 0x08
|
||||
#define PCI_CONFIG_INFO 0x0C
|
||||
#define PCI_CONFIG_BAR(n) (0x10 + (n) * 4)
|
||||
#define PCI_CONFIG_SUBSYSTEM 0x2C
|
||||
#define PCI_CONFIG_CAPABILITIES 0x34
|
||||
#define PCI_CONFIG_IRQ 0x3C
|
||||
|
||||
#define PCI_CONFIG_BRIDGE 0x18
|
||||
|
||||
#define PCI_ID(vnd, dev) (((uint32_t) (vnd)) | ((uint32_t) (dev) << 16))
|
||||
|
||||
struct pci_device;
|
||||
typedef void (*pci_driver_func_t)(struct pci_device *dev);
|
||||
|
||||
void pci_init(void);
|
||||
void pci_add_root_bus(uint8_t n);
|
||||
|
||||
uint32_t pci_config_read_dword(struct pci_device *dev, uint16_t off);
|
||||
void pci_add_irq(struct pci_device *dev, irq_handler_func_t handler, void *ctx);
|
||||
|
||||
void pci_add_class_driver(uint32_t full_class, pci_driver_func_t func);
|
||||
|
||||
// pcidb.c
|
||||
const char *pci_class_string(uint16_t full_class);
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include "sys/amd64/hw/pci/pci.h"
|
||||
|
||||
//void pci_usb_uhci_init(pci_addr_t addr);
|
||||
Reference in New Issue
Block a user