struct boot_params boot_params __attribute__((aligned(32)));
void parse_cmdline(const char *cmdline);
-void init_vbe(void *vmiptr);
+void init_vbe(void *, void *);
void check_kernel(unsigned long addr, unsigned long magic) {
if (magic != MULTIBOOT2_BOOTLOADER_MAGIC) {
printk("Your boot loader does not support multiboot.\n");
void *vmi = (void *)vbe->vbe_mode_info.external_specification;
// vbe->vbe_control_info;
// asm volatile("xchg %%bx, %%bx;nop;nop;" ::"a"(vci), "b"(vmi));
- init_vbe(vmi);
+ // asm volatile("xchg %%bx, %%bx;nop;nop;" ::"a"(vbe->vbe_interface_seg), "b"(vbe->vbe_interface_off),
+ // "c"(vbe->vbe_interface_len));
+ init_vbe(vci, vmi);
break;
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
- asm volatile("xchg %bx, %bx;nop;nop;nop;nop;");
+ // asm volatile("xchg %bx, %bx;nop;nop;nop;nop;");
break;
default:
printk("tag %x size %x\n", tag->type, tag->size);
# 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
- .long 1280
- .long 800
- .long 32
- .framebuffer_tag_end:
+ // .align 8
+ // .framebuffer_tag_bgn:
+ // .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER
+ // .short MULTIBOOT_HEADER_TAG_OPTIONAL
+ // .long .framebuffer_tag_end - .framebuffer_tag_bgn
+ // .long 800
+ // .long 600
+ // .long 32
+ // .framebuffer_tag_end:
.align 8
.multiboot2_tag_end:
// #include <page.h>
#include <system.h>
#include <types.h>
+
typedef struct vbe_mode_info {
u16 mode_attributes;
u8 wina_attributes;
// pte_t vbe_pte[PTECNT_PER_PAGE] __attribute__((__aligned__(PAGE_SIZE)));
// extern pde_t init_pgd[];
-void init_vbe(void *vmiptr) {
+void init_vbe(void *vciptr, void *vmiptr) {
vbe_mode_info_t *vmi = (vbe_mode_info_t *)vmiptr;
+
system.vbe_phys_addr = vmi->phys_base_ptr;
system.x_resolution = vmi->x_resolution;
system.y_resolution = vmi->y_resolution;
- // unsigned long phys_base_addr = vmi->phys_base_ptr;
-
- // asm volatile("xchg %%bx, %%bx;nop;" ::"a"(phys_base_addr));
-
- // init_pgd[phys_base_addr >> 22] = va2pa(vbe_pte) | 7;
- // asm volatile("xchg %bx, %bx;nop;nop;nop;nop;");
- // for (int i = 0; i < PTECNT_PER_PAGE; i++) {
- // vbe_pte[i] = phys_base_addr + i * PAGE_SIZE + 7;
- // }
- // asm volatile("xchg %bx, %bx;nop;nop;nop;nop;");
- // unsigned long *p = (unsigned long *)phys_base_addr;
- // for (int i = 0; i < 1024; i++) {
- // p[i] = 0x00FF0000;
- // }
}
\ No newline at end of file
LoadCR3(va2pa(init_pgd));
- // 测试显存
- for (int i = 0; i < 4096; i++) {
- unsigned long *vram = (unsigned long *)VRAM_VADDR_BASE;
- vram[i] = 0x00FF0000;
- }
+ // // 测试显存
+ // for (int i = 0; i < system.x_resolution * (system.y_resolution - 32); i++) {
+ // unsigned long *vram = (unsigned long *)VRAM_VADDR_BASE;
+ // vram[i] = 0x000000FF;
+ // }
+
+ // while (1) {
+ // u16 lineH = 32;
+ // unsigned long *vram = (unsigned long *)VRAM_VADDR_BASE;
+ // int sep = system.x_resolution * (system.y_resolution - lineH);
+ // for (int i = 0; i < sep; i++) {
+ // vram[i] = vram[i + system.x_resolution * lineH];
+ // }
+
+ // unsigned int long color = 0x0000FF;
+ // color = (vram[0] == 0x0000FF ? 0x00FF00 : 0x0000FF);
+
+ // for (int i = sep; i < sep + system.x_resolution * lineH; i++) {
+ // vram[i] = color;
+ // }
+ // }
}
void init_mm() {
set default="0"
set timeout=1
-
menuentry 'Kernel' --class os {
#insmod ext2
- set root='(hd0,msdos1)'
+ set root='(hd0,1)'
multiboot2 /boot/Kernel root=hda0 delay=2
boot
}