Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.associations": {
"*.TXT": "txt",
"agp_backend.h": "c",
"vmalloc.h": "c",
"slab.h": "c"
}
}
11 changes: 8 additions & 3 deletions arch/i386/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ int_msg:

.globl boot_gdt_descr
.globl idt_descr
.globl cpu_gdt_descr
.globl cpu_gdt_descr /* ����GDT�ĵ�ַ�����ǵĴ�С������ڸ������� */

ALIGN
# early boot GDT descriptor (must use 1:1 address mapping)
Expand Down Expand Up @@ -484,6 +484,9 @@ ENTRY(boot_gdt_table)
/*
* The Global Descriptor Table contains 28 quadwords, per-CPU.
*/
/* ����δʹ�õ����Ŀ����Ϊ��ʹ����һ����ʵ��������ܹ�����ͬһ��32�ֽڵ�Ӳ�����ٻ������� */
/* GDT: ȫ������������GDT�������еĵ�ַ�ʹ�С�����gdtr���ƼĴ�����
LDT���ֲ�������������ǰ����ʹ�õ�LDT��ַ�ʹ�С���ڿ��ƼĴ����� */
.align PAGE_SIZE_asm
ENTRY(cpu_gdt_table)
.quad 0x0000000000000000 /* NULL descriptor */
Expand All @@ -492,7 +495,7 @@ ENTRY(cpu_gdt_table)
.quad 0x0000000000000000 /* 0x1b reserved */
.quad 0x0000000000000000 /* 0x20 unused */
.quad 0x0000000000000000 /* 0x28 unused */
.quad 0x0000000000000000 /* 0x33 TLS entry 1 */
.quad 0x0000000000000000 /* 0x33 TLS entry 1 */ /* 3���ֲ��̴߳洢(TLS)�Σ����ֻ����������߳�Ӧ�ó���ʹ�����3���ֲ����̵߳����ݶ� */
.quad 0x0000000000000000 /* 0x3b TLS entry 2 */
.quad 0x0000000000000000 /* 0x43 TLS entry 3 */
.quad 0x0000000000000000 /* 0x4b reserved */
Expand All @@ -504,10 +507,11 @@ ENTRY(cpu_gdt_table)
.quad 0x00cffa000000ffff /* 0x73 user 4GB code at 0x00000000 */
.quad 0x00cff2000000ffff /* 0x7b user 4GB data at 0x00000000 */

.quad 0x0000000000000000 /* 0x80 TSS descriptor */
.quad 0x0000000000000000 /* 0x80 TSS descriptor *//* ����״̬��(TSS)��ÿ����������һ�� */
.quad 0x0000000000000000 /* 0x88 LDT descriptor */

/* Segments used for calling PnP BIOS */
/* ֧�ּ��弴��(PnP)���ܵ�BIOS���������ص�5���� */
.quad 0x00c09a0000000000 /* 0x90 32-bit code */
.quad 0x00809a0000000000 /* 0x98 16-bit code */
.quad 0x0080920000000000 /* 0xa0 16-bit data */
Expand All @@ -517,6 +521,7 @@ ENTRY(cpu_gdt_table)
* The APM segments have byte granularity and their bases
* and limits are set at run time.
*/
/* �߼���Դ����(AMP)��ص�3���� */
.quad 0x00409a0000000000 /* 0xb8 APM CS code */
.quad 0x00009a0000000000 /* 0xc0 APM CS 16 code (16 bit) */
.quad 0x0040920000000000 /* 0xc8 APM DS data */
Expand Down
8 changes: 4 additions & 4 deletions include/asm-arm/segment.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef __ASM_ARM_SEGMENT_H
#define __ASM_ARM_SEGMENT_H

#define __KERNEL_CS 0x0
#define __KERNEL_DS 0x0
#define __KERNEL_CS 0x0 /* 内核代码段 */
#define __KERNEL_DS 0x0 /* 内核数据段 */

#define __USER_CS 0x1
#define __USER_DS 0x1
#define __USER_CS 0x1 /* 用户代码段 */
#define __USER_DS 0x1 /* 用户数据段 */

#endif /* __ASM_ARM_SEGMENT_H */

2 changes: 1 addition & 1 deletion include/asm-x86_64/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <linux/config.h>

/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
#define PAGE_SHIFT 12 /* 页大小为2^12 = 4096字节 */
#ifdef __ASSEMBLY__
#define PAGE_SIZE (0x1 << PAGE_SHIFT)
#else
Expand Down
Binary file added md_file/img/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added md_file/img/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions md_file/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### 段选择符和段寄存器

逻辑地址 = 段标识符 + 段内相对地址偏移量

段标识符:16位,称为段选择符 = [15:3]索引号 + [2]TI表指示器 + [1:0]RPL请求者特权级

偏移量:32位

段寄存器:存放段选择符(cs, ss, ds, es, fs, gs)

![img](./img/1.png)

### 段描述符字段

段描述符描述了段的特征

GDT: 全局描述符表。GDT在主存中的地址和大小存放在gdtr控制寄存器中

LDT:局部描述符表。当前正被使用的LDT地址和大小放在控制寄存器中

![段描述符字段](./img/0.png)
1 change: 1 addition & 0 deletions readme_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
arch和include目录下包含了linux所支持的不同的硬件平台