Simple bios interrupt hangs kernel

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
Tachi22
Posts: 3
Joined: Sat Mar 12, 2016 10:29 am
Libera.chat IRC: Tachi22

Simple bios interrupt hangs kernel

Post by Tachi22 »

Hello, I tried to use memory detection interrupt today and found out it hangs my Kernel. After few minutes of checking I found out every bios interrupt does that. I'm pretty sure I'm in Real Mode, so I have no idea what is problem.

I'm just doing it wrong probably, so I'm asking anyone who can help.

I've tried to put Set cursor Bios interrupt just before my C++ main method is called. Here is my code.

Code: Select all

.set ALIGN,    1<<0             # Zarovnanie modulov na stranku
.set MEMINFO,  1<<1             # Mapa pamate
.set FLAGS,    ALIGN | MEMINFO  # Vlajka pre "Multiboot"
.set MAGIC,    0x1BADB002       # Magicke cislo - na najdenie headeru
.set CHECKSUM, -(MAGIC + FLAGS) # Checksum prvych 4 riadkov


.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM

.section .bootstrap_stack, "aw", @nobits
stack_bottom:
.skip 16384 # 16384 B = 16KiB
stack_top:

movl %esp, %ebp

.section .text
.global _start
.type _start, @function
_start:
	movl $stack_top, %esp

	#Set registers for interrupt

	movb $0, %bh
	movb $2, %dh
	movb $2, %dl
	movb $0x02, %ah

	#hlt
	int $0x10 #Interrupt 0x10 hangs
	#hlt

	call kernelStartPoint

	cli
	hlt

.Lhang:
	jmp .Lhang

.size _start, . - _start
If anyone can help, thank you.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Simple bios interrupt hangs kernel

Post by Octocontrabass »

Tachi22 wrote:I'm pretty sure I'm in Real Mode,
You are not.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Simple bios interrupt hangs kernel

Post by kzinti »

Octocontrabass wrote:You are not.
LOL. +1

What makes you "pretty sure you are in real mode"?
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Simple bios interrupt hangs kernel

Post by osdever »

You are not in RM now, GRUB gives protected mode for you. Use some code from Text Mode Cursor for cursor position settings. You can't use any BIOS interrupts in PM.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
Tachi22
Posts: 3
Joined: Sat Mar 12, 2016 10:29 am
Libera.chat IRC: Tachi22

Re: Simple bios interrupt hangs kernel

Post by Tachi22 »

Thank you! As I thought, I did it completely wrong, but at least i've learned something new. I somehow didn't noticed that Grub automatically gives me Protected Mode... Does that mean, that I have to use information from Multiboot to detect Memory?
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Simple bios interrupt hangs kernel

Post by Octocontrabass »

Yep. The multiboot specification (it looks like you're using multiboot 1) will tell you everything you need to know to get a memory map from GRUB.
Tachi22
Posts: 3
Joined: Sat Mar 12, 2016 10:29 am
Libera.chat IRC: Tachi22

Re: Simple bios interrupt hangs kernel

Post by Tachi22 »

Thanks for information. Going to work now.
Post Reply