mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
wrench: 更新Makefile
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
kernel_driver_subdirs:=video interrupt usb
|
||||
kernel_driver_subdirs:=video interrupt usb pci uart acpi disk keyboard mouse multiboot2 timers
|
||||
|
||||
all:
|
||||
@list='$(kernel_driver_subdirs)'; for subdir in $$list; do \
|
||||
|
8
kernel/driver/acpi/Makefile
Normal file
8
kernel/driver/acpi/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
all: acpi.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
|
||||
acpi.o: acpi.c
|
||||
gcc $(CFLAGS) -c acpi.c -o acpi.o
|
10
kernel/driver/disk/Makefile
Normal file
10
kernel/driver/disk/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
all: ata.o ahci.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
ata.o: ata.c
|
||||
gcc $(CFLAGS) -c ata.c -o ata.o
|
||||
|
||||
ahci.o: ahci/ahci.c
|
||||
gcc $(CFLAGS) -c ahci/ahci.c -o ahci/ahci.o
|
8
kernel/driver/keyboard/Makefile
Normal file
8
kernel/driver/keyboard/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
all: ps2_keyboard.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
|
||||
ps2_keyboard.o: ps2_keyboard.c
|
||||
gcc $(CFLAGS) -c ps2_keyboard.c -o ps2_keyboard.o
|
8
kernel/driver/mouse/Makefile
Normal file
8
kernel/driver/mouse/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
all: ps2_mouse.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
|
||||
ps2_mouse.o: ps2_mouse.c
|
||||
gcc $(CFLAGS) -c ps2_mouse.c -o ps2_mouse.o
|
7
kernel/driver/multiboot2/Makefile
Normal file
7
kernel/driver/multiboot2/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
all: multiboot2.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
multiboot2.o: multiboot2.c
|
||||
gcc $(CFLAGS) -c multiboot2.c -o multiboot2.o
|
11
kernel/driver/pci/Makefile
Normal file
11
kernel/driver/pci/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
all: pci.o msi.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
|
||||
pci.o: pci.c
|
||||
gcc $(CFLAGS) -c pci.c -o pci.o
|
||||
|
||||
msi.o: msi.c
|
||||
gcc $(CFLAGS) -c msi.c -o msi.o
|
229
kernel/driver/pci/msi.c
Normal file
229
kernel/driver/pci/msi.c
Normal file
@ -0,0 +1,229 @@
|
||||
#include "msi.h"
|
||||
#include "pci.h"
|
||||
|
||||
/**
|
||||
* @brief 生成架构相关的msi的message address
|
||||
*
|
||||
*/
|
||||
#define pci_get_arch_msi_message_address(processor) ((uint64_t)(0xfee00000UL | (processor << 12)))
|
||||
|
||||
/**
|
||||
* @brief 生成架构相关的message data
|
||||
*
|
||||
*/
|
||||
#define pci_get_arch_msi_message_data(vector, processor, edge_trigger, assert) ((uint32_t)((vector & 0xff) | (edge_trigger == 1 ? 0 : (1 << 15)) | ((assert == 0) ? 0 : (1 << 14))))
|
||||
|
||||
|
||||
/**
|
||||
* @brief 启用 Message Signaled Interrupts
|
||||
*
|
||||
* @param header 设备header
|
||||
* @param vector 中断向量号
|
||||
* @param processor 要投递到的处理器
|
||||
* @param edge_trigger 是否边缘触发
|
||||
* @param assert 是否高电平触发
|
||||
*
|
||||
* @return 返回码
|
||||
*/
|
||||
int pci_enable_msi(void *header, uint8_t vector, uint32_t processor, uint8_t edge_trigger, uint8_t assert)
|
||||
{
|
||||
struct pci_device_structure_header_t *ptr = (struct pci_device_structure_header_t *)header;
|
||||
uint32_t cap_ptr;
|
||||
uint32_t tmp;
|
||||
uint16_t message_control;
|
||||
uint64_t message_addr;
|
||||
switch (ptr->HeaderType)
|
||||
{
|
||||
case 0x00: // general device
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
cap_ptr = ((struct pci_device_structure_general_device_t *)ptr)->Capabilities_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
message_control = (tmp >> 16) & 0xffff;
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 写入message address
|
||||
message_addr = pci_get_arch_msi_message_address(processor); // 获取message address
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x4, (uint32_t)(message_addr & 0xffffffff));
|
||||
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, (uint32_t)((message_addr >> 32) & 0xffffffff));
|
||||
|
||||
// 写入message data
|
||||
tmp = pci_get_arch_msi_message_data(vector, processor, edge_trigger, assert);
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0xc, tmp);
|
||||
else
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, tmp);
|
||||
|
||||
// 使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
|
||||
case 0x01: // pci to pci bridge
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_pci_to_pci_bridge_t *)ptr)->Capability_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
message_control = (tmp >> 16) & 0xffff;
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 写入message address
|
||||
message_addr = pci_get_arch_msi_message_address(processor); // 获取message address
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x4, (uint32_t)(message_addr & 0xffffffff));
|
||||
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, (uint32_t)((message_addr >> 32) & 0xffffffff));
|
||||
|
||||
// 写入message data
|
||||
tmp = pci_get_arch_msi_message_data(vector, processor, edge_trigger, assert);
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0xc, tmp);
|
||||
else
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, tmp);
|
||||
|
||||
// 使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
case 0x02: // pci to card bus bridge
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
break;
|
||||
|
||||
default: // 不应该到达这里
|
||||
return E_WRONG_HEADER_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 在已配置好msi寄存器的设备上,使能msi
|
||||
*
|
||||
* @param header 设备头部
|
||||
* @return int 返回码
|
||||
*/
|
||||
int pci_start_msi(void *header)
|
||||
{
|
||||
struct pci_device_structure_header_t *ptr = (struct pci_device_structure_header_t *)header;
|
||||
uint32_t cap_ptr;
|
||||
uint32_t tmp;
|
||||
|
||||
switch (ptr->HeaderType)
|
||||
{
|
||||
case 0x00: // general device
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_general_device_t *)ptr)->Capabilities_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
|
||||
case 0x01: // pci to pci bridge
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_pci_to_pci_bridge_t *)ptr)->Capability_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
//使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
case 0x02: // pci to card bus bridge
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
break;
|
||||
|
||||
default: // 不应该到达这里
|
||||
return E_WRONG_HEADER_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief 禁用指定设备的msi
|
||||
*
|
||||
* @param header pci header
|
||||
* @return int
|
||||
*/
|
||||
int pci_disable_msi(void *header)
|
||||
{
|
||||
struct pci_device_structure_header_t *ptr = (struct pci_device_structure_header_t *)header;
|
||||
uint32_t cap_ptr;
|
||||
uint32_t tmp;
|
||||
|
||||
switch (ptr->HeaderType)
|
||||
{
|
||||
case 0x00: // general device
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_general_device_t *)ptr)->Capabilities_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 禁用msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp &= (~(1 << 16));
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
|
||||
case 0x01: // pci to pci bridge
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_pci_to_pci_bridge_t *)ptr)->Capability_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
//禁用msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp &= (~(1 << 16));
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
case 0x02: // pci to card bus bridge
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
break;
|
||||
|
||||
default: // 不应该到达这里
|
||||
return E_WRONG_HEADER_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
32
kernel/driver/pci/msi.h
Normal file
32
kernel/driver/pci/msi.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <common/glib.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief 启用 Message Signaled Interrupts
|
||||
*
|
||||
* @param header 设备header
|
||||
* @param vector 中断向量号
|
||||
* @param processor 要投递到的处理器
|
||||
* @param edge_trigger 是否边缘触发
|
||||
* @param assert 是否高电平触发
|
||||
*
|
||||
* @return 返回码
|
||||
*/
|
||||
int pci_enable_msi(void * header, uint8_t vector, uint32_t processor, uint8_t edge_trigger, uint8_t assert);
|
||||
|
||||
/**
|
||||
* @brief 禁用指定设备的msi
|
||||
*
|
||||
* @param header pci header
|
||||
* @return int
|
||||
*/
|
||||
int pci_disable_msi(void *header);
|
||||
|
||||
/**
|
||||
* @brief 在已配置好msi寄存器的设备上,使能msi
|
||||
*
|
||||
* @param header 设备头部
|
||||
* @return int 返回码
|
||||
*/
|
||||
int pci_start_msi(void *header);
|
@ -26,17 +26,6 @@ static void pci_checkBus(uint8_t bus);
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief 生成架构相关的msi的message address
|
||||
*
|
||||
*/
|
||||
#define pci_get_arch_msi_message_address(processor) ((uint64_t)(0xfee00000UL | (processor << 12)))
|
||||
|
||||
/**
|
||||
* @brief 生成架构相关的message data
|
||||
*
|
||||
*/
|
||||
#define pci_get_arch_msi_message_data(vector, processor, edge_trigger, assert) ((uint32_t)((vector & 0xff) | (edge_trigger == 1 ? 0 : (1 << 15)) | ((assert == 0) ? 0 : (1 << 14))))
|
||||
|
||||
/**
|
||||
* @brief 从pci配置空间读取信息
|
||||
@ -479,219 +468,6 @@ void pci_init()
|
||||
kinfo("PCI bus initialized.")
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 启用 Message Signaled Interrupts
|
||||
*
|
||||
* @param header 设备header
|
||||
* @param vector 中断向量号
|
||||
* @param processor 要投递到的处理器
|
||||
* @param edge_trigger 是否边缘触发
|
||||
* @param assert 是否高电平触发
|
||||
*
|
||||
* @return 返回码
|
||||
*/
|
||||
int pci_enable_msi(void *header, uint8_t vector, uint32_t processor, uint8_t edge_trigger, uint8_t assert)
|
||||
{
|
||||
struct pci_device_structure_header_t *ptr = (struct pci_device_structure_header_t *)header;
|
||||
uint32_t cap_ptr;
|
||||
uint32_t tmp;
|
||||
uint16_t message_control;
|
||||
uint64_t message_addr;
|
||||
switch (ptr->HeaderType)
|
||||
{
|
||||
case 0x00: // general device
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
cap_ptr = ((struct pci_device_structure_general_device_t *)ptr)->Capabilities_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
message_control = (tmp >> 16) & 0xffff;
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 写入message address
|
||||
message_addr = pci_get_arch_msi_message_address(processor); // 获取message address
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x4, (uint32_t)(message_addr & 0xffffffff));
|
||||
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, (uint32_t)((message_addr >> 32) & 0xffffffff));
|
||||
|
||||
// 写入message data
|
||||
tmp = pci_get_arch_msi_message_data(vector, processor, edge_trigger, assert);
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0xc, tmp);
|
||||
else
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, tmp);
|
||||
|
||||
// 使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
|
||||
case 0x01: // pci to pci bridge
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_pci_to_pci_bridge_t *)ptr)->Capability_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
message_control = (tmp >> 16) & 0xffff;
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 写入message address
|
||||
message_addr = pci_get_arch_msi_message_address(processor); // 获取message address
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x4, (uint32_t)(message_addr & 0xffffffff));
|
||||
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, (uint32_t)((message_addr >> 32) & 0xffffffff));
|
||||
|
||||
// 写入message data
|
||||
tmp = pci_get_arch_msi_message_data(vector, processor, edge_trigger, assert);
|
||||
if (message_control & (1 << 7)) // 64位
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0xc, tmp);
|
||||
else
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr + 0x8, tmp);
|
||||
|
||||
// 使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
case 0x02: // pci to card bus bridge
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
break;
|
||||
|
||||
default: // 不应该到达这里
|
||||
return E_WRONG_HEADER_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 在已配置好msi寄存器的设备上,使能msi
|
||||
*
|
||||
* @param header 设备头部
|
||||
* @return int 返回码
|
||||
*/
|
||||
int pci_start_msi(void *header)
|
||||
{
|
||||
struct pci_device_structure_header_t *ptr = (struct pci_device_structure_header_t *)header;
|
||||
uint32_t cap_ptr;
|
||||
uint32_t tmp;
|
||||
|
||||
switch (ptr->HeaderType)
|
||||
{
|
||||
case 0x00: // general device
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_general_device_t *)ptr)->Capabilities_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
|
||||
case 0x01: // pci to pci bridge
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_pci_to_pci_bridge_t *)ptr)->Capability_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
//使能msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp |= (1 << 16);
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
case 0x02: // pci to card bus bridge
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
break;
|
||||
|
||||
default: // 不应该到达这里
|
||||
return E_WRONG_HEADER_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief 禁用指定设备的msi
|
||||
*
|
||||
* @param header pci header
|
||||
* @return int
|
||||
*/
|
||||
int pci_disable_msi(void *header)
|
||||
{
|
||||
struct pci_device_structure_header_t *ptr = (struct pci_device_structure_header_t *)header;
|
||||
uint32_t cap_ptr;
|
||||
uint32_t tmp;
|
||||
|
||||
switch (ptr->HeaderType)
|
||||
{
|
||||
case 0x00: // general device
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_general_device_t *)ptr)->Capabilities_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
// 禁用msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp &= (~(1 << 16));
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
|
||||
case 0x01: // pci to pci bridge
|
||||
if (!(ptr->Status & 0x10))
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
cap_ptr = ((struct pci_device_structure_pci_to_pci_bridge_t *)ptr)->Capability_Pointer;
|
||||
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
|
||||
if (tmp & 0xff != 0x5)
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
|
||||
//禁用msi
|
||||
tmp = pci_read_config(ptr->bus, ptr->device, ptr->func, cap_ptr); // 读取cap+0x0处的值
|
||||
tmp &= (~(1 << 16));
|
||||
pci_write_config(ptr->bus, ptr->device, ptr->func, cap_ptr, tmp);
|
||||
|
||||
break;
|
||||
case 0x02: // pci to card bus bridge
|
||||
return E_NOT_SUPPORT_MSI;
|
||||
break;
|
||||
|
||||
default: // 不应该到达这里
|
||||
return E_WRONG_HEADER_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取 device structure
|
||||
|
@ -205,34 +205,7 @@ void* pci_read_header(int *type, uchar bus, uchar slot, uchar func, bool add_to_
|
||||
*/
|
||||
void pci_checkAllBuses();
|
||||
|
||||
/**
|
||||
* @brief 启用 Message Signaled Interrupts
|
||||
*
|
||||
* @param header 设备header
|
||||
* @param vector 中断向量号
|
||||
* @param processor 要投递到的处理器
|
||||
* @param edge_trigger 是否边缘触发
|
||||
* @param assert 是否高电平触发
|
||||
*
|
||||
* @return 返回码
|
||||
*/
|
||||
int pci_enable_msi(void * header, uint8_t vector, uint32_t processor, uint8_t edge_trigger, uint8_t assert);
|
||||
|
||||
/**
|
||||
* @brief 禁用指定设备的msi
|
||||
*
|
||||
* @param header pci header
|
||||
* @return int
|
||||
*/
|
||||
int pci_disable_msi(void *header);
|
||||
|
||||
/**
|
||||
* @brief 在已配置好msi寄存器的设备上,使能msi
|
||||
*
|
||||
* @param header 设备头部
|
||||
* @return int 返回码
|
||||
*/
|
||||
int pci_start_msi(void *header);
|
||||
|
||||
/**
|
||||
* @brief 获取 device structure
|
||||
|
10
kernel/driver/timers/Makefile
Normal file
10
kernel/driver/timers/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
all: rtc.o HPET.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
rtc.o: rtc/rtc.c
|
||||
gcc $(CFLAGS) -c rtc/rtc.c -o rtc/rtc.o
|
||||
|
||||
HPET.o: HPET/HPET.c
|
||||
gcc $(CFLAGS) -c HPET/HPET.c -o HPET/HPET.o
|
7
kernel/driver/uart/Makefile
Normal file
7
kernel/driver/uart/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
all: uart.o
|
||||
|
||||
CFLAGS += -I .
|
||||
|
||||
uart.o: uart.c
|
||||
gcc $(CFLAGS) -c uart.c -o uart.o
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <driver/usb/usb.h>
|
||||
#include <driver/pci/pci.h>
|
||||
#include <driver/pci/msi.h>
|
||||
|
||||
#define XHCI_MAX_HOST_CONTROLLERS 4 // 本驱动程序最大支持4个xhci root hub controller
|
||||
#define XHCI_MAX_ROOT_HUB_PORTS 128 // 本驱动程序最大支持127个root hub 端口(第0个保留)
|
||||
|
Reference in New Issue
Block a user