Plotting fancy stripe on graphical framebuffer

This commit is contained in:
Jarkko Toivanen 2023-06-16 05:53:26 +03:00
parent 743b22ccd6
commit 79dcbb8393
Signed by: jt
GPG key ID: 9151B109B73ECAD5
2 changed files with 48 additions and 15 deletions

View file

@ -57,13 +57,45 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
} }
if (mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) { if (mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) {
vga_write("\nFramebuffer: "); vga_write("\nFramebuffer: ");
vga_write("address: 0x");
vga_write(ultoa(mbootinfo->framebuffer_addr, 16));
serial_write_string("\nFramebuffer: "); serial_write_string("\nFramebuffer: ");
serial_write_string("address: 0x"); vga_write("address: 0x");
serial_write_string("\n Address: 0x");
vga_write(ultoa(mbootinfo->framebuffer_addr, 16));
serial_write_string(ultoa(mbootinfo->framebuffer_addr, 16)); serial_write_string(ultoa(mbootinfo->framebuffer_addr, 16));
unsigned long *vmem = mbootinfo->framebuffer_addr;
*vmem = 0xff00ff; serial_write_string("\n Dimensions: ");
serial_write_string(itoa(mbootinfo->framebuffer_width, 10));
serial_write_string("X");
serial_write_string(itoa(mbootinfo->framebuffer_height, 10));
serial_write_string("x");
serial_write_string(itoa(mbootinfo->framebuffer_bpp, 10));
serial_write_string("\n Pitch: ");
serial_write_string(itoa(mbootinfo->framebuffer_pitch, 10));
serial_write_string("\n RPos:");
serial_write_string(itoa(mbootinfo->framebuffer_red_field_position, 10));
serial_write_string("\n GPos:");
serial_write_string(itoa(mbootinfo->framebuffer_green_field_position, 10));
serial_write_string("\n BPos:");
serial_write_string(itoa(mbootinfo->framebuffer_blue_field_position, 10));
unsigned long *vmem;
int i;
for (i = 0; i < mbootinfo->framebuffer_height; i++) {
vmem = mbootinfo->framebuffer_addr + i*mbootinfo->framebuffer_pitch + i*(mbootinfo->framebuffer_bpp/8);
*vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
*vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
}
} else { } else {
vga_write_color("\nVideo info not available", VGA_COLOR_BLACK, VGA_COLOR_RED); vga_write_color("\nVideo info not available", VGA_COLOR_BLACK, VGA_COLOR_RED);
@ -71,4 +103,5 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
return; return;
} }
vga_write_line("\nExecution finished, halting..."); vga_write_line("\nExecution finished, halting...");
serial_write_string("\nExecution finished, halting...");
} }

View file

@ -3,7 +3,7 @@ use32
MULTIBOOT_PAGE_ALIGN equ (1 shl 0) MULTIBOOT_PAGE_ALIGN equ (1 shl 0)
MULTIBOOT_MEMORY_INFO equ (1 shl 1) MULTIBOOT_MEMORY_INFO equ (1 shl 1)
MULTIBOOT_VIDEO_REQUEST equ (0 shl 2) MULTIBOOT_VIDEO_REQUEST equ (1 shl 2)
MULTIBOOT_AOUT_KLUDGE equ (1 shl 16) MULTIBOOT_AOUT_KLUDGE equ (1 shl 16)
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_VIDEO_REQUEST MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_VIDEO_REQUEST
@ -13,15 +13,15 @@ MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAG
dd MULTIBOOT_HEADER_MAGIC dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM dd MULTIBOOT_CHECKSUM
; dd 0 ; header address dd 0 ; header address
; dd 0 ; load address dd 0 ; load address
; dd 0 ; load end address dd 0 ; load end address
; dd 0 ; bss end address dd 0 ; bss end address
; dd 0 ; entry address dd 0 ; entry address
; dd 0 ; video mode_type (0:fb, 1:txt) (set flags[2]!) dd 0 ; video mode_type (0:fb, 1:txt) (set flags[2]!)
; dd 1024 ; video width dd 1024 ; video width
; dd 768 ; video height dd 768 ; video height
; dd 24 ; video depth dd 32 ; video depth
section '.bss' writable align 16 section '.bss' writable align 16
stack_bottom: stack_bottom: