Skip to content

Commit

Permalink
feat(intr): clint timer inited
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed May 30, 2024
1 parent 912ea99 commit bb50602
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/kernel/arch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ add_library(${PROJECT_NAME} OBJECT
${PROJECT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/boot.S
>
${PROJECT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/arch_main.cpp
${PROJECT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/intr.cpp
${PROJECT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/interrupt.cpp
)

# 添加定义
Expand Down
63 changes: 63 additions & 0 deletions src/kernel/arch/riscv64/interrupt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

/**
* @file interrupt.h
* @brief 中断处理
* @author Zone.N ([email protected])
* @version 1.0
* @date 2023-07-15
* @copyright MIT LICENSE
* https://github.com/Simple-XX/SimpleKernel
* @par change log:
* <table>
* <tr><th>Date<th>Author<th>Description
* <tr><td>2023-07-15<td>Zone.N ([email protected])<td>创建文件
* </table>
*/

#ifndef SIMPLEKERNEL_SRC_KERNEL_INCLUDE_INTERRUPT_H_
#define SIMPLEKERNEL_SRC_KERNEL_INCLUDE_INTERRUPT_H_

#include <cstdint>

#include "cpu.hpp"
#include "interrupt_base.h"
#include "stdio.h"

/**
* @brief core-local interrupt controller
* 本地核心中断控制器
* 用于控制 excp 与 intr
*/
class Clint {
public:
Clint() {
// 开启内部中断
Cpu::WriteSie(Cpu::ReadSie() | Cpu::kSieSsie);
printf("Clint init.\n");
}

/// @name 构造/析构函数
/// @{
Clint(const Clint &) = default;
Clint(Clint &&) = default;
auto operator=(const Clint &) -> Clint & = default;
auto operator=(Clint &&) -> Clint & = default;
~Clint() = default;
/// @}
};

class Interrupt : public InterruptBase {
public:
Interrupt() { Clint(); }

/// @name 构造/析构函数
/// @{
Interrupt(const Interrupt &) = default;
Interrupt(Interrupt &&) = default;
auto operator=(const Interrupt &) -> Interrupt & = default;
auto operator=(Interrupt &&) -> Interrupt & = default;
~Interrupt() = default;
/// @}
};

#endif /* SIMPLEKERNEL_SRC_KERNEL_INCLUDE_INTERRUPT_H_ */
12 changes: 0 additions & 12 deletions src/kernel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ uint32_t main(uint32_t argc, uint8_t* argv) {

IntrInit(argc, argv);

IntrInit(argc, argv);

IntrInit(argc, argv);

IntrInit(argc, argv);

IntrInit(argc, argv);

IntrInit(argc, argv);

IntrInit(argc, argv);

// 进入死循环
while (1) {
;
Expand Down

0 comments on commit bb50602

Please sign in to comment.