vbe: Fix handling of VBE versions older than 3.0
This commit is contained in:
parent
c0417a875d
commit
e7147188e1
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,7 +6,7 @@
|
|||||||
/**/*.bin
|
/**/*.bin
|
||||||
/**/*.bin.gz
|
/**/*.bin.gz
|
||||||
/**/*.elf
|
/**/*.elf
|
||||||
/**/*.img
|
/**/*.hdd
|
||||||
/bochsout.txt
|
/bochsout.txt
|
||||||
/bx_enh_dbg.ini
|
/bx_enh_dbg.ini
|
||||||
.vscode
|
.vscode
|
||||||
|
44
Makefile
44
Makefile
@ -2,7 +2,7 @@ CC = cc
|
|||||||
CFLAGS = -O2 -pipe -Wall -Wextra
|
CFLAGS = -O2 -pipe -Wall -Wextra
|
||||||
PATH := $(shell pwd)/toolchain/bin:$(PATH)
|
PATH := $(shell pwd)/toolchain/bin:$(PATH)
|
||||||
|
|
||||||
.PHONY: all clean stage2 stage2-clean decompressor decompressor-clean toolchain test.img echfs-test ext2-test fat32-test
|
.PHONY: all clean stage2 stage2-clean decompressor decompressor-clean toolchain test.hdd echfs-test ext2-test fat32-test
|
||||||
|
|
||||||
all: stage2 decompressor
|
all: stage2 decompressor
|
||||||
gzip -n -9 < stage2/stage2.bin > stage2/stage2.bin.gz
|
gzip -n -9 < stage2/stage2.bin > stage2/stage2.bin.gz
|
||||||
@ -37,30 +37,30 @@ toolchain:
|
|||||||
limine-install: limine-install.c
|
limine-install: limine-install.c
|
||||||
$(CC) $(CFLAGS) limine-install.c -o limine-install
|
$(CC) $(CFLAGS) limine-install.c -o limine-install
|
||||||
|
|
||||||
test.img:
|
test.hdd:
|
||||||
rm -f test.img
|
rm -f test.hdd
|
||||||
dd if=/dev/zero bs=1M count=0 seek=64 of=test.img
|
dd if=/dev/zero bs=1M count=0 seek=64 of=test.hdd
|
||||||
parted -s test.img mklabel msdos
|
parted -s test.hdd mklabel msdos
|
||||||
parted -s test.img mkpart primary 2048s 100%
|
parted -s test.hdd mkpart primary 2048s 100%
|
||||||
|
|
||||||
echfs-test: all limine-install test.img
|
echfs-test: all limine-install test.hdd
|
||||||
$(MAKE) -C test
|
$(MAKE) -C test
|
||||||
echfs-utils -m -p0 test.img quick-format 512 > part_guid
|
echfs-utils -m -p0 test.hdd quick-format 512 > part_guid
|
||||||
sed "s/@GUID@/`cat part_guid`/g" < test/limine.cfg > limine.cfg.tmp
|
sed "s/@GUID@/`cat part_guid`/g" < test/limine.cfg > limine.cfg.tmp
|
||||||
echfs-utils -m -p0 test.img import limine.cfg.tmp limine.cfg
|
echfs-utils -m -p0 test.hdd import limine.cfg.tmp limine.cfg
|
||||||
rm -f limine.cfg.tmp part_guid
|
rm -f limine.cfg.tmp part_guid
|
||||||
echfs-utils -m -p0 test.img import stage2.map boot/stage2.map
|
echfs-utils -m -p0 test.hdd import stage2.map boot/stage2.map
|
||||||
echfs-utils -m -p0 test.img import test/test.elf boot/test.elf
|
echfs-utils -m -p0 test.hdd import test/test.elf boot/test.elf
|
||||||
echfs-utils -m -p0 test.img import test/bg.bmp boot/bg.bmp
|
echfs-utils -m -p0 test.hdd import test/bg.bmp boot/bg.bmp
|
||||||
./limine-install limine.bin test.img
|
./limine-install limine.bin test.hdd
|
||||||
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon stdio
|
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.hdd -debugcon stdio
|
||||||
|
|
||||||
ext2-test: all limine-install test.img
|
ext2-test: all limine-install test.hdd
|
||||||
$(MAKE) -C test
|
$(MAKE) -C test
|
||||||
cp stage2.map test/
|
cp stage2.map test/
|
||||||
rm -rf test_image/
|
rm -rf test_image/
|
||||||
mkdir test_image
|
mkdir test_image
|
||||||
sudo losetup -Pf --show test.img > loopback_dev
|
sudo losetup -Pf --show test.hdd > loopback_dev
|
||||||
sudo partprobe `cat loopback_dev`
|
sudo partprobe `cat loopback_dev`
|
||||||
sudo mkfs.ext2 `cat loopback_dev`p1
|
sudo mkfs.ext2 `cat loopback_dev`p1
|
||||||
sudo mount `cat loopback_dev`p1 test_image
|
sudo mount `cat loopback_dev`p1 test_image
|
||||||
@ -70,14 +70,14 @@ ext2-test: all limine-install test.img
|
|||||||
sudo umount test_image/
|
sudo umount test_image/
|
||||||
sudo losetup -d `cat loopback_dev`
|
sudo losetup -d `cat loopback_dev`
|
||||||
rm -rf test_image loopback_dev
|
rm -rf test_image loopback_dev
|
||||||
./limine-install limine.bin test.img
|
./limine-install limine.bin test.hdd
|
||||||
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon stdio
|
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.hdd -debugcon stdio
|
||||||
|
|
||||||
fat32-test: all limine-install test.img
|
fat32-test: all limine-install test.hdd
|
||||||
$(MAKE) -C test
|
$(MAKE) -C test
|
||||||
rm -rf test_image/
|
rm -rf test_image/
|
||||||
mkdir test_image
|
mkdir test_image
|
||||||
sudo losetup -Pf --show test.img > loopback_dev
|
sudo losetup -Pf --show test.hdd > loopback_dev
|
||||||
sudo partprobe `cat loopback_dev`
|
sudo partprobe `cat loopback_dev`
|
||||||
sudo mkfs.fat -F 32 `cat loopback_dev`p1
|
sudo mkfs.fat -F 32 `cat loopback_dev`p1
|
||||||
sudo mount `cat loopback_dev`p1 test_image
|
sudo mount `cat loopback_dev`p1 test_image
|
||||||
@ -87,5 +87,5 @@ fat32-test: all limine-install test.img
|
|||||||
sudo umount test_image/
|
sudo umount test_image/
|
||||||
sudo losetup -d `cat loopback_dev`
|
sudo losetup -d `cat loopback_dev`
|
||||||
rm -rf test_image loopback_dev
|
rm -rf test_image loopback_dev
|
||||||
./limine-install limine.bin test.img
|
./limine-install limine.bin test.hdd
|
||||||
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon stdio
|
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.hdd -debugcon stdio
|
||||||
|
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
BIN
stage2.map
BIN
stage2.map
Binary file not shown.
@ -571,12 +571,6 @@ bool init_vbe(struct vbe_framebuffer_info *ret,
|
|||||||
get_vbe_info(&vbe_info);
|
get_vbe_info(&vbe_info);
|
||||||
|
|
||||||
print("vbe: Version: %u.%u\n", vbe_info.version_maj, vbe_info.version_min);
|
print("vbe: Version: %u.%u\n", vbe_info.version_maj, vbe_info.version_min);
|
||||||
|
|
||||||
if (vbe_info.version_maj < 3) {
|
|
||||||
print("vbe: We do not support VBE versions older than 3.0\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
print("vbe: OEM: %s\n", (char *)rm_desegment(vbe_info.oem_seg, vbe_info.oem_off));
|
print("vbe: OEM: %s\n", (char *)rm_desegment(vbe_info.oem_seg, vbe_info.oem_off));
|
||||||
print("vbe: Graphics vendor: %s\n", (char *)rm_desegment(vbe_info.vendor_seg, vbe_info.vendor_off));
|
print("vbe: Graphics vendor: %s\n", (char *)rm_desegment(vbe_info.vendor_seg, vbe_info.vendor_off));
|
||||||
print("vbe: Product name: %s\n", (char *)rm_desegment(vbe_info.prod_name_seg, vbe_info.prod_name_off));
|
print("vbe: Product name: %s\n", (char *)rm_desegment(vbe_info.prod_name_seg, vbe_info.prod_name_off));
|
||||||
@ -604,10 +598,10 @@ bool init_vbe(struct vbe_framebuffer_info *ret,
|
|||||||
target_width, target_height, target_bpp);
|
target_width, target_height, target_bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
retry:;
|
|
||||||
uint16_t *vid_modes = (uint16_t *)rm_desegment(vbe_info.vid_modes_seg,
|
uint16_t *vid_modes = (uint16_t *)rm_desegment(vbe_info.vid_modes_seg,
|
||||||
vbe_info.vid_modes_off);
|
vbe_info.vid_modes_off);
|
||||||
|
|
||||||
|
retry:
|
||||||
for (size_t i = 0; vid_modes[i] != 0xffff; i++) {
|
for (size_t i = 0; vid_modes[i] != 0xffff; i++) {
|
||||||
struct vbe_mode_info_struct vbe_mode_info;
|
struct vbe_mode_info_struct vbe_mode_info;
|
||||||
get_vbe_mode_info(&vbe_mode_info, vid_modes[i]);
|
get_vbe_mode_info(&vbe_mode_info, vid_modes[i]);
|
||||||
@ -617,6 +611,9 @@ retry:;
|
|||||||
// We only support RGB for now
|
// We only support RGB for now
|
||||||
if (vbe_mode_info.memory_model != 0x06)
|
if (vbe_mode_info.memory_model != 0x06)
|
||||||
continue;
|
continue;
|
||||||
|
// We only support linear modes
|
||||||
|
if (!(vbe_mode_info.mode_attributes & (1 << 7)))
|
||||||
|
continue;
|
||||||
print("vbe: Found matching mode %x, attempting to set...\n", vid_modes[i]);
|
print("vbe: Found matching mode %x, attempting to set...\n", vid_modes[i]);
|
||||||
if (set_vbe_mode(vid_modes[i]) == 0x01) {
|
if (set_vbe_mode(vid_modes[i]) == 0x01) {
|
||||||
print("vbe: Failed to set video mode %x, moving on...\n", vid_modes[i]);
|
print("vbe: Failed to set video mode %x, moving on...\n", vid_modes[i]);
|
||||||
@ -625,16 +622,26 @@ retry:;
|
|||||||
print("vbe: Framebuffer address: %x\n", vbe_mode_info.framebuffer_addr);
|
print("vbe: Framebuffer address: %x\n", vbe_mode_info.framebuffer_addr);
|
||||||
ret->memory_model = vbe_mode_info.memory_model;
|
ret->memory_model = vbe_mode_info.memory_model;
|
||||||
ret->framebuffer_addr = vbe_mode_info.framebuffer_addr;
|
ret->framebuffer_addr = vbe_mode_info.framebuffer_addr;
|
||||||
ret->framebuffer_pitch = vbe_mode_info.lin_bytes_per_scanline;
|
|
||||||
ret->framebuffer_width = vbe_mode_info.res_x;
|
ret->framebuffer_width = vbe_mode_info.res_x;
|
||||||
ret->framebuffer_height = vbe_mode_info.res_y;
|
ret->framebuffer_height = vbe_mode_info.res_y;
|
||||||
ret->framebuffer_bpp = vbe_mode_info.bpp;
|
ret->framebuffer_bpp = vbe_mode_info.bpp;
|
||||||
ret->red_mask_size = vbe_mode_info.lin_red_mask_size;
|
if (vbe_info.version_maj < 3) {
|
||||||
ret->red_mask_shift = vbe_mode_info.lin_red_mask_shift;
|
ret->framebuffer_pitch = vbe_mode_info.bytes_per_scanline;
|
||||||
ret->green_mask_size = vbe_mode_info.lin_green_mask_size;
|
ret->red_mask_size = vbe_mode_info.red_mask_size;
|
||||||
ret->green_mask_shift = vbe_mode_info.lin_green_mask_shift;
|
ret->red_mask_shift = vbe_mode_info.red_mask_shift;
|
||||||
ret->blue_mask_size = vbe_mode_info.lin_blue_mask_size;
|
ret->green_mask_size = vbe_mode_info.green_mask_size;
|
||||||
ret->blue_mask_shift = vbe_mode_info.lin_blue_mask_shift;
|
ret->green_mask_shift = vbe_mode_info.green_mask_shift;
|
||||||
|
ret->blue_mask_size = vbe_mode_info.blue_mask_size;
|
||||||
|
ret->blue_mask_shift = vbe_mode_info.blue_mask_shift;
|
||||||
|
} else {
|
||||||
|
ret->framebuffer_pitch = vbe_mode_info.lin_bytes_per_scanline;
|
||||||
|
ret->red_mask_size = vbe_mode_info.lin_red_mask_size;
|
||||||
|
ret->red_mask_shift = vbe_mode_info.lin_red_mask_shift;
|
||||||
|
ret->green_mask_size = vbe_mode_info.lin_green_mask_size;
|
||||||
|
ret->green_mask_shift = vbe_mode_info.lin_green_mask_shift;
|
||||||
|
ret->blue_mask_size = vbe_mode_info.lin_blue_mask_size;
|
||||||
|
ret->blue_mask_shift = vbe_mode_info.lin_blue_mask_shift;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -647,5 +654,5 @@ retry:;
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("Could not set a video mode");
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user