/* By Marcus Xing include/proc.h 与进程有关的头文件 */ /* forward include: type.h protect.h */ #ifndef _PROC_H_ #define _PROC_H_ #define MAX_PROC 50 /* 进程的最大个数 */ #define STACK_A 1024 /* 进程A的堆栈大小 */ #define STACK_B 1024 /* 进程B的堆栈大小 */ #define STACK_C 1024 /* 进程C的堆栈大小 */ #define STACK_PROC_TTY 1024 /* 终端进程的堆栈大小 */ /* 所有进程的堆栈大小 */ #define ALL_PROC_STACK_SPACE (STACK_A + / STACK_B + / STACK_C + / STACK_PROC_TTY / ) /* PCB中的栈结构 */ typedef struct s_stack_frame { u32 fs; u32 gs; u32 es; u32 ds; u32 edi; u32 esi; u32 ebp; u32 dummy_esp; u32 ebx; u32 edx; u32 ecx; u32 eax; u32 save_ret_addr; /* 中断程序中的SAVE函数的返回地址 */ u32 eip; u32 cs; u32 eflags; u32 esp; u32 ss; }Stack_Frame; /* PCB结构 */ typedef struct s_pcb { Stack_Frame stack_frame; /* 栈结构 */ u16 LDT_Selector; /* 此进程在GDT的LDT选择子 */ Descriptor LDT[2]; /* 此进程的LDT,有2个成员 */ u32 proc_id; /* 此进程的进程号 */ char proc_name[16]; /* 此进程的名字,容纳15个字符 */ /* 以下两项用于进程调度 */ int ticks; /* 每个进程当前的ticks值,初始化为priority */ int priority; /* 每个进程的初始ticks值 */ int bind_tty; /* 每个进程绑定的TTY */ }PCB; /* TSS的结构 */ typedef struct s_tss { u32 backlink; u32 esp0; u32 ss0; u32 esp1; u32 ss1; u32 esp2; u32 ss2; u32 cr3; u32 eip; u32 flags; u32 eax; u32 ecx; u32 edx; u32 ebx; u32 esp; u32 ebp; u32 esi; u32 edi; u32 es; u32 cs; u32 ss; u32 ds; u32 fs; u32 gs; u32 ldt; u16 trap; u16 iobase; /* I/O位图基址大于或等于TSS段界限,就表示没有I/O许可位图 */ }TSS; /* 各进程的与众不同的部分结构,便于添加一个新的进程 */ typedef struct s_proc_unique { u32 proc_exec_addr; /* 进程执行体的地址 */ u32 proc_stack_size; /* 进程的私有堆栈的字节大小 */ char proc_name[16]; /* 进程的名字 */ }Proc_Unique; #endif