Page 1 of 1

Simple bios interrupt hangs kernel

Posted: Sat Mar 12, 2016 3:59 pm
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.

Re: Simple bios interrupt hangs kernel

Posted: Sat Mar 12, 2016 4:38 pm
by Octocontrabass
Tachi22 wrote:I'm pretty sure I'm in Real Mode,
You are not.

Re: Simple bios interrupt hangs kernel

Posted: Sun Mar 13, 2016 1:20 am
by kzinti
Octocontrabass wrote:You are not.
LOL. +1

What makes you "pretty sure you are in real mode"?

Re: Simple bios interrupt hangs kernel

Posted: Sun Mar 13, 2016 1:25 am
by abcdef4bfd
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.

Re: Simple bios interrupt hangs kernel

Posted: Sun Mar 13, 2016 2:58 am
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?

Re: Simple bios interrupt hangs kernel

Posted: Sun Mar 13, 2016 6:00 am
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.

Re: Simple bios interrupt hangs kernel

Posted: Sun Mar 13, 2016 9:06 am
by Tachi22
Thanks for information. Going to work now.