Compare commits

..

3 Commits

10 changed files with 61 additions and 17 deletions

View File

@ -7,7 +7,7 @@
/**
* @name gate_descriptor_t
* @addindex x86_64
*
*
*
*/
typedef struct __gate_descriptor_t
@ -23,12 +23,12 @@ typedef struct __gate_descriptor_t
/**
* @name INTERRUPT_DESCRIPTOR_FLAG_IST
* @addindex x86_64
*
*
* `gate_descriptor_t``flags`
*
*
* `ssp`tss描述符在任务段中的的索引
*/
#define INTERRUPT_DESCRIPTOR_FLAG_IST(ssp) (ssp)
#define INTERRUPT_DESCRIPTOR_FLAG_IST 1
// 在第15位上有一个表示代码段是否存在的标志位代码段总是存在故直接设置为1
#define INTERRUPT_DESCRIPTOR_FLAG_TYPE_INTERRUPT (0x8e << 8)
@ -36,7 +36,7 @@ typedef struct __gate_descriptor_t
/**
* @name idt
*
*
*
*/
extern gate_descriptor_t idt[256];

View File

@ -12,4 +12,6 @@
*/
extern void prepare_stack();
extern u32 TSS[26];
#endif

View File

@ -4,6 +4,18 @@
#include <types.h>
#include <libk/bits.h>
/**
* @details x86_64
*
*
*
* * 0 \~ 2MB使
* * 2MB \~ 4MB
* * 4MB \~ 16MB
* * 16MB \~ ?
* * ? \~ 128MB
*/
/**
* @name MEMM_PAGE_SIZE
* @addindex

View File

@ -116,7 +116,7 @@ typedef void (*memm_free_t)(void *allocator, void *mem);
typedef struct __allocator_t
{
#ifndef MEMM_ALLOCATOR_MAGIC
#define MEMM_ALLOCATOR_MAGIC 0x271fe441
#define MEMM_ALLOCATOR_MAGIC ((u32)0x271fe441)
#endif
// 分配器有效性由此检验,不为`MEMM_ALLOCATOR_MAGIC_NUM`说明获得了一个错误的分配器地址。
// 此值在编译时通过各种方式确定,若

View File

@ -7,7 +7,7 @@ CC = gcc
CCFLAGS = -m64 -mcmodel=large -I ../../include \
-fno-stack-protector -fno-exceptions \
-fno-builtin -nostdinc -nostdlib \
-DMEMM_ALLOCATOR_MAGIC=\"${ALLOCATOR_MAGIC}\"
-DMEMM_ALLOCATOR_MAGIC="(u32)(0x${ALLOCATOR_MAGIC})"
ifdef release
CCFLAGS := ${CCFLAGS} -O2
endif

View File

@ -26,9 +26,6 @@ init64:
lea rax, [systemcall_procedure]
wrmsr
; 加载中断相关寄存器
; 需要加载寄存器IA32_INTERRUPT_SSP_TABLE
jmp kmain
section .multiboot2 align=8

View File

@ -47,7 +47,7 @@ init32:
; 设置gdt_ptr
mov eax, 0x10402a ; gdt_ptr + 2
mov dword [eax], 0x104000 ; gdt
; 加载GDTR和段寄存器
; 加载GDTR、段寄存器和TR寄存器
db 0x66
lgdt [0x104028] ; gdt_ptr
mov ax, 0x10
@ -56,6 +56,8 @@ init32:
mov es, ax
mov fs, ax
mov gs, ax
mov ax, 0x30
ltr ax
; 打开PAE
mov eax, cr4
@ -99,10 +101,13 @@ PD0:
; 分段
gdt:
dq 0
dq 0x0020980000000000 ; 内核态代码段
dq 0x0000920000000000 ; 内核态数据段
dq 0x0020f80000000000 ; 用户态代码段
dq 0x0000f20000000000 ; 用户态数据段
dq 0x0020980000000000 ; 内核态代码段
dq 0x0000920000000000 ; 内核态数据段
dq 0x0020f80000000000 ; 用户态代码段
dq 0x0000f20000000000 ; 用户态数据段
dq 0
dq 0x0000891060000000 ; TSS段低64位
dq 0 ; TSS段高64位
gdt_end:
gdt_ptr: ; 0x104028
@ -120,3 +125,14 @@ idt_ptr: ; 0x104038
global idt
idt:
resq 512 ; 16 bytes per descriptor (512 q-bytes)
section .cpumeta.tss alogn=4096
global TSS
TSS:
dd 0
dq 0x1000000 ; rsp0内核栈
dq 0 ; rsp1
dq 0 ; rsp2
dq 0
dq 0x400000 ; ist1中断栈
resb 104 - ($ - TSS)

View File

@ -139,7 +139,7 @@ impl KernelLogger {
return false;
}
}
return true;
true
};
while !all_end(&indeces, &logs) {
let mut min_ind = None;

View File

@ -206,6 +206,19 @@ impl ToString for Message {
/// .build();
/// ```
///
/// 定义了`message!`宏,简化构造消息的代码:
///
/// ```rust
/// use crate::kernel::tty::tty::BuilderFunctions::*;
///
/// message!(
/// Msg("Hello, "),
/// Msg("Metaverse"),
/// FgColor(Color::GREEN),
/// Msg("!\n"),
/// );
/// ```
///
/// 对于特殊情况可以使用非链式调用:
/// ```rust
/// let mut msg = MessageBuilder::new();

View File

@ -13,10 +13,14 @@ SECTIONS {
{
*(.multiboot2)
}
.cpumeta :
.cpumeta ALIGN(4096) :
{
*(.cpumeta)
}
.cpumeta.tss ALIGN(4096) :
{
*(.cpumeta.tss)
}
. = 16M;
.text :
{