diff options
Diffstat (limited to 'kernel/vesa.c')
| -rw-r--r-- | kernel/vesa.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/kernel/vesa.c b/kernel/vesa.c new file mode 100644 index 0000000..93a42f3 --- /dev/null +++ b/kernel/vesa.c @@ -0,0 +1,111 @@ +//http://wiki.osdev.org/GUI +#include "kernel.h" + +typedef struct vbeinfo_struct{ + char VbeSignature[4]; // == "VESA" + uint16_t VbeVersion; // == 0x0300 for VBE 3.0 + uint16_t OemStringPtr[2]; // isa vbeFarPtr + uint8_t Capabilities[4]; + uint16_t VideoModePtr[2]; // isa vbeFarPtr + uint16_t TotalMemory; // as # of 64KB blocks +}vbeinfo; + +typedef struct ModeInfoBlock { + uint16_t attributes; + uint8_t winA,winB; + uint16_t granularity; + uint16_t winsize; + uint16_t segmentA, segmentB; + uint16_t realFctPtr[2]; +// VBE_FAR(realFctPtr); + uint16_t pitch; // bytes per scanline + + uint16_t Xres, Yres; + uint8_t Wchar, Ychar, planes, bpp, banks; + uint8_t memory_model, bank_size, image_pages; + uint8_t reserved0; + + uint8_t red_mask, red_position; + uint8_t green_mask, green_position; + uint8_t blue_mask, blue_position; + uint8_t rsv_mask, rsv_position; + uint8_t directcolor_attributes; + + uint32_t physbase; // your LFB (Linear Framebuffer) address ;) + uint32_t reserved1; + uint16_t reserved2; +}vbemodeinfo; + +static vbemodeinfo *VbeModeInfoBlock; + +void vesa_init(vbeinfo *info,vbemodeinfo *mode) +{ + int i=0; + +// while(info[i].VbeSignature[0]=='V') + // { + scr_put_string("vesa: init vbe version: "); + scr_put_hex(info[i].VbeVersion); + scr_put_string(" / videomode ptr: "); + scr_put_hex(info[i].VideoModePtr[0]); + scr_put_hex(info[i].VideoModePtr[1]); + scr_put_string_nl(""); + +// i++; + // } + // + int *modeptr=info[i].VideoModePtr[0]; // 0x8322; // do not hardcode !!! take from vbeinfo! + + while(*modeptr!=0xffff&&*modeptr!=0) + { + + scr_put_string("vesa: mode supported: "); + scr_put_hex(*modeptr); + scr_put_string_nl(""); + + modeptr++; + } + + scr_put_string("vesa: selected mode res: "); + scr_put_hex(mode->Xres); + scr_put_string(" x "); + scr_put_hex(mode->Yres); + scr_put_string_nl(""); + scr_put_string("vesa: selected mode banks: "); + scr_put_hex(mode->banks); + scr_put_string_nl(""); + scr_put_string("vesa: attribs: "); + scr_put_hex(mode->attributes); + scr_put_string_nl(""); + scr_put_string("vesa: physbase: "); + scr_put_hex32(mode->physbase); + scr_put_string_nl(""); + scr_put_string("vesa: bpp: "); + scr_put_hex(mode->bpp); + scr_put_string_nl(""); +/* +uint8_t *videomem=mode->physbase; +for(i=0;i<0xffffff;i++) +{ + videomem[i]=i; +} +*/ + + VbeModeInfoBlock=mode; + + +} + +void PutPixel(int x,int y, int color){ + + //do not write memory outside the screen buffer, check parameters against the VBE mode info + if (x<0 || x>VbeModeInfoBlock->Xres|| y<0 || y>VbeModeInfoBlock->Yres) return; +// + if (x) x = (x*(VbeModeInfoBlock->bpp>>3)); // get bytes (divide by 8) + if (y) y = (y*VbeModeInfoBlock->pitch); + uint8_t *cTemp=VbeModeInfoBlock->physbase; + cTemp[x+y] = (uint8_t)(color & 0xff); + cTemp[x+y+1] = (uint8_t)((color>>8) & 0xff); + cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff); + } + |
