From 359872e17655ddc008aabbabfed5fb8ab11bcb08 Mon Sep 17 00:00:00 2001 From: jason416 Date: Sat, 29 Jun 2019 13:10:54 +0800 Subject: [PATCH] fix HPET issue, IDE disk still not solved --- kernel/APIC.c | 2 +- kernel/HPET.c | 5 ++++- kernel/Makefile | 6 +++--- kernel/main.c | 12 ++++-------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/kernel/APIC.c b/kernel/APIC.c index 4af18f0..86fb9e0 100644 --- a/kernel/APIC.c +++ b/kernel/APIC.c @@ -352,7 +352,7 @@ void APIC_IOAPIC_init() IOAPIC_init(); /* for VMware platform, do not need to enable IOAPIC.*/ -#if 0 +#ifndef UEFI //get RCBA address io_out32(0xcf8,0x8000f8f0); x = io_in32(0xcfc); diff --git a/kernel/HPET.c b/kernel/HPET.c index 3f2bdec..785f129 100644 --- a/kernel/HPET.c +++ b/kernel/HPET.c @@ -59,7 +59,9 @@ void HPET_init() unsigned int * p = NULL; unsigned char * HPET_addr = (unsigned char *)Phy_To_Virt(0xfed00000); struct IO_APIC_RET_entry entry; - + +/* for VMware platform, get CRBA will not work */ +#ifndef UEFI //get RCBA address io_out32(0xcf8,0x8000f8f0); x = io_in32(0xcfc); @@ -74,6 +76,7 @@ void HPET_init() //enable HPET *p = 0x80; io_mfence(); +#endif //init I/O APIC IRQ2 => HPET Timer 0 entry.vector = 34; diff --git a/kernel/Makefile b/kernel/Makefile index f18ad81..1ab4727 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -18,7 +18,7 @@ BOOT_METHOD := UEFI all: system_tmp kallsyms.o ld -b elf64-x86-64 -z muldefs -o system head.o entry.o APU_boot.o main.o printk.o trap.o memory.o interrupt.o PIC.o task.o cpu.o keyboard.o mouse.o serial.o disk.o SMP.o time.o HPET.o softirq.o timer.o schedule.o fat32.o VFS.o sys.o syscalls.o semaphore.o waitqueue.o kallsyms.o -T Kernel.lds objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary system kernel.bin - sudo mount -o loop ~/Desktop/MINE_UEFI-flat.vmdk /mnt/ + sudo mount -o loop ~/Desktop/MINE_EFI-flat.vmdk /mnt/ sudo cp kernel.bin /mnt/ sudo umount /mnt sudo sync @@ -55,7 +55,7 @@ interrupt.o: interrupt.c ifeq ($(PIC),APIC) PIC.o: APIC.c - gcc $(CFLAGS) -c APIC.c -o PIC.o + gcc $(CFLAGS) -c APIC.c -o PIC.o -D$(BOOT_METHOD) else PIC.o: 8259A.c gcc $(CFLAGS) -c 8259A.c -o PIC.o @@ -86,7 +86,7 @@ time.o: time.c gcc $(CFLAGS) -c time.c HPET.o: HPET.c - gcc $(CFLAGS) -c HPET.c + gcc $(CFLAGS) -c HPET.c -D$(BOOT_METHOD) softirq.o: softirq.c gcc $(CFLAGS) -c softirq.c diff --git a/kernel/main.c b/kernel/main.c index 802cde0..d3221ba 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -131,13 +131,11 @@ color_printk(RED,BLACK,"boot_para_info->Graphics_Info.HorizontalResolution:%#018 color_printk(RED,BLACK,"mouse init \n"); mouse_init(); -// color_printk(RED,BLACK,"disk init \n"); -// disk_init(); + color_printk(RED,BLACK,"disk init \n"); + disk_init(); color_printk(RED,BLACK,"ICR init \n"); - /* IPI can not work, need to figure out */ -#if 1 SMP_init(); //prepare send INIT IPI @@ -200,14 +198,12 @@ color_printk(RED,BLACK,"boot_para_info->Graphics_Info.HorizontalResolution:%#018 icr_entry.vector = 0xc9; wrmsr(0x830,*(unsigned long *)&icr_entry); -#endif color_printk(RED,BLACK,"Timer init \n"); timer_init(); - /* in HPET_init(), get CRBA will not work on VMware */ - // color_printk(RED,BLACK,"HPET init \n"); - // HPET_init(); + color_printk(RED,BLACK,"HPET init \n"); + HPET_init(); #if 0 #include "serial.h" extern struct serial_des rs_table[]; -- Gitee