Мигает в запущенном окне QEMU текст и нету текста INTERRUPT

283
14 июня 2018, 11:10

Всё собрал но текст появляется и тут же пропадает и нет текста INTERRUPT в QEMU постоянно обновляется мигает в окошке в QEMU запускал на Ubuntu 16.04 запускаю через команду qemu-system-i386 -kernel mykernel.bin что делать не знаю. Вот то что выводит консоль:

sergey@COMPUTER:~/Рабочий стол/myOS_9.0T$ make mykernel.bin
as --32 -o loader.o loader.s
g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o gdt.o -c gdt.cpp
g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o port.o -c port.cpp
as --32 -o interruptstubs.o interruptstubs.s
interruptstubs.s: Assembler messages:
interruptstubs.s: Warning: конец файла не в конце строки; вставлен символ новой строки
g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o interrupts.o -c interrupts.cpp
interrupts.cpp: In static member function ‘static uint32_t InterruptManager::handleInterrupt(uint8_t, uint32_t)’:
interrupts.cpp:88:24: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
     printf(" INTERRUPT");
                        ^
g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o kernel.o -c kernel.cpp
kernel.cpp: In function ‘void kernelMain(const void*, uint32_t)’:
kernel.cpp:49:56: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
     printf("Hello World!!This is MY OS TESTED VERSION!");
                                                        ^
kernel.cpp:50:56: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
     printf("Hello World!!This is MY OS TESTED VERSION!");
                                                        ^
ld -melf_i386 -T linker.ld -o mykernel.bin loader.o gdt.o port.o interruptstubs.o interrupts.o kernel.o
sergey@COMPUTER:~/Рабочий стол/myOS_9.0T$

interrupts.cpp

#include "interrupts.h"

void printf(char* str);

InterruptManager::GateDescriptor InterruptManager::InterruptDescriptorTable[256];
void InterruptManager::SetInterruptDescriptorTableEntry(
        uint8_t interruptNumber,
        uint16_t codeSegmentSelectorOffset,
        void (*handler)(),
        uint8_t DescriptorPrivilegeLevel,
        uint8_t DescriptorType)
{
    const uint8_t IDT_DESC_PRESENT = 0x80;
    InterruptDescriptorTable[interruptNumber].handlerAddressLowBits = ((uint32_t)handler) & 0xFFFF;
    InterruptDescriptorTable[interruptNumber].handlerAddressHighBits = (((uint32_t)handler) >> 16) & 0xFFFF;
    InterruptDescriptorTable[interruptNumber].gdt_codeSegmentSelector = codeSegmentSelectorOffset;
    InterruptDescriptorTable[interruptNumber].access = IDT_DESC_PRESENT | DescriptorType | ((DescriptorPrivilegeLevel&3) << 5);
    InterruptDescriptorTable[interruptNumber].reserved = 0;
}
InterruptManager::InterruptManager(GlobalDescriptorTable* gdt)
: picMasterCommand(0x20),
  picMasterData(0x21),
  picSlaveCommand(0xA0),
  picSlaveData(0xA1)
 {
    uint16_t CodeSegment = gdt->CodeSegmentSelector();
    const uint8_t IDT_INTERRUPT_GATE = 0xE;
    for(uint16_t i = 0; i < 256; i++)
        SetInterruptDescriptorTableEntry(i, CodeSegment, &IgnoreInterruptRequest, 0, IDT_INTERRUPT_GATE);
    SetInterruptDescriptorTableEntry(0x20, CodeSegment, &HandleInterruptRequest0x00, 0, IDT_INTERRUPT_GATE);
    SetInterruptDescriptorTableEntry(0x21, CodeSegment, &HandleInterruptRequest0x01, 0, IDT_INTERRUPT_GATE);

    picMasterCommand.Write(0x11);
    picSlaveCommand.Write(0x11);
    picMasterData.Write(0x20);
    picSlaveData.Write(0x28);
    picMasterData.Write(0x04);
    picSlaveData.Write(0x02);
    picMasterData.Write(0x01);
    picSlaveData.Write(0x01);
    picMasterData.Write(0x00);
    picSlaveData.Write(0x00);


    InterruptDescriptorTablePointer idt;
    idt.size = 256 * sizeof(GateDescriptor) - 1;
    idt.base = (uint32_t)InterruptDescriptorTable;
    asm volatile("lidt %0" : : "m" (idt));
}
void InterruptManager::IgnoreInterruptRequest()
{
}
InterruptManager::~InterruptManager()
{
}
void InterruptManager::Activate()
{
    asm("sti");
}

uint32_t InterruptManager::handleInterrupt(uint8_t interruptNumber, uint32_t esp)
{
    printf(" INTERRUPT");
    return esp;
}

kernel.cpp

#include "types.h"
#include "gdt.h"
#include "interrupts.h"
void printf(char* str)
{
    static uint16_t* VideoMemory = (uint16_t*)0xb8000;
    static uint16_t x=0, y=0;
    for(int i = 0; str[i] != '\0'; ++i)
    {
        switch(str[i])
        {
            case '\n':
                y++;
                x = 0;
                break;
            default:
                VideoMemory[80*y+x] = (VideoMemory[80*y+x] & 0xFF00) | str[i];
                x++;
                break;             
        }

        if(x >= 80)
        {
            y++;
            x = 0;
        }
        if(y >= 25)
        {
            for(y = 0; y < 25; y++)
                for(x = 0; x < 80; x++)
                    VideoMemory[80*y+x] = (VideoMemory[80*y+x] & 0xFF00) | ' ';
            x = 0;
            y = 0;
        }
    }
}
extern "C" void kernelMain(const void* multiboot_structure, uint32_t /*multiboot_magic*/)
{
    printf("Hello World!!This is MY OS TESTED VERSION!");
    printf("Hello World!!This is MY OS TESTED VERSION!");
    GlobalDescriptorTable gdt;
    InterruptManager interrupts(&gdt);
    interrupts.Activate();
    while(1);
}

если же вы хотите посмотреть все файлы вот ссылка https://yadi.sk/d/jWiS7mNZ3WaiLy

Если знаете помогите пожалуйста, заранее спасибо

READ ALSO
Архитектура ОС Линукс

Архитектура ОС Линукс

Передо мной схема ОСИду сверху вниз - Applications, System Libraries, System Call Interface etc

354
Реализация поиска простых делителей

Реализация поиска простых делителей

Всем привет, написал код по поиску простых чисел и запоминания этих чисел и их степеней:

274
Выбор папки. C++. MFC

Выбор папки. C++. MFC

Как вызвать Dialog для выбора папки, не для файла, а именно для папки?

214
Как сделать сайдбар по всей высоте родителя?

Как сделать сайдбар по всей высоте родителя?

Как сделать блок "Соседние статьи" справа по всей высоте родительского блока? Раньше у родительского блока была задана height, но ее пришлось...

251