Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sergey@COMPUTER:~/Рабочий стол/myOS_8.0T$ make mykernel.bin
- as --32 -o interruptstubs.o interruptstubs.s
- interruptstubs.s: Assembler messages:
- interruptstubs.s: Warning: конец файла не в конце строки; вставлен символ новой строки
- interruptstubs.s:8: Error: junk at end of line, first unrecognized character is `:'
- interruptstubs.s:27: Error: bad register name `%0x00+IRQ_BASE'
- interruptstubs.s:28: Error: bad register name `%0x01+IRQ_BASE'
- Makefile:12: ошибка выполнения рецепта для цели «interruptstubs.o»
- make: *** [interruptstubs.o] Ошибка 1
- sergey@COMPUTER:~/Рабочий стол/myOS_8.0T$
- .set IRQ_BASE, 0x20
- .section .text
- .extern _ZN16InterruptManager15handleInterruptEhj
- .global _ZN16InterruptManager22IgnoreInterruptRequestEv:
- .macro HandleException num
- .global _ZN16InterruptManager16HandleExceptionnum()Ev
- _ZN16InterruptManager15HandleExceptionnum()Ev:
- movb %num, (interruptnumber)
- jmp int_bottom
- .endm
- .macro HandleInterruptRequest num
- .global _ZN16InterruptManager26HandleInterruptRequestnum()Ev
- _ZN16InterruptManager26HandleInterruptRequestnum()Ev:
- movb %num + IRQ_BASE, (interruptnumber)
- jmp int_bottom
- .endm
- HandleInterruptRequest 0x00
- HandleInterruptRequest 0x01
- int_bottom:
- pusha
- pushl %ds
- pushl %es
- pushl %fs
- pushl %gs
- pushl %esp
- push (interruptnumber)
- call _Z15handleInterrupthj
- # addl $5, %esp
- movl %eax, %esp
- popl %gs
- popl %fs
- popl %es
- popl %ds
- popa
- _ZN16InterruptManager22IgnoreInterruptRequestEv:
- iret
- .data
- interruptnumber: .byte 0
- #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)
- {
- 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);
- InterruptDescriptorTablePointer idt;
- idt.size = 256 * sizeof(GateDescriptor) - 1;
- idt.base = (uint32_t)InterruptDescriptorTable;
- asm volatile("lidt %0" : : "m" (idt));
- }
- InterruptManager::~InterruptManager()
- {
- }
- void InterruptManager::Activate()
- {
- asm("sti");
- }
- uint32_t InterruptManager::handleInterrupt(uint8_t interruptNumber, uint32_t esp)
- {
- printf(" INTERRUPT");
- return esp;
- }
- #ifndef __INTERRUPTS_H
- #define __INTERRUPTS_H
- #include "types.h"
- #include "port.h"
- #include "gdt.h"
- class InterruptManager
- {
- protected:
- struct GateDescriptor
- {
- uint16_t handlerAddressLowBits;
- uint16_t gdt_codeSegmentSelector;
- uint8_t reserved;
- uint8_t access;
- uint16_t handlerAddressHighBits;
- } __attribute__((packed));
- static GateDescriptor InterruptDescriptorTable[256];
- struct InterruptDescriptorTablePointer
- {
- uint16_t size;
- uint32_t base;
- } __attribute__((packed));
- static void SetInterruptDescriptorTableEntry(
- uint8_t interruptNumber,
- uint16_t codeSegmentSelectorOffset,
- void (*handler)(),
- uint8_t DescriptorPrivilegeLevel,
- uint8_t DescriptorType
- );
- public:
- InterruptManager(GlobalDescriptorTable* gdt);
- ~InterruptManager();
- void Activate();
- static uint32_t handleInterrupt(uint8_t interruptNumber, uint32_t esp);
- static void IgnoreInterruptRequest();
- static void HandleInterruptRequest0x00();
- static void HandleInterruptRequest0x01();
- };
- #endif
- .global _ZN16InterruptManager22IgnoreInterruptRequestEv:
- interruptstubs.s:8: Error: junk at end of line, first unrecognized character is `:'
Add Comment
Please, Sign In to add comment