chore: reorganize file directories
We have reorganized all the file directories that previously looked ugly as hell (cough cough arch/x86_64 cough) Now it looks much cleaner Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "idt.h"
|
||||
#include "util/binary.h"
|
||||
#include "libk/binary.h"
|
||||
|
||||
|
||||
IDTEntry g_IDT[256];
|
||||
@@ -1,7 +1,7 @@
|
||||
// ... includes ...
|
||||
#include "io.h"
|
||||
#include "debug.h"
|
||||
#include "arch/x86_64/isr.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/debug.h"
|
||||
#include "arch/x86_64/boot/isr.h"
|
||||
#include "idt.h"
|
||||
#define MODULE "ISR"
|
||||
|
||||
@@ -16,7 +16,7 @@ x86_64_ISR\num:
|
||||
jmp isr_common
|
||||
.endm
|
||||
|
||||
.include "arch/x86_64/isrs_gen.inc" // ← update path if needed
|
||||
.include "arch/x86_64/boot/isrs_gen.inc"
|
||||
|
||||
isr_common:
|
||||
push rax
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ata.h"
|
||||
#include "io.h"
|
||||
#include "stdio.h"
|
||||
#include "memory.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/stdio.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "pci.h"
|
||||
#include "arch/x86_64/io.h"
|
||||
#include <stdio.h>
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/stdio.h"
|
||||
|
||||
#define PCI_CFG_ADDR 0x0CF8
|
||||
#define PCI_CFG_DATA 0x0CFC
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "libk/string.h"
|
||||
#include "mm/pmm.h"
|
||||
#include "mm/vmm.h"
|
||||
#include "mm/memory.h"
|
||||
#include "stdio.h"
|
||||
#include "libk/stdio.h"
|
||||
#include "fs/elf.h"
|
||||
|
||||
extern uintptr_t g_hhdm_offset;
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "apic.h"
|
||||
#include "mm/vmm.h"
|
||||
#include "mm/memory.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/stdio.h"
|
||||
/* ── Internal state ───────────────────────────────────────────────────────── */
|
||||
static volatile uint32_t *g_lapic = NULL; /* Virtual address of LAPIC MMIO */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "e9.h"
|
||||
#include <arch/x86_64/io.h>
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
|
||||
void e9_putc(char c)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "pic.h"
|
||||
#include "io.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PIC1_COMMAND_PORT 0x20
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "apic.h"
|
||||
#include "mm/vmm.h"
|
||||
#include "mm/memory.h"
|
||||
#include "stdio.h"
|
||||
#include "libk/stdio.h"
|
||||
#include <uacpi/tables.h> /* uacpi_table_find_by_signature / uacpi_table_unref */
|
||||
#include "pic.h"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "irq.h"
|
||||
#include "i8259.h"
|
||||
#include "io.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include <stddef.h>
|
||||
#include <util/arrays.h>
|
||||
#include "stdio.h"
|
||||
#include <debug.h>
|
||||
#include "libk/arrays.h"
|
||||
#include "libk/stdio.h"
|
||||
#include "libk/debug.h"
|
||||
#include "apic.h"
|
||||
#include "ioapic.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "isr.h"
|
||||
#include "arch/x86_64/boot/isr.h"
|
||||
|
||||
|
||||
typedef void (*IRQHandler)(Registers* regs);
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "pit.h"
|
||||
#include "irq.h"
|
||||
#include "io.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include <stdint.h>
|
||||
#include "stdio.h"
|
||||
#include "libk/stdio.h"
|
||||
#include "e9.h"
|
||||
#include "limine.h"
|
||||
#include "apic.h"
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "irq.h"
|
||||
#include "io.h"
|
||||
#include <stdint.h>
|
||||
#include "stdio.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/stdio.h"
|
||||
#include "e9.h"
|
||||
|
||||
extern volatile uint64_t g_Ticks;
|
||||
@@ -0,0 +1,49 @@
|
||||
#include <stdint.h>
|
||||
#include "arch/x86_64/sys/pit.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/stdio.h"
|
||||
#include "tsc.h"
|
||||
|
||||
extern uint64_t PIT_GetTicks(void);
|
||||
|
||||
volatile uint64_t tsc_cycles_per_us = 0;
|
||||
|
||||
uint64_t rdtsc(void)
|
||||
{
|
||||
uint32_t lo, hi;
|
||||
__asm__ volatile ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
return ((uint64_t)hi << 32) | lo;
|
||||
}
|
||||
|
||||
|
||||
void calibrate_tsc(void)
|
||||
{
|
||||
// Use a stable PIT rate for calibration
|
||||
const uint32_t pit_freq = 1000; // 1000 Hz = 1ms per tick
|
||||
const uint32_t calibration_ticks = 1000; // 1 second total
|
||||
|
||||
|
||||
|
||||
// Wait for PIT to stabilize
|
||||
uint64_t start_ticks = PIT_GetTicks();
|
||||
while (PIT_GetTicks() == start_ticks)
|
||||
;
|
||||
|
||||
uint64_t start_tsc = rdtsc();
|
||||
uint64_t target_ticks = start_ticks + calibration_ticks;
|
||||
|
||||
// Wait for known number of PIT ticks
|
||||
while (PIT_GetTicks() < target_ticks)
|
||||
;
|
||||
|
||||
uint64_t end_tsc = rdtsc();
|
||||
|
||||
// Compute elapsed time
|
||||
uint64_t tsc_delta = end_tsc - start_tsc;
|
||||
|
||||
uint64_t elapsed_us = 1000000ULL;
|
||||
|
||||
tsc_cycles_per_us = tsc_delta / elapsed_us;
|
||||
|
||||
printf("TSC calibration complete: %lu cycles/us\n", tsc_cycles_per_us);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stdint.h>
|
||||
#include "arch/x86_64/sys/pit.h"
|
||||
#include "arch/x86_64/cpu/io.h"
|
||||
#include "libk/stdio.h"
|
||||
uint64_t rdtsc(void);
|
||||
|
||||
|
||||
|
||||
void calibrate_tsc(void);
|
||||
Reference in New Issue
Block a user