Skip to content

Commit

Permalink
adding gfx files
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkl committed Mar 29, 2018
1 parent ab97568 commit 03cf875
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 18 deletions.
4 changes: 4 additions & 0 deletions bootdisk-root/boot/grub/grub.cfg
@@ -1,14 +1,18 @@
insmod vbe
insmod vga

menuentry "SOSO DISK" {
set root=(hd0,1)
multiboot /boot/kernel.bin
module /boot/initrd.fat
set gfxpayload=1024x768x32
boot
}

menuentry "SOSO CD" {
set root=(cd)
multiboot /boot/kernel.bin
module /boot/initrd.fat
set gfxpayload=1024x768x32
boot
}
14 changes: 12 additions & 2 deletions kernel/boot.asm
@@ -1,7 +1,8 @@
MBOOT_PAGE_ALIGN equ 1<<0
MBOOT_MEM_INFO equ 1<<1
MBOOT_USE_GFX equ 1<<2
MBOOT_HEADER_MAGIC equ 0x1BADB002
MBOOT_HEADER_FLAGS equ MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO
MBOOT_HEADER_FLAGS equ MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO ;| MBOOT_USE_GFX
MBOOT_CHECKSUM equ -(MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS)


Expand All @@ -13,7 +14,16 @@ align 4
dd MBOOT_HEADER_MAGIC
dd MBOOT_HEADER_FLAGS
dd MBOOT_CHECKSUM

dd 0x00000000 ; header_addr
dd 0x00000000 ; load_addr
dd 0x00000000 ; load_end_addr
dd 0x00000000 ; bss_end_addr
dd 0x00000000 ; entry_addr
; Graphics requests
dd 0x00000000 ; 0 = linear graphics
dd 1024
dd 768
dd 32

section .bss
align 16
Expand Down
40 changes: 40 additions & 0 deletions kernel/gfx.c
@@ -0,0 +1,40 @@
#include "gfx.h"
#include "vmm.h"
#include "serial.h"

static uint32 gWidth = 0;
static uint32 gHeight = 0;
static uint32 gBytePerPixel = 0;
static uint32* gPixels = NULL;

void Gfx_Initialize(uint32* pixels, uint32 width, uint32 height, uint32 bytePerPixel)
{
gPixels = pixels;
gWidth = width;
gHeight = height;
gBytePerPixel = bytePerPixel;

Serial_PrintF("Gfx_Initialize\n");

char* p_address = (char*)gPixels;
char* v_address = (char*)gPixels;

Serial_PrintF("Gfx_Initialize: %x\n", gPixels);

BOOL success = addPageToPd(gKernelPageDirectory, v_address, p_address, 0);

if (success)
{
Serial_PrintF("Gfx_Initialize: success\n");

for (int y = 0; y < gHeight; ++y)
{
for (int x = 0; x < gWidth; ++x)
{
gPixels[x + y * gWidth] = 255;
}
}
}

Serial_PrintF("Gfx_Initialize: end\n");
}
8 changes: 8 additions & 0 deletions kernel/gfx.h
@@ -0,0 +1,8 @@
#ifndef GFX_H
#define GFX_H

#include "common.h"

void Gfx_Initialize(uint32* pixels, uint32 width, uint32 height, uint32 bytePerPixel);

#endif // GFX_H
15 changes: 2 additions & 13 deletions kernel/main.c
Expand Up @@ -22,6 +22,7 @@
#include "fatfilesystem.h"
#include "vbe.h"
#include "fifobuffer.h"
#include "gfx.h"

extern uint32 _start;
extern uint32 _end;
Expand Down Expand Up @@ -425,19 +426,7 @@ int kmain(struct Multiboot *mboot_ptr)

Debug_initialize("/dev/tty10");

vbe_mode_info_t* vbe_info = (vbe_mode_info_t*)mboot_ptr->vbe_mode_info;
if (vbe_info)
{
Screen_PrintF("Video: x:%d, y:%d\n", vbe_info->XResolution, vbe_info->YResolution);
}

Serial_PrintF("framebuffer_addr: %x\n", mboot_ptr->framebuffer_addr);
Serial_PrintF("framebuffer_pitch: %d\n", mboot_ptr->framebuffer_pitch);
Serial_PrintF("framebuffer_width: %d\n", mboot_ptr->framebuffer_width);
Serial_PrintF("framebuffer_height: %d\n", mboot_ptr->framebuffer_height);
Serial_PrintF("framebuffer_bpp: %d\n", mboot_ptr->framebuffer_bpp);
Serial_PrintF("framebuffer_type: %d\n", mboot_ptr->framebuffer_type);

//Gfx_Initialize((uint32*)(uint32)mboot_ptr->framebuffer_addr, mboot_ptr->framebuffer_width, mboot_ptr->framebuffer_height, mboot_ptr->framebuffer_bpp / 32);

initializeRandom();

Expand Down
3 changes: 3 additions & 0 deletions kernel/multiboot.h
Expand Up @@ -3,6 +3,9 @@

#include "common.h"

#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2

struct Multiboot
{
Expand Down
6 changes: 3 additions & 3 deletions kernel/vmm.c
Expand Up @@ -224,19 +224,19 @@ BOOL addPageToPd(uint32* pd, char *v_addr, char *p_addr, int flags)
{
uint32 *pde = NULL;

//Screen_PrintF("DEBUG: pd_add_page(): v_addr:%x p_addr:%x flags:%x\n", v_addr, p_addr, flags);
//Screen_PrintF("DEBUG: addPageToPd(): v_addr:%x p_addr:%x flags:%x\n", v_addr, p_addr, flags);


int index = (((uint32) v_addr & 0xFFC00000) >> 20) / 4;
pde = pd + index;
if ((*pde & PG_PRESENT) == PG_PRESENT)
{
//Already assigned!
Debug_PrintF("ERROR: pd_add_page(): pde:%x is already assigned!!\n", pde);
Debug_PrintF("ERROR: addPageToPd(): pde:%x is already assigned!!\n", pde);
return FALSE;
}

//Screen_PrintF("pd_add_page(): pde:%x\n", pde);
//Screen_PrintF("addPageToPd(): pde:%x\n", pde);

*pde = ((uint32) p_addr) | (PG_PRESENT | PG_4MB | PG_WRITE | flags);
//Screen_PrintF("pde:%x *pde:%x\n", pde, *pde);
Expand Down
2 changes: 2 additions & 0 deletions soso.files
Expand Up @@ -70,3 +70,5 @@ kernel/list.c
kernel/list.h
kernel/pipe.h
kernel/pipe.c
kernel/gfx.h
kernel/gfx.c

0 comments on commit 03cf875

Please sign in to comment.