Rework PCI ata and serial drivers, program according to the progif byte
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "kprintf.h"
|
||||
|
||||
typedef union {
|
||||
uint32_t bits;
|
||||
@@ -17,6 +18,23 @@ typedef union {
|
||||
};
|
||||
} PciDev;
|
||||
|
||||
typedef struct {
|
||||
uint16_t iobase;
|
||||
} PciBarIo;
|
||||
|
||||
typedef struct {
|
||||
uint64_t addr;
|
||||
} PciBarMem;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
PciBarIo io;
|
||||
PciBarMem mem;
|
||||
} x;
|
||||
uint64_t size;
|
||||
uint32_t flags;
|
||||
} PciBar;
|
||||
|
||||
#define PCI_CFG_ADDR 0xCF8
|
||||
#define PCI_CFG_DATA 0xCFC
|
||||
|
||||
@@ -48,7 +66,10 @@ typedef union {
|
||||
#define PCI_DEV_PER_BUS 32
|
||||
#define PCI_FN_PER_DEV 32
|
||||
|
||||
#define PCI_BAR_IOBASE(bar) ((bar) & 0xFFFFFFFC)
|
||||
#define PCI_BAR_IO 0x01
|
||||
#define PCI_BAR_MEM32 0x02
|
||||
#define PCI_BAR_MEM64 0x04
|
||||
#define PCI_BAR_PREFETCH 0x08
|
||||
|
||||
uint32_t pci_read32(PciDev dev, uint32_t field);
|
||||
uint16_t pci_read16(PciDev dev, uint32_t field);
|
||||
@@ -56,6 +77,8 @@ uint8_t pci_read8(PciDev dev, uint32_t field);
|
||||
void pci_write32(PciDev dev, uint32_t field, uint32_t v);
|
||||
void pci_write16(PciDev dev, uint32_t field, uint16_t v);
|
||||
void pci_write8(PciDev dev, uint32_t field, uint8_t v);
|
||||
void pci_readbar(PciDev dev, uint32_t bar, uint32_t *addr, uint32_t *mask);
|
||||
void pci_getbar(PciDev dev, PciBar *bar, uint32_t barid);
|
||||
uint32_t pci_devtype(PciDev dev);
|
||||
uint32_t pci_scndrybus(PciDev dev);
|
||||
uint32_t pci_isend(PciDev dev);
|
||||
@@ -74,4 +97,13 @@ void pci_init(void);
|
||||
typedef void (*PciInitFn)(void);
|
||||
extern PciInitFn PCI_INIT_ARRAY[PCI_INIT_ARRAY_MAX];
|
||||
|
||||
#define PCI_LOG_BAR(tag_, bar_, num) \
|
||||
LOG("pci/"tag_, "BAR%d: type=%s flags=0x%08x,size=0x%016x,resource=0x%016x\n", \
|
||||
num, \
|
||||
(bar_).flags & PCI_BAR_IO ? "I/O" : ((bar_).flags & PCI_BAR_MEM32 ? "MEM32" : "MEM64"), \
|
||||
(bar_).flags, \
|
||||
(bar_).size, \
|
||||
(bar_).flags & PCI_BAR_IO ? (bar_).x.io.iobase : (bar_).x.mem.addr \
|
||||
);
|
||||
|
||||
#endif // PCI_PCI_H_
|
||||
|
||||
Reference in New Issue
Block a user