Add: Set same memory space for userland and kernel using paging

This commit is contained in:
brice.boisson 2023-09-06 12:59:06 +09:00
parent 1734b485b5
commit 191dc9c59a
3 changed files with 7 additions and 7 deletions

View File

@ -78,20 +78,20 @@ void init_gdt(void)
// Code
gdt[1] = init_descriptor((struct segment_desc_param) { .Limit_1 = 0xFFFF,
.Base = 0, .Type = 0x0B, .S = 1, .DPL = 0, .P = 1,
.Limit_2 = 0x02, .AVL = 0, .L = 0, .D_B = 1, .G = 1 });
.Limit_2 = 0x0F, .AVL = 0, .L = 0, .D_B = 1, .G = 1 });
// Data
gdt[2] = init_descriptor((struct segment_desc_param) { .Limit_1 = 0xFFFF,
.Base = 0, .Type = 2, .S = 1, .DPL = 0, .P = 1,
.Limit_2 = 0x02, .AVL = 0, .L = 0, .D_B = 1, .G = 1 });
.Limit_2 = 0x0F, .AVL = 0, .L = 0, .D_B = 1, .G = 1 });
// Code
gdt[3] = init_descriptor((struct segment_desc_param) { .Limit_1 = 0xFFFF,
.Base = 0x30000, .Type = 0x0B, .S = 1, .DPL = 3, .P = 1,
.Base = 0, .Type = 0x0B, .S = 1, .DPL = 3, .P = 1,
.Limit_2 = 0x0F, .AVL = 0, .L = 0, .D_B = 1, .G = 1 });
// Data
gdt[4] = init_descriptor((struct segment_desc_param) { .Limit_1 = 0xFFFF,
.Base = 0x30000, .Type = 2, .S = 1, .DPL = 3, .P = 1,
.Base = 0, .Type = 2, .S = 1, .DPL = 3, .P = 1,
.Limit_2 = 0x0F, .AVL = 0, .L = 0, .D_B = 1, .G = 1 });
user_land_tss.ssp = 0x0;

View File

@ -26,7 +26,7 @@ void launch_process(int tss, int memory_start, int userland_stack, int userland_
and $0xffffbfff, %%eax \n \
push %%eax \n \
push %5 \n \
push $0x0 \n \
push $0x30000 \n \
movl $0x20000, %6 \n \
movw %7, %%ax \n \
movw %%ax, %%ds \n \

View File

@ -7,14 +7,14 @@ void userland(void)
// asm volatile ("movl $2, %eax; int $0x30");
// asm("movl %%eax,%0" : "=r"(res));
// asm volatile ("int $0x30");
char *str = (void *) 0x100;
char *str = (void *) 0x30100;
str[0] = 'H';
str[1] = 'e';
str[2] = 'l';
str[3] = 'l';
str[4] = 'o';
str[5] = '\0';
asm volatile ("mov $1, %%eax; movl $0x30100, %%ebx; int $0x30; movl %%eax, %0" : "=r" (res));
asm volatile ("mov $1, %%eax; movl $0x30100, %%ebx; int $0x30; movl %%eax, %1" : "=m" (str), "=r" (res));
// asm volatile ("mov $1, %%eax; movl %0, %%ebx; int $0x30" : "=m" (str));
// asm ("mov $1, %eax; int $0x30");
// asm ("movl %0, %eax; int $0x30" : "=m" (res));