forked from Simple-XX/SimpleKernel
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from digmouse233/lib
Lib
- Loading branch information
Showing
82 changed files
with
24,667 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# vmm | ||
# intr | ||
|
||
虚拟内存管理 | ||
中断管理+键盘输入 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
# This file is a part of Simple-XX/SimpleKernel (https://github.com/Simple-XX/SimpleKernel). | ||
# | ||
# CMakeLists.txt for Simple-XX/SimpleKernel. | ||
|
||
PROJECT(boot C ASM) | ||
|
||
find_asm_source_files(ASM_SOURCE_FILES ${boot_SOURCE_DIR}) | ||
|
||
set(boot_src ${ASM_SOURCE_FILES}) | ||
|
||
add_library(${PROJECT_NAME} OBJECT ${boot_src}) | ||
|
||
target_include_libc_header_files(${PROJECT_NAME}) | ||
target_include_drv_header_files(${PROJECT_NAME}) | ||
target_include_arch_header_files(${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/** | ||
* @file apic.cpp | ||
* @brief APIC 抽象 | ||
* @author Zone.N ([email protected]) | ||
* @version 1.0 | ||
* @date 2021-09-18 | ||
* @copyright MIT LICENSE | ||
* https://github.com/Simple-XX/SimpleKernel | ||
* @par change log: | ||
* <table> | ||
* <tr><th>Date<th>Author<th>Description | ||
* <tr><td>2021-09-18<td>digmouse233<td>迁移到 doxygen | ||
* </table> | ||
*/ | ||
|
||
#include "stdio.h" | ||
#include "assert.h" | ||
#include "intr.h" | ||
#include "cpu.hpp" | ||
#include "apic.h" | ||
|
||
// 64-ia-32-architectures-software-developer-vol-3a-manual#10 | ||
|
||
/// @todo 完善,加入内核 | ||
APIC::APIC(void) { | ||
return; | ||
} | ||
|
||
APIC::~APIC(void) { | ||
return; | ||
} | ||
|
||
/// @see 64-ia-32-architectures-software-developer-vol-3a-manual#10.4.3 | ||
|
||
int32_t APIC::init(void) { | ||
LOCAL_APIC::init(); | ||
IO_APIC::init(); | ||
printf("apic init.\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
/** | ||
* @file apic.h | ||
* @brief APIC 抽象头文件 | ||
* @author Zone.N ([email protected]) | ||
* @version 1.0 | ||
* @date 2021-09-18 | ||
* @copyright MIT LICENSE | ||
* https://github.com/Simple-XX/SimpleKernel | ||
* @par change log: | ||
* <table> | ||
* <tr><th>Date<th>Author<th>Description | ||
* <tr><td>2021-09-18<td>digmouse233<td>迁移到 doxygen | ||
* </table> | ||
*/ | ||
|
||
#ifndef _APIC_H_ | ||
#define _APIC_H_ | ||
|
||
#include "stdint.h" | ||
|
||
/** | ||
* @brief APIC 抽象 | ||
*/ | ||
class APIC { | ||
private: | ||
protected: | ||
public: | ||
APIC(void); | ||
~APIC(void); | ||
static int32_t init(void); | ||
}; | ||
|
||
/** | ||
* @brief 本地 APIC | ||
*/ | ||
class LOCAL_APIC { | ||
private: | ||
protected: | ||
public: | ||
LOCAL_APIC(void); | ||
~LOCAL_APIC(void); | ||
static int32_t init(void); | ||
}; | ||
|
||
/** | ||
* @brief IO APIC | ||
*/ | ||
class IO_APIC { | ||
private: | ||
protected: | ||
public: | ||
IO_APIC(void); | ||
~IO_APIC(void); | ||
static int32_t init(void); | ||
}; | ||
|
||
static APIC apic; | ||
|
||
#endif /* _APIC_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
/** | ||
* @file io_apic.cpp | ||
* @brief IOAPIC 抽象 | ||
* @author Zone.N ([email protected]) | ||
* @version 1.0 | ||
* @date 2021-09-18 | ||
* @copyright MIT LICENSE | ||
* https://github.com/Simple-XX/SimpleKernel | ||
* @par change log: | ||
* <table> | ||
* <tr><th>Date<th>Author<th>Description | ||
* <tr><td>2021-09-18<td>digmouse233<td>迁移到 doxygen | ||
* </table> | ||
*/ | ||
|
||
#include "intr.h" | ||
#include "cpu.hpp" | ||
#include "io.h" | ||
#include "apic.h" | ||
|
||
/// @todo | ||
|
||
IO_APIC::IO_APIC(void) { | ||
return; | ||
} | ||
|
||
IO_APIC::~IO_APIC(void) { | ||
return; | ||
} | ||
|
||
int32_t IO_APIC::init(void) { | ||
printf("io apic init.\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
/** | ||
* @file loacl_apic.cpp | ||
* @brief loacl APIC 抽象 | ||
* @author Zone.N ([email protected]) | ||
* @version 1.0 | ||
* @date 2021-09-18 | ||
* @copyright MIT LICENSE | ||
* https://github.com/Simple-XX/SimpleKernel | ||
* @par change log: | ||
* <table> | ||
* <tr><th>Date<th>Author<th>Description | ||
* <tr><td>2021-09-18<td>digmouse233<td>迁移到 doxygen | ||
* </table> | ||
*/ | ||
|
||
#include "stdio.h" | ||
#include "assert.h" | ||
#include "intr.h" | ||
#include "cpu.hpp" | ||
#include "apic.h" | ||
|
||
/// @see 64-ia-32-architectures-software-developer-vol-3a-manual#10 | ||
|
||
/// @todo 完善,加入内核 | ||
LOCAL_APIC::LOCAL_APIC(void) { | ||
return; | ||
} | ||
|
||
LOCAL_APIC::~LOCAL_APIC(void) { | ||
return; | ||
} | ||
|
||
/// @see 64-ia-32-architectures-software-developer-vol-3a-manual#10.4.3 | ||
|
||
int32_t LOCAL_APIC::init(void) { | ||
// 先判断 cpu 是否支持 | ||
CPU::CPUID cpuid; | ||
if (cpuid.xapic() == false) { | ||
warn("Not support LOCAL_APIC&xAPIC.\n"); | ||
} | ||
if (cpuid.x2apic() == false) { | ||
warn("Not support x2APIC.\n"); | ||
} | ||
uint64_t msr = CPU::READ_MSR(CPU::IA32_APIC_BASE); | ||
// 开启 xAPIC 与 x2APIC | ||
msr |= (CPU::IA32_APIC_BASE_GLOBAL_ENABLE_BIT | | ||
CPU::IA32_APIC_BASE_X2APIC_ENABLE_BIT); | ||
CPU::WRITE_MSR(CPU::IA32_APIC_BASE, msr); | ||
// 设置 SIVR | ||
msr = CPU::READ_MSR(CPU::IA32_X2APIC_SIVR); | ||
if (cpuid.eoi() == true) { | ||
msr |= CPU::IA32_X2APIC_SIVR_EOI_ENABLE_BIT; | ||
} | ||
msr |= CPU::IA32_X2APIC_SIVR_APIC_ENABLE_BIT; | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_SIVR, msr); | ||
|
||
// 屏蔽所有 LVT | ||
msr = 0; | ||
msr |= CPU::IA32_X2APIC_LVT_MASK_BIT; | ||
msr = 0x10000; | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_CMCI, msr); | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_LVT_TIMER, msr); | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_LVT_THERMAL, msr); | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_LVT_PMI, msr); | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_LVT_LINT0, msr); | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_LVT_LINT1, msr); | ||
CPU::WRITE_MSR(CPU::IA32_X2APIC_LVT_ERROR, msr); | ||
|
||
printf("local apic init.\n"); | ||
return 0; | ||
} |
Oops, something went wrong.