VESA 24bpp using QEMU from WSL (blue channel not working)

I am currently struggling with VESA graphics.

I am switching to VESA using this assembly code below

Note: At this point I am still in 16 bit real-mode
Note 2: video_info is a label in the 32 bit area of my code. there should be no issues, since it is correctly initialized by the code below

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#Set VESA Mode
mov $0x4f02, %ax
movw $0x4118, %bx
int $0x10
mov %ds, %ax # Set up the extra segment
mov %ax, %es # with the data segment
#Get VESA Info
mov $(video_info-_start),%di
mov $0x4f01, %ax
mov %bx, %cx
int $0x10
# enable A20 line
inb $0x92, %al
orb $2, %al
outb %al, $0x92
# Load GDT
lgdt (gdt_init-_start)
# Enter protected mode
mov %cr0, %eax
or $1, %eax
mov %eax, %cr0
</code>
<code>#Set VESA Mode mov $0x4f02, %ax movw $0x4118, %bx int $0x10 mov %ds, %ax # Set up the extra segment mov %ax, %es # with the data segment #Get VESA Info mov $(video_info-_start),%di mov $0x4f01, %ax mov %bx, %cx int $0x10 # enable A20 line inb $0x92, %al orb $2, %al outb %al, $0x92 # Load GDT lgdt (gdt_init-_start) # Enter protected mode mov %cr0, %eax or $1, %eax mov %eax, %cr0 </code>
#Set VESA Mode
mov $0x4f02, %ax
movw $0x4118, %bx
int $0x10

mov %ds, %ax        # Set up the extra segment
mov %ax, %es        # with the data segment

#Get VESA Info
mov $(video_info-_start),%di
mov $0x4f01, %ax
mov %bx, %cx
int $0x10
    
# enable A20 line
inb $0x92, %al      
orb $2, %al
outb %al, $0x92

# Load GDT
lgdt (gdt_init-_start)

# Enter protected mode
mov %cr0, %eax
or $1, %eax
mov %eax, %cr0

After setting the mode, %ax is 0x4f

After this code, I switch to 32 bit real mode, then I jump to my kernel main written in C

I dont think that its important, but my gdt looks like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>.word 0,0,0,0 # seg 0 - null
.word 0xffff, 0x0000, 0x9a00, 0x00cf # seg 1 - kernel code
.word 0xffff, 0x0000, 0x9200, 0x00cf # seg 2 - kernel data
</code>
<code>.word 0,0,0,0 # seg 0 - null .word 0xffff, 0x0000, 0x9a00, 0x00cf # seg 1 - kernel code .word 0xffff, 0x0000, 0x9200, 0x00cf # seg 2 - kernel data </code>
.word   0,0,0,0             # seg 0 - null
    .word   0xffff, 0x0000, 0x9a00, 0x00cf  # seg 1 - kernel code
    .word   0xffff, 0x0000, 0x9200, 0x00cf  # seg 2 - kernel data

I tried to render some pixels to the screen.
The pixels are rendered, however, their color doesnt seem to be right.

After debugging the VESA Information I got the following details:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>PhysBasePtr = 0xfd000000
BitsPerPixel = 24
Red/Green/Bluemasksize = 8
RedfieldPosition = 16
GreenfieldPosition = 8
BluefieldPosition = 0
</code>
<code>PhysBasePtr = 0xfd000000 BitsPerPixel = 24 Red/Green/Bluemasksize = 8 RedfieldPosition = 16 GreenfieldPosition = 8 BluefieldPosition = 0 </code>
PhysBasePtr = 0xfd000000
BitsPerPixel = 24
Red/Green/Bluemasksize = 8
RedfieldPosition = 16
GreenfieldPosition = 8
BluefieldPosition = 0

Also, this returns true: ModeAttributes & (1 << 7)

That indicates that the framebuffer is linear

However, when i try this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>uint8_t* v = 0xfd000000
v[2] = 0x00; //Red
v[1] = 0x00; //Green
v[0] = 0xff; //Blue
</code>
<code>uint8_t* v = 0xfd000000 v[2] = 0x00; //Red v[1] = 0x00; //Green v[0] = 0xff; //Blue </code>
uint8_t* v = 0xfd000000
v[2] = 0x00; //Red
v[1] = 0x00; //Green
v[0] = 0xff; //Blue

The desired pixel is not blue but black

When I inspect the memory at 0xfd000000 the value is correct, but the pixel color is not

I am currently using qemu for emulation

The command I am using for running the Kernel is

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>qemu-system-x86_64 -drive format=raw,file=floppy.img -vga std -monitor stdio
</code>
<code>qemu-system-x86_64 -drive format=raw,file=floppy.img -vga std -monitor stdio </code>
qemu-system-x86_64 -drive format=raw,file=floppy.img -vga std -monitor stdio

I already tried changing some offsets from the physbase address but nothing seems to work for me.

I tried different -monitor and -vga options in qemu, none work for me apparently

Also, i tried running some other kernels I found on github (e.g dthain/basekernel) and trying around a bit, none of them seem to display the colors correctly for me.

I am using a RTX 3050 (idk if its important lmao)

Maybe the problem is WSL/Qemu related?

Any ideas why this is not working?

New contributor

FearXenon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật