feat: chargement pmode complet jusqu'à lancement du code pour la décompression
This commit is contained in:
parent
b565d073c7
commit
63f7e530cc
|
@ -1,7 +1,10 @@
|
||||||
target remote localhost:1234
|
target remote localhost:1234
|
||||||
set disassembly-flavor att
|
set disassembly-flavor att
|
||||||
symbol-file ./system/realmode/setup.sym
|
add-symbol-file ./system/realmode/setup.sym 0x902f6
|
||||||
set architecture i8086
|
set architecture i8086
|
||||||
break *0x90200
|
break *0x90200
|
||||||
cont
|
cont
|
||||||
clear *0x90200
|
clear *0x90200
|
||||||
|
break main
|
||||||
|
cont
|
||||||
|
clear main
|
||||||
|
|
|
@ -882,6 +882,11 @@ class Source(Dashboard.Module):
|
||||||
if not gdb.selected_thread().is_stopped():
|
if not gdb.selected_thread().is_stopped():
|
||||||
return []
|
return []
|
||||||
# try to fetch the current line (skip if no line information)
|
# try to fetch the current line (skip if no line information)
|
||||||
|
arch = gdb.parameter('architecture');
|
||||||
|
if arch=="i8086":
|
||||||
|
realpc=int(gdb.parse_and_eval('$pc'))+int(gdb.parse_and_eval('$cs'))*16
|
||||||
|
sal = gdb.find_pc_line(realpc)
|
||||||
|
else:
|
||||||
sal = gdb.selected_frame().find_sal()
|
sal = gdb.selected_frame().find_sal()
|
||||||
current_line = sal.line
|
current_line = sal.line
|
||||||
if current_line == 0:
|
if current_line == 0:
|
||||||
|
@ -962,7 +967,12 @@ instructions constituting the current statement are marked, if available."""
|
||||||
if not gdb.selected_thread().is_stopped():
|
if not gdb.selected_thread().is_stopped():
|
||||||
return []
|
return []
|
||||||
line_info = None
|
line_info = None
|
||||||
|
arch = gdb.parameter('architecture');
|
||||||
frame = gdb.selected_frame() # PC is here
|
frame = gdb.selected_frame() # PC is here
|
||||||
|
if arch=="i8086":
|
||||||
|
realpc=frame.pc()+int(gdb.parse_and_eval('$cs'))*16
|
||||||
|
else:
|
||||||
|
realpc=frame.pc()
|
||||||
disassemble = frame.architecture().disassemble
|
disassemble = frame.architecture().disassemble
|
||||||
try:
|
try:
|
||||||
# try to fetch the function boundaries using the disassemble command
|
# try to fetch the function boundaries using the disassemble command
|
||||||
|
@ -971,21 +981,20 @@ instructions constituting the current statement are marked, if available."""
|
||||||
end = int(re.split('[ :]', output[-3][3:], 1)[0], 16)
|
end = int(re.split('[ :]', output[-3][3:], 1)[0], 16)
|
||||||
asm = disassemble(start, end_pc=end)
|
asm = disassemble(start, end_pc=end)
|
||||||
# find the location of the PC
|
# find the location of the PC
|
||||||
pc_index = next(index for index, instr in enumerate(asm)
|
pc_index = next(index for index, instr in enumerate(asm) if instr['addr'] == realpc)
|
||||||
if instr['addr'] == frame.pc())
|
|
||||||
start = max(pc_index - self.context, 0)
|
start = max(pc_index - self.context, 0)
|
||||||
end = pc_index + self.context + 1
|
end = pc_index + self.context + 1
|
||||||
asm = asm[start:end]
|
asm = asm[start:end]
|
||||||
# if there are line information then use it, it may be that
|
# if there are line information then use it, it may be that
|
||||||
# line_info is not None but line_info.last is None
|
# line_info is not None but line_info.last is None
|
||||||
line_info = gdb.find_pc_line(frame.pc())
|
line_info = gdb.find_pc_line(realpc)
|
||||||
line_info = line_info if line_info.last else None
|
line_info = line_info if line_info.last else None
|
||||||
except (gdb.error, StopIteration):
|
except (gdb.error, StopIteration):
|
||||||
# if it is not possible (stripped binary or the PC is not present in
|
# if it is not possible (stripped binary or the PC is not present in
|
||||||
# the output of `disassemble` as per issue #31) start from PC and
|
# the output of `disassemble` as per issue #31) start from PC and
|
||||||
# end after twice the context
|
# end after twice the context
|
||||||
try:
|
try:
|
||||||
asm = disassemble(frame.pc(), count=2 * self.context + 1)
|
asm = disassemble(realpc, count=2 * self.context + 1)
|
||||||
except gdb.error as e:
|
except gdb.error as e:
|
||||||
msg = '{}'.format(e)
|
msg = '{}'.format(e)
|
||||||
return [ansi(msg, R.style_error)]
|
return [ansi(msg, R.style_error)]
|
||||||
|
@ -1046,7 +1055,7 @@ instructions constituting the current statement are marked, if available."""
|
||||||
format_string = '{}{}{}{}{}'
|
format_string = '{}{}{}{}{}'
|
||||||
indicator = ' '
|
indicator = ' '
|
||||||
text = ' ' + highlighter.process(text)
|
text = ' ' + highlighter.process(text)
|
||||||
if addr == frame.pc():
|
if addr == realpc:
|
||||||
if not R.ansi:
|
if not R.ansi:
|
||||||
indicator = '>'
|
indicator = '>'
|
||||||
addr_str = ansi(addr_str, R.style_selected_1)
|
addr_str = ansi(addr_str, R.style_selected_1)
|
||||||
|
|
|
@ -91,12 +91,10 @@ u8 testA20(void);
|
||||||
void enableA20kbc(void);
|
void enableA20kbc(void);
|
||||||
void enableA20fast(void);
|
void enableA20fast(void);
|
||||||
u8 enableA20(void);
|
u8 enableA20(void);
|
||||||
void memset(void *dst, u8 val, u32 count, u32 size);
|
void memcpyto(void *src, void *dst, u32 count);
|
||||||
void memcpy(void *src, void *dst, u32 count, u32 size);
|
|
||||||
void initselectors(u32 executingoffset);
|
|
||||||
void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags, gdtdes * desc);
|
void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags, gdtdes * desc);
|
||||||
void initgdt();
|
void initgdt();
|
||||||
void maskinterrupts(void);
|
void maskinterrupts(void);
|
||||||
void initcoprocessor(void);
|
void initcoprocessor(void);
|
||||||
void initpmode(u32 offset);
|
void initpmode();
|
||||||
void main(void);
|
void main(void);
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
||||||
/* */
|
/* */
|
||||||
extern restart;
|
extern restart;
|
||||||
|
int main(u8* info);
|
||||||
|
|
52
lib/gdt.c
52
lib/gdt.c
|
@ -6,9 +6,61 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
/* registre gdt */
|
||||||
|
static struct gdtr gdtreg;
|
||||||
|
|
||||||
|
/* table de GDT */
|
||||||
|
static gdtdes gdt[GDT_SIZE];
|
||||||
|
|
||||||
/* TSS */
|
/* TSS */
|
||||||
static struct tss tss0;
|
static struct tss tss0;
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Créé un descripteur GDT */
|
||||||
|
|
||||||
|
void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags, gdtdes * desc)
|
||||||
|
{
|
||||||
|
desc->lim0_15 = (limite & 0xffff);
|
||||||
|
desc->base0_15 = (base & 0xffff);
|
||||||
|
desc->base16_23 = (base & 0xff0000) >> 16;
|
||||||
|
desc->acces = acces;
|
||||||
|
desc->lim16_19 = (limite & 0xf0000) >> 16;
|
||||||
|
desc->flags = (flags & 0xf);
|
||||||
|
desc->base24_31 = (base & 0xff000000) >> 24;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Initialise la GDT */
|
||||||
|
|
||||||
|
void initgdt(u32 offset)
|
||||||
|
{
|
||||||
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]); /* descripteur nul */
|
||||||
|
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING0 | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[1]); /* code -> SEL_KERNEL_CODE */
|
||||||
|
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[2]); /* pile -> SEL_KERNEL_STACK */
|
||||||
|
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING3 | SEG_CONFORMING | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[3]); /* code -> SEL_USER_CODE */
|
||||||
|
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[4]); /* pile -> SEL_USER_STACK */
|
||||||
|
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[5]); /* data -> SEL_KERNEL_DATA */
|
||||||
|
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[6]); /* data -> SEL_USER_DATA */
|
||||||
|
|
||||||
|
tss0.trapflag = 0x00;
|
||||||
|
tss0.iomap = 0x00;
|
||||||
|
tss0.esp0 = 0x6000;
|
||||||
|
tss0.ss0 = SEL_TSS;
|
||||||
|
|
||||||
|
makegdtdes(&tss0, 0x67, SEG_PRESENT | SEG_CODE | SEG_RING3 | SEG_ACCESSED, 0x00, &gdt[7]); /* descripteur de tss */
|
||||||
|
|
||||||
|
/* initialise le registre gdt */
|
||||||
|
gdtreg.limite = GDT_SIZE * sizeof(gdtdes);
|
||||||
|
gdtreg.base = GDT_ADDR;
|
||||||
|
/* recopie de la GDT a son adresse */
|
||||||
|
memcpy(&gdt, (u8 *) gdtreg.base, gdtreg.limite, 1);
|
||||||
|
/* chargement du registre GDT */
|
||||||
|
lgdt(gdtreg);
|
||||||
|
/* initialisation des segments */
|
||||||
|
initselectors(offset);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
/* Initialise les selecteurs avec la GDT */
|
/* Initialise les selecteurs avec la GDT */
|
||||||
|
|
||||||
|
|
14
makefile
14
makefile
|
@ -1,4 +1,4 @@
|
||||||
DEBUG=exec gnome-terminal --geometry=120x40+1+1 -x ./debug/debug.sh
|
DEBUG=exec gnome-terminal --geometry=120x55+1+1 -x ./debug/debug.sh
|
||||||
REMOVE=rm -f
|
REMOVE=rm -f
|
||||||
INSTALL=sudo apt-get install
|
INSTALL=sudo apt-get install
|
||||||
COPY=cp
|
COPY=cp
|
||||||
|
@ -81,15 +81,15 @@ backup: clean
|
||||||
cd ..
|
cd ..
|
||||||
tar cf - Source\ C | gzip -f - > backup.tar.gz
|
tar cf - Source\ C | gzip -f - > backup.tar.gz
|
||||||
|
|
||||||
test: programs bits32 harddisk qemu
|
test: tools programs bits32 harddisk qemu
|
||||||
|
|
||||||
test64: programs bits64 uefi qemu64
|
test64: tools programs bits64 uefi qemu64
|
||||||
|
|
||||||
retest: littleclean test
|
retest: littleclean test
|
||||||
|
|
||||||
retest64: littleclean test64
|
retest64: littleclean test64
|
||||||
|
|
||||||
testbochs: programs bits32 harddisk bochs-debug
|
testbochs: tools programs bits32 harddisk bochs-debug
|
||||||
|
|
||||||
view:
|
view:
|
||||||
hexdump -C ./final/harddisk.img.final|head -c10000
|
hexdump -C ./final/harddisk.img.final|head -c10000
|
||||||
|
@ -104,15 +104,15 @@ redebug64: littleclean debug-system64
|
||||||
|
|
||||||
kernel: debug-kernel
|
kernel: debug-kernel
|
||||||
|
|
||||||
debug-boot: programs bits32 harddisk qemu-debug
|
debug-boot: tools programs bits32 harddisk qemu-debug
|
||||||
sleep 2
|
sleep 2
|
||||||
$(DEBUG) ./debug/boot.txt
|
$(DEBUG) ./debug/boot.txt
|
||||||
|
|
||||||
debug-system: programs bits32 harddisk qemu-debug
|
debug-system: tools programs bits32 harddisk qemu-debug
|
||||||
sleep 2
|
sleep 2
|
||||||
$(DEBUG) ./debug/system.txt
|
$(DEBUG) ./debug/system.txt
|
||||||
|
|
||||||
debug-system64: programs bits64 uefi qemu-debug64
|
debug-system64: tools programs bits64 uefi qemu-debug64
|
||||||
sleep 2
|
sleep 2
|
||||||
$(DEBUG) ./debug/system.txt
|
$(DEBUG) ./debug/system.txt
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ togit: clean indent
|
||||||
piggy.o: piggy.S
|
piggy.o: piggy.S
|
||||||
$(ASM) $@ $^
|
$(ASM) $@ $^
|
||||||
|
|
||||||
system: systemc.o system.o ../lib/libs.o
|
system: system.o system_asm.o ../lib/libs.o
|
||||||
$(LINK) -T system.ld system.o ../lib/libs.o
|
$(LINK) -T system.ld system.o ../lib/libs.o
|
||||||
$(OBJDEBUG) system system.sym
|
$(OBJDEBUG) system system.sym
|
||||||
$(NM) system > system.map
|
$(NM) system > system.map
|
||||||
|
@ -51,10 +51,10 @@ piggy.S: system.bin.gz
|
||||||
realmode/setup.bin:
|
realmode/setup.bin:
|
||||||
make -C realmode
|
make -C realmode
|
||||||
|
|
||||||
systemc.o: system.c
|
system.o: system.c
|
||||||
$(GCC) $@ $^
|
$(GCC) $@ $^
|
||||||
|
|
||||||
system.o: system.S
|
system_asm.o: system_asm.S
|
||||||
$(ASM) $@ $^
|
$(ASM) $@ $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
GCC=gcc -O0 -g -nostdinc -ffreestanding -Wall -Wstrict-prototypes -fno-stack-protector -march=i386 -m16 -mpreferred-stack-boundary=2 -mregparm=3 -fno-pic -fno-strict-aliasing -mno-mmx -mno-sse -w -I ../../include -c
|
GCC=gcc -O0 -g -nostdinc -ffreestanding -Wall -Wstrict-prototypes -fno-stack-protector -march=i386 -m16 -fno-pic -fno-strict-aliasing -mno-mmx -mno-sse -w -I ../../include -c
|
||||||
ASM=gcc -O0 -m16 -march=i386 -fno-pic -D__ASSEMBLY__ -I ../ -I ../../include -c -o
|
ASM=gcc -O0 -m16 -march=i386 -fno-pic -D__ASSEMBLY__ -I ../ -I ../../include -c -o
|
||||||
LINK=ld -m elf_i386 -n
|
LINK=ld -m elf_i386 -n
|
||||||
CONVERT=dos2unix
|
CONVERT=dos2unix
|
||||||
|
@ -13,8 +13,8 @@ $(eval VERSION=$(shell git describe --tags))
|
||||||
all: setup.bin
|
all: setup.bin
|
||||||
sync
|
sync
|
||||||
|
|
||||||
setup: setupc.o setup.o
|
setup: setupc.o setup.o setup32.o
|
||||||
$(LINK) -T setup.ld setupc.o setup.o
|
$(LINK) -T setup.ld setupc.o setup.o setup32.o
|
||||||
|
|
||||||
setup.bin: setup
|
setup.bin: setup
|
||||||
$(OBJCOPY) $^ $@
|
$(OBJCOPY) $^ $@
|
||||||
|
@ -27,6 +27,9 @@ setupc.o: setup.c
|
||||||
setup.o: setup.S
|
setup.o: setup.S
|
||||||
$(ASM) $@ $^
|
$(ASM) $@ $^
|
||||||
|
|
||||||
|
setup32.o: pmode.S
|
||||||
|
$(ASM) $@ $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(REMOVE) setup
|
$(REMOVE) setup
|
||||||
$(REMOVE) *.o
|
$(REMOVE) *.o
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "memory.h"
|
||||||
|
#include "gdt.h"
|
||||||
|
.text
|
||||||
|
.code16
|
||||||
|
|
||||||
|
.global gotopmode
|
||||||
|
gotopmode:
|
||||||
|
jmp 1f
|
||||||
|
1:
|
||||||
|
xorl %eax,%eax
|
||||||
|
movl %ds,%ax
|
||||||
|
shl $0x4,%eax
|
||||||
|
add %eax,(2f)
|
||||||
|
movl %cr0, %eax
|
||||||
|
orb $0x01, %al
|
||||||
|
movl %eax, %cr0
|
||||||
|
.byte 0x66, 0xea
|
||||||
|
2: .long pmode
|
||||||
|
.word SEL_KERNEL_CODE
|
||||||
|
|
||||||
|
.code32
|
||||||
|
.section ".text32","ax"
|
||||||
|
.global pmode
|
||||||
|
pmode:
|
||||||
|
movw $SEL_KERNEL_DATA, %ax
|
||||||
|
movw %ax, %ds
|
||||||
|
movw %ax, %es
|
||||||
|
movw %ax, %fs
|
||||||
|
movw %ax, %gs
|
||||||
|
movl $KERNEL_CODE_ADDR, %ebx
|
||||||
|
movw $SEL_KERNEL_STACK, %ax
|
||||||
|
movw %ax, %ss
|
||||||
|
movl $KERNEL_STACK_ADDR, %esp
|
||||||
|
xor %eax,%eax
|
||||||
|
xor %ecx,%ecx
|
||||||
|
xor %edx,%edx
|
||||||
|
xor %esi,%esi
|
||||||
|
xor %edi,%edi
|
||||||
|
xor %ebp,%ebp
|
||||||
|
jmp *%ebx
|
|
@ -123,7 +123,7 @@ setup_move_size: .word 0x8000 # size to move, when setup is not
|
||||||
|
|
||||||
code32_start: # here loaders can put a different
|
code32_start: # here loaders can put a different
|
||||||
# start address for 32-bit code.
|
# start address for 32-bit code.
|
||||||
.long 0x100000 # 0x100000 = default for big kernel
|
.long LOAD_PHYSICAL_ADDR # 0x100000 = default for big kernel
|
||||||
|
|
||||||
ramdisk_image: .long 0 # address of loaded ramdisk image
|
ramdisk_image: .long 0 # address of loaded ramdisk image
|
||||||
# Here the loader puts the 32-bit
|
# Here the loader puts the 32-bit
|
||||||
|
|
|
@ -175,86 +175,37 @@ u8 enableA20(void)
|
||||||
int loops = LOOPS_A20_ENABLE;
|
int loops = LOOPS_A20_ENABLE;
|
||||||
int kbcerr;
|
int kbcerr;
|
||||||
while (loops--) {
|
while (loops--) {
|
||||||
if (testA20())
|
if (!testA20())
|
||||||
return 1;
|
return NULL;
|
||||||
kbcerr = empty8042();
|
kbcerr = empty8042();
|
||||||
if (testA20())
|
if (!testA20())
|
||||||
return 1;
|
return NULL;
|
||||||
if (!kbcerr) {
|
if (!kbcerr) {
|
||||||
enableA20kbc();
|
enableA20kbc();
|
||||||
if (testA20())
|
if (!testA20())
|
||||||
return 1;
|
return NULL;
|
||||||
}
|
}
|
||||||
enableA20fast();
|
enableA20fast();
|
||||||
if (testA20())
|
if (!testA20())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************/
|
|
||||||
/* Copie un octet une ou plusieurs fois en mémoire */
|
|
||||||
|
|
||||||
void memset(void *dst, u8 val, u32 count, u32 size)
|
|
||||||
{
|
|
||||||
u8 *d = (u8 *) dst;
|
|
||||||
if (size > 0)
|
|
||||||
size--;
|
|
||||||
for (; count != 0; count--)
|
|
||||||
{
|
|
||||||
*(d++) = val;
|
|
||||||
d += size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
/* Copie une portion de mémoire vers une autre */
|
/* Copie une portion de mémoire vers une autre */
|
||||||
|
|
||||||
void memcpy(void *src, void *dst, u32 count, u32 size)
|
void memcpyto(void *src, void *dst, u32 count)
|
||||||
{
|
{
|
||||||
u8 *s = (u8 *) src;
|
asm("push %%es\n\
|
||||||
u8 *d = (u8 *) dst;
|
cld\n\
|
||||||
if (size > 0)
|
|
||||||
size--;
|
|
||||||
for (; count != 0; count--)
|
|
||||||
{
|
|
||||||
*(d++) = *(s++);
|
|
||||||
d += size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************/
|
|
||||||
/* Initialise les selecteurs avec la GDT */
|
|
||||||
|
|
||||||
void initselectors(u32 executingoffset)
|
|
||||||
{
|
|
||||||
asm(" movl %%cr0, %%eax \n \
|
|
||||||
orb $0x00000001, %%eax \n \
|
|
||||||
movl %%eax, %%cr0 \n \
|
|
||||||
ljmp %[code], $raz\n\
|
|
||||||
raz:\n \
|
|
||||||
.code32\n\
|
|
||||||
movw %[data], %%ax \n \
|
|
||||||
movw %%ax, %%ds \n \
|
|
||||||
movw %%ax, %%es \n \
|
|
||||||
movw %%ax, %%fs \n \
|
|
||||||
movw %%ax, %%gs \n \
|
|
||||||
movl %[offset], %%ebx \n \
|
|
||||||
movw %[stack], %%ax \n \
|
|
||||||
movw %%ax, %%ss \n \
|
|
||||||
movl %[stackoff], %%esp \n \
|
|
||||||
xor %%eax,%%eax\n\
|
xor %%eax,%%eax\n\
|
||||||
xor %%ebx,%%ebx\n\
|
mov %%ax,%%es\n\
|
||||||
xor %%ecx,%%ecx\n\
|
rep movsb\n\
|
||||||
xor %%edx,%%edx\n\
|
pop %%es"::"S" (src), "D" (dst), "c" (count):);
|
||||||
xor %%esi,%%esi\n\
|
|
||||||
xor %%edi,%%edi\n\
|
|
||||||
xor %%ebp,%%ebp\n\
|
|
||||||
jmp %%ebx\n\
|
|
||||||
.code16gcc"::[data] "i"(SEL_KERNEL_DATA),[code] "i"(SEL_KERNEL_CODE),[stack] "i"(SEL_KERNEL_STACK),[stackoff] "i"(KERNEL_STACK_ADDR),[offset] "m"(executingoffset));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
/* Créé un descripteur GDT */
|
/* Créé un descripteur GDT */
|
||||||
|
|
||||||
|
@ -278,16 +229,16 @@ void initgdt()
|
||||||
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]); /* descripteur nul */
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]); /* descripteur nul */
|
||||||
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING0 | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[1]); /* code -> SEL_KERNEL_CODE */
|
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING0 | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[1]); /* code -> SEL_KERNEL_CODE */
|
||||||
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[2]); /* pile -> SEL_KERNEL_STACK */
|
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[2]); /* pile -> SEL_KERNEL_STACK */
|
||||||
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING3 | SEG_CONFORMING | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[3]); /* code -> SEL_USER_CODE */
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[3]); /* LIBRE */
|
||||||
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[4]); /* pile -> SEL_USER_STACK */
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[4]); /* LIBRE */
|
||||||
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[5]); /* data -> SEL_KERNEL_DATA */
|
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[5]); /* data -> SEL_KERNEL_DATA */
|
||||||
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[6]); /* data -> SEL_USER_DATA */
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[6]); /* LIBRE */
|
||||||
makegdtdes(0x0, 0x67, SEG_PRESENT | SEG_CODE | SEG_RING3 | SEG_ACCESSED, 0x00, &gdt[7]); /* descripteur de tss */
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[7]); /* LIBRE */
|
||||||
/* initialise le registre gdt */
|
/* initialise le registre gdt */
|
||||||
gdtreg.limite = GDT_SIZE * sizeof(gdtdes);
|
gdtreg.limite = GDT_SIZE * sizeof(gdtdes);
|
||||||
gdtreg.base = GDT_ADDR;
|
gdtreg.base = GDT_ADDR;
|
||||||
/* recopie de la GDT a son adresse */
|
/* recopie de la GDT a son adresse */
|
||||||
memcpy(&gdt, (u8 *) gdtreg.base, gdtreg.limite, 1);
|
memcpyto(&gdt, (u8 *) gdtreg.base, gdtreg.limite);
|
||||||
/* chargement du registre GDT */
|
/* chargement du registre GDT */
|
||||||
lgdt(gdtreg);
|
lgdt(gdtreg);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +262,7 @@ void initcoprocessor(void)
|
||||||
iodelay();
|
iodelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initpmode(u32 offset)
|
void initpmode()
|
||||||
{
|
{
|
||||||
if (enableA20()) {
|
if (enableA20()) {
|
||||||
showstr("impossible d'ouvrir la ligne A20...\n");
|
showstr("impossible d'ouvrir la ligne A20...\n");
|
||||||
|
@ -319,7 +270,7 @@ void initpmode(u32 offset)
|
||||||
}
|
}
|
||||||
maskinterrupts();
|
maskinterrupts();
|
||||||
initgdt();
|
initgdt();
|
||||||
initselectors(offset);
|
gotopmode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
|
@ -334,5 +285,5 @@ void main(void)
|
||||||
showstr(" -Initialisation du coprocesseur\r\n");
|
showstr(" -Initialisation du coprocesseur\r\n");
|
||||||
initcoprocessor();
|
initcoprocessor();
|
||||||
showstr(" -Passage en mode protege\r\n");
|
showstr(" -Passage en mode protege\r\n");
|
||||||
initpmode(0x10000);
|
initpmode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
static u8 warnmsg[] =
|
static u8 warnmsg[] =
|
||||||
"\033[150C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m";
|
"\033[150C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m";
|
||||||
|
@ -59,6 +60,8 @@ int main(u8* info)
|
||||||
logo();
|
logo();
|
||||||
|
|
||||||
print("\033[37m\033[0m -Initilisation de la memoire virtuelle");
|
print("\033[37m\033[0m -Initilisation de la memoire virtuelle");
|
||||||
|
initgdt(&&next);
|
||||||
|
next:
|
||||||
initpaging();
|
initpaging();
|
||||||
remap_memory(VESA_FBMEM);
|
remap_memory(VESA_FBMEM);
|
||||||
ok();
|
ok();
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
.code32
|
.code32
|
||||||
.section ".text"
|
.section ".text"
|
||||||
.global start
|
.global start
|
||||||
|
.extern main
|
||||||
start:
|
start:
|
||||||
ljmp $SEL_KERNEL_CODE,$suite
|
|
||||||
suite:
|
|
||||||
movw $SEL_KERNEL_DATA, %ax
|
movw $SEL_KERNEL_DATA, %ax
|
||||||
movw %ax, %ds
|
movw %ax, %ds
|
||||||
movw %ax, %es
|
movw %ax, %es
|
||||||
|
@ -26,3 +25,4 @@ suite:
|
||||||
xor %esi,%esi
|
xor %esi,%esi
|
||||||
xor %edi,%edi
|
xor %edi,%edi
|
||||||
xor %ebp,%ebp
|
xor %ebp,%ebp
|
||||||
|
call main
|
Loading…
Reference in New Issue