Screen flashes after interrupts are activated

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
mrjbom
Member
Member
Posts: 322
Joined: Sun Jul 21, 2019 7:34 am

Screen flashes after interrupts are activated

Post by mrjbom »

Hello.

I integrate interrupts on this guide.
Everything seems to work, but the screen flickers. I use GRUB as a loader, at the end of the article it is written how this error is fixed, but I do not understand where to insert it, in what part of the code.

Now my bootloader looks like this.
Last edited by mrjbom on Mon Dec 02, 2019 9:57 am, edited 1 time in total.
Octocontrabass
Member
Member
Posts: 5580
Joined: Mon Mar 25, 2013 7:01 pm

Re: Screen flashes after interrupts are activated

Post by Octocontrabass »

Nowhere. It's a bad idea to copy code you don't understand.

You need to set up the GDT before you can use the IDT, so perhaps read about the GDT first and come back if you have any questions.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: Screen flashes after interrupts are activated

Post by Klakap »

You can implement GDT table code from Interrupt tutorial to your code with:

Code: Select all

bits 32

%define MULTIBOOT_MAGIC 0x1BADB002
%define MULTIBOOT_FLAGS (1<<0 | 1<<1 | 1<<2)

section .text
align 4
multiboot_header:
    dd MULTIBOOT_MAGIC
    dd MULTIBOOT_FLAGS
    dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
    dd 0
    dd 0
    dd 0
    dd 0
    dd 0
    dd 0
    dd 800 ; width
    dd 600 ; height
    dd 32 ; bbp

global start
extern kmain

start:
  cli
  mov esp, stack_space
  push ebx
  push eax

  jmp load_gdt
 
  ;global descriptor table
  gdt:
 
  gdt_null:
  dq 0
 
  gdt_code:
  dw 0FFFFh
  dw 0
 
  db 0
  db 10011010b
  db 11001111b
  db 0
 
  gdt_data:
  dw 0FFFFh
  dw 0
 
  db 0
  db 10010010b
  db 11001111b
  db 0
 
  gdt_end:
 
  gdt_desc:
   dw gdt_end - gdt - 1
   dd gdt
 
  ;load gdt
  load_gdt:
    lgdt [gdt_desc]  ;load GDT

  call kmain
  hlt

section .bss
resb 8192
stack_space:
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: Screen flashes after interrupts are activated

Post by FusT »

You should write your own code, the code in the wiki is terrible.
Lots of duplication, no explanation on how it works, what it does, etc.

In OSdev it is vital that you understand what your code is doing and why. It will make debugging later on a lot easier.
User avatar
mrjbom
Member
Member
Posts: 322
Joined: Sun Jul 21, 2019 7:34 am

Re: Screen flashes after interrupts are activated

Post by mrjbom »

Klakap wrote:You can implement GDT table code from Interrupt tutorial to your code with:
Thanks for your help. I just did not know how to use the code from the tutorial.
User avatar
mrjbom
Member
Member
Posts: 322
Joined: Sun Jul 21, 2019 7:34 am

Re: Screen flashes after interrupts are activated

Post by mrjbom »

Klakap wrote:You can implement GDT table code from Interrupt tutorial to your code with...
Hello again.

I updated bootloader but it didn't solve the problem. I don't know what it is, it should have solved it. Do you know what else might be the problem? I hope for your help.

You can read the code in the repository

I hope you all will be clear, I don't have time to put in the repository, sorry.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: Screen flashes after interrupts are activated

Post by Klakap »

Code: Select all

  load_gdt:
  lgdt [gdt_desc]  ;load GDT
  mov ax, 0x10
  mov ds, ax
  mov es, ax
  mov fs, ax
  mov gs, ax
  mov ss, ax
  jmp 0x08:.setcs
  .setcs:
Here is problem. It should seems as:

Code: Select all

lgdt [gdt_desc]
jmp 0x0008:fix_cs

fix_cs:
mov ax, 0x0010
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax

mov esp, stack_space ;set stack pointer to your point

call kmain
Post Reply