From: acevest Date: Mon, 29 Dec 2025 11:10:21 +0000 (+0800) Subject: 图形模式的进一步测试 X-Git-Url: http://repos.zhaoyanbai.com/Mou_128.png?a=commitdiff_plain;h=54710834cca593d161f5bca5f7fcdefbe9f7cccc;p=kernel.git 图形模式的进一步测试 --- diff --git a/.gitignore b/.gitignore index 6b0ccfb..27c3157 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,4 @@ initrd initfs rootfs **/init - +*.log diff --git a/boot/boot.c b/boot/boot.c index a1dfb90..1b2905b 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -57,6 +57,27 @@ void set_tss(); void setup_i8254(uint16_t); void setup_boot_irqs(); +void parse_framebuffer(void *addr) { + struct multiboot_tag_framebuffer *fb = (struct multiboot_tag_framebuffer *)addr; + if(0 == fb) { + printk("no framebuffer info\n"); + } + + uint32_t type = fb->common.type; + uint32_t size = fb->common.size; + uint64_t fb_addr = fb->common.framebuffer_addr; + uint32_t fb_pitch = fb->common.framebuffer_pitch; + uint32_t fb_width = fb->common.framebuffer_width; + uint32_t fb_height = fb->common.framebuffer_height; + uint8_t fb_bpp = fb->common.framebuffer_bpp; + uint8_t fb_type = fb->common.framebuffer_type; + + printk("type %u size %u addr %lx pitch %u width %u height %u bpp %u type %u\n", + type, size, fb_addr, fb_pitch, fb_width, fb_height, fb_bpp, fb_type); + + +} + void check_kernel(unsigned long addr, unsigned long magic) { init_serial(); @@ -187,6 +208,7 @@ void check_kernel(unsigned long addr, unsigned long magic) { break; case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: printk("frame buffer\n"); + parse_framebuffer(tag); break; case MULTIBOOT_TAG_TYPE_ELF_SECTIONS: { diff --git a/boot/multiboot.S b/boot/multiboot.S index 1e6d69f..fa76874 100644 --- a/boot/multiboot.S +++ b/boot/multiboot.S @@ -130,27 +130,33 @@ multiboot2_header_bgn: # checksum .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot2_header_end - multiboot2_header_bgn)) - // .align 8 - // .framebuffer_tag_bgn: - // .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER - // .short MULTIBOOT_HEADER_TAG_OPTIONAL - // .long .framebuffer_tag_end - .framebuffer_tag_bgn - // # width - // # Contains the number of the columns. This is specified in pixels in a graphics mode, - // # and in characters in a text mode. - // # The value zero indicates that the OS image has no preference. - // .long 1024 - // # height - // # Contains the number of the lines. This is specified in pixels in a graphics mode, - // # and in characters in a text mode. - // # The value zero indicates that the OS image has no preference. - // .long 768 - // # depth - // # Contains the number of bits per pixel in a graphics mode, and zero in a text mode. - // # The value zero indicates that the OS image has no preference. - // .long 32 - // .framebuffer_tag_end: - +#if 1 + /* === Framebuffer Tag === */ + .align 8 + .framebuffer_tag_bgn: + .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER + .short MULTIBOOT_HEADER_TAG_OPTIONAL + .long .framebuffer_tag_end - .framebuffer_tag_bgn + + # width + # Contains the number of the columns. This is specified in pixels in a graphics mode, + # and in characters in a text mode. + # The value zero indicates that the OS image has no preference. + .long 0 + + # height + # Contains the number of the lines. This is specified in pixels in a graphics mode, + # and in characters in a text mode. + # The value zero indicates that the OS image has no preference. + .long 0 + + # depth + # Contains the number of bits per pixel in a graphics mode, and zero in a text mode. + # The value zero indicates that the OS image has no preference. + .long 0 + + .framebuffer_tag_end: +#endif // // .align 2 // .multiboot2_header_tag_module: // .short MULTIBOOT_HEADER_TAG_MODULE_ALIGN diff --git a/mkiso.sh b/mkiso.sh index 3b3645f..36180e8 100755 --- a/mkiso.sh +++ b/mkiso.sh @@ -68,7 +68,7 @@ for i in "${!files[@]}"; do done #docker exec -it $CONTAINER_ID /usr/bin/grub2-mkrescue -o /tmp/kernel.iso /tmp/iso/ -docker exec -it $CONTAINER_ID bash -c "cd /tmp && grub2-mkrescue -o kernel.iso /tmp/iso/" +docker exec -it $CONTAINER_ID bash -c "cd /tmp && grub2-mkrescue -o kernel.iso --modules=\"video video_bochs video_cirrus vbe\" /tmp/iso/" docker cp $CONTAINER_ID:/tmp/kernel.iso . diff --git a/scripts/iso.grub.cfg b/scripts/iso.grub.cfg index c245630..a18af78 100644 --- a/scripts/iso.grub.cfg +++ b/scripts/iso.grub.cfg @@ -1,17 +1,26 @@ #serial --unit=0 --speed=115200 -serial --unit=0 -terminal_input serial -terminal_output serial +#serial --unit=0 +#terminal_input serial +#terminal_output serial +#terminal_output serial_com0 +load_video +set gfxmode=auto +set gfxpayload=keep +terminal_output gfxterm + set default="0" set timeout=0 menuentry 'Kernel' --class os { #insmod ext2 #set gfxpayload=1024x768x32 #insmod all_video + #set gfxmode=auto + #set gfxmode=auto multiboot2 /boot/Kernel root=hda7 delay=2 module2 /boot/rootfs rootfs #module2 /boot/init init + videoinfo boot }