Browse Source

wip pcie

master
Mathieu Serandour 1 year ago
parent
commit
48d24988d9
  1. 5
      kernel/acpi/acpi.c
  2. 14
      kernel/drivers/pcie.c
  3. 7
      kernel/drivers/pcie.h
  4. 6
      kernel/entry.c

5
kernel/acpi/acpi.c

@ -185,7 +185,10 @@ static void parse_pcie(const struct PCIETable* table) {
size_t size = (table->header.length-sizeof(table->header));
pcie_descriptor.size = size / sizeof(struct PCIE_segment_group_descriptor);
assert(pcie_descriptor.size < PCIE_SUPPORTED_SEGMENT_GROUPS);
memcpy(pcie_descriptor.array, table->segments, size);
}

14
kernel/drivers/pcie.c

@ -1,5 +1,17 @@
#include "pcie.h"
#include "../debug/logging.h"
#include "../debug/dump.h"
struct PCIE_Descriptor pcie_descriptor = {0};
void pcie_init(void) {
klog_debug("init pcie...");
klog_debug("%d", pcie_descriptor.size);
dump(
pcie_descriptor.array,
pcie_descriptor.size * sizeof(struct PCIE_segment_group_descriptor),
sizeof(struct PCIE_segment_group_descriptor),
DUMP_HEX8
);
}

7
kernel/drivers/pcie.h

@ -15,10 +15,10 @@ struct PCIE_segment_group_descriptor {
};
#define PCIE_SUPPORTED_SEGMENT_GROUPS 2
struct PCIE_Descriptor {
size_t size;
struct PCIE_segment_group_descriptor array[4];
struct PCIE_segment_group_descriptor array[PCIE_SUPPORTED_SEGMENT_GROUPS];
// we only handle PCIE devices with only 4 segment groups max
};
@ -27,3 +27,6 @@ struct PCIE_Descriptor {
extern struct PCIE_Descriptor pcie_descriptor;
void pcie_init(void);

6
kernel/entry.c

@ -12,6 +12,7 @@
#include "regs.h"
#include "int/apic.h"
#include "drivers/hpet.h"
#include "drivers/pcie.h"
#include "int/idt.h"
#include "memory/physical_allocator.h"
@ -108,7 +109,7 @@ static void print_fb_infos(struct stivale2_struct_tag_framebuffer* fbtag) {
static void init_memory(const struct stivale2_struct_tag_memmap* memmap_tag,
const struct stivale2_struct_tag_framebuffer* fbtag) {
klog_debug("init memory...");
init_physical_allocator(memmap_tag);
@ -184,6 +185,9 @@ void _start(struct stivale2_struct *stivale2_struct) {
kputs(klog_get());
klog_flush();
pcie_init();
hpet_init();
apic_setup_clock();

Loading…
Cancel
Save