feat: mode vesa balbutiant, mauvaise gestion RGB ajout de modules dans GRUB non uefi
This commit is contained in:
parent
26faaf8713
commit
c179f61bff
Binary file not shown.
|
@ -3,6 +3,9 @@
|
|||
/* */
|
||||
#include "types.h"
|
||||
|
||||
#ifndef MULTIBOOT
|
||||
# define ALLTYMULTIBOOTPES
|
||||
|
||||
/* How many bytes from the start of the file we search for the header. */
|
||||
#define MULTIBOOT_SEARCH 32768
|
||||
#define MULTIBOOT_HEADER_ALIGN 8
|
||||
|
@ -387,5 +390,7 @@
|
|||
};
|
||||
|
||||
void getbootinfo(void);
|
||||
u32 getblockinfo(void);
|
||||
void initmultiboot(const u32 addr);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -69,7 +69,6 @@ typedef struct capabilities {
|
|||
bool graphic;
|
||||
u8 depth;
|
||||
u8 refresh;
|
||||
u8 fonttype;
|
||||
} capabilities __attribute__ ((packed));
|
||||
|
||||
typedef struct console {
|
||||
|
@ -125,7 +124,6 @@ void apply_bestdriver(void);
|
|||
void apply_nextdriver(void);
|
||||
void apply_driver(u8* name);
|
||||
void apply_nextvideomode(void);
|
||||
void initvideo(void);
|
||||
|
||||
/* Fonctions du pilote */
|
||||
u8 *(*detect_hardware) (void);
|
||||
|
|
|
@ -14,6 +14,14 @@ void initmultiboot(const u32 addr)
|
|||
infobloc=addr;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Renvoie l'adresse du bloc multiboot2 */
|
||||
|
||||
u32 getblockinfo(void)
|
||||
{
|
||||
return infobloc;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Affiche les informations multiboot2 */
|
||||
|
||||
|
|
18
lib/shell.c
18
lib/shell.c
|
@ -394,17 +394,17 @@ int rebootnow()
|
|||
|
||||
int test2d()
|
||||
{
|
||||
setvideo_mode(0x87);
|
||||
fill(0x00);
|
||||
changemode(0x83);
|
||||
videoinfos *vinfo=getvideo_info();
|
||||
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);
|
||||
for (int i = 0; i < 3000; i++) {
|
||||
a.x = random(0, vinfo->currentwidth);
|
||||
a.y = random(0, vinfo->currentheight);
|
||||
b.x = random(0, vinfo->currentwidth);
|
||||
b.y = random(0, vinfo->currentheight);
|
||||
c.x = random(0, vinfo->currentwidth);
|
||||
c.y = random(0, vinfo->currentheight);
|
||||
trianglefilled(&a, &b, &c, random(0, 16));
|
||||
triangle(&a, &b, &c, 2);
|
||||
}
|
||||
|
|
86
lib/vesa.c
86
lib/vesa.c
|
@ -6,6 +6,7 @@
|
|||
#include "memory.h"
|
||||
#include "asm.h"
|
||||
#include "types.h"
|
||||
#include "multiboot2.h"
|
||||
|
||||
static videoinfos infos;
|
||||
|
||||
|
@ -13,10 +14,49 @@ static capabilities vesacapabilities[] = {
|
|||
{0xFF,000,000,false, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */
|
||||
u8 *VESA_detect_hardware(void) {
|
||||
u32 addr=getblockinfo();
|
||||
struct multiboot_tag *tag;
|
||||
unsigned size = *(unsigned *) addr;
|
||||
for (tag = (struct multiboot_tag *) (addr + 8);
|
||||
tag->type != MULTIBOOT_TAG_TYPE_END;
|
||||
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7)))
|
||||
{
|
||||
switch (tag->type)
|
||||
{
|
||||
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
|
||||
{
|
||||
struct multiboot_tag_framebuffer *tagfb = (struct multiboot_tag_framebuffer *) tag;
|
||||
|
||||
switch (tagfb->common.framebuffer_type)
|
||||
{
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
|
||||
vesacapabilities[0].modenumber=0x0;
|
||||
vesacapabilities[0].width=tagfb->common.framebuffer_width;
|
||||
vesacapabilities[0].height=tagfb->common.framebuffer_height;
|
||||
vesacapabilities[0].graphic=true;
|
||||
vesacapabilities[0].depth=tagfb->common.framebuffer_bpp;
|
||||
vesacapabilities[0].refresh=0x0;
|
||||
infos.baseaddress=tagfb->common.framebuffer_addr;
|
||||
infos.currentpitch=tagfb->common.framebuffer_pitch;
|
||||
return "LEGACY";
|
||||
break;
|
||||
|
||||
default:
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -28,7 +68,23 @@ static u8 realsize;
|
|||
|
||||
u8 VESA_setvideo_mode(u8 mode)
|
||||
{
|
||||
|
||||
if (mode>0) return 1;
|
||||
infos.currentmode=mode;
|
||||
infos.currentwidth=vesacapabilities[0].width;
|
||||
infos.currentheight=vesacapabilities[0].height;
|
||||
infos.currentdepth=vesacapabilities[0].depth;
|
||||
infos.currentactivepage=0;
|
||||
infos.currentshowedpage=0;
|
||||
infos.currentcursorX=0;
|
||||
infos.currentcursorY=0;
|
||||
infos.currentfont1=0;
|
||||
infos.currentfont2=0;
|
||||
infos.isgraphic=vesacapabilities[0].graphic;
|
||||
infos.isblinking=false;
|
||||
infos.iscursorvisible=false;
|
||||
infos.pagesnumber=1;
|
||||
infos.pagesize=infos.currentheight*infos.currentpitch;
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -53,7 +109,21 @@ videoinfos *VESA_getvideo_info (void) {
|
|||
/*******************************************************************************/
|
||||
/* Effecture un mouvement de la mémoire centrale vers la mémoire video (linéarisée) */
|
||||
u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
|
||||
u32 realdst=infos.baseaddress + infos.currentactivepage * infos.pagesize+dst;
|
||||
switch (infos.currentdepth) {
|
||||
case 32:
|
||||
if (!increment_src)
|
||||
{
|
||||
u32 pattern = (u32) src;
|
||||
stosb(pattern,realdst,size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -67,7 +137,13 @@ u32 VESA_video_to_mem (u32 src,void *dst, u32 size)
|
|||
/* Effecture un mouvement de la mémoire video (linéarisé) vers la mémoire vidéo (linéarisée) */
|
||||
u32 VESA_video_to_video (u32 src,u32 dst, u32 size)
|
||||
{
|
||||
|
||||
u32 realsrc=infos.baseaddress + infos.currentactivepage * infos.pagesize+src;
|
||||
u32 realdst=infos.baseaddress + infos.currentactivepage * infos.pagesize+dst;
|
||||
switch (infos.currentdepth) {
|
||||
case 32:
|
||||
movsd(realsrc,realdst,size>>2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -75,7 +151,7 @@ u32 VESA_video_to_video (u32 src,u32 dst, u32 size)
|
|||
|
||||
void VESA_page_set(u8 page)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -83,7 +159,7 @@ void VESA_page_set(u8 page)
|
|||
|
||||
void VESA_page_show(u8 page)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -91,7 +167,7 @@ void VESA_page_show(u8 page)
|
|||
|
||||
void VESA_dummy(void)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
|
14
lib/vga.c
14
lib/vga.c
|
@ -202,6 +202,20 @@ u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
|
|||
stosb(pattern,realdst,size);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (size%4 == 0)
|
||||
{
|
||||
movsd(src,realdst,size>>2);
|
||||
}
|
||||
else if (size%2 == 0)
|
||||
{
|
||||
movsw(src,realdst,size>>1);
|
||||
}
|
||||
else
|
||||
{
|
||||
movsb(src,realdst,size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
|
||||
|
|
43
lib/video.c
43
lib/video.c
|
@ -1,8 +1,6 @@
|
|||
/*******************************************************************************/
|
||||
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
||||
/* */
|
||||
#include "vga.h"
|
||||
#include "vesa.h"
|
||||
#include "asm.h"
|
||||
#include "video.h"
|
||||
#include "stdarg.h"
|
||||
|
@ -870,8 +868,11 @@ void registerdriver(videofonction *pointer)
|
|||
i=0;
|
||||
while (registred[i].nom!=NULL && i<MAXDRIVERS)
|
||||
i++;
|
||||
if (pointer->detect_hardware()!=NULL)
|
||||
{
|
||||
registred[i].pointer=pointer;
|
||||
registred[i].nom=pointer->getvideo_drivername();
|
||||
}
|
||||
}
|
||||
/*******************************************************************************/
|
||||
/* Choisi le meilleur driver en terme d'affichage */
|
||||
|
@ -970,18 +971,6 @@ void apply_nextvideomode(void) {
|
|||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Initialise la video */
|
||||
|
||||
void initvideo(void)
|
||||
{
|
||||
initdriver();
|
||||
registerdriver(&vgafonctions);
|
||||
registerdriver(&vesafonctions);
|
||||
apply_driver("VGA");
|
||||
changemode(0x01);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Rempli l'écran avec un attribut donné et des espaces vides */
|
||||
|
||||
|
@ -1048,6 +1037,7 @@ void scroll_disable(void)
|
|||
void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||
{
|
||||
u8 x, y, pattern, set;
|
||||
u32 color;
|
||||
if (!vinfo->isgraphic)
|
||||
{
|
||||
u32 addr=(coordx<<1)+vinfo->currentpitch*coordy;
|
||||
|
@ -1063,15 +1053,24 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
|||
{
|
||||
set = pattern & 0x1;
|
||||
if (set == 0)
|
||||
writepxl((coordx<<3) + x, (coordy<<3) + y, ((attrib & 0xF0) >> 8));
|
||||
if (vinfo->currentdepth>24)
|
||||
color = 0xFFFFFF;
|
||||
else
|
||||
writepxl((coordx<<3) + x, (coordy<<3) + y, (attrib & 0x0F) );
|
||||
color = ((attrib & 0xF0) >> 8);
|
||||
else
|
||||
if (vinfo->currentdepth>24)
|
||||
color = 0;
|
||||
else
|
||||
color = (attrib & 0x0F);
|
||||
writepxl((coordx<<3) + x, (coordy<<3) + y, color);
|
||||
rol(pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Retourne le caractère du mode texte aux coordonnées spécifiées */
|
||||
|
||||
|
@ -1107,10 +1106,13 @@ u8 getattrib (u16 coordx, u16 coordy)
|
|||
|
||||
void hline(u32 x1, u32 x2, u32 y, u8 color)
|
||||
{
|
||||
if (vinfo->isgraphic)
|
||||
{
|
||||
if (x2 > x1)
|
||||
mem_to_video(color,x1,x2-x1,false);
|
||||
mem_to_video(color,x1+vinfo->currentpitch*y,x2-x1,false);
|
||||
else
|
||||
mem_to_video(color,x2,x2-x1,false);
|
||||
mem_to_video(color,x2+vinfo->currentpitch*y,x1-x2,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1118,7 +1120,10 @@ void hline(u32 x1, u32 x2, u32 y, u8 color)
|
|||
/* Affiche un pixel à l'écran */
|
||||
void writepxl (u16 x, u16 y, u32 color)
|
||||
{
|
||||
u32 addr=x+vinfo->currentpitch*y;
|
||||
if (vinfo->isgraphic)
|
||||
{
|
||||
u32 addr=(vinfo->currentdepth>>3)*x+vinfo->currentpitch*y;
|
||||
mem_to_video(color,addr,1,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
makefile
2
makefile
|
@ -61,6 +61,8 @@ redebug: littleclean debug-system
|
|||
|
||||
debug64: debug-system64
|
||||
|
||||
redebug64: littleclean debug-system64
|
||||
|
||||
debug-boot: bits32 harddisk qemu-debug
|
||||
(sleep 2;cgdb -x ./debug/boot.txt)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ SECTION .multiboot
|
|||
|
||||
%define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
|
||||
|
||||
%define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
|
||||
%define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
|
||||
|
||||
%define MULTIBOOT_HEADER_TAG_END 0
|
||||
|
||||
|
@ -28,25 +28,14 @@ align MULTIBOOT_TAG_ALIGN
|
|||
dd multiboot_header_end - multiboot_header
|
||||
dd -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
|
||||
align MULTIBOOT_TAG_ALIGN
|
||||
%if arch = "bitsd32"
|
||||
%warning "Avec la console VGA/EGA."
|
||||
console_tag_start:
|
||||
dw MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS ; type
|
||||
dw MULTIBOOT_HEADER_TAG_OPTIONAL ; flags
|
||||
dd console_tag_end - console_tag_start
|
||||
dd MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED
|
||||
console_tag_end:
|
||||
%else
|
||||
align MULTIBOOT_TAG_ALIGN
|
||||
framebuffer_tag_start:
|
||||
%warning "Avec le FRAMEBUFFER VESA."
|
||||
dw MULTIBOOT_TAG_TYPE_FRAMEBUFFER ; type
|
||||
dw MULTIBOOT_HEADER_TAG_FRAMEBUFFER ; type
|
||||
dw MULTIBOOT_HEADER_TAG_OPTIONAL ; flags
|
||||
dd framebuffer_tag_end - framebuffer_tag_start
|
||||
dd 1024 ; width
|
||||
dd 768 ; height
|
||||
dd 32 ; depth
|
||||
%endif
|
||||
align MULTIBOOT_TAG_ALIGN
|
||||
framebuffer_tag_end:
|
||||
dw MULTIBOOT_HEADER_TAG_END
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
||||
/* */
|
||||
#include "vga.h"
|
||||
#include "vesa.h"
|
||||
#include "video.h"
|
||||
#include "interrupts.h"
|
||||
#include "timer.h"
|
||||
|
@ -46,25 +47,20 @@ void error()
|
|||
int main(u32 magic, u32 addr)
|
||||
{
|
||||
cli();
|
||||
initvideo();
|
||||
/* Efface l'ecran */
|
||||
if (magic == MULTIBOOT2_BOOTLOADER_MAGIC) initmultiboot(addr);
|
||||
initdriver();
|
||||
registerdriver(&vgafonctions);
|
||||
registerdriver(&vesafonctions);
|
||||
apply_bestdriver();
|
||||
changemode(0x0);
|
||||
|
||||
print("\033[2J\000");
|
||||
if (getwidth()>40) print(ansilogo);
|
||||
/* Efface l'ecran */
|
||||
print("\033[2J\r\n\000");
|
||||
if (getwidth()==80) print(ansilogo);
|
||||
|
||||
print("\033[37m\033[0m -Chargement noyaux");
|
||||
ok();
|
||||
|
||||
printf("\033[37m\033[0m -Nombre magique multiboot2 : %X",
|
||||
(u32) magic);
|
||||
if (magic == MULTIBOOT2_BOOTLOADER_MAGIC)
|
||||
{
|
||||
initmultiboot(addr);
|
||||
ok();
|
||||
}
|
||||
else
|
||||
error();
|
||||
|
||||
print("\033[37m\033[0m -Initilisation de la memoire (GDT)");
|
||||
initgdt(&&next);
|
||||
next:
|
||||
|
@ -75,7 +71,7 @@ int main(u32 magic, u32 addr)
|
|||
ok();
|
||||
|
||||
print("\033[37m\033[0m -Initilisation de la pagination (PAGING)");
|
||||
initpaging();
|
||||
//initpaging();
|
||||
ok();
|
||||
|
||||
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)");
|
||||
|
|
Loading…
Reference in New Issue