pci: add simple pci driver
this driver only prints devices on the pci bus.
This commit is contained in:
parent
2c9e239c65
commit
605507a688
7 changed files with 113 additions and 32 deletions
13
include/dev/pci.h
Normal file
13
include/dev/pci.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _PCI_H_
|
||||
#define _PCI_H_
|
||||
|
||||
#include <kernel/common.h>
|
||||
|
||||
#define PCIPM_CONFIG_ADDRESS 0xCF8
|
||||
#define PCIPM_CONFIG_DATA 0xCFC
|
||||
|
||||
void pci_init();
|
||||
uint16_t pci_config_read_word(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
|
||||
#endif /* _PCI_H_ */
|
||||
|
|
@ -4,21 +4,16 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t val)
|
||||
{
|
||||
__asm__ volatile("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
#define genio(suffix, type) \
|
||||
void out##suffix(uint16_t port, type value); \
|
||||
type in##suffix(uint16_t port);
|
||||
|
||||
static inline uint8_t inb(uint16_t port)
|
||||
{
|
||||
uint8_t ret;
|
||||
__asm__ volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
genio(b, uint8_t);
|
||||
genio(w, uint16_t);
|
||||
genio(l, uint32_t);
|
||||
|
||||
static inline void iowait()
|
||||
{
|
||||
outb(0x80, 0);
|
||||
}
|
||||
#undef genio
|
||||
|
||||
void iowait();
|
||||
|
||||
#endif /* _PIO_H_ */
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
#ifndef _STDIO_H_
|
||||
#define _STDIO_H_
|
||||
|
||||
#define COL_RED_BLACK "\e[31;40m"
|
||||
#define COL_YELLOW_BLACK "\e[33;40m"
|
||||
#define COL_GREEN_BLACK "\e[32;40m"
|
||||
#define COL_MAGENTA_BLACK "\e[35;40m"
|
||||
#define COL_RED_BLACK "\e[31m"
|
||||
#define COL_YELLOW_BLACK "\e[33m"
|
||||
#define COL_GREEN_BLACK "\e[32m"
|
||||
#define COL_MAGENTA_BLACK "\e[35m"
|
||||
|
||||
#define COL_RESET "\e[m"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue