Browse Source

:wrench: include上级文件夹时,统一采用<>来指定文件

fslongjin 2 năm trước cách đây
mục cha
commit
d0ddb73788

+ 4 - 1
.vscode/settings.json

@@ -104,7 +104,10 @@
         "spinlock.h": "c",
         "stat.h": "c",
         "video.h": "c",
-        "libm.h": "c"
+        "libm.h": "c",
+        "ahci.h": "c",
+        "slab.h": "c",
+        "boot_info.h": "c"
     },
     "C_Cpp.errorSquiggles": "Enabled",
     "esbonio.sphinx.confDir": ""

+ 2 - 2
kernel/arch/x86_64/x86_64_ipi.h

@@ -11,8 +11,8 @@
 
 #pragma once
 
-#include "../../common/kprint.h"
-#include "../../driver/interrupt/apic/apic.h"
+#include <common/kprint.h>
+#include <driver/interrupt/apic/apic.h>
 
 /**
  * @brief 发送ipi消息

+ 3 - 3
kernel/common/printk.c

@@ -3,9 +3,9 @@
 //
 #include "printk.h"
 #include "kprint.h"
-#include "../driver/multiboot2/multiboot2.h"
-#include "../mm/mm.h"
-#include "../process/spinlock.h"
+#include <driver/multiboot2/multiboot2.h>
+#include <mm/mm.h>
+#include <process/spinlock.h>
 
 #include <driver/uart/uart.h>
 #include <driver/video/video.h>

+ 4 - 4
kernel/driver/acpi/acpi.c

@@ -1,8 +1,8 @@
 #include "acpi.h"
-#include "../../common/printk.h"
-#include "../../common/kprint.h"
-#include "../multiboot2/multiboot2.h"
-#include "../../mm/mm.h"
+#include <common/printk.h>
+#include <common/kprint.h>
+#include <driver/multiboot2/multiboot2.h>
+#include <mm/mm.h>
 
 #define acpi_get_RSDT_entry_vaddr(phys_addr) (ACPI_DESCRIPTION_HEDERS_BASE + (phys_addr)-acpi_RSDT_entry_phys_base) // 获取RSDT entry的虚拟地址
 // #define acpi_get_XSDT_entry_vaddr(phys_addr) (ACPI_DESCRIPTION_HEDERS_BASE + (phys_addr)-acpi_XSDT_entry_phys_base) // 获取XSDT entry的虚拟地址

+ 2 - 2
kernel/driver/acpi/acpi.h

@@ -4,8 +4,8 @@
 
 #pragma once
 
-#include "../../common/glib.h"
-#include "../../mm/mm.h"
+#include <common/glib.h>
+#include <mm/mm.h>
 
 #define ACPI_ICS_TYPE_PROCESSOR_LOCAL_APIC 0
 #define ACPI_ICS_TYPE_IO_APIC 1

+ 3 - 2
kernel/driver/disk/ahci/ahci.c

@@ -1,6 +1,6 @@
 #include "ahci.h"
-#include "../../../common/kprint.h"
-#include "../../../mm/slab.h"
+#include <common/kprint.h>
+#include <mm/slab.h>
 #include <syscall/syscall.h>
 #include <syscall/syscall_num.h>
 
@@ -23,6 +23,7 @@ static int ahci_find_cmdslot(HBA_PORT *port);
 
 // 计算HBA_MEM的虚拟内存地址
 #define cal_HBA_MEM_VIRT_ADDR(device_num) (AHCI_MAPPING_BASE + (ul)(((struct pci_device_structure_general_device_t *)(ahci_devs[device_num]))->BAR5 - ((((struct pci_device_structure_general_device_t *)(ahci_devs[0]))->BAR5) & PAGE_2M_MASK)))
+
 /**
  * @brief 初始化ahci模块
  *

+ 3 - 3
kernel/driver/disk/ahci/ahci.h

@@ -1,8 +1,8 @@
 #pragma once
 
-#include "../block_device.h"
-#include "../../pci/pci.h"
-#include "../../../mm/mm.h"
+#include <driver/disk/block_device.h>
+#include <driver/pci/pci.h>
+#include <mm/mm.h>
 
 /**
  * @todo 加入io调度器(当操作系统实现了多进程之后要加入这个)

+ 2 - 2
kernel/driver/disk/ata.c

@@ -1,6 +1,6 @@
 #include "ata.h"
-#include "../../common/kprint.h"
-#include "../interrupt/apic/apic.h"
+#include <common/kprint.h>
+#include <driver/interrupt/apic/apic.h>
 
 struct apic_IO_APIC_RTE_entry entry;
 

+ 1 - 1
kernel/driver/disk/ata.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../../common/glib.h"
+#include <common/glib.h>
 
 // ======== PIO端口定义 ========
 #define PORT_DISK0_DATA 0x1f0                     // 数据

+ 1 - 1
kernel/driver/disk/block_device.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../../common/glib.h"
+#include <common/glib.h>
 #include "stdint.h"
 #include <process/semaphore.h>
 

+ 3 - 3
kernel/driver/interrupt/8259A/8259A.c

@@ -1,7 +1,7 @@
 #include "8259A.h"
-#include "../../../common/printk.h"
-#include "../../../common/kprint.h"
-#include "../../../exception/gate.h"
+#include <common/printk.h>
+#include <common/kprint.h>
+#include <exception/gate.h>
 
 // 导出定义在irq.c中的中段门表
 extern void (*interrupt_table[24])(void);

+ 2 - 2
kernel/driver/interrupt/8259A/8259A.h

@@ -11,8 +11,8 @@
 
 #pragma once
 
-#include "../../../common/glib.h"
-#include "../../../exception/irq.h"
+#include <common/glib.h>
+#include <exception/irq.h>
 
 #define PIC_EOI		0x20
 #define PIC_master		0x20		/* IO base address for master PIC */

+ 7 - 7
kernel/driver/interrupt/apic/apic.c

@@ -1,10 +1,10 @@
 #include "apic.h"
-#include "../../../common/kprint.h"
-#include "../../../common/printk.h"
-#include "../../../common/cpu.h"
-#include "../../../common/glib.h"
-#include "../../../exception/gate.h"
-#include "../../acpi/acpi.h"
+#include <common/kprint.h>
+#include <common/printk.h>
+#include <common/cpu.h>
+#include <common/glib.h>
+#include <exception/gate.h>
+#include <driver/acpi/acpi.h>
 
 #include <exception/softirq.h>
 #include <process/process.h>
@@ -28,7 +28,7 @@ static struct acpi_IO_APIC_Structure_t *io_apic_ICS;
                              "movq	$0x00,	%%rax	\n\t"   \
                              "movq 	$0x80b,	%%rcx	\n\t" \
                              "wrmsr	\n\t" ::            \
-                                 : "memory");            \
+                                 : "memory");           \
     } while (0)
 
 /**

+ 4 - 4
kernel/driver/interrupt/apic/apic.h

@@ -1,9 +1,9 @@
 #pragma once
 
-#include "../../../common/asm.h"
-#include "../../../process/ptrace.h"
-#include "../../../exception/irq.h"
-#include "../../../mm/mm.h"
+#include <common/asm.h>
+#include <process/ptrace.h>
+#include <exception/irq.h>
+#include <mm/mm.h>
 
 #define APIC_SUCCESS 0
 #define APIC_E_NOTFOUND 1

+ 4 - 4
kernel/driver/keyboard/ps2_keyboard.c

@@ -1,8 +1,8 @@
 #include "ps2_keyboard.h"
-#include "../interrupt/apic/apic.h"
-#include "../../mm/mm.h"
-#include "../../mm/slab.h"
-#include "../../common/printk.h"
+#include <driver/interrupt/apic/apic.h>
+#include <mm/mm.h>
+#include <mm/slab.h>
+#include <common/printk.h>
 #include <filesystem/VFS/VFS.h>
 #include <process/wait_queue.h>
 #include <process/spinlock.h>

+ 1 - 1
kernel/driver/keyboard/ps2_keyboard.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../../common/glib.h"
+#include <common/glib.h>
 
 #define PS2_KEYBOARD_INTR_VECTOR 0x21   // 键盘的中断向量号
 

+ 5 - 5
kernel/driver/mouse/ps2_mouse.c

@@ -1,9 +1,9 @@
 #include "ps2_mouse.h"
-#include "../interrupt/apic/apic.h"
-#include "../../mm/mm.h"
-#include "../../mm/slab.h"
-#include "../../common/printk.h"
-#include "../../common/kprint.h"
+#include <driver/interrupt/apic/apic.h>
+#include <mm/mm.h>
+#include <mm/slab.h>
+#include <common/printk.h>
+#include <common/kprint.h>
 
 static struct ps2_mouse_input_buffer *ps2_mouse_buf_ptr = NULL;
 static int c = 0;

+ 1 - 1
kernel/driver/mouse/ps2_mouse.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../../common/glib.h"
+#include <common/glib.h>
 
 #define PS2_MOUSE_INTR_VECTOR 0x2c // 鼠标的中断向量号
 

+ 2 - 2
kernel/driver/multiboot2/multiboot2.c

@@ -1,8 +1,8 @@
 #include "multiboot2.h"
 #include "assert.h"
 
-#include "../../common/glib.h"
-#include "../../common/kprint.h"
+#include <common/glib.h>
+#include <common/kprint.h>
 uintptr_t multiboot2_boot_info_addr;
 unsigned int multiboot2_magic;
 unsigned int multiboot2_boot_info_size;

+ 2 - 2
kernel/driver/multiboot2/multiboot2.h

@@ -7,8 +7,8 @@
 
 #include "stdint.h"
 #include "stdbool.h"
-#include "../../common/boot_info.h"
-#include "../acpi/acpi.h"
+#include <common/boot_info.h>
+#include <driver/acpi/acpi.h>
 
 /// @see Multiboot2 Specification version 2.0.pdf
 // 启动后,在 32 位内核进入点,机器状态如下:

+ 2 - 2
kernel/driver/pci/pci.c

@@ -1,6 +1,6 @@
 #include "pci.h"
-#include "../../common/kprint.h"
-#include "../../mm/slab.h"
+#include <common/kprint.h>
+#include <mm/slab.h>
 
 static uint count_device_list = 0;
 static void pci_checkBus(uint8_t bus);

+ 1 - 1
kernel/driver/pci/pci.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../../common/glib.h"
+#include <common/glib.h>
 #include "stdint.h"
 
 #define PORT_PCI_CONFIG_ADDRESS 0xcf8

+ 2 - 2
kernel/driver/timers/HPET/HPET.h

@@ -2,11 +2,11 @@
 
 #include <common/glib.h>
 #include <driver/acpi/acpi.h>
-#include<driver/timers/rtc/rtc.h>
+#include <driver/timers/rtc/rtc.h>
 
 #define E_HPET_INIT_FAILED 1
 
-#define HPET0_INTERVAL 500    // HPET0定时器的中断间隔为500us
+#define HPET0_INTERVAL 500 // HPET0定时器的中断间隔为500us
 int HPET_init();
 
 /**

+ 17 - 1
kernel/driver/usb/usb.c

@@ -1 +1,17 @@
-#include "usb.h"
+#include "usb.h"
+#include <common/kprint.h>
+#include <driver/pci/pci.h>
+
+#define MAX_USB_NUM 8 // pci总线上的usb设备的最大数量
+
+// 在pci总线上寻找到的usb设备控制器的header
+struct pci_device_structure_header_t *usb_pdevs[MAX_USB_NUM];
+
+/**
+ * @brief 初始化usb驱动程序
+ *
+ */
+void usb_init()
+{
+    kinfo("Initializing usb driver...");
+}

+ 19 - 1
kernel/driver/usb/usb.h

@@ -1 +1,19 @@
-#pragma once
+#pragma once
+
+// usb设备在pci总线上的class
+#define USB_CLASS 0xC
+#define USB_SUBCLASS 0x3
+
+// 不同的usb设备在pci总线上的prog IF
+#define USB_TYPE_UHCI 0x0
+#define USB_TYPE_OHCI 0x10
+#define USB_TYPE_EHCI 0x20
+#define USB_TYPE_XHCI 0x30
+#define USB_TYPE_UNSPEC 0x80    // Unspecified
+#define USB_TYPE_DEVICE 0xfe    // USB Device(Not controller)
+
+/**
+ * @brief 初始化usb驱动程序
+ * 
+ */
+void usb_init();

+ 1 - 1
kernel/exception/gate.h

@@ -9,7 +9,7 @@
 #ifndef __GATE_H__
 #define __GATE_H__
 
-#include "../common/kprint.h"
+#include <common/kprint.h>
 #include <mm/mm.h>
 
 //描述符表的结构体

+ 4 - 4
kernel/exception/irq.c

@@ -3,13 +3,13 @@
 
 // 对进行
 #if _INTR_8259A_
-#include "../driver/interrupt/8259A/8259A.h"
+#include <driver/interrupt/8259A/8259A.h>
 #else
-#include "../driver/interrupt/apic/apic.h"
+#include <driver/interrupt/apic/apic.h>
 #endif
 
-#include "../common/asm.h"
-#include "../common/printk.h"
+#include <common/asm.h>
+#include <common/printk.h>
 #include "gate.h"
 #include <mm/slab.h>
 

+ 2 - 2
kernel/exception/irq.h

@@ -11,9 +11,9 @@
 
 #pragma once
 
-#include "../common/glib.h"
+#include <common/glib.h>
 
-#include "../process/ptrace.h"
+#include <process/ptrace.h>
 
 #define SMP_IRQ_NUM 10
 #define LOCAL_APIC_IRQ_NUM 10

+ 2 - 2
kernel/exception/trap.c

@@ -1,7 +1,7 @@
 #include "trap.h"
 #include "gate.h"
-#include "../process/ptrace.h"
-#include "../common/kprint.h"
+#include <process/ptrace.h>
+#include <common/kprint.h>
 #include <process/process.h>
 #include <debug/traceback/traceback.h>
 

+ 3 - 3
kernel/exception/trap.h

@@ -8,9 +8,9 @@
 
 #pragma once
 
-#include "../common/printk.h"
-#include "../common/glib.h"
-#include "../common/asm.h"
+#include <common/printk.h>
+#include <common/glib.h>
+#include <common/asm.h>
 
 /**
  * @brief 初始化系统中断表

+ 3 - 3
kernel/mm/mm.c

@@ -1,8 +1,8 @@
 #include "mm.h"
 #include "slab.h"
-#include "../common/printk.h"
-#include "../common/kprint.h"
-#include "../driver/multiboot2/multiboot2.h"
+#include <common/printk.h>
+#include <common/kprint.h>
+#include <driver/multiboot2/multiboot2.h>
 #include <process/process.h>
 
 ul Total_Memory = 0;

+ 1 - 1
kernel/mm/mm.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../common/glib.h"
+#include <common/glib.h>
 
 // 每个页表的项数
 // 64位下,每个页表4k,每条页表项8B,故一个页表有512条

+ 3 - 3
kernel/mm/slab.h

@@ -1,9 +1,9 @@
 #pragma once
 
 #include "mm.h"
-#include "../common/glib.h"
-#include "../common/printk.h"
-#include "../common/kprint.h"
+#include <common/glib.h>
+#include <common/printk.h>
+#include <common/kprint.h>
 
 #define SIZEOF_LONG_ALIGN(size) ((size + sizeof(long) - 1) & ~(sizeof(long) - 1))
 #define SIZEOF_INT_ALIGN(size) ((size + sizeof(int) - 1) & ~(sizeof(int) - 1))

+ 5 - 5
kernel/process/process.c

@@ -1,10 +1,10 @@
 #include "process.h"
 
-#include "../exception/gate.h"
-#include "../common/printk.h"
-#include "../common/kprint.h"
-#include "../syscall/syscall.h"
-#include "../syscall/syscall_num.h"
+#include <exception/gate.h>
+#include <common/printk.h>
+#include <common/kprint.h>
+#include <syscall/syscall.h>
+#include <syscall/syscall_num.h>
 #include <mm/slab.h>
 #include <sched/sched.h>
 #include <filesystem/fat32/fat32.h>

+ 4 - 4
kernel/process/process.h

@@ -10,10 +10,10 @@
 
 #pragma once
 
-#include "../common/cpu.h"
-#include "../common/glib.h"
-#include "../mm/mm.h"
-#include "../syscall/syscall.h"
+#include <common/cpu.h>
+#include <common/glib.h>
+#include <mm/mm.h>
+#include <syscall/syscall.h>
 #include "ptrace.h"
 #include <common/errno.h>
 #include <filesystem/VFS/VFS.h>

+ 7 - 7
kernel/smp/smp.c

@@ -1,11 +1,11 @@
 #include "smp.h"
-#include "../common/kprint.h"
-#include "../driver/interrupt/apic/apic.h"
-#include "../exception/gate.h"
-#include "../common/cpu.h"
-#include "../mm/slab.h"
-#include "../process/process.h"
-#include "../process/spinlock.h"
+#include <common/kprint.h>
+#include <driver/interrupt/apic/apic.h>
+#include <exception/gate.h>
+#include <common/cpu.h>
+#include <mm/slab.h>
+#include <process/process.h>
+#include <process/spinlock.h>
 
 #include <sched/sched.h>
 

+ 4 - 4
kernel/smp/smp.h

@@ -1,9 +1,9 @@
 #pragma once
-#include "../common/glib.h"
+#include <common/glib.h>
 
-#include "../common/asm.h"
-#include "../driver/acpi/acpi.h"
-#include "../driver/interrupt/apic/apic.h"
+#include <common/asm.h>
+#include <driver/acpi/acpi.h>
+#include <driver/interrupt/apic/apic.h>
 
 #define MAX_SUPPORTED_PROCESSOR_NUM 1024    
 

+ 1 - 1
kernel/syscall/syscall.c

@@ -1,5 +1,5 @@
 #include "syscall.h"
-#include "../process/process.h"
+#include <process/process.h>
 #include <exception/gate.h>
 #include <exception/irq.h>
 #include <driver/disk/ahci/ahci.h>

+ 3 - 3
kernel/syscall/syscall.h

@@ -1,8 +1,8 @@
 #pragma once
 
-#include "../common/glib.h"
-#include "../common/kprint.h"
-#include "../process/ptrace.h"
+#include <common/glib.h>
+#include <common/kprint.h>
+#include <process/ptrace.h>
 #include <common/unistd.h>
 // 定义最大系统调用数量
 #define MAX_SYSTEM_CALL_NUM 256