2023-12-03 17:08:00 +08:00
|
|
|
|
#ifndef KERNEL_H
|
|
|
|
|
#define KERNEL_H 1
|
|
|
|
|
|
|
|
|
|
#include <types.h>
|
2023-12-13 02:24:25 +08:00
|
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
|
|
|
|
|
|
#include <kernel/arch/x86_64/kernel.h>
|
|
|
|
|
|
2024-01-14 21:52:10 +08:00
|
|
|
|
#define ISA_NAME "x86_64"
|
2023-12-13 02:24:25 +08:00
|
|
|
|
|
|
|
|
|
#endif
|
2023-12-03 17:08:00 +08:00
|
|
|
|
|
2024-02-18 03:53:54 +08:00
|
|
|
|
/**
|
|
|
|
|
* @name KERNEL_TODO
|
|
|
|
|
*
|
|
|
|
|
* 表示此处还没有实现代码。
|
|
|
|
|
*/
|
2023-12-03 17:08:00 +08:00
|
|
|
|
#define KERNEL_TODO() \
|
|
|
|
|
while (true) \
|
|
|
|
|
{ \
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-18 03:53:54 +08:00
|
|
|
|
/**
|
|
|
|
|
* @name simple_lock
|
|
|
|
|
*
|
|
|
|
|
* 简易同步锁。有如下两个方法:
|
|
|
|
|
*
|
|
|
|
|
* ```c
|
|
|
|
|
* #define simple_lock_lock(lock)
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* 获取一个锁。
|
|
|
|
|
*
|
|
|
|
|
* ```c
|
|
|
|
|
* #define simple_lock_unlock(lock)
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* 解开一个锁。
|
|
|
|
|
*/
|
2023-12-03 17:08:00 +08:00
|
|
|
|
#define simple_lock_lock(lock) \
|
|
|
|
|
{ \
|
|
|
|
|
while (lock == true) \
|
|
|
|
|
; \
|
|
|
|
|
(lock) = true; \
|
|
|
|
|
}
|
|
|
|
|
#define simple_lock_unlock(lock) (lock) = false;
|
|
|
|
|
|
2024-02-18 03:53:54 +08:00
|
|
|
|
/**
|
|
|
|
|
* @name kmain_rust
|
|
|
|
|
*
|
|
|
|
|
* rust内核主程序。
|
|
|
|
|
*/
|
2024-01-20 23:50:03 +08:00
|
|
|
|
extern void kmain_rust();
|
|
|
|
|
|
2024-02-18 03:53:54 +08:00
|
|
|
|
/**
|
|
|
|
|
* @name kend
|
|
|
|
|
*
|
|
|
|
|
* 内核结束的标记。
|
|
|
|
|
*
|
|
|
|
|
* 此变量不代表任何值,但是此变量的地址被安排到了内核镜像的末尾,用于标志内核结束的位置。
|
|
|
|
|
*/
|
|
|
|
|
extern void *kend;
|
2023-12-03 17:08:00 +08:00
|
|
|
|
|
|
|
|
|
#endif
|