Supprimer un message
rfr
Ah tous ces gens qui font des trucs utiles ...
Une partie de mon dernier projet:
void k_init_taskm() {
k_memset(&system_tss, 0, sizeof(struct tss_t));
k_memset(&user_tss, 0, sizeof(struct tss_t));
level0_stack = k_allocate_page();
level0_stack += 0x1000;
level3_stack = k_allocate_page();
level3_stack += 0x1000;
system_tss.tss_cr3 = 0x1000;
system_tss.tss_ss = 0x10;
system_tss.tss_esp0 = level0_stack;
user_tss.tss_cr3 = 0x10000;
user_tss.tss_cs = 0x1b;
user_tss.tss_ds = 0x23;
user_tss.tss_eax = 0x0;
user_tss.tss_ebp = 0x0;
user_tss.tss_ebx = 0x0;
user_tss.tss_ecx = 0x0;
user_tss.tss_edi = 0x0;
user_tss.tss_edx = 0x0;
user_tss.tss_eflags = 0x202;
user_tss.tss_eip = (unsigned long) k_do_nothing;
user_tss.tss_es = 0x23;
user_tss.tss_esi = 0x0;
user_tss.tss_esp0 = level0_stack;
user_tss.tss_esp = level3_stack;
user_tss.tss_fs = 0x23;
user_tss.tss_gs = 0x23;
user_tss.tss_ldtss = 0x0;
user_tss.tss_ss = 0x23;
user_tss.tss_ss0 = 0x10;
k_fill_task_descriptor(6, (unsigned long) &system_tss, 0);
k_fill_task_descriptor(7, (unsigned long) &user_tss, 3);
k_fill_task_gate(8, 0x3b, 3);
k_sys_ldtr();
k_jump_to_user_mode();
Une partie de mon dernier projet:
void k_init_taskm() {
k_memset(&system_tss, 0, sizeof(struct tss_t));
k_memset(&user_tss, 0, sizeof(struct tss_t));
level0_stack = k_allocate_page();
level0_stack += 0x1000;
level3_stack = k_allocate_page();
level3_stack += 0x1000;
system_tss.tss_cr3 = 0x1000;
system_tss.tss_ss = 0x10;
system_tss.tss_esp0 = level0_stack;
user_tss.tss_cr3 = 0x10000;
user_tss.tss_cs = 0x1b;
user_tss.tss_ds = 0x23;
user_tss.tss_eax = 0x0;
user_tss.tss_ebp = 0x0;
user_tss.tss_ebx = 0x0;
user_tss.tss_ecx = 0x0;
user_tss.tss_edi = 0x0;
user_tss.tss_edx = 0x0;
user_tss.tss_eflags = 0x202;
user_tss.tss_eip = (unsigned long) k_do_nothing;
user_tss.tss_es = 0x23;
user_tss.tss_esi = 0x0;
user_tss.tss_esp0 = level0_stack;
user_tss.tss_esp = level3_stack;
user_tss.tss_fs = 0x23;
user_tss.tss_gs = 0x23;
user_tss.tss_ldtss = 0x0;
user_tss.tss_ss = 0x23;
user_tss.tss_ss0 = 0x10;
k_fill_task_descriptor(6, (unsigned long) &system_tss, 0);
k_fill_task_descriptor(7, (unsigned long) &user_tss, 3);
k_fill_task_gate(8, 0x3b, 3);
k_sys_ldtr();
k_jump_to_user_mode();