2018-10-13 13:42:13 +02:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* COS2000 - Compatible Operating System - LGPL v3 - Hord<72> Nicolas */
|
|
|
|
|
/* */
|
|
|
|
|
#include "vesa.h"
|
|
|
|
|
#include "video.h"
|
|
|
|
|
#include "memory.h"
|
|
|
|
|
#include "asm.h"
|
|
|
|
|
#include "types.h"
|
2018-10-13 17:17:40 +02:00
|
|
|
|
#include "multiboot2.h"
|
2018-10-13 13:42:13 +02:00
|
|
|
|
|
|
|
|
|
static videoinfos infos;
|
|
|
|
|
|
|
|
|
|
static capabilities vesacapabilities[] = {
|
|
|
|
|
{0xFF,000,000,false, 0, 0},
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-13 17:17:40 +02:00
|
|
|
|
|
2018-10-13 13:42:13 +02:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */
|
|
|
|
|
u8 *VESA_detect_hardware(void) {
|
2018-11-14 22:23:10 +01:00
|
|
|
|
struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb();
|
|
|
|
|
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;
|
|
|
|
|
}
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Change le mode video courant */
|
|
|
|
|
/* ERR 0 aucune
|
|
|
|
|
/* ERR 1 mode non existant */
|
|
|
|
|
|
|
|
|
|
static u8 realsize;
|
|
|
|
|
|
|
|
|
|
u8 VESA_setvideo_mode(u8 mode)
|
|
|
|
|
{
|
2018-10-13 17:17:40 +02:00
|
|
|
|
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;
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Renvoie le nom du driver */
|
|
|
|
|
u8 *VESA_getvideo_drivername (void) {
|
|
|
|
|
return "VESA";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Renvoie un pointeur sur la structure des capacit<69>s graphiques */
|
|
|
|
|
|
|
|
|
|
u8 *VESA_getvideo_capabilities (void) {
|
|
|
|
|
return vesacapabilities;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Renvoie un pointeur sur l'<27>tat courant de la carte */
|
|
|
|
|
videoinfos *VESA_getvideo_info (void) {
|
|
|
|
|
return &infos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Effecture un mouvement de la m<>moire centrale vers la m<>moire video (lin<69>aris<69>e) */
|
|
|
|
|
u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
|
2018-10-13 17:17:40 +02:00
|
|
|
|
u32 realdst=infos.baseaddress + infos.currentactivepage * infos.pagesize+dst;
|
|
|
|
|
switch (infos.currentdepth) {
|
|
|
|
|
case 32:
|
|
|
|
|
if (!increment_src)
|
|
|
|
|
{
|
2018-10-16 21:56:39 +02:00
|
|
|
|
stosd(src,realdst,size);
|
2018-10-13 17:17:40 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Effecture un mouvement de la m<>moire video (lin<69>aris<69>e) vers la m<>moire centrale*/
|
|
|
|
|
u32 VESA_video_to_mem (u32 src,void *dst, u32 size)
|
|
|
|
|
{
|
2018-10-13 17:17:40 +02:00
|
|
|
|
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Effecture un mouvement de la m<>moire video (lin<69>aris<69>) vers la m<>moire vid<69>o (lin<69>aris<69>e) */
|
|
|
|
|
u32 VESA_video_to_video (u32 src,u32 dst, u32 size)
|
|
|
|
|
{
|
2018-10-13 17:17:40 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Fixe la page ecran de travail */
|
|
|
|
|
|
|
|
|
|
void VESA_page_set(u8 page)
|
|
|
|
|
{
|
2018-10-13 17:17:40 +02:00
|
|
|
|
return;
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Affiche la page ecran specifi<66> */
|
|
|
|
|
|
|
|
|
|
void VESA_page_show(u8 page)
|
|
|
|
|
{
|
2018-10-13 17:17:40 +02:00
|
|
|
|
return;
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Fonction inutile */
|
|
|
|
|
|
|
|
|
|
void VESA_dummy(void)
|
|
|
|
|
{
|
2018-10-13 17:17:40 +02:00
|
|
|
|
return;
|
2018-10-13 13:42:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Attend la retrace verticale */
|
|
|
|
|
|
|
|
|
|
void VESA_wait_vretrace(void)
|
|
|
|
|
{
|
|
|
|
|
while ((inb(STATE) & 8) == 0) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Attend la retrace horizontale */
|
|
|
|
|
|
|
|
|
|
void VESA_wait_hretrace(void)
|
|
|
|
|
{
|
|
|
|
|
while ((inb(STATE) & 1) == 0) ;
|
|
|
|
|
}
|
|
|
|
|
|