feat: structure command et ajout d'un fichier shell.c
This commit is contained in:
parent
c3a153b091
commit
93897a6cce
|
@ -1,5 +1,15 @@
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
|
#define SEL_KERNEL_CODE 0x8 /* selecteur code du kernel */
|
||||||
|
#define SEL_KERNEL_DATA 0x10 /* selecteur data du kernel */
|
||||||
|
#define SEL_KERNEL_STACK 0x18 /* selecteur pile du kernel */
|
||||||
|
#define STACK_OFFSET 0x20000 /* adresse de la pile du kernel */
|
||||||
|
|
||||||
|
#define SIZEGDT 0x4 /* nombre de descripteurs */
|
||||||
|
|
||||||
|
#define BASEGDT 0x00000800 /* addr de la GDT */
|
||||||
|
|
||||||
|
|
||||||
typedef struct gdtdes {
|
typedef struct gdtdes {
|
||||||
u16 lim0_15;
|
u16 lim0_15;
|
||||||
u16 base0_15;
|
u16 base0_15;
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
typedef struct command
|
||||||
|
{
|
||||||
|
u8 name[64];
|
||||||
|
u8 params[64];
|
||||||
|
int (*function)(void)
|
||||||
|
} command __attribute__ ((packed));
|
||||||
|
|
||||||
|
int rebootnow();
|
||||||
|
int test2d();
|
||||||
|
int readidt();
|
||||||
|
int readgdt();
|
||||||
|
int detectcpu();
|
||||||
|
int mode();
|
||||||
|
int clear();
|
||||||
|
int dump_regs();
|
46
lib/gdt.c
46
lib/gdt.c
|
@ -2,9 +2,6 @@
|
||||||
#include "asm.h"
|
#include "asm.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define SIZEGDT 0x4 /* nombre de descripteurs */
|
|
||||||
|
|
||||||
#define BASEGDT 0x00000800 /* addr de la GDT */
|
|
||||||
|
|
||||||
/* registre gdt */
|
/* registre gdt */
|
||||||
static struct gdtr gdtreg;
|
static struct gdtr gdtreg;
|
||||||
|
@ -16,12 +13,12 @@ static gdtdes gdt[SIZEGDT];
|
||||||
|
|
||||||
/* Initialise la GDT */
|
/* Initialise la GDT */
|
||||||
|
|
||||||
void initgdt()
|
void initgdt(u32 offset)
|
||||||
{
|
{
|
||||||
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]);
|
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]); /* selecteur nulle */
|
||||||
makegdtdes(0x0, 0xFFFFF, 0x9B, 0x0D, &gdt[1]); /* code */
|
makegdtdes(0x0, 0xFFFFF, 0x9B, 0x0D, &gdt[1]); /* code -> SEL_KERNEL_CODE */
|
||||||
makegdtdes(0x0, 0xFFFFF, 0x93, 0x0D, &gdt[2]); /* data */
|
makegdtdes(0x0, 0xFFFFF, 0x93, 0x0D, &gdt[2]); /* data -> SEL_KERNEL_DATA */
|
||||||
makegdtdes(0x0, 0x00000, 0x97, 0x0D, &gdt[3]); /* pile */
|
makegdtdes(0x0, 0x00000, 0x97, 0x0D, &gdt[3]); /* pile -> SEL_KERNEL_STACK */
|
||||||
/* initialise le registre gdt */
|
/* initialise le registre gdt */
|
||||||
gdtreg.limite = SIZEGDT * 8;
|
gdtreg.limite = SIZEGDT * 8;
|
||||||
gdtreg.base = BASEGDT;
|
gdtreg.base = BASEGDT;
|
||||||
|
@ -30,19 +27,28 @@ void initgdt()
|
||||||
/* chargement du registre GDT */
|
/* chargement du registre GDT */
|
||||||
lgdt(&gdtreg);
|
lgdt(&gdtreg);
|
||||||
/* initialisation des segments */
|
/* initialisation des segments */
|
||||||
asm(" movw $0x10, %ax \n \
|
initselectors(offset);
|
||||||
movw %ax, %ds \n \
|
}
|
||||||
movw %ax, %es \n \
|
|
||||||
movw %ax, %fs \n \
|
/*******************************************************************************/
|
||||||
movw %ax, %gs \n \
|
|
||||||
movl 0x0C(%esp), %ebx \n \
|
/* Initialise les selecteurs avec la GDT */
|
||||||
movw $0x18, %ax \n \
|
|
||||||
movw %ax, %ss \n \
|
void initselectors(u32 executingoffset)
|
||||||
movl $0x20000, %esp \n \
|
{
|
||||||
ljmp $0x08, $raz \n \
|
asm(" 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 \
|
||||||
|
ljmp %[code], $raz \n \
|
||||||
raz: \n \
|
raz: \n \
|
||||||
pushl %ebx \n \
|
pushl %%ebx \n \
|
||||||
ret\n");
|
ret\n"::[data] "i"(SEL_KERNEL_DATA),[code] "i"(SEL_KERNEL_CODE), [stack] "i"(SEL_KERNEL_STACK), [stackoff] "i"(STACK_OFFSET), [offset] "m"(executingoffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -m32 -F pe-i386 -I ../include
|
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -m32 -F pe-i386 -I ../include
|
||||||
LINK=ld -m elf_i386 -r -o
|
LINK=ld -m elf_i386 -r -o
|
||||||
OBJS=memory.o vga.o video.o mouse.o interrupts.o timer.o keyboard.o types.o string.o 2d.o 3d.o math.o cpu.o gdt.o
|
OBJS=memory.o vga.o video.o mouse.o interrupts.o timer.o keyboard.o types.o string.o 2d.o 3d.o math.o cpu.o gdt.o shell.o
|
||||||
|
|
||||||
all: makeall
|
all: makeall
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,215 @@
|
||||||
|
#include "vga.h"
|
||||||
|
#include "video.h"
|
||||||
|
#include "interrupts.h"
|
||||||
|
#include "asm.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "2d.h"
|
||||||
|
#include "gdt.h"
|
||||||
|
#include "shell.h"
|
||||||
|
|
||||||
|
static command commands[] = {
|
||||||
|
{"REBOOT","",&rebootnow},
|
||||||
|
{"CLEAR","",&clear},
|
||||||
|
{"MODE","",&mode},
|
||||||
|
{"DETECTCPU","",&detectcpu},
|
||||||
|
{"TEST2D","",&test2d},
|
||||||
|
{"REGS","",&dump_regs},
|
||||||
|
{"GDT","",&readgdt},
|
||||||
|
{"IDT","",&readidt},
|
||||||
|
};
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Shell, traite les commandes */
|
||||||
|
|
||||||
|
void shell() {
|
||||||
|
static u8 field[]=" \000";
|
||||||
|
static u8 item[]=" \000";
|
||||||
|
int i;
|
||||||
|
bool found;
|
||||||
|
while (true) {
|
||||||
|
print("\r\n# ");
|
||||||
|
getstring(&field);
|
||||||
|
print("\r\n");
|
||||||
|
if (strgetnbitems(&field,' ')<1) continue;
|
||||||
|
strgetitem(&field, &item, ' ', 0);
|
||||||
|
strtoupper(&item);
|
||||||
|
found=false;
|
||||||
|
for(i=0;i<sizeof(commands);i++) {
|
||||||
|
if (strcmp(&item,&commands[i].name)==0) {
|
||||||
|
(*commands[i].function)();
|
||||||
|
found=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) printf("Commande inconnue !\r\n\000");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Affiche les registres */
|
||||||
|
|
||||||
|
int regs() {
|
||||||
|
dump_regs();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Change le mode */
|
||||||
|
|
||||||
|
int mode() {
|
||||||
|
setvmode(0x84);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Efface l'écran */
|
||||||
|
|
||||||
|
int clear() {
|
||||||
|
fill(0x00);
|
||||||
|
gotoscr(0,0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Redemarre */
|
||||||
|
|
||||||
|
int rebootnow() {
|
||||||
|
print("<Appuyer sur une touche pour redemarrer>");
|
||||||
|
waitascii();
|
||||||
|
reboot();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Test les fonctionnalité 2D graphiques */
|
||||||
|
|
||||||
|
int test2d() {
|
||||||
|
setvmode(0x89);
|
||||||
|
fill(0x00);
|
||||||
|
struct vertex2d a,b,c;
|
||||||
|
randomize();
|
||||||
|
for(int i=0;i<3200;i++)
|
||||||
|
{
|
||||||
|
a.x=random(0, 800);
|
||||||
|
a.y=random(0, 600);
|
||||||
|
b.x=random(0, 800);
|
||||||
|
b.y=random(0, 600);
|
||||||
|
c.x=random(0, 800);
|
||||||
|
c.y=random(0, 600);
|
||||||
|
trianglefilled(&a,&b,&c,random(0, 16));
|
||||||
|
triangle(&a,&b,&c,2);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Lit l'IDT et l'affiche */
|
||||||
|
|
||||||
|
int readidt()
|
||||||
|
{
|
||||||
|
u32 index,i=0;
|
||||||
|
idtdes* desc;
|
||||||
|
struct idtr idtreg;
|
||||||
|
sidt(&idtreg);
|
||||||
|
printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX",idtreg.base,(u32)idtreg.limite);
|
||||||
|
desc=idtreg.base;
|
||||||
|
for(index=0;index<idtreg.limite/sizeof(idtdes);index++)
|
||||||
|
{
|
||||||
|
u32 select=desc[index].select;
|
||||||
|
u32 offset=desc[index].offset0_15+(desc[index].offset16_31 << 16);
|
||||||
|
u32 type=desc[index].type;
|
||||||
|
printf("\r\nInterruption % d Selecteur %hX: offset:%X type:",i++,select,offset,type);
|
||||||
|
if (type==INTGATE) print("INTGATE");
|
||||||
|
else if (type==TRAPGATE) print("TRAPGATE");
|
||||||
|
else if (type==TASKGATE) print("TASKGATE");
|
||||||
|
else if (type==CALLGATE) print("CALLGATE");
|
||||||
|
else if (type==LDTDES) print("LDTDES");
|
||||||
|
else print("inconnu");
|
||||||
|
if (i%32==0) {
|
||||||
|
print("\r\n<Appuyez sur une touche>\r\n");
|
||||||
|
waitascii();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Lit les descripteurs GDT et les affiche */
|
||||||
|
|
||||||
|
int readgdt()
|
||||||
|
{
|
||||||
|
u32 index;
|
||||||
|
gdtdes* desc;
|
||||||
|
struct gdtr gdtreg;
|
||||||
|
sgdt(&gdtreg);
|
||||||
|
printf("Information sur la LGDT\r\nAdresse:%X Limite:%hX",gdtreg.base,(u32)gdtreg.limite);
|
||||||
|
desc=gdtreg.base;
|
||||||
|
for(index=0;index<gdtreg.limite/sizeof(gdtdes);index++)
|
||||||
|
{
|
||||||
|
u32 acces=desc[index].acces;
|
||||||
|
if (acces >> 7 == 1) {
|
||||||
|
u32 flags=desc[index].flags;
|
||||||
|
u32 limit=desc[index].lim0_15+(desc[index].lim16_19 << 16);
|
||||||
|
u32 base=desc[index].base0_15+(desc[index].base16_23 << 16)+(desc[index].base24_31 << 24) ;
|
||||||
|
printf("\r\nSelecteur %hX: base:%X limit:%X access:%hX flags:%hX\r\n -> ",index*sizeof(gdtdes),base,limit,acces,flags);
|
||||||
|
if ((acces >> 4) & 1 == 1)
|
||||||
|
print("Systeme ");
|
||||||
|
else {
|
||||||
|
if (acces & 1 == 1)
|
||||||
|
print("Acces ");
|
||||||
|
}
|
||||||
|
if ((acces >> 3) & 1 == 1) {
|
||||||
|
print("Code.");
|
||||||
|
if ((acces >> 1) & 1 == 1)
|
||||||
|
print("Readable ");
|
||||||
|
if ((acces >> 2) & 1 == 1)
|
||||||
|
print("Conforming ");
|
||||||
|
else
|
||||||
|
print("Normal ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print("Data.");
|
||||||
|
if ((acces >> 3) & 1 == 1)
|
||||||
|
print("Down ");
|
||||||
|
else
|
||||||
|
print("up ");
|
||||||
|
if ((acces >> 1) & 1 == 1)
|
||||||
|
print("writeable ");
|
||||||
|
}
|
||||||
|
if (flags & 1 == 1)
|
||||||
|
print("Dispo ");
|
||||||
|
if ((flags >> 2) & 1 == 1)
|
||||||
|
print("32 bits ");
|
||||||
|
else
|
||||||
|
print("16 bits ");
|
||||||
|
if ((flags >> 3) & 1 == 1)
|
||||||
|
print("4k ");
|
||||||
|
else
|
||||||
|
print("1b ");
|
||||||
|
u8 dpl=(acces>>5) & 0b11;
|
||||||
|
printf("DPL:%d",dpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Detecte et affiche les information sur le CPU */
|
||||||
|
|
||||||
|
int detectcpu()
|
||||||
|
{
|
||||||
|
cpuinfo cpu;
|
||||||
|
u8 noproc[] = "\033[31mInconnu\033[0m\000";
|
||||||
|
strcpy(&noproc, &cpu.detectedname);
|
||||||
|
getcpuinfos(&cpu);
|
||||||
|
printf("\r\nDetection du processeur\r\033[1m Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux d'instruction\t:%s\033[0m\r\n\000",cpu.stepping, cpu.models, cpu.family, &cpu.detectedname,&cpu.techs);
|
||||||
|
return 0;
|
||||||
|
}
|
162
system/system.c
162
system/system.c
|
@ -10,6 +10,7 @@
|
||||||
#include "2d.h"
|
#include "2d.h"
|
||||||
#include "ansi.c"
|
#include "ansi.c"
|
||||||
#include "gdt.h"
|
#include "gdt.h"
|
||||||
|
#include "shell.h"
|
||||||
|
|
||||||
static u8 warnmsg[] =
|
static u8 warnmsg[] =
|
||||||
"\033[99C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m\000";
|
"\033[99C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m\000";
|
||||||
|
@ -50,7 +51,8 @@ int main(void)
|
||||||
ok();
|
ok();
|
||||||
|
|
||||||
print("\033[37m\033[0m -Initilisation de la memoire (GDT)\000");
|
print("\033[37m\033[0m -Initilisation de la memoire (GDT)\000");
|
||||||
initgdt();
|
initgdt(&&next);
|
||||||
|
next:
|
||||||
ok();
|
ok();
|
||||||
|
|
||||||
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)\000");
|
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)\000");
|
||||||
|
@ -60,172 +62,22 @@ int main(void)
|
||||||
ok();
|
ok();
|
||||||
|
|
||||||
print(" -Installation du handler timer (IRQ 0)\000");
|
print(" -Installation du handler timer (IRQ 0)\000");
|
||||||
setidt((u32) timer, 0x8, INTGATE, 32);
|
setidt((u32) timer, SEL_KERNEL_CODE, INTGATE, 32);
|
||||||
enableirq(0);
|
enableirq(0);
|
||||||
ok();
|
ok();
|
||||||
|
|
||||||
print(" -Installation du handler clavier (IRQ 1)\000");
|
print(" -Installation du handler clavier (IRQ 1)\000");
|
||||||
setidt((u32) keyboard, 0x8, INTGATE, 33);
|
setidt((u32) keyboard, SEL_KERNEL_CODE, INTGATE, 33);
|
||||||
enableirq(1);
|
enableirq(1);
|
||||||
ok();
|
ok();
|
||||||
|
|
||||||
print(" -Installation du handler souris (IRQ12+Cascade IRQ2)\000");
|
print(" -Installation du handler souris (IRQ12+Cascade IRQ2)\000");
|
||||||
setidt((u32) mouse, 0x8, INTGATE, 100);
|
setidt((u32) mouse, SEL_KERNEL_CODE, INTGATE, 100);
|
||||||
enableirq(2);
|
enableirq(2);
|
||||||
enableirq(12);
|
enableirq(12);
|
||||||
if (initmouse() != 1)
|
if (initmouse() != 1)
|
||||||
warning();
|
warning();
|
||||||
else
|
else
|
||||||
ok();
|
ok();
|
||||||
static u8 field[]=" \000";
|
shell();
|
||||||
static u8 item[]=" \000";
|
|
||||||
static u8 cmd_reboot[]="REBOOT\000";
|
|
||||||
static u8 cmd_mode[]="MODE\000";
|
|
||||||
static u8 cmd_clear[]="CLEAR\000";
|
|
||||||
static u8 cmd_detectcpu[]="DETECTCPU\000";
|
|
||||||
static u8 cmd_test2d[]="TEST2D\000";
|
|
||||||
static u8 cmd_regs[]="REGS\000";
|
|
||||||
static u8 cmd_gdt[]="GDT\000";
|
|
||||||
static u8 cmd_idt[]="IDT\000";
|
|
||||||
while (true) {
|
|
||||||
print("\r\n# ");
|
|
||||||
getstring(&field);
|
|
||||||
print("\r\n");
|
|
||||||
if (strgetnbitems(&field,' ')<1) continue;
|
|
||||||
strgetitem(&field, &item, ' ', 0);
|
|
||||||
strtoupper(&item);
|
|
||||||
|
|
||||||
if (strcmp(&item,&cmd_reboot)==0) reboot();
|
|
||||||
else if (strcmp(&item,&cmd_mode)==0) setvmode(0x84);
|
|
||||||
else if (strcmp(&item,&cmd_clear)==0) fill(0x00);
|
|
||||||
else if (strcmp(&item,&cmd_detectcpu)==0) detectcpu();
|
|
||||||
else if (strcmp(&item,&cmd_test2d)==0) test2d();
|
|
||||||
else if (strcmp(&item,&cmd_regs)==0) dump_regs();
|
|
||||||
else if (strcmp(&item,&cmd_gdt)==0) readgdt();
|
|
||||||
else if (strcmp(&item,&cmd_idt)==0) readidt();
|
|
||||||
else
|
|
||||||
printf("Commande inconnue !\r\n\000");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************/
|
|
||||||
|
|
||||||
/* Test les fonctionnalité 2D graphiques */
|
|
||||||
|
|
||||||
void test2d() {
|
|
||||||
setvmode(0x89);
|
|
||||||
fill(0x00);
|
|
||||||
struct vertex2d a,b,c;
|
|
||||||
randomize();
|
|
||||||
for(int i=0;i<3200;i++)
|
|
||||||
{
|
|
||||||
a.x=random(0, 800);
|
|
||||||
a.y=random(0, 600);
|
|
||||||
b.x=random(0, 800);
|
|
||||||
b.y=random(0, 600);
|
|
||||||
c.x=random(0, 800);
|
|
||||||
c.y=random(0, 600);
|
|
||||||
trianglefilled(&a,&b,&c,random(0, 16));
|
|
||||||
triangle(&a,&b,&c,2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************/
|
|
||||||
|
|
||||||
/* Lit l'IDT et l'affiche */
|
|
||||||
|
|
||||||
void readidt()
|
|
||||||
{
|
|
||||||
u32 index,i=0;
|
|
||||||
idtdes* desc;
|
|
||||||
struct idtr idtreg;
|
|
||||||
sidt(&idtreg);
|
|
||||||
printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX",idtreg.base,(u32)idtreg.limite);
|
|
||||||
desc=idtreg.base;
|
|
||||||
for(index=0;index<idtreg.limite/sizeof(idtdes);index++)
|
|
||||||
{
|
|
||||||
u32 select=desc[index].select;
|
|
||||||
u32 offset=desc[index].offset0_15+(desc[index].offset16_31 << 16);
|
|
||||||
u32 type=desc[index].type;
|
|
||||||
printf("\r\nInterruption % d Selecteur %hX: offset:%X type:",i++,select,offset,type);
|
|
||||||
if (type==INTGATE) print("INTGATE");
|
|
||||||
else if (type==TRAPGATE) print("TRAPGATE");
|
|
||||||
else if (type==TASKGATE) print("TASKGATE");
|
|
||||||
else if (type==CALLGATE) print("CALLGATE");
|
|
||||||
else if (type==LDTDES) print("LDTDES");
|
|
||||||
else print("inconnu");
|
|
||||||
if (i%32==0) waitascii();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/*******************************************************************************/
|
|
||||||
|
|
||||||
/* Lit les descripteurs GDT et les affiche */
|
|
||||||
|
|
||||||
void readgdt()
|
|
||||||
{
|
|
||||||
u32 index;
|
|
||||||
gdtdes* desc;
|
|
||||||
struct gdtr gdtreg;
|
|
||||||
sgdt(&gdtreg);
|
|
||||||
printf("Information sur la LGDT\r\nAdresse:%X Limite:%hX",gdtreg.base,(u32)gdtreg.limite);
|
|
||||||
desc=gdtreg.base;
|
|
||||||
for(index=0;index<=gdtreg.limite/sizeof(gdtdes);index++)
|
|
||||||
{
|
|
||||||
u32 acces=desc[index].acces;
|
|
||||||
if (acces >> 7 == 1) {
|
|
||||||
u32 flags=desc[index].flags;
|
|
||||||
u32 limit=desc[index].lim0_15+(desc[index].lim16_19 << 16);
|
|
||||||
u32 base=desc[index].base0_15+(desc[index].base16_23 << 16)+(desc[index].base24_31 << 24) ;
|
|
||||||
printf("\r\nSelecteur %hX: base:%X limit:%X access:%hX flags:%hX\r\n -> ",index*sizeof(gdtdes),base,limit,acces,flags);
|
|
||||||
if ((acces >> 4) & 1 == 1)
|
|
||||||
print("Systeme ");
|
|
||||||
else {
|
|
||||||
if (acces & 1 == 1)
|
|
||||||
print("Acces ");
|
|
||||||
}
|
|
||||||
if ((acces >> 3) & 1 == 1) {
|
|
||||||
print("Code.");
|
|
||||||
if ((acces >> 1) & 1 == 1)
|
|
||||||
print("Readable ");
|
|
||||||
if ((acces >> 2) & 1 == 1)
|
|
||||||
print("Conforming ");
|
|
||||||
else
|
|
||||||
print("Normal ");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print("Data.");
|
|
||||||
if ((acces >> 3) & 1 == 1)
|
|
||||||
print("Down ");
|
|
||||||
else
|
|
||||||
print("up ");
|
|
||||||
if ((acces >> 1) & 1 == 1)
|
|
||||||
print("writeable ");
|
|
||||||
}
|
|
||||||
if (flags & 1 == 1)
|
|
||||||
print("Dispo");
|
|
||||||
if ((flags >> 2) & 1 == 1)
|
|
||||||
print("32 bits ");
|
|
||||||
else
|
|
||||||
print("16 bits ");
|
|
||||||
if ((flags >> 3) & 1 == 1)
|
|
||||||
print("4k ");
|
|
||||||
else
|
|
||||||
print("1b ");
|
|
||||||
u8 dpl=(acces>>5) & 0b11;
|
|
||||||
printf("DPL:%d",dpl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************/
|
|
||||||
|
|
||||||
/* Detecte et affiche les information sur le CPU */
|
|
||||||
|
|
||||||
void detectcpu()
|
|
||||||
{
|
|
||||||
cpuinfo cpu;
|
|
||||||
u8 noproc[] = "\033[31mInconnu\033[0m\000";
|
|
||||||
strcpy(&noproc, &cpu.detectedname);
|
|
||||||
getcpuinfos(&cpu);
|
|
||||||
printf("\r\nDetection du processeur\r\033[1m Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux d'instruction\t:%s\033[0m\r\n\000",cpu.stepping, cpu.models, cpu.family, &cpu.detectedname,&cpu.techs);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue